示例#1
0
 public function __construct($label, $params = array(), $_deprecated = null)
 {
     if (is_bool($params)) {
         _deprecated_argument(get_class($this) . '::' . __FUNCTION__, '5.1.1', 'Use $params array instead.');
         $params = array('self_closing' => $params);
         if (is_bool($_deprecated)) {
             $params['visibility'] = $_deprecated ? self::VISIBILITY_ALL : self::VISIBILITY_NONE;
         } else {
             if (is_int($_deprecated)) {
                 $params['visibility'] = $_deprecated;
             }
         }
     }
     if (!is_null($this->tag)) {
         _deprecated_argument(get_class($this) . '::' . __FUNCTION__, '5.1.1', 'Use $params array instead.');
         $params['tag'] = $this->tag;
     }
     $this->domain = Theme::getInstance()->domain;
     $this->label = $label;
     foreach (array_intersect_key($params, array_flip(array('tag', 'self_closing', 'parent', 'visibility'))) as $name => $value) {
         $this->{$name} = $value;
     }
     if ($this->tag === null) {
         $class = explode('\\', get_class($this));
         $this->tag = Func::stringID(array_pop($class), '_');
     }
     if ($this->parent !== null && !$this->parent instanceof self) {
         $this->parent = self::getInstance($params['parent']);
     }
     self::$instances[$this->tag] = $this;
     $this->register();
 }
示例#2
0
 public function __construct($label, $description = '', $class = '', $width = null)
 {
     $this->_domain = Theme::getInstance()->domain;
     $this->_id = Func::stringID(str_replace(array(__CLASS__, Theme::getInstance()->class . '\\Widgets\\Widget', Theme::getInstance()->class . 'Widget', Theme::getInstance()->class), '', get_class($this)));
     parent::__construct(\Drone\apply_filters('widget_id_base', Theme::getInstance()->theme->id . '-' . $this->_id, $this->_id), Theme::getInstance()->theme->name . ' ' . self::LABEL_SEPARATOR . ' ' . $label, array('description' => $description, 'classname' => $class ? $class : 'widget-' . $this->_id), array('width' => $width));
 }
