示例#1
0
/**
 * Starts the GZIP output buffer.
 *
 * @return bool
 **/
function headway_gzip()
{
    //If zlib is not loaded, we can't gzip.
    if (!extension_loaded('zlib')) {
        return false;
    }
    //If zlib.output_compression is on, do not gzip
    if (ini_get('zlib.output_compression') == 1) {
        return false;
    }
    //If a cache system is active then do not gzip
    if (defined('WP_CACHE') && WP_CACHE) {
        return false;
    }
    //Allow headway_gzip filter to cancel gzip compression.
    if (!($gzip = apply_filters('headway_gzip', HeadwayOption::get('enable-gzip', false, true)))) {
        return false;
    }
    //If gzip has already happened, then just return.
    if (in_array('ob_gzhandler', ob_list_handlers())) {
        return;
    }
    ob_start('ob_gzhandler');
    return true;
}
示例#2
0
 /**
  * Checks if the user can access the visual editor.
  * 
  * @uses headway_user_level()
  * @uses HeadwayOption::get()
  *
  * @return bool
  **/
 public static function can_user_visually_edit($ignore_debug_mode = false)
 {
     if (!$ignore_debug_mode && HeadwayOption::get('debug-mode')) {
         return true;
     }
     return is_user_logged_in() && self::can_user('headway_visual_editor');
 }
示例#3
0
 public static function init()
 {
     self::check_option_groups();
     if (headway_get('ve-preview') && HeadwayCapabilities::can_user_visually_edit()) {
         HeadwayOption::$group_suffix = '_preview';
     }
 }
示例#4
0
 public static function is_enabled()
 {
     //If the theme doesn't support the responsive grid, then disable it.
     if (!current_theme_supports('headway-grid') || !current_theme_supports('headway-responsive-grid')) {
         return false;
     }
     return HeadwayOption::get('enable-responsive-grid', false, false);
 }
示例#5
0
 /**
  * Echos the Powered By Headway link.
  * 
  * @uses HeadwayOption::get()
  *
  * @param string $text The name of the program to be displayed.  Defaults to Headway (obviously).
  * 
  * @return mixed
  **/
 public static function show_headway_link()
 {
     if (HeadwayOption::get('affiliate-link')) {
         $headway_location = strip_tags(HeadwayOption::get('affiliate-link'));
     } else {
         $headway_location = 'http://headwaythemes.com/';
     }
     echo apply_filters('headway_link', '<p class="footer-left footer-headway-link footer-link">' . __('Powered by Headway, the ', 'headway') . ' <a href="' . $headway_location . '" title="Headway Premium WordPress Theme">drag and drop WordPress theme</a></p>');
 }
示例#6
0
 public static function feed_url($feed)
 {
     //Do not change the URL of comment feed URLs.
     if (strpos($feed, 'comment') !== false) {
         return $feed;
     }
     $feed_url = HeadwayOption::get('feed-url');
     //If the feed URL option doesn't have http[://] at the beginning, then we're a no go on changing the feed URL.
     if (!$feed_url || strpos($feed_url, 'http') !== 0) {
         return $feed;
     }
     return $feed_url;
 }
示例#7
0
 public static function add_editor_style($css)
 {
     if (HeadwayOption::get('disable-editor-style', false, false)) {
         return $css;
     }
     if (!current_theme_supports('editor-style')) {
         return $css;
     }
     if (!current_theme_supports('headway-design-editor')) {
         return $css;
     }
     HeadwayCompiler::register_file(array('name' => 'editor-style', 'format' => 'css', 'fragments' => array('headway_content_block_editor_style'), 'dependencies' => array(HEADWAY_LIBRARY_DIR . '/blocks/content/editor-style.php'), 'enqueue' => false));
     return $css . ',' . HeadwayCompiler::get_url('editor-style');
 }
示例#8
0
 /**
  * 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;
     }
 }
示例#9
0
 public static function get_grid_width($wrapper)
 {
     if (!is_array($wrapper)) {
         return false;
     }
     /* If wrapper is mirrored then use settings from it for the grid */
     if ($potential_wrapper_mirror = HeadwayWrappers::get_wrapper_mirror($wrapper)) {
         $wrapper = $potential_wrapper_mirror;
     }
     $column_width = headway_get('use-independent-grid', $wrapper) ? headway_get('column-width', $wrapper) : HeadwayOption::get('column-width', false, HeadwayWrappers::$default_column_width);
     $gutter_width = headway_get('use-independent-grid', $wrapper) ? headway_get('gutter-width', $wrapper) : HeadwayOption::get('gutter-width', false, HeadwayWrappers::$default_gutter_width);
     return $column_width * headway_get('columns', $wrapper) + (headway_get('columns', $wrapper) - 1) * $gutter_width;
 }
示例#10
0
 public static function add_template($template_name = null, $blocks = null, $wrappers = null)
 {
     $templates = HeadwayOption::get('list', 'templates', array());
     $last_template_id = HeadwayOption::get('last-id', 'templates', 0);
     /* These  two variables be used for when a blocks/wrappers imported ID is different than the one that it ends up with... i.g. skin importing to line up instances */
     $block_id_translations = array();
     $wrapper_id_translations = array();
     /* Build name */
     $id = $last_template_id + 1;
     $template_name = $template_name ? $template_name : 'Template ' . $id;
     /* Add template to templates array so it can be sent to DB */
     $templates[$id] = $template_name;
     /* Send array to DB */
     HeadwayOption::set('list', $templates, 'templates');
     HeadwayOption::set('last-id', $id, 'templates');
     /* Add blocks and wrappers */
     if ($blocks && $wrappers) {
         /* Format wrappers */
         foreach ($wrappers as $wrapper_id => $wrapper_settings) {
             $old_wrapper_id = $wrapper_id;
             $new_wrapper = HeadwayWrappers::add_wrapper('template-' . $id, $wrapper_settings);
             $wrapper_id_translations[str_replace('wrapper-', '', $old_wrapper_id)] = array('id' => $new_wrapper['id'], 'layout' => 'template-' . $id);
         }
         /* Add blocks */
         foreach ($blocks as $block) {
             $old_block_id = $block['id'];
             unset($block['id']);
             unset($block['layout']);
             /* Update block's wrapper ID to match the real ID of the imported wrapper because if you link to the old ID from the export file then it won't match up */
             $block['wrapper'] = 'wrapper-' . $wrapper_id_translations[str_replace('wrapper-', '', $block['wrapper'])]['id'];
             $new_block_id = HeadwayBlocksData::add_block('template-' . $id, $block);
             $block_id_translations[$old_block_id] = $new_block_id;
         }
     }
     /* End adding wrappers and blocks */
     return array('id' => $id, 'name' => $template_name, 'block-id-translations' => $block_id_translations, 'wrapper-id-translations' => $wrapper_id_translations);
 }
示例#11
0
 public function update_notice()
 {
     if (!is_super_admin() || HeadwayOption::get('disable-update-notices', false, false) || !($update_info = $this->retrieve_update_info())) {
         return;
     }
     $changelog_url = headway_get('changelog_url', $update_info, false);
     $new_version = headway_get('new_version', $update_info);
     $valid_key = headway_get('is_valid_key', $update_info, false);
     if ($valid_key === true) {
         if (!$this->notify_only) {
             echo sprintf(__('<div id="update-nag">%s %s is now available, you\'re running %s! <a href="%s">Click here to update</a> or <a href="%s" target="_blank">learn more</a> about the update.</div>', 'headway'), $this->name, $new_version, $this->current_version, admin_url('update-core.php'), str_replace('{KEY}', headway_get_license_key(), $changelog_url));
         } else {
             echo sprintf(__('<div id="update-nag">%s %s is now available, you\'re running %s! Go to the <a href="%s" target="_blank">Headway Dashboard</a> to download the latest version or <a href="%s" target="_blank">learn more</a> about the update.</div>', 'headway'), $this->name, $new_version, $this->current_version, HEADWAY_DASHBOARD_URL, str_replace('{KEY}', headway_get_license_key(), $changelog_url));
         }
         return true;
     } else {
         switch ($valid_key) {
             case 'expired':
                 echo sprintf(__('<div id="update-nag">%s %s is now available, you\'re running %s!  Your Headway license has expired.  Please visit the <a href="%s">Headway Dashboard</a> to renew your license so you can continue to receive updates.</div>', 'headway'), $this->name, $new_version, $this->current_version, HEADWAY_DASHBOARD_URL);
                 break;
             default:
                 echo sprintf(__('<div id="update-nag">%s %s is now available, you\'re running %s!  You will not be able to update until you enter a valid license key on the <a href="%s">Headway Options</a> panel.</div>', 'headway'), $this->name, $new_version, $this->current_version, admin_url('admin.php?page=headway-options'));
                 break;
         }
         return false;
     }
 }
示例#12
0
 /**
  * For some reason, the 'blocks-by-id', 'blocks-by-type', and 'blocks-by-layout' options become blank.  This will restore them.
  **/
 public static function repair_blocks()
 {
     global $wpdb;
     /* Build layout options catalog */
     $catalog = array();
     foreach (wp_load_alloptions() as $option => $option_value) {
         if (strpos($option, 'headway_layout_options_') !== 0 || $option == 'headway_layout_options_catalog' || strpos($option, 'headway_layout_options_') === 0 && substr($option, -8) == '_preview') {
             continue;
         }
         $catalog[] = str_replace('headway_layout_options_', '', $option);
     }
     /* Set up blank arrays */
     $blocks_by_id = array();
     $blocks_by_type = array();
     $blocks_by_layout = array();
     foreach ($catalog as $layout) {
         /* If the layout is numeric, then check if the post even exists and isn't a revision.  If it does not exist or is a revision, delete it! */
         if (is_numeric($layout)) {
             $post_row = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE ID = %d LIMIT 1", $layout));
             if ($post_row) {
                 $post_status = get_post_status($layout);
             }
             /* If the post row is false (doesn't exist) or post status is revision (AKA inherit) then delete the whole layout option group */
             if (!$post_row || $post_status == 'inherit') {
                 delete_option('headway_layout_options_' . $layout);
                 continue;
             }
         }
         $layout_options = get_option('headway_layout_options_' . $layout);
         //If there are no blocks, then skip the layout
         if (!isset($layout_options['general']['blocks']) || !is_array($layout_options['general']['blocks'])) {
             continue;
         }
         /* If the layout ID is template then change the underscore to a hyphen */
         if (strpos($layout, 'template_') === 0) {
             $layout = str_replace('template_', 'template-', $layout);
         }
         $layout_blocks = $layout_options['general']['blocks'];
         //If the layout is a template, then skip these two conditionals
         if (strpos($layout, 'template') !== 0) {
             //If the layout doesn't have any blocks, then remove the customized flag if it exists.
             if (!isset($layout_blocks) || !is_array($layout_blocks) || count($layout_blocks) === 0) {
                 HeadwayLayoutOption::delete($layout, 'customized');
                 continue;
             }
             //If the layout isn't customized and doesn't have a template assigned,
             //then nuke those blocks from the layout options and do not include them in the main block options
             if ((!isset($layout_options['general']['customized']) || $layout_options['general']['customized'] !== 'true') && (!isset($layout_options['general']['template']) || $layout_options['general']['template'] === 'false')) {
                 HeadwayLayoutOption::delete($layout, 'blocks');
                 continue;
             }
         }
         foreach ($layout_blocks as $block_id => $block) {
             /* Blocks by ID */
             $blocks_by_id[$block['id']] = array('layout' => $layout, 'type' => $block['type']);
             /* Blocks by type */
             if (!isset($blocks_by_type[$block['type']])) {
                 $blocks_by_type[$block['type']] = array();
             }
             $blocks_by_type[$block['type']][$block['id']] = $layout;
             /* Blocks by layout */
             if (!isset($blocks_by_layout[$layout])) {
                 $blocks_by_layout[$layout] = array();
             }
             $blocks_by_layout[$layout][$block['id']] = true;
         }
     }
     HeadwayOption::set('blocks-by-type', $blocks_by_type, 'blocks');
     HeadwayOption::set('blocks-by-id', $blocks_by_id, 'blocks');
     HeadwayOption::set('blocks-by-layout', $blocks_by_layout, 'blocks');
     return true;
 }
示例#13
0
 protected function modify_arguments($post = false)
 {
     //Do not use this box if the page being edited is the front page since they can edit the setting in the configuration.
     if (get_option('page_on_front') == headway_get('post') && get_option('show_on_front') == 'page') {
         $this->info = '<strong>Configure the SEO settings for this page (Front Page) in the Headway Search Engine Optimization settings tab in <a href="' . admin_url('admin.php?page=headway-options#tab-seo-content') . '" target="_blank">Headway &raquo; Configuration</a>.</strong>';
         $this->inputs = array();
         return;
     }
     //Setup the defaults for the title and checkboxes
     $current_screen = get_current_screen();
     $seo_templates_query = HeadwayOption::get('seo-templates', 'general', HeadwaySEO::output_layouts_and_defaults());
     $seo_templates = headway_get('single-' . $current_screen->id, $seo_templates_query, array());
     $title_template = str_replace(array('%sitename%', '%SITENAME%'), get_bloginfo('name'), headway_get('title', $seo_templates));
     echo '<input type="hidden" id="title-seo-template" value="' . $title_template . '" />';
     $this->inputs['noindex']['default'] = headway_get('noindex', $seo_templates);
     $this->inputs['nofollow']['default'] = headway_get('nofollow', $seo_templates);
     $this->inputs['noarchive']['default'] = headway_get('noarchive', $seo_templates);
     $this->inputs['nosnippet']['default'] = headway_get('nosnippet', $seo_templates);
     $this->inputs['noodp']['default'] = headway_get('noodp', $seo_templates);
     $this->inputs['noydir']['default'] = headway_get('noydir', $seo_templates);
 }
示例#14
0
 public static function delete_special_element_properties($element_group, $element_id, $special_element_type, $special_element_meta)
 {
     $element = HeadwayOption::get($element_id, 'design-editor-group-' . $element_group);
     /* Delete all special elements matching the meta and type */
     if (isset($element['special-element-' . $special_element_type][$special_element_meta])) {
         unset($element['special-element-' . $special_element_type][$special_element_meta]);
     }
     /* Send it back to DB */
     return HeadwayOption::set($element_id, $element, 'design-editor-group-' . $element_group);
 }
示例#15
0
 public function display()
 {
     if (!$this->blocks) {
         return $this->display_no_blocks_message();
     }
     foreach ($this->wrappers as $wrapper_id => $wrapper_settings) {
         $wrapper_id_for_blocks = $wrapper_id;
         /* Check if mirroring.  If mirroring, change wrapper ID to the wrapper being mirrored and preserve original ID for a later class */
         if ($wrapper_being_mirrored = HeadwayWrappers::get_wrapper_mirror($wrapper_settings)) {
             $mirrored_wrapper_id = $wrapper_being_mirrored['id'];
             $wrapper_id_for_blocks = $mirrored_wrapper_id;
             foreach (HeadwayBlocksData::get_blocks_by_wrapper($wrapper_being_mirrored['layout'], $mirrored_wrapper_id) as $block_from_mirrored_wrapper) {
                 $this->blocks[$block_from_mirrored_wrapper['id']] = $block_from_mirrored_wrapper;
             }
         }
         /* Grab blocks belonging to this wrapper */
         $wrapper_blocks = array();
         foreach ($this->blocks as $block_id => $block) {
             if (headway_get('wrapper', $block, HeadwayWrappers::$default_wrapper_id) === $wrapper_id_for_blocks) {
                 $wrapper_blocks[$block_id] = $block;
             }
             /* If there's only one wrapper and the block does not have a proper ID or is default, move it to that wrapper */
             if (count($this->wrappers) === 1 && (headway_get('wrapper', $block) === null || headway_get('wrapper', $block) == 'wrapper-default' || !isset($this->wrappers[headway_get('wrapper', $block)]))) {
                 $wrapper_blocks[$block_id] = $block;
             }
         }
         /* Setup wrapper classes */
         $wrapper_column_width = headway_get('use-independent-grid', $wrapper_settings) ? headway_get('column-width', $wrapper_settings) : HeadwayOption::get('column-width', false, HeadwayWrappers::$default_column_width);
         $wrapper_gutter_width = headway_get('use-independent-grid', $wrapper_settings) ? headway_get('gutter-width', $wrapper_settings) : HeadwayOption::get('gutter-width', false, HeadwayWrappers::$default_gutter_width);
         $wrapper_classes = array('wrapper');
         $wrapper_classes[] = $wrapper_settings['fluid'] ? 'wrapper-fluid' : 'wrapper-fixed';
         $wrapper_classes[] = HeadwayResponsiveGrid::is_active() ? 'responsive-grid' : null;
         $wrapper_classes[] = headway_get('use-independent-grid', $wrapper_settings) ? 'independent-grid' : null;
         $wrapper_classes[] = 'grid-' . ($wrapper_settings['fluid-grid'] || HeadwayResponsiveGrid::is_enabled() ? 'fluid' : 'fixed') . '-' . $wrapper_settings['columns'] . '-' . $wrapper_column_width . '-' . $wrapper_gutter_width;
         $wrapper_classes[] = $wrapper_being_mirrored ? 'wrapper-mirroring-' . HeadwayWrappers::format_wrapper_id($mirrored_wrapper_id) : null;
         $last_wrapper_id = array_slice(array_keys($this->wrappers), -1, 1);
         $last_wrapper_id = $last_wrapper_id[0];
         $first_wrapper_id = array_keys($this->wrappers);
         $first_wrapper_id = $first_wrapper_id[0];
         if ($last_wrapper_id == $wrapper_id) {
             $wrapper_classes[] = 'wrapper-last';
         } else {
             if ($first_wrapper_id == $wrapper_id) {
                 $wrapper_classes[] = 'wrapper-first';
             }
         }
         /* Custom wrapper classes */
         $custom_css_classes = explode(' ', str_replace('  ', ' ', str_replace(',', ' ', htmlspecialchars(strip_tags(headway_get('css-classes', $wrapper_settings, ''))))));
         $wrapper_classes = array_merge($wrapper_classes, $custom_css_classes);
         /* Display the wrapper */
         do_action('headway_before_wrapper');
         echo '<div id="' . $wrapper_id . '" class="' . implode(' ', array_unique(array_filter($wrapper_classes))) . '">' . "\n\n";
         do_action('headway_wrapper_open');
         $wrapper = new HeadwayGridRenderer($wrapper_blocks, $wrapper_settings);
         $wrapper->render_grid();
         do_action('headway_wrapper_close');
         echo '</div><!-- .wrapper -->' . "\n\n";
         do_action('headway_after_wrapper');
         /* End displaying wrapper */
     }
 }
