'header', 'linking' => 'internal', 'side' => 'frontend', 'priority' => 5, 'language' => 'css', ); /** * Array with the options for a specific custom-css-js post */ private $options = array(); /** * Constructor */ public function __construct() { $this->add_functions(); } /** * Add actions and filters */ function add_functions() { // Add filters $filters = array( 'manage_custom-css-js_posts_columns' => 'manage_custom_posts_columns', ); foreach ( $filters as $_key => $_value ) { add_filter( $_key, array( $this, $_value ) ); } // Add actions $actions = array( 'admin_menu' => 'admin_menu', 'admin_enqueue_scripts' => 'admin_enqueue_scripts', 'current_screen' => 'current_screen', 'admin_notices' => 'create_uploads_directory', 'edit_form_after_title' => 'codemirror_editor', 'add_meta_boxes' => 'add_meta_boxes', 'save_post' => 'options_save_meta_box_data', 'trashed_post' => 'trash_post', 'untrashed_post' => 'trash_post', 'wp_ajax_ccj_active_code' => 'wp_ajax_ccj_active_code', 'wp_ajax_ccj_permalink' => 'wp_ajax_ccj_permalink', 'post_submitbox_start' => 'post_submitbox_start', 'restrict_manage_posts' => 'restrict_manage_posts', 'load-post.php' => 'contextual_help', 'load-post-new.php' => 'contextual_help', 'edit_form_before_permalink' => 'edit_form_before_permalink', 'before_delete_post' => 'before_delete_post', ); foreach ( $actions as $_key => $_value ) { add_action( $_key, array( $this, $_value ) ); } // Add some custom actions/filters add_action( 'manage_custom-css-js_posts_custom_column', array( $this, 'manage_posts_columns' ), 10, 2 ); add_filter( 'manage_edit-custom-css-js_sortable_columns', array( $this, 'manage_edit_posts_sortable_columns' ) ); add_action( 'posts_orderby', array( $this, 'posts_orderby' ), 10, 2 ); add_action( 'posts_join_paged', array( $this, 'posts_join_paged' ), 10, 2 ); add_action( 'posts_where_paged', array( $this, 'posts_where_paged' ), 10, 2 ); add_filter( 'post_row_actions', array( $this, 'post_row_actions' ), 10, 2 ); add_filter( 'parse_query', array( $this, 'parse_query' ), 10 ); add_filter( 'wp_statuses_get_supported_post_types', array( $this, 'wp_statuses_get_supported_post_types' ), 20 ); add_action( 'current_screen', array( $this, 'current_screen_2' ), 100 ); } /** * Add submenu pages */ function admin_menu() { $menu_slug = 'edit.php?post_type=custom-css-js'; $submenu_slug = 'post-new.php?post_type=custom-css-js'; remove_submenu_page( $menu_slug, $submenu_slug ); $title = __( 'Add Custom CSS', 'custom-css-js' ); add_submenu_page( $menu_slug, $title, $title, 'publish_custom_csss', $submenu_slug . '&language=css' ); $title = __( 'Add Custom JS', 'custom-css-js' ); add_submenu_page( $menu_slug, $title, $title, 'publish_custom_csss', $submenu_slug . '&language=js' ); $title = __( 'Add Custom HTML', 'custom-css-js' ); add_submenu_page( $menu_slug, $title, $title, 'publish_custom_csss', $submenu_slug . '&language=html' ); } /** * Enqueue the scripts and styles */ public function admin_enqueue_scripts( $hook ) { $screen = get_current_screen(); // Only for custom-css-js post type if ( $screen->post_type != 'custom-css-js' ) { return false; } // Some handy variables $a = plugins_url( '/', CCJ_PLUGIN_FILE ) . 'assets'; $cm = $a . '/codemirror'; $v = CCJ_VERSION; wp_enqueue_script( 'ccj-tipsy', $a . '/jquery.tipsy.js', array( 'jquery' ), $v, false ); wp_enqueue_style( 'ccj-tipsy', $a . '/tipsy.css', array(), $v ); wp_enqueue_script( 'ccj-cookie', $a . '/js.cookie.js', array( 'jquery' ), $v, false ); wp_register_script( 'ccj-admin', $a . '/ccj_admin.js', array( 'jquery', 'jquery-ui-resizable' ), $v, false ); wp_localize_script( 'ccj-admin', 'CCJ', $this->cm_localize() ); wp_enqueue_script( 'ccj-admin' ); wp_enqueue_style( 'ccj-admin', $a . '/ccj_admin.css', array(), $v ); // Only for the new/edit Code's page if ( $hook == 'post-new.php' || $hook == 'post.php' ) { wp_deregister_script( 'wp-codemirror' ); wp_enqueue_style( 'jquery-ui', 'https://code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css', array(), $v ); wp_enqueue_script( 'ccj-codemirror', $cm . '/lib/codemirror.js', array( 'jquery' ), $v, false ); wp_enqueue_style( 'ccj-codemirror', $cm . '/lib/codemirror.css', array(), $v ); wp_enqueue_script( 'ccj-admin_url_rules', $a . '/ccj_admin-url_rules.js', array( 'jquery' ), $v, false ); // Add the language modes $cmm = $cm . '/mode/'; wp_enqueue_script( 'cm-xml', $cmm . 'xml/xml.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'cm-js', $cmm . 'javascript/javascript.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'cm-css', $cmm . 'css/css.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'cm-htmlmixed', $cmm . 'htmlmixed/htmlmixed.js', array( 'ccj-codemirror' ), $v, false ); $cma = $cm . '/addon/'; wp_enqueue_script( 'ccj-closebrackets', $cma . 'edit/closebrackets.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'ccj-matchbrackets', $cma . 'edit/matchbrackets.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'ccj-matchtags', $cma . 'edit/matchtags.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'cm-dialog', $cma . 'dialog/dialog.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'cm-search', $cma . 'search/search.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'cm-searchcursor', $cma . 'search/searchcursor.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'cm-jump-to-line', $cma . 'search/jump-to-line.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'ccj-fullscreen', $cma . 'display/fullscreen.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_style( 'cm-dialog', $cma . 'dialog/dialog.css', array(), $v ); wp_enqueue_script( 'ccj-formatting', $cm . '/lib/util/formatting.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'ccj-comment', $cma . 'comment/comment.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'ccj-active-line', $cma . 'selection/active-line.js', array( 'ccj-codemirror' ), $v, false ); // Hint Addons wp_enqueue_script( 'ccj-hint', $cma . 'hint/show-hint.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'ccj-hint-js', $cma . 'hint/javascript-hint.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'ccj-hint-xml', $cma . 'hint/xml-hint.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'ccj-hint-html', $cma . 'hint/html-hint.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'ccj-hint-css', $cma . 'hint/css-hint.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'ccj-hint-anyword', $cma . 'hint/anyword-hint.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_style( 'ccj-hint', $cma . 'hint/show-hint.css', array(), $v ); // Fold Addons wp_enqueue_script( 'ccj-fold-brace', $cma . 'fold/brace-fold.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'ccj-fold-comment', $cma . 'fold/comment-fold.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'ccj-fold-code', $cma . 'fold/foldcode.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'ccj-fold-gutter', $cma . 'fold/foldgutter.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'ccj-fold-indent', $cma . 'fold/indent-fold.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'ccj-fold-markdown', $cma . 'fold/markdown-fold.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_script( 'ccj-fold-xml', $cma . 'fold/xml-fold.js', array( 'ccj-codemirror' ), $v, false ); wp_enqueue_style( 'ccj-fold-gutter', $cma . 'fold/foldgutter.css', array(), $v ); // remove the assets from other plugins so it doesn't interfere with CodeMirror global $wp_scripts; if ( is_array( $wp_scripts->registered ) && count( $wp_scripts->registered ) != 0 ) { foreach ( $wp_scripts->registered as $_key => $_value ) { if ( ! isset( $_value->src ) ) { continue; } if ( strstr( $_value->src, 'wp-content/plugins' ) !== false && strstr( $_value->src, 'plugins/custom-css-js/assets' ) === false && strstr( $_value->src, 'plugins/advanced-custom-fields/' ) === false && strstr( $_value->src, 'plugins/wp-jquery-update-test/' ) === false && strstr( $_value->src, 'plugins/enable-jquery-migrate-helper/' ) === false && strstr( $_value->src, 'plugins/tablepress/' ) === false && strstr( $_value->src, 'plugins/advanced-custom-fields-pro/' ) === false ) { unset( $wp_scripts->registered[ $_key ] ); } } } // remove the CodeMirror library added by the Product Slider for WooCommerce plugin by ShapedPlugin wp_enqueue_style( 'spwps-codemirror', $a . '/empty.css', '1.0' ); wp_enqueue_script( 'spwps-codemirror', $a . '/empty.js', array(), '1.0', true ); } } /** * Send variables to the ccj_admin.js script */ public function cm_localize() { global $wp_version; $settings = get_option( 'ccj_settings', array() ); $vars = array( 'wp_version' => $wp_version, 'autocomplete' => isset( $settings['ccj_autocomplete'] ) && ! $settings['ccj_autocomplete'] ? false : true, 'active' => __( 'Active', 'custom-css-js' ), 'inactive' => __( 'Inactive', 'custom-css-js' ), 'activate' => __( 'Activate', 'custom-css-js' ), 'deactivate' => __( 'Deactivate', 'custom-css-js' ), 'active_title' => __( 'The code is active. Click to deactivate it', 'custom-css-js' ), 'deactive_title' => __( 'The code is inactive. Click to activate it', 'custom-css-js' ), /* CodeMirror options */ 'codemirror' => array( 'indentUnit' => 4, 'indentWithTabs' => true, 'inputStyle' => 'contenteditable', 'lineNumbers' => true, 'lineWrapping' => true, 'styleActiveLine' => true, 'continueComments' => true, 'extraKeys' => array( 'Ctrl-Space' => 'autocomplete', 'Cmd-Space' => 'autocomplete', 'Ctrl-/' => 'toggleComment', 'Cmd-/' => 'toggleComment', 'Alt-F' => 'findPersistent', 'Ctrl-F' => 'findPersistent', 'Cmd-F' => 'findPersistent', 'Ctrl-J' => 'toMatchingTag', ), 'direction' => 'ltr', // Code is shown in LTR even in RTL languages. 'gutters' => array( 'CodeMirror-lint-markers' ), 'matchBrackets' => true, 'matchTags' => array( 'bothTags' => true ), 'autoCloseBrackets' => true, 'autoCloseTags' => true, ) ); return apply_filters( 'ccj_code_editor_settings', $vars); } public function add_meta_boxes() { add_meta_box( 'custom-code-options', __( 'Options', 'custom-css-js' ), array( $this, 'custom_code_options_meta_box_callback' ), 'custom-css-js', 'side', 'low' ); remove_meta_box( 'slugdiv', 'custom-css-js', 'normal' ); } /** * Get options for a specific custom-css-js post */ private function get_options( $post_id ) { if ( isset( $this->options[ $post_id ] ) ) { return $this->options[ $post_id ]; } $options = get_post_meta( $post_id ); if ( empty( $options ) || ! isset( $options['options'][0] ) ) { $this->options[ $post_id ] = $this->default_options; return $this->default_options; } if ( is_array( $options['options'][0] ) && isset( $options['options'][0]['type'] ) ) { return $options['options'][0]; } $options = @unserialize( $options['options'][0] ); $this->options[ $post_id ] = $options; return $options; } /** * Reformat the `edit` or the `post` screens */ function current_screen( $current_screen ) { if ( $current_screen->post_type != 'custom-css-js' ) { return false; } if ( $current_screen->base == 'post' ) { add_action( 'admin_head', array( $this, 'current_screen_post' ) ); } if ( $current_screen->base == 'edit' ) { add_action( 'admin_head', array( $this, 'current_screen_edit' ) ); } wp_deregister_script( 'autosave' ); } /** * Add the buttons in the `edit` screen */ function add_new_buttons() { $current_screen = get_current_screen(); if ( ( isset( $current_screen->action ) && $current_screen->action == 'add' ) || $current_screen->post_type != 'custom-css-js' ) { return false; } ?>
'', 'active' => '', 'type' => __( 'Type', 'custom-css-js' ), 'title' => __( 'Title' ), 'author' => __( 'Author' ), 'published' => __( 'Published' ), 'modified' => __( 'Modified', 'custom-css-js' ), ); } /** * Fill the data for the new added columns in the `edit` screen */ function manage_posts_columns( $column, $post_id ) { if ( 'type' === $column ) { $options = $this->get_options( $post_id ); echo '' . $options['language'] . ''; } if ( 'modified' === $column || 'published' === $column ) { $post = get_post( $post_id ); if ( '0000-00-00 00:00:00' === $post->post_date ) { $t_time = __( 'Unpublished' ); $h_time = $t_time; $time_diff = 0; } else { $time = ( 'published' === $column ) ? get_post_time( 'U', true, $post ) : get_post_modified_time( 'U', true, $post ); $time_diff = time() - $time; if ( $time && $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) { /* translators: %s: Human-readable time difference. */ $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); } else { $h_time = ( 'published' === $column ) ? get_the_time( __( 'Y/m/d' ), $post ) : get_the_modified_time( __( 'Y/m/d' ), $post ); } } echo $h_time; } if ( 'active' === $column ) { $url = wp_nonce_url( admin_url( 'admin-ajax.php?action=ccj_active_code&code_id=' . $post_id ), 'ccj-active-code-' . $post_id ); if ( $this->is_active( $post_id ) ) { $active_title = __( 'The code is active. Click to deactivate it', 'custom-css-js' ); $active_icon = 'dashicons-star-filled'; } else { $active_title = __( 'The code is inactive. Click to activate it', 'custom-css-js' ); $active_icon = 'dashicons-star-empty ccj_row'; } echo '' . '' . ''; } } /** * Make the 'Modified' column sortable */ function manage_edit_posts_sortable_columns( $columns ) { $columns['active'] = 'active'; $columns['type'] = 'type'; $columns['modified'] = 'modified'; $columns['published'] = 'published'; return $columns; } /** * List table: Change the query in order to filter by code type */ function parse_query( $query ) { global $wpdb; if ( ! is_admin() || ! $query->is_main_query() ) { return $query; } if ( ! isset( $query->query['post_type'] ) ) { return $query; } if ( 'custom-css-js' !== $query->query['post_type'] ) { return $query; } $filter = filter_input( INPUT_GET, 'language_filter' ); if ( ! is_string( $filter ) || strlen( $filter ) == 0 ) { return $query; } $filter = '%' . $wpdb->esc_like( $filter ) . '%'; $post_id_query = "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value LIKE %s"; $post_ids = $wpdb->get_col( $wpdb->prepare( $post_id_query, 'options', $filter ) ); if ( ! is_array( $post_ids ) || count( $post_ids ) == 0 ) { $post_ids = array( -1 ); } $query->query_vars['post__in'] = $post_ids; return $query; } /** * The "Publish"/"Update" button is missing if the "LH Archived Post Status" plugins is installed. */ function wp_statuses_get_supported_post_types( $post_types ) { unset( $post_types['custom-css-js'] ); return $post_types; } /** * List table: add a filter by code type */ function restrict_manage_posts( $post_type ) { if ( 'custom-css-js' !== $post_type ) { return; } $languages = array( 'css' => __( 'CSS Codes', 'custom-cs-js' ), 'js' => __( 'JS Codes', 'custom-css-js' ), 'html' => __( 'HTML Codes', 'custom-css-js' ), ); echo ''; echo ''; } /** * Order table by Type and Active columns */ function posts_orderby( $orderby, $query ) { if ( ! is_admin() ) { return $orderby; } global $wpdb; if ( 'custom-css-js' === $query->get( 'post_type' ) && 'type' === $query->get( 'orderby' ) ) { $orderby = "REGEXP_SUBSTR( {$wpdb->prefix}postmeta.meta_value, 'js|html|css') " . $query->get( 'order' ); } if ( 'custom-css-js' === $query->get( 'post_type' ) && 'active' === $query->get( 'orderby' ) ) { $orderby = "coalesce( postmeta1.meta_value, 'p' ) " . $query->get( 'order' ); } return $orderby; } /** * Order table by Type and Active columns */ function posts_join_paged( $join, $query ) { if ( ! is_admin() ) { return $join; } global $wpdb; if ( 'custom-css-js' === $query->get( 'post_type' ) && 'type' === $query->get( 'orderby' ) ) { $join = "LEFT JOIN {$wpdb->prefix}postmeta ON {$wpdb->prefix}posts.ID = {$wpdb->prefix}postmeta.post_id"; } if ( 'custom-css-js' === $query->get( 'post_type' ) && 'active' === $query->get( 'orderby' ) ) { $join = "LEFT JOIN (SELECT post_id AS ID, meta_value FROM {$wpdb->prefix}postmeta WHERE meta_key = '_active' ) as postmeta1 USING( ID )"; } return $join; } /** * Order table by Type and Active columns */ function posts_where_paged( $where, $query ) { if ( ! is_admin() ) { return $where; } global $wpdb; if ( 'custom-css-js' === $query->get( 'post_type' ) && 'type' === $query->get( 'orderby' ) ) { $where .= " AND {$wpdb->prefix}postmeta.meta_key = 'options'"; } return $where; } /** * Activate/deactivate a code * * @return void */ function wp_ajax_ccj_active_code() { if ( ! isset( $_GET['code_id'] ) ) { die(); } $code_id = absint( $_GET['code_id'] ); $response = 'error'; if ( check_admin_referer( 'ccj-active-code-' . $code_id ) ) { if ( 'custom-css-js' === get_post_type( $code_id ) ) { $active = get_post_meta( $code_id, '_active', true ); $active = ( $active !== 'no' ) ? $active = 'yes' : 'no'; update_post_meta( $code_id, '_active', $active === 'yes' ? 'no' : 'yes' ); $this->build_search_tree(); } } echo $active; die(); } /** * Check if a code is active * * @return bool */ function is_active( $post_id ) { return get_post_meta( $post_id, '_active', true ) !== 'no'; } /** * Reformat the `edit` screen */ function current_screen_edit() { ?> remove_unallowed_metaboxes(); $strings = array( 'Add CSS Code' => __( 'Add CSS Code', 'custom-css-js' ), 'Add JS Code' => __( 'Add JS Code', 'custom-css-js' ), 'Add HTML Code' => __( 'Add HTML Code', 'custom-css-js' ), 'Edit CSS Code' => __( 'Edit CSS Code', 'custom-css-js' ), 'Edit JS Code' => __( 'Edit JS Code', 'custom-css-js' ), 'Edit HTML Code' => __( 'Edit HTML Code', 'custom-css-js' ), ); if ( isset( $_GET['post'] ) ) { $action = 'Edit'; $post_id = esc_attr( $_GET['post'] ); } else { $action = 'Add'; $post_id = false; } $language = $this->get_language( $post_id ); $title = $action . ' ' . strtoupper( $language ) . ' Code'; $title = ( isset( $strings[ $title ] ) ) ? $strings[ $title ] : $strings['Add CSS Code']; if ( $action == 'Edit' ) { $title .= ' ' . __( 'Add CSS Code', 'custom-css-js' ) . ' '; $title .= '' . __( 'Add JS Code', 'custom-css-js' ) . ''; $title .= '' . __( 'Add HTML Code', 'custom-css-js' ) . ''; } ?> $_boxes ) { foreach ( $_boxes as $_key => $_value ) { if ( ! in_array( $_key, $allowed ) ) { unset( $wp_meta_boxes['custom-css-js']['side'][ $_priority ][ $_key ] ); } } } // Normal boxes $allowed = array( 'slugdiv', 'previewdiv', 'url-rules', 'revisionsdiv' ); $allowed = apply_filters( 'custom-css-js-meta-boxes-normal', $allowed ); foreach ( $wp_meta_boxes['custom-css-js']['normal'] as $_priority => $_boxes ) { foreach ( $_boxes as $_key => $_value ) { if ( ! in_array( $_key, $allowed ) ) { unset( $wp_meta_boxes['custom-css-js']['normal'][ $_priority ][ $_key ] ); } } } unset( $wp_meta_boxes['custom-css-js']['advanced'] ); } /** * Add the codemirror editor in the `post` screen */ public function codemirror_editor( $post ) { $current_screen = get_current_screen(); if ( $current_screen->post_type != 'custom-css-js' ) { return false; } if ( empty( $post->post_title ) && empty( $post->post_content ) ) { $new_post = true; $post_id = false; } else { $new_post = false; if ( ! isset( $_GET['post'] ) ) { $_GET['post'] = $post->id; } $post_id = esc_attr( $_GET['post'] ); } $language = $this->get_language( $post_id ); $settings = get_option( 'ccj_settings' ); // Replace the htmlentities (https://wordpress.org/support/topic/annoying-bug-in-text-editor/), but only selectively if ( isset( $settings['ccj_htmlentities'] ) && $settings['ccj_htmlentities'] == 1 && strstr( $post->post_content, '&' ) ) { // First the ampresands $post->post_content = str_replace( '&', htmlentities( '&' ), $post->post_content ); // Then the rest of the entities $html_flags = defined( 'ENT_HTML5' ) ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES; $entities = get_html_translation_table( HTML_ENTITIES, $html_flags ); unset( $entities[ array_search( '&', $entities ) ] ); $regular_expression = str_replace( ';', '', '/(' . implode( '|', $entities ) . ')/i' ); preg_match_all( $regular_expression, $post->post_content, $matches ); if ( isset( $matches[0] ) && count( $matches[0] ) > 0 ) { foreach ( $matches[0] as $_entity ) { $post->post_content = str_replace( $_entity, htmlentities( $_entity ), $post->post_content ); } } } if ( isset( $settings['ccj_htmlentities2'] ) && $settings['ccj_htmlentities2'] == 1 ) { $post->post_content = htmlentities( $post->post_content ); } switch ( $language ) { case 'js': if ( $new_post ) { $post->post_content = __( '/* Add your JavaScript code here. If you are using the jQuery library, then don\'t forget to wrap your code inside jQuery.ready() as follows: jQuery(document).ready(function( $ ){ // Your code in here }); -- If you want to link a JavaScript file that resides on another server (similar to ), then please use the "Add HTML Code" page, as this is a HTML code that links a JavaScript file. End of comment */ ', 'custom-css-js' ) . PHP_EOL . PHP_EOL; } $code_mirror_mode = 'text/javascript'; $code_mirror_before = ''; break; case 'html': if ( $new_post ) { $post->post_content = __( ' ', 'custom-css-js' ) . PHP_EOL . PHP_EOL; } $code_mirror_mode = 'html'; $code_mirror_before = ''; $code_mirror_after = ''; break; case 'php': if ( $new_post ) { $post->post_content = '/* The following will be executed as if it were written in functions.php. */' . PHP_EOL . PHP_EOL; } $code_mirror_mode = 'php'; $code_mirror_before = ''; break; default: if ( $new_post ) { $post->post_content = __( '/* Add your CSS code here. For example: .example { color: red; } For brushing up on your CSS knowledge, check out http://www.w3schools.com/css/css_syntax.asp End of comment */ ', 'custom-css-js' ) . PHP_EOL . PHP_EOL; } $code_mirror_mode = 'text/css'; $code_mirror_before = ''; } ?>
  post_status ) { echo ''; if ( $last_user = get_userdata( get_post_meta( $post->ID, '_edit_last', true ) ) ) { printf( __( 'Last edited by %1$s on %2$s at %3$s', 'custom-css-js-pro' ), esc_html( $last_user->display_name ), mysql2date( get_option( 'date_format' ), $post->post_modified ), mysql2date( get_option( 'time_format' ), $post->post_modified ) ); } else { printf( __( 'Last edited on %1$s at %2$s', 'custom-css-js-pro' ), mysql2date( get_option( 'date_format' ), $post->post_modified ), mysql2date( get_option( 'time_format' ), $post->post_modified ) ); } echo ''; } ?>
get_options( $post->ID ); if ( ! isset( $options['preprocessor'] ) ) { $options['preprocessor'] = 'none'; } if ( isset( $_GET['language'] ) ) { $options['language'] = $this->get_language(); } $meta = $this->get_options_meta(); if ( $options['language'] == 'html' ) { $meta = $this->get_options_meta_html(); } $options['multisite'] = false; wp_nonce_field( 'options_save_meta_box_data', 'custom-css-js_meta_box_nonce' ); ?>
$a ) { $close_div = false; if ( ( $_key == 'preprocessor' && $options['language'] == 'css' ) || ( $_key == 'linking' && $options['language'] == 'html' ) || in_array( $_key, ['priority', 'minify', 'multisite' ] ) ) { $close_div = true; $output .= '
'; } // Don't show Pre-processors for JavaScript Codes if ( $options['language'] == 'js' && $_key == 'preprocessor' ) { continue; } $output .= '

' . esc_attr( $a['title'] ) . '

' . PHP_EOL; $output .= $this->render_input( $_key, $a, $options ); if ( $close_div ) { $output .= '
'; } } echo $output; ?>
Simple Custom CSS and JS Pro', 'custom-css-js' ); ?>
array( 'title' => __( 'Linking type', 'custom-css-js' ), 'type' => 'radio', 'default' => 'internal', 'values' => array( 'external' => array( 'title' => __( 'External File', 'custom-css-js' ), 'dashicon' => 'media-code', ), 'internal' => array( 'title' => __( 'Internal', 'custom-css-js' ), 'dashicon' => 'editor-alignleft', ), ), ), 'type' => array( 'title' => __( 'Where on page', 'custom-css-js' ), 'type' => 'radio', 'default' => 'header', 'values' => array( 'header' => array( 'title' => __( 'In the element', 'custom-css-js' ), 'dashicon' => 'arrow-up-alt2', ), 'footer' => array( 'title' => __( 'In the