Make WordPress Core

Changeset 11530


Ignore:
Timestamp:
06/07/2009 01:52:44 AM (15 years ago)
Author:
azaozz
Message:

Allow CodePress to be disabled from Screen Options, see #10027

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/misc.php

    r11450 r11530  
    342342        jQuery('#newcontent_cp').val(newcontent.getCode()).removeAttr('disabled');
    343343});
     344jQuery('#codepress-on').hide();
     345jQuery('#codepress-off').show();
    344346/* ]]> */
    345347</script>
    346348<?php
     349}
     350
     351/**
     352 * Determine whether to use CodePress or not.
     353 *
     354 * @since 2.8
     355**/
     356function use_codepress() {
     357
     358    if ( isset($_GET['codepress']) ) {
     359        $on = 'on' == $_GET['codepress'] ? 'on' : 'off';
     360        set_user_setting( 'codepress', $on );
     361    } else {
     362        $on = get_user_setting('codepress', 'on');
     363    }
     364
     365    if ( 'on' == $on ) {
     366        add_action( 'admin_print_footer_scripts', 'codepress_footer_js' );
     367        return true;
     368    }
     369
     370    return false;
    347371}
    348372
  • trunk/wp-admin/includes/template.php

    r11503 r11530  
    34323432        $_wp_contextual_help = array();
    34333433
    3434     $widgets_access = '';
     3434    $settings = '';
    34353435
    34363436    switch ( $screen ) {
     
    34723472            }
    34733473            break;
     3474        case 'theme-editor':
     3475        case 'plugin-editor':
     3476            $settings = '<p><a id="codepress-on" href="' . $screen . '.php?codepress=on">' . __('Enable syntax highlighting') . '</a><a id="codepress-off" href="' . $screen . '.php?codepress=off">' . __('Disable syntax highlighting') . "</a></p>\n";
     3477            $show_screen = true;
     3478            break;
    34743479        case 'widgets':
    34753480            if ( !isset($_wp_contextual_help['widgets']) ) {
     
    34773482                $_wp_contextual_help['widgets'] = $help;
    34783483            }
    3479             $widgets_access = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n";
     3484            $settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n";
    34803485            $show_screen = true;
    34813486            break;
     
    35013506<?php echo screen_layout($screen); ?>
    35023507<?php echo $screen_options; ?>
    3503 <?php echo $widgets_access; ?>
     3508<?php echo $settings; ?>
    35043509<div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div>
    35053510</form>
  • trunk/wp-admin/plugin-editor.php

    r11500 r11530  
    8484    }
    8585
    86     wp_enqueue_script( 'codepress' );
    87     add_action( 'admin_print_footer_scripts', 'codepress_footer_js' );
     86    if ( use_codepress() )
     87        wp_enqueue_script( 'codepress' );
    8888
    8989    // List of allowable extensions
  • trunk/wp-admin/theme-editor.php

    r11380 r11530  
    7878        wp_die('<p>'.__('You do not have sufficient permissions to edit themes for this blog.').'</p>');
    7979
    80     wp_enqueue_script( 'codepress' );
    81     add_action( 'admin_print_footer_scripts', 'codepress_footer_js' );
     80    if ( use_codepress() )
     81        wp_enqueue_script( 'codepress' );
     82
    8283    require_once('admin-header.php');
    8384
  • trunk/wp-admin/wp-admin.css

    r11526 r11530  
    21172117
    21182118.wp-hidden-children .wp-hidden-child,
    2119 .ui-tabs-hide {
     2119.ui-tabs-hide,
     2120#codepress-off {
    21202121    display: none;
    21212122}
  • trunk/wp-includes/js/codepress/codepress.js

    r10614 r11530  
    123123        return;
    124124    CodePress.path = codepress_path;
    125     t = document.getElementsByTagName('textarea');
    126     for(var i=0,n=t.length;i<n;i++) {
     125    var t = document.getElementsByTagName('textarea'), i, id;
     126    for(i=0,n=t.length;i<n;i++) {
    127127        if(t[i].className.match('codepress')) {
    128128            id = t[i].id;
Note: See TracChangeset for help on using the changeset viewer.