Make WordPress Themes


Ignore:
Timestamp:
03/17/2025 10:48:32 AM (8 months ago)
Author:
themedropbox
Message:

New version of ChromeNews - 5.3.1

Location:
chromenews/5.3.1
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • chromenews/5.3.1/functions.php

    r250533 r263400  
    11<?php
     2
    23/**
    34 * ChromeNews functions and definitions
     
    2324
    2425if (!function_exists('chromenews_setup')):
    25     /**
    26      * Sets up theme defaults and registers support for various WordPress features.
    27      *
    28      * Note that this function is hooked into the after_setup_theme hook, which
    29      * runs before the init hook. The init hook is too late for some features, such
    30      * as indicating support for post thumbnails.
    31      */
    32     /**
    33      *
    34      */
    35     /**
    36      *
    37      */
    38     function chromenews_setup()
    39     {
    40         /*
     26  /**
     27   * Sets up theme defaults and registers support for various WordPress features.
     28   *
     29   * Note that this function is hooked into the after_setup_theme hook, which
     30   * runs before the init hook. The init hook is too late for some features, such
     31   * as indicating support for post thumbnails.
     32   */
     33  /**
     34   *
     35   */
     36  /**
     37   *
     38   */
     39  function chromenews_setup()
     40  {
     41    /*
    4142         * Make theme available for translation.
    4243         * Translations can be filed in the /languages/ directory.
     
    4445         * to change 'chromenews' to the name of your theme in all the template files.
    4546         */
    46         load_theme_textdomain('chromenews', get_template_directory() . '/languages');
    47 
    48         // Add default posts and comments RSS feed links to head.
    49         add_theme_support('automatic-feed-links');
    50 
    51         /*
     47    load_theme_textdomain('chromenews', get_template_directory() . '/languages');
     48
     49    // Add default posts and comments RSS feed links to head.
     50    add_theme_support('automatic-feed-links');
     51
     52    /*
    5253         * Let WordPress manage the document title.
    5354         * By adding theme support, we declare that this theme does not use a
     
    5556         * provide it for us.
    5657         */
    57         add_theme_support('title-tag');
    58 
    59         /*
     58    add_theme_support('title-tag');
     59
     60    /*
    6061         * Enable support for Post Thumbnails on posts and pages.
    6162         *
    6263         * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
    6364         */
    64         add_theme_support('post-thumbnails');
    65         // Add featured image sizes
    66         add_image_size('chromenews-featured', 1024, 0, false); // width, height, crop
    67         add_image_size('chromenews-large', 825, 575, true); // width, height, crop
    68         add_image_size('chromenews-medium', 590, 410, true); // width, height, crop
    69 
    70 
    71         /*
     65    add_theme_support('post-thumbnails');
     66    // Add featured image sizes
     67    add_image_size('chromenews-featured', 1024, 0, false); // width, height, crop
     68    add_image_size('chromenews-large', 825, 575, true); // width, height, crop
     69    add_image_size('chromenews-medium', 590, 410, true); // width, height, crop
     70
     71
     72    /*
    7273         * Enable support for Post Formats on posts and pages.
    7374         *
    7475         * @link https://developer.wordpress.org/themes/functionality/post-formats/
    7576         */
    76         add_theme_support('post-formats', array('image', 'video', 'gallery'));
    77 
    78         // This theme uses wp_nav_menu() in one location.
    79         register_nav_menus(array(
    80             'aft-primary-nav' => esc_html__('Primary Menu', 'chromenews'),
    81             'aft-social-nav' => esc_html__('Social Menu', 'chromenews'),
    82             'aft-footer-nav' => esc_html__('Footer Menu', 'chromenews'),
    83         ));
    84 
    85         /*
     77    add_theme_support('post-formats', array('image', 'video', 'gallery'));
     78
     79    // This theme uses wp_nav_menu() in one location.
     80    register_nav_menus(array(
     81      'aft-primary-nav' => esc_html__('Primary Menu', 'chromenews'),
     82      'aft-social-nav' => esc_html__('Social Menu', 'chromenews'),
     83      'aft-footer-nav' => esc_html__('Footer Menu', 'chromenews'),
     84    ));
     85
     86    /*
    8687         * Switch default core markup for search form, comment form, and comments
    8788         * to output valid HTML5.
    8889         */
    89         add_theme_support('html5', array(
    90             'search-form',
    91             'comment-form',
    92             'comment-list',
    93             'gallery',
    94             'caption',
    95         ));
    96 
    97         // Set up the WordPress core custom background feature.
    98         add_theme_support('custom-background', apply_filters('chromenews_custom_background_args', array(
    99             'default-color' => 'eeeeee',
    100             'default-image' => '',
    101         )));
    102 
    103         // Add theme support for selective refresh for widgets.
    104         add_theme_support('customize-selective-refresh-widgets');
    105 
    106 
    107 
    108         /**
    109          * Add support for core custom logo.
    110          *
    111          * @link https://codex.wordpress.org/Theme_Logo
    112          */
    113         add_theme_support('custom-logo', array(
    114             'flex-width' => true,
    115             'flex-height' => true,
    116         ));
    117 
    118 
    119         /*
     90    add_theme_support('html5', array(
     91      'search-form',
     92      'comment-form',
     93      'comment-list',
     94      'gallery',
     95      'caption',
     96    ));
     97
     98    // Set up the WordPress core custom background feature.
     99    add_theme_support('custom-background', apply_filters('chromenews_custom_background_args', array(
     100      'default-color' => 'eeeeee',
     101      'default-image' => '',
     102    )));
     103
     104    // Add theme support for selective refresh for widgets.
     105    add_theme_support('customize-selective-refresh-widgets');
     106
     107
     108
     109    /**
     110     * Add support for core custom logo.
     111     *
     112     * @link https://codex.wordpress.org/Theme_Logo
     113     */
     114    add_theme_support('custom-logo', array(
     115      'flex-width' => true,
     116      'flex-height' => true,
     117    ));
     118
     119
     120    /*
    120121        * Add theme support for gutenberg block
    121122        */
    122         add_theme_support( 'align-wide' );
    123         add_theme_support( 'responsive-embeds' );
    124         add_theme_support( 'wp-block-styles' );
    125         add_theme_support( 'appearance-tools' );
    126         add_theme_support( 'custom-spacing' );       
    127         add_theme_support( 'custom-units' );
    128         add_theme_support( 'custom-line-height' );
    129         add_theme_support( 'border' );
    130         add_theme_support( 'link-color' );
    131 
    132     }
     123    add_theme_support('align-wide');
     124    add_theme_support('responsive-embeds');
     125    add_theme_support('wp-block-styles');
     126    add_theme_support('appearance-tools');
     127    add_theme_support('custom-spacing');
     128    add_theme_support('custom-units');
     129    add_theme_support('custom-line-height');
     130    add_theme_support('border');
     131    add_theme_support('link-color');
     132  }
    133133endif;
    134134add_action('after_setup_theme', 'chromenews_setup');
    135    
    136     /**
    137      * Set the content width in pixels, based on the theme's design and stylesheet.
    138      *
    139      * Priority 0 to make it available to lower priority callbacks.
    140      *
    141      * @global int $content_width
    142      */
    143     function chromenews_content_width()
    144     {
    145         $GLOBALS['content_width'] = apply_filters('chromenews_content_width', 640);
    146     }
    147    
    148     add_action('after_setup_theme', 'chromenews_content_width', 0);
     135
     136/**
     137 * Set the content width in pixels, based on the theme's design and stylesheet.
     138 *
     139 * Priority 0 to make it available to lower priority callbacks.
     140 *
     141 * @global int $content_width
     142 */
     143function chromenews_content_width()
     144{
     145  $GLOBALS['content_width'] = apply_filters('chromenews_content_width', 640);
     146}
     147
     148add_action('after_setup_theme', 'chromenews_content_width', 0);
    149149
    150150/**
     
    154154 * @return string Filtered font string with only the allowed variants.
    155155 */
    156 function chromenews_filter_font_variants($font) {
    157     if (empty($font) || strpos($font, ':') === false) {
    158         return $font; // Return as is if no variants exist.
     156function chromenews_filter_font_variants($font)
     157{
     158  if (empty($font) || strpos($font, ':') === false) {
     159    return $font; // Return as is if no variants exist.
     160  }
     161
     162  list($font_name, $variants) = explode(':', $font);
     163
     164  // Define allowed variants to reduce file size and improve performance.
     165  $allowed_variants = array('400', '700');
     166  $font_variants = explode(',', $variants);
     167  $filtered_variants = array_intersect($font_variants, $allowed_variants);
     168
     169  return !empty($filtered_variants) ? $font_name . ':' . implode(',', $filtered_variants) : $font_name;
     170}
     171
     172/**
     173 * Generate the Google Fonts URL based on theme options and locale.
     174 *
     175 * @since 1.0.0
     176 * @return string Google Fonts URL or empty string if no fonts are required.
     177 */
     178function chromenews_fonts_url()
     179{
     180  $fonts_url = '';
     181  $fonts = array();
     182  $subsets = array('latin'); // Default subset is 'latin'.
     183
     184  // Adjust subsets based on locale.
     185  $locale = get_locale();
     186  $subset_mapping = array(
     187    'cs' => 'latin-ext',
     188    'pl' => 'latin-ext',
     189    'hu' => 'latin-ext',
     190    'ru' => 'cyrillic',
     191    'el' => 'greek',
     192    'vi' => 'vietnamese',
     193  );
     194
     195  foreach ($subset_mapping as $lang_code => $subset) {
     196    if (strpos($locale, $lang_code) !== false) {
     197      $subsets[] = $subset;
     198      break;
    159199    }
    160  
    161     list($font_name, $variants) = explode(':', $font);
    162  
    163     // Define allowed variants to reduce file size and improve performance.
    164     $allowed_variants = array('400', '700');
    165     $font_variants = explode(',', $variants);
    166     $filtered_variants = array_intersect($font_variants, $allowed_variants);
    167  
    168     return !empty($filtered_variants) ? $font_name . ':' . implode(',', $filtered_variants) : $font_name;
    169   }
    170  
     200  }
     201
     202  // Fetch theme options for fonts and filter variants.
     203  $site_title_font = chromenews_filter_font_variants(chromenews_get_option('site_title_font'));
     204  $primary_font = chromenews_filter_font_variants(chromenews_get_option('primary_font'));
     205  $secondary_font = chromenews_filter_font_variants(chromenews_get_option('secondary_font'));
     206
     207  // Collect fonts only if they are not 'off'.
     208  foreach (array($site_title_font, $primary_font, $secondary_font) as $font) {
     209    if (!empty($font) && 'off' !== sprintf(_x('on', '%s font: on or off', 'chromenews'), $font)) {
     210      $fonts[] = $font;
     211    }
     212  }
     213
     214  // Remove duplicate fonts.
     215  $fonts = array_unique($fonts);
     216
     217  // Generate the Google Fonts URL if fonts are available.
     218  if (!empty($fonts)) {
     219    $fonts_url = add_query_arg(array(
     220      'family'  => implode('|', $fonts), // Concatenate fonts with '|'.
     221      'subset'  => implode(',', array_unique($subsets)), // Unique subsets.
     222      'display' => 'swap', // Use 'swap' for performance.
     223    ), 'https://fonts.googleapis.com/css');
     224  }
     225
     226  return esc_url($fonts_url); // Ensure safe output.
     227}
     228
     229/**
     230 * Add preconnect links for Google Fonts domains to improve performance.
     231 *
     232 * @param array  $urls          URLs to print for resource hints.
     233 * @param string $relation_type The relation type of the URLs (e.g., 'preconnect').
     234 * @return array Filtered URLs.
     235 */
     236function chromenews_add_preconnect_links($urls, $relation_type)
     237{
     238  if ('preconnect' === $relation_type) {
     239    $urls[] = 'https://fonts.googleapis.com';
     240    $urls[] = 'https://fonts.gstatic.com';
     241  }
     242
     243  return $urls;
     244}
     245add_filter('wp_resource_hints', 'chromenews_add_preconnect_links', 10, 2);
     246
     247/**
     248 * Preload Google Fonts stylesheets in the <head> for performance.
     249 */
     250function chromenews_preload_google_fonts()
     251{
     252  $fonts_url = chromenews_fonts_url();
     253
     254  if ($fonts_url) {
     255    printf(
     256      "<link rel='preload' href='%s' as='style' onload=\"this.onload=null;this.rel='stylesheet'\" type='text/css' media='all' crossorigin='anonymous'>\n",
     257      esc_url($fonts_url)
     258    );
     259  }
     260}
     261add_action('wp_head', 'chromenews_preload_google_fonts', 1);
     262
     263/**
     264 * Enqueue the theme's Google Fonts stylesheet with additional optimization.
     265 */
     266function chromenews_enqueue_google_fonts()
     267{
     268  $fonts_url = chromenews_fonts_url();
     269
     270  if ($fonts_url) {
     271    wp_enqueue_style('chromenews-google-fonts', $fonts_url, array(), null);
     272  }
     273}
     274add_action('wp_enqueue_scripts', 'chromenews_enqueue_google_fonts');
     275
     276
     277
     278
     279/**
     280 * Load Init for Hook files.
     281 */
     282require get_template_directory() . '/inc/custom-style.php';
     283
     284/**
     285 * Enqueue styles.
     286 */
     287
     288add_action('wp_enqueue_scripts', 'chromenews_style_files');
     289function chromenews_style_files()
     290{
     291
     292  $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     293
     294  wp_enqueue_style('chromenews-icons', get_template_directory_uri() . '/assets/icons/style.css');
     295
     296
     297  // $fonts_url = chromenews_fonts_url();
     298  $chromenews_version =  wp_get_theme()->get('Version');
     299
     300  // if (!empty($fonts_url)) {
     301  //     wp_enqueue_style('chromenews-google-fonts', $fonts_url, array(), null);
     302  // }
     303
    171304  /**
    172   * Generate the Google Fonts URL based on theme options and locale.
    173   *
    174   * @since 1.0.0
    175   * @return string Google Fonts URL or empty string if no fonts are required.
    176   */
    177   function chromenews_fonts_url() {
    178     $fonts_url = '';
    179     $fonts = array();
    180     $subsets = array('latin'); // Default subset is 'latin'.
    181  
    182     // Adjust subsets based on locale.
    183     $locale = get_locale();
    184     $subset_mapping = array(
    185         'cs' => 'latin-ext',
    186         'pl' => 'latin-ext',
    187         'hu' => 'latin-ext',
    188         'ru' => 'cyrillic',
    189         'el' => 'greek',
    190         'vi' => 'vietnamese',
    191     );
    192  
    193     foreach ($subset_mapping as $lang_code => $subset) {
    194         if (strpos($locale, $lang_code) !== false) {
    195             $subsets[] = $subset;
    196             break;
    197         }
    198     }
    199  
    200     // Fetch theme options for fonts and filter variants.
    201     $site_title_font = chromenews_filter_font_variants(chromenews_get_option('site_title_font'));
    202     $primary_font = chromenews_filter_font_variants(chromenews_get_option('primary_font'));
    203     $secondary_font = chromenews_filter_font_variants(chromenews_get_option('secondary_font'));
    204  
    205     // Collect fonts only if they are not 'off'.
    206     foreach (array($site_title_font, $primary_font, $secondary_font) as $font) {
    207         if (!empty($font) && 'off' !== sprintf(_x('on', '%s font: on or off', 'chromenews'), $font)) {
    208             $fonts[] = $font;
    209         }
    210     }
    211  
    212     // Remove duplicate fonts.
    213     $fonts = array_unique($fonts);
    214  
    215     // Generate the Google Fonts URL if fonts are available.
    216     if (!empty($fonts)) {
    217         $fonts_url = add_query_arg(array(
    218             'family'  => implode('|', $fonts), // Concatenate fonts with '|'.
    219             'subset'  => implode(',', array_unique($subsets)), // Unique subsets.
    220             'display' => 'swap', // Use 'swap' for performance.
    221         ), 'https://fonts.googleapis.com/css');
    222     }
    223  
    224     return esc_url($fonts_url); // Ensure safe output.
    225   }
    226  
    227   /**
    228   * Add preconnect links for Google Fonts domains to improve performance.
    229   *
    230   * @param array  $urls          URLs to print for resource hints.
    231   * @param string $relation_type The relation type of the URLs (e.g., 'preconnect').
    232   * @return array Filtered URLs.
    233   */
    234   function chromenews_add_preconnect_links($urls, $relation_type) {
    235     if ('preconnect' === $relation_type) {
    236         $urls[] = 'https://fonts.googleapis.com';
    237         $urls[] = 'https://fonts.gstatic.com';
    238     }
    239  
    240     return $urls;
    241   }
    242   add_filter('wp_resource_hints', 'chromenews_add_preconnect_links', 10, 2);
    243  
    244   /**
    245   * Preload Google Fonts stylesheets in the <head> for performance.
    246   */
    247   function chromenews_preload_google_fonts() {
    248     $fonts_url = chromenews_fonts_url();
    249  
    250     if ($fonts_url) {
    251         printf(
    252             "<link rel='preload' href='%s' as='style' onload=\"this.onload=null;this.rel='stylesheet'\" type='text/css' media='all' crossorigin='anonymous'>\n",
    253             esc_url($fonts_url)
    254         );
    255     }
    256   }
    257   add_action('wp_head', 'chromenews_preload_google_fonts', 1);
    258  
    259   /**
    260   * Enqueue the theme's Google Fonts stylesheet with additional optimization.
    261   */
    262   function chromenews_enqueue_google_fonts() {
    263     $fonts_url = chromenews_fonts_url();
    264  
    265     if ($fonts_url) {
    266         wp_enqueue_style('chromenews-google-fonts', $fonts_url, array(), null);
    267     }
    268   }
    269   add_action('wp_enqueue_scripts', 'chromenews_enqueue_google_fonts');
    270  
    271 
    272 
    273 
    274 /**
    275  * Load Init for Hook files.
    276  */
    277  require get_template_directory() . '/inc/custom-style.php';
    278 
    279 /**
    280  * Enqueue styles.
    281  */
    282  
    283 add_action('wp_enqueue_scripts', 'chromenews_style_files');
    284 function chromenews_style_files(){
    285    
    286     $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';   
    287      
    288     wp_enqueue_style('chromenews-icons', get_template_directory_uri() . '/assets/icons/style.css'); 
    289    
    290    
    291     // $fonts_url = chromenews_fonts_url();
    292     $chromenews_version =  wp_get_theme()->get( 'Version' );
    293    
    294     // if (!empty($fonts_url)) {
    295     //     wp_enqueue_style('chromenews-google-fonts', $fonts_url, array(), null);
    296     // }
    297    
    298     /**
    299      * Load WooCommerce compatibility file.
    300      */
    301     if (class_exists('WooCommerce')) {
    302         wp_enqueue_style('chromenews-woocommerce-style', get_template_directory_uri() . '/woocommerce.css');
    303        
    304         $font_path = WC()->plugin_url() . '/assets/fonts/';
    305         $inline_font = '@font-face {
     305   * Load WooCommerce compatibility file.
     306   */
     307  if (class_exists('WooCommerce')) {
     308    wp_enqueue_style('chromenews-woocommerce-style', get_template_directory_uri() . '/woocommerce.css');
     309
     310    $font_path = WC()->plugin_url() . '/assets/fonts/';
     311    $inline_font = '@font-face {
    306312            font-family: "star";
    307313            src: url("' . $font_path . 'star.eot");
     
    313319            font-style: normal;
    314320        }';
    315        
    316         wp_add_inline_style('chromenews-woocommerce-style', $inline_font);
     321
     322    wp_add_inline_style('chromenews-woocommerce-style', $inline_font);
     323  }
     324
     325
     326  wp_enqueue_style('chromenews-style', get_template_directory_uri() . '/style' . $min . '.css', array(), $chromenews_version);
     327  wp_add_inline_style('chromenews-style', chromenews_custom_style());
     328
     329  if (is_rtl() && is_child_theme()) {
     330    wp_enqueue_style(
     331      'chromenews-rtl',
     332      get_template_directory_uri() . '/rtl.css',
     333      array(), // Load after other styles
     334      $chromenews_version
     335    );
     336  }
     337}
     338
     339/**
     340 * Enqueue scripts.
     341 */
     342
     343function chromenews_scripts()
     344{
     345
     346  $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     347  $chromenews_version =  wp_get_theme()->get('Version');
     348
     349  wp_enqueue_script('jquery');
     350  wp_enqueue_script('jquery-cookie', get_template_directory_uri() . '/assets/jquery.cookie.js');
     351  wp_enqueue_script('chromenews-toggle-script', get_template_directory_uri() . '/assets/toggle-script.js', array('jquery-cookie'), $chromenews_version, true);
     352  wp_enqueue_script('chromenews-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true);
     353  wp_enqueue_script('chromenews-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), $chromenews_version, true);
     354  wp_enqueue_script('chromenews-script', get_template_directory_uri() . '/admin-dashboard/dist/chromenews_scripts.build.js', array('jquery'), $chromenews_version, true);
     355
     356  $top_header_time_format = chromenews_get_option('top_header_time_format');
     357  $localized_time_format = array();
     358  if ($top_header_time_format == 'en-US' || $top_header_time_format == 'en-GB') {
     359    $localized_time_format['format'] = $top_header_time_format;
     360    wp_localize_script('chromenews-script', 'AFlocalizedTime', $localized_time_format);
     361  }
     362
     363  if (is_singular() && comments_open() && get_option('thread_comments')) {
     364    wp_enqueue_script('comment-reply');
     365  }
     366
     367  if (is_active_sidebar('express-off-canvas-panel')) {
     368    wp_enqueue_style('sidr', get_template_directory_uri() . '/assets/sidr/css/jquery.sidr.dark.css', array(), $chromenews_version);
     369    wp_enqueue_script('sidr', get_template_directory_uri() . '/assets/sidr/js/jquery.sidr' . $min . '.js', array('jquery'), $chromenews_version, true);
     370  }
     371
     372  if (is_page_template('tmpl-front-page.php') || is_front_page() || is_home()) {
     373
     374    $show_main_news_section = chromenews_get_option('show_main_news_section');
     375    $show_flash_news_section = chromenews_get_option('show_flash_news_section');
     376    $main_banner_layout = chromenews_get_option('select_main_banner_layout_section');
     377    if ($show_flash_news_section) {
     378      wp_enqueue_script('marquee', get_template_directory_uri() . '/assets/marquee/jquery.marquee.js', array('jquery'), $chromenews_version, true);
    317379    }
    318    
    319    
    320     wp_enqueue_style('chromenews-style', get_template_directory_uri().'/style'.$min.'.css', array(), $chromenews_version);
    321     wp_add_inline_style('chromenews-style', chromenews_custom_style());
    322 
    323     if (is_rtl() && is_child_theme()) {
    324         wp_enqueue_style(
    325             'chromenews-rtl',
    326             get_template_directory_uri() . '/rtl.css',
    327             array(), // Load after other styles
    328             $chromenews_version
    329         );
     380
     381    if ($show_main_news_section) {
     382      wp_enqueue_style('slick', get_template_directory_uri() . '/assets/slick/css/slick' . $min . '.css', array(), $chromenews_version);
     383      wp_enqueue_script('slick', get_template_directory_uri() . '/assets/slick/js/slick' . $min . '.js', array('jquery'), $chromenews_version, true);
    330384    }
    331 }
    332 
    333 /**
    334 * Enqueue scripts.
    335 */
    336 
    337 function chromenews_scripts()
    338 {
    339 
    340     $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
    341     $chromenews_version =  wp_get_theme()->get( 'Version' );
    342    
    343     wp_enqueue_script('jquery');
    344     wp_enqueue_script('jquery-cookie', get_template_directory_uri() . '/assets/jquery.cookie.js');
    345     wp_enqueue_script('chromenews-toggle-script', get_template_directory_uri() . '/assets/toggle-script.js', array('jquery-cookie'), $chromenews_version, true);
    346     wp_enqueue_script('chromenews-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true);
    347     wp_enqueue_script('chromenews-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), $chromenews_version, true);
    348     wp_enqueue_script('chromenews-script', get_template_directory_uri() . '/assets/script.js', array('jquery'), $chromenews_version, true);
    349    
    350     $top_header_time_format = chromenews_get_option('top_header_time_format');
    351     $localized_time_format = array();
    352     if($top_header_time_format == 'en-US' || $top_header_time_format == 'en-GB'){
    353         $localized_time_format['format'] = $top_header_time_format;
    354         wp_localize_script('chromenews-script', 'AFlocalizedTime', $localized_time_format);
    355     }
    356 
    357     if (is_singular() && comments_open() && get_option('thread_comments')) {
    358         wp_enqueue_script('comment-reply');
    359     }
    360 
    361     if (is_active_sidebar('express-off-canvas-panel')){
    362         wp_enqueue_style('sidr', get_template_directory_uri() . '/assets/sidr/css/jquery.sidr.dark.css', array(), $chromenews_version);
    363         wp_enqueue_script('sidr', get_template_directory_uri() . '/assets/sidr/js/jquery.sidr' . $min . '.js', array('jquery'), $chromenews_version, true);
    364     }
    365 
    366     if ( is_page_template('tmpl-front-page.php') || is_front_page() || is_home()) {
    367 
    368         $show_main_news_section = chromenews_get_option('show_main_news_section');
    369         $show_flash_news_section = chromenews_get_option('show_flash_news_section');
    370         $main_banner_layout = chromenews_get_option('select_main_banner_layout_section');
    371         if($show_flash_news_section){
    372             wp_enqueue_script('marquee', get_template_directory_uri() . '/assets/marquee/jquery.marquee.js', array('jquery'), $chromenews_version, true);
    373            
    374         }
    375 
    376         if($show_main_news_section){           
    377             wp_enqueue_style('slick', get_template_directory_uri() . '/assets/slick/css/slick' . $min . '.css', array(), $chromenews_version);           
    378             wp_enqueue_script('slick', get_template_directory_uri() . '/assets/slick/js/slick' . $min . '.js', array('jquery'), $chromenews_version, true);
    379            
    380            
    381         }
    382         wp_enqueue_script('bootstrap', get_template_directory_uri() . '/assets/bootstrap/js/bootstrap' . $min . '.js', array('jquery'), $chromenews_version, true);             
    383          
    384     }
    385 
    386     if(!is_singular()){       
    387        
    388         wp_enqueue_script('matchheight', get_template_directory_uri() . '/assets/jquery-match-height/jquery.matchHeight' . $min . '.js', array('jquery'), $chromenews_version, true);       
    389        
    390     }
    391 
    392     if(has_block('gallery') || is_active_widget(false, false, 'media_gallery')){
    393 
    394         wp_enqueue_script('magnific-popup', get_template_directory_uri() . '/assets/magnific-popup/jquery.magnific-popup' . $min . '.js', array('jquery'), $chromenews_version, true);
    395         wp_enqueue_style('magnific-popup', get_template_directory_uri() . '/assets/magnific-popup/magnific-popup.css', array(), $chromenews_version);
    396    
    397     }
    398 
    399 
    400 
     385    wp_enqueue_script('bootstrap', get_template_directory_uri() . '/assets/bootstrap/js/bootstrap' . $min . '.js', array('jquery'), $chromenews_version, true);
     386  }
     387
     388  if (!is_singular()) {
     389
     390    wp_enqueue_script('matchheight', get_template_directory_uri() . '/assets/jquery-match-height/jquery.matchHeight' . $min . '.js', array('jquery'), $chromenews_version, true);
     391  }
     392
     393  if (has_block('gallery') || is_active_widget(false, false, 'media_gallery')) {
     394
     395    wp_enqueue_script('magnific-popup', get_template_directory_uri() . '/assets/magnific-popup/jquery.magnific-popup' . $min . '.js', array('jquery'), $chromenews_version, true);
     396    wp_enqueue_style('magnific-popup', get_template_directory_uri() . '/assets/magnific-popup/magnific-popup.css', array(), $chromenews_version);
     397  }
    401398}
    402399
    403400add_action('wp_enqueue_scripts', 'chromenews_scripts');
    404    
    405    
    406     /**
    407      * Enqueue admin scripts and styles.
    408      *
    409      * @since ChromeNews 1.0.0
    410      */
    411     function chromenews_admin_scripts($hook)
    412     {
    413         if ('widgets.php' === $hook) {
    414             wp_enqueue_media();
    415             wp_enqueue_script('chromenews-widgets', get_template_directory_uri() . '/assets/widgets.js', array('jquery'), '1.0.0', true);
    416         }
    417         wp_enqueue_style('chromenews-notice', get_template_directory_uri() . '/assets/css/notice.css');
    418    
    419        
    420     }
    421    
    422     add_action('admin_enqueue_scripts', 'chromenews_admin_scripts');
     401
     402
     403/**
     404 * Enqueue admin scripts and styles.
     405 *
     406 * @since ChromeNews 1.0.0
     407 */
     408function chromenews_admin_scripts($hook)
     409{
     410  if ('widgets.php' === $hook) {
     411    wp_enqueue_media();
     412    wp_enqueue_script('chromenews-widgets', get_template_directory_uri() . '/assets/widgets.js', array('jquery'), '1.0.0', true);
     413  }
     414  wp_enqueue_style('chromenews-notice', get_template_directory_uri() . '/assets/css/notice.css');
     415}
     416
     417add_action('admin_enqueue_scripts', 'chromenews_admin_scripts');
    423418
    424419
     
    471466 */
    472467if (defined('JETPACK__VERSION')) {
    473     require get_template_directory() . '/inc/jetpack.php';
     468  require get_template_directory() . '/inc/jetpack.php';
    474469}
    475470
     
    478473 */
    479474if (class_exists('WooCommerce')) {
    480     require get_template_directory() . '/inc/woocommerce.php';
     475  require get_template_directory() . '/inc/woocommerce.php';
    481476}
    482477
     
    493488{
    494489
    495     if (isset($args->theme_location) && 'aft-primary-nav' == $args->theme_location && $item->description)
    496         $item_output = str_replace('</a>', '<span class="menu-description">' . $item->description . '</span></a>', $item_output);
    497 
    498     return $item_output;
     490  if (isset($args->theme_location) && 'aft-primary-nav' == $args->theme_location && $item->description)
     491    $item_output = str_replace('</a>', '<span class="menu-description">' . $item->description . '</span></a>', $item_output);
     492
     493  return $item_output;
    499494}
    500495
    501496add_filter('walker_nav_menu_start_el', 'chromenews_header_menu_desc', 10, 4);
    502497
    503 function chromenews_menu_notitle( $menu ){
    504     return $menu = preg_replace('/ title=\"(.*?)\"/', '', $menu );
    505 
    506 }
    507 add_filter( 'wp_nav_menu', 'chromenews_menu_notitle' );
    508 add_filter( 'wp_page_menu', 'chromenews_menu_notitle' );
    509 add_filter( 'wp_list_categories', 'chromenews_menu_notitle' );
    510 
    511 add_action( 'after_setup_theme', 'chromenews_transltion_init');
    512 
    513 function chromenews_transltion_init() {
    514     load_theme_textdomain( 'chromenews', false, get_template_directory()  . '/languages' );
    515 }
     498function chromenews_menu_notitle($menu)
     499{
     500  return $menu = preg_replace('/ title=\"(.*?)\"/', '', $menu);
     501}
     502add_filter('wp_nav_menu', 'chromenews_menu_notitle');
     503add_filter('wp_page_menu', 'chromenews_menu_notitle');
     504add_filter('wp_list_categories', 'chromenews_menu_notitle');
     505
     506add_action('after_setup_theme', 'chromenews_transltion_init');
     507
     508function chromenews_transltion_init()
     509{
     510  load_theme_textdomain('chromenews', false, get_template_directory()  . '/languages');
     511}
Note: See TracChangeset for help on using the changeset viewer.