SHARE
TWEET

Rize - functions.php

a guest Jul 7th, 2019 40 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // Include Beans. Do not remove the line below.
  3. require_once( get_template_directory() . '/lib/init.php' );
  4.  
  5. /////////////////////////////////////////////////
  6.  
  7.  
  8. // PREVENT AUTO PLUGIN UPDATES
  9.  
  10. /////////////////////////////////////////////////
  11.  
  12. add_filter( 'auto_update_plugin', '__return_false' );
  13.  
  14. /////////////////////////////////////////////////
  15.  
  16.  
  17. // ENQUEUE STUFF
  18.  
  19. /////////////////////////////////////////////////
  20.  
  21.  
  22. add_action( 'beans_uikit_enqueue_scripts', 'beans_child_enqueue_uikit_assets' );
  23.  
  24. function beans_child_enqueue_uikit_assets() {
  25.  
  26.     // Enqueue UIkit necessary extra components.
  27.     beans_uikit_enqueue_components( array( 'flex', 'contrast', 'toggle', 'slideset', 'scrollspy', 'animation','dropdown', 'modal', 'tooltip', 'smooth-scroll', 'switcher', 'tab', 'cover'  ) );
  28.     beans_uikit_enqueue_components( array( 'accordion', 'lightbox','sortable'), 'add-ons' );
  29.  
  30.     // Enqueue child theme style.less
  31.     beans_compiler_add_fragment( 'uikit', get_stylesheet_directory_uri() . '/style.less', 'less' );
  32. }
  33.  
  34.  
  35.  
  36.  
  37. /////////////////////////////////////////////////
  38.  
  39.  
  40. // RANK MATH DISABLE ON DIRECTORY
  41.  
  42. /////////////////////////////////////////////////
  43.  
  44.  
  45.  
  46.  
  47.  
  48. /////////////////////////////////////////////////
  49.  
  50.  
  51. // BODY FADE
  52.  
  53. /////////////////////////////////////////////////
  54.  
  55. beans_add_attribute('beans_body', 'data-uk-scrollspy', 'cls:"uk-animation-fade", delay:100');
  56.  
  57.  
  58. //////
  59.  
  60. /// custom javascript
  61.  
  62. add_action( 'wp_enqueue_scripts', function(){
  63.     wp_register_script('custom-front', get_stylesheet_directory_uri() . '/js/custom-front.js', array('jquery'), '1.0.0', false);
  64.     wp_register_script('custom-dashboard', get_stylesheet_directory_uri() . '/js/custom-dashboard.js', array('jquery'), '1.0.0', false);
  65.     wp_register_script('custom-overview', get_stylesheet_directory_uri() . '/js/custom-overview.js', array('jquery'), '1.0.0', false);
  66.     wp_register_script('custom-refund', get_stylesheet_directory_uri() . '/js/custom-refund.js', array('jquery'), '1.0.0', false);
  67.     wp_register_script('custom-vendor', get_stylesheet_directory_uri() . '/js/custom-vendor.js', array('jquery'), '1.0.0', false);
  68.     wp_enqueue_script( 'custom-front' );
  69.  
  70.     if(current_user_can('vendor')){
  71.         wp_enqueue_script( 'custom-dashboard' );
  72.         wp_enqueue_script( 'custom-overview' );
  73.         wp_enqueue_script( 'custom-refund' );
  74.         wp_enqueue_script( 'custom-vendor' );
  75.     }
  76.  
  77. });
  78.  
  79.  
  80. /////////////////////////////////////////////////
  81.  
  82. // EMAIL ENCODING
  83.  
  84. /////////////////////////////////////////////////
  85.  
  86. function email_encode_function( $atts, $content ){
  87.     return '<a style="text-decoration:underline" href="'.antispambot("mailto:".$content).'">'.antispambot($content).'</a>';
  88. }
  89. add_shortcode( 'email', 'email_encode_function' );
  90.  
  91.  
  92. /////////////////////////////////////////////////
  93.  
  94.  
  95. //GOOGLE MATERIAL ICONS
  96.  
  97. /////////////////////////////////////////////////
  98.  
  99.  
  100. //Enqueue Google icon font
  101. wp_enqueue_style('material_icons', 'https://fonts.googleapis.com/icon?family=Material+Icons');
  102.  
  103.  
  104. /////////////////////////////////////////////////
  105.  
  106.  
  107. //GRIDS
  108.  
  109. /////////////////////////////////////////////////
  110.  
  111. // Enqueue the UIkit dynamic grid component.
  112. add_action( 'beans_uikit_enqueue_scripts', 'beans_child_enqueue_grid_uikit_assets' );
  113.  
  114. function beans_child_enqueue_grid_uikit_assets() {
  115.  
  116.     // Stop here if we are on a single view.
  117.     if ( is_single() )
  118.         return;
  119.  
  120.     beans_uikit_enqueue_components( array( 'grid' ), 'add-ons' );
  121.  
  122. }
  123.  
  124.  
  125. /////////////////////////////////////////////////
  126.  
  127.  
  128. //IMAGES AND VIDEO
  129.  
  130. /////////////////////////////////////////////////
  131.  
  132. //add div around video embed
  133. add_filter( 'embed_oembed_html', 'custom_oembed_filter', 10, 4 ) ;
  134.  
  135. function custom_oembed_filter($html, $url, $attr, $post_ID) {
  136.     $return = '<div class="video-container">'.$html.'</div>';
  137.     return $return;
  138. }
  139.  
  140. //Add padding to the_content
  141. beans_add_attribute('the_content', 'class', 'my-padding-large');
  142.  
  143.  
  144. //Change default image options in display settings media uploader
  145. function mytheme_setup() {
  146.     // Set default values for the upload media box
  147.     update_option('image_default_align', 'left' );
  148.     update_option('image_default_link_type', 'media' );
  149.     update_option('image_default_size', 'original' );
  150.  
  151. }
  152. add_action('after_setup_theme', 'mytheme_setup');
  153.  
  154.  
  155. //add class to p tag
  156. beans_add_attribute('woo_cart_shipping_calculator_note', 'class', 'my-mar-zero-t');
  157.  
  158. /////////////////////////////////////////////////
  159.  
  160.  
  161. //REGISTER NEW MENU LOCATIONS
  162.  
  163. /////////////////////////////////////////////////
  164.  
  165. function register_my_menus() {
  166.   register_nav_menus(
  167.     array(
  168.       'womens-menu' => __( 'Womens Menu' ),
  169.       'mens-menu' => __( 'Mens Menu' ),
  170.       'kids-menu' => __( 'Kids Menu' )
  171.     )
  172.   );
  173. }
  174. add_action( 'init', 'register_my_menus' );
  175.  
  176.  
  177.  
  178.  
  179.  
  180. /////////////////////////////////////////////////
  181.  
  182. // ADD OVERLAY MENU TO HEADER
  183.  
  184. /////////////////////////////////////////////////
  185.  
  186. add_action( 'beans_header_prepend_markup', 'add_overlay_menu' );
  187.  
  188. function add_overlay_menu() {
  189.     ?>
  190.     <?php include( 'overlay-menu.php' ); ?>
  191.     <?php
  192. }
  193.  
  194.  
  195.  
  196.  
  197.  
  198. /////////////////////////////////////////////////
  199.  
  200. // ADD SHARE INCLUDE TO ARCHIVE
  201.  
  202. /////////////////////////////////////////////////
  203.  
  204. //Create Share function
  205. function my_add_share(){
  206.  
  207. include'includes/archive-share.php';
  208. }
  209.  
  210. //Add Share to Archive
  211. add_action( 'woocommerce_after_shop_loop', 'my_add_share', 10 );
  212.  
  213.  
  214.  
  215.  
  216. /////////////////////////////////////////////////
  217.  
  218. // RSS INCLUDE FEATURED IMAGE
  219.  
  220. /////////////////////////////////////////////////
  221.  
  222.  
  223.  
  224. function featuredtoRSS($content) {
  225. global $post;
  226. if ( has_post_thumbnail( $post->ID ) ){
  227. $content = '<div>' . get_the_post_thumbnail( $post->ID, 'full', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content;
  228. }
  229. return $content;
  230. }
  231.  
  232. add_filter('the_excerpt_rss', 'featuredtoRSS');
  233. add_filter('the_content_feed', 'featuredtoRSS');
  234.  
  235.  
  236. /////////////////////////////////////////////////
  237.  
  238. // WC Vendors Pro - Notify Vendor when Product is Approved
  239.  
  240. /////////////////////////////////////////////////
  241.  
  242.  
  243. add_action( 'pending_to_publish', 'wcv_notify_vendor_on_publish' );
  244. function wcv_notify_vendor_on_publish( $post_id ) {
  245.     global $post;
  246.     if ( $post->post_author != get_current_user_id() ) {
  247.         $author = new WP_User( $post->post_author );
  248.         $email_data = array(
  249.             'to'      => $author->user_email,
  250.             'subject' => sprintf( __( 'Your post on %1$s has been published!', 'email_author_on_publish' ), get_bloginfo('name') ),
  251.             '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 ) ),
  252.         );
  253.         wp_mail( $email_data['to'], $email_data['subject'], $email_data['message'] );
  254.     }
  255. }
  256.  
  257.  
  258. /////////////////////////////////////////////////
  259.  
  260. // MAILCHIMP CONNECTION
  261.  
  262. /////////////////////////////////////////////////
  263.  
  264. add_action('beans_head_append_markup', 'mc_connect');
  265. function mc_connect (){ ?>
  266. <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>
  267. <?php }
  268.  
  269.  
  270. /////////////////////////////////////////////////
  271.  
  272. // Pinterest
  273.  
  274. /////////////////////////////////////////////////
  275.  
  276. add_action('beans_head_append_markup', 'pin_connect');
  277. function pin_connect (){ ?>
  278. <meta name="p:domain_verify" content="464fe418dc3e48afbc7c8110d9d07d9e"/>
  279. <?php }
  280.  
  281.  
  282. /////////////////////////////////////////////////
  283.  
  284. // INCLUDES
  285.  
  286. /////////////////////////////////////////////////
  287.  
  288.  
  289. // include 'includes/cookie-message.php';
  290.  
  291. // include 'includes/errors.php';
  292.  
  293. include 'includes/support.php';
  294. include 'includes/nav.php';
  295. include 'includes/sticky.php';
  296. include 'includes/crumb.php';
  297. include 'includes/posts.php';
  298. include 'includes/loops.php';
  299. include 'includes/side-bar.php';
  300. include 'includes/foot.php';
  301. include 'includes/woo.php';
  302. include 'includes/vendors.php';
  303. include 'includes/custom-search.php';
  304. include 'includes/loop-amendments.php';
  305. include 'includes/archive-elements.php';
  306. include 'includes/ninja.php';
  307. include 'includes/stripe-refund-process.php';
  308. include 'includes/shortcode_def.php';
  309.  
  310.  
  311.  
  312. //////////
  313.  
  314. // WC Vendor
  315.  
  316. ////////
  317.  
  318.  
  319. add_filter('wcv_my_account_msg', 'custom_wcv_my_account_msg');
  320. function custom_wcv_my_account_msg(){
  321.    $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>';
  322.    return $message;
  323. }
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330. //////
  331.  
  332. // WC Vendor Store Settings
  333.  
  334. /////
  335.  
  336. function custom_payment_policy(){
  337.     return '<div class="policy">
  338.                 <p class="meta_title">Payment Methods</p>
  339.         <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>
  340.         <br/>
  341.                 <p>We accept payment by ALL MAJOR CREDIT CARDS only.</p>
  342.           <p class="meta_title">Payment security</p>
  343.           <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>
  344.             </div>';
  345. }
  346.  
  347.  
  348. function store_policy_shipping( ){
  349.     if ( class_exists( 'WCVendors_Pro' ) ){
  350.         $key = '_wcv_custom_settings_policy_shipping';
  351.         $value = get_user_meta( get_current_user_id(), $key, true );
  352.         // Bank Name
  353.         WCVendors_Pro_Form_Helper::textarea( array(
  354.             'value'             => $value,
  355.             'id'                => $key,
  356.             'label'             => __( 'Shipping Policy', 'wcvendors-pro' ),
  357.             'placeholder'           => __( 'Information about your shipping terms', 'wcvendors-pro' ),
  358.             'desc_tip'          => 'true'
  359.             )
  360.         );
  361.     }
  362. }
  363.  
  364.  
  365.  
  366. function store_policy_returns( ){
  367.     if ( class_exists( 'WCVendors_Pro' ) ){
  368.         $key = '_wcv_custom_settings_policy_returns';
  369.         $value = get_user_meta( get_current_user_id(), $key, true );
  370.         WCVendors_Pro_Form_Helper::textarea( array(
  371.             'value'         => $value,
  372.             'id'                => $key,
  373.             'label'             => __( 'Returns, Exchanges & Refunds Policy', 'wcvendors-pro' ),
  374.             'placeholder'       => __( 'How you handle returns, exchanges and refunds', 'wcvendors-pro' ),
  375.             'desc_tip'          => 'true',
  376.         ) );
  377.     }
  378. }
  379.  
  380. function store_policy_additional( ){
  381.     if ( class_exists( 'WCVendors_Pro' ) ){
  382.         $key = '_wcv_custom_settings_policy_additional';
  383.         $value = get_user_meta( get_current_user_id(), $key, true );
  384.         // Bank Name
  385.         WCVendors_Pro_Form_Helper::textarea( array(
  386.             'value'             => $value,
  387.             'id'                => $key,
  388.             'label'             => __( 'Additional Policies', 'wcvendors-pro' ),
  389.             'placeholder'           => __( 'Any other policies can go here', 'wcvendors-pro' ),
  390.             'desc_tip'          => 'true'
  391.             )
  392.         );
  393.     }
  394. }
  395.  
  396. function store_global_shipping_max_bundle(){
  397.     if ( class_exists( 'WCVendors_Pro' ) ){
  398.         $key = '_wcv_custom_settings_max_bundle_per_shipping_cost';
  399.         $value = get_user_meta( get_current_user_id(), $key, true );
  400.        
  401.         $nums_array = array();
  402.         for($i = 1; $i < 101; $i++){
  403.             $nums_array[$i] = $i;
  404.         }
  405.         WCVendors_Pro_Form_Helper::select( array(
  406.             'value'             => $value,
  407.             'id'                => $key,
  408.             'label'             => __( 'Maximum items bundled per each shipping charge', 'wcvendors-pro' ),
  409.             'options' => $nums_array
  410.             )
  411.         );
  412.     }
  413. }
  414.  
  415. function store_global_shipping_min_free_shipping(){
  416.     if ( class_exists( 'WCVendors_Pro' ) ){
  417.         $key = '_wcv_custom_settings_min_free_shipping';
  418.         $value = get_user_meta( get_current_user_id(), $key, true );
  419.         WCVendors_Pro_Form_Helper::input( array(
  420.             'value'             => $value,
  421.             'id'                => $key,
  422.             'label'             => __( 'Minmum spend for free shipping', 'wcvendors-pro' ),
  423.             'placeholder' => 'Leave Blank for no free shipping option'
  424.             )
  425.         );
  426.     }
  427. }
  428.  
  429. function get_designer_placeholder(){
  430.     return '<img src="' . get_bloginfo('url').'/wp-content/uploads/2019/04/default-store-icon2.png" alt="" class="directory-image" />';
  431. }
  432.  
  433.  
  434. /* All functions related to size guide creation, storage and output are in the following include folder */
  435. include 'includes/sizeGuides.php';
  436.  
  437. include 'includes/wcv-dashboard-amendments.php';
  438.  
  439. include 'includes/helper-functions.php';
  440.  
  441. function returnBy(){
  442.   return 'by';
  443. }
  444. /* Carl Aiau after big upgrade */
  445. add_filter('wcvendors_cart_sold_by', 'returnBy');
  446. add_filter('wcvendors_cart_sold_by_meta', 'returnBy');
  447. add_filter('wcvendors_sold_by_in_loop', 'returnBy');
  448.  
  449. /* Blocking non admins */
  450. add_action( 'init', 'blockusers_init' );
  451. function blockusers_init() {
  452.     if ( is_admin() && ! current_user_can( 'administrator' ) &&
  453.     ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
  454.         wp_redirect( get_permalink( get_option('woocommerce_myaccount_page_id') ) );
  455.         exit;
  456.     }
  457. }
  458.  
  459. add_action('admin_init', function(){
  460.  
  461.     beans_register_post_meta(
  462.         array(array(
  463.             'id'         => 'post-header',
  464.             'label'      => 'Post Header',
  465.             'type'       => 'image'
  466.         )),
  467.         array( 'post' ),
  468.         'blog-post-header',
  469.         array(
  470.             'title' => 'Hero Image'
  471.         )
  472.     );
  473. });
  474.  
  475. /*
  476.  *
  477.  * Add custom image size for Rize
  478.  *
  479.  */
  480. add_image_size( 'rize_large', 1200, 1200, false);
  481.  
  482.  
  483. /*
  484.  *
  485.  * Styles Product Taxonomy
  486.  *
  487.  */
  488. function register_style_taxonmy() {
  489.  
  490.     /**
  491.      * Taxonomy: Styles.
  492.      */
  493.  
  494.     $labels = array(
  495.         "name" => __( 'Styles', 'tm-beans' ),
  496.         "singular_name" => __( 'Style', 'tm-beans' ),
  497.     );
  498.  
  499.     $args = array(
  500.         "label" => __( 'Styles', 'tm-beans' ),
  501.         "labels" => $labels,
  502.         "public" => true,
  503.         "hierarchical" => false,
  504.         "label" => "Styles",
  505.         "show_ui" => true,
  506.         "show_in_menu" => true,
  507.         "show_in_nav_menus" => true,
  508.         "query_var" => true,
  509.         "rewrite" => array( 'slug' => 'style', 'with_front' => true, ),
  510.         "show_admin_column" => false,
  511.         "show_in_rest" => false,
  512.         "rest_base" => "",
  513.         "show_in_quick_edit" => false,
  514.     );
  515.     register_taxonomy( "style", array( "product" ), $args );
  516. }
  517.  
  518. add_action( 'init', 'register_style_taxonmy' );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top