コード例 #1
0
ファイル: maintenance.php プロジェクト: danaiser/hollandLawns
 /**
  * Over time, there may be issues to be corrected between updates or naming conventions to be changed between updates.
  * All of that will be processed here.
  **/
 public static function db_upgrade($db_version)
 {
     /* Pre-3.0.3 */
     if (version_compare($db_version, '3.0.3', '<')) {
         self::fix_serialization_in_db();
         self::repair_blocks();
     }
     /**
      * Pre-3.2.3
      * 
      * Change the old wrapper-horizontal-padding and wrapper-vertical-padding to design editor values
      **/
     if (version_compare($db_version, '3.2.3', '<')) {
         $horizontal_padding = HeadwayOption::get('wrapper-horizontal-padding', 'general', 15);
         $vertical_padding = HeadwayOption::get('wrapper-vertical-padding', 'general', 15);
         HeadwayElementsData::set_property('structure', 'wrapper', 'padding-top', $vertical_padding);
         HeadwayElementsData::set_property('structure', 'wrapper', 'padding-bottom', $vertical_padding);
         HeadwayElementsData::set_property('structure', 'wrapper', 'padding-left', $horizontal_padding);
         HeadwayElementsData::set_property('structure', 'wrapper', 'padding-right', $horizontal_padding);
     }
     /**
      * Pre-3.4
      * 
      * - Change block and wrapper margins to Design Editor values
      * - Convert Media blocks to Slider or Embed blocks
      **/
     if (version_compare($db_version, '3.4', '<')) {
         /* Change block and wrapper margins to Design Editor values */
         HeadwayElementsData::set_property('structure', 'wrapper', 'margin-top', HeadwayOption::get('wrapper-top-margin', 'general', 30));
         HeadwayElementsData::set_property('structure', 'wrapper', 'margin-bottom', HeadwayOption::get('wrapper-bottom-margin', 'general', 30));
         HeadwayElementsData::set_property('default-elements', 'default-block', 'margin-bottom', HeadwayOption::get('block-bottom-margin', 'general', 10));
         /* Convert Media blocks to Slider or Embed blocks */
         $media_blocks = HeadwayBlocksData::get_blocks_by_type('media');
         if (is_array($media_blocks) && count($media_blocks)) {
             foreach ($media_blocks as $media_block_id => $media_block_layout_id) {
                 $media_block = HeadwayBlocksData::get_block($media_block_id);
                 $media_block_mode = headway_get('mode', $media_block['settings'], 'embed');
                 switch ($media_block_mode) {
                     case 'embed':
                         HeadwayBlocksData::update_block($media_block['layout'], $media_block['id'], array('type' => 'embed'));
                         break;
                     case 'image-rotator':
                         $slider_images = array();
                         foreach (headway_get('images', $media_block['settings'], array()) as $media_block_image) {
                             $slider_images[] = array('image' => $media_block_image, 'image-description' => null, 'image-hyperlink' => null);
                         }
                         HeadwayBlocksData::update_block($media_block['layout'], $media_block['id'], array('type' => 'slider', 'settings' => array('images' => $slider_images)));
                         break;
                 }
             }
         }
     }
     /* Add action to flush caches */
     do_action('headway_db_upgrade');
     /* Update the version here. */
     $headway_settings = get_option('headway', array('version' => 0));
     $headway_settings['version'] = HEADWAY_VERSION;
     update_option('headway', $headway_settings);
     return true;
 }
コード例 #2
0
ファイル: api-block.php プロジェクト: danaiser/hollandLawns
 public function get_blocks_select_options_for_mirroring()
 {
     $block_type = $this->block['type'];
     $blocks = HeadwayBlocksData::get_blocks_by_type($block_type);
     $options = array('' => '&ndash; Do Not Mirror &ndash;');
     //If there are no blocks, then just return the Do Not Mirror option.
     if (!isset($blocks) || !is_array($blocks)) {
         return $options;
     }
     foreach ($blocks as $block_id => $layout_id) {
         //Get the block instance
         $block = HeadwayBlocksData::get_block($block_id);
         //If the block is mirrored, skip it
         if (HeadwayBlocksData::is_block_mirrored($block)) {
             continue;
         }
         /* Do not show block that's in a mirrored wrapper */
         if (HeadwayWrappers::get_wrapper_mirror(HeadwayWrappers::get_wrapper(headway_get('wrapper', $block)))) {
             continue;
         }
         //Create the default name by using the block type and ID
         $default_name = HeadwayBlocks::block_type_nice($block['type']) . ' #' . $block['id'];
         //If we can't get a name for the layout, then things probably aren't looking good.  Just skip this block.
         if (!($layout_name = HeadwayLayout::get_name($layout_id))) {
             continue;
         }
         //Make sure the block exists
         if (!HeadwayBlocksData::block_exists($block['id'])) {
             continue;
         }
         $current_layout_suffix = $this->block['layout'] == $layout_id ? ' (Warning: Same Layout)' : null;
         //Get alias if it exists, otherwise use the default name
         $options[$block['id']] = headway_get('alias', $block['settings'], $default_name) . ' &ndash; ' . $layout_name . $current_layout_suffix;
     }
     //Remove the current block from the list
     unset($options[$this->block['id']]);
     return $options;
 }
コード例 #3
0
ファイル: grid-wizard.php プロジェクト: danaiser/hollandLawns
 static function get_blocks_select_options_for_mirroring($block_type)
 {
     $return = '';
     $blocks = HeadwayBlocksData::get_blocks_by_type($block_type);
     //If there are no blocks, then just return the Do Not Mirror option.
     if (!isset($blocks) || !is_array($blocks)) {
         return $return;
     }
     foreach ($blocks as $block_id => $layout_id) {
         //Get the block instance
         $block = HeadwayBlocksData::get_block($block_id);
         //If the block is mirrored, skip it
         if (headway_get('mirror-block', $block['settings'], false)) {
             continue;
         }
         //If the block is in the same layout as the current block, then do not allow it to be used as a block to mirror.
         if ($layout_id == headway_post('layout')) {
             continue;
         }
         //Create the default name by using the block type and ID
         $default_name = HeadwayBlocks::block_type_nice($block['type']) . ' #' . $block['id'];
         //If we can't get a name for the layout, then things probably aren't looking good.  Just skip this block.
         if (!($layout_name = HeadwayLayout::get_name($layout_id))) {
             continue;
         }
         //Get alias if it exists, otherwise use the default name
         $return .= '<option value="' . $block['id'] . '">' . headway_get('alias', $block['settings'], $default_name) . ' &ndash; ' . $layout_name . '</option>';
     }
     return $return;
 }
コード例 #4
0
ファイル: admin.php プロジェクト: danaiser/hollandLawns
    public static function notice_no_widgets_or_menus()
    {
        global $pagenow;
        if ($pagenow != 'widgets.php' && $pagenow != 'nav-menus.php') {
            return false;
        }
        $grid_mode_url = add_query_arg(array('visual-editor' => 'true', 'visual-editor-mode' => 'grid'), home_url());
        //Show the widgets message if no widget blocks exist.
        if ($pagenow == 'widgets.php') {
            $widget_area_blocks = HeadwayBlocksData::get_blocks_by_type('widget-area');
            if (!empty($widget_area_blocks)) {
                return;
            }
            if (!current_theme_supports('headway-grid')) {
                return;
            }
            echo '<div class="updated" style="margin-top: 15px;">
			       <p>Headway has detected that you have no Widget Area blocks.  If you wish to use the WordPress widgets system with Headway, please add a Widget Area block in the <a href="' . $grid_mode_url . '" target="_blank">Visual Editor: Grid</a>.</p>
			
					<style type="text/css">
						div.error.below-h2 { display: none; }
						div.error.below-h2 + p { display: none; }
					</style>
			    </div>';
        }
        //Show the navigation menus message if no navigation blocks exist.
        if ($pagenow == 'nav-menus.php') {
            $navigation_blocks = HeadwayBlocksData::get_blocks_by_type('navigation');
            if (!empty($navigation_blocks)) {
                return;
            }
            if (!current_theme_supports('headway-grid')) {
                return;
            }
            echo '<div class="updated">
			       <p>Headway has detected that you have no Navigation blocks.  If you wish to use the WordPress menus system with Headway, please add a Navigation block in the <a href="' . $grid_mode_url . '" target="_blank">Visual Editor: Grid</a>.</p>
			    </div>';
        }
    }
