ID, '_SnS', true ); $SnS = is_array( $SnS ) ? $SnS: array(); $styles = isset( $SnS['styles'] ) ? $SnS[ 'styles' ]: array(); if ( ! empty( $styles[ 'classes_mce' ] ) ) array_unshift( $buttons, 'styleselect' ); return $buttons; } static function tiny_mce_before_init( $initArray ) { global $post; $SnS = get_post_meta( $post->ID, '_SnS', true ); $SnS = is_array( $SnS ) ? $SnS: array(); $styles = isset( $SnS['styles'] ) ? $SnS[ 'styles' ]: array(); // Add div as a format option, should probably use a string replace thing here. // Better yet, a setting for adding these. Postpone for now. //$initArray['theme_advanced_blockformats'] = "p,address,pre,h1,h2,h3,h4,h5,h6,div"; if ( ( ! empty( $styles[ 'classes_body' ] ) || ! empty( $styles[ 'classes_post' ] ) ) && ! isset( $initArray['body_class'] ) ) $initArray['body_class'] = ''; // Add body_class (and/or maybe post_class) values... somewhat problematic. if ( ! empty( $styles[ 'classes_body' ] ) ) $initArray['body_class'] .= ' ' . $styles[ 'classes_body' ]; if ( ! empty( $styles[ 'classes_post' ] ) ) $initArray['body_class'] .= ' ' . $styles[ 'classes_post' ]; // In case Themes or plugins have added style_formats, not tested. if ( isset( $initArray['style_formats'] ) ) $style_formats = json_decode( $initArray['style_formats'], true ); else $style_formats = array(); if ( ! empty( $styles[ 'classes_mce' ] ) ) foreach ( $styles[ 'classes_mce' ] as $format ) $style_formats[] = $format; if ( ! empty( $style_formats ) ) $initArray['style_formats'] = json_encode( $style_formats ); return $initArray; } /** * Admin Action: 'mce_css' * Adds a styles sheet to TinyMCE via ajax that contains the current styles data. */ static function mce_css( $mce_css ) { $url = admin_url( 'admin-ajax.php' ); $url = wp_nonce_url( $url, 'sns_tinymce_styles' ); $url = add_query_arg( 'post_id', get_the_ID(), $url ); $url = add_query_arg( 'action', 'sns_tinymce_styles', $url ); add_theme_support( 'editor-styles' ); add_editor_style( $url ); return $mce_css; } /** * Admin Action: 'add_meta_boxes' * Main Meta Box function. Checks restriction options and display options, calls add_meta_box() and adds actions for adding admin CSS and JavaScript. */ static function add_meta_boxes() { if ( current_user_can( 'unfiltered_html' ) ) { $post_type = get_current_screen()->post_type; if ( in_array( $post_type, get_post_types( array('show_ui' => true, 'public' => true ) ) ) ) { add_meta_box( 'SnS_meta_box', __( 'Scripts n Styles', 'scripts-n-styles' ), array( __CLASS__, 'admin_meta_box' ), $post_type, 'normal', 'high' ); add_filter( 'default_hidden_meta_boxes', array( __CLASS__, 'default_hidden_meta_boxes' ) ); add_action( "admin_print_styles", array( __CLASS__, 'meta_box_styles')); add_action( "admin_print_scripts", array( __CLASS__, 'meta_box_scripts')); add_filter( 'contextual_help', array( 'SnS_Admin', 'help' ) ); add_filter( 'mce_buttons_2', array( __CLASS__, 'mce_buttons_2' ) ); add_filter( 'tiny_mce_before_init', array( __CLASS__, 'tiny_mce_before_init' ) ); add_filter( 'replace_editor', array( __CLASS__, 'mce_css' ) ); } } } static function default_hidden_meta_boxes( $hidden ) { $options = get_option( 'SnS_options' ); if ( ! ( isset( $options[ 'metabox' ] ) && 'yes' == $options[ 'metabox' ] ) ) { $hidden[] = 'SnS_meta_box'; $hidden[] = 'SnS_shortcode'; } return $hidden; } /** * Admin Action: 'add_meta_boxes' * Outputs the Meta Box. Only called on callback from add_meta_box() during the add_meta_boxes action. * @param unknown_type WordPress Post object. */ static function admin_meta_box( $post ) { $registered_handles = Scripts_n_Styles::get_wp_registered(); $SnS = get_post_meta( $post->ID, '_SnS', true ); $SnS = is_array( $SnS ) ? $SnS: array(); $styles = isset( $SnS['styles'] ) ? $SnS[ 'styles' ]: array(); $scripts = isset( $SnS['scripts'] ) ? $SnS[ 'scripts' ]: array(); $html = isset( $SnS['html'] ) ? $SnS[ 'html' ]: array(); $position = get_user_option( "current_sns_tab" ); if ( ! in_array( $position, array( 's0', 's1', 's2', 's3', 's4', 's5', 's6' ) ) ) $position = 's0'; wp_nonce_field( Scripts_n_Styles::$file, self::NONCE_NAME ); ?>
verbatim in <script> tags at the end of your page's (or post's)", 'scripts-n-styles' ) ?> ...
... </head> .
... </body> .
verbatim in <style> tags in the <head> tag of your page (or post).', 'scripts-n-styles' ) ?>
space separated class names will be added to the body_class() or post_class() function (provided your theme uses these functions).', 'scripts-n-styles' ) ?>
' . esc_html( $handle ) . ' '; ?>
HTML for the head element", 'scripts-n-styles' ) ?> ...
HTML for the bottom of the body element", 'scripts-n-styles' ) ?> ...