page = add_theme_page( 'Visual Theme Editor', 'Visual Theme Editor', 'switch_themes', $this->slug, array( &$this, 'vte_render' ) ); add_action( "admin_print_styles-$this->page", array( &$this, 'init_styles' ) ); add_action( "admin_print_scripts-$this->page", array( &$this, 'init_scripts' ) ); } function init() { add_filter( "screen_settings", array( &$this, 'screen_options' ), 10, 2 ); add_action( 'wp_ajax_vte_save', array( &$this, 'ajax_save' ) ); // Requirements require_once('php/functions.php'); require_once('php/panels.php'); require_once('php/parse-css.php'); require_once('php/class-vte-style-ui.php'); // Style module included by default. // @TODO: Potentially rework the vte_init action or provide a _before method. add_action('vte_init', array('VTEStyleUI', 'init')); // Parse CSS if ( !defined('DOING_AJAX') ) { $parser = new CSSParser(); $vte_stylesheet = STYLESHEETPATH . '/vte-style.css'; $stylesheet = STYLESHEETPATH . '/style.css'; $exists = file_exists( $vte_stylesheet ); if ( $exists && isset( $_REQUEST['reset'] ) && $_REQUEST['reset'] ) { unlink( $vte_stylesheet ); } else if ( $exists ) { $stylesheet = $vte_stylesheet; } $this->rules = $parser->rules( file_get_contents( $stylesheet ), true ); } // Set mode $this->mode = isset( $_REQUEST['mode'] ) ? $_REQUEST['mode'] : 'vte-style'; do_action( 'vte_init', $this->mode ); } function vte_render() { include('php/ui/foundation.php'); } function init_styles() { $plugin = $this->get_plugin_url(); wp_enqueue_style('visual-theme-editor', $plugin . 'css/style.css'); wp_enqueue_style('visual-theme-editor-iframe', $plugin . 'css/iframe.css'); // Dynamic css references. echo ''; } function init_scripts() { $plugin = $this->get_plugin_url(); wp_enqueue_script('json2'); wp_enqueue_script('jquery'); wp_enqueue_script('jquery-color'); wp_enqueue_script('jquery-scrollTo', $plugin . 'js/jquery/jquery.scrollTo.js', // @todo: enqueue minified copy array('jquery'), '1.4', true); // Includes jQuery UI core, widget factory, position. wp_enqueue_script('vte-jquery-ui-custom', $plugin . 'js/jquery/jquery-ui-1.8.2.custom.min.js', array('jquery'), '1.8.2', true); wp_enqueue_script('visual-theme-editor', $plugin . 'js/visual-theme-editor.js', array('json2', 'vte-jquery-ui-custom', 'jquery-color', 'jquery-scrollTo'), false, true); wp_localize_script( 'visual-theme-editor', 'vteL10n', array( 'warnResetStyles' => __( "You are about to permanently reset this theme. \n 'Cancel' to stop, 'OK' to reset.", 'vte' ), 'alertSave' => __('The changes you made will be lost if you navigate away from this page.', 'vte'), 'msgSave' => __('Saved.', 'vte'), 'strProperty' => __('Property', 'vte'), 'strValue' => __('Value', 'vte') ) ); ?> id !== $this->page ) return $str; $out = ''; $modes = vte_get_modes(); foreach ( $modes as $mode_id => $mode ) { $out.= vte_screen_options( '', $mode_id, $mode['title'] ); } if ( ! empty( $out ) ) $str .= "

" . __( "Advanced Properties", "vte") . "

" . $out; return $str; } function mode_comparator( $a, $b ) { if ( $a['priority'] == $b['priority'] ) return 0; return ( $a['priority'] < $b['priority'] ) ? -1 : 1; } function ajax_save() { check_ajax_referer('vte_save', 'vte_save_nonce'); do_action("vte_save_$this->mode"); die('1'); } } ?>