コード例 #5
0
ファイル: blocks.php プロジェクト: danaiser/hollandLawns
 public static function setup_block_actions()
 {
     /* If cache exists then use it */
     if (HeadwayOption::get('cached', 'block-actions-cache', false) && !(headway_get('ve-preview') && HeadwayCapabilities::can_user_visually_edit())) {
         self::$block_actions = array('init' => HeadwayOption::get('init', 'block-actions-cache', array()), 'enqueue' => HeadwayOption::get('enqueue', 'block-actions-cache', array()), 'dynamic-js' => HeadwayOption::get('dynamic-js', 'block-actions-cache', array()), 'dynamic-css' => HeadwayOption::get('dynamic-css', 'block-actions-cache', array()), 'block-objects' => HeadwayOption::get('block-objects', 'block-actions-cache', array()));
         return self::$block_actions;
     }
     /* Build the cache */
     $block_types = self::get_block_types();
     foreach ($block_types as $block_type => $block_type_options) {
         //Make sure that the block type has at least one of the following: init_action, enqueue_action, or dynamic_js
         if (!method_exists($block_type_options['class'], 'init_action') && !method_exists($block_type_options['class'], 'enqueue_action') && !(method_exists($block_type_options['class'], 'dynamic_js') || method_exists($block_type_options['class'], 'js_content')) && !method_exists($block_type_options['class'], 'dynamic_css')) {
             continue;
         }
         $blocks = HeadwayBlocksData::get_blocks_by_type($block_type);
         /* If there are no blocks for this type, skip it */
         if (!is_array($blocks) || count($blocks) === 0) {
             continue;
         }
         /* Go through each type and add a flag if the method exists */
         foreach ($blocks as $block_id => $layout_id) {
             /* Make sure that the layout is set to customized and not using a template */
             if (!HeadwayLayout::is_customized($layout_id) && strpos($layout_id, 'template-') === false) {
                 continue;
             }
             /* Retrieve block.  If it doesn't exist, skip it of course. */
             if (!($block = HeadwayBlocksData::get_block($block_id))) {
                 continue;
             }
             /* If layout ID is numeric (a post), change it to the single-POSTTYPE-ID format */
             if (is_numeric($layout_id)) {
                 $layout_id = 'single-' . get_post_type($layout_id) . '-' . $layout_id;
             }
             /* Init */
             if (method_exists($block_type_options['class'], 'init_action')) {
                 if (!isset(self::$block_actions['init'][$layout_id])) {
                     self::$block_actions['init'][$layout_id] = array();
                 }
                 if (!HeadwayBlocksData::is_block_mirrored($block)) {
                     self::$block_actions['init'][$layout_id][] = $block_id;
                 }
             }
             /* End Init */
             /* Enqueue */
             if (method_exists($block_type_options['class'], 'enqueue_action')) {
                 if (!isset(self::$block_actions['enqueue'][$layout_id])) {
                     self::$block_actions['enqueue'][$layout_id] = array();
                 }
                 self::$block_actions['enqueue'][$layout_id][] = $block_id;
             }
             /* End Enqueue */
             /* Dynamic JS */
             if (method_exists($block_type_options['class'], 'dynamic_js') || method_exists($block_type_options['class'], 'js_content')) {
                 if (!isset(self::$block_actions['dynamic-js'][$layout_id])) {
                     self::$block_actions['dynamic-js'][$layout_id] = array();
                 }
                 self::$block_actions['dynamic-js'][$layout_id][] = $block_id;
             }
             /* End JS Content */
             /* Dynamic CSS */
             if (method_exists($block_type_options['class'], 'dynamic_css')) {
                 if (!isset(self::$block_actions['dynamic-css'][$layout_id])) {
                     self::$block_actions['dynamic-css'][$layout_id] = array();
                 }
                 self::$block_actions['dynamic-css'][$layout_id][] = $block_id;
             }
             /* End Dynamic CSS */
             /* Add block to Block Objects Array */
             if (!isset(self::$block_actions['block-objects']) || !is_array(self::$block_actions['block-objects'])) {
                 self::$block_actions['block-objects'] = array();
             }
             if (!headway_get($block_id, self::$block_actions['block-objects'])) {
                 self::$block_actions['block-objects'][$block_id] = $block;
                 self::$block_actions['block-objects'][$block_id]['class'] = $block_type_options['class'];
                 self::$block_actions['block-objects'][$block_id]['layout'] = $layout_id;
             }
             /* End block objects array */
         }
     }
     /* Set the cache */
     HeadwayOption::set('init', self::$block_actions['init'], 'block-actions-cache');
     HeadwayOption::set('enqueue', self::$block_actions['enqueue'], 'block-actions-cache');
     HeadwayOption::set('dynamic-js', self::$block_actions['dynamic-js'], 'block-actions-cache');
     HeadwayOption::set('dynamic-css', self::$block_actions['dynamic-css'], 'block-actions-cache');
     HeadwayOption::set('block-objects', self::$block_actions['block-objects'], 'block-actions-cache');
     HeadwayOption::set('cached', true, 'block-actions-cache');
     return self::$block_actions;
 }