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:
parent
a6e6817154
commit
1f2eb2f8b8
|
@ -341,11 +341,35 @@ jQuery('#template').submit(function(){
|
||||||
if (jQuery('#newcontent_cp').length)
|
if (jQuery('#newcontent_cp').length)
|
||||||
jQuery('#newcontent_cp').val(newcontent.getCode()).removeAttr('disabled');
|
jQuery('#newcontent_cp').val(newcontent.getCode()).removeAttr('disabled');
|
||||||
});
|
});
|
||||||
|
jQuery('#codepress-on').hide();
|
||||||
|
jQuery('#codepress-off').show();
|
||||||
/* ]]> */
|
/* ]]> */
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?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.
|
* Saves option for number of rows when listing posts, pages, comments, etc.
|
||||||
*
|
*
|
||||||
|
|
|
@ -3431,7 +3431,7 @@ function screen_meta($screen) {
|
||||||
if ( !isset($_wp_contextual_help) )
|
if ( !isset($_wp_contextual_help) )
|
||||||
$_wp_contextual_help = array();
|
$_wp_contextual_help = array();
|
||||||
|
|
||||||
$widgets_access = '';
|
$settings = '';
|
||||||
|
|
||||||
switch ( $screen ) {
|
switch ( $screen ) {
|
||||||
case 'post':
|
case 'post':
|
||||||
|
@ -3471,12 +3471,17 @@ function screen_meta($screen) {
|
||||||
$_wp_contextual_help[$screen] = $help;
|
$_wp_contextual_help[$screen] = $help;
|
||||||
}
|
}
|
||||||
break;
|
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':
|
case 'widgets':
|
||||||
if ( !isset($_wp_contextual_help['widgets']) ) {
|
if ( !isset($_wp_contextual_help['widgets']) ) {
|
||||||
$help = widgets_help();
|
$help = widgets_help();
|
||||||
$_wp_contextual_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;
|
$show_screen = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3500,7 +3505,7 @@ function screen_meta($screen) {
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php echo screen_layout($screen); ?>
|
<?php echo screen_layout($screen); ?>
|
||||||
<?php echo $screen_options; ?>
|
<?php echo $screen_options; ?>
|
||||||
<?php echo $widgets_access; ?>
|
<?php echo $settings; ?>
|
||||||
<div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div>
|
<div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -83,8 +83,8 @@ default:
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( use_codepress() )
|
||||||
wp_enqueue_script( 'codepress' );
|
wp_enqueue_script( 'codepress' );
|
||||||
add_action( 'admin_print_footer_scripts', 'codepress_footer_js' );
|
|
||||||
|
|
||||||
// List of allowable extensions
|
// List of allowable extensions
|
||||||
$editable_extensions = array('php', 'txt', 'text', 'js', 'css', 'html', 'htm', 'xml', 'inc', 'include');
|
$editable_extensions = array('php', 'txt', 'text', 'js', 'css', 'html', 'htm', 'xml', 'inc', 'include');
|
||||||
|
|
|
@ -77,8 +77,9 @@ default:
|
||||||
if ( !current_user_can('edit_themes') )
|
if ( !current_user_can('edit_themes') )
|
||||||
wp_die('<p>'.__('You do not have sufficient permissions to edit themes for this blog.').'</p>');
|
wp_die('<p>'.__('You do not have sufficient permissions to edit themes for this blog.').'</p>');
|
||||||
|
|
||||||
|
if ( use_codepress() )
|
||||||
wp_enqueue_script( 'codepress' );
|
wp_enqueue_script( 'codepress' );
|
||||||
add_action( 'admin_print_footer_scripts', 'codepress_footer_js' );
|
|
||||||
require_once('admin-header.php');
|
require_once('admin-header.php');
|
||||||
|
|
||||||
update_recently_edited($file);
|
update_recently_edited($file);
|
||||||
|
|
|
@ -2116,7 +2116,8 @@ td.plugin-title {
|
||||||
/* Global classes */
|
/* Global classes */
|
||||||
|
|
||||||
.wp-hidden-children .wp-hidden-child,
|
.wp-hidden-children .wp-hidden-child,
|
||||||
.ui-tabs-hide {
|
.ui-tabs-hide,
|
||||||
|
#codepress-off {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,8 +122,8 @@ CodePress.run = function() {
|
||||||
if (navigator.userAgent.toLowerCase().indexOf('webkit') != -1)
|
if (navigator.userAgent.toLowerCase().indexOf('webkit') != -1)
|
||||||
return;
|
return;
|
||||||
CodePress.path = codepress_path;
|
CodePress.path = codepress_path;
|
||||||
t = document.getElementsByTagName('textarea');
|
var t = document.getElementsByTagName('textarea'), i, id;
|
||||||
for(var i=0,n=t.length;i<n;i++) {
|
for(i=0,n=t.length;i<n;i++) {
|
||||||
if(t[i].className.match('codepress')) {
|
if(t[i].className.match('codepress')) {
|
||||||
id = t[i].id;
|
id = t[i].id;
|
||||||
t[i].id = id+'_cp';
|
t[i].id = id+'_cp';
|
||||||
|
|
Loading…
Reference in New Issue