Exemplo n.º 1
0
function motopressCERemoveHeadwayFix($post_id, $post_type)
{
    if (defined('HEADWAY_VERSION')) {
        global $wpdb;
        if (version_compare(HEADWAY_VERSION, '3.7.10', '>=') || property_exists($wpdb, 'hw_wrappers')) {
            global $wp_query;
            $originalWpQuery = $wp_query;
            $key = $post_type === 'page' ? 'page_id' : 'p';
            $wp_query = new WP_Query($key . '=' . $post_id);
            if (have_posts()) {
                while (have_posts()) {
                    the_post();
                }
            }
            $layoutId = HeadwayLayout::get_current_in_use();
            HeadwayWrappersData::delete_by_layout($layoutId);
            $transient_id_customized_layouts = 'hw_customized_layouts_template_' . HeadwayOption::$current_skin;
            $customized_layouts = get_transient($transient_id_customized_layouts);
            if ($customized_layouts) {
                $index = array_search($layoutId, $customized_layouts);
                if ($index !== false) {
                    unset($customized_layouts[$layoutId]);
                    set_transient($transient_id_customized_layouts, $customized_layouts);
                }
            }
            wp_reset_postdata();
            $wp_query = $originalWpQuery;
        }
    }
}
Exemplo n.º 2
0
function motopressCEAddHeadwayFix($post_id, $tmp_post_id, $post_type)
{
    if (defined('HEADWAY_VERSION')) {
        global $wpdb;
        if (version_compare(HEADWAY_VERSION, '3.7.10', '>=') || property_exists($wpdb, 'hw_wrappers')) {
            global $wp_query;
            $originalWpQuery = $wp_query;
            $key = $post_type === 'page' ? 'page_id' : 'p';
            $wp_query = new WP_Query($key . '=' . $post_id);
            if (have_posts()) {
                while (have_posts()) {
                    the_post();
                }
            }
            $layoutId = HeadwayLayout::get_current_in_use();
            $wrappers = HeadwayWrappersData::get_wrappers_by_layout($layoutId);
            //            if ($wrappers[0]['id'] !== 'default') {
            if (!array_key_exists('default', $wrappers)) {
                $sep = preg_quote(HeadwayLayout::$sep);
                if (preg_match('/^single' . $sep . '[a-z]+' . $sep . '\\d+$/is', $layoutId)) {
                    $layoutTmpId = str_replace($post_id, $tmp_post_id, $layoutId);
                } else {
                    $layoutTmpId = 'single' . HeadwayLayout::$sep . $post_type . HeadwayLayout::$sep . $tmp_post_id;
                }
                update_option('motopress-ce-hw-layout', $layoutTmpId);
                foreach ($wrappers as $wrapper_id => $wrapper) {
                    $wrapperId = HeadwayWrappersData::add_wrapper($layoutTmpId, $wrapper);
                    $blocks = HeadwayBlocksData::get_blocks_by_wrapper($layoutId, $wrapper_id);
                    foreach ($blocks as $block_id => &$block) {
                        $block['wrapper_id'] = $wrapperId;
                        $block['wrapper'] = $wrapperId;
                        HeadwayBlocksData::add_block($layoutTmpId, $block);
                    }
                    unset($block);
                }
                $transient_id_customized_layouts = 'hw_customized_layouts_template_' . HeadwayOption::$current_skin;
                $customized_layouts = get_transient($transient_id_customized_layouts);
                if (!$customized_layouts) {
                    $customized_layouts = array_unique($wpdb->get_col($wpdb->prepare("SELECT layout FROM {$wpdb->hw_blocks} WHERE template = '%s'", HeadwayOption::$current_skin)));
                }
                if (!in_array($layoutTmpId, $customized_layouts)) {
                    $customized_layouts[] = $layoutTmpId;
                    set_transient($transient_id_customized_layouts, $customized_layouts);
                }
            }
            wp_reset_postdata();
            $wp_query = $originalWpQuery;
        } else {
            $layout = get_option('headway_layout_options_' . $post_id);
            if ($layout) {
                update_option('headway_layout_options_' . $tmp_post_id, $layout);
            } else {
                delete_option('headway_layout_options_' . $tmp_post_id);
            }
        }
    }
}
Exemplo n.º 3
0
 public function __construct()
 {
     $this->id = HeadwayLayout::get_current_in_use();
     $this->blocks = HeadwayBlocksData::get_blocks_by_layout($this->id);
     $this->wrappers = HeadwayWrappers::get_layout_wrappers($this->id);
 }
Exemplo n.º 4
0
 public static function register_layout_css()
 {
     $current_layout_in_use = HeadwayLayout::get_current_in_use();
     $css_name = 'layout-' . HeadwayLayout::get_current_in_use();
     $fragments = array();
     /* If the grid is supported, then include the wrapper, grid, and block heights */
     if (current_theme_supports('headway-grid')) {
         $fragments['dynamic-wrapper'] = array('HeadwayDynamicStyle', 'wrapper');
     }
     /* Include dynamic CSS from blocks such as navigation block or any block that has per-block CSS */
     $fragments['dynamic-block-css'] = array('HeadwayBlocks', 'output_block_dynamic_css');
     return HeadwayCompiler::register_file(array('name' => $css_name, 'format' => 'css', 'fragments' => $fragments, 'dependencies' => array(HEADWAY_LIBRARY_DIR . '/media/dynamic/style.php')));
 }
Exemplo n.º 5
0
 /**
  * @param string
  * 
  * @return bool
  **/
 public static function cache_file($file)
 {
     $cache = HeadwayOption::get('cache', false, array());
     //Get the current layout here directly and set is as GET since the output trigger can use POST, but this cannot.
     $_GET['layout-in-use'] = HeadwayLayout::get_current_in_use();
     $_GET['compiler-cache'] = true;
     $content = self::combine_fragments($cache[$file]);
     //If existing cache file exists, delete it.
     self::delete_cache_file($cache[$file]['filename']);
     //Change LESS extension to CSS
     $extension = $cache[$file]['format'] != 'less' ? $cache[$file]['format'] : 'css';
     //If the file is set to only clear on a hard flush, then add that to the filename
     $hard_cache_suffix = $cache[$file]['require-hard-flush'] ? '-hard-cache' : null;
     //MD5 the contents that way we can check for differences down the road
     $cache[$file]['hash'] = md5($content);
     $cache[$file]['filename'] = $file . '-' . substr($cache[$file]['hash'], 0, 7) . $hard_cache_suffix . '.' . $extension;
     //Build file
     $file_handle = @fopen(HEADWAY_CACHE_DIR . '/' . $cache[$file]['filename'], 'w');
     if (!@fwrite($file_handle, $content)) {
         return false;
     }
     @chmod(HEADWAY_CACHE_DIR . '/' . $cache[$file]['filename'], 0755);
     @fclose($file_handle);
     HeadwayOption::set('cache', $cache);
     return true;
 }
Exemplo n.º 6
0
 /**
  * Assembles the classes for the body element.
  **/
 public static function body_class($c)
 {
     global $wp_query, $authordata;
     $c[] = 'custom';
     /* User Agents */
     if (!HeadwayCompiler::is_plugin_caching()) {
         $user_agent = $_SERVER['HTTP_USER_AGENT'];
         /* IE */
         if ($ie_version = headway_is_ie()) {
             $c[] = 'ie';
             $c[] = 'ie' . $ie_version;
         }
         /* Modern Browsers */
         if (stripos($user_agent, 'Safari') !== false) {
             $c[] = 'safari';
         } elseif (stripos($user_agent, 'Firefox') !== false) {
             $c[] = 'firefox';
         } elseif (stripos($user_agent, 'Chrome') !== false) {
             $c[] = 'chrome';
         } elseif (stripos($user_agent, 'Opera') !== false) {
             $c[] = 'opera';
         }
         /* Rendering Engines */
         if (stripos($user_agent, 'WebKit') !== false) {
             $c[] = 'webkit';
         } elseif (stripos($user_agent, 'Gecko') !== false) {
             $c[] = 'gecko';
         }
         /* Mobile */
         if (stripos($user_agent, 'iPhone') !== false) {
             $c[] = 'iphone';
         } elseif (stripos($user_agent, 'iPod') !== false) {
             $c[] = 'ipod';
         } elseif (stripos($user_agent, 'iPad') !== false) {
             $c[] = 'ipad';
         } elseif (stripos($user_agent, 'Android') !== false) {
             $c[] = 'android';
         }
     }
     /* End User Agents */
     /* Responsive Grid */
     if (HeadwayResponsiveGrid::is_enabled()) {
         $c[] = 'responsive-grid-enabled';
     }
     if (HeadwayResponsiveGrid::is_active()) {
         $c[] = 'responsive-grid-active';
     }
     /* Pages */
     if (is_page() && isset($wp_query->post) && isset($wp_query->post->ID)) {
         $c[] = 'pageid-' . $wp_query->post->ID;
         $c[] = 'page-slug-' . $wp_query->post->post_name;
     }
     /* Posts & Pages */
     if (is_singular() && isset($wp_query->post) && isset($wp_query->post->ID)) {
         //Add the custom classes from the meta box
         if ($custom_css_class = HeadwayLayoutOption::get($wp_query->post->ID, 'css-class', null)) {
             $custom_css_classes = str_replace('  ', ' ', str_replace(',', ' ', htmlspecialchars(strip_tags($custom_css_class))));
             $c = array_merge($c, array_filter(explode(' ', $custom_css_classes)));
         }
     }
     /* Layout IDs, etc */
     $c[] = 'layout-' . HeadwayLayout::get_current();
     $c[] = 'layout-using-' . HeadwayLayout::get_current_in_use();
     if (HeadwayRoute::is_visual_editor_iframe()) {
         $c[] = 've-iframe';
     }
     if (headway_get('ve-iframe-mode') && HeadwayRoute::is_visual_editor_iframe()) {
         $c[] = 'visual-editor-mode-' . headway_get('ve-iframe-mode');
     }
     if (!current_theme_supports('headway-design-editor')) {
         $c[] = 'design-editor-disabled';
     }
     $c = array_unique(array_filter($c));
     return $c;
 }
Exemplo n.º 7
0
 public static function enqueue_block_dynamic_js_file()
 {
     //Do not run these if it's the admin page or the visual editor is open
     if (is_admin() || HeadwayRoute::is_visual_editor()) {
         return false;
     }
     $current_layout_in_use = HeadwayLayout::get_current_in_use();
     $script_name = 'block-dynamic-js-layout-' . HeadwayLayout::get_current_in_use();
     $block_actions = self::get_blocks_for_dynamic_asset('js', $current_layout_in_use);
     if (empty($block_actions)) {
         return;
     }
     HeadwayCompiler::register_file(array('name' => $script_name, 'format' => 'js', 'fragments' => array(array('HeadwayBlocks', 'output_block_dynamic_js')), 'enqueue' => false));
     if (strlen((string) self::output_block_dynamic_js($current_layout_in_use)) > 0) {
         wp_enqueue_script($script_name, HeadwayCompiler::get_url($script_name), array('jquery'));
     }
 }
Exemplo n.º 8
0
    public static function display_canvas()
    {
        echo '<!DOCTYPE HTML>
		<html lang="en">

		<head>

			<meta charset="' . get_bloginfo('charset') . '" />
			<link rel="profile" href="http://gmpg.org/xfn/11" />

			<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
			<meta http-equiv="cache-control" content="no-cache" />

			<title>Visual Editor Grid: ' . wp_title(false, false) . '</title>';
        do_action('headway_grid_iframe_head');
        echo '</head><!-- /head -->

		<body class="visual-editor-iframe-grid ' . join(' ', get_body_class()) . '">';
        $wrappers = HeadwayWrappers::get_layout_wrappers(HeadwayLayout::get_current_in_use());
        $blocks = HeadwayBlocksData::get_blocks_by_layout(HeadwayLayout::get_current_in_use());
        echo '<div id="whitewrap" data-wrappers="' . htmlspecialchars(json_encode($wrappers)) . '">';
        foreach ($wrappers as $wrapper_id => $wrapper_settings) {
            /* Setup wrapper classes */
            $wrapper_classes = array('wrapper');
            $wrapper_classes[] = headway_get('use-independent-grid', $wrapper_settings) ? 'independent-grid' : null;
            $wrapper_classes[] = $wrapper_settings['fluid'] ? 'wrapper-fluid' : 'wrapper-fixed';
            $wrapper_classes[] = $wrapper_settings['fluid'] && $wrapper_settings['fluid-grid'] ? 'wrapper-fluid-grid' : 'wrapper-fixed-grid';
            if (HeadwayWrappers::get_wrapper_mirror($wrapper_settings)) {
                $wrapper_classes[] = 'wrapper-mirrored';
            }
            /* Populate wrapper with its blocks */
            $wrapper_blocks = array();
            foreach ($blocks as $block_id => $block) {
                /* Grab blocks belonging to this wrapper */
                if (headway_get('wrapper', $block, HeadwayWrappers::$default_wrapper_id) === $wrapper_id) {
                    $wrapper_blocks[$block_id] = $block;
                }
                /* If last wrapper, grab all blocks on this layout with invalid wrapper IDs to make sure they're editable somewhere */
                $last_wrapper_id = array_slice(array_keys($wrappers), -1, 1);
                $last_wrapper_id = $last_wrapper_id[0];
                if ($last_wrapper_id == $wrapper_id && !headway_get(headway_get('wrapper', $block, HeadwayWrappers::$default_wrapper_id), $wrappers)) {
                    $wrapper_blocks[$block_id] = $block;
                }
            }
            /* Output the wrapper */
            echo '<div id="' . $wrapper_id . '" class="' . implode(' ', array_filter($wrapper_classes)) . '">';
            echo '<div class="wrapper-mirror-overlay"></div><!-- .wrapper-mirror-overlay -->';
            self::display_grid_blocks($wrapper_blocks, $wrapper_settings);
            echo '</div><!-- #wrapper-' . $wrapper_id . ' -->';
        }
        echo '<div id="wrapper-buttons-template">';
        echo '<div class="wrapper-top-margin-handle wrapper-handle wrapper-margin-handle" title="Drag to change wrapper top margin"><span></span><span></span><span></span></div>';
        echo '<div class="wrapper-drag-handle wrapper-handle tooltip tooltip-right" title="Drag to change wrapper order"><span></span><span></span><span></span></div>';
        echo '<div class="wrapper-bottom-margin-handle wrapper-handle wrapper-margin-handle" title="Drag to change wrapper bottom margin"><span></span><span></span><span></span></div>';
        echo '<div class="wrapper-options tooltip tooltip-right" title="Click to open wrapper options"><span></span></div>';
        echo '</div><!-- .wrapper-buttons -->';
        do_action('headway_grid_iframe_footer');
        echo '</div><!-- #whitewrap -->
		</body>
		</html>';
    }