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

git-svn-id: http://svn.automattic.com/wordpress/trunk@11530 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2009-06-07 01:52:44 +00:00
parent a6e6817154
commit 1f2eb2f8b8
6 changed files with 41 additions and 10 deletions

View File

@ -341,11 +341,35 @@ jQuery('#template').submit(function(){
if (jQuery('#newcontent_cp').length)
jQuery('#newcontent_cp').val(newcontent.getCode()).removeAttr('disabled');
});
jQuery('#codepress-on').hide();
jQuery('#codepress-off').show();
/* ]]> */
</script>
<?php
}
/**
* Determine whether to use CodePress or not.
*
* @since 2.8
**/
function use_codepress() {
if ( isset($_GET['codepress']) ) {
$on = 'on' == $_GET['codepress'] ? 'on' : 'off';
set_user_setting( 'codepress', $on );
} else {
$on = get_user_setting('codepress', 'on');
}
if ( 'on' == $on ) {
add_action( 'admin_print_footer_scripts', 'codepress_footer_js' );
return true;
}
return false;
}
/**
* Saves option for number of rows when listing posts, pages, comments, etc.
*

View File

@ -3431,7 +3431,7 @@ function screen_meta($screen) {
if ( !isset($_wp_contextual_help) )
$_wp_contextual_help = array();
$widgets_access = '';
$settings = '';
switch ( $screen ) {
case 'post':
@ -3471,12 +3471,17 @@ function screen_meta($screen) {
$_wp_contextual_help[$screen] = $help;
}
break;
case 'theme-editor':
case 'plugin-editor':
$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";
$show_screen = true;
break;
case 'widgets':
if ( !isset($_wp_contextual_help['widgets']) ) {
$help = widgets_help();
$_wp_contextual_help['widgets'] = $help;
}
$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";
$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";
$show_screen = true;
break;
}
@ -3500,7 +3505,7 @@ function screen_meta($screen) {
<?php endif; ?>
<?php echo screen_layout($screen); ?>
<?php echo $screen_options; ?>
<?php echo $widgets_access; ?>
<?php echo $settings; ?>
<div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div>
</form>
</div>

View File

@ -83,8 +83,8 @@ default:
exit;
}
wp_enqueue_script( 'codepress' );
add_action( 'admin_print_footer_scripts', 'codepress_footer_js' );
if ( use_codepress() )
wp_enqueue_script( 'codepress' );
// List of allowable extensions
$editable_extensions = array('php', 'txt', 'text', 'js', 'css', 'html', 'htm', 'xml', 'inc', 'include');

View File

@ -77,8 +77,9 @@ default:
if ( !current_user_can('edit_themes') )
wp_die('<p>'.__('You do not have sufficient permissions to edit themes for this blog.').'</p>');
wp_enqueue_script( 'codepress' );
add_action( 'admin_print_footer_scripts', 'codepress_footer_js' );
if ( use_codepress() )
wp_enqueue_script( 'codepress' );
require_once('admin-header.php');
update_recently_edited($file);

View File

@ -2116,7 +2116,8 @@ td.plugin-title {
/* Global classes */
.wp-hidden-children .wp-hidden-child,
.ui-tabs-hide {
.ui-tabs-hide,
#codepress-off {
display: none;
}

View File

@ -122,8 +122,8 @@ CodePress.run = function() {
if (navigator.userAgent.toLowerCase().indexOf('webkit') != -1)
return;
CodePress.path = codepress_path;
t = document.getElementsByTagName('textarea');
for(var i=0,n=t.length;i<n;i++) {
var t = document.getElementsByTagName('textarea'), i, id;
for(i=0,n=t.length;i<n;i++) {
if(t[i].className.match('codepress')) {
id = t[i].id;
t[i].id = id+'_cp';