Пример #1
0
 /**
  * Theme setup
  *
  * @since 1.0
  * @see \Drone\Theme::onSetupTheme()
  */
 protected function onSetupTheme()
 {
     // Theme features
     $this->addThemeFeature('x-ua-compatible');
     $this->addThemeFeature('nav-menu-current-item');
     $this->addThemeFeature('force-img-caption-shortcode-filter');
     // Editor style
     add_editor_style('data/css/wp/editor.css');
     // Menus
     register_nav_menus(array('main-desktop' => __('Main menu (desktop)', 'everything'), 'main-mobile' => __('Main menu (mobile)', 'everything'), 'additional-mobile' => __('Additional menu (mobile)', 'everything'), 'top-bar-desktop' => __('Top bar menu (desktop)', 'everything'), 'top-bar-mobile' => __('Top bar menu (mobile)', 'everything'), 'secondary-upper' => __('Upper secondary menu', 'everything'), 'secondary-lower' => __('Lower secondary menu', 'everything')));
     // Title
     add_theme_support('title-tag');
     if (version_compare($this->wp_version, '4.1-beta1') < 0) {
         // @deprecated 1.5
         add_action('wp_head', function () {
             echo '<title>' . wp_title('-', false, 'right') . '</title>';
         });
         add_filter('wp_title', function ($title, $sep) {
             if (is_feed()) {
                 return $title;
             }
             if ((is_home() || is_front_page()) && ($description = get_bloginfo('description', 'display'))) {
                 return $sep ? get_bloginfo('name') . " {$sep} {$description}" : get_bloginfo('name');
             } else {
                 return $sep ? $title . get_bloginfo('name') : $title;
             }
         }, 10, 2);
     }
     // Images
     add_theme_support('post-thumbnails');
     if (Everything::to('general/retina')) {
         $this->addThemeFeature('retina-image-size');
     }
     $thumbnail_size = Everything::to('post/thumbnail/size');
     $max_width = Everything::to_('general/max_width')->value('default');
     add_image_size('post-thumbnail', $thumbnail_size['width'], $thumbnail_size['height'], true);
     add_image_size('post-thumbnail-mini', 56, 84, false);
     add_image_size('post-thumbnail-mini-crop', 56, 56, true);
     add_image_size('logo', 999, 60, false);
     add_image_size('full-hd', 1920, 2880, false);
     add_image_size('auto', 236, 354, false);
     // mobile 3 columns
     add_image_size('auto-1', 364, 546, false);
     // mobile 2 columns
     add_image_size('auto-2', 748, 1122, false);
     // mobile 1 column
     add_image_size('auto-3', 960, 1140, false);
     add_image_size('max-width', $max_width['default'], round($max_width['default'] * 1.5), false);
     // Post formats
     add_theme_support('post-formats', array('aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video'));
     // Shortcodes
     $this->addThemeFeature('shortcode-page');
     $this->addThemeFeature('shortcode-no-format');
     // Classes
     \Drone\Options\Option\Font::$always_used = array('Open Sans', 'Montserrat');
     // bbPress
     if (Everything::isPluginActive('bbpress')) {
         $func = function ($show) {
             return is_bbpress() ? false : $show;
         };
         add_filter('everything_meta_display', $func, 20);
         add_filter('everything_social_buttons_display', $func, 20);
     }
     // Captcha
     if (Everything::isPluginActive('captcha')) {
         if (has_action('comment_form_after_fields', 'cptch_comment_form_wp3')) {
             remove_action('comment_form_after_fields', 'cptch_comment_form_wp3', 1);
             remove_action('comment_form_logged_in_after', 'cptch_comment_form_wp3', 1);
             add_filter('comment_form_field_comment', function ($comment_field) {
                 $captcha = \Drone\Func::functionGetOutputBuffer('cptch_comment_form_wp3');
                 $captcha = preg_replace('#<br( /)?>#', '', $captcha);
                 return $comment_field . $captcha;
             });
         }
     }
     // WooCommerce
     if (Everything::isPluginActive('woocommerce')) {
         require $this->template_dir . '/inc/woocommerce.php';
         add_theme_support('woocommerce');
     }
     // WooCommerce Brands
     if (Everything::isPluginActive('woocommerce-brands')) {
         remove_action('woocommerce_product_meta_end', array($GLOBALS['WC_Brands'], 'show_brand'));
     }
     // WPML
     if (Everything::isPluginActive('wpml')) {
         define('ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS', true);
     }
     // Illegal
     if (!is_admin() && Everything::isIllegal()) {
         Everything::to_('footer/end_note/right')->value = Everything::to_('footer/end_note/right')->default;
     }
 }