array( 'image' => get_template_directory_uri() . '/library/images/demo/slider-default01.jpg', 'text' => sprintf( __( '
Style is what you do with it
', 'shopstar' ), esc_url( 'https://www.outtheboxthemes.com/wordpress-themes/shopstar/' ), __( 'Shop Now', 'shopstar' ) ) ), 'slide2' => array( 'image' => get_template_directory_uri() . '/library/images/demo/slider-default02.jpg', 'text' => sprintf( __( 'But your outfit can be
', 'shopstar' ), esc_url( 'https://www.outtheboxthemes.com/wordpress-themes/shopstar/' ), __( 'Shop Now', 'shopstar' ) ) ) ); } if ( ! function_exists( 'shopstar_setup' ) ) : /** * Sets up theme defaults and registers support for various WordPress features. * * Note that this function is hooked into the after_setup_theme hook, which * runs before the init hook. The init hook is too late for some features, such * as indicating support for post thumbnails. */ function shopstar_setup() { /** * Set the content width based on the theme's design and stylesheet. */ global $content_width; if ( ! isset( $content_width ) ) { $content_width = 832; /* pixels */ } $editor_styles = array( 'library/css/editor-style.css' ); $editor_styles[] = shopstar_fonts_url(); add_editor_style( $editor_styles ); if ( !get_theme_mod( 'otb_shopstar_dot_org' ) ) set_theme_mod( 'otb_shopstar_dot_org', true ); if ( !get_theme_mod( 'otb_shopstar_activated' ) ) set_theme_mod( 'otb_shopstar_activated', date('Y-m-d') ); /* * Make theme available for translation. * Translations can be filed in the /languages/ directory. * If you're building a theme based on shopstar, use a find and replace * to change 'shopstar' to the name of your theme in all the template files. */ load_theme_textdomain( 'shopstar', get_template_directory() . '/languages' ); // Add default posts and comments RSS feed links to head. add_theme_support( 'automatic-feed-links' ); /* * Enable support for Post Thumbnails on posts and pages. * * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails */ add_theme_support( 'post-thumbnails' ); add_image_size( 'shopstar_blog_img_side', 352, 230, true ); // This theme uses wp_nav_menu() in one location. register_nav_menus( array( 'primary' => esc_html__( 'Primary Menu', 'shopstar' ) ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'navigation-widgets' ) ); /* * Setup Custom Logo Support for theme * Supported from WordPress version 4.5 onwards * More Info: https://make.wordpress.org/core/2016/03/10/custom-logo/ */ if ( function_exists( 'has_custom_logo' ) ) { add_theme_support( 'custom-logo' ); } // The custom header is used for the logo add_theme_support( 'custom-header', array( 'default-image' => esc_url( get_template_directory_uri() ) . '/library/images/headers/default.jpg', 'width' => 1680, 'height' => 600, 'flex-width' => true, 'flex-height' => true, 'header-text' => false, ) ); // Set up the WordPress core custom background feature. add_theme_support( 'custom-background', apply_filters( 'shopstar_custom_background_args', array( 'default-color' => 'FFFFFF', 'default-image' => '', ) ) ); add_theme_support( 'title-tag' ); // Gutenberg Support add_theme_support( 'align-wide' ); // Toggle WordPress 5.8+ block-based widgets if ( !get_theme_mod( 'shopstar-gutenberg-enable-block-based-widgets', customizer_library_get_default( 'shopstar-gutenberg-enable-block-based-widgets' ) ) ) { remove_theme_support( 'widgets-block-editor' ); } add_theme_support( 'woocommerce', array( 'gallery_thumbnail_image_width' => 300 ) ); if ( get_theme_mod( 'shopstar-woocommerce-product-image-zoom', true ) ) { add_theme_support( 'wc-product-gallery-zoom' ); } add_theme_support( 'wc-product-gallery-lightbox' ); add_theme_support( 'wc-product-gallery-slider' ); add_theme_support( 'responsive-embeds' ); add_theme_support( 'custom-spacing' ); } endif; // shopstar_setup add_action( 'after_setup_theme', 'shopstar_setup' ); if ( ! function_exists( 'shopstar_fonts_url' ) ) : /** * Register custom fonts. */ function shopstar_fonts_url() { $fonts_url = ''; $font_families = array(); $font_families[] = 'Prata:400'; $font_families[] = 'Raleway:100,300,400,500,600,700,800'; $font_families[] = 'Lato:300,300italic,400,400italic,600,600italic,700,700italic'; $font_families[] = 'Lora:400italic'; $query_args = array( 'family' => urlencode( implode( '|', $font_families ) ), 'subset' => urlencode( 'latin,latin-ext' ), ); $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); return esc_url_raw( $fonts_url ); } endif; /** * Enqueue admin scripts and styles. */ function shopstar_admin_scripts() { wp_enqueue_style( 'shopstar-admin', get_template_directory_uri() . '/library/css/admin.css', array(), SHOPSTAR_THEME_VERSION ); wp_enqueue_script( 'shopstar-admin', get_template_directory_uri() . '/library/js/admin.js', SHOPSTAR_THEME_VERSION, true ); } add_action( 'admin_enqueue_scripts', 'shopstar_admin_scripts' ); function shopstar_set_elementor_default_schemes( $config ) { // Primary $config['schemes']['items']['color']['items']['1']['value'] = get_theme_mod( 'shopstar-heading-font-color', customizer_library_get_default( 'shopstar-heading-font-color' ) ); // Secondary $config['schemes']['items']['color']['items']['2']['value'] = get_theme_mod( 'shopstar-primary-color', customizer_library_get_default( 'shopstar-primary-color' ) ); // Text $config['schemes']['items']['color']['items']['3']['value'] = get_theme_mod( 'shopstar-body-font-color', customizer_library_get_default( 'shopstar-body-font-color' ) ); // Accent $config['schemes']['items']['color']['items']['4']['value'] = get_theme_mod( 'shopstar-primary-color', customizer_library_get_default( 'shopstar-primary-color' ) ); // Primary Headline $config['schemes']['items']['typography']['items']['1']['value'] = [ 'font-family' => get_theme_mod( 'shopstar-heading-font', customizer_library_get_default( 'shopstar-heading-font' ) ), 'font-weight' => get_theme_mod( 'shopstar-heading-font-weight', customizer_library_get_default( 'shopstar-heading-font-weight' ) ) ]; // Secondary Headline $config['schemes']['items']['typography']['items']['2']['value'] = [ 'font-family' => get_theme_mod( 'shopstar-heading-font', customizer_library_get_default( 'shopstar-heading-font' ) ), 'font-weight' => get_theme_mod( 'shopstar-heading-font-weight', customizer_library_get_default( 'shopstar-heading-font-weight' ) ) ]; // Body Text $config['schemes']['items']['typography']['items']['3']['value'] = [ 'font-family' => get_theme_mod( 'shopstar-body-font', customizer_library_get_default( 'shopstar-body-font' ) ), //'font-weight' => get_theme_mod( 'shopstar-body-font-weight', customizer_library_get_default( 'shopstar-body-font-weight' ) ) ]; // Accent Text $config['schemes']['items']['typography']['items']['4']['value'] = [ 'font-family' => get_theme_mod( 'shopstar-heading-font', customizer_library_get_default( 'shopstar-heading-font' ) ), 'font-weight' => get_theme_mod( 'shopstar-heading-font-weight', customizer_library_get_default( 'shopstar-heading-font-weight' ) ) ]; $config['schemes']['items']['color-picker']['items']['1']['value'] = get_theme_mod( 'shopstar-primary-color', customizer_library_get_default( 'shopstar-primary-color' ) ); $config['schemes']['items']['color-picker']['items']['2']['value'] = get_theme_mod( 'shopstar-button-color', customizer_library_get_default( 'shopstar-button-color' ) ); $config['schemes']['items']['color-picker']['items']['3']['value'] = get_theme_mod( 'shopstar-body-font-color', customizer_library_get_default( 'shopstar-body-font-color' ) ); $config['schemes']['items']['color-picker']['items']['4']['value'] = get_theme_mod( 'shopstar-footer-color', customizer_library_get_default( 'shopstar-footer-color' ) ); $config['schemes']['items']['color-picker']['items']['5']['value'] = ''; $config['schemes']['items']['color-picker']['items']['6']['value'] = ''; $config['schemes']['items']['color-picker']['items']['7']['value'] = ''; $config['schemes']['items']['color-picker']['items']['8']['value'] = ''; return $config; }; add_filter('elementor/editor/localize_settings', 'shopstar_set_elementor_default_schemes', 100); // Adjust content_width for full width pages function shopstar_adjust_content_width() { global $content_width; if ( shopstar_is_woocommerce_activated() && is_woocommerce() ) { $is_woocommerce = true; } else { $is_woocommerce = false; } if ( is_page_template( 'template-full-width.php' ) ) { $content_width = 1140; } else if ( ( is_page_template( 'template-left-sidebar.php' ) || basename( get_page_template() ) === 'page.php' ) && !is_active_sidebar( 'sidebar-1' ) ) { $content_width = 1140; } else if ( shopstar_is_woocommerce_activated() && is_shop() && get_theme_mod( 'shopstar-layout-woocommerce-shop-full-width', customizer_library_get_default( 'shopstar-layout-woocommerce-shop-full-width' ) ) ) { $content_width = 1140; } else if ( shopstar_is_woocommerce_activated() && is_product() && get_theme_mod( 'shopstar-layout-woocommerce-product-full-width', customizer_library_get_default( 'shopstar-layout-woocommerce-product-full-width' ) ) ) { $content_width = 1140; } else if ( shopstar_is_woocommerce_activated() && ( is_product_category() || is_product_tag() ) && get_theme_mod( 'shopstar-layout-woocommerce-category-tag-page-full-width', customizer_library_get_default( 'shopstar-layout-woocommerce-category-tag-page-full-width' ) ) ) { $content_width = 1140; } else if ( $is_woocommerce && !is_active_sidebar( 'sidebar-1' ) ) { $content_width = 1140; } } add_action( 'template_redirect', 'shopstar_adjust_content_width' ); /** * Add a widget to the dashboard. * * This function is hooked into the 'wp_dashboard_setup' action below. */ /* function shopstar_add_dashboard_widgets() { wp_add_dashboard_widget( 'otb-dashboard-news', // Widget slug. __( 'Out the Box News', 'shopstar' ), // Title. 'otb_dashboard_news' // Display function. ); // Move the Out the Box widget to the top global $wp_meta_boxes; $dashboard = $wp_meta_boxes['dashboard']['normal']['core']; $ours = array( 'otb-dashboard-news' => $dashboard['otb-dashboard-news'] ); unset($dashboard['otb-dashboard-news']); $wp_meta_boxes['dashboard']['normal']['core'] = array_merge( $ours, $dashboard ); // WPCS: override ok. } add_action( 'wp_dashboard_setup', 'shopstar_add_dashboard_widgets', 20 ); */ /** * Create the function to output the contents of your Dashboard Widget. */ function otb_dashboard_news() { $feed = array( array( 'url' => 'https://www.outtheboxthemes.com/feed/', 'items' => 4, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 1, ), ); wp_dashboard_primary_output( 'otb_dashboard_widget_news', $feed ); if( function_exists( 'wp_print_community_events_markup' ) ) { ?> rating it on wordpress.org :)'; if ( !get_user_meta( $user_id, 'shopstar_review_notice_dismissed' ) ) { $class = 'notice notice-success is-dismissible'; printf( '', esc_attr( $class ), $message ); } } $today = new DateTime( date( 'Y-m-d' ) ); $activate = new DateTime( date( get_theme_mod( 'otb_shopstar_activated' ) ) ); if ( $activate->diff($today)->d >= 14 ) { add_action( 'admin_notices', 'shopstar_review_notice' ); } function shopstar_review_notice_dismissed() { $user_id = get_current_user_id(); if ( isset( $_GET['shopstar-review-notice-dismissed'] ) ) { add_user_meta( $user_id, 'shopstar_review_notice_dismissed', 'true', true ); } } add_action( 'admin_init', 'shopstar_review_notice_dismissed' ); function shopstar_admin_notice() { $user_id = get_current_user_id(); $message = array ( 'id' => 19, 'heading' => 'Black Friday Sale', 'text' => 'Get 40% off any of our Premium WordPress themes this Black Friday!', //'text' => '🎄Get 20% off any of our Premium WordPress themes until Christmas Day!🎄', 'link' => 'https://www.outtheboxthemes.com/go/theme-notification-black-friday-2023-wordpress-themes/' ); if ( !empty( $message['text'] ) && !get_user_meta( $user_id, 'shopstar_admin_notice_' .$message['id']. '_dismissed' ) ) { $class = 'notice otb-notice notice-success is-dismissible'; printf( '', esc_attr( $class ), $message['heading'], $message['text'], $message['link'], $message['id'] ); } } if ( date('Y-m-d') >= '2023-11-24' && date('Y-m-d') <= '2023-11-27' ) { add_action( 'admin_notices', 'shopstar_admin_notice' ); } function shopstar_admin_notice_dismissed() { $user_id = get_current_user_id(); if ( isset( $_GET['shopstar-admin-notice-dismissed'] ) ) { $shopstar_admin_notice_id = $_GET['shopstar-admin-notice-id']; add_user_meta( $user_id, 'shopstar_admin_notice_' .$shopstar_admin_notice_id. '_dismissed', 'true', true ); } } add_action( 'admin_init', 'shopstar_admin_notice_dismissed' ); /** * Register widget area. * * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar */ function shopstar_widgets_init() { register_sidebar( array( 'name' => esc_html__( 'Sidebar', 'shopstar' ), 'id' => 'sidebar-1', 'description' => '', 'before_widget' => '', 'before_title' => ''; echo __( 'Out of Stock', 'shopstar' ); echo '
'; } } /* if (!function_exists('woocommerce_template_loop_add_to_cart')) { function woocommerce_template_loop_add_to_cart( $args = array() ) { global $product; if (!$product->is_in_stock()) { echo ''; echo __( 'Out of Stock', 'shopstar' ); echo '
'; } else { $defaults = array( 'quantity' => 1, 'class' => implode( ' ', array_filter( array( 'button', 'product_type_' . $product->get_type(), $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', $product->supports( 'ajax_add_to_cart' ) ? 'ajax_add_to_cart' : '' ) ) ) ); $args = apply_filters( 'woocommerce_loop_add_to_cart_args', wp_parse_args( $args, $defaults ), $product ); wc_get_template( 'loop/add-to-cart.php', $args ); } } } */ function shopstar_excerpt_length( $length ) { if ( is_admin() || ( !is_home() && !is_category() && !is_tag() && !is_search() ) ) { return $length; } else { return get_theme_mod( 'shopstar-blog-excerpt-length', customizer_library_get_default( 'shopstar-blog-excerpt-length' ) ); } } add_filter( 'excerpt_length', 'shopstar_excerpt_length', 999 ); if ( ! function_exists( 'shopstar_excerpt_more' ) ) { function shopstar_excerpt_more( $more ) { if ( is_admin() ) { return $more; } else { return ' ' . wp_kses_post( pll__( get_theme_mod( 'shopstar-blog-read-more-text', customizer_library_get_default( 'shopstar-blog-read-more-text' ) ) ), 'shopstar' ) . ''; } } } add_filter( 'excerpt_more', 'shopstar_excerpt_more' ); /** * Adjust is_home query if shopstar-slider-categories is set */ function shopstar_set_blog_queries( $query ) { $slider_categories = get_theme_mod( 'shopstar-slider-categories' ); $slider_type = get_theme_mod( 'shopstar-slider-type', customizer_library_get_default( 'shopstar-slider-type' ) ); if ( $slider_categories != '' && $slider_type == 'shopstar-slider-default' ) { $is_front_page = ( $query->get('page_id') == get_option('page_on_front') || is_front_page() ); if ( count($slider_categories) > 0) { // do not alter the query on wp-admin pages and only alter it if it's the main query if ( !is_admin() && !$is_front_page && $query->get('id') != 'slider' || !is_admin() && $is_front_page && $query->get('id') != 'slider' ){ $query->set( 'category__not_in', $slider_categories ); } } } } add_action( 'pre_get_posts', 'shopstar_set_blog_queries' ); function shopstar_filter_recent_posts_widget_parameters( $params ) { $slider_categories = get_theme_mod( 'shopstar-slider-categories' ); $slider_type = get_theme_mod( 'shopstar-slider-type', customizer_library_get_default( 'shopstar-slider-type' ) ); if ( $slider_categories != '' && $slider_type == 'shopstar-slider-default' ) { if ( count($slider_categories) > 0) { // do not alter the query on wp-admin pages and only alter it if it's the main query $params['category__not_in'] = $slider_categories; } } return $params; } add_filter('widget_posts_args','shopstar_filter_recent_posts_widget_parameters'); /** * Adjust the widget categories query if shopstar-slider-categories is set */ function shopstar_set_widget_categories_args($args){ $slider_categories = get_theme_mod( 'shopstar-slider-categories' ); $slider_type = get_theme_mod( 'shopstar-slider-type', customizer_library_get_default( 'shopstar-slider-type' ) ); if ( $slider_categories != '' && $slider_type == 'shopstar-slider-default' ) { if ( count($slider_categories) > 0) { $exclude = implode(',', $slider_categories); $args['exclude'] = $exclude; } } return $args; } add_filter('widget_categories_args', 'shopstar_set_widget_categories_args'); function shopstar_set_widget_categories_dropdown_arg($args){ $slider_categories = get_theme_mod( 'shopstar-slider-categories' ); $slider_type = get_theme_mod( 'shopstar-slider-type', customizer_library_get_default( 'shopstar-slider-type' ) ); if ( $slider_categories != '' && $slider_type == 'shopstar-slider-default' ) { if ( count($slider_categories) > 0) { $exclude = implode(',', $slider_categories); $args['exclude'] = $exclude; } } return $args; } add_filter('widget_categories_dropdown_args', 'shopstar_set_widget_categories_dropdown_arg'); function shopstar_update_allowed_tags( $tags ) { $tags["h1"] = array(); $tags["h2"] = array(); $tags["h3"] = array(); $tags["h4"] = array(); $tags["h5"] = array(); $tags["h6"] = array(); $tags["p"] = array(); $tags["br"] = array(); return $tags; } add_filter( 'wp_kses_allowed_html', 'shopstar_update_allowed_tags' ); function shopstar_register_required_plugins() { $plugins = array( array( 'name' => __( 'Super Simple Slider', 'shopstar' ), 'slug' => 'super-simple-slider', 'required' => false ), array( 'name' => __( 'Elementor Page Builder', 'shopstar' ), 'slug' => 'elementor', 'required' => false ), array( 'name' => __( 'SiteOrigin Widgets Bundle', 'shopstar' ), 'slug' => 'so-widgets-bundle', 'required' => false ), array( 'name' => __( 'Beam me up Scotty', 'shopstar' ), 'slug' => 'beam-me-up-scotty', 'required' => false ), array( 'name' => __( 'WPForms', 'shopstar' ), 'slug' => 'wpforms-lite', 'required' => false ), array( 'name' => __( 'WooCommerce', 'shopstar' ), 'slug' => 'woocommerce', 'required' => false ), array( 'name' => __( 'MailChimp for WordPress', 'shopstar' ), 'slug' => 'mailchimp-for-wp', 'required' => false ), array( 'name' => __( 'Anti-Spam', 'shopstar' ), 'slug' => 'anti-spam', 'required' => false ), array( 'name' => __( 'Yoast SEO', 'shopstar' ), 'slug' => 'wordpress-seo', 'required' => false ) ); $config = array( 'id' => 'shopstar', // Unique ID for hashing notices for multiple instances of TGMPA. 'default_path' => '', // Default absolute path to bundled plugins. 'menu' => 'tgmpa-install-plugins', // Menu slug. 'has_notices' => true, // Show admin notices or not. 'dismissable' => true, // If false, a user cannot dismiss the nag message. 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag. 'is_automatic' => false, // Automatically activate plugins after installation or not. 'message' => '' // Message to output right before the plugins table. ); tgmpa( $plugins, $config ); } add_action( 'tgmpa_register', 'shopstar_register_required_plugins' ); /** * Determine if Custom Post Type * usage: if ( is_this_a_custom_post_type() ) * * References/Modified from: * @link https://codex.wordpress.org/Function_Reference/get_post_types * @link http://wordpress.stackexchange.com/users/73/toscho <== love this person! * @link http://wordpress.stackexchange.com/a/95906/64742 */ function shopstar_is_this_a_custom_post_type( $post = NULL ) { $all_custom_post_types = get_post_types( array ( '_builtin' => false ) ); //* there are no custom post types if ( empty ( $all_custom_post_types ) ) return false; $custom_types = array_keys( $all_custom_post_types ); $current_post_type = get_post_type( $post ); //* could not detect current type if ( ! $current_post_type ) return false; return in_array( $current_post_type, $custom_types ); } /** * Remove blog menu link class 'current_page_parent' when on an unrelated CPT * or search results page * or 404 page * dep: is_this_a_custom_post_type() function * modified from: https://gist.github.com/ajithrn/1f059b2201d66f647b69 */ function shopstar_if_cpt_or_search_or_404_remove_current_page_parent_on_blog_page_link( $classes, $item, $args ) { if ( shopstar_is_this_a_custom_post_type() || is_search() || is_404() ) { $blog_page_id = intval( get_option('page_for_posts') ); if ( $blog_page_id != 0 && $item->object_id == $blog_page_id ) { unset( $classes[array_search( 'current_page_parent', $classes )] ); } } return $classes; } add_filter( 'nav_menu_css_class', 'shopstar_if_cpt_or_search_or_404_remove_current_page_parent_on_blog_page_link', 10, 3 ); if ( function_exists( 'pll_register_string' ) ) { /** * Register some string from the customizer to be translated with Polylang */ function shopstar_pll_register_string() { // Header pll_register_string( 'shopstar-header-info-text', get_theme_mod( 'shopstar-header-info-text', customizer_library_get_default( 'shopstar-header-info-text' ) ), 'shopstar', false ); // Search pll_register_string( 'shopstar-search-placeholder-text', get_theme_mod( 'shopstar-search-placeholder-text', customizer_library_get_default( 'shopstar-search-placeholder-text' ) ), 'shopstar', false ); pll_register_string( 'shopstar-website-text-no-search-results-heading', get_theme_mod( 'shopstar-website-text-no-search-results-heading', customizer_library_get_default( 'shopstar-website-text-no-search-results-heading' ) ), 'shopstar', false ); pll_register_string( 'shopstar-website-text-no-search-results-text', get_theme_mod( 'shopstar-website-text-no-search-results-text', customizer_library_get_default( 'shopstar-website-text-no-search-results-text' ) ), 'shopstar', true ); // Header media pll_register_string( 'shopstar-header-image-text', get_theme_mod( 'shopstar-header-image-text', customizer_library_get_default( 'shopstar-header-image-text' ) ), 'shopstar', true ); // Blog read more pll_register_string( 'shopstar-blog-read-more-text', get_theme_mod( 'shopstar-blog-read-more-text', customizer_library_get_default( 'shopstar-blog-read-more-text' ) ), 'shopstar', true ); // 404 pll_register_string( 'shopstar-website-text-404-page-heading', get_theme_mod( 'shopstar-website-text-404-page-heading', customizer_library_get_default( 'shopstar-website-text-404-page-heading' ) ), 'shopstar', true ); pll_register_string( 'shopstar-website-text-404-page-text', get_theme_mod( 'shopstar-website-text-404-page-text', customizer_library_get_default( 'shopstar-website-text-404-page-text' ) ), 'shopstar', true ); } add_action( 'admin_init', 'shopstar_pll_register_string' ); } /** * A fallback function that outputs a non-translated string if Polylang is not active * * @param $string * * @return void */ if ( !function_exists( 'pll_e' ) ) { function pll_e( $str ) { echo $str; } } /** * A fallback function that returns a non-translated string if Polylang is not active * * @param $string * * @return string */ if ( !function_exists( 'pll__' ) ) { function pll__( $str ) { return $str; } }