Exemplo n.º 1
0
        /**
         * This function prints scripts after TinyMCE has been initialized for dynamic CSS in the
         * content editor based on page template dropdown selection.
         */
        public function tiny_mce_before_init($mceInit, $editor_id)
        {
            // Grab the Baton Customizer instance
            $baton_customizer = Baton_Customizer_Instance();
            // Default maximum width
            $max_width = 1272;
            // Determine if the max width theme mod is set
            if (($max_content_width = $baton_customizer->get_theme_mod('baton_max_width')) && $max_content_width !== $max_width) {
                $max_width = $max_content_width;
            }
            // Adjust max width for padding (22.5%)
            $max_width -= round($max_width * 0.225);
            // Only on the admin 'content' editor
            if (is_admin() && !isset($mceInit['setup']) && $editor_id === 'content') {
                $mceInit['setup'] = 'function( editor ) {
					// Editor init
					editor.on( "init", function( e ) {
						// Only on the "content" editor (other editors can inherit the setup function on init)
						if( editor.id === "content" ) {
							var $page_template = jQuery( "#page_template" ),
								full_width_templates = ["template-full-width.php", "template-landing-page.php"],
								$content_editor_head = jQuery( editor.getDoc() ).find( "head" );

							// If the page template dropdown exists
							if ( $page_template.length ) {
								// When the page template dropdown changes
								$page_template.on( "change", function() {
									// Is this a full width template?
									if ( full_width_templates.indexOf( $page_template.val() ) !== -1 ) {
										// Add dynamic CSS
										if( $content_editor_head.find( "#' . get_template() . '-editor-css" ).length === 0 ) {
											$content_editor_head.append( "<style type=\'text/css\' id=\'' . get_template() . '-editor-css\'> body, body.wp-autoresize { max-width: ' . $max_width . 'px; } </style>" );
										}
									}
									else {
										// Remove dynamic CSS
										$content_editor_head.find( "#' . get_template() . '-editor-css" ).remove();

										// If the full width style was added on TinyMCE Init, remove it
										$content_editor_head.find( "link[href^=\'' . get_template_directory_uri() . '/css/editor-style-full-width.css\']" ).remove();
									}
								} );
							}
						}
					} );
				}';
            }
            return $mceInit;
        }
Exemplo n.º 2
0
         */
        public function set_transient()
        {
            $sds_theme_options_instance = SDS_Theme_Options_Instance();
            // Grab the SDS_Theme_Options instance
            $data = array();
            // Default
            // Always add the Customizer CSS
            $data['customizer_css'] = $this->get_customizer_css();
            // Always add the theme's version
            $data['version'] = $sds_theme_options_instance->theme->get('Version');
            // Set the transient
            set_transient($this->transient_name, $data);
            return $data;
        }
        /**
         * This function deletes our transient data.
         */
        public function delete_transient()
        {
            // Delete the transient
            delete_transient($this->transient_name);
        }
    }
    function Baton_Customizer_Instance()
    {
        return Baton_Customizer::instance();
    }
    // Starts Baton Customizer
    Baton_Customizer_Instance();
}