public static function init() { if (!HeadwayCapabilities::can_user_visually_edit()) { return; } //If no child theme is active or if a child theme IS active and the grid is supported, use the grid mode. if (current_theme_supports('headway-grid')) { self::$modes['Grid'] = 'Add blocks and arrange your website structure'; } self::$modes['Design'] = 'Choose fonts, colors, and other styles'; //If the grid is disabled, set Design as the default mode. if (!current_theme_supports('headway-grid')) { self::$default_mode = 'design'; } //Attempt to raise memory limit to max @ini_set('memory_limit', apply_filters('headway_memory_limit', WP_MAX_MEMORY_LIMIT)); //Load libraries and content Headway::load('visual-editor/preview', 'VisualEditorPreview'); //Put in action so we can run top level functions do_action('headway_visual_editor_init'); //Visual Editor AJAX add_action('wp_ajax_headway_visual_editor', array(__CLASS__, 'ajax')); if (HeadwayOption::get('debug-mode')) { add_action('wp_ajax_nopriv_headway_visual_editor', array(__CLASS__, 'ajax')); } //Iframe handling add_action('headway_body_close', array(__CLASS__, 'iframe_load_flag')); add_action('headway_grid_iframe_footer', array(__CLASS__, 'iframe_load_flag')); }
public static function secure_method_save_options() { //Set up options parse_str(headway_post('options'), $options); if (HeadwayVisualEditor::save($options)) { echo 'success'; } }
/** * Register the panel. * * @param string Name of panel to be displayed * @param string ID of panel for HTML and options **/ public function register() { global $headway_registered_ve_boxes; if (!isset($headway_registered_ve_boxes)) { $headway_registered_ve_boxes = array(); } if (in_array($this->id, $headway_registered_ve_boxes)) { return false; } $mode = HeadwayVisualEditor::get_current_mode(); if ($this->mode === 'all' || strtolower($this->mode) === strtolower($mode)) { add_action('headway_visual_editor_boxes', array($this, 'build_box')); } if ($this->load_with_ajax) { add_action('headway_visual_editor_ajax_box_content_' . $this->id, array($this, 'content')); } $headway_registered_ve_boxes[] = $this->id; }
/** * Register the panel. * * @param string Name of panel to be displayed * @param string ID of panel for HTML and options **/ public function register() { $mode = HeadwayVisualEditor::get_current_mode(); /* Forward old Manage panels to Design */ if ($this->mode == 'manage') { $this->mode = 'design'; } if (strtolower($this->mode) !== strtolower($mode)) { return false; } /* Since there is a message that's displayed if there is no panel content, we have to tell it not to display the message now that * we're registering a panel */ remove_action('headway_visual_editor_panel_top', array('HeadwayVisualEditorDisplay', 'add_default_panel_link')); remove_action('headway_visual_editor_content', array('HeadwayVisualEditorDisplay', 'add_default_panel')); add_action('headway_visual_editor_panel_top', array($this, 'panel_link')); add_action('headway_visual_editor_content', array($this, 'build_panel')); if (method_exists($this, 'init')) { $this->init(); } }
/** * Direct index.php to the appropriate function * * @return bool **/ public static function direct() { //If viewing the visual editor, stop the template loading and show the visual editor. if (self::is_visual_editor()) { //If user is logged in and can't visually edit, loop them back to normal template. if (is_user_logged_in() && !HeadwayCapabilities::can_user_visually_edit()) { wp_die('You have insufficient permissions to use the Headway Visual Editor.<br /><br /><a href="' . home_url() . '">Return to Home</a>'); return false; //If the user isn't logged in at all, log 'em in and loop back to visual editor as long as debug mode isn't active } elseif (!is_user_logged_in() && !HeadwayOption::get('debug-mode')) { return auth_redirect(); } HeadwayVisualEditor::display(); die; //Theme Preview } elseif (self::is_theme_preview()) { return wp_die('Headway and Headway Child Themes cannot be previewed. Please activate the theme if you wish to see how it looks.'); } elseif (self::is_grid()) { Headway::load('visual-editor/iframe-grid'); HeadwayVisualEditorIframeGrid::show(); die; } }
<span class="save-button preview-button" id="inactive-preview-button">Preview</span> </div> '; } ?> </div><!-- #menu-right --> </div><!-- #menu --> <!-- Big Boy iframe --> <div id="iframe-container"> <?php $layout_url = HeadwayVisualEditor::get_current_mode() == 'grid' ? home_url() : HeadwayLayout::get_url(HeadwayLayout::get_current()); $iframe_url = add_query_arg(array('ve-iframe' => 'true', 've-layout' => HeadwayLayout::get_current(), 've-iframe-mode' => HeadwayVisualEditor::get_current_mode(), 'rand' => rand(1, 999999)), $layout_url); echo '<iframe id="content" class="content" src="' . $iframe_url . '" scrolling="no"></iframe>'; if (HeadwayVisualEditor::is_mode('grid')) { echo '<iframe id="preview" class="content" src="" style="display: none;" scrolling="no"></iframe>'; } echo '<div id="iframe-overlay"></div>'; echo '<div id="iframe-loading-overlay"><div class="cog-container"><div class="cog-bottom-left"></div><div class="cog-top-right"></div></div></div>'; ?> </div> <!-- #iframe#content --> <div id="panel"> <ul id="panel-top"> <?php do_action('headway_visual_editor_panel_top'); ?>
<?php if (!HeadwayVisualEditor::is_mode('grid') && current_theme_supports('headway-live-css')) { headway_register_visual_editor_box('HeadwayLiveCSSBox'); } class HeadwayLiveCSSBox extends HeadwayVisualEditorBoxAPI { /** * Slug/ID of panel. Will be used for HTML IDs and whatnot. **/ protected $id = 'live-css'; /** * Name of panel. This will be shown in the title. **/ protected $title = 'Live CSS'; protected $description = 'Enter custom CSS and it\'ll show instantly!'; /** * Which mode to put the panel on. **/ protected $mode = 'all'; protected $center = true; protected $width = 500; protected $height = 300; protected $min_width = 350; protected $min_height = 200; protected $closable = true; protected $draggable = true; protected $resizable = true; public function content() { echo '<textarea id="live-css" name="live-css" data-group="general">' . HeadwayOption::get('live-css') . '</textarea>';
public static function menu_links() { echo '<li id="menu-link-tools" class="menu-link-has-submenu"> <span>Tools</span> <ul>'; // echo '<li id="tools-undo"><span>Undo <small>Ctrl + Z</small></span></li> // <li id="tools-redo"><span>Redo <small>Ctrl + Y</small></span></li>'; if (HeadwayVisualEditor::is_mode('grid')) { echo '<li id="tools-grid-wizard"><span>Grid Wizard</span></li>'; } if (!HeadwayVisualEditor::is_mode('grid') && current_theme_supports('headway-live-css')) { echo '<li id="tools-live-css"><span>Live CSS <small>Ctrl + E</small></span></li>'; } if (HeadwayCompiler::can_cache()) { echo '<li id="tools-clear-cache"><span>Clear Cache' . (!HeadwayCompiler::caching_enabled() ? ' (Disabled)' : '') . '</span></li>'; } echo '<li id="tools-tour"><span>Tour</span></li> </ul> </li>'; echo '<li id="menu-link-admin" class="menu-link-has-submenu"> <span>Admin</span> <ul> <li><a href="' . admin_url() . '" target="_blank">Dashboard</a></li> <li><a href="' . admin_url('widgets.php') . '" target="_blank">Widgets</a></li> <li><a href="' . admin_url('nav-menus.php') . '" target="_blank">Menus</a></li> <li><a href="' . admin_url('admin.php?page=headway-options') . '" target="_blank">Headway Options</a></li> <li><a href="http://docs.headwaythemes.com" target="_blank">Documentation</a></li> <li><a href="http://support.headwaythemes.com" target="_blank">Support</a></li> </ul> </li>'; echo '<li id="menu-link-view-site"><a href="' . home_url() . '" target="_blank">View Site</a></li>'; }
public static function save_preview_options() { //Set up options parse_str(headway_get('unsaved'), $options); return HeadwayVisualEditor::save($options, HeadwayLayout::get_current(), 'grid'); }