Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Include Beans. Do not remove the line below.
- require_once( get_template_directory() . '/lib/init.php' );
- /////////////////////////////////////////////////
- // PREVENT AUTO PLUGIN UPDATES
- /////////////////////////////////////////////////
- add_filter( 'auto_update_plugin', '__return_false' );
- /////////////////////////////////////////////////
- // ENQUEUE STUFF
- /////////////////////////////////////////////////
- add_action( 'beans_uikit_enqueue_scripts', 'beans_child_enqueue_uikit_assets' );
- function beans_child_enqueue_uikit_assets() {
- // Enqueue UIkit necessary extra components.
- beans_uikit_enqueue_components( array( 'flex', 'contrast', 'toggle', 'slideset', 'scrollspy', 'animation','dropdown', 'modal', 'tooltip', 'smooth-scroll', 'switcher', 'tab', 'cover' ) );
- beans_uikit_enqueue_components( array( 'accordion', 'lightbox','sortable'), 'add-ons' );
- // Enqueue child theme style.less
- beans_compiler_add_fragment( 'uikit', get_stylesheet_directory_uri() . '/style.less', 'less' );
- }
- /////////////////////////////////////////////////
- // RANK MATH DISABLE ON DIRECTORY
- /////////////////////////////////////////////////
- /////////////////////////////////////////////////
- // BODY FADE
- /////////////////////////////////////////////////
- beans_add_attribute('beans_body', 'data-uk-scrollspy', 'cls:"uk-animation-fade", delay:100');
- //////
- /// custom javascript
- add_action( 'wp_enqueue_scripts', function(){
- wp_register_script('custom-front', get_stylesheet_directory_uri() . '/js/custom-front.js', array('jquery'), '1.0.0', false);
- wp_register_script('custom-dashboard', get_stylesheet_directory_uri() . '/js/custom-dashboard.js', array('jquery'), '1.0.0', false);
- wp_register_script('custom-overview', get_stylesheet_directory_uri() . '/js/custom-overview.js', array('jquery'), '1.0.0', false);
- wp_register_script('custom-refund', get_stylesheet_directory_uri() . '/js/custom-refund.js', array('jquery'), '1.0.0', false);
- wp_register_script('custom-vendor', get_stylesheet_directory_uri() . '/js/custom-vendor.js', array('jquery'), '1.0.0', false);
- wp_enqueue_script( 'custom-front' );
- if(current_user_can('vendor')){
- wp_enqueue_script( 'custom-dashboard' );
- wp_enqueue_script( 'custom-overview' );
- wp_enqueue_script( 'custom-refund' );
- wp_enqueue_script( 'custom-vendor' );
- }
- });
- /////////////////////////////////////////////////
- // EMAIL ENCODING
- /////////////////////////////////////////////////
- function email_encode_function( $atts, $content ){
- return '<a style="text-decoration:underline" href="'.antispambot("mailto:".$content).'">'.antispambot($content).'</a>';
- }
- add_shortcode( 'email', 'email_encode_function' );
- /////////////////////////////////////////////////
- //GOOGLE MATERIAL ICONS
- /////////////////////////////////////////////////
- //Enqueue Google icon font
- wp_enqueue_style('material_icons', 'https://fonts.googleapis.com/icon?family=Material+Icons');
- /////////////////////////////////////////////////
- //GRIDS
- /////////////////////////////////////////////////
- // Enqueue the UIkit dynamic grid component.
- add_action( 'beans_uikit_enqueue_scripts', 'beans_child_enqueue_grid_uikit_assets' );
- function beans_child_enqueue_grid_uikit_assets() {
- // Stop here if we are on a single view.
- if ( is_single() )
- return;
- beans_uikit_enqueue_components( array( 'grid' ), 'add-ons' );
- }
- /////////////////////////////////////////////////
- //IMAGES AND VIDEO
- /////////////////////////////////////////////////
- //add div around video embed
- add_filter( 'embed_oembed_html', 'custom_oembed_filter', 10, 4 ) ;
- function custom_oembed_filter($html, $url, $attr, $post_ID) {
- $return = '<div class="video-container">'.$html.'</div>';
- return $return;
- }
- //Add padding to the_content
- beans_add_attribute('the_content', 'class', 'my-padding-large');
- //Change default image options in display settings media uploader
- function mytheme_setup() {
- // Set default values for the upload media box
- update_option('image_default_align', 'left' );
- update_option('image_default_link_type', 'media' );
- update_option('image_default_size', 'original' );
- }
- add_action('after_setup_theme', 'mytheme_setup');
- //add class to p tag
- beans_add_attribute('woo_cart_shipping_calculator_note', 'class', 'my-mar-zero-t');
- /////////////////////////////////////////////////
- //REGISTER NEW MENU LOCATIONS
- /////////////////////////////////////////////////
- function register_my_menus() {
- register_nav_menus(
- array(
- 'womens-menu' => __( 'Womens Menu' ),
- 'mens-menu' => __( 'Mens Menu' ),
- 'kids-menu' => __( 'Kids Menu' )
- )
- );
- }
- add_action( 'init', 'register_my_menus' );
- /////////////////////////////////////////////////
- // ADD OVERLAY MENU TO HEADER
- /////////////////////////////////////////////////
- add_action( 'beans_header_prepend_markup', 'add_overlay_menu' );
- function add_overlay_menu() {
- ?>
- <?php include( 'overlay-menu.php' ); ?>
- <?php
- }
- /////////////////////////////////////////////////
- // ADD SHARE INCLUDE TO ARCHIVE
- /////////////////////////////////////////////////
- //Create Share function
- function my_add_share(){
- include'includes/archive-share.php';
- }
- //Add Share to Archive
- add_action( 'woocommerce_after_shop_loop', 'my_add_share', 10 );
- /////////////////////////////////////////////////
- // RSS INCLUDE FEATURED IMAGE
- /////////////////////////////////////////////////
- function featuredtoRSS($content) {
- global $post;
- if ( has_post_thumbnail( $post->ID ) ){
- $content = '<div>' . get_the_post_thumbnail( $post->ID, 'full', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content;
- }
- return $content;
- }
- add_filter('the_excerpt_rss', 'featuredtoRSS');
- add_filter('the_content_feed', 'featuredtoRSS');
- /////////////////////////////////////////////////
- // WC Vendors Pro - Notify Vendor when Product is Approved
- /////////////////////////////////////////////////
- add_action( 'pending_to_publish', 'wcv_notify_vendor_on_publish' );
- function wcv_notify_vendor_on_publish( $post_id ) {
- global $post;
- if ( $post->post_author != get_current_user_id() ) {
- $author = new WP_User( $post->post_author );
- $email_data = array(
- 'to' => $author->user_email,
- 'subject' => sprintf( __( 'Your post on %1$s has been published!', 'email_author_on_publish' ), get_bloginfo('name') ),
- 'message' => sprintf( __( 'Your post "%1$s" on %2$s has been published: %3$s', 'email_author_on_publish' ), $post->post_title, get_bloginfo( 'name' ), get_permalink( $post->ID ) ),
- );
- wp_mail( $email_data['to'], $email_data['subject'], $email_data['message'] );
- }
- }
- /////////////////////////////////////////////////
- // MAILCHIMP CONNECTION
- /////////////////////////////////////////////////
- add_action('beans_head_append_markup', 'mc_connect');
- function mc_connect (){ ?>
- <script id="mcjs">!function(c,h,i,m,p){m=c.createElement(h),p=c.getElementsByTagName(h)[0],m.async=1,m.src=i,p.parentNode.insertBefore(m,p)}(document,"script","https://chimpstatic.com/mcjs-connected/js/users/b5f0a9b83205511058b288847/4767f05deda442c4f78661faf.js");</script>
- <?php }
- /////////////////////////////////////////////////
- // Pinterest
- /////////////////////////////////////////////////
- add_action('beans_head_append_markup', 'pin_connect');
- function pin_connect (){ ?>
- <meta name="p:domain_verify" content="464fe418dc3e48afbc7c8110d9d07d9e"/>
- <?php }
- /////////////////////////////////////////////////
- // INCLUDES
- /////////////////////////////////////////////////
- // include 'includes/cookie-message.php';
- // include 'includes/errors.php';
- include 'includes/support.php';
- include 'includes/nav.php';
- include 'includes/sticky.php';
- include 'includes/crumb.php';
- include 'includes/posts.php';
- include 'includes/loops.php';
- include 'includes/side-bar.php';
- include 'includes/foot.php';
- include 'includes/woo.php';
- include 'includes/vendors.php';
- include 'includes/custom-search.php';
- include 'includes/loop-amendments.php';
- include 'includes/archive-elements.php';
- include 'includes/ninja.php';
- include 'includes/stripe-refund-process.php';
- include 'includes/shortcode_def.php';
- //////////
- // WC Vendor
- ////////
- add_filter('wcv_my_account_msg', 'custom_wcv_my_account_msg');
- function custom_wcv_my_account_msg(){
- $message = 'To add or edit products, view sales and orders for your designer dashboard account, or to configure your store, visit your <a href="' . get_bloginfo('url') . '/dashboard">Designer Dashboard</a>';
- return $message;
- }
- //////
- // WC Vendor Store Settings
- /////
- function custom_payment_policy(){
- return '<div class="policy">
- <p class="meta_title">Payment Methods</p>
- <span style="font-size:30px; color:#222;"><i class="uk-icon-cc-visa "></i> <i class="uk-icon-cc-mastercard "></i> <i class="uk-icon-cc-discover "></i> <i class="uk-icon-cc-amex "></i> <i class="uk-icon-cc-jcb "></i> </span>
- <br/>
- <p>We accept payment by ALL MAJOR CREDIT CARDS only.</p>
- <p class="meta_title">Payment security</p>
- <p>Our payment processor has been audited by a PCI-certified auditor and is certified to PCI Service Provider Level 1. This is the most stringent level of certification available in the payments industry.</p>
- </div>';
- }
- function store_policy_shipping( ){
- if ( class_exists( 'WCVendors_Pro' ) ){
- $key = '_wcv_custom_settings_policy_shipping';
- $value = get_user_meta( get_current_user_id(), $key, true );
- // Bank Name
- WCVendors_Pro_Form_Helper::textarea( array(
- 'value' => $value,
- 'id' => $key,
- 'label' => __( 'Shipping Policy', 'wcvendors-pro' ),
- 'placeholder' => __( 'Information about your shipping terms', 'wcvendors-pro' ),
- 'desc_tip' => 'true'
- )
- );
- }
- }
- function store_policy_returns( ){
- if ( class_exists( 'WCVendors_Pro' ) ){
- $key = '_wcv_custom_settings_policy_returns';
- $value = get_user_meta( get_current_user_id(), $key, true );
- WCVendors_Pro_Form_Helper::textarea( array(
- 'value' => $value,
- 'id' => $key,
- 'label' => __( 'Returns, Exchanges & Refunds Policy', 'wcvendors-pro' ),
- 'placeholder' => __( 'How you handle returns, exchanges and refunds', 'wcvendors-pro' ),
- 'desc_tip' => 'true',
- ) );
- }
- }
- function store_policy_additional( ){
- if ( class_exists( 'WCVendors_Pro' ) ){
- $key = '_wcv_custom_settings_policy_additional';
- $value = get_user_meta( get_current_user_id(), $key, true );
- // Bank Name
- WCVendors_Pro_Form_Helper::textarea( array(
- 'value' => $value,
- 'id' => $key,
- 'label' => __( 'Additional Policies', 'wcvendors-pro' ),
- 'placeholder' => __( 'Any other policies can go here', 'wcvendors-pro' ),
- 'desc_tip' => 'true'
- )
- );
- }
- }
- function store_global_shipping_max_bundle(){
- if ( class_exists( 'WCVendors_Pro' ) ){
- $key = '_wcv_custom_settings_max_bundle_per_shipping_cost';
- $value = get_user_meta( get_current_user_id(), $key, true );
- $nums_array = array();
- for($i = 1; $i < 101; $i++){
- $nums_array[$i] = $i;
- }
- WCVendors_Pro_Form_Helper::select( array(
- 'value' => $value,
- 'id' => $key,
- 'label' => __( 'Maximum items bundled per each shipping charge', 'wcvendors-pro' ),
- 'options' => $nums_array
- )
- );
- }
- }
- function store_global_shipping_min_free_shipping(){
- if ( class_exists( 'WCVendors_Pro' ) ){
- $key = '_wcv_custom_settings_min_free_shipping';
- $value = get_user_meta( get_current_user_id(), $key, true );
- WCVendors_Pro_Form_Helper::input( array(
- 'value' => $value,
- 'id' => $key,
- 'label' => __( 'Minmum spend for free shipping', 'wcvendors-pro' ),
- 'placeholder' => 'Leave Blank for no free shipping option'
- )
- );
- }
- }
- function get_designer_placeholder(){
- return '<img src="' . get_bloginfo('url').'/wp-content/uploads/2019/04/default-store-icon2.png" alt="" class="directory-image" />';
- }
- /* All functions related to size guide creation, storage and output are in the following include folder */
- include 'includes/sizeGuides.php';
- include 'includes/wcv-dashboard-amendments.php';
- include 'includes/helper-functions.php';
- function returnBy(){
- return 'by';
- }
- /* Carl Aiau after big upgrade */
- add_filter('wcvendors_cart_sold_by', 'returnBy');
- add_filter('wcvendors_cart_sold_by_meta', 'returnBy');
- add_filter('wcvendors_sold_by_in_loop', 'returnBy');
- /* Blocking non admins */
- add_action( 'init', 'blockusers_init' );
- function blockusers_init() {
- if ( is_admin() && ! current_user_can( 'administrator' ) &&
- ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
- wp_redirect( get_permalink( get_option('woocommerce_myaccount_page_id') ) );
- exit;
- }
- }
- add_action('admin_init', function(){
- beans_register_post_meta(
- array(array(
- 'id' => 'post-header',
- 'label' => 'Post Header',
- 'type' => 'image'
- )),
- array( 'post' ),
- 'blog-post-header',
- array(
- 'title' => 'Hero Image'
- )
- );
- });
- /*
- *
- * Add custom image size for Rize
- *
- */
- add_image_size( 'rize_large', 1200, 1200, false);
- /*
- *
- * Styles Product Taxonomy
- *
- */
- function register_style_taxonmy() {
- /**
- * Taxonomy: Styles.
- */
- $labels = array(
- "name" => __( 'Styles', 'tm-beans' ),
- "singular_name" => __( 'Style', 'tm-beans' ),
- );
- $args = array(
- "label" => __( 'Styles', 'tm-beans' ),
- "labels" => $labels,
- "public" => true,
- "hierarchical" => false,
- "label" => "Styles",
- "show_ui" => true,
- "show_in_menu" => true,
- "show_in_nav_menus" => true,
- "query_var" => true,
- "rewrite" => array( 'slug' => 'style', 'with_front' => true, ),
- "show_admin_column" => false,
- "show_in_rest" => false,
- "rest_base" => "",
- "show_in_quick_edit" => false,
- );
- register_taxonomy( "style", array( "product" ), $args );
- }
- add_action( 'init', 'register_style_taxonmy' );
- /*
- *
- * Disable Rank Math for page with ID 1161
- *
- */
- add_action( 'wp_head', 'rankmath_disable_features',1);
- function rankmath_disable_features() {
- if( is_page( '1161' ) ) {
- remove_all_actions( 'rank_math/head');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement