Merge pull request #238 from ThemeBoy/tweak-codemirror
Add Codemirror to Custom CSS field
This commit is contained in:
@@ -538,6 +538,18 @@ table.widefat.sp-sortable-table tbody tr .icon {
|
||||
-webkit-transition: none;
|
||||
}
|
||||
|
||||
/* CodeMirror */
|
||||
|
||||
.sp-settings-section .CodeMirror {
|
||||
border: 1px solid #ddd;
|
||||
box-shadow: inset 0 1px 2px rgba(0,0,0,.07);
|
||||
}
|
||||
|
||||
.sp-settings-section .CodeMirror-gutters {
|
||||
background: #f9f9f9;
|
||||
border-color: #e1e1e1;
|
||||
}
|
||||
|
||||
/* Paragraph */
|
||||
.sp-para {
|
||||
margin: 1em 0;
|
||||
|
||||
@@ -57,3 +57,19 @@ function sp_get_screen_ids() {
|
||||
'edit-sp_role',
|
||||
) );
|
||||
}
|
||||
add_action( 'sportspress_settings_general', 'add_codemirror_to_custom_css' );
|
||||
function add_codemirror_to_custom_css() {
|
||||
// Enqueue code editor and settings for manipulating HTML.
|
||||
$settings = wp_enqueue_code_editor( array( 'type' => 'css' ) );
|
||||
// Bail if user disabled CodeMirror.
|
||||
if ( false === $settings ) {
|
||||
return;
|
||||
}
|
||||
wp_add_inline_script(
|
||||
'code-editor',
|
||||
sprintf(
|
||||
'jQuery( function() { wp.codeEditor.initialize( "sportspress_custom_css", %s ); } );',
|
||||
wp_json_encode( $settings )
|
||||
)
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user