array('300', '300italic', '400', '400italic', '500', '500italic', '600', '600italic', '700', '700italic', '800', '800italic', '900', '900italic'), 'Abril Fatface' => array('300', '300italic', '400', '400italic', '500', '500italic', '600', '600italic', '800', '800italic'), 'Unna' => array('300', '300italic', '400', '400italic', '500', '500italic', '600', '600italic', '800', '800italic') ); /** * Contains default charsets for the fonts of the theme. * * @access protected * @var array */ protected $google_fonts_charsets = array('latin', 'latin-ext'); /** * Returns the instance of the Apola class. * * @static * @access public * @return Apola */ public static function getInstance() { if( !isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } /** * Constructor of the class. */ public function __construct(ConfigurableInterface $admin = null, $helper = null) { $this->admin = $admin; $this->helper = $helper; add_action('wp_enqueue_scripts', array($this, 'registerAssets')); add_filter('body_class', array($this, 'bodyClasses')); $this->template_dir = defined('APOLA_TEMPLATE_DIRECTORY_URI') ? APOLA_TEMPLATE_DIRECTORY_URI : get_template_directory_uri(); $this->addRequiredThemePlugins(array( array( 'name' => esc_html__('Apola Theme Functionality', 'apola'), 'slug' => 'apola-theme-functionality', 'source' => 'apola/pluginus/apola-theme-functionality.zip', 'required' => true, 'version' => '1.0.0', ), array( 'name' => esc_html__('Meta Box Conditional Logic', 'apola'), 'slug' => 'meta-box-conditional-logic', 'source' => 'apola/pluginus/meta-box-conditional-logic.zip', 'required' => true, 'version' => '1.5.0' ), array( 'name' => esc_html__('Slider Revolution', 'apola'), 'slug' => 'revslider', 'source' => 'apola/pluginus/revslider.zip', 'required' => false, 'version' => '5.4.7.2' ), array( 'name' => esc_html__('WPBakery Page Builder', 'apola'), 'slug' => 'js_composer', 'source' => 'pluginus/js_composer.zip', 'required' => true, 'version' => '5.4.7' ) )); add_action('apola_page_prepend', array($this, 'prependToThePageContent')); add_action('customize_register', array($this, 'modifyCustomizer')); } /** * Registers assets. * * @access protected * @return Apola */ public function registerAssets() { $this->current_page_type = $this->getThemeOption('apola-page-type', 'apola-default', array( 'overriden_by' => 'apola-page-type-individual', 'depend_on' => array('key' => 'apola-page-settings-inherit-individual', 'value' => 0) )); $this->current_page_style = $this->getThemeOption('apola-page-type-portfolio-gallery-page-style', 'apola-grid'); // order is important return $this->registerStyles() ->integrateTypographySettings() ->registerFonts() ->registerInlineStyles() ->registerScripts() ->registerInlineScripts(); } /** * Adds necessary classes to the body element. * * @access public * @return array */ public function bodyClasses( $classes ) { $apola_header_type = $this->getThemeOption('apola-header-type', 'apola-header-side', array( 'overriden_by' => 'apola-page-header-type-individual', 'depend_on' => array( 'key' => 'apola-page-header-state-individual', 'value' => '0' ) )); $apola_side_header_position = $this->getThemeOption('apola-header-side-position', 'apo-header-vertical-left', array( 'overriden_by' => 'apola-page-header-side-position-individual', 'depend_on' => array( 'key' => 'apola-page-header-state-individual', 'value' => '0' ) )); $apola_pages_skin = $this->getThemeOption('apola-page-skin', 'apo-page-light-skin', array( 'overriden_by' => 'apola-page-skin-individual', 'depend_on' => array( 'key' => 'apola-page-skin-state-individual', 'value' => 0 ) )); if(is_singular(array('page'))) { $page_type = $this->getThemeOption('apola-page-type', 'apola-default', array( 'overriden_by' => 'apola-page-type-individual', 'depend_on' => array( 'key' => 'apola-page-settings-inherit-individual', 'value' => 0 ) )); $portfolio_page_style = $this->getThemeOption('apola-page-type-portfolio-gallery-page-style'); if($page_type == 'apola-fullpage-fixed-image') { array_push($classes, 'apo-full-page-fixed-content'); } elseif($page_type == 'apola-fullpage') { $apola_controls_slide_numbers = $this->getThemeOption('apola-page-type-fullpage-slide-numbers-state', 1); $apola_controls_navigation = $this->getThemeOption('apola-page-type-fullpage-navigation-state', 1); $apola_controls_languages = $this->getThemeOption('apola-page-type-fullpage-languages-state', 1); if($apola_controls_slide_numbers == 1 || $apola_controls_navigation == 1 || $apola_controls_languages == 1) { array_push($classes, 'apo-has-full-page-controls'); } } elseif(in_array($portfolio_page_style, array('apola-full-page', 'apola-striped-carousel'))) { $page_style_light_skin = array_search('apo-page-light-skin', $classes); if($page_style_light_skin !== false) unset($classes[$page_style_light_skin]); array_push($classes, 'apo-page-dark-skin'); if($portfolio_page_style == 'apola-full-page') array_push($classes, 'apo-fp-photo-stream'); } } array_push($classes, $apola_pages_skin); if($apola_header_type == 'apola-header-side' && $apola_side_header_position == 'apo-header-vertical-left') { array_push($classes, 'apo-header-vertical-left'); array_push($classes, 'apo-hidden-column-left'); } elseif($apola_header_type == 'apola-header-side' && $apola_side_header_position == 'apo-header-vertical-right') { array_push($classes, 'apo-header-vertical-right'); array_push($classes, 'apo-hidden-column-right'); } if(is_singular('apola-galleries')) { $apola_gallery_builder = get_post_meta(get_queried_object_id(), 'apola_gallery_builder', true); if(isset($apola_gallery_builder['sliders']) && is_array($apola_gallery_builder['sliders']) && isset($apola_gallery_builder['sliders']['single-page-type'])) { switch($apola_gallery_builder['sliders']['single-page-type']) { case 'striped-carousel': $page_style_light_skin = array_search('apo-page-light-skin', $classes); if($page_style_light_skin !== false) unset($classes[$page_style_light_skin]); array_push($classes, 'apo-page-dark-skin'); break; case 'full-page' : $page_style_light_skin = array_search('apo-page-light-skin', $classes); if($page_style_light_skin !== false) unset($classes[$page_style_light_skin]); array_push($classes, 'apo-fp-photo-stream'); array_push($classes, 'apo-page-dark-skin'); break; } } } return $classes; } /** * Registers necessary styles. * * @access protected * @return Apola */ protected function registerStyles() { wp_register_style( 'rev-slider', $this->template_dir . '/assets/vendors/revolution/css/settings.css', array(), '5.4.1' ); wp_register_style( 'swiper-slider', $this->template_dir . '/assets/vendors/swiper/swiper.min.css', array(), '3.4.2' ); wp_register_style( 'fullpage', $this->template_dir . '/assets/vendors/fullpage/jquery.fullpage.min.css', array(), '2.9.4' ); wp_enqueue_style( 'apola-reset', $this->template_dir . '/assets/css/reset.min.css', array(), '1.0.0'); wp_enqueue_style( 'bootstrap', $this->template_dir . '/assets/css/bootstrap.min.css', array(), '3.3.7' ); wp_enqueue_style( 'fontawesome', $this->template_dir . '/assets/css/font-awesome.min.css', array(), '4.7.0' ); wp_enqueue_style( 'linearicons', $this->template_dir . '/assets/css/linearicons.css', array(), '1.0.0' ); wp_enqueue_style( 'animate-css', $this->template_dir . '/assets/css/animate.css', array(), '3.5.1' ); wp_enqueue_style( 'hamburgers', $this->template_dir . '/assets/css/hamburgers.min.css', array(), '1.0.0' ); wp_enqueue_style( 'fancybox', $this->template_dir . '/assets/vendors/fancybox/jquery.fancybox.min.css', array(), '3.3.4' ); wp_enqueue_style( 'custom-scrollbar', $this->template_dir . '/assets/vendors/mCustomScrollbar/jquery.mCustomScrollbar.min.css', array(), '3.1.5' ); wp_enqueue_style( 'arctic-modal', $this->template_dir . '/assets/vendors/arcticmodal/jquery.arcticmodal-0.3.css', array(), '0.0.3' ); wp_enqueue_style( 'owl-carousel', $this->template_dir . '/assets/vendors/owl-carousel/assets/owl.carousel.min.css', array(), '2.2.1' ); wp_enqueue_style( 'apola-icons', $this->template_dir . '/assets/css/apola-icons.css', array(), '1.0.0' ); wp_enqueue_style( 'apola-style', $this->template_dir . '/style.css', array('bootstrap', 'fontawesome', 'linearicons', 'apola-icons', 'fullpage'), '1.0.0' ); if(is_singular('apola-galleries')) { wp_enqueue_style('rev-slider'); wp_enqueue_style('swiper-slider'); $apola_gallery_builder = get_post_meta(get_queried_object_id(), 'apola_gallery_builder', true); if(isset($apola_gallery_builder['sliders']) && is_array($apola_gallery_builder['sliders']) && isset($apola_gallery_builder['sliders']['single-page-type'])) { switch($apola_gallery_builder['sliders']['single-page-type']) { case 'full-page': wp_enqueue_style('fullpage'); break; } } } switch($this->current_page_type) { case 'apola-portfolio-gallery' : switch($this->current_page_style) { case 'apola-slideshow': wp_enqueue_style('rev-slider'); wp_enqueue_style('swiper-slider'); break; case 'apola-full-page': wp_enqueue_style('fullpage'); break; } break; case 'apola-fullpage': case 'apola-fullpage-fixed-image': wp_enqueue_style('fullpage'); break; } return $this; } /** * Registers necessary inline stylesheets. * * @access protected * @return Apola */ protected function registerInlineStyles() { $background_is_blurred = $this->getThemeOption('apola-page-background-image-is-blurred-individual', 0); switch($this->current_page_type) { case 'apola-portfolio-gallery' : switch($this->current_page_style) { case 'apola-slideshow': wp_add_inline_style('apola-style', $this->helper()->getPlainCSS( array('html:not(.apo-with-wp-admin-bar-offset)'), array('margin-top' => '0px !important'), array('min-width', '783px'))); break; } break; } if(is_singular('apola-galleries')) { $apola_gallery_builder = get_post_meta(get_queried_object_id(), 'apola_gallery_builder', true); if(isset($apola_gallery_builder['sliders']) && is_array($apola_gallery_builder['sliders']) && isset($apola_gallery_builder['sliders']['single-page-type'])) { switch($apola_gallery_builder['sliders']['single-page-type']) { case 'slideshow': wp_add_inline_style('apola-style', $this->helper()->getPlainCSS( array('html:not(.apo-with-wp-admin-bar-offset)'), array('margin-top' => '0px !important'), array('min-width', '783px'))); break; } } } if($background_is_blurred == 0) $this->setCurrentPageBackgroundSharp(); return $this; } /** * Registers necessary scripts. * * @access protected * @return Apola */ protected function registerScripts() { wp_register_script( 'swiper-slider', $this->template_dir . '/assets/vendors/swiper/swiper.min.js', array('jquery'), '3.4.2', true ); wp_register_script( 'rev-slider-tools', $this->template_dir . '/assets/vendors/revolution/js/jquery.themepunch.tools.min.js', array('jquery'), '5.4.1', true ); wp_register_script( 'rev-slider', $this->template_dir . '/assets/vendors/revolution/js/jquery.themepunch.revolution.min.js', array('jquery'), '5.4.1', true ); wp_register_script( 'fullpage-scrolloverflow', $this->template_dir . '/assets/vendors/fullpage/vendors/scrolloverflow.min.js', array('jquery'), '2.9.4', true ); wp_register_script( 'fullpage', $this->template_dir . '/assets/vendors/fullpage/jquery.fullpage.min.js', array('jquery'), '2.9.4', true ); wp_register_script( 'apola-fullpage-wrapper', $this->template_dir . '/assets/js/modules/apola.fullpage.js', array('jquery', 'apola-core'), '1.0.0', true ); wp_enqueue_script( 'modernizr', $this->template_dir . '/assets/vendors/modernizr.js', array(), '3.3.1' ); wp_enqueue_script( 'isotope', $this->template_dir . '/assets/vendors/isotope.pkgd.min.js', array('jquery'), '3.0.3', true ); wp_enqueue_script( 'jquery-easings', $this->template_dir . '/assets/vendors/jquery.easing.1.3.min.js', array('jquery'), '1.3.0', true ); wp_enqueue_script( 'appear', $this->template_dir . '/assets/vendors/jquery.appear.min.js', array('jquery'), '1.0.3', true ); wp_enqueue_script( 'owl-carousel', $this->template_dir . '/assets/vendors/owl-carousel/owl.carousel.min.js', array('jquery'), '2.2.1', true ); wp_enqueue_script( 'fancybox', $this->template_dir . '/assets/vendors/fancybox/jquery.fancybox.min.js', array('jquery'), '3.3.4', true ); wp_enqueue_script( 'wt-nav', $this->template_dir . '/assets/vendors/wt.jquery.nav.1.0.js', array('jquery'), '1.0.0', true ); wp_enqueue_script( 'wat-sameheight', $this->template_dir . '/assets/vendors/wat.sameheight.js', array('jquery'), '1.0.0', true ); wp_enqueue_script( 'mad-custom-select', $this->template_dir . '/assets/vendors/mad.customselect.js', array('jquery'), '1.0.0', true ); wp_enqueue_script( 'custom-scrollbar', $this->template_dir . '/assets/vendors/mCustomScrollbar/jquery.mCustomScrollbar.concat.min.js', array('jquery'), '3.1.5', true ); wp_enqueue_script( 'arctic-modal', $this->template_dir . '/assets/vendors/arcticmodal/jquery.arcticmodal-0.3.min.js', array('jquery'), '0.0.3', true ); wp_enqueue_script( 'apola-core', $this->template_dir . '/assets/js/apola.core.js', array('jquery', 'appear'), '1.0.0', true ); wp_enqueue_script( 'apola-sameheight', $this->template_dir . '/assets/js/modules/apola.sameheight.js', array('jquery', 'apola-core'), '1.0.0', true ); wp_enqueue_script( 'apola-isotope-wrapper', $this->template_dir . '/assets/js/modules/apola.isotope.js', array('jquery', 'apola-core'), '1.0.0', true ); wp_enqueue_script( 'apola-parallax-grid', $this->template_dir . '/assets/js/modules/apola.parallax-grid.js', array('jquery', 'apola-core'), '1.0.0', true ); wp_enqueue_script( 'apola-init', $this->template_dir . '/assets/js/apola.init.js', array('jquery'), '1.0.0', true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } if(is_singular('apola-galleries')) { wp_enqueue_script('rev-slider-tools'); wp_enqueue_script('rev-slider'); wp_enqueue_script('swiper-slider'); $apola_gallery_builder = get_post_meta(get_queried_object_id(), 'apola_gallery_builder', true); if(isset($apola_gallery_builder['sliders']) && is_array($apola_gallery_builder['sliders']) && isset($apola_gallery_builder['sliders']['single-page-type'])) { switch($apola_gallery_builder['sliders']['single-page-type']) { case 'full-page': wp_enqueue_script('fullpage-scrolloverflow'); wp_enqueue_script('fullpage'); wp_enqueue_script('apola-fullpage-wrapper'); break; } } } switch($this->current_page_type) { case 'apola-portfolio-gallery' : switch($this->current_page_style) { case 'apola-slideshow': wp_enqueue_script('rev-slider-tools'); wp_enqueue_script('rev-slider'); wp_enqueue_script('swiper-slider'); break; case 'apola-full-page': wp_enqueue_script('fullpage-scrolloverflow'); wp_enqueue_script('fullpage'); wp_enqueue_script('apola-fullpage-wrapper'); break; } break; case 'apola-fullpage' : case 'apola-fullpage-fixed-image' : wp_enqueue_script('fullpage-scrolloverflow'); wp_enqueue_script('fullpage'); wp_enqueue_script('apola-fullpage-wrapper'); break; } return $this; } /** * Register necessary inline scripts. * * @access protected * @return Apola */ protected function registerInlineScripts() { $footer_type = $this->getThemeOption('apola-footer-style', 'apola-footer-widget-area', array( 'overriden_by' => 'apola-page-footer-style-individual', 'depend_on' => array( 'key' => 'apola-page-footer-state-individual', 'value' => '0' ) )); if($footer_type == 'apola-footer-widget-area') { $footer_widgets_geometry = $this->getThemeOption('apola-footer-widget-area-widgets-geometry', null); $footer_widgets_geometry_prepared = array(); if($footer_widgets_geometry) { foreach($footer_widgets_geometry as $row_key => $row) { foreach($row as $column_key => $column) { array_push($footer_widgets_geometry_prepared, $column); } } } if(is_array($footer_widgets_geometry_prepared) && count($footer_widgets_geometry_prepared)) { wp_localize_script('apola-core', 'ApolaFooterWidgetsGeometry', $footer_widgets_geometry_prepared); } } wp_localize_script('apola-core', 'ApolaOptions', array( 'preloader' => $this->getThemeOption('page-loader-state', '0') )); wp_localize_script('apola-core', 'ApolaAJAXData', array( 'url' => admin_url('admin-ajax.php'), 'AJAX_token' => wp_create_nonce('apola-ajax-nonce') )); wp_localize_script('apola-init', 'ApolaLocalizationData', array( 'prevButtonText' => esc_html__('Prev', 'apola'), 'nextButtonText' => esc_html__('Next', 'apola') )); wp_localize_script('apola-init', 'ApolaFancyboxI18N', array( 'CLOSE' => esc_html__('Close', 'apola'), 'NEXT' => esc_html__('Next', 'apola'), 'PREV' => esc_html__('Previous', 'apola'), 'ERROR' => esc_html__('The requested content cannot be loaded. Please try again later.', 'apola'), 'PLAY_START' => esc_html__('Start slideshow', 'apola'), 'PLAY_STOP' => esc_html__('Pause slideshow', 'apola'), 'FULL_SCREEN' => esc_html__('Full screen', 'apola'), 'THUMBS' => esc_html__('Thumbnails', 'apola'), 'DOWNLOAD' => esc_html__('Download', 'apola'), 'SHARE' => esc_html__('Share', 'apola'), 'ZOOM' => esc_html__('Zoom', 'apola') )); return $this; } /** * Sets a background image to the current page. * * @access protected * @return Apola */ protected function setCurrentPageBackgroundSharp() { $background_image_isset = false; $background_image = $this->getThemeOption('apola-page-background-image-individual', null); $background_repeat = $this->getThemeOption('apola-page-background-repeat-individual', 'no-repeat'); $background_position = $this->getThemeOption('apola-page-background-position-individual', 'center center'); $background_size = $this->getThemeOption('apola-page-background-size-individual', 'cover'); $background_attachment = $this->getThemeOption('apola-page-background-attachment-individual', 'fixed'); if(is_array($background_image) && count($background_image)) { $background_image = array_shift($background_image); if(isset($background_image['full_url']) && !empty($background_image['full_url'])) { wp_add_inline_style('apola-style', $this->helper()->getPlainCSS('body', array( 'background-image' => sprintf('url(%s)', $background_image['full_url']), 'background-repeat' => $background_repeat, 'background-position' => $background_position, 'background-size' => $background_size, 'background-attachment' => $background_attachment ))); } } return $this; } /** * Sets a blurred background image to the current page. * * @access protected * @return Apola */ protected function setCurrentPageBackgroundBlurred() { $background_image_isset = false; $background_image = $this->getThemeOption('apola-page-background-image-individual', null); $background_repeat = $this->getThemeOption('apola-page-background-repeat-individual', 'no-repeat'); $background_position = $this->getThemeOption('apola-page-background-position-individual', 'center center'); $background_size = $this->getThemeOption('apola-page-background-size-individual', 'cover'); $background_attachment = $this->getThemeOption('apola-page-background-attachment-individual', 'fixed'); if(is_array($background_image) && count($background_image)) { $background_image = array_shift($background_image); if(isset($background_image['full_url']) && !empty($background_image['full_url'])) : ?>
getThemeOption('apola-page-background-image-is-blurred-individual', 0); if($background_is_blurred == 1) $this->setCurrentPageBackgroundBlurred(); } /** * . * * @access protected * @return Apola */ protected function integrateTypographySettings() { global $apola_settings; $elements_fonts_fallback = array( 'body' => array( 'google' => true, 'font-weight' => '300', 'font-style' => 'normal', 'font-family' => 'Poppins', 'font-size' => '16px', 'line-height' => '30px' ), 'h1' => array( 'google' => true, 'font-weight' => '400', 'font-style' => 'normal', 'font-family' => 'Abril Fatface', 'font-size' => '60px', 'line-height' => '60px' ), 'h2' => array( 'google' => true, 'font-weight' => '400', 'font-style' => 'normal', 'font-family' => 'Abril Fatface', 'font-size' => '48px', 'line-height' => '48px' ), 'h3' => array( 'google' => true, 'font-weight' => '400', 'font-style' => 'normal', 'font-family' => 'Abril Fatface', 'font-size' => '36px', 'line-height' => '36px' ), 'h4' => array( 'google' => true, 'font-weight' => '400', 'font-style' => 'normal', 'font-family' => 'Abril Fatface', 'font-size' => '30px', 'line-height' => '30px' ), 'h5' => array( 'google' => true, 'font-weight' => '400', 'font-style' => 'normal', 'font-family' => 'Abril Fatface', 'font-size' => '24px', 'line-height' => '24px' ), 'h6' => array( 'google' => true, 'font-weight' => '400', 'font-style' => 'normal', 'font-family' => 'Abril Fatface', 'font-size' => '20px', 'line-height' => '20px' ), 'first-accented' => array( 'google' => true, 'font-family' => 'Abril Fatface' ), 'second-accented' => array( 'google' => true, 'font-family' => 'Unna' ) ); $body_font_selectors = array('.apo-body-font', 'blockquote footer', '.apo-404-error-text', '.gallery-caption', '.apo-progress-bar-title', '.apo-team-member-name', '.apo-social-networks-title', '.apo-pricing-table-title', '.apo-portfolio-container.apo-style-2 .apo-project-title', '.apo-fh-article-title', '.apo-header-vertical .apo-header-item .apo-page-title', '.apo-page-header.apo-style-2 .apo-page-title', '.apo-shortcode-header.apo-style-2 .apo-shortcode-header-title', '.apo-testimonial footer', '.apo-testimonial .apo-testimonial-author', '.apo-portfolio-container.apo-style-1 .apo-project-title', '.apo-portfolio-container.apo-style-3 .apo-project-title', '.apo-portfolio-container.apo-style-4 .apo-project-title', '.apo-contact-section-body .apo-contact-info'); $first_accented_font_selectors = array('.apo-first-accented-font', 'blockquote.apo-first-accented-font', '.apo-entries-container.apo-style-5 .apo-entry-title', '.apo-photo-stream .fp-section .apo-section-title'); $second_accented_font_selectors = array('.apo-second-accented-font', '.apo-section-sub-title', 'blockquote.apo-second-accented-font', '.apo-hidden-column .apo-navigation > li > a', '.apo-page-title', '.apo-shortcode-header-title', '.apo-counter::before', '.apo-fp-slide-numbers', '.apo-timeline-item-title', '.apo-icon-box-title', '.apo-contact-info', '.apo-widget.apo-widget-comments .apo-comment-entry-title', '.apo-entry-title', '.comments-list .fn', '.apo-portfolio-container.apo-style-6 .apo-project-title', '.apo-contact-section-title', 'blockquote:not([class*="accented-font"]):not(.apo-body-font)', '.apo-widget .calendar_wrap table tbody', '.comments-list .fn', '.apo-widget.apo-widget-comments .apo-comment-entry-title'); $full_typography_template = ' ${selector} { font-family: "${font-family}", "sans-serif"; font-weight: ${font-weight}; font-style: ${font-style}; font-size: ${font-size}; line-height: ${line-height}; } '; $ff_only_typography_template = ' ${selector} { font-family: "${font-family}", "sans-serif"; } '; $font_data_prepared = array(); $elements = array( 'body', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'first-accented', 'second-accented'); $inline_css_data = ''; if(!is_array($apola_settings)) $apola_settings = array(); foreach($elements as $element) { $option_name = sprintf('%s-font', $element); if(!isset($apola_settings[$option_name]) || !is_array($apola_settings[$option_name])) { if(isset($elements_fonts_fallback[$element])) { $apola_settings[$option_name] = $elements_fonts_fallback[$element]; } } if ( isset($apola_settings[$option_name]['google']) && $apola_settings[$option_name]['google'] !== 'false' ) { $font_data = $apola_settings[$option_name]; $font = $apola_settings[$option_name]['font-family']; if(!isset($this->google_fonts[$font])) { $this->google_fonts[$font] = array(); } $font_weight = isset($font_data['font-weight']) ? $font_data['font-weight'] : '400'; $font_style = isset($font_data['font-style']) && $font_data['font-style'] == 'italic' ? 'italic' : ''; $font_weight_final = $font_weight . $font_style; if(!in_array($font_weight_final, $this->google_fonts[$font])) { array_push($this->google_fonts[$font], $font_weight_final); } if(in_array($element, array('first-accented', 'second-accented'))) { $font_data_prepared = array( '${selector}' => implode(',', ($element == 'first-accented' ? $first_accented_font_selectors : $second_accented_font_selectors)), '${font-family}' => $font ); $template = $ff_only_typography_template; } else { $font_data_prepared = array( '${selector}' => $element, '${font-family}' => $font, '${font-weight}' => (isset($font_data['font-weight']) && !empty($font_data['font-weight'])) ? $font_data['font-weight'] : $elements_fonts_fallback[$element]['font-weight'], '${font-style}' => (isset($font_data['font-style']) && !empty($font_data['font-style'])) ? $font_data['font-style'] : $elements_fonts_fallback[$element]['font-style'], '${font-size}' => isset($font_data['font-size']) ? $font_data['font-size'] : $elements_fonts_fallback[$element]['font-size'], '${line-height}' => isset($font_data['line-height']) ? $font_data['line-height'] : $elements_fonts_fallback[$element]['line-height'] ); $template = $full_typography_template; if($element == 'body' && count($body_font_selectors)) { $like_body_font_data_prepared = array( '${selector}' => implode(',', $body_font_selectors), '${font-family}' => $font ); $inline_css_data .= str_replace(array_keys($like_body_font_data_prepared), array_values($like_body_font_data_prepared), $ff_only_typography_template); } } $inline_css_data .= str_replace(array_keys($font_data_prepared), array_values($font_data_prepared), $template); } } if(!empty($inline_css_data)) { wp_add_inline_style('apola-style', $inline_css_data); } return $this; } /** * Registers theme fonts. * * @access protected * @return Apola */ protected function registerFonts() { global $apola_settings; $fonts_charsets_state = is_array($apola_settings) && isset($apola_settings['apola-google-charsets-state']) && $apola_settings['apola-google-charsets-state']; $fonts_charsets = boolval($fonts_charsets_state) && isset($apola_settings['apola-google-charsets']) && !empty($apola_settings['apola-google-charsets']) ? $apola_settings['apola-google-charsets'] : $this->google_fonts_charsets; wp_enqueue_style('apola-google-fonts', apola_google_fonts_url($this->google_fonts, $fonts_charsets), null, null); return $this; } /** * Returns an instance of the class that implements ConfigurableInterface interface. * * @access public * @return ConfigurableInterface */ public function admin() { return $this->admin; } /** * Returns an instance of the class that implements HelperInterface interface. * * @access public * @return HelperInterface */ public function helper() { return $this->helper; } /** * Returns an option value. * * @param string $name - the option name * @param mixed $fallback - fallback value * @param array $data - additional data for getting the option * @access public * @return mixed */ public function getThemeOption($name, $fallback = '', array $data = array()) { if( !isset( $this->admin ) ) return $fallback; return $this->admin->getOption($name, $fallback, $data); } /** * Sets an option value programmatically. * * @param string $name - the option name * @param mixed $value - value of the option * @access public * @return void */ public function setThemeOption($name, $value) { if( !isset( $this->admin ) ) return null; return $this->admin->setOption($name, $value); } /** * Returns array of required plugins. * * @access public * @return array */ public function getRequiredThemePlugins() { return $this->bundled_plugins; } /** * Registers required plugins. * * @param array $plugins * @access public * @return Apola */ public function addRequiredThemePlugins($plugins) { $this->bundled_plugins = array_merge($this->bundled_plugins, $plugins); return $this; } /** * Modifies the customizer. * * @access public */ public function modifyCustomizer() { global $wp_customize; if($wp_customize && method_exists($wp_customize, 'remove_control') && method_exists($wp_customize, 'remove_section')) { $wp_customize->remove_control('site_icon'); $wp_customize->remove_control('display_header_text'); $wp_customize->remove_section('colors'); $wp_customize->remove_section('header_image'); } } } ?>