示例#3
0
 /**
  * Theme options compatybility
  *
  * @since 1.7
  *
  * @param array  $data
  * @param string $version
  */
 public function onThemeOptionsCompatybility(array &$data, $version)
 {
     // 1.7
     if (version_compare($version, '1.7-alpha-3') < 0) {
         $conditional_tags_migrate = function ($data, $sidebars_widgets = false) {
             foreach ($_ = $data as $tag => $value) {
                 if ($sidebars_widgets) {
                     if (!preg_match('/^footer-(?P<tag>.+)-(?P<i>[0-5])$/', $tag, $footer_sidebar)) {
                         continue;
                     }
                     $tag = $footer_sidebar['tag'];
                 }
                 $new_tag = false;
                 if (preg_match('/^(post_type_|term_|bbpress|woocommerce)/', $tag)) {
                     // new format
                     continue;
                 } else {
                     if (in_array($tag, array('default', 'front_page', 'blog', 'search', '404'))) {
                         // general
                         continue;
                     } else {
                         if (in_array($tag, array('forum', 'topic'))) {
                             // bbpress
                             $new_tag = 'bbpress_' . $tag;
                         } else {
                             if (in_array($tag, array('shop', 'cart', 'checkout', 'order_received_page', 'account_page'))) {
                                 // woocommerce
                                 $new_tag = 'woocommerce_' . $tag;
                             } else {
                                 if (strpos($tag, 'template_') === 0) {
                                     // template
                                     if (!preg_match('/.\\.php$/', $tag)) {
                                         foreach (array_keys(Everything::getInstance()->theme->get_page_templates()) as $template) {
                                             if ($tag == \Drone\Func::stringID('template_' . preg_replace('/\\.php$/i', '', $template), '_')) {
                                                 $new_tag = 'template_' . preg_replace('/\\.(php)$/i', '_\\1', $template);
                                                 break;
                                             }
                                         }
                                     }
                                 } else {
                                     if (preg_match('/^[_a-z]+_[0-9]+$/', $tag)) {
                                         // taxonomy
                                         if (preg_match('/^(portfolio_(category|tag)|topic_tag)_/', $tag)) {
                                             $new_tag = 'term_' . preg_replace('/_/', '-', $tag, 1);
                                         } else {
                                             $new_tag = 'term_' . $tag;
                                         }
                                     } else {
                                         if (preg_match('/^[_a-z]+$/', $tag)) {
                                             // post type
                                             $new_tag = 'post_type_' . $tag;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if ($new_tag !== false) {
                     if ($sidebars_widgets) {
                         $tag = $footer_sidebar[0];
                         $new_tag = "footer-{$new_tag}-{$footer_sidebar['i']}";
                     }
                     unset($data[$tag]);
                     $data[$new_tag] = $value;
                 }
             }
             return $data;
         };
         if (isset($data['general']['layout']) && is_array($data['general']['layout'])) {
             $data['general']['layout'] = $conditional_tags_migrate($data['general']['layout']);
         }
         if (isset($data['general']['max_width']) && is_array($data['general']['max_width'])) {
             $data['general']['max_width'] = $conditional_tags_migrate($data['general']['max_width']);
         }
         if (isset($data['general']['background']['background']) && is_array($data['general']['background']['background'])) {
             $data['general']['background']['background'] = $conditional_tags_migrate($data['general']['background']['background']);
         }
         if (isset($data['banner']['content']) && is_array($data['banner']['content'])) {
             $data['banner']['content'] = $conditional_tags_migrate($data['banner']['content']);
         }
         if (isset($data['nav']['secondary']['upper']) && is_array($data['nav']['secondary']['upper'])) {
             $data['nav']['secondary']['upper'] = $conditional_tags_migrate($data['nav']['secondary']['upper']);
         }
         if (isset($data['nav']['secondary']['lower']) && is_array($data['nav']['secondary']['lower'])) {
             $data['nav']['secondary']['lower'] = $conditional_tags_migrate($data['nav']['secondary']['lower']);
         }
         if (isset($data['nav']['headline']) && is_array($data['nav']['headline'])) {
             $data['nav']['headline'] = $conditional_tags_migrate($data['nav']['headline']);
         }
         if (isset($data['sidebar']['layout']) && is_array($data['sidebar']['layout'])) {
             $data['sidebar']['layout'] = $conditional_tags_migrate($data['sidebar']['layout']);
         }
         if (isset($data['footer']['layout']) && is_array($data['footer']['layout'])) {
             $data['footer']['layout'] = $conditional_tags_migrate($data['footer']['layout']);
         }
         if (($sidebars_widgets = get_option('sidebars_widgets')) !== false && is_array($sidebars_widgets)) {
             $new_sidebars_widgets = $conditional_tags_migrate($sidebars_widgets, true);
             if ($sidebars_widgets !== $new_sidebars_widgets) {
                 update_option('sidebars_widgets', $new_sidebars_widgets);
             }
         }
     }
 }
示例#4
0
 protected function _scripts()
 {
     static $outputted = false;
     if ($outputted) {
         return '';
     } else {
         $outputted = true;
     }
     $google_fonts = array();
     if (self::$google_fonts !== false) {
         foreach (self::$google_fonts as $font) {
             $google_fonts[] = $font['family'];
         }
     }
     $custom_fontface = Func::filesList(Theme::getInstance()->stylesheet_dir . '/' . self::$fonts_path, self::$fonts_exts, function (&$i, &$bn, $pi) {
         $i = $pi['filename'];
         $bn = ucwords(Func::stringID(preg_replace('/webfont$/', '', $pi['filename']), ' '));
     });
     return 'var web_safe = ' . json_encode(self::$web_safe) . '; ' . 'var google_fonts = ' . json_encode($google_fonts) . '; ' . 'var custom_fontface = ' . json_encode($custom_fontface) . ';';
 }