ia/mediaelement-and-player.min.js', array(), false, true); wp_enqueue_script('canon-placeholder', get_template_directory_uri(). '/js/placeholder.js', array(), false, true); wp_enqueue_script('canon-mosaic', get_template_directory_uri(). '/js/mosaic.1.0.1.min.js', array(), false, true); wp_enqueue_script('canon-matchHeight', get_template_directory_uri(). '/js/jquery.matchHeight-min.js', array(), false, true); wp_enqueue_script('canon-cleantabs', get_template_directory_uri(). '/js/cleantabs.jquery.js', array(), false, true); wp_enqueue_script('canon-scrollup', get_template_directory_uri(). '/js/jquery.scrollUp.min.js', array(), false, true); wp_enqueue_script('canon-selectivizr', get_template_directory_uri(). '/js/selectivizr-min.js', array(), false, true); wp_enqueue_script('canon-fittext', get_template_directory_uri(). '/js/fittext.js', array(), false, true); wp_enqueue_script('canon-owl-carousel', get_template_directory_uri(). '/js/owl-carousel/owl.carousel.min.js', array(), false, true); wp_enqueue_script('canon-scrollreveal', get_template_directory_uri(). '/js/scrollReveal.js', array(), false, true); //canon scripts wp_enqueue_script('canon-global-functions', get_template_directory_uri(). '/js/global_functions.js', array(), false, true); wp_enqueue_script('canon-custom-scripts', get_template_directory_uri(). '/js/custom-scripts.js', array(), false, true); wp_enqueue_script('canon-scripts', get_template_directory_uri() . '/js/scripts.js', array('jquery'), false, true); //support for threaded comments if (is_singular() && get_option('thread_comments')) wp_enqueue_script('comment-reply'); //styles (css) wp_enqueue_style('normalize', get_template_directory_uri(). '/css/normalize.min.css'); wp_enqueue_style('canon-flexslider-style', get_template_directory_uri(). '/css/flexslider.css'); wp_enqueue_style('canon-font-awesome-style', get_template_directory_uri(). '/css/font-awesome.css'); wp_enqueue_style('canon-owl-carousel-style', get_template_directory_uri(). '/js/owl-carousel/owl.carousel.css'); wp_enqueue_style('canon-mosaic-style', get_template_directory_uri(). '/css/mosaic.css'); wp_enqueue_style('canon-sidr-style', get_template_directory_uri(). '/css/jquery.sidr.light.css'); wp_enqueue_style('canon-mediaelementplayer-style', get_template_directory_uri(). '/js/media/mediaelementplayer.min.css'); wp_enqueue_style('canon-fancybox-style', get_template_directory_uri(). '/js/fancybox/jquery.fancybox.css'); wp_enqueue_style('canon-fancybox-buttons-style', get_template_directory_uri(). '/js/fancybox/helpers/jquery.fancybox-buttons.css'); wp_enqueue_style('canon-fancybox-thumbs-style', get_template_directory_uri(). '/js/fancybox/helpers/jquery.fancybox-thumbs.css'); if (class_exists('Woocommerce')) { wp_enqueue_style('canon-woo-shop-style', get_template_directory_uri(). '/css/woo-shop.css'); } // enqueue theme woocommerce style wp_enqueue_style('canon-composer-theme-style', get_template_directory_uri(). '/css/composer-theme-style.css', array('js_composer_front')); wp_enqueue_style('js_composer_custom_css', false, array('canon-composer-theme-style')); // core theme styles wp_enqueue_style('style', get_stylesheet_uri()); if (isset($canon_options['use_responsive_design'])) { if ($canon_options['use_responsive_design'] == "checked") { wp_enqueue_style('responsive_style', get_template_directory_uri(). '/css/responsive.css'); } } if (isset($canon_options['use_boxed_design'])) { if ($canon_options['use_boxed_design'] == "checked") { wp_enqueue_style('boxed_style', get_template_directory_uri(). '/css/boxed.css'); } else { wp_enqueue_style('fullwidth_style', get_template_directory_uri(). '/css/full.css'); } } // dynamic_css printout add_action('wp_print_scripts','canon_dynamic_css'); //localize sripts wp_localize_script('canon-scripts','extData', array( 'ajaxUrl' => admin_url('admin-ajax.php'), 'pageType' => mb_get_page_type(), 'templateURI' => get_template_directory_uri(), 'canonOptions' => $canon_options, 'canonOptionsFrame' => $canon_options_frame, 'canonOptionsPost' => $canon_options_post, 'canonOptionsAppearance' => $canon_options_appearance, 'canonOptionsAdvanced' => $canon_options_advanced, )); } //back end includes function canon_load_to_back() { //get options $canon_options = get_option('canon_options'); $canon_options_advanced = get_option('canon_options_advanced'); //wp scripts (js) wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui', false, array(), false, true); wp_enqueue_script('jquery-ui-sortable', false, array(), false, true); wp_enqueue_script('thickbox', false, array(), false, true); wp_enqueue_script('media-upload', false, array(), false, true); //external scripts wp_enqueue_script('canon-admin-colorpicker', get_template_directory_uri() . '/js/colorpicker.js', array(), false, true); wp_enqueue_script('canon-admin-scripts', get_template_directory_uri() . '/js/admin-scripts.js', array(), false, true); //style (css) wp_enqueue_style('thickbox'); wp_enqueue_style('canon-admin-style', get_template_directory_uri(). '/css/admin-style.css'); wp_enqueue_style('canon-admin-font-awesome-style', get_template_directory_uri(). '/css/font-awesome.css'); wp_enqueue_style('canon-admin-colorpicker-style', get_template_directory_uri(). '/css/colorpicker.css'); //localize sripts wp_localize_script('canon-admin-scripts','extData', array( 'templateURI' => get_template_directory_uri(), 'ajaxURL' => admin_url('admin-ajax.php'), 'canonOptions' => $canon_options, 'canonOptionsAdvanced' => $canon_options_advanced, )); if ( strpos(get_current_screen()->id, 'canon_options_appearance') !== false ) wp_localize_script('canon-admin-scripts','extDataFonts', array('fonts' => mb_get_google_webfonts())); } /************************************** SETUP THEME ***************************************/ add_action( 'after_setup_theme', 'canon_setup_theme' ); function canon_setup_theme() { /************************************** GET OPTIONS ***************************************/ $canon_options = get_option('canon_options'); $canon_options_advanced = get_option('canon_options_advanced'); /************************************** ADD ACTIONS ***************************************/ // front end includes add_action('wp_enqueue_scripts','canon_load_to_front'); // back end includes add_action('admin_enqueue_scripts', 'canon_load_to_back'); // add post views counter to all posts add_action('wp_head', 'mb_update_post_views_single_check' ); // media upload customize add_action( 'admin_init', 'check_upload_page' ); // hide theme settings from non-admins add_action( 'admin_menu', 'hide_theme_settings_from_non_admins' ); // maintenance mode reminder if ($canon_options['use_maintenance_mode'] == "checked") { add_action('admin_notices','canon_maintenance_mode_reminder'); } /************************************** ADD FILTERS ***************************************/ // disable woocommerce default styles if (class_exists('Woocommerce')) { add_filter( 'woocommerce_enqueue_styles', '__return_false' ); } // make shortcodes execute in widget texts add_filter('widget_text', 'do_shortcode'); /************************************** ADD_THEME_SUPPORT CALLS ***************************************/ // Add default posts and comments RSS feed links to . add_theme_support( 'automatic-feed-links' ); // This theme uses Featured Images add_theme_support( 'post-thumbnails' ); //post formats add_theme_support('post-formats', array('quote','gallery','video','audio')); // woocommerce add_theme_support( 'woocommerce' ); // visual composer set as theme and disable updater if (function_exists('vc_set_as_theme')) { vc_set_as_theme($disable_updater = true); } // visual composer disable front end if (function_exists('vc_disable_frontend')) { vc_disable_frontend(); } /************************************** IMAGE SIZES ***************************************/ add_image_size( 'small_square_thumb', 130, 130, true); //set general content width if (!isset($content_width)) $content_width = 1320; /************************************** REGISTER MENUS ***************************************/ //register primary menu register_nav_menus(array( 'primary_menu' => 'Primary Menu' )); //register secondary menu register_nav_menus(array( 'secondary_menu' => 'Secondary Menu' )); /************************************** LOCALIZATION INIT ***************************************/ $lang_dir = get_template_directory() . '/lang'; load_theme_textdomain('loc_canon', $lang_dir); /************************************** REGISTER THEME WIDGET AREAS ***************************************/ // SIDEBARS if (function_exists('register_sidebar')) { register_sidebar(array( 'id' => "canon_archive_sidebar_widget_area", 'name' => 'Post/Archive Sidebar Widget Area', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' )); } if (function_exists('register_sidebar')) { register_sidebar(array( 'id' => "canon_page_sidebar_widget_area", 'name' => 'Page Sidebar Widget Area', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' )); } // FOOTER WIDGET AREAS if (function_exists('register_sidebar')) { register_sidebar(array( 'id' => "canon_footer_widget_area_1", 'name' => 'Footer: Widget Area 1', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' )); } if (function_exists('register_sidebar')) { register_sidebar(array( 'id' => "canon_footer_widget_area_2", 'name' => 'Footer: Widget Area 2', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' )); } if (function_exists('register_sidebar')) { register_sidebar(array( 'id' => "canon_footer_widget_area_3", 'name' => 'Footer: Widget Area 3', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' )); } if (function_exists('register_sidebar')) { register_sidebar(array( 'id' => "canon_footer_widget_area_4", 'name' => 'Footer: Widget Area 4', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' )); } if (function_exists('register_sidebar')) { register_sidebar(array( 'id' => "canon_footer_widget_area_5", 'name' => 'Footer: Widget Area 5', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' )); } /************************************** REGISTER CUSTOM WIDGET AREAS ***************************************/ $canon_options_advanced = get_option('canon_options_advanced'); if (isset($canon_options_advanced['custom_widget_areas'])) { for ($i = 0; $i < count($canon_options_advanced['custom_widget_areas']); $i++) { if (isset($canon_options_advanced['custom_widget_areas'][$i])) { $cwa_name = $canon_options_advanced['custom_widget_areas'][$i]; $cwa_slug = mb_create_slug($cwa_name); if (function_exists('register_sidebar') && !empty($cwa_name)) { register_sidebar(array( 'id' => 'canon_cwa_' . $cwa_slug, 'name' => $cwa_name, 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' )); } } } } } // end canon_setup_theme /************************************** MEDIA UPLOAD CUSTOMIZE ***************************************/ function check_upload_page() { global $pagenow; if ( 'media-upload.php' == $pagenow || 'async-upload.php' == $pagenow ) { // Now we'll replace the 'Insert into Post Button' inside Thickbox add_filter( 'gettext', 'replace_thickbox_text', 1, 3 ); } } function replace_thickbox_text($translated_text, $text, $domain) { if ('Insert into Post' == $text) { $referer_strpos = strpos( wp_get_referer(), 'referer=boost_' ); if ( $referer_strpos != '' ) { //now get the referer $referer_str = wp_get_referer(); $explode_arr = explode('referer=', $referer_str); $explode_arr = explode('&type=', $explode_arr[1]); $referer = $explode_arr[0]; //define button text for each referer if ($referer == "boost_logo") return "Use as logo"; if ($referer == "boost_favicon") return "Use as favicon"; if ($referer == "boost_bg") return "Use as background"; if ($referer == "boost_media") return "Use this media file"; if ($referer == "boost_default") return "Use this image"; //default return $referer; } } return $translated_text; } /************************************** REMOVE THEME SETTINGS FOR NON-ADMINS ***************************************/ function hide_theme_settings_from_non_admins(){ if (!current_user_can('switch_themes')) { remove_menu_page('handle_canon_options'); } } /************************************** SET THEME COOKIE ***************************************/ add_action('init','set_scene_cookie'); function set_scene_cookie() { if (!isset($_COOKIE['scene_cookie'])) { setcookie('scene_cookie', "user-ratings=", time()+(60*60*24*365), COOKIEPATH, COOKIE_DOMAIN, false); } } /************************************** MAINTENANCE MODE REMINDER ***************************************/ function canon_maintenance_mode_reminder() { printf('

%s

', __('Maintenance mode is on - remember that only logged-in users will be able to see your site pages. Go to Settings > General > Maintenance Mode to disable.','loc_canon')); } Γιώργος ΠαπασίμοςMarch 19, 2018 - Γιώργος Παπασίμος