示例#16
0
 public static function save($options, $current_layout = false, $mode = false)
 {
     if (!$current_layout) {
         $current_layout = headway_post('layout');
     }
     if (!$mode) {
         $mode = headway_post('mode');
     }
     //Handle triple slash bullshit
     if (get_magic_quotes_gpc() === 1) {
         $options = array_map('stripslashes_deep', $options);
     }
     $blocks = isset($options['blocks']) ? $options['blocks'] : null;
     $wrappers = isset($options['wrappers']) ? $options['wrappers'] : null;
     $layout_options = isset($options['layout-options']) ? $options['layout-options'] : null;
     $options_inputs = isset($options['options']) ? $options['options'] : null;
     $design_editor_inputs = isset($options['design-editor']) ? $options['design-editor'] : null;
     //Set the current layout to customized if it's the grid mode
     if ($mode == 'grid') {
         HeadwayLayoutOption::set($current_layout, 'customized', true);
     }
     /* Blocks */
     if ($blocks) {
         foreach ($blocks as $id => $methods) {
             foreach ($methods as $method => $value) {
                 switch ($method) {
                     case 'new':
                         if (HeadwayBlocksData::get_block($id)) {
                             continue;
                         }
                         $dimensions = explode(',', $blocks[$id]['dimensions']);
                         $position = explode(',', $blocks[$id]['position']);
                         $settings = isset($blocks[$id]['settings']) ? $blocks[$id]['settings'] : array();
                         $args = array('id' => $id, 'type' => $value, 'position' => array('left' => $position[0], 'top' => $position[1]), 'dimensions' => array('width' => $dimensions[0], 'height' => $dimensions[1]), 'settings' => $settings);
                         HeadwayBlocksData::add_block($current_layout, $args);
                         break;
                     case 'delete':
                         HeadwayBlocksData::delete_block($current_layout, $id);
                         break;
                     case 'dimensions':
                         $dimensions = explode(',', $value);
                         $args = array('dimensions' => array('width' => $dimensions[0], 'height' => $dimensions[1]));
                         HeadwayBlocksData::update_block($current_layout, $id, $args);
                         break;
                     case 'position':
                         $position = explode(',', $value);
                         $args = array('position' => array('left' => $position[0], 'top' => $position[1]));
                         HeadwayBlocksData::update_block($current_layout, $id, $args);
                         break;
                     case 'wrapper':
                         $args = array('wrapper' => $value);
                         HeadwayBlocksData::update_block($current_layout, $id, $args);
                         break;
                     case 'settings':
                         //Retrieve all blocks from layout
                         $layout_blocks = HeadwayBlocksData::get_blocks_by_layout($current_layout);
                         //Get the block from the layout
                         $block = headway_get($id, $layout_blocks);
                         //If block doesn't exist, we can't do anything.
                         if (!$block) {
                             continue;
                         }
                         //If there aren't any options, then don't do anything either
                         if (!is_array($value) || count($value) === 0) {
                             continue;
                         }
                         $block['settings'] = array_merge($block['settings'], $value);
                         HeadwayBlocksData::update_block($current_layout, $id, $block);
                         break;
                 }
             }
         }
     }
     /* End Blocks */
     /* Wrappers */
     if ($wrappers) {
         /* Pluck last-id out of wrappers and send it to DB */
         if (headway_get('last-id', $wrappers)) {
             $last_id = $wrappers['last-id'];
             unset($wrappers['last-id']);
             HeadwayOption::set('last-id', $last_id, 'wrappers');
         }
         /* Save layout wrappers to dB */
         HeadwayOption::set($current_layout, $wrappers, 'wrappers');
     }
     /* End Wrappers */
     /* Layout Options */
     if ($layout_options) {
         foreach ($layout_options as $group => $options) {
             foreach ($options as $option => $value) {
                 HeadwayLayoutOption::set($current_layout, $option, $value, $group);
             }
         }
     }
     /* End Layout Options */
     /* Options */
     if ($options_inputs) {
         foreach ($options_inputs as $group => $options) {
             foreach ($options as $option => $value) {
                 HeadwayOption::set($option, $value, $group);
             }
         }
     }
     /* End Options */
     /* Design Editor Inputs */
     if ($design_editor_inputs) {
         /* If skin import is set to true then nuke all design settings to prevent overlapping settings */
         if (headway_get('skin-import', $design_editor_inputs)) {
             HeadwayElementsData::delete_all();
         }
         /* End skin import nuke */
         /* Handle skin templates */
         $skin_templates = headway_get('skin-import-templates', $design_editor_inputs);
         if (is_array($skin_templates) && count($skin_templates)) {
             $skin_template_block_id_translations = array();
             $skin_template_wrapper_id_translations = array();
             foreach ($skin_templates as $skin_template_name => $skin_template_blocks) {
                 /* Pluck wrappers array out of blocks array */
                 $skin_template_wrappers = $skin_template_blocks['wrappers'];
                 unset($skin_template_blocks['wrappers']);
                 $template = HeadwayLayout::add_template($skin_template_name, $skin_template_blocks, $skin_template_wrappers);
                 /* Use + rather than array_merge because + preserves numeric keys */
                 $skin_template_block_id_translations = $skin_template_block_id_translations + $template['block-id-translations'];
                 $skin_template_wrapper_id_translations = $skin_template_wrapper_id_translations + $template['wrapper-id-translations'];
             }
             /* Re-map block IDs in instances according to block ID translations */
             foreach ($design_editor_inputs as $element_id => $element_data) {
                 if (!is_array($element_data) || !isset($element_data['special-element-instance'])) {
                     continue;
                 }
                 foreach ($element_data['special-element-instance'] as $instance_id => $instance_properties) {
                     $instance_id_fragments = explode('-', $instance_id);
                     $instance_potential_block_id_search = preg_match('/\\bblock\\b\\-[0-9]+/', $instance_id, $instance_potential_block_id_search_results);
                     $instance_potential_block_id = str_replace('block-', '', end($instance_potential_block_id_search_results));
                     $instance_potential_wrapper_id = $instance_id_fragments[1];
                     /* Wrapper instance conditional. Modify new instance ID accordingly */
                     if (strpos($instance_id, 'wrapper-') === 0 && isset($skin_template_wrapper_id_translations[intval($instance_potential_wrapper_id)])) {
                         $new_wrapper_id = $skin_template_wrapper_id_translations[intval($instance_potential_wrapper_id)]['id'];
                         $new_wrapper_layout = $skin_template_wrapper_id_translations[intval($instance_potential_wrapper_id)]['layout'];
                         $new_instance_id = 'wrapper-' . $new_wrapper_id . '-layout-' . $new_wrapper_layout;
                         /* Block instance conditional.  Modify new instance ID accordingly */
                     } else {
                         if (strpos($instance_id, 'block-') !== false && is_numeric($instance_potential_block_id) && isset($skin_template_block_id_translations[intval($instance_potential_block_id)])) {
                             $new_block_id = $skin_template_block_id_translations[intval($instance_potential_block_id)];
                             $new_instance_id = str_replace('block-' . $instance_potential_block_id, 'block-' . $new_block_id, $instance_id);
                             /* Not a proper block or wrapper instance, just skip it */
                         } else {
                             continue;
                         }
                     }
                     /* Remove existing instance key/value pair */
                     unset($design_editor_inputs[$element_id]['special-element-instance'][$instance_id]);
                     /* Add new instance key/value pair with new instance ID */
                     $design_editor_inputs[$element_id]['special-element-instance'][$new_instance_id] = $instance_properties;
                 }
             }
         }
         /* End skin template handling */
         /* Loop through to get every element and its properties */
         foreach ($design_editor_inputs as $element_id => $element_data) {
             if (!is_array($element_data) || !isset($element_data['group'])) {
                 continue;
             }
             $element_group = $element_data['group'];
             //Dispatch depending on type of element data
             foreach ($element_data as $element_data_node => $element_data_node_data) {
                 //Handle different nodes depending on what they are
                 if ($element_data_node == 'properties') {
                     //Set each property for the regular element
                     foreach ($element_data_node_data as $property_id => $property_value) {
                         HeadwayElementsData::set_property($element_group, $element_id, $property_id, $property_value);
                     }
                     //Handle instances, states, etc.
                 } else {
                     if (strpos($element_data_node, 'special-element-') === 0) {
                         $special_element_type = str_replace('special-element-', '', $element_data_node);
                         //Loop through the special elements
                         foreach ($element_data_node_data as $special_element => $special_element_properties) {
                             //Set the special element properties now
                             foreach ($special_element_properties as $special_element_property => $special_element_property_value) {
                                 HeadwayElementsData::set_special_element_property($element_group, $element_id, $special_element_type, $special_element, $special_element_property, $special_element_property_value);
                             }
                         }
                     }
                 }
             }
         }
         /* End loop */
     }
     /* End Design Editor Inputs */
     //This hook is used by cache flushing, plugins, etc.  Do not fire on preview save because it'll flush preview options
     if (!headway_get('ve-preview')) {
         do_action('headway_visual_editor_save');
     }
     return true;
 }
示例#17
0
 public static function flush_cache()
 {
     return HeadwayOption::delete('webfont-cache');
 }
示例#18
0
 public function render_input($input)
 {
     //Fill defaults
     $defaults = array('tooltip' => false, 'default' => false, 'callback' => null);
     //Merge defaults
     $input = array_merge($defaults, $input);
     //Fix up inputs
     $input = $this->parse_function_args($input);
     if (!isset($input['name']) || !isset($input['type'])) {
         return;
     }
     /* Set up main input variables */
     $input['name'] = strtolower($input['name']);
     $input['group'] = isset($input['group']) ? $input['group'] : $this->options_group;
     $input['tooltip'] = isset($input['tooltip']) && $input['tooltip'] != false ? $input['tooltip'] : false;
     /* Populate the value */
     $input['default'] = isset($input['default']) ? $input['default'] : null;
     if (isset($this->wrapper) && $this->wrapper && !isset($input['value'])) {
         $input['value'] = HeadwayWrappers::get_wrapper_setting($this->wrapper, $input['name'], $input['default']);
     } else {
         if (isset($this->block) && $this->block && !isset($input['value'])) {
             $input['value'] = HeadwayBlocksData::get_block_setting($this->block, $input['name'], $input['default']);
         } else {
             if (!isset($input['value'])) {
                 $input['value'] = HeadwayOption::get($input['name'], $input['group'], $input['default']);
             }
         }
     }
     /* Setup Attributes */
     $attributes_array = array('id' => isset($this->block) && $this->block ? 'input-' . $this->block['id'] . '-' . $input['name'] : 'input-' . $input['group'] . '-' . $input['name'], 'name' => $input['name'], 'data-group' => $input['group']);
     /* Set up the callback attribute */
     $attributes_array['data-callback'] = htmlspecialchars('(function(args){var input=args.input;var value=args.value;var block=args.block || null;' . $input['callback'] . '})');
     /* Set up data handler override if it's used */
     if (headway_get('data-handler-callback', $input)) {
         $attributes_array['data-data-handler-callback'] = htmlspecialchars('(function(args){' . $input['data-handler-callback'] . '})');
     }
     /* Set up toggle attribute */
     if (headway_get('toggle', $input)) {
         $attributes_array['data-toggle'] = htmlspecialchars(json_encode($input['toggle']));
     }
     /* No save attribute */
     if (headway_get('no-save', $input, false)) {
         $attributes_array['data-no-save'] = 'true';
     }
     /* Turn attributes array into a string for HTML */
     $input['attributes'] = '';
     foreach ($attributes_array as $attribute => $attribute_value) {
         $input['attributes'] .= $attribute . '="' . $attribute_value . '" ';
     }
     $input['attributes'] = trim($input['attributes']);
     /* If it's a repeater then handle it before it's handled as an input */
     if ($input['type'] == 'repeater') {
         return $this->repeater($input);
     }
     /* Handle regular input */
     if (method_exists($this, 'input_' . str_replace('-', '_', $input['type']))) {
         /* Handle all types except for raw HTML input */
         if ($input['type'] != 'raw-html') {
             echo '<div class="input input-' . $input['type'] . '" id="input-' . $input['name'] . '">';
             if ($input['tooltip']) {
                 echo '<div class="tooltip-button" title="' . htmlspecialchars($input['tooltip']) . '"></div>';
             }
             call_user_func(array($this, 'input_' . str_replace('-', '_', $input['type'])), $input);
             echo '</div><!-- #input-' . $input['name'] . ' -->';
         } else {
             call_user_func(array($this, 'input_' . str_replace('-', '_', $input['type'])), $input);
         }
     }
     /* End regular input handling */
 }
示例#19
0
 /**
  * @return bool
  **/
 public static function flush_cache($hard = false)
 {
     //Flush Headway cache if it is active.
     if (self::can_cache()) {
         //Delete the Headway cache option if hard flush otherwise delete the ones that aren't set to stay with soft flush
         if ($hard) {
             HeadwayOption::delete('cache');
         } else {
             $cache = HeadwayOption::get('cache');
             foreach ($cache as $cached_file_id => $cached_file) {
                 if (!headway_get('require-hard-flush', $cached_file, false)) {
                     unset($cache[$cached_file_id]);
                 }
             }
             HeadwayOption::set('cache', $cache);
         }
         //Set do not delete list
         $no_delete = array('..', '.');
         if ($handle = opendir(HEADWAY_CACHE_DIR)) {
             while (false !== ($file = readdir($handle))) {
                 if (in_array($file, $no_delete) || strpos($file, 'hard-cache') !== false && !$hard) {
                     continue;
                 }
                 @unlink(HEADWAY_CACHE_DIR . '/' . $file);
             }
             closedir($handle);
         }
     }
     //Flush plugin caches
     self::flush_plugin_caches();
     return true;
 }
示例#20
0
HeadwayAdminInputs::generate($form);
?>
						
			<h3 class="title title-hr">Admin</h3>
			
			<?php 
$form = array(array('type' => 'checkbox', 'label' => 'Version Number', 'checkboxes' => array(array('id' => 'hide-menu-version-number', 'label' => 'Hide Headway Version Number From Menu', 'checked' => HeadwayOption::get('hide-menu-version-number', false, false))), 'description' => 'Check this if you wish to have the Menu say "Headway" instead of "Headway ' . HEADWAY_VERSION . '"'), array('type' => 'checkbox', 'label' => 'Update Notices', 'checkboxes' => array(array('id' => 'disable-update-notices', 'label' => 'Disable Headway Update Notices', 'checked' => HeadwayOption::get('disable-update-notices', false, false))), 'description' => 'If you wish to hide the notices that appear when an update is available for Headway, check this.'), array('type' => 'checkbox', 'label' => 'Editor Style', 'checkboxes' => array(array('id' => 'disable-editor-style', 'label' => 'Disable Editor Style', 'checked' => HeadwayOption::get('disable-editor-style', false, false))), 'description' => 'By default, Headway will take any settings in the Design Editor and add them to <a href="http://codex.wordpress.org/TinyMCE" target="_blank">WordPress\' TinyMCE editor</a> style.  Use this option to prevent that.'));
HeadwayAdminInputs::generate($form);
?>
			
			<h3 class="title title-hr">Debugging</h3>
			
			<div class="alert alert-red"><p>The following option should only be checked if a member of the Headway Themes team asks you to do so.</p></div>
			
			<?php 
$form = array(array('type' => 'checkbox', 'label' => 'Debug Mode', 'checkboxes' => array(array('id' => 'debug-mode', 'label' => 'Enable Debug Mode', 'checked' => HeadwayOption::get('debug-mode', false, false))), 'description' => 'Having Debug Mode enabled will allow the Headway Themes team to access the Visual Editor for support purposes, but <strong>will not allow changes to be saved<strong>.'));
HeadwayAdminInputs::generate($form);
?>
			
		</div>
		
		
	</div>

	<div class="hr hr-submit" style="display: none;"></div>

	<p class="submit" style="display: none;">
		<input type="submit" name="headway-submit" value="Save Changes" class="button-primary headway-save" />
	</p>
	
</form>
示例#21
0
 public static function export_skin($skin_name = 'Unnamed', $include_live_css = false, $included_templates = false)
 {
     do_action('headway_before_export_skin');
     /* Set up variables */
     $element_data = HeadwayElementsData::get_all_elements();
     $skin = array('name' => $skin_name, 'element-data' => $element_data);
     if ($include_live_css) {
         $skin['live-css'] = HeadwayOption::get('live-css');
     }
     /* If templates are to be included then query for them and convert all mirrored blocks into original blocks by pulling their mirror target's settings */
     if (is_array($included_templates)) {
         $skin['templates'] = array();
         $white_listed_block_instances = array();
         $white_listed_wrapper_instances = array();
         foreach ($included_templates as $template_id) {
             $template_name = HeadwayLayout::get_name('template-' . $template_id);
             $template_blocks = HeadwayBlocksData::get_blocks_by_layout('template-' . $template_id);
             $template_wrappers = HeadwayWrappers::get_layout_wrappers('template-' . $template_id);
             /* Loop through each block in the template and check if it's mirrored.  If it is, replace it with the block that it's mirroring */
             foreach ($template_blocks as $template_block_index => $template_block) {
                 if (!($mirrored_block = HeadwayBlocksData::is_block_mirrored($template_block))) {
                     /* Allow this block's instances to be in the skin */
                     $white_listed_block_instances[] = $template_block['id'];
                     /* Delete mirror option in case it's present */
                     if (isset($template_blocks[$template_block_index]['settings']['mirror-block'])) {
                         unset($template_blocks[$template_block_index]['settings']['mirror-block']);
                     }
                     continue;
                 }
                 $template_blocks[$template_block_index]['id'] = $mirrored_block['id'];
                 $template_blocks[$template_block_index]['settings'] = $mirrored_block['settings'];
                 /* Allow this block's instances to be in the skin */
                 $white_listed_block_instances[] = $mirrored_block['id'];
             }
             /* Whitelist wrapper instances */
             foreach ($template_wrappers as $template_wrapper_id => $template_wrapper_settings) {
                 $white_listed_wrapper_instances[] = $template_wrapper_id;
             }
             $skin['templates'][$template_name] = $template_blocks;
             $skin['templates'][$template_name]['wrappers'] = $template_wrappers;
         }
     }
     /* Need to remove instances that aren't in the included templates and layout specific customizations from $element_data here */
     foreach ($skin['element-data'] as $element_id => $element) {
         /* Add in the element group that way it can be saved @since 3.4.8 */
         $element_registration = HeadwayElementAPI::get_element($element_id);
         $skin['element-data'][$element_id]['group'] = $element_registration['group'];
         /* Remove instances that aren't in this skin's templates */
         if (isset($element['special-element-instance'])) {
             /* White list doesn't exist, just remove all instances */
             if (!isset($white_listed_block_instances)) {
                 unset($skin['element-data'][$element_id]['special-element-instance']);
                 /* White List Exists, loop through each instance and check its ID */
             } else {
                 foreach ($skin['element-data'][$element_id]['special-element-instance'] as $instance_id => $properties) {
                     $instance_id_fragments = explode('-', $instance_id);
                     $instance_potential_block_id_search = preg_match('/\\bblock\\b\\-[0-9]+/', $instance_id, $instance_potential_block_id_search_results);
                     $instance_potential_block_id = str_replace('block-', '', end($instance_potential_block_id_search_results));
                     $instance_potential_wrapper_id = $instance_id_fragments[0] . '-' . $instance_id_fragments[1];
                     /* Wrapper instance conditional.  If a positive match, CONTINUE that way the unset doesn't happen */
                     if (strpos($instance_id, 'wrapper-') === 0 && in_array($instance_potential_wrapper_id, $white_listed_wrapper_instances)) {
                         continue;
                     } else {
                         if (strpos($instance_id, 'block-') !== false && is_numeric($instance_potential_block_id) && in_array($instance_potential_block_id, $white_listed_block_instances)) {
                             continue;
                         }
                     }
                     /* Delete the instance if it doesn't match the block OR wrapper whitelist */
                     unset($skin['element-data'][$element_id]['special-element-instance'][$instance_id]);
                 }
             }
         }
         /* Remove layout-specific customizations from the skin */
         if (isset($element['special-element-layout'])) {
             unset($skin['element-data'][$element_id]['special-element-layout']);
         }
     }
     /* Spit the file out */
     return self::to_json('Headway Skin - ' . $skin_name, 'skin', $skin);
 }
示例#22
0
 public static function add_visual_editor_js_vars()
 {
     //Gather the URLs for the block types
     $block_types = HeadwayBlocks::get_block_types();
     $block_type_urls = array();
     foreach ($block_types as $block_type => $block_type_options) {
         $block_type_urls[$block_type] = $block_type_options['url'];
     }
     $block_styles = class_exists('HeadwayChildThemeAPI') ? HeadwayChildThemeAPI::get_block_style_classes() : array();
     $current_layout_status = HeadwayLayout::get_status(HeadwayLayout::get_current());
     $script_name = is_ssl() ? 'headway-ve-js-https' : 'headway-ve-js';
     wp_localize_script($script_name, 'Headway', array('ajaxURL' => admin_url('admin-ajax.php'), 'currentLayout' => HeadwayLayout::get_current(), 'currentLayoutName' => HeadwayLayout::get_name(HeadwayLayout::get_current()), 'currentLayoutCustomized' => $current_layout_status['customized'], 'currentLayoutTemplate' => $current_layout_status['template'], 'availableBlockID' => HeadwayBlocksData::get_available_block_id(), 'availableWrapperID' => HeadwayWrappers::get_available_wrapper_id(), 'headwayURL' => get_template_directory_uri(), 'siteURL' => site_url(), 'homeURL' => home_url(), 'adminURL' => admin_url(), 'mode' => HeadwayVisualEditor::get_current_mode(), 'designEditorSupport' => current_theme_supports('headway-design-editor'), 'siteName' => get_bloginfo('name'), 'siteDescription' => get_bloginfo('description'), 'security' => wp_create_nonce('headway-visual-editor-ajax'), 'ranTour' => json_encode(array('legacy' => HeadwayOption::get('ran-tour', false, false), 'grid' => HeadwayOption::get('ran-tour-grid', false, false), 'design' => HeadwayOption::get('ran-tour-design', false, false))), 'blockTypeURLs' => json_encode($block_type_urls), 'allBlockTypes' => json_encode($block_types), 'disableCodeMirror' => HeadwayOption::get('disable-codemirror', false, false), 'frontPage' => get_option('show_on_front', 'posts'), 'gridSupported' => current_theme_supports('headway-grid'), 'disableTooltips' => HeadwayOption::get('disable-visual-editor-tooltips', false, false), 'blockStyles' => $block_styles, 'responsiveGrid' => HeadwayResponsiveGrid::is_enabled(), 'designEditorProperties' => HeadwayVisualEditor::is_mode('design') ? json_encode(HeadwayElementProperties::get_properties()) : json_encode(array()), 'colorpickerSwatches' => HeadwayOption::get('colorpicker-swatches', false, array()), 'gridSafeMode' => HeadwayOption::get('grid-safe-mode', false, false), 'defaultGridColumnCount' => HeadwayWrappers::$default_columns, 'globalGridColumnWidth' => HeadwayWrappers::$global_grid_column_width, 'globalGridGutterWidth' => HeadwayWrappers::$global_grid_gutter_width, 'touch' => stripos($_SERVER['HTTP_USER_AGENT'], 'iPad') !== false ? true : false));
 }
示例#23
0
 /**
  * To promote caching on browsers, Headway can tell WordPress to not put in the query variables on the style and script URLs.
  **/
 public static function remove_dependency_query_vars($query)
 {
     if (!HeadwayOption::get('remove-dependency-query-vars', 'general', false) && !HeadwayRoute::is_visual_editor_iframe()) {
         return $query;
     }
     return remove_query_arg('ver', $query);
 }
示例#24
0
 public static function clear_block_actions_cache()
 {
     HeadwayOption::set('init', array(), 'block-actions-cache');
     HeadwayOption::set('enqueue', array(), 'block-actions-cache');
     HeadwayOption::set('dynamic-js', array(), 'block-actions-cache');
     HeadwayOption::set('dynamic-css', array(), 'block-actions-cache');
     HeadwayOption::set('block-objects', array(), 'block-actions-cache');
     return HeadwayOption::set('cached', false, 'block-actions-cache');
 }
示例#25
0
 static function live_css()
 {
     if (headway_get('visual-editor-open')) {
         return null;
     }
     return HeadwayOption::get('live-css');
 }
示例#26
0
 public static function parent_menu()
 {
     $menu_setup = HeadwayOption::get('menu-setup', false, 'getting-started');
     /* Figure out the primary page */
     switch ($menu_setup) {
         case 'getting-started':
             $parent_menu = array('id' => 'getting-started', 'name' => 'Getting Started', 'callback' => array('HeadwayAdminPages', 'getting_started'));
             break;
         case 'visual-editor':
             $parent_menu = array('id' => 'visual-editor', 'name' => 'Visual Editor', 'callback' => array('HeadwayAdminPages', 'visual_editor'));
             break;
         case 'options':
             $parent_menu = array('id' => 'options', 'name' => 'Options', 'callback' => array('HeadwayAdminPages', 'options'));
             break;
     }
     return $parent_menu;
 }
示例#27
0
 public function content()
 {
     echo '<textarea id="live-css" name="live-css" data-group="general">' . HeadwayOption::get('live-css') . '</textarea>';
 }
示例#28
0
    GD Support:			<?php 
echo function_exists('gd_info') ? "Yes\n" : "***WARNING*** No\n";
?>
    
    PHP Memory Limit:	<?php 
echo ini_get('memory_limit') . "\n";
?>
    PHP Post Max Size:	<?php 
echo ini_get('post_max_size') . "\n";
?>
    
    WP_DEBUG: 			<?php 
echo defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n";
?>
    Debug Mode: 		<?php 
echo HeadwayOption::get('debug-mode', false, false) ? 'Enabled' . "\n" : 'Disabled' . "\n";
?>
    
	Show On Front: 		<?php 
echo get_option('show_on_front') . "\n";
?>
	Page On Front: 		<?php 
echo get_option('page_on_front') . "\n";
?>
	Page For Posts: 	<?php 
echo get_option('page_for_posts') . "\n";
?>

	<?php 
if (!headway_get('exclude-counts')) {
    ?>
示例#29
0
 public static function get_seo_templates($layout = false)
 {
     $seo_templates_query = HeadwayOption::get('seo-templates', 'general', self::output_layouts_and_defaults());
     if ($layout) {
         return headway_get(self::current_seo_layout(), $seo_templates_query, array());
     } else {
         return $seo_templates_query;
     }
 }
 public static function method_change_grid_height()
 {
     $grid_height = headway_post('grid_height');
     //Make sure the grid height is numeric and at least 800px
     if (!is_numeric($grid_height) || $grid_height < 800) {
         return false;
     }
     HeadwayOption::set('grid-height', $grid_height);
 }