public function enqueue_scripts() { hocwp_register_core_style_and_script(); $localize_object = hocwp_default_script_localize_object(); if (hocwp_is_debugging()) { wp_localize_script('hocwp', 'hocwp', $localize_object); wp_register_script('hocwp-front-end', HOCWP_URL . '/js/hocwp-front-end' . HOCWP_JS_SUFFIX, array('hocwp'), false, true); wp_register_script($this->textdomain, $this->url . '/js/hocwp-plugin' . HOCWP_JS_SUFFIX, array('hocwp-front-end'), false, true); } else { wp_register_script($this->textdomain, $this->url . '/js/hocwp-plugin' . HOCWP_JS_SUFFIX, array(), $this->version, true); wp_localize_script($this->textdomain, 'hocwp', $localize_object); } wp_register_style($this->textdomain . '-style', $this->url . '/css/hocwp-plugin' . HOCWP_CSS_SUFFIX, array(), $this->version); wp_enqueue_style($this->textdomain . '-style'); $script = apply_filters($this->name . '_use_scripts', true); if ($script) { wp_enqueue_script($this->textdomain); } }
function hocwp_setup_theme_scripts() { do_action('hocwp_enqueue_scripts'); if (hocwp_use_jquery_cdn()) { hocwp_load_jquery_from_cdn(); } hocwp_theme_register_lib_superfish(); hocwp_theme_register_lib_bootstrap(); hocwp_theme_register_lib_font_awesome(); hocwp_theme_register_core_style_and_script(); if (hocwp_theme_sticky_last_widget()) { hocwp_theme_register_lib_sticky(); } $localize_object = array('expand' => '<span class="screen-reader-text">' . esc_html__('expand child menu', 'hocwp-theme') . '</span>', 'collapse' => '<span class="screen-reader-text">' . esc_html__('collapse child menu', 'hocwp-theme') . '</span>'); $localize_object = wp_parse_args($localize_object, hocwp_theme_default_script_localize_object()); $use = hocwp_use_core_style(); $superfish = hocwp_use_superfish_menu(); if (hocwp_is_debugging()) { wp_localize_script('hocwp', 'hocwp', $localize_object); wp_register_style('hocwp-front-end-style', get_template_directory_uri() . '/hocwp/css/hocwp-front-end' . HOCWP_CSS_SUFFIX, array('hocwp-style')); wp_register_script('hocwp-front-end', get_template_directory_uri() . '/hocwp/js/hocwp-front-end' . HOCWP_JS_SUFFIX, array('hocwp'), false, true); $style_deps = array('bootstrap-style', 'font-awesome-style', 'superfish-style', 'hocwp-front-end-style'); $script_deps = array('superfish', 'bootstrap', 'hocwp-front-end'); if (!$use) { unset($style_deps[array_search('hocwp-front-end-style', $style_deps)]); } if (!$superfish) { unset($style_deps[array_search('superfish-style', $style_deps)]); unset($script_deps[array_search('superfish', $script_deps)]); } wp_register_style('hocwp-custom-font-style', get_template_directory_uri() . '/css/hocwp-custom-font' . HOCWP_CSS_SUFFIX); $style_deps[] = 'hocwp-custom-font-style'; wp_register_style('hocwp-custom-front-end-style', get_template_directory_uri() . '/css/hocwp-custom-front-end' . HOCWP_CSS_SUFFIX, $style_deps); wp_register_script('hocwp-custom-front-end', get_template_directory_uri() . '/js/hocwp-custom-front-end' . HOCWP_JS_SUFFIX, $script_deps, false, true); } else { $style_deps = array('bootstrap-style', 'font-awesome-style', 'superfish-style'); $script_deps = array('superfish', 'bootstrap'); if (!$superfish) { unset($style_deps[array_search('superfish-style', $style_deps)]); unset($script_deps[array_search('superfish', $script_deps)]); } wp_register_style('hocwp-custom-front-end-style', get_template_directory_uri() . '/css/hocwp-custom-front-end' . HOCWP_CSS_SUFFIX, $style_deps, HOCWP_THEME_VERSION); wp_register_script('hocwp-custom-front-end', get_template_directory_uri() . '/js/hocwp-custom-front-end' . HOCWP_JS_SUFFIX, $script_deps, HOCWP_THEME_VERSION, true); wp_localize_script('hocwp-custom-front-end', 'hocwp', $localize_object); } if (!hocwp_in_maintenance_mode()) { wp_enqueue_style('hocwp-custom-front-end-style'); wp_enqueue_script('hocwp-custom-front-end'); } if (is_singular()) { $post_id = get_the_ID(); if (comments_open($post_id) && (bool) get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } } }