Advertisement
zumixosan

Function Theme Grosir Market

Oct 23rd, 2019
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 88.47 KB | None | 0 0
  1. <?php
  2.  
  3. // Do not allow directly accessing this file.
  4. if ( ! defined( 'ABSPATH' ) ) {
  5.     exit( 'Direct script access denied.' );
  6. }
  7.  
  8. if ( !defined( 'RH_MAIN_THEME_VERSION' ) ) {
  9.     define('RH_MAIN_THEME_VERSION', '9.6.1');
  10. }
  11. if(!defined('REHUB_NAME_ACTIVE_THEME')){
  12.     define('REHUB_NAME_ACTIVE_THEME', 'REHUB');
  13. }
  14.  
  15. if(!is_admin()) add_action('init', 'rehub_framework_register_scripts');
  16. if( !function_exists('rehub_framework_register_scripts') ) {
  17. function rehub_framework_register_scripts() {
  18.  
  19.     // Stylesheets
  20.     wp_register_style('rhstyle', get_stylesheet_directory_uri() . '/style.css', array(), RH_MAIN_THEME_VERSION);
  21.     wp_register_style('responsive', get_template_directory_uri() . '/css/responsive.css', array(), RH_MAIN_THEME_VERSION);
  22.     wp_register_style('rehub_shortcode', get_template_directory_uri() . '/shortcodes/css/css.css', array(), RH_MAIN_THEME_VERSION);
  23.     wp_register_style('rehubfontawesome', get_template_directory_uri() . '/admin/fonts/fontawesome/font-awesome.min.css', array(), '5.3.1');
  24.     wp_register_style( 'rehub-woocommerce', get_template_directory_uri().'/css/woocommerce.css', array(), RH_MAIN_THEME_VERSION, 'all' );
  25.     wp_register_style('bbpress_css', get_template_directory_uri() . '/css/bbpresscustom.css', array(), RH_MAIN_THEME_VERSION); 
  26.     wp_register_style('jquery.nouislider', get_template_directory_uri() . '/css/jquery.nouislider.css');
  27.     wp_register_style('tabletoggle', get_template_directory_uri() . '/css/tabletoggle.css', array(), '5.0.9');
  28.     wp_register_style('eggrehub', get_template_directory_uri() . '/css/eggrehub.css', array(), RH_MAIN_THEME_VERSION);
  29.     wp_register_style('video-pl', get_template_directory_uri() . '/css/video-playlist.css');
  30.     wp_register_style('eddrehub', get_template_directory_uri() . '/css/edd.css');
  31.     wp_register_style('rhwcvendor', get_template_directory_uri() . '/css/wcvendor.css', array(), RH_MAIN_THEME_VERSION);
  32.     wp_register_style('rhwcfmdash', get_template_directory_uri() . '/css/rhwcfmdash.css', array(), RH_MAIN_THEME_VERSION);
  33.     wp_register_style('rhwcfmstore', get_template_directory_uri() . '/css/rhwcfmstore.css', array(), RH_MAIN_THEME_VERSION);
  34.     wp_register_style('rhcomparesearch', get_template_directory_uri() . '/css/comparesearch.css', array(), RH_MAIN_THEME_VERSION);
  35.     wp_register_style('modulobox', get_template_directory_uri() . '/css/modulobox.min.css', array(), '1.4.4');
  36.    
  37.     //Scripts
  38.     wp_register_script('rhinview', get_template_directory_uri() . '/js/inview.js', array('jquery'), '1.0', true);
  39.     wp_register_script('rhpgwmodal', get_template_directory_uri() . '/js/pgwmodal.js', array('jquery'), '2.0', true);
  40.     wp_register_script('rhunveil', get_template_directory_uri() . '/js/unveil.js', array('jquery'), '1.0', true);
  41.     wp_register_script('rhcuttab', get_template_directory_uri() . '/js/cuttabs.js', array('jquery'), '3.3.6', true);
  42.     wp_register_script('rhhoverintent', get_template_directory_uri() . '/js/hoverintent.js', array('jquery'), '1.9', true);
  43.     wp_register_script('rhniceselect', get_template_directory_uri() . '/js/niceselect.js', array('jquery'), '1.0', true);
  44.     wp_register_script('rhcountdown', get_template_directory_uri() . '/js/countdown.js', array('jquery'), '1.0', true);
  45.     wp_register_script('rehub', get_template_directory_uri() . '/js/custom.js', array('jquery'), RH_MAIN_THEME_VERSION, true);
  46.     wp_register_script('flexslider', get_template_directory_uri() . '/js/jquery.flexslider-min.js', array('jquery'), '2.2.2', true);
  47.     wp_register_script('totemticker', get_template_directory_uri() . '/js/jquery.totemticker.js', array('jquery'), '', true);
  48.     wp_register_script('carouFredSel', get_template_directory_uri() . '/js/jquery.carouFredSel-6.2.1-packed.js', array('jquery'), '6.2.1', true);
  49.     wp_register_script('sticky', get_template_directory_uri() . '/js/jquery.sticky.js', array('jquery'), '1.0.5', true);
  50.     wp_register_script('custom_scroll', get_template_directory_uri() . '/js/custom_scroll.js', array('jquery'), '1.0.1', true);
  51.     wp_register_script('masonry', get_template_directory_uri() . '/js/masonry.pkgd.min.js', array('jquery'), '3.1.5', true);
  52.     wp_register_script('imagesloaded', get_template_directory_uri() . '/js/imagesloaded.pkgd.min.js', array('jquery'), '3.1.8', true);
  53.     wp_register_script('masonry_init', get_template_directory_uri() . '/js/masonry_init.js', array('jquery', 'masonry'), '3.1.5', true);
  54.     wp_register_script('rh_elparallax', get_template_directory_uri() . '/js/elparallax.js', array('jquery'), '1.0', true); 
  55.     wp_register_script('jquery.nouislider', get_template_directory_uri() . '/js/jquery.nouislider.full.min.js', array('jquery'), '7.0.0', true);
  56.     wp_register_script( 'zeroclipboard', get_template_directory_uri() . '/js/clipboard.min.js', array('jquery'), '1.5.16' );
  57.     wp_register_script('wpsm_googlemap',  get_template_directory_uri() . '/shortcodes/js/wpsm_googlemap.js', array('jquery'), '', true);
  58.     wp_register_script('tipsy', get_template_directory_uri() . '/shortcodes/js/jquery.tipsy.js', array('jquery'), '1.0.0'); // tipsy       
  59.     wp_register_script('tablesorter', get_template_directory_uri() . '/js/jquery.tablesorter.min.js', array('jquery'), '2.0.2'); // table sorter
  60.     wp_register_script('touchswipe', get_template_directory_uri() . '/js/jquery.touchSwipe.min.js', array('jquery'), '2.0.5'); // swiper
  61.     wp_register_script('affegg_coupons', get_template_directory_uri() . '/js/affegg_coupons.js', array('jquery'), '1.1.0', true); // affiliate coupons
  62.     wp_register_script('owlcarousel', get_template_directory_uri() . '/js/owl.carousel.min.js', array('jquery'), '1.9.9', true);
  63.     wp_register_script('video_playlist', get_template_directory_uri() . '/js/video_playlist.js', array('jquery'), '1.0.0', true);
  64.     wp_register_script('stickysidebar', get_template_directory_uri() . '/js/stickysidebar.js', array('jquery'), '1.3.1', true);
  65.     wp_register_script('printcoupon', get_template_directory_uri() . '/js/printcoupon.js', array('jquery'), '1.0.1', true);
  66.     wp_register_script('typehead', get_template_directory_uri() . '/js/typehead.js', array('jquery'), '0.10.5', true);
  67.     wp_register_script( 'rehubcompare', get_template_directory_uri() . '/js/comparechart.js', array('jquery', 'rehub'), '1.2', true );
  68.     wp_register_script( 'rehubwaypoints', get_template_directory_uri() . '/js/jquery.waypoints.min.js', array('jquery'), '4.0.1', true );  
  69.     wp_register_script( 'justifygallery', get_template_directory_uri() . '/js/jquery.justifiedGallery.min.js', array('jquery'), '3.6.3', true );
  70.     wp_register_script( 'customfloatpanel', get_template_directory_uri() . '/js/custom_floatpanel.js', array('jquery'), '1.0', true ); 
  71.     wp_register_script( 'modulobox', get_template_directory_uri() . '/js/modulobox.min.js', array('jquery'), '1.0.5', true );              
  72. }
  73. }
  74. if(!is_admin()) add_action('wp_enqueue_scripts', 'rehub_enqueue_scripts',11);
  75. if( !function_exists('rehub_enqueue_scripts') ) {
  76. function rehub_enqueue_scripts() {
  77.     if (rh_check_plugin_active('affiliate-egg/affiliate-egg.php') || defined('\ContentEgg\PLUGIN_PATH')) {wp_enqueue_style('eggrehub');}
  78.     wp_enqueue_style('rhstyle');
  79.     wp_enqueue_style('responsive');
  80.     wp_enqueue_style('rehub_shortcode');   
  81.     wp_enqueue_style('rehubfontawesome');
  82.     wp_enqueue_script('rhinview');
  83.     wp_enqueue_script('rhpgwmodal');
  84.     wp_enqueue_script('rhunveil');
  85.     wp_enqueue_script('rhcuttab');
  86.     wp_enqueue_script('rhhoverintent');
  87.     wp_enqueue_script('rhniceselect');
  88.     wp_enqueue_script('rhcountdown');
  89.     wp_enqueue_script('rehub');
  90.     if (class_exists('Woocommerce')) {wp_enqueue_style( 'rehub-woocommerce');}
  91.     if (defined('wcv_plugin_dir') OR class_exists('WeDevs_Dokan') OR class_exists('WCMp')) {wp_enqueue_style('rhwcvendor');}
  92.     if (class_exists('Easy_Digital_Downloads')) {wp_enqueue_style( 'eddrehub');}
  93.     if (class_exists('bbPress' )) {wp_enqueue_style('bbpress_css');}   
  94.     if (rehub_option('rehub_sticky_nav')) {wp_enqueue_script( 'sticky' );}
  95.  
  96.     $translation_array = array(
  97.         'back' => esc_html__( 'back', 'rehub-theme' ),
  98.         'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ),
  99.         'templateurl' => get_template_directory_uri(),
  100.         'fin' => esc_html__( 'That\'s all', 'rehub-theme' ),
  101.         'noresults' => esc_html__( 'No results found', 'rehub-theme' ),
  102.         'your_rating' => esc_html__( 'Your Rating:', 'rehub-theme' ),
  103.         'nonce' => wp_create_nonce('ajaxed-nonce'),
  104.         'hotnonce' => wp_create_nonce('hotnonce'),
  105.         'wishnonce' => wp_create_nonce('wishnonce'),
  106.         'searchnonce' => wp_create_nonce('search-nonce'),
  107.         'filternonce' => wp_create_nonce('filter-nonce'),
  108.         'couponnonce' => wp_create_nonce('coupon-nonce'),
  109.         'rating_tabs_id'   => wp_create_nonce('rating_tabs_nonce'),  
  110.         'max_temp' => REHUB_MAX_TEMP,
  111.         'min_temp' => REHUB_MIN_TEMP,
  112.         'helpnotnonce' => wp_create_nonce('commre-nonce'),     
  113.     );
  114.     wp_localize_script( 'rehub', 'translation', $translation_array );
  115.  
  116.     $affcoupons_array = array(
  117.         'coupontextready' => esc_html__( 'Here is your coupon code', 'rehub-theme' ),
  118.         'coupontextcopied' => esc_html__( 'Code is copied', 'rehub-theme' ),
  119.         'coupongoto' => esc_html__( 'Go to ', 'rehub-theme' ), 
  120.         'couponwebsite' => esc_html__( 'Website', 'rehub-theme' ),
  121.         'couponuseoffer' => esc_html__( ' and use this Offer.', 'rehub-theme' ),
  122.         'couponorcheck' => esc_html__( 'Or check your new window for opened website', 'rehub-theme' ),                       
  123.     );     
  124.     wp_localize_script( 'affegg_coupons', 'coupvars', $affcoupons_array );
  125.  
  126.     if (is_singular() && get_option('thread_comments')) wp_enqueue_script('comment-reply');
  127. }
  128. }
  129.  
  130. if(defined( 'WCFMmp_TOKEN' )){
  131.     add_action('after_wcfm_load_styles', 'rh_custom_styles_wcfm_dash');
  132.     function rh_custom_styles_wcfm_dash($end_point){
  133.         wp_enqueue_style('rhwcfmdash');
  134.     }
  135.     if(!is_admin()) add_action('wp_enqueue_scripts', 'rh_custom_styles_wcfm_store',99);
  136.     function rh_custom_styles_wcfm_store(){
  137.         wp_enqueue_style('rhwcfmstore');
  138.     }  
  139. }
  140.  
  141. if(!is_admin()) add_action( 'wp_enqueue_scripts', 'rh_optimized_media_styles', 99 );
  142. function rh_optimized_media_styles() {
  143.     wp_dequeue_style( 'font-awesome' );
  144.     wp_dequeue_style( 'dokan-fontawesome' );
  145.     wp_dequeue_style( 'yith-wcwl-font-awesome' );
  146.     wp_dequeue_script( 'vc_woocommerce-add-to-cart-js' );
  147.  
  148.     if (rehub_option('disable_woo_scripts')) {
  149.         if ( function_exists( 'is_woocommerce' ) ) {
  150.             if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
  151.                 # Scripts
  152.                 wp_dequeue_script( 'wc-add-to-cart' );
  153.                 wp_dequeue_script( 'wc-cart-fragments' );;
  154.                 wp_dequeue_script( 'wc-add-to-cart-variation' );
  155.                 wp_dequeue_script( 'wc-cart' );
  156.                 wp_dequeue_script( 'woocommerce' );
  157.             }
  158.         }
  159.     }
  160.  
  161.     //wp_dequeue_script( 'jqueryui' );
  162. }
  163.  
  164. //add helper functions
  165. include (get_template_directory() . '/functions/helper_functions.php');
  166.  
  167. if( !function_exists('rehub_custom_css') ) {
  168. function rehub_custom_css() {
  169.     return get_template_part('inc/customization');
  170. }
  171. }
  172. add_action( 'wp_head', 'rehub_custom_css' );
  173.  
  174. // Add specific CSS class by filter
  175. add_filter('body_class','rehub_body_classes');
  176. function rehub_body_classes($classes) {
  177. if (rehub_option('rehub_body_block')) $classes[] = 'rh-boxed-container';   
  178. if (rehub_option('enable_adsense_opt')) $classes[] = 'mediad_layout_enabled';
  179. if (rehub_option('rehub_content_shadow') !='' ){
  180.     $classes[] = 'noinnerpadding';
  181. }
  182.     // return the $classes array
  183.     return $classes;
  184. }
  185.  
  186. /*** Other essensials ***/
  187. if ( ! isset( $content_width ) ){
  188.     $content_width = 840;
  189. }
  190.    
  191. add_theme_support( 'automatic-feed-links' );
  192. add_theme_support( 'woocommerce');
  193. add_theme_support( 'html5', array( 'search-form' ) );
  194. function rehub_theme_support_add() {
  195.     add_theme_support( 'title-tag' );
  196.     add_theme_support( 'wc-product-gallery-zoom' );
  197.     add_theme_support( 'wc-product-gallery-lightbox' );
  198.     add_theme_support( 'wc-product-gallery-slider' );
  199.     add_theme_support( 'editor-styles' );
  200.     add_editor_style( 'css/style-editor.css' );
  201. }
  202. add_action( 'after_setup_theme', 'rehub_theme_support_add' );
  203.  
  204. // This theme uses its own gallery styles.
  205. add_filter( 'use_default_gallery_style', '__return_false' );
  206.  
  207. //remove some unuseful filter
  208. add_filter( 'term_description', 'shortcode_unautop');
  209. add_filter( 'term_description', 'do_shortcode' );
  210. add_filter('widget_text', 'do_shortcode');
  211.  
  212. //We disable photon extension as theme has own resizer
  213. if ( class_exists( 'Jetpack_Photon' ) && Jetpack::is_module_active( 'photon' ) ) {
  214.     Jetpack::deactivate_module( 'photon' );
  215. }
  216. add_filter( 'lazyload_is_enabled', '__return_false', 99 );
  217.  
  218.  
  219. //////////////////////////////////////////////////////////////////
  220. // Translation
  221. //////////////////////////////////////////////////////////////////
  222. add_action('after_setup_theme', 'rehub_theme_setup');
  223. if( !function_exists('rehub_theme_setup') ) {
  224. function rehub_theme_setup(){
  225.     load_theme_textdomain('rehub-theme', get_template_directory() . '/lang');
  226. }
  227. }
  228.  
  229. //////////////////////////////////////////////////////////////////
  230. // REHub Class for admin and Constants
  231. //////////////////////////////////////////////////////////////////
  232. require_once ( get_template_directory().'/admin/rehub.php');
  233.  
  234. // Here we populate the font face
  235. $font_face_nav      = rehub_option('rehub_nav_font');
  236. if ($font_face_nav){
  237.     $font_face_nav_weight = rehub_option('rehub_nav_font_weight');
  238.     $font_face_nav_style  = rehub_option('rehub_nav_font_style');
  239.     $font_face_nav_subset  = rehub_option('rehub_nav_font_subset');
  240.     if(rehub_option('disable_google_fonts') != true){
  241.         VP_Site_GoogleWebFont::instance()->add($font_face_nav, $font_face_nav_weight, $font_face_nav_style, $font_face_nav_subset);
  242.     }
  243. }
  244.  
  245. $font_face_headings = rehub_option('rehub_headings_font');
  246. if($font_face_headings){
  247.     $font_face_headings_weight = rehub_option('rehub_headings_font_weight');
  248.     $font_face_headings_style  = rehub_option('rehub_headings_font_style');
  249.     $font_face_headings_subset  = rehub_option('rehub_headings_font_subset');
  250.     if(rehub_option('disable_google_fonts') != true){
  251.         VP_Site_GoogleWebFont::instance()->add($font_face_headings, $font_face_headings_weight, $font_face_headings_style, $font_face_headings_subset);    
  252.     }  
  253. }
  254.  
  255. $font_face_body   = rehub_option('rehub_body_font');
  256. if($font_face_body){
  257.     $font_face_body_weight = rehub_option('rehub_body_font_weight');
  258.     $font_face_body_style  = rehub_option('rehub_body_font_style');
  259.     $font_face_body_subset  = rehub_option('rehub_body_font_subset');
  260.     if(rehub_option('disable_google_fonts') != true){
  261.         VP_Site_GoogleWebFont::instance()->add($font_face_body, $font_face_body_weight, $font_face_body_style, $font_face_body_subset);    
  262.     }      
  263. }
  264.  
  265. // embed font function
  266. function rehub_embed_fonts()
  267. {
  268.     if(rehub_option('disable_google_fonts') == true){
  269.         if (REHUB_NAME_ACTIVE_THEME == 'REPICK') {
  270.             wp_enqueue_style('default_font', get_stylesheet_directory_uri() . '/css/opensans.css');
  271.         }elseif(REHUB_NAME_ACTIVE_THEME == 'RETHING'){
  272.             wp_enqueue_style('default_font', get_stylesheet_directory_uri() . '/css/localfont.css');
  273.         }elseif(REHUB_NAME_ACTIVE_THEME == 'RECART'){
  274.             wp_enqueue_style('default_font', get_stylesheet_directory_uri() . '/css/localfont.css');
  275.         }      
  276.         else{
  277.             wp_enqueue_style('default_font', get_template_directory_uri() . '/css/roboto.css');
  278.         }
  279.        
  280.     }else{
  281.         if(rehub_option('disable_default_fonts') != true){
  282.             if (REHUB_NAME_ACTIVE_THEME == 'REPICK') {
  283.                 wp_enqueue_style('default_font', '//fonts.googleapis.com/css?family=Open+Sans:400,700');
  284.             }elseif(REHUB_NAME_ACTIVE_THEME == 'RETHING'){
  285.                 wp_enqueue_style('default_font', '//fonts.googleapis.com/css?family=Noto+Serif:400,700');
  286.                 wp_enqueue_style('head_nav', '//fonts.googleapis.com/css?family=Montserrat:700');
  287.             }elseif(REHUB_NAME_ACTIVE_THEME == 'RECART'){
  288.                 wp_enqueue_style('default_font', '//fonts.googleapis.com/css?family=Poppins:400,700');
  289.             }else{
  290.                 wp_enqueue_style('default_font', '//fonts.googleapis.com/css?family=Roboto:400,700&subset=latin,cyrillic');
  291.             }
  292.         }              
  293.     }  
  294. }
  295. add_action('wp_enqueue_scripts', 'rehub_embed_fonts');
  296. add_action('admin_enqueue_scripts', 'rehub_embed_fonts');
  297. function rehub_resource_hints( $urls, $relation_type ) {
  298.     if ( wp_style_is( 'default_font', 'queue' ) && 'preconnect' === $relation_type && rehub_option('disable_google_fonts') != true) {
  299.         $urls[] = array(
  300.             'href' => 'https://fonts.gstatic.com',
  301.             'crossorigin',
  302.         );
  303.     }
  304.     return $urls;
  305. }
  306. add_filter( 'wp_resource_hints', 'rehub_resource_hints', 10, 2 );
  307.  
  308. //////////////////////////////////////////////////////////////////
  309. // Register WordPress menus
  310. //////////////////////////////////////////////////////////////////
  311. add_action( 'after_setup_theme', 'rehub_register_my_menus' );
  312.  
  313. if( !function_exists('rehub_register_my_menus') ) {
  314. function rehub_register_my_menus() {
  315.     register_nav_menus(
  316.         array(
  317.             'primary-menu' => esc_html__( 'Primary Menu', 'rehub-theme' ),
  318.             'top-menu' => esc_html__( 'Top Menu', 'rehub-theme' ),
  319.             'user_logged_in_menu' => esc_html__( 'User Logged In Menu', 'rehub-theme' ),
  320.         )
  321.     );
  322. }
  323. }
  324.  
  325. class Rehub_Walker extends Walker_Nav_Menu
  326. {  
  327.     function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
  328.         global $wp_query;
  329.         $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
  330.  
  331.         $class_names = $value = '';
  332.  
  333.         $classes = empty( $item->classes ) ? array() : (array) $item->classes;
  334.  
  335.         $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
  336.         $class_names = ' class="' . esc_attr( $class_names ) . '"';
  337.  
  338.         $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
  339.  
  340.         $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
  341.         $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
  342.         $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
  343.         $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';
  344.  
  345.         $item_output = $args->before;
  346.         $item_output .= '<a'. $attributes .'>';
  347.         $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID );
  348.         $item_output .= $args->link_after . '</a>';
  349.         $item_output .= $args->after;
  350.  
  351.         $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args);
  352.     }  
  353. }
  354. //Add search and login to the main navigation
  355. add_filter( 'wp_nav_menu_items', 'rehub_add_search_to_main_nav', 20, 4 );
  356. if( ! function_exists( 'rehub_add_search_to_main_nav' ) ) {
  357.     function rehub_add_search_to_main_nav( $items, $args ) {
  358.         $ubermenu = false;
  359.  
  360.         if( function_exists( 'ubermenu_get_menu_instance_by_theme_location' ) && ubermenu_get_menu_instance_by_theme_location( $args->theme_location ) ) {
  361.             // disable on ubermenu navigations
  362.             $ubermenu = true;
  363.         }
  364.  
  365.         if( $ubermenu == false ) {
  366.             if( $args->theme_location == 'primary-menu' && rehub_option('woo_cart_place') == '2' && rehub_option('rehub_header_style') != 'header_seven') {
  367.                 global $woocommerce;
  368.                 if ($woocommerce){
  369.                 $items .= '<li class="menu-item rehub-custom-menu-item rh_woocartmenu">';
  370.                     $items .= '<a class="rh-header-icon rh-flex-center-align rh_woocartmenu-link cart-contents cart_count_'.$woocommerce->cart->cart_contents_count.'" href="'.wc_get_cart_url().'"><span class="rh_woocartmenu-icon"><span class="rh-icon-notice rehub-main-color-bg">'.$woocommerce->cart->cart_contents_count.'</span></span><span class="rh_woocartmenu-amount">'.$woocommerce->cart->get_cart_total().'</span></a>';
  371.                 $items .= '</li>';                 
  372.                 }
  373.  
  374.             }          
  375.             if($args->theme_location == 'primary-menu' && rehub_option('rehub_login_icon') == 'menu' && rehub_option('userlogin_enable') == '1') {
  376.                 $loginurl = (rehub_option('custom_login_url')) ? esc_url(rehub_option('custom_login_url')) : '';       
  377.                 $items .= '<li class="menu-item rehub-custom-menu-item rehub-top-login-onclick">';
  378.                     $items .= wpsm_user_modal_shortcode(array('wrap'=> 'a', 'loginurl'=>$loginurl));
  379.                 $items .= '</li>';             
  380.             }                                              
  381.         }
  382.  
  383.         return $items;
  384.     }
  385. }
  386. //Add elements to Sliding Mobile Panel
  387. if( ! function_exists( 'rh_custom_sliding_elements' ) ) {
  388.     function rh_custom_sliding_elements(){
  389.         $slidinglogo = rehub_option('logo_mobilesliding');
  390.         $slidingtext = rehub_option('text_mobilesliding');
  391.         $output = '';
  392.         if($slidingtext || $slidinglogo){
  393.             $slidingbg = rehub_option('bg_mobilesliding');
  394.             $slidingcolor = rehub_option('color_mobilesliding');           
  395.             $bgimage = ($slidingbg) ? 'background-image: url('.esc_url($slidingbg).'); background-repeat: repeat; background-position: left top;' : '';
  396.             if($slidingcolor){
  397.                 $bgcolor = 'background-color: '.$slidingcolor.';';
  398.             }
  399.             elseif(rehub_option("rehub_custom_color") != ''){
  400.                 $bgcolor = 'background-color: '.rehub_option("rehub_custom_color").';';
  401.             }
  402.             else{
  403.                 $bgcolor = 'background-color: #f1f1f1;';
  404.             }      
  405.             $output.= '<div id="rhmobpnlcustom" class="rhhidden"><div id="rhmobtoppnl" style="'.$bgimage.$bgcolor.'" class="pr15 pl15 pb15 pt15">';
  406.             if($slidinglogo){
  407.                 $output.= '<div class="text-center"><img id="mobpanelimg" src="'.esc_url($slidinglogo).'" alt="Logo" /></div>';
  408.             }
  409.             if($slidingtext){
  410.                 $output.= '<div id="mobpaneltext" class="mt15">'.do_shortcode($slidingtext).'</div>';
  411.             }
  412.             $output.= '</div></div>';      
  413.         }
  414.         return $output;
  415.     }
  416. }
  417.  
  418. //Add elements to footer
  419. function rehub_add_elem_to_footer(){
  420.     ?>
  421.     <?php
  422.         if (rehub_option('rehub_logo_inmenu') !='') {
  423.             $logoimageurl = '';
  424.             if(rehub_option('rehub_logo_inmenu_url') !=''){
  425.                 $logoimageurl = rehub_option("rehub_logo_inmenu_url");
  426.             }
  427.             elseif (rehub_option('rehub_logo') !='') {
  428.                 $logoimageurl = rehub_option('rehub_logo');
  429.             }
  430.             if ($logoimageurl) {
  431.                 echo '<div id="logo_mobile_wrapper"><a href="'.get_home_url().'" class="logo_image_mobile"><img src="'.$logoimageurl.'" alt="'.get_bloginfo( "name" ).'" /></a></div>';
  432.             }                
  433.         }            
  434.     ?>  
  435.  
  436.     <?php if( rehub_option( 'rehub_logo_retina' ) != '' && rehub_option( 'rehub_logo_retina_width' ) != '' && rehub_option( 'rehub_logo_retina_height' ) !=''): ?>
  437.         <?php
  438.             $menuscript = '
  439.            jQuery(document).ready(function($) {
  440.                 var retina = window.devicePixelRatio > 1 ? true : false;
  441.                 if(retina) {
  442.                     jQuery(".logo_image img").attr("src", "'.rehub_option( "rehub_logo_retina" ).'");
  443.                 }
  444.            });';
  445.             wp_add_inline_script('rehub', $menuscript);
  446.         ?>
  447.     <?php endif; ?>
  448.  
  449.     <?php echo rh_custom_sliding_elements();?>
  450.  
  451.     <?php
  452.         if (rehub_option('rehub_analytics')) {
  453.             echo rehub_option('rehub_analytics');  
  454.         }            
  455.     ?>          
  456.  
  457.     <?php
  458. }
  459. add_action('wp_footer', 'rehub_add_elem_to_footer');
  460.  
  461. function add_menu_for_blank(){
  462.     echo '<nav class="top_menu"><ul class="menu"><li><a href="/wp-admin/nav-menus.php" target="_blank">Click to Add your menu</a></li></ul></nav>';
  463. }
  464. function add_top_menu_for_blank(){
  465.     echo '<div class="top-nav"><ul class="menu"><li></li></ul></div>';
  466. }
  467.  
  468. add_filter( 'walker_nav_menu_start_el', 'rh_shortcode_in_menu', 20, 2 );
  469. function rh_shortcode_in_menu( $item_output, $item ) {
  470.     // Rare case when $item is not an object, usually with custom themes.
  471.     if ( ! is_object( $item ) || ! isset( $item->object ) ) {
  472.         return $item_output;
  473.     }
  474.     if ( isset( $item->url ) && ('http://SHORTCODE' === $item->url || 'SHORTCODE' === $item->url || 'https://SHORTCODE' === $item->url) ) {
  475.         if(!empty( $item->description)){
  476.             $item_output = do_shortcode( $item->description );
  477.         }
  478.     }  
  479.     return $item_output;
  480. }
  481.  
  482.  
  483. //////////////////////////////////////////////////////////////////
  484. // Resizer
  485. //////////////////////////////////////////////////////////////////
  486. @define('BFITHUMB_UPLOAD_FOLDER', 'thumbs_dir');
  487. require_once('inc/BFI_Thumb.php');
  488.  
  489. //////////////////////////////////////////////////////////////////
  490. // Post thumbnails
  491. //////////////////////////////////////////////////////////////////
  492.  
  493. add_action( 'after_setup_theme', 'rehub_image_sizes' );
  494. if ( !function_exists( 'rehub_image_sizes' ) ) {
  495.     function rehub_image_sizes() {
  496.         add_theme_support( 'post-thumbnails' );
  497.         set_post_thumbnail_size( 788, 0, true );
  498.     }
  499. }
  500.  
  501. //////////////////////////////////////////////////////////////////
  502. // Resizer function
  503. //////////////////////////////////////////////////////////////////
  504.  
  505. if( !class_exists('WPSM_image_resizer') ) {
  506. class WPSM_image_resizer{
  507.  
  508.     public $src = '';
  509.     public $width = '';
  510.     public $height = '';
  511.     public $size = 'full';
  512.     public $crop = false;
  513.     public $lazy = false;
  514.     public $title = '';
  515.     public $use_thumb = false;
  516.     public $no_thumb = '';
  517.     public $quality = '100';
  518.  
  519.     function __construct(){ //Enable lazy load when we need
  520.         if (rehub_option('enable_lazy_images') == '1'){
  521.             $this->lazy = true;
  522.         }
  523.     }
  524.  
  525.     public function get_resized_url() { //Show resized url with bfi_thumb function
  526.         $params = array( 'width' => $this->width, 'height' => $this->height, 'quality' => $this->quality, 'crop' => $this->crop);
  527.         $image_url = esc_url($this->src);
  528.         if (empty ($this->src) && $this->use_thumb == true) {
  529.             $image_url = $this->get_mypost_thumb_url();
  530.             if(!rehub_option('rh_image_resize')){
  531.                 $image_url = bfi_thumb( $image_url, $params );
  532.             }
  533.             $image_url = apply_filters('rh_thumb_resized_url', $image_url );           
  534.         }
  535.         else {
  536.             $image_url = bfi_thumb( $image_url, $params );
  537.             $image_url = apply_filters('rh_src_resized_url', $image_url );
  538.         }
  539.         if (empty($image_url)) {
  540.             $image_url = $this->no_thumb();        
  541.         }
  542.         return $image_url;     
  543.     }
  544.  
  545.     public function get_not_resized_url(){ //Show not resized url of image
  546.         $image_url = esc_url($this->src);
  547.  
  548.         if (empty ($this->src) && $this->use_thumb == true) {
  549.             $image_url = $this->get_mypost_thumb_url();
  550.         }
  551.         if (empty($image_url)) {
  552.             $image_url = $this->no_thumb();        
  553.         }
  554.         return apply_filters('rh_thumb_notresized_url', $image_url );
  555.     }
  556.  
  557.     public function get_mypost_thumb_url() {
  558.         global $post ;
  559.         $image_url = '';
  560.         if (function_exists('_nelioefi_url')){
  561.             $image_nelio_url = get_post_meta( $post->ID, _nelioefi_url(), true );
  562.             if (!empty($image_nelio_url)){
  563.                 return apply_filters('rh_thumb_url', $image_nelio_url );
  564.             }          
  565.         }
  566.         if ( has_post_thumbnail($post->ID) ){
  567.             $image_id = get_post_thumbnail_id($post->ID);  
  568.             $image_url = wp_get_attachment_image_src($image_id, $this->size);  
  569.             $image_url = $image_url[0];
  570.             return apply_filters('rh_thumb_url', $image_url );
  571.         }  
  572.         return apply_filters('rh_thumb_url', $image_url ); 
  573.     }
  574.  
  575.     public static function get_post_thumb_static($size = 'full'){
  576.         global $post ;
  577.         $image_url = '';
  578.         if (function_exists('_nelioefi_url')){
  579.             $image_nelio_url = get_post_meta( $post->ID, _nelioefi_url(), true );
  580.             if (!empty($image_nelio_url)){
  581.                 return apply_filters('rh_thumb_url', $image_nelio_url );
  582.             }          
  583.         }      
  584.         if ( has_post_thumbnail($post->ID) ){
  585.             $image_id = get_post_thumbnail_id($post->ID);  
  586.             $image_url = wp_get_attachment_image_src($image_id,$size);  
  587.             $image_url = $image_url[0];
  588.             return apply_filters('rh_thumb_url', $image_url );
  589.         }
  590.         return apply_filters('rh_thumb_url', $image_url ); 
  591.     }  
  592.  
  593.     public function no_thumb(){ //Set blank image when no image url found
  594.         if(rehub_option('featured_fallback_img')){$image_url = esc_url(rehub_option('featured_fallback_img'));}
  595.         else if(!empty($this->no_thumb)){$image_url = $this->no_thumb;}
  596.         else {$image_url = get_template_directory_uri() . '/images/default/blank.gif';}
  597.         return apply_filters('rh_no_thumb_url', $image_url);
  598.     }  
  599.  
  600.     public function show_resized_image() {
  601.         $width_param = (!empty($this->width)) ? ' width="'.$this->width.'"': '';
  602.         $height_param = (!empty($this->height)) ? ' height="'.$this->height.'"': '';
  603.         $alt = (!empty($this->title)) ? $this->title : the_title_attribute (array('echo' => 0) );
  604.         if ($this->lazy == true){
  605.             if(function_exists('is_amp_endpoint') && is_amp_endpoint()){
  606.                 echo '<img class="lazyimages" data-src="'.$this->get_resized_url().'"'.$width_param.$height_param.' alt="'.the_title_attribute (array('echo' => 0) ).'" src="'.$this->get_resized_url().'" />';
  607.             }else{         
  608.                 echo '<img class="lazyimages" data-src="'.$this->get_resized_url().'"'.$width_param.$height_param.' alt="'.the_title_attribute (array('echo' => 0) ).'" src="'.$this->no_thumb().'" />';
  609.             }
  610.         }
  611.         else {
  612.             echo '<img src="'.$this->get_resized_url().'"'.$width_param.$height_param.' alt="'.$alt.'" />';
  613.         }
  614.     }
  615.  
  616.     public function show_not_resized_image() {
  617.         $width_param = (!empty($this->width)) ? ' width="'.$this->width.'"': '';
  618.         $height_param = (!empty($this->height)) ? ' height="'.$this->height.'"': '';
  619.         $alt = (!empty($this->title)) ? $this->title : the_title_attribute (array('echo' => 0) );      
  620.         if ($this->lazy == true){
  621.             if(function_exists('is_amp_endpoint') && is_amp_endpoint()){
  622.                 echo '<img class="lazyimages" data-src="'.$this->get_not_resized_url().'"'.$width_param.$height_param.' alt="'.the_title_attribute (array('echo' => 0) ).'" src="'.$this->get_not_resized_url().'" />';
  623.             }else{
  624.                 echo '<img class="lazyimages" data-src="'.$this->get_not_resized_url().'"'.$width_param.$height_param.' alt="'.the_title_attribute (array('echo' => 0) ).'" src="'.$this->no_thumb().'" />';               
  625.             }
  626.  
  627.         }
  628.         else {
  629.             echo '<img src="'.$this->get_not_resized_url().'"'.$width_param.$height_param.' alt="'.$alt.'" />';
  630.         }
  631.     }
  632.  
  633.     public static function show_static_resized_image($params = array()) {
  634.        
  635.         $src = $width = $height = $title = $no_thumb_url = $no_thumb_fallback = '';
  636.         $crop = $lazy = $thumb = false;
  637.         if (rehub_option('enable_lazy_images') == '1'){
  638.             $lazy = true;
  639.         }      
  640.         @extract ($params);
  641.  
  642.         $params = array( 'width' => $width, 'height' => $height, 'crop' => $crop);
  643.         $no_thumb = (!empty($no_thumb_url)) ? apply_filters('rh_no_thumb_url', $no_thumb_url) : get_template_directory_uri() . '/images/default/blank.gif';
  644.         $image_url = esc_url($src);
  645.         if (empty($title)) {
  646.             $title = the_title_attribute (array('echo' => 0) );
  647.         }
  648.         if (!empty($image_url)) {
  649.             $image_url = bfi_thumb( $image_url, $params );
  650.             $image_url = apply_filters('rh_static_resized_url', $image_url);       
  651.         }  
  652.         elseif (empty($image_url) && $thumb == true) {
  653.             $image_url = self::get_post_thumb_static();
  654.             if(!rehub_option('rh_image_resize')){
  655.                 $image_url = bfi_thumb( $image_url, $params );
  656.             }
  657.             $image_url = apply_filters('rh_thumb_resized_url', $image_url );
  658.         }  
  659.         if (empty($image_url)) {
  660.             if (!empty($no_thumb_fallback)) return $no_thumb_fallback;
  661.             $image_url = $no_thumb;
  662.             $image_url = apply_filters('rh_no_thumb_url', $image_url); 
  663.         }
  664.         $width_param = (!empty($width)) ? ' width="'.$width.'"': '';
  665.         $height_param = (!empty($height)) ? ' height="'.$height.'"': '';
  666.         if ($lazy == true){
  667.             if(function_exists('is_amp_endpoint') && is_amp_endpoint()){
  668.                 echo '<img class="lazyimages" data-src="'.$image_url.'"'.$width_param.$height_param.' alt="'.$title.'" src="'.$image_url.'" />';
  669.             }else{
  670.                 echo '<img class="lazyimages" data-src="'.$image_url.'"'.$width_param.$height_param.' alt="'.$title.'" src="'.$no_thumb.'" />';
  671.             }
  672.         }
  673.         else {
  674.             echo '<img class="nolazyftheme" src="'.$image_url.'"'.$width_param.$height_param.' alt="'.$title.'" />';
  675.         }
  676.     }
  677.  
  678.     public static function show_wp_image($image_size='full', $attachment_id = '', $attributes = array()) {
  679.         global $post;
  680.         $lazy = true;
  681.         $lazy = apply_filters('rh_lazy_load', $lazy, $attachment_id);
  682.         if (!rehub_option('enable_lazy_images')){
  683.             $lazy = false;
  684.         }  
  685.         if(rehub_option('rh_image_resize')){
  686.             $image_size='full';
  687.         }      
  688.         $transparent = get_template_directory_uri() . '/images/default/blank.gif';
  689.         $image_id = ($attachment_id) ? (int)$attachment_id : get_post_thumbnail_id($post->ID);  
  690.         $image = wp_get_attachment_image_src($image_id,$image_size);
  691.         if(!empty($image)) {
  692.             $image_url = $image[0];
  693.         }else{
  694.             $image_url = '';
  695.         }
  696.         $image_url = apply_filters('rh_thumb_url', $image_url );
  697.         $css_class = (!empty($attributes['css_class'])) ? $attributes['css_class'] : '';
  698.         $output = '';
  699.         if ($lazy == true){
  700.             $alt   = trim( strip_tags( get_post_meta($image_id, '_wp_attachment_image_alt', true ) ) );
  701.             $alt = apply_filters('wp_get_attachment_alt_attribute', $alt);
  702.             if (empty($alt)) {
  703.                 $alt = the_title_attribute (array('echo' => 0) );
  704.             }          
  705.             if ( has_post_thumbnail($post->ID) ){
  706.                 $transparent = get_template_directory_uri() . '/images/default/blank.gif';
  707.                 if ( $attributes ) {
  708.                     $full_size_image = wp_get_attachment_image_src($image_id, 'full' );
  709.                     $output = sprintf(
  710.                         '<img src="%s" data-src="%s" alt="%s" class="lazyimages %s" data-large_image="%s" data-large_image_width="%s" data-large_image_height="%s">',
  711.                         esc_url( $transparent ),
  712.                         esc_url( $image_url ),
  713.                         esc_attr( $alt ),
  714.                         esc_attr( $css_class ),
  715.                         esc_attr( $full_size_image[0] ),
  716.                         esc_attr( $attributes['data-large_image_width'] ),
  717.                         esc_attr( $attributes['data-large_image_height'] )
  718.                     );
  719.                 } else {
  720.                     $output = sprintf(
  721.                         '<img src="%s" data-src="%s" alt="%s" class="lazyimages %s" width="%s" height="%s">',
  722.                         esc_url( $transparent ),
  723.                         esc_url( $image[0] ),
  724.                         esc_attr( $alt ),
  725.                         esc_attr( $css_class ),
  726.                         esc_attr( $image[1] ),
  727.                         esc_attr( $image[2] )
  728.                     );
  729.                 }
  730.             }else{
  731.                 if(rehub_option('featured_fallback_img')){
  732.                     $nothumb_url = esc_url(rehub_option('featured_fallback_img'));
  733.                 }
  734.                 else if(!empty($attributes['no_thumb'])){
  735.                     $nothumb_url = esc_url($attributes['no_thumb']);
  736.                 }
  737.                 else {
  738.                     $nothumb_url = get_template_directory_uri() . '/images/default/wooproductph.png';
  739.                 }
  740.                 $nothumb_url = apply_filters('rh_no_thumb_url', $nothumb_url);             
  741.                 $output = sprintf(
  742.                     '<img src="%s" data-src="%s" alt="%s" class="lazyimages %s" width="%s" height="%s">',
  743.                     esc_url( $transparent ),
  744.                     esc_url( $nothumb_url),
  745.                     esc_attr( $alt ),
  746.                     esc_attr( $css_class ),
  747.                     esc_attr( $image[1] ),
  748.                     esc_attr( $image[2] )
  749.                 );
  750.             }
  751.         } else {
  752.             $attributes['class'] = $css_class;
  753.             $output = wp_get_attachment_image( $image_id, $image_size, false, $attributes );
  754.         }
  755.        
  756.         $output = apply_filters('rh_thumb_output', $output);
  757.         return $output;    
  758.     }      
  759.  
  760. }}
  761.  
  762. //////////////////////////////////////////////////////////////////
  763. // Thumbnail function
  764. //////////////////////////////////////////////////////////////////
  765. if( !function_exists('wpsm_thumb') ) {
  766. function wpsm_thumb( $size = 'small', $lazy = true ){
  767.     if( $size == 'medium_news' ){$width = 432; $height = 250; $nothumb = get_template_directory_uri() . '/images/default/noimage_432_250.png' ;}
  768.     elseif( $size == 'med_thumbs' ){$width = 123; $height = 90; $nothumb = get_template_directory_uri() . '/images/default/noimage_123_90.png' ;}  
  769.     elseif( $size == 'news_big' ){$width = 378; $height = 310; $nothumb = get_template_directory_uri() . '/images/default/noimage_378_310.png' ;}
  770.     elseif( $size == 'grid_thumb' ){$width = 250; $height = 180; $nothumb = get_template_directory_uri() . '/images/default/noimage_250_180.png' ;}
  771.     elseif( $size == 'grid_news' ){$width = 336; $height = 220; $nothumb = get_template_directory_uri() . '/images/default/noimage_336_220.png' ;} 
  772.     else{ $width = 123; $height = 90; $nothumb = get_template_directory_uri() . '/images/default/noimage_123_90.png' ;}
  773.    
  774.     $showimg = new WPSM_image_resizer();
  775.     $showimg->use_thumb = true;
  776.     $showimg->no_thumb = $nothumb;
  777.     if ($lazy == false) {
  778.         $showimg->lazy = false;
  779.     }
  780.  
  781.     if( rehub_option( 'rh_image_resize')){
  782.         $showimg->size = $size;
  783.         $showimg->width = $width;
  784.         $showimg->height = $height;    
  785.         $showimg->show_not_resized_image();        
  786.     }else{
  787.         $showimg->width = $width;
  788.         $showimg->height = $height;
  789.         $showimg->crop = true;
  790.         $showimg->show_resized_image();
  791.     }
  792. }  
  793. }
  794.  
  795. //////////////////////////////////////////////////////////////////
  796. // Labels, badges, metas
  797. //////////////////////////////////////////////////////////////////
  798.  
  799. if( !function_exists('rehub_price_clean') ) {
  800. function rehub_price_clean($price) {
  801.     $cur_clean = array('8377', 'Rs.', 'руб.', 'RS.' );
  802.     $price = str_replace($cur_clean, '', $price);
  803.     if (rehub_option('price_pattern') == 'us') {
  804.         $price = (float) preg_replace("/[^0-9\.]/","", $price);        
  805.     }
  806.     elseif (rehub_option('price_pattern') == 'eu') {
  807.         $price = preg_replace("/[^0-9,]/","", $price);
  808.         $price = (float) str_replace(',', '.', $price);        
  809.     }
  810.     elseif (rehub_option('price_pattern') == 'in') {
  811.         $price = (float) preg_replace("/[^0-9\.]/","", $price);        
  812.     }
  813.     else {
  814.         $price = (float) preg_replace("/[^0-9\.]/","", $price);
  815.     }  
  816.     if (!is_numeric($price) || $price =='0')    {
  817.         return;
  818.     }
  819.     return $price;
  820.  
  821. }
  822. }
  823.  
  824. if( !function_exists('rehub_formats_icons') ) {
  825. function rehub_formats_icons($editor='no')
  826. {
  827.     global $post;
  828.     $offer_price_old = get_post_meta($post->ID, 'rehub_offer_product_price_old', true );
  829.     $offer_price_old = apply_filters('rehub_create_btn_price_old', $offer_price_old);  
  830.     if(!empty($offer_price_old)) {
  831.         $offer_price = get_post_meta( $post->ID, 'rehub_offer_product_price', true );
  832.         $offer_price = apply_filters('rehub_create_btn_price', $offer_price);      
  833.         if ( !empty($offer_price)) {
  834.             $offer_pricesale = rehub_price_clean($offer_price); //Clean price from currence symbols
  835.             $offer_priceold = rehub_price_clean($offer_price_old); //Clean price from currence symbols
  836.             if (is_numeric($offer_priceold) && is_numeric($offer_pricesale) && $offer_priceold !=0 && (int)$offer_priceold > (int)$offer_pricesale) {
  837.                 $off_proc = 0 -(100 - ((int)$offer_pricesale / (int)$offer_priceold) * 100);
  838.                 $off_proc = round($off_proc);
  839.                 echo '<span class="overlay_post_formats sale_format"><i class="far fa-tag"></i> <span>'.$off_proc.'%</span></span>';
  840.             }
  841.         }          
  842.     }  
  843. }
  844. }
  845.  
  846. if( !function_exists('rehub_format_score') ) {
  847. function rehub_format_score($size = 'small', $type = 'star' )
  848. {
  849.     if(vp_metabox('rehub_post.rehub_framework_post_type') == 'review') {
  850.         $overall_score_icon = rehub_get_overall_score();
  851.         $total = $overall_score_icon * 10;
  852.         if ($overall_score_icon !='0' && $overall_score_icon !='') {
  853.             if ($type == 'star') {
  854.                 echo '<div class="star-'.$size.'"><span class="stars-rate"><span style="width: '.$total.'%;"></span></span></div>';
  855.             }
  856.             elseif ($type == 'square') {
  857.                 echo '<span class="overlay_post_formats review_formats_score">'.$overall_score_icon.'</span>';
  858.             }
  859.             elseif ($type == 'line') { ?>
  860.                 <div class="rate-line rate-line-inner<?php if (rehub_option('color_type_review') == 'multicolor') {echo ' colored_rate_bar';} ?>">
  861.                     <div class="line" data-percent="<?php echo (int)$total;?>%">
  862.                         <span class="filled r_score_<?php echo round($overall_score_icon); ?>"><?php echo ''.$overall_score_icon ?></span>
  863.                     </div>
  864.                 </div>
  865.             <?php
  866.             }          
  867.         }  
  868.     }
  869. }
  870. }
  871.  
  872. if( !function_exists('meta_all') ) { //post meta
  873. function meta_all ($time_exist, $cats_exist, $admin_exist, $cats_post = false ){
  874.     global $post;
  875.     if(rehub_option('exclude_author_meta') != 1 && ($admin_exist != false)){ ?>
  876.         <?php $author_id=$post->post_author; ?>
  877.         <span class="admin_meta">
  878.             <a class="admin" href="<?php echo get_author_posts_url( $author_id ) ?>">
  879.                 <?php if ($admin_exist === 'full') :?><?php echo get_avatar( $author_id, '22' ); ?><?php endif;?>
  880.                 <?php the_author_meta( 'display_name', $author_id ); ?>
  881.             </a>
  882.         </span>
  883.     <?php }  
  884.     if(rehub_option('exclude_date_meta') != 1 && ($time_exist != false)){ ?>
  885.         <span class="date_meta"><?php the_modified_time(get_option( 'date_format' )); ?></span>
  886.     <?php }
  887.     if(rehub_option('exclude_cat_meta') != 1 && ($cats_exist != false) && (!empty($cats_exis))){ ?>
  888.         <?php $cat_name = get_cat_name($cats_exist); ?>
  889.         <span class="cat_link_meta"><a class="cat" href="<?php echo get_category_link( $cats_exist); ?>"><?php echo ''.$cat_name ?></a></span>
  890.     <?php }  
  891.     if(rehub_option('exclude_cat_meta') != 1 && ($cats_post != false)){
  892.         $postidforcat = $post->ID;
  893.         if ('post' == $post->post_type) {
  894.             $categories = get_the_category($postidforcat);
  895.             $separator = ', ';
  896.             $output = '';
  897.             if ( ! empty( $categories ) ) {
  898.                 echo '<span class="cat_link_meta">';
  899.                 foreach( $categories as $category ) {
  900.                     $output .= '<a class="cat" href="' . esc_url( get_category_link( $category->term_id ) ) . '" title="' . esc_attr( sprintf( esc_html__( 'View all posts in %s', 'rehub-theme' ), $category->name ) ) . '">' . esc_html( $category->name ) . '</a>' . $separator;
  901.                 }
  902.                 echo trim( $output, $separator );
  903.                 echo '</span>';
  904.             }
  905.         }
  906.         elseif ('blog' == $post->post_type) {
  907.             $term_list = get_the_term_list( $post->ID, 'blog_category', '<span class="date_meta">', ', ', '</span>' );
  908.             if(!is_wp_error($term_list)){
  909.                 echo ''.$term_list;
  910.             }
  911.         }
  912.     }          
  913. }
  914. }
  915.  
  916. if( !function_exists('rh_post_header_meta') ) { //post meta
  917. function rh_post_header_meta ($admin_exist = true, $time_exist = true, $view_exist = true, $comment_exist = true, $cats_post = true ){
  918.     global $post;
  919.     if(rehub_option('exclude_author_meta') != 1 && ($admin_exist != false)){ ?>
  920.         <?php $author_id=$post->post_author; ?>
  921.         <span class="admin_meta">
  922.             <a class="admin" href="<?php echo get_author_posts_url( $author_id ) ?>">
  923.                 <?php if ($admin_exist === 'full') :?><?php echo get_avatar( $author_id, '22' ); ?><?php endif;?>
  924.                 <?php if ($admin_exist === 'fullbig') :?><?php echo get_avatar( $author_id, '40' ); ?><?php endif;?>               
  925.                 <?php the_author_meta( 'display_name', $author_id ); ?>        
  926.             </a>
  927.         </span>
  928.     <?php }  
  929.     if(rehub_option('exclude_date_meta') != 1 && ($time_exist != false)){ ?>
  930.         <span class="date_meta"><?php the_modified_time(get_option( 'date_format' )); ?></span>
  931.     <?php }  
  932.     if(rehub_option('post_view_disable') != 1 && ($view_exist != false) && function_exists('RH_get_post_views')){ ?>
  933.         <?php $rehub_views = RH_get_post_views($post->ID); if ($rehub_views !='') :?>
  934.             <span class="postview_meta"><?php echo (int)$rehub_views; ?> </span>
  935.         <?php endif ;?>
  936.     <?php }
  937.     if(rehub_option('exclude_comments_meta') != 1 && ($comment_exist != false)){ ?>
  938.         <?php if($comment_exist=='compact'):?>
  939.             <span class="comm_count_meta"><?php comments_popup_link( esc_html__('0','rehub-theme'), esc_html__('1','rehub-theme'), esc_html__('%','rehub-theme'), 'comm_meta', ''); ?></span>
  940.         <?php elseif ($comment_exist == 'compactnoempty'):?>
  941.             <?php if($post->comment_count > 0):?>
  942.             <span class="comm_count_meta"><?php comments_popup_link( esc_html__('0','rehub-theme'), esc_html__('1','rehub-theme'), esc_html__('%','rehub-theme'), 'comm_meta', ''); ?></span>
  943.             <?php endif;?>
  944.         <?php else:?>
  945.             <span class="comm_count_meta"><?php comments_popup_link( esc_html__('no comments','rehub-theme'), esc_html__('1 comment','rehub-theme'), esc_html__('% comments','rehub-theme'), 'comm_meta', ''); ?></span>
  946.         <?php endif;?>
  947.     <?php }
  948.     if(rehub_option('exclude_cat_meta') != 1 && ($cats_post != false)){
  949.         $postidforcat = $post->ID;
  950.         if ('post' == $post->post_type) {
  951.             $categories = get_the_category($postidforcat);
  952.             $separator = ', ';
  953.             $output = '';
  954.             if ( ! empty( $categories ) ) {
  955.                 echo '<span class="cat_link_meta">';
  956.                 foreach( $categories as $category ) {
  957.                     $output .= '<a class="cat" href="' . esc_url( get_category_link( $category->term_id ) ) . '" title="' . esc_attr( sprintf( esc_html__( 'View all posts in %s', 'rehub-theme' ), $category->name ) ) . '">' . esc_html( $category->name ) . '</a>' . $separator;
  958.                 }
  959.                 echo trim( $output, $separator );
  960.                 echo '</span>';
  961.             }
  962.         }
  963.         elseif ('blog' == $post->post_type) {
  964.             $term_list = get_the_term_list( $post->ID, 'blog_category', '<span class="date_meta">', ', ', '</span>' );
  965.             if(!is_wp_error($term_list)){
  966.                 echo ''.$term_list;
  967.             }
  968.         }
  969.         elseif ('product' == $post->post_type) {
  970.             $term_list = get_the_term_list( $post->ID, 'product_cat', '<span class="date_meta">', ', ', '</span>' );
  971.             if(!is_wp_error($term_list)){
  972.                 echo ''.$term_list;
  973.             }
  974.         }      
  975.     }              
  976. }
  977. }
  978.  
  979. if( !function_exists('rh_post_header_meta_big') ) { //post meta_big
  980. function rh_post_header_meta_big (){
  981.     global $post;
  982.     ?>
  983.         <div class="floatleft mr15">
  984.             <?php if(rehub_option('exclude_author_meta') != 1):?>
  985.                 <?php $author_id=$post->post_author; ?>
  986.                 <a href="<?php echo get_author_posts_url( $author_id ) ?>" class="floatleft mr10">
  987.                     <?php echo get_avatar( $author_id, '40' ); ?>                  
  988.                 </a>   
  989.             <?php endif;?>
  990.             <span class="floatleft authortimemeta">
  991.                 <?php if(rehub_option('exclude_author_meta') != 1):?>
  992.                     <a href="<?php echo get_author_posts_url( $author_id ) ?>">            
  993.                         <?php the_author_meta( 'display_name', $author_id ); ?>        
  994.                     </a>
  995.                 <?php endif;?>
  996.                 <?php if(rehub_option('exclude_date_meta') != 1):?>
  997.                     <div class="date_time_post"><?php the_modified_time(get_option( 'date_format' )); ?></div>
  998.                 <?php endif;?>
  999.             </span>
  1000.  
  1001.         </div>
  1002.         <div class="floatright ml15 postviewcomm mt5">
  1003.             <?php if(rehub_option('post_view_disable') != 1 && function_exists('RH_get_post_views')):?>
  1004.                 <?php $rehub_views = RH_get_post_views($post->ID);?>
  1005.                 <span class="postview_meta mr15 ml15"><strong><?php echo (int)$rehub_views; ?></strong> <?php esc_html_e('Views', 'rehub-theme');?></span>
  1006.             <?php endif;?> 
  1007.             <?php if(rehub_option('exclude_comments_meta') != 1):?>        
  1008.                 <span class="comm_count_meta"><strong><?php comments_popup_link( esc_html__('0','rehub-theme'), esc_html__('1 comment','rehub-theme'), esc_html__('% comments','rehub-theme'), 'comm_meta', ''); ?></strong></span>
  1009.             <?php endif;?>         
  1010.         </div> 
  1011.     <?php                  
  1012. }
  1013. }
  1014.  
  1015. if( !function_exists('rh_post_header_cat') ) { //post meta
  1016. function rh_post_header_cat($post_type='post', $dealstore = false, $postid = ''){
  1017.     if($postid){
  1018.         $post_id = $postid;
  1019.     }
  1020.     else{
  1021.         global $post;
  1022.         $post_id = $post->ID;
  1023.     }
  1024.     if(rehub_option('exclude_cat_meta') != 1){
  1025.         echo '<div class="rh-cat-list-title">';
  1026.         if ($post_type=='post' && 'post' == get_post_type($post_id)) {
  1027.             $categories = get_the_category($post_id);
  1028.             $separator = '';
  1029.             $output = '';
  1030.             if ( ! empty( $categories ) ) {
  1031.                 foreach( $categories as $category ) {
  1032.                     $cat_data = get_option("category_$category->term_id");
  1033.                     if (!empty($cat_data['cat_color'])) :
  1034.                         echo '<style scoped>.rh-cat-label-title.rh-cat-'.$category->term_id.'{background-color:'.$cat_data['cat_color'].'; color:#fff}</style>';
  1035.                     endif;
  1036.                     $output .= '<a class="rh-cat-label-title rh-cat-'.$category->term_id.'" href="' . esc_url( get_category_link( $category->term_id ) ) . '" title="' . esc_attr( sprintf( esc_html__( 'View all posts in %s', 'rehub-theme' ), $category->name ) ) . '">' . esc_html( $category->name ) . '</a>' . $separator;
  1037.                 }
  1038.                 echo trim( $output, $separator );
  1039.             }
  1040.             if(rehub_option('enable_brand_taxonomy') == 1 && $dealstore == true){
  1041.                 $dealcats = wp_get_post_terms($post_id, 'dealstore', array("fields" => "all"));
  1042.                 if( ! empty( $dealcats ) && ! is_wp_error( $dealcats ) ) {
  1043.                     foreach( $dealcats as $dealcat ) {
  1044.                         echo '<a class="rh-cat-label-title rh-dealstore-cat rh-cat-'.$dealcat->term_id.'" href="' . esc_url( get_term_link( $dealcat->term_id ) ) . '" title="' . esc_attr( sprintf( esc_html__( 'View all posts in %s', 'rehub-theme' ), $dealcat->name ) ) . '">' . esc_html( $dealcat->name ) . '</a>' . $separator;                    
  1045.                     }
  1046.                 }                              
  1047.             }      
  1048.         }
  1049.         elseif ('blog' == get_post_type($post_id)) {
  1050.             $term_list = get_the_term_list( $post_id, 'blog_category', '<span class="rh-cat-label-title">', '', '</span>' );
  1051.             if(!is_wp_error($term_list)){
  1052.                 echo ''.$term_list;
  1053.             }
  1054.         }
  1055.         echo '</div>';
  1056.     }              
  1057. }
  1058. }
  1059.  
  1060. if( !function_exists('meta_small') ) { //another post meta function
  1061. function meta_small ($time_exist, $cats_exist, $comment_exist, $post_views = false ){
  1062.     global $post;    
  1063.     if(rehub_option('exclude_date_meta') != 1 && ($time_exist != false)){ ?>
  1064.         <span class="date_meta"><?php the_modified_time(get_option( 'date_format' )); ?></span>    
  1065.     <?php }
  1066.     if(rehub_option('exclude_cat_meta') != 1 && ($cats_exist != false)){ ?>
  1067.         <?php $cat_name = get_cat_name($cats_exist); ?>
  1068.         <span class="cat_link_meta"><a href="<?php echo get_category_link( $cats_exist); ?>" class="cat"><?php echo esc_attr($cat_name) ?></a></span>
  1069.     <?php }
  1070.     if(rehub_option('exclude_comments_meta') != 1 && ($comment_exist != false)){ ?>
  1071.         <?php if($comment_exist=='compact'):?>
  1072.             <span class="comm_count_meta"><?php comments_popup_link( esc_html__('0','rehub-theme'), esc_html__('1','rehub-theme'), esc_html__('%','rehub-theme'), 'comm_meta', ''); ?></span>
  1073.         <?php elseif ($comment_exist == 'compactnoempty'):?>
  1074.             <?php if($post->comment_count > 0):?>
  1075.             <span class="comm_count_meta"><?php comments_popup_link( esc_html__('0','rehub-theme'), esc_html__('1','rehub-theme'), esc_html__('%','rehub-theme'), 'comm_meta', ''); ?></span>
  1076.             <?php endif;?>
  1077.         <?php else:?>
  1078.             <span class="comm_count_meta"><?php comments_popup_link( esc_html__('no comments','rehub-theme'), esc_html__('1 comment','rehub-theme'), esc_html__('% comments','rehub-theme'), 'comm_meta', ''); ?></span>
  1079.         <?php endif;?>
  1080.     <?php }
  1081.     if($post_views != false && rehub_option('post_view_disable') != 1 && function_exists('RH_get_post_views')){ ?>
  1082.         <?php $rehub_views = RH_get_post_views($post->ID); if ($rehub_views !='') :?>
  1083.             <span class="postview_meta"><?php echo (int)$rehub_views; ?> </span>
  1084.         <?php endif ;?>
  1085.     <?php }            
  1086. }
  1087. }
  1088.  
  1089. if( !function_exists('re_badge_create') ) { //CREATING BADGES
  1090. function re_badge_create ($type = 'label', $postid = '' ){
  1091.     if($postid){
  1092.         $post_id = $postid;
  1093.     }
  1094.     else{
  1095.         global $post;
  1096.         $post_id = $post->ID;
  1097.     }
  1098.     $badge = get_post_meta($post_id, 'is_editor_choice', true);
  1099.     if ($badge !='' && $badge !='0' && $badge !='no') {
  1100.         $output = '';
  1101.         $label = rehub_option('badge_label_'.$badge.'');  
  1102.         if($type =='tablelabel'){
  1103.             $output .= '<span class="re-line-badge re-line-table-badge badge_'.$badge.'"><span>'.$label.'</span></span>';
  1104.         }
  1105.         elseif($type =='ribbon'){
  1106.             $output .= '<span class="re-ribbon-badge badge_'.$badge.'"><span>'.$label.'</span></span>';
  1107.         }
  1108.         elseif($type =='ribbonleft'){
  1109.             $output .= '<span class="re-ribbon-badge left-badge badge_'.$badge.'"><span>'.$label.'</span></span>';
  1110.         }              
  1111.         elseif($type =='starburst'){
  1112.             $output .= '<span class="re-starburst badge_'.$badge.'"><span><span><span><span><span><span><span><span><strong>'.$label.'</strong></span></span></span></span></span></span></span></span></span></span>';
  1113.         }
  1114.         elseif($type =='class'){
  1115.             $output .= 'ed_choice_col badge_'.$badge.'';
  1116.         }
  1117.         elseif($type =='labelbig'){
  1118.             $output .= '<div class="text-center"><span class="re-line-badge re-line-big-label badge_'.$badge.'"><span>'.$label.'</span></span></div>';
  1119.         }
  1120.         elseif($type =='labelsmall'){
  1121.             $output .= '<span class="re-line-badge re-line-small-label badge_'.$badge.'"><span>'.$label.'</span></span>';
  1122.         }
  1123.         else{
  1124.             $output .= '<span class="re-line-badge badge_'.$badge.'"><span>'.$label.'</span></span>';
  1125.         }  
  1126.         return $output;    
  1127.     }
  1128.     else {
  1129.         return;
  1130.     }
  1131.        
  1132. }
  1133. }
  1134.  
  1135. //////////////////////////////////////////////////////////////////
  1136. // ADD FUNCTIONS
  1137. //////////////////////////////////////////////////////////////////
  1138.  
  1139. //Review and user reviews
  1140. if (rehub_option('type_user_review') == 'user') {include (get_template_directory() . '/functions/user_review_no_editor.php');}
  1141. include (get_template_directory() . '/functions/review_functions.php');
  1142. if (rehub_option('type_user_review') == 'full_review' || rehub_option('type_user_review') == 'user') {
  1143.     include (get_template_directory() . '/functions/user_review_functions.php');
  1144. }
  1145.  
  1146. //Affiliate for posts
  1147. include (get_template_directory() . '/functions/affiliate_functions.php');
  1148.  
  1149. //add video class
  1150. include (get_template_directory() . '/functions/video_class.php');
  1151.  
  1152. //add widget sidebar functions
  1153. include (get_template_directory() . '/functions/sidebar_functions.php');
  1154.  
  1155. //add woocommerce functions
  1156. if (class_exists('Woocommerce')) {
  1157. include (get_template_directory() . '/functions/woo_functions.php');
  1158. }
  1159.  
  1160. //add EDD functions
  1161. if (class_exists('Easy_Digital_Downloads')) {
  1162.     include (get_template_directory() . '/functions/edd_functions.php');
  1163. }
  1164.  
  1165. //add ajax functions
  1166. include (get_template_directory() . '/functions/ajax_helper_functions.php');
  1167.  
  1168. //add member helper functions
  1169. include (get_template_directory() . '/functions/member_helper_functions.php');
  1170.  
  1171. //add shortcode functions
  1172. include (get_template_directory() . '/shortcodes/shortcodes.php');
  1173.  
  1174. // Login / Register Modal
  1175. if (rehub_option('userlogin_enable') == '1') {
  1176. require_once ( rh_locate_template( 'inc/user-login.php' ) );
  1177. }
  1178.  
  1179. // Compare functions
  1180. if (rehub_option('compare_page') != '' || rehub_option('compare_multicats_textarea') != '') {
  1181. require_once ( 'inc/compare.php');
  1182. }
  1183.  
  1184. // Hot, thumb functions
  1185. require_once ( locate_template( 'functions/thumbandhot.php' ) );
  1186.  
  1187. //support buddypress functions
  1188. if ( class_exists( 'BuddyPress' ) ) {
  1189.     require_once ( rh_locate_template( 'buddypress/bp_custom.php' ) );
  1190. }
  1191.  
  1192.  
  1193. //////////////////////////////////////////////////////////////////
  1194. // COMMENTS LAYOUT
  1195. //////////////////////////////////////////////////////////////////
  1196.  
  1197. if( !function_exists('rehub_framework_comments') ) {
  1198. function rehub_framework_comments($comment, $args, $depth) {
  1199.     $GLOBALS['comment'] = $comment;    
  1200.     ?>
  1201.     <li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
  1202.         <div class="commbox">
  1203.             <div class="comment-author vcard clearfix">
  1204.                 <?php edit_comment_link(__('Edit', 'rehub-theme')); ?>
  1205.                 <?php comment_reply_link(array_merge( $args, array('reply_text' => esc_html__(' Reply', 'rehub-theme'), 'depth' => $depth, 'max_depth' => $args['max_depth'])), $comment->comment_ID); ?>                    
  1206.                 <?php echo get_avatar($comment,$args['avatar_size']); ?>
  1207.                 <div class="comm_meta_wrap">
  1208.                     <?php if (rehub_option('rh_enable_mycred_comment') == 1):?>
  1209.                         <?php
  1210.                             $author_id = $comment->user_id;
  1211.                             if(function_exists('mycred_get_users_rank') && $author_id !=0){
  1212.                                 if(rehub_option('rh_mycred_custom_points')){
  1213.                                     $custompoint = rehub_option('rh_mycred_custom_points');
  1214.                                     $mycredrank = mycred_get_users_rank($author_id, $custompoint );
  1215.                                 }
  1216.                                 else{
  1217.                                     $mycredrank = mycred_get_users_rank($author_id);       
  1218.                                 }
  1219.                             }
  1220.                             if(function_exists('mycred_display_users_total_balance')){
  1221.                                 if(rehub_option('rh_mycred_custom_points')){
  1222.                                     $custompoint = rehub_option('rh_mycred_custom_points');
  1223.                                     $mycredpoint = mycred_render_shortcode_my_balance(array('type'=>$custompoint, 'user_id'=>$author_id, 'wrapper'=>'', 'balance_el' => '') );
  1224.                                 }
  1225.                                 else{
  1226.                                     $mycredpoint = mycred_render_shortcode_my_balance(array('user_id'=>$author_id, 'wrapper'=>'', 'balance_el' => '') );          
  1227.                                 }
  1228.                             }                          
  1229.  
  1230.                             ?>
  1231.  
  1232.                         <span class="fn"><?php echo get_comment_author_link(); ?><?php if (!empty($mycredrank) && is_object( $mycredrank)) :?><span class="rh-user-rank-mc rh-user-rank-<?php echo (int)$mycredrank->post_id; ?>"><?php echo esc_html($mycredrank->title) ;?></span><?php endif;?></span>
  1233.                         <div class="comm_meta_cred">
  1234.                             <?php if ( function_exists( 'mycred_get_users_badges' ) && $author_id !=0 ) : ?>
  1235.                                 <?php rh_mycred_display_users_badges( $author_id ) ?>
  1236.                             <?php endif; ?>
  1237.                             <?php if (!empty($mycredpoint)) :?><div><i class="far fa-star"></i> <?php echo ''.$mycredpoint; ?></div><?php endif;?>
  1238.                         </div>
  1239.                     <?php else:?>
  1240.                         <span class="fn"><?php echo get_comment_author_link(); ?>
  1241.                         <?php  
  1242.                             if (function_exists('bp_get_member_type')){
  1243.                                 $author_id = $comment->user_id;    
  1244.                                 $membertype = bp_get_member_type($author_id);
  1245.                                 $membertype_object = bp_get_member_type_object($membertype);
  1246.                                 $membertype_label = (!empty($membertype_object) && is_object($membertype_object)) ? $membertype_object->labels['singular_name'] : '';
  1247.                                 if($membertype_label){
  1248.                                     echo '<span class="rh-user-rank-mc rh-user-rank-'.$membertype.'">'.$membertype_label.'</span>';
  1249.                                 }
  1250.                             }
  1251.                         ?>     
  1252.                         </span>
  1253.                     <?php endif;?>             
  1254.                     <span class="time"><a href="#comment-<?php comment_ID() ?>"><?php printf(__('%1$s at %2$s', 'rehub-theme'), get_comment_date(),  get_comment_time()) ?></a></span>
  1255.                     <?php if ($comment->comment_approved == '0') : ?><div class="ap_waiting"><em><?php esc_html_e('Comment awaiting for approval', 'rehub-theme'); ?></em></div><?php endif; ?>
  1256.                 </div>             
  1257.             </div>
  1258.             <?php if (rehub_option('type_user_review') == 'full_review' || rehub_option('type_user_review') == 'user') :?>              
  1259.                 <?php $userCriteria = get_comment_meta(get_comment_ID(), 'user_criteria', true);
  1260.                 if(is_array($userCriteria) && !empty($userCriteria)) :?>
  1261.                   <div class="comment-content-withreview">
  1262.                        <?php attach_comment_criteria_raitings () ;?>
  1263.                   </div>  
  1264.                 <?php else :?>
  1265.                    <div class="comment-content"><?php comment_text(); ?></div>
  1266.                 <?php endif; ?>
  1267.             <?php else :?>
  1268.                 <div class="comment-content"><?php comment_text(); ?></div>
  1269.             <?php endif; ?>          
  1270.         </div>
  1271.     <?php
  1272. }
  1273. }
  1274.  
  1275. if(!function_exists('rh_comment_author_profile_link')){
  1276. function rh_comment_author_profile_link(){
  1277. global $comment;
  1278. if (empty($comment)) return;
  1279. $commentauthor_ID = $comment->user_id;
  1280.  
  1281. if ($commentauthor_ID ==0) {
  1282.     $author = get_comment_author( $comment->comment_ID);
  1283.     $url = get_comment_author_url( $comment->comment_ID);
  1284.     if ( empty( $url ) || 'http://' == $url )
  1285.         $return = $author;
  1286.     else
  1287.         $return = '<span class="ext-source" data-dest="'.$url.'">'.$author.'</span>';
  1288. }
  1289. else {
  1290.     $author = get_userdata($commentauthor_ID);
  1291.     /* Registered Commenter */
  1292.     if ( !empty($author) ){
  1293.         $authorid = $author->ID;
  1294.         $authorName = $author->display_name;
  1295.         if (class_exists( 'BuddyPress' )) {
  1296.             return '<span class="int-source" data-dest="'.bp_core_get_user_domain($authorid).'">'.$authorName.'</span>';
  1297.         }
  1298.         elseif (count_user_posts($authorid) > 0 && !empty($author)) {  
  1299.             return '<span class="int-source" data-dest="'.get_author_posts_url($authorid).'">'.$authorName.'</span>';
  1300.         }  
  1301.         else {
  1302.             $author = get_comment_author($comment->comment_ID);
  1303.             $return = $author;
  1304.         }          
  1305.     }
  1306.     else {
  1307.         $author = get_comment_author($comment->comment_ID);
  1308.         $return = $author;
  1309.     }
  1310. }
  1311. return $return;
  1312. }
  1313. }
  1314. if (rehub_option('enable_comment_link') == 1){
  1315.     add_filter('get_comment_author_link', 'rh_comment_author_profile_link');
  1316. }
  1317.  
  1318.  
  1319.  
  1320. /**
  1321.  * This file represents an example of the code that themes would use to register
  1322.  * the required plugins.
  1323.  *
  1324.  * It is expected that theme authors would copy and paste this code into their
  1325.  * functions.php file, and amend to suit.
  1326.  *
  1327.  * @package    TGM-Plugin-Activation
  1328.  * @subpackage Example
  1329.  * @version    2.4.0
  1330.  * @author     Thomas Griffin <thomasgriffinmedia.com>
  1331.  * @author     Gary Jones <gamajo.com>
  1332.  * @copyright  Copyright (c) 2014, Thomas Griffin
  1333.  * @license    http://opensource.org/licenses/gpl-2.0.php GPL v2 or later
  1334.  * @link       https://github.com/thomasgriffin/TGM-Plugin-Activation
  1335.  */
  1336.  
  1337. /**
  1338.  * Include the TGM_Plugin_Activation class.
  1339.  */
  1340. require_once dirname( __FILE__ ) . '/class-tgm-plugin-activation.php';
  1341.  
  1342. add_action( 'tgmpa_register', 'my_theme_register_required_plugins' );
  1343. /**
  1344.  * Register the required plugins for this theme.
  1345.  *
  1346.  * In this example, we register two plugins - one included with the TGMPA library
  1347.  * and one from the .org repo.
  1348.  *
  1349.  * The variable passed to tgmpa_register_plugins() should be an array of plugin
  1350.  * arrays.
  1351.  *
  1352.  * This function is hooked into tgmpa_init, which is fired within the
  1353.  * TGM_Plugin_Activation class constructor.
  1354.  */
  1355. if( !function_exists('my_theme_register_required_plugins') ) {
  1356. function my_theme_register_required_plugins() {
  1357.  
  1358.     /**
  1359.      * Array of plugin arrays. Required keys are name and slug.
  1360.      * If the source is NOT from the .org repo, then source is also required.
  1361.      */
  1362.     $plugins = array(
  1363.         array(
  1364.             'name' => 'One Click Demo Import',
  1365.             'slug' => 'one-click-demo-import',
  1366.             'required' => false,
  1367.             'image_url' => get_template_directory_uri() . '/admin/screens/images/ocdi.jpg',
  1368.             'description' => 'Import demo content and settings',
  1369.         ),     
  1370.         array(
  1371.             'name'                  => 'Envato Market', // The plugin name
  1372.             'slug'                  => 'envato-market', // The plugin slug (typically the folder name)
  1373.             'source'                => get_template_directory() . '/plugins/envato-market.zip', // The plugin source
  1374.             'required'              => false, // If false, the plugin is only 'recommended' instead of required
  1375.             'version'               => '', // E.g. 1.0.0. If set, the active plugin must be this version or higher, otherwise a notice is presented
  1376.             'force_activation'      => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch
  1377.             'force_deactivation'    => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins
  1378.             'external_url'          => '', // If set, overrides default API URL and points to an external URL
  1379.             'image_url'             => get_template_directory_uri() . '/admin/screens/images/envato.jpg',          
  1380.             'description'           => 'Auto update of theme',
  1381.         ),     
  1382.         array(
  1383.             'name'      => 'Content EGG',
  1384.             'slug'      => 'content-egg',
  1385.             'required'  => false,
  1386.             'image_url'          => get_template_directory_uri() . '/admin/screens/images/contentegg.png',
  1387.             'description'           => 'All in one for moneymaking',           
  1388.         ), 
  1389.         array(
  1390.             'name'                  => 'Rehub Framework', // The plugin name
  1391.             'slug'                  => 'rehub-framework', // The plugin slug (typically the folder name)
  1392.             'source'                => get_template_directory() . '/plugins/rehub-framework.zip',
  1393.             'required'              => true,
  1394.             'version'               => '2.4',
  1395.             'force_activation'      => false,
  1396.             'force_deactivation'    => false,
  1397.             'external_url'          => '',
  1398.             'image_url'             => get_template_directory_uri() . '/admin/screens/images/framework.png',
  1399.             'description'           => 'Rehub Theme framework',
  1400.         ),                                     
  1401.  
  1402.     );
  1403.    
  1404.  
  1405.     if (REHUB_NAME_ACTIVE_THEME == 'REDOKAN'){
  1406.         $plugins[] = array(
  1407.             'name'      => 'Dokan Multivendor Marketplace',
  1408.             'slug'      => 'dokan-lite',
  1409.             'required'  => true,
  1410.             'image_url'          => get_template_directory_uri() . '/admin/screens/images/redokan.jpg',
  1411.             'description'           => 'Vendor Functions for Site',        
  1412.         );
  1413.     }  
  1414.  
  1415.     if (REHUB_NAME_ACTIVE_THEME == 'REHUB' || REHUB_NAME_ACTIVE_THEME == 'REWISE' || REHUB_NAME_ACTIVE_THEME == 'RECASH'){
  1416.         $plugins[] = array(
  1417.             'name'      => 'Elementor',
  1418.             'slug'      => 'elementor',
  1419.             'required'  => false,
  1420.             'image_url'          => get_template_directory_uri() . '/admin/screens/images/elementor.jpg',
  1421.             'description'           => 'Elementor Page Builder',           
  1422.         );
  1423.     }        
  1424.  
  1425.     /**
  1426.      * Array of configuration settings. Amend each line as needed.
  1427.      * If you want the default strings to be available under your own theme domain,
  1428.      * leave the strings uncommented.
  1429.      * Some of the strings are added into a sprintf, so see the comments at the
  1430.      * end of each line for what each argument will be.
  1431.      */
  1432.     $config = array(
  1433.         'id'           => 'rehub-theme',                 // Unique ID for hashing notices for multiple instances of TGMPA.
  1434.         'default_path' => '',                      // Default absolute path to pre-packaged plugins.
  1435.         'menu'         => 'tgmpa-install-plugins', // Menu slug.
  1436.         'has_notices'  => true,                    // Show admin notices or not.
  1437.         'dismissable'  => true,                    // If false, a user cannot dismiss the nag message.
  1438.         'dismiss_msg'  => '',                      // If 'dismissable' is false, this message will be output at top of nag.
  1439.         'is_automatic' => false,                   // Automatically activate plugins after installation or not.
  1440.         'message'      => '',                      // Message to output right before the plugins table.
  1441.         'strings'      => array(
  1442.             'page_title'                      => esc_html__( 'Install Required Plugins', 'rehub-theme' ),
  1443.             'menu_title'                      => esc_html__( 'Install Plugins', 'rehub-theme' ),
  1444.             'installing'                      => esc_html__( 'Installing Plugin: %s', 'rehub-theme' ), // %s = plugin name.
  1445.             'oops'                            => esc_html__( 'Something went wrong with the plugin API.', 'rehub-theme' ),
  1446.             'notice_can_install_required'     => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.', 'rehub-theme' ), // %1$s = plugin name(s).
  1447.             'notice_can_install_recommended'  => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s. Please, activate only those plug-ins which are necessary to you', 'rehub-theme' ), // %1$s = plugin name(s).
  1448.             'notice_cannot_install'           => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.', 'rehub-theme' ), // %1$s = plugin name(s).
  1449.             'notice_can_activate_required'    => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.', 'rehub-theme' ), // %1$s = plugin name(s).
  1450.             'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.', 'rehub-theme' ), // %1$s = plugin name(s).
  1451.             'notice_cannot_activate'          => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.', 'rehub-theme' ), // %1$s = plugin name(s).
  1452.             'notice_ask_to_update'            => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.', 'rehub-theme' ), // %1$s = plugin name(s).
  1453.             'notice_cannot_update'            => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.', 'rehub-theme' ), // %1$s = plugin name(s).
  1454.             'install_link'                    => _n_noop( 'Begin installing plugin', 'Begin installing plugins', 'rehub-theme' ),
  1455.             'activate_link'                   => _n_noop( 'Begin activating plugin', 'Begin activating plugins', 'rehub-theme' ),
  1456.             'return'                          => esc_html__( 'Return to Required Plugins Installer and Activate plugins', 'rehub-theme' ),
  1457.             'plugin_activated'                => esc_html__( 'Plugin activated successfully.', 'rehub-theme' ),
  1458.             'complete'                        => esc_html__( 'All plugins installed and activated successfully. %s', 'rehub-theme' ), // %s = dashboard link.
  1459.             'nag_type'                        => 'updated' // Determines admin notice type - can only be 'updated', 'update-nag' or 'error'.
  1460.         )
  1461.     );
  1462.  
  1463.     tgmpa( $plugins, $config );
  1464.  
  1465. }
  1466. }
  1467.  
  1468.  
  1469. // Open Graph + JSON-LD
  1470. function re_add_openschema() {
  1471.  
  1472.     $jsonload = $jsonloadsale = array();
  1473.     if (is_single() && !is_singular('product')) {
  1474.         global $post;      
  1475.  
  1476.         if(vp_metabox('rehub_post.rehub_framework_post_type') == 'review'){
  1477.  
  1478.             if(rehub_option('type_schema_review') == 'user' && rehub_option('type_user_review') == 'full_review'){
  1479.                 $jsonload["@context"] = "http://schema.org/";                  
  1480.                 $usercount = '';
  1481.                 $user_rates = get_post_meta($post->ID, 'post_user_raitings', true);
  1482.                 $user_average = get_post_meta($post->ID, 'post_user_average', true);
  1483.                 if (!empty($user_rates)) {
  1484.                     $usercount = (!empty($user_rates['criteria'][0]['count'])) ? $user_rates['criteria'][0]['count'] : '';
  1485.                 }
  1486.                 if($usercount !=''){
  1487.                     $jsonload["@type"] = "Book";
  1488.                     $jsonload["name"] = $post->post_title;
  1489.                     $jsonload["description"] = $post->post_excerpt;                
  1490.                     $jsonload["aggregateRating"] = array(
  1491.                         "@type" => "AggregateRating",
  1492.                         "worstRating" => "1",
  1493.                         "bestRating" => "10",                  
  1494.                         "ratingValue" => round($user_average, 1),
  1495.                         "reviewCount" => $usercount,
  1496.                     );
  1497.                 }
  1498.             }
  1499.             elseif(rehub_option('type_schema_review') == 'user' && rehub_option('type_user_review') == 'simple'){
  1500.                 $jsonload["@context"] = "http://schema.org/";                  
  1501.                 $jsonload["@type"] = "Book";
  1502.                 $jsonload["name"] = $post->post_title;
  1503.                 $jsonload["description"] = $post->post_excerpt;                    
  1504.                 $rate = get_post_meta($post->ID, 'rehub_user_rate', true );
  1505.                 $count = get_post_meta($post->ID, 'rehub_users_num', true );
  1506.                 $userAverage = (!empty($rate) && !empty($count)) ? (($rate/$count)/5)*10 : 9;
  1507.                 $jsonload["aggregateRating"] = array(
  1508.                     "@type" => "AggregateRating",
  1509.                     "worstRating" => "1",
  1510.                     "bestRating" => "10",                  
  1511.                     "ratingValue" => round($userAverage, 1),
  1512.                     "reviewCount" => $count,
  1513.                 );
  1514.             }              
  1515.             elseif(rehub_option('type_schema_review') != 'none'){
  1516.                
  1517.                 $author_data = get_userdata($post->post_author);
  1518.                 $jsonload["@context"] = "http://schema.org/";
  1519.  
  1520.                 $overal_score = rehub_get_overall_score();
  1521.                 $review_body = (vp_metabox('rehub_post.review_post.0.review_post_summary_text') != '') ? vp_metabox('rehub_post.review_post.0.review_post_summary_text') : $post->post_excerpt;
  1522.                 $review_name = (vp_metabox('rehub_post.review_post.0.review_post_heading') != '') ? vp_metabox('rehub_post.review_post.0.review_post_heading') : $post->post_title;
  1523.                 $jsonload["@type"] = "Review";
  1524.                 $jsonload["name"] = $review_name;
  1525.                 $jsonload["datePublished"] = $post->post_date;
  1526.                 $jsonload["dateModified"] = $post->post_modified;                  
  1527.                 $jsonload["reviewBody"] = $review_body;
  1528.                 $jsonload["reviewRating"] = array(
  1529.                         "@type" => "Rating",
  1530.                         "worstRating" => "1",
  1531.                         "bestRating" => "10",
  1532.                         "ratingValue" => round($overal_score, 1),
  1533.                 );
  1534.                 $jsonload["author"] = array(
  1535.                   "@type" => "Person",
  1536.                   "name" => $author_data->display_name,
  1537.                 );  
  1538.                 $jsonload["itemReviewed"] = array(
  1539.                   "@type" => "Product",
  1540.                   "name" => $post->post_title,
  1541.                 );
  1542.  
  1543.                 $organization = rehub_option('rehub_org_name_review');
  1544.                 $logo = rehub_option('rehub_logo');
  1545.                 $logo_width = rehub_option('rehub_logo_retina_width');
  1546.                 $logo_height = rehub_option('rehub_logo_retina_height');
  1547.                 if ($organization ){
  1548.                     $jsonload["publisher"] = array(
  1549.                         "@type" => "Organization",
  1550.                         "name" => esc_html($organization),
  1551.                     );
  1552.                
  1553.                     if ($logo_width && $logo_height && $logo){
  1554.                         $jsonload["publisher"]["logo"] = array(
  1555.                             "@type" => "ImageObject",
  1556.                             "url" => esc_url($logo),
  1557.                             "height" => esc_html($logo_height),
  1558.                             "width" => esc_html($logo_width),          
  1559.                         );
  1560.                     }
  1561.                 }                  
  1562.  
  1563.             }
  1564.         }          
  1565.     }
  1566.  
  1567.     $using_jetpack_publicize = ( class_exists( 'Jetpack' ) && in_array( 'publicize', Jetpack::get_active_modules()) ) ? true : false;
  1568.     if ( !defined('WPSEO_VERSION') && !class_exists('NY_OG_Admin') && $using_jetpack_publicize == false) {
  1569.         echo '<meta property="og:site_name" content="'. get_bloginfo('name') .'"/>'; // Sets the site name to the one in your WordPress settings
  1570.         echo '<meta property="og:url" content="' . get_permalink() . '"/>'; // Gets the permalink to the post/page
  1571.  
  1572.         if (is_singular()) { // If we are on a blog post/page
  1573.             global $post;
  1574.             echo '<meta property="og:title" content="' . esc_html(get_the_title()) . '"/>'; // Gets the page title
  1575.             echo '<meta property="og:type" content="article"/>'; // Sets the content type to be article.
  1576.             if(has_post_thumbnail( get_the_ID() )) { // If the post has a featured image.
  1577.                 $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
  1578.                 if (!empty($thumbnail[1])){
  1579.                     echo '<meta property="og:image" content="' . $thumbnail[0] . '"/>';
  1580.                     echo '<meta property="og:image:width" content="'.$thumbnail[1].'" />';
  1581.                     echo '<meta property="og:image:height" content="'.$thumbnail[2].'" />';
  1582.                 }
  1583.             }          
  1584.         } elseif(is_front_page() or is_home()) { // If it is the front page or home page
  1585.             echo '<meta property="og:title" content="' . get_bloginfo('name') . '"/>'; // Get the site title
  1586.             echo '<meta property="og:type" content="website"/>'; // Sets the content type to be website.
  1587.         }
  1588.     }
  1589.     if(function_exists('bp_get_profile_field_data')){
  1590.         if(bp_is_user()){
  1591.             global $bp;
  1592.             $bpuserid = $bp->displayed_user->id;
  1593.             $seo_user_description = '';
  1594.             $profile_description = rehub_option('rh_bp_seo_description');
  1595.             $profile_phone = rehub_option('rh_bp_phone');          
  1596.             $bpuserrating = get_user_meta( $bpuserid, 'rh_bp_user_rating', true);
  1597.             $bpuserratingcount = get_user_meta( $bpuserid, 'rh_total_bp_user_rating_num', true);
  1598.             $image = bp_attachments_get_attachment('url', array('object_dir' => 'members','item_id' => $bpuserid) );           
  1599.             if ($profile_description){
  1600.                 $seo_user_description = bp_get_profile_field_data('field='.$profile_description.'&user_id='.$bpuserid);
  1601.             }
  1602.             if ($profile_phone){
  1603.                 $phone = bp_get_profile_field_data('field='.$profile_phone.'&user_id='.$bpuserid);
  1604.             }          
  1605.             if(!$seo_user_description){
  1606.                 $seo_user_description = get_bloginfo('description');
  1607.             }
  1608.             $seo_user_description = apply_filters('rh_bp_user_seo_description', $seo_user_description);
  1609.             echo '<meta name="description" content="'.kama_excerpt('maxchar=220&echo=false&text='.$seo_user_description).'" />';
  1610.             $thumbnail = bp_get_displayed_user_avatar('type=full&html=false');
  1611.             if (!empty($thumbnail)){
  1612.                 echo '<meta property="og:image" content="' . $thumbnail . '"/>';
  1613.                 echo '<meta property="og:image:width" content="300" />';
  1614.                 echo '<meta property="og:image:height" content="300" />';
  1615.             }          
  1616.         }
  1617.     }  
  1618.  
  1619.     if(!empty($jsonload)){
  1620.         echo '<script type="application/ld+json">'.json_encode($jsonload).'</script>';
  1621.     }
  1622. }
  1623.  
  1624. add_action( 'wp_head', 're_add_openschema', 5 );
  1625.  
  1626. //VC init
  1627. if (class_exists('WPBakeryVisualComposerAbstract')) {
  1628.     if(!function_exists('add_rehub_to_vc')) {
  1629.         function add_rehub_to_vc(){
  1630.             require_once ( 'functions/vc_functions.php');
  1631.         }
  1632.     }
  1633.     if(!function_exists('rehub_vc_styles')) {
  1634.         function rehub_vc_styles() {
  1635.             wp_enqueue_style('rehub_vc', get_template_directory_uri() .'/functions/vc/vc.css', array(), time(), 'all');
  1636.         }
  1637.     }
  1638.     function rhVCSetAsTheme() {
  1639.         vc_set_as_theme();
  1640.     }
  1641.  
  1642.     add_action( 'vc_before_init', 'rhVCSetAsTheme' );      
  1643.     add_action('init','add_rehub_to_vc', 5);
  1644.     add_action('admin_enqueue_scripts', 'rehub_vc_styles');
  1645. }
  1646.  
  1647. //Elementor Init
  1648.  
  1649. if ( did_action( 'elementor/loaded' ) ) {
  1650. require_once ('functions/el_functions.php');
  1651. require_once ('rehub-elementor/templates/remote.php');
  1652. }
  1653.  
  1654. /*function rehub_admin_error_notice() {
  1655.     $page = (isset($_GET['page'])) ? $_GET['page'] : '';
  1656.     global $current_user ;
  1657.     $user_id = $current_user->ID;  
  1658.     if ( ! get_user_meta($user_id, 'ignore_notices_rehub90') ) {
  1659.         if ($page=='rehub' || $page=='rehub-support' || $page=='rehub-plugins' || $page=='rehub-demos' || $page=='vpt_option' ) {
  1660.             $class = "error";
  1661.             $message = 'This is major update of theme. All sites will be affected by changed code. Please read important information <a href="http://rehubdocs.wpsoul.com/docs/rehub-theme/for-developers/critical-9-0-update/" target="_blank">Rehub 9.0 version</a> which can affect your site.' ;
  1662.             echo"<div class=\"$class\" style=\"display:block !important\"> <p>$message <a href=\"?rehub_nag_ignore=0\">Hide Notice</a></p></div>";
  1663.         }
  1664.     }
  1665. }
  1666. add_action( 'admin_notices', 'rehub_admin_error_notice' ); 
  1667.  
  1668. add_action('admin_init', 'rehub_nag_ignore');
  1669. function rehub_nag_ignore() {
  1670.     global $current_user;
  1671.     $user_id = $current_user->ID;
  1672.     if ( isset($_GET['rehub_nag_ignore']) && '0' == $_GET['rehub_nag_ignore'] ) {
  1673.         add_user_meta($user_id, 'ignore_notices_rehub90', 'true', true);          
  1674.     }
  1675. }*/
  1676.  
  1677.  
  1678.  
  1679. /**
  1680.  * Register the 'Custom Column' column in the importer.
  1681.  * https://wordpress.org/plugins/woocommerce-unit-of-measure/ meta:_woo_uom_input
  1682.  * https://www.cloudways.com/blog/add-product-information-in-woocommerce/ meta: unit
  1683.  * @param array $options
  1684.  * @return array $options
  1685.  */
  1686. function add_column_to_importer( $options ) {
  1687.  
  1688.     // column slug => column name
  1689.     $options['unit'] = 'Isi Unit'; 
  1690.     $options['_woo_uom_input'] = 'Satuan Jual';
  1691.     $options['harganormalpcs'] = 'Harga Normal (pcs)'; 
  1692.     $options['harganormallsn'] = 'Harga Normal (lsn)';
  1693.  
  1694.     $options['hargahemat_grosirmarket_pcs'] = 'Harga Hemat GrosirMarket (pcs)';
  1695.     $options['hargahemat_grosirmarket_lsn'] = 'Harga Hemat GrosirMarket (lsn)';
  1696.  
  1697.  
  1698.     $options['hargatermurah_grosirmarket_pcs'] = 'Harga Termurah GrosirMarket (pcs)';  
  1699.     $options['hargatermurah_grosirmarket_lsn'] = 'Harga Termurah GrosirMarket (lsn)';
  1700.  
  1701.     // tier 2 wholesale dokan ^
  1702.  
  1703.  
  1704.     $options['_discount_status'] = 'Wholesale Type';
  1705.  
  1706.     $options['hargatermurah_grosirmarket_minimal'] = 'Minimal Qty Harga Termurah';
  1707.     $options['_lot_discount_quantity'] = 'lot discount quantity 1';
  1708.     $options['_lot_discount_quantity_two'] = 'lot discount quantity 2';
  1709.  
  1710.     $options['_is_lot_discount'] = 'enable lot discount';
  1711.  
  1712.  
  1713.  
  1714.  
  1715.     return $options;
  1716. }
  1717. add_filter( 'woocommerce_csv_product_import_mapping_options', 'add_column_to_importer' );
  1718.  
  1719. /**
  1720.  * Add automatic mapping support for 'Custom Column'.
  1721.  * This will automatically select the correct mapping for columns named 'Custom Column' or 'custom column'.
  1722.  *
  1723.  * @param array $columns
  1724.  * @return array $columns
  1725.  */
  1726. function add_column_to_mapping_screen( $columns ) {
  1727.    
  1728.     // potential column name => column slug
  1729.     $columns['Isi Unit'] = 'unit'; 
  1730.     $columns['Satuan Jual'] = '_woo_uom_input';
  1731.     $columns['Harga Normal (pcs)'] = 'harganormalpcs'; 
  1732.     $columns['Harga Normal (lsn)'] = 'harganormallsn';
  1733.  
  1734.     $columns['Harga Hemat GrosirMarket (pcs)'] = 'hargahemat_grosirmarket_pcs';
  1735.     $columns['Harga Hemat GrosirMarket (lsn)'] = 'hargahemat_grosirmarket_lsn';
  1736.  
  1737.  
  1738.     $columns['Harga Termurah GrosirMarket (pcs)'] = 'hargatermurah_grosirmarket_pcs';  
  1739.     $columns['Harga Termurah GrosirMarket (lsn)'] = 'hargatermurah_grosirmarket_lsn';
  1740.  
  1741.  
  1742.     $columns['Wholesale Type'] = '_discount_status';
  1743.  
  1744.     $columns['Minimal Qty Harga Termurah'] = 'hargatermurah_grosirmarket_minimal';
  1745.  
  1746.     $columns['lot discount quantity 1'] = '_lot_discount_quantity';
  1747.     $columns['lot discount quantity 2'] = '_lot_discount_quantity_two';
  1748.     $columns['enable lot discount'] = '_is_lot_discount';
  1749.  
  1750.  
  1751.     return $columns;
  1752. }
  1753. add_filter( 'woocommerce_csv_product_import_mapping_default_columns', 'add_column_to_mapping_screen' );
  1754.  
  1755. /**
  1756.  * Process the data read from the CSV file.
  1757.  * This just saves the value in meta data, but you can do anything you want here with the data.
  1758.  *
  1759.  * @param WC_Product $object - Product being imported or updated.
  1760.  * @param array $data - CSV data read for the product.
  1761.  * @return WC_Product $object
  1762.  */
  1763. function process_import( $object, $data ) {
  1764.    
  1765.     if ( ! empty( $data['unit'] ) ) {
  1766.         $object->update_meta_data( 'unit', $data['unit'] );
  1767.     }
  1768.  
  1769.     if ( ! empty( $data['_woo_uom_input'] ) ) {
  1770.         $object->update_meta_data( '_woo_uom_input', $data['_woo_uom_input'] );
  1771.     }
  1772.  
  1773.  
  1774.     if ( ! empty( $data['harganormalpcs'] ) ) {
  1775.         $object->update_meta_data( 'harganormalpcs', $data['harganormalpcs'] );
  1776.     }
  1777.  
  1778.     if ( ! empty( $data['harganormallsn'] ) ) {
  1779.         $object->update_meta_data( 'harganormallsn', $data['harganormallsn'] );
  1780.     }
  1781.  
  1782.  
  1783.     if ( ! empty( $data['hargahemat_grosirmarket_pcs'] ) ) {
  1784.         $object->update_meta_data( 'hargahemat_grosirmarket_pcs', $data['hargahemat_grosirmarket_pcs'] );
  1785.     }
  1786.  
  1787.     if ( ! empty( $data['hargahemat_grosirmarket_lsn'] ) ) {
  1788.         $object->update_meta_data( 'hargahemat_grosirmarket_lsn', $data['hargahemat_grosirmarket_lsn'] );
  1789.     }
  1790.  
  1791.     if ( ! empty( $data['hargatermurah_grosirmarket_pcs'] ) ) {
  1792.         $object->update_meta_data( 'hargatermurah_grosirmarket_pcs', $data['hargatermurah_grosirmarket_pcs'] );
  1793.     }
  1794.  
  1795.    
  1796.     if ( ! empty( $data['hargatermurah_grosirmarket_lsn'] ) ) {
  1797.         $object->update_meta_data( 'hargatermurah_grosirmarket_lsn', $data['hargatermurah_grosirmarket_lsn'] );
  1798.     }
  1799.  
  1800. // Testing
  1801.  
  1802.  
  1803.     if ( ! empty( $data['_woo_uom_input'] ) ) {
  1804.         $object->update_meta_data( 'grosir_unit', $data['_woo_uom_input'] );
  1805.     }
  1806.  
  1807.     if ( ! empty( $data['hargatermurah_grosirmarket_lsn'] ) ) {
  1808.         $object->update_meta_data( '_lot_discount_amount_two', $data['hargatermurah_grosirmarket_lsn'] );
  1809.     }
  1810.  
  1811.         if ( ! empty( $data['hargahemat_grosirmarket_lsn'] ) ) {
  1812.         $object->update_meta_data( '_lot_discount_amount', $data['hargahemat_grosirmarket_lsn'] );
  1813.     }
  1814.  
  1815.  
  1816. // Testing
  1817.  
  1818.  
  1819.     if ( ! empty( $data['_discount_status'] ) ) {
  1820.         $object->update_meta_data( '_discount_status', $data['_discount_status'] );
  1821.     }
  1822.  
  1823.     if ( ! empty( $data['_discount_status'] ) ) {
  1824.         $object->update_meta_data( '_discount_status_two', $data['_discount_status'] );
  1825.     }
  1826.  
  1827.     if ( ! empty( $data['_discount_status'] ) ) {
  1828.         $object->update_meta_data( '_discount_status_three', $data['_discount_status'] );
  1829.     }
  1830.  
  1831.  
  1832.     if ( ! empty( $data['_lot_discount_quantity'] ) ) {
  1833.         $object->update_meta_data( '_lot_discount_quantity', $data['_lot_discount_quantity'] );
  1834.     }
  1835.  
  1836.     if ( ! empty( $data['_lot_discount_quantity_two'] ) ) {
  1837.         $object->update_meta_data( '_lot_discount_quantity_two', $data['_lot_discount_quantity_two'] );
  1838.     }
  1839.  
  1840.         if ( ! empty( $data['_is_lot_discount'] ) ) {
  1841.         $object->update_meta_data( '_is_lot_discount', $data['_is_lot_discount'] );
  1842.     }
  1843.  
  1844.     if ( ! empty( $data['hargatermurah_grosirmarket_minimal'] ) ) {
  1845.         $object->update_meta_data( 'hargatermurah_grosirmarket_minimal', $data['hargatermurah_grosirmarket_minimal'] );
  1846.     }
  1847.  
  1848.     return $object;
  1849. }
  1850. add_filter( 'woocommerce_product_import_pre_insert_product_object', 'process_import', 10, 2 );
  1851.  
  1852.  
  1853. /**
  1854.  * Plugin Name: Extra Product Info
  1855.  * Plugin URI: https://www.cloudways.com/blog/add-product-information-in-woocommerce/
  1856.  * Description: Add extra info for pharmacy products
  1857.  * Author: Your name
  1858.  * Author URI: http:// domain.com
  1859.  * Version: 1.0
  1860.  */
  1861.  
  1862. add_filter( 'rwmb_meta_boxes', 'pharmacy_meta_boxes' );
  1863. function pharmacy_meta_boxes( $meta_boxes )
  1864. {
  1865.     $meta_boxes[] = array(
  1866.         'title'      => __( 'Simulasi Grosir Pricing Grosirmarket.com', 'pharmacy' ),
  1867.         'post_types' => 'product',
  1868.         'fields'     => array(
  1869.             array(
  1870.                 'id'       => 'unit',
  1871.                 'name'     => __( 'Isi Unit', 'pharmacy' ),
  1872.                 'type'     => 'text',
  1873.             ),
  1874.             array(
  1875.                 'id'   => 'harganormalpcs',
  1876.                 'name' => __( 'Harga Pasaran (pcs)', 'pharmacy' ),
  1877.                 'type' => 'text',
  1878.             ),
  1879.             array(
  1880.                 'id'       => 'harganormallsn',
  1881.                 'name'     => __( 'Harga Pasaran (lsn)', 'pharmacy' ),
  1882.                 'type'     => 'text',
  1883.             ),
  1884.  
  1885.             array(
  1886.                 'id'   => 'hargahemat_grosirmarket_pcs',
  1887.                 'name' => __( 'Harga Hemat GrosirMarket (pcs)', 'pharmacy' ),
  1888.                 'type' => 'text',
  1889.             ),
  1890.             array(
  1891.                 'id'   => 'hargahemat_grosirmarket_lsn',
  1892.                 'name' => __( 'Harga Hemat GrosirMarket (lsn)', 'pharmacy' ),
  1893.                 'type' => 'text',
  1894.             ),
  1895.  
  1896.             array(
  1897.                 'id'   => 'hargatermurah_grosirmarket_pcs',
  1898.                 'name' => __( 'Harga Termurah GrosirMarket (pcs)', 'pharmacy' ),
  1899.                 'type' => 'text',
  1900.             ),
  1901.             array(
  1902.                 'id'   => 'hargatermurah_grosirmarket_lsn',
  1903.                 'name' => __( 'Harga Termurah GrosirMarket (lsn)', 'pharmacy' ),
  1904.                 'type' => 'text',
  1905.             ),
  1906.  
  1907.             array(
  1908.                 'id'   => 'hargatermurah_grosirmarket_minimal',
  1909.                 'name' => __( 'Minimal Details', 'pharmacy' ),
  1910.                 'type' => 'text',
  1911.             ),
  1912.  
  1913.  
  1914.             array(
  1915.                 'id'   => 'grosir_unit',
  1916.                 'name' => __( 'Grosir Unit ', 'pharmacy' ),
  1917.                 'type' => 'text',
  1918.             ),
  1919.  
  1920.  
  1921.         ),
  1922.     );
  1923.     return $meta_boxes;
  1924. }
  1925.  
  1926. add_action( 'woocommerce_single_product_summary', 'pharmacy_extra_info' );
  1927. function pharmacy_extra_info()
  1928. {
  1929.     if ( $meta = rwmb_meta( 'unit' ) )
  1930.     {
  1931.         echo '' . __( 'Isi:', 'pharmacy' ) . "<strong> $meta</strong><br><br>";
  1932.     }
  1933.  
  1934. /** Harga Normal Pasar */
  1935.  
  1936.     if ( $meta = rwmb_meta( 'harganormallsn' ) )
  1937.     {
  1938.         echo ' <strong>Harga Jual Pasar</strong><br>' . __( ' ', 'pharmacy' ) . "<strong><span class=rehub-wooprice-color>Rp $meta </span></strong>";
  1939.     }
  1940.  
  1941.     if ( $meta = rwmb_meta( 'grosir_unit' ) )   {
  1942.         echo '' . __( '', 'pharmacy' ) . "<strong><span class=rehub-wooprice-color>/$meta</span></strong>";
  1943.     }
  1944.  
  1945.     if ( $meta = rwmb_meta( 'harganormalpcs' ) )
  1946.     {
  1947.         echo ' ' . __( ' ', 'pharmacy' ) . "(Rp $meta/Pcs)<br><br>";
  1948.     }
  1949.  
  1950.  
  1951. /** Harga Hemat https://grosirmarket.com */
  1952.  
  1953.  
  1954.  
  1955.     if ( $meta = rwmb_meta( 'hargahemat_grosirmarket_lsn' ) )
  1956.     {
  1957.         echo ' <strong>Harga GrosirMarket.com</strong><br>' . __( ' ', 'pharmacy' ) . "<strong><span class=rehub-wooprice-color>Rp $meta </span></strong>";
  1958.     }
  1959.  
  1960.     if ( $meta = rwmb_meta( 'grosir_unit' ) )   {
  1961.         echo '' . __( '', 'pharmacy' ) . "<strong><span class=rehub-wooprice-color>/$meta</span></strong>";
  1962.     }
  1963.  
  1964.     if ( $meta = rwmb_meta( 'hargahemat_grosirmarket_pcs' ) )
  1965.     {
  1966.         echo ' ' . __( ' ', 'pharmacy' ) . "(Rp $meta/Pcs)<br><br>";
  1967.     }
  1968.  
  1969.  
  1970. /** Harga  Termurah https://grosirmarket.com */
  1971.  
  1972.  
  1973.     if ( $meta = rwmb_meta( 'hargatermurah_grosirmarket_lsn' ) )
  1974.     {
  1975.         echo ' <strong>Harga Termurah GrosirMarket.com</strong><br>' . __( ' ', 'pharmacy' ) . "<strong><span class=rehub-wooprice-color>Rp $meta </span></strong>";
  1976.     }
  1977.  
  1978.     if ( $meta = rwmb_meta( 'grosir_unit' ) )   {
  1979.         echo '' . __( '', 'pharmacy' ) . "<strong><span class=rehub-wooprice-color>/$meta</span></strong>";
  1980.     }
  1981.  
  1982.     if ( $meta = rwmb_meta( 'hargatermurah_grosirmarket_pcs' ) )
  1983.     {
  1984.         echo ' ' . __( ' ', 'pharmacy' ) . "(Rp $meta/Pcs)<br>";
  1985.     }
  1986.  
  1987.     if ( $meta = rwmb_meta( 'hargatermurah_grosirmarket_minimal' ) )
  1988.     {
  1989.         echo ' ' . __( 'Minimal: ', 'pharmacy' ) . "<strong><span class=rehub-wooprice-color> $meta</span></strong><br><br>";
  1990.     }
  1991.  
  1992. }
  1993.  
  1994.  
  1995. /**
  1996.  * Plugin Name: Extra Wholesale Product Info Dokan
  1997.  * Plugin URI: Dewi
  1998.  * Description: Add extra info for Wholesale Pricing Dokan
  1999.  * Version: 1.0
  2000.  */
  2001.  
  2002. add_filter( 'rwmb_meta_boxes', 'wholesale_meta_boxes' );
  2003. function wholesale_meta_boxes( $meta_boxes )
  2004. {
  2005.     $meta_boxes[] = array(
  2006.         'title'      => __( 'Wholesale Pricing Dokan', 'wholesale' ),
  2007.         'post_types' => 'product',
  2008.         'fields'     => array(
  2009.             array(
  2010.                 'id'       => '_is_lot_discount',
  2011.                 'name'     => __( 'Enable Bulk Discount', 'wholesale' ),
  2012.                 'type'     => 'checkbox',
  2013.                 'type'    => 'select',
  2014.                 'options'       => array(
  2015.                     'yes'       => 'Enable',
  2016.                     'no'        => 'Disable',
  2017.                 ),
  2018.             ),
  2019.             array(
  2020.             'id'        => '_discount_status',
  2021.             'name'   => __( 'Type', 'wholesale' ),
  2022.             'type'    => 'select',
  2023.             'options'         => array(
  2024.                 'fixed'       => 'Fixed Price',
  2025.                 'percentage' => 'Percentage Discount',
  2026.             ),
  2027.             'placeholder'     => 'Select an Item',
  2028.             ),
  2029.             array(
  2030.                 'id'       => '_lot_discount_quantity',
  2031.                 'name'     => __( 'Minimum Quantity Tier 1', 'wholesale' ),
  2032.                 'type'     => 'number',
  2033.             ),
  2034.             array(
  2035.                 'id'   => '_lot_discount_amount',
  2036.                 'name' => __( 'Amount Tier 1', 'wholesale' ),
  2037.                 'type' => 'number',
  2038.             ),
  2039.             array(
  2040.                 'id'   => '_lot_discount_quantity_two',
  2041.                 'name' => __( 'Minimum Qty Tier 2', 'wholesale' ),
  2042.                 'type' => 'number',
  2043.             ),
  2044.             array(
  2045.                 'id'   => '_lot_discount_amount_two',
  2046.                 'name' => __( 'Amount Tier 2', 'wholesale' ),
  2047.                 'type' => 'number',
  2048.             ),
  2049.             array(
  2050.                 'id'   => '_lot_discount_quantity_three',
  2051.                 'name' => __( 'Minimum Qty Tier 3', 'wholesale' ),
  2052.                 'type' => 'number',
  2053.             ),
  2054.             array(
  2055.                 'id'   => '_lot_discount_amount_three',
  2056.                 'name' => __( 'Amount Tier 3', 'wholesale' ),
  2057.                 'type' => 'number',
  2058.             ),
  2059.         ),
  2060.     );
  2061.     return $meta_boxes;
  2062. }
  2063.  
  2064.  
  2065. /**
  2066.  * Plugin Name: Change Add to cart text
  2067.  */
  2068.  
  2069. add_filter( 'add_to_cart_text', 'woo_custom_single_add_to_cart_text' );                // < 2.1
  2070. add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_single_add_to_cart_text' );  // 2.1 +
  2071.  
  2072. function woo_custom_single_add_to_cart_text() {
  2073.  
  2074.     return __( 'Beli Sekarang', 'woocommerce' );
  2075.  
  2076. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement