Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2016
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 152.18 KB | None | 0 0
  1. <?php
  2. /**
  3.  * @package WordPress
  4.  * @subpackage SnapShopWP Theme
  5.  * @author Shindiri Studio (http://www.shindiristudio.com) & http://www.mihajlovicnenad.com/
  6.  */
  7.  
  8. /**
  9.  * Acive Plugins
  10.  */
  11. define( "SNPSHPWP_MULTISITE", ( is_multisite() ? true : false ) );
  12. $using_woo = false;
  13. if ( SNPSHPWP_MULTISITE === true ) {
  14.     if ( array_key_exists( 'woocommerce/woocommerce.php', maybe_unserialize( get_site_option( 'active_sitewide_plugins') ) ) ) {
  15.         $using_woo = true;
  16.     }
  17.     elseif ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ? 'active' : '' ) {
  18.         $using_woo = true;
  19.     }
  20. }
  21. elseif ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ? 'active' : '' ) {
  22.     $using_woo = true;
  23. }
  24. define( "SNPSHPWP_WOOCOMMERCE", $using_woo );
  25.  
  26. $using_fbuilder = false;
  27. if ( SNPSHPWP_MULTISITE === true ) {
  28.     if ( array_key_exists( 'frontend_builder/frontend_builder.php', maybe_unserialize( get_site_option( 'active_sitewide_plugins') ) ) ) {
  29.         $using_fbuilder = true;
  30.     }
  31.     elseif ( in_array( 'frontend_builder/frontend_builder.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ? 'active' : '' ) {
  32.         $using_fbuilder = true;
  33.     }
  34. }
  35. elseif ( in_array( 'frontend_builder/frontend_builder.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ? 'active' : '' ) {
  36.     $using_fbuilder = true;
  37. }
  38. define( "SNPSHPWP_FBUILDER", $using_fbuilder );
  39.  
  40. $using_revslider = false;
  41. if ( SNPSHPWP_MULTISITE === true ) {
  42.     if ( array_key_exists( 'revslider/revslider.php', maybe_unserialize( get_site_option( 'active_sitewide_plugins') ) ) ) {
  43.         $using_revslider = true;
  44.     }
  45.     elseif ( in_array( 'revslider/revslider.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ? 'active' : '' ) {
  46.         $using_revslider = true;
  47.     }
  48. }
  49. elseif ( in_array( 'revslider/revslider.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ? 'active' : '' ) {
  50.     $using_revslider = true;
  51. }
  52. define( "SNPSHPWP_REVSLIDER", $using_revslider );
  53.  
  54. $using_prdctfltr = false;
  55. if ( SNPSHPWP_MULTISITE === true ) {
  56.     if ( array_key_exists( 'prdctfltr/prdctfltr.php', maybe_unserialize( get_site_option( 'active_sitewide_plugins') ) ) ) {
  57.         $using_prdctfltr = true;
  58.     }
  59.     elseif ( in_array( 'prdctfltr/prdctfltr.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ? 'active' : '' ) {
  60.         $using_prdctfltr = true;
  61.     }
  62. }
  63. elseif ( in_array( 'prdctfltr/prdctfltr.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ? 'active' : '' ) {
  64.     $using_prdctfltr = true;
  65. }
  66. define( "SNPSHPWP_PRDCTFLTR", $using_prdctfltr );
  67.  
  68. $using_chimp = false;
  69. if ( SNPSHPWP_MULTISITE === true ) {
  70.     if ( array_key_exists( 'mailchimp-for-wp/mailchimp-for-wp.php', maybe_unserialize( get_site_option( 'active_sitewide_plugins') ) ) ) {
  71.         $using_chimp = true;
  72.     }
  73.     elseif ( in_array( 'mailchimp-for-wp/mailchimp-for-wp.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ? 'active' : '' ) {
  74.         $using_chimp = true;
  75.     }
  76. }
  77. elseif ( in_array( 'mailchimp-for-wp/mailchimp-for-wp.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ? 'active' : '' ) {
  78.     $using_chimp = true;
  79. }
  80. define( "SNPSHPWP_MAILCHIMP", $using_chimp );
  81.  
  82. $using_fbuilder_commerce = false;
  83. if ( SNPSHPWP_MULTISITE === true ) {
  84.     if ( array_key_exists( 'frontend_builder_commerce/frontend_builder_commerce.php', maybe_unserialize( get_site_option( 'active_sitewide_plugins') ) ) ) {
  85.         $using_fbuilder_commerce = true;
  86.     }
  87.     elseif ( in_array( 'frontend_builder_commerce/frontend_builder_commerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ? 'active' : '' ) {
  88.         $using_fbuilder_commerce = true;
  89.     }
  90. }
  91. elseif ( in_array( 'frontend_builder_commerce/frontend_builder_commerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ? 'active' : '' ) {
  92.     $using_fbuilder_commerce = true;
  93. }
  94. define( "SNPSHPWP_FBUILDER_COMMERCE", $using_fbuilder_commerce );
  95.  
  96.  
  97. /**
  98.  * Slightly Modified Options Framework
  99.  */
  100. require_once ('admin/index.php');
  101.  
  102. /*
  103.  * After Setup SnapShopWP Theme
  104. */
  105. if ( !function_exists('snpshpwp_setup_theme') ) :
  106. function snpshpwp_setup_theme() {
  107.     global $snpshpwp_data;
  108.  
  109.     load_theme_textdomain( 'snpshpwp', get_template_directory() . '/languages' );
  110.  
  111.     add_theme_support( 'automatic-feed-links' );
  112.  
  113.     add_theme_support( 'post-thumbnails' );
  114.  
  115.     $feat_width = ( isset($snpshpwp_data['fimage_width']) ? $snpshpwp_data['fimage_width'] : 960 );
  116.     $feat_height = ( isset($snpshpwp_data['fimage_height']) ? $snpshpwp_data['fimage_height'] : 400 );
  117.     add_image_size( 'snpshpwp-fullblog', $feat_width, $feat_height, true );
  118.  
  119.     $feat_width = ( isset($snpshpwp_data['single_fimage_width']) ? $snpshpwp_data['single_fimage_width'] : 1200 );
  120.     $feat_height = ( isset($snpshpwp_data['single_fimage_height']) ? $snpshpwp_data['single_fimage_height'] : 400 );
  121.     add_image_size( 'snpshpwp-fullsingle', $feat_width, $feat_height, true );
  122.  
  123.     add_image_size( 'snpshpwp-square', 200, 200, true );
  124.  
  125.     add_theme_support( 'custom-background');
  126.  
  127.     // Add support for Post Formats
  128.     add_theme_support( 'post-formats', array( 'audio', 'gallery', 'link', 'video', 'image', 'quote' ) );
  129.  
  130.     // Adds editor style
  131.     add_editor_style();
  132. }
  133. endif;
  134. add_action( 'after_setup_theme', 'snpshpwp_setup_theme' );
  135.  
  136.  
  137. /**
  138.  * Includes
  139.  */
  140. if ( SNPSHPWP_FBUILDER === true ) { include_once ('shortcodes.php'); }
  141. require_once ('lib/wp-less/lessc.inc.php');
  142. require_once ('lib/wp-less/wp-less.php');
  143. include_once ('lib/twitteroauth/twitteroauth.php');
  144. include_once ('lib/hybridcore/hybridcore-breadcrumb-trail.php');
  145. if ( is_admin() ) {
  146.     include_once ('lib/snpshpwp-menu/snpshpwp-menu.php');
  147.     require_once ('lib/tgm-plugin-activation/class-tgm-plugin-activation.php');
  148. }
  149.  
  150. /**
  151.  * TGM Plugin Activation
  152.  */
  153.  
  154. if ( !function_exists('snpshpwp_register_required_plugins') ) :
  155. function snpshpwp_register_required_plugins() {
  156.  
  157.     $plugins = array(
  158.         array(
  159.             'name'                  => 'Frontend Builder',
  160.             'slug'                  => 'frontend_builder',
  161.             'source'                => get_template_directory() . '/lib/plugins/frontend_builder.zip',
  162.             'required'              => true,
  163.             'version'               => '2.7.1',
  164.             'force_activation'      => false,
  165.             'force_deactivation'    => false,
  166.             'external_url'          => 'http://codecanyon.net/item/frontend-builder-wordpress-content-assembler?ref=br0'
  167.         ),
  168.         array(
  169.             'name'                  => 'Revolution Slider',
  170.             'slug'                  => 'revslider',
  171.             'source'                => get_template_directory() . '/lib/plugins/revslider.zip',
  172.             'required'              => false,
  173.             'version'               => '4.5.95',
  174.             'force_activation'      => false,
  175.             'force_deactivation'        => false,
  176.             'external_url'          => 'http://www.themepunch.com/codecanyon/revolution_wp/',
  177.         ),
  178.         array(
  179.             'name'                  => 'Content Timeline',
  180.             'slug'                  => 'content_timeline',
  181.             'source'                => get_template_directory() . '/lib/plugins/content_timeline.zip',
  182.             'required'              => false,
  183.             'version'               => '2.35',
  184.             'force_activation'      => false,
  185.             'force_deactivation'        => false,
  186.             'external_url'          => 'http://www.shindiristudio.com/demo/?item=Content%20Timeline_Wordpress',
  187.         ),
  188.         array(
  189.             'name'                  => 'WooCommerce',
  190.             'slug'                  => 'woocommerce',
  191.             'required'              => false,
  192.             'version'               => '2.1.12'
  193.         ),
  194.         array(
  195.             'name'                  => 'Frontend Builder Commerce',
  196.             'slug'                  => 'frontend_builder_commerce',
  197.             'source'                => get_template_directory() . '/lib/plugins/frontend_builder_commerce.zip',
  198.             'required'              => true,
  199.             'version'               => '1.10',
  200.             'force_activation'      => false,
  201.             'force_deactivation'    => false,
  202.             'external_url'          => '#'
  203.         ),
  204.         array(
  205.             'name'                  => 'WooCommerce Product Filter',
  206.             'slug'                  => 'prdctfltr',
  207.             'source'                => get_template_directory() . '/lib/plugins/woocommerce-product-filter.zip',
  208.             'required'              => true,
  209.             'version'               => '1.2.4',
  210.             'force_activation'      => false,
  211.             'force_deactivation'    => false,
  212.             'external_url'          => 'http://codecanyon.net/item/woocommerce-product-filter/8514038?ref=dzeriho'
  213.         ),
  214.         array(
  215.             'name'                  => 'MailChimp for WordPress Lite',
  216.             'slug'                  => 'mailchimp-for-wp',
  217.             'required'              => false,
  218.             'version'               => '2.1.1'
  219.         )
  220.     );
  221.  
  222.     $theme_text_domain = 'snpshpwp';
  223.  
  224.     $config = array(
  225.         'domain'            => $theme_text_domain,
  226.         'default_path'      => '',
  227.         'parent_menu_slug'  => 'themes.php',
  228.         'parent_url_slug'   => 'themes.php',
  229.         'menu'              => 'install-required-plugins',
  230.         'has_notices'       => true,
  231.         'is_automatic'      => true,
  232.         'message'           => '',
  233.         'strings'   => array(
  234.             'page_title' => __( 'Install Required Plugins', $theme_text_domain ),
  235.             'menu_title' => __( 'Install Plugins', $theme_text_domain ),
  236.             'installing' => __( 'Installing Plugin: %s', $theme_text_domain ), // %1$s = plugin name
  237.             'oops' => __( 'Something went wrong with the plugin API.', $theme_text_domain ),
  238.             'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.' ),
  239.             'notice_can_install_recommended'=> _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.' ),
  240.             '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.' ),
  241.             'notice_can_activate_required'  => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.' ),
  242.             'notice_can_activate_recommended'   => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.' ),
  243.             '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.' ),
  244.             '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.' ),
  245.             '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.' ),
  246.             'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins' ),
  247.             'activate_link' => _n_noop( 'Activate installed plugin', 'Activate installed plugins' ),
  248.             'return'=> __( 'Return to Required Plugins Installer', $theme_text_domain ),
  249.             'plugin_activated' => __( 'Plugin activated successfully.', $theme_text_domain ),
  250.             'complete' => __( 'All plugins installed and activated successfully. %s', $theme_text_domain )
  251.         )
  252.     );
  253.  
  254.     tgmpa( $plugins, $config );
  255.  
  256. }
  257. endif;
  258. add_action( 'tgmpa_register', 'snpshpwp_register_required_plugins' );
  259.  
  260.  
  261. /*
  262.  * Load Scripts
  263. */
  264. if ( !function_exists('snpshpwp_scripts') ) :
  265. function snpshpwp_scripts() {
  266.     global $snpshpwp_data;
  267.    
  268.     if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
  269.         wp_enqueue_script( 'comment-reply' );
  270.  
  271.     wp_enqueue_script( 'jquery' );
  272.     wp_enqueue_script( 'snpshpwp-mdrnzr', get_template_directory_uri() . '/js/modernizer.min.js', array( 'jquery' ), '1.0', false);
  273.     wp_enqueue_script( 'snpshpwp-tween', get_template_directory_uri() . '/js/TweenMax.min.js', array( 'jquery' ), '1.0', true);
  274.     wp_enqueue_script( 'snpshpwp-scrolltoplugin', get_template_directory_uri() . '/js/scrolltoplugin.js', array( 'jquery' ), '1.0', true);
  275.     wp_enqueue_script( 'snpshpwp-swipebox', get_template_directory_uri() . '/js/swipebox/source/jquery.swipebox.min.js', array( 'jquery' ), '1.0', true);
  276.     wp_enqueue_script( 'snpshpwp-idangerous', get_template_directory_uri() . '/js/idangerous.swiper.min.js', array( 'jquery' ), '2.6.1', true);
  277.     wp_enqueue_script( 'snpshpwp-smoothscroll', get_template_directory_uri() . '/js/smoothscroll.js', array( 'jquery' ), '1.0', true);
  278.     wp_enqueue_script( 'snpshpwp-imgsloaded', get_template_directory_uri() . '/js/imagesloaded.js', array( 'jquery' ), '1.0', true);
  279.     wp_enqueue_script( 'snpshpwp-fntsmoothie', get_template_directory_uri() . '/js/fontsmoothie.min.js', array( 'jquery' ), '1.0', true);
  280.     wp_enqueue_script( 'snpshpwp-pjax', get_template_directory_uri() . '/js/jquery.pjax.js', array( 'jquery' ), '1.0', true);
  281.     wp_enqueue_script( 'snpshpwp-classie', get_template_directory_uri() . '/js/classie.js', array( 'jquery' ), '1.0', true);
  282.     wp_enqueue_script( 'snpshpwp-notify', get_template_directory_uri() . '/js/notification.js', array( 'jquery' ), '1.0', true);
  283.     wp_enqueue_script( 'snpshpwp-main-js', get_template_directory_uri() . '/js/main.js', array( 'jquery' ), '1.0', true);
  284.  
  285.  
  286.  
  287.     $entry = 'none';
  288.     $entry_mute = 'none';
  289.     $entry_loop = 'none';
  290.     $entry_hd = 'none';
  291.     $entry_fallback = 'none';
  292.  
  293.     if ( is_page() ) {
  294.         $page_bg = get_post_meta( get_the_ID(), 'snpshpwp_page_bg', true );
  295.         if ( $page_bg !== '' && $page_bg !== 'none' ) {
  296.             switch ($page_bg) :
  297.                 case 'videoembed' :
  298.                     $entry = get_post_meta(get_the_ID(),'snpshpwp_pagevideo_embed',true);
  299.                     $entry_mute = get_post_meta(get_the_ID(),'snpshpwp_pagevideo_embed_mute',true);
  300.                     $entry_loop = get_post_meta(get_the_ID(),'snpshpwp_pagevideo_embed_loop',true);
  301.                     $entry_hd = get_post_meta(get_the_ID(),'snpshpwp_pagevideo_embed_hd',true);
  302.                     $entry_fallback = wp_get_attachment_url( get_post_thumbnail_id(get_the_ID()) );
  303.                 break;
  304.                 case 'html5video' :
  305.                     $entry = 'none';
  306.                     $entry_mute = 'none';
  307.                     $entry_loop = 'none';
  308.                     $entry_hd = 'none';
  309.                     $entry_fallback = 'none';
  310.                 break;
  311.                 default :
  312.                     die( __('Invalid options.', 'snpshpwp') );
  313.             endswitch;
  314.         }
  315.     }
  316.  
  317.     wp_localize_script( 'snpshpwp-main-js', 'snpshpwp', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'siteurl'=> home_url('/'), 'ts_viewmore' => __('VIEW DETAILS', 'snpshpwp') , 'video_bg' => $entry, 'video_mute' => $entry_mute, 'video_loop' => $entry_loop, 'video_hd' => $entry_hd, 'content_width' => intval($snpshpwp_data['fb_mres_w']), 'content_width_mobile' => intval($snpshpwp_data['fb_lres_w']), 'loader' => ( isset($snpshpwp_data['loader_active']) ? $snpshpwp_data['loader_active'] : 0 ) ) );
  318.  
  319. }
  320. endif;
  321. add_action( 'wp_enqueue_scripts', 'snpshpwp_scripts' );
  322.  
  323.  
  324. /*
  325.  * Load Styles
  326. */
  327. if ( !function_exists('snpshpwp_styles_css') ) :
  328. function snpshpwp_styles_css() {
  329.  
  330.     global $snpshpwp_data;
  331.  
  332.     if ( ! isset( $content_width ) )
  333.         $content_width = $snpshpwp_data['content_width'];
  334.  
  335.     wp_enqueue_style( 'snpshpwp-style', get_stylesheet_uri() );
  336.     wp_enqueue_style( 'snpshpwp-less-style', get_stylesheet_directory_uri() . '/less/snapshop.less' );
  337.  
  338.     if ( SNPSHPWP_FBUILDER === false ) {
  339.         wp_enqueue_style( 'snpshpwp-fbuilder', get_template_directory_uri() . '/css/frontend.css' );
  340.     }
  341. }
  342. endif;
  343. add_action( 'wp_enqueue_scripts', 'snpshpwp_styles_css' );
  344.  
  345.  
  346.  
  347. /*
  348.  * LESS CSS
  349. */
  350.  
  351. if ( !function_exists('snpshpwp_less') ) :
  352. function snpshpwp_less( $vars, $handle ) {
  353.     global $snpshpwp_data;
  354.  
  355.     /* header bar vars */
  356.  
  357.     if ( $snpshpwp_data['f_header_bar_mnggl_on'] !== '1' ) {
  358.         $vars['f_header_bar_mn_face'] = $snpshpwp_data['f_header_bar_mn']['face'];
  359.         $vars['f_header_bar_mn_size'] = $snpshpwp_data['f_header_bar_mn']['size'];
  360.         $vars['f_header_bar_mn_style'] = $snpshpwp_data['f_header_bar_mn']['style'];
  361.         $vars['f_header_bar_mn_weight'] = $snpshpwp_data['f_header_bar_mn']['weight'];
  362.     }
  363.     else {
  364.         $vars['f_header_bar_mn_face'] = $snpshpwp_data['f_header_bar_mnggl']['face'];
  365.         $vars['f_header_bar_mn_size'] = $snpshpwp_data['f_header_bar_mnggl']['size'];
  366.         $vars['f_header_bar_mn_style'] = $snpshpwp_data['f_header_bar_mnggl']['style'];
  367.         $vars['f_header_bar_mn_weight'] = $snpshpwp_data['f_header_bar_mnggl']['weight'];
  368.     }
  369.     $vars['header_bar_height'] = ( $snpshpwp_data['header_bar'] !== '1' ? $snpshpwp_data['header_bar_height'].'px' : '0px' );
  370.     $vars['s_header_bar_bg'] = $snpshpwp_data['s_header_bar_bg'];
  371.     $vars['s_header_bar_txt'] = $snpshpwp_data['s_header_bar_txt'];
  372.     $vars['s_header_bar_lnk'] = $snpshpwp_data['s_header_bar_lnk'];
  373.     $vars['s_header_bar_lnkhvr'] = $snpshpwp_data['s_header_bar_lnkhvr'];
  374.     $vars['s_header_bar_brdr'] = $snpshpwp_data['s_header_bar_brdr'];
  375.  
  376.  
  377.     /* header vars */
  378.     $vars['header_custom_height'] = ( $snpshpwp_data['header_custom'] !== '' ? $snpshpwp_data['header_custom_height'].'px' : '0px' );
  379.  
  380.     $vars['header_height'] = $snpshpwp_data['header_height'].'px';
  381.     $vars['header_width'] = $snpshpwp_data['header_width'].'px';
  382.     $vars['header_logo'] = $snpshpwp_data['header_logo'];
  383.     $vars['s_header_ldbr'] = $snpshpwp_data['s_header_ldbr'];
  384.     $vars['s_header_bg'] = $snpshpwp_data['s_header_bg'];
  385.     $vars['s_header_txt'] = $snpshpwp_data['s_header_txt'];
  386.     $vars['s_header_lnk'] = $snpshpwp_data['s_header_lnk'];
  387.     $vars['s_header_lnkhvr'] = $snpshpwp_data['s_header_lnkhvr'];
  388.     $vars['s_header_brdr'] = $snpshpwp_data['s_header_brdr'];
  389.     $vars['s_header_tpbrdr'] = $snpshpwp_data['s_header_tpbrdr'];
  390.     $vars['s_header_drpdwn_bg'] = $snpshpwp_data['s_header_drpdwn_bg'];
  391.     $vars['s_header_drpdwn_lnk'] = $snpshpwp_data['s_header_drpdwn_lnk'];
  392.     $vars['s_header_drpdwn_lnkhvr'] = $snpshpwp_data['s_header_drpdwn_lnkhvr'];
  393.  
  394.  
  395.     if ( $snpshpwp_data['f_header_mnggl_on'] !== '1' ) {
  396.         $vars['f_header_mn_face'] = $snpshpwp_data['f_header_mn']['face'];
  397.         $vars['f_header_mn_size'] = $snpshpwp_data['f_header_mn']['size'];
  398.         $vars['f_header_mn_style'] = $snpshpwp_data['f_header_mn']['style'];
  399.         $vars['f_header_mn_weight'] = $snpshpwp_data['f_header_mn']['weight'];
  400.     }
  401.     else {
  402.         $vars['f_header_mn_face'] = $snpshpwp_data['f_header_mnggl']['face'];
  403.         $vars['f_header_mn_size'] = $snpshpwp_data['f_header_mnggl']['size'];
  404.         $vars['f_header_mn_style'] = $snpshpwp_data['f_header_mnggl']['style'];
  405.         $vars['f_header_mn_weight'] = $snpshpwp_data['f_header_mnggl']['weight'];
  406.     }
  407.  
  408.     if ( $snpshpwp_data['f_header_drpdwnggl_on'] !== '1' ) {
  409.         $vars['f_header_drpdwn_face'] = $snpshpwp_data['f_header_drpdwn']['face'];
  410.         $vars['f_header_drpdwn_size'] = $snpshpwp_data['f_header_drpdwn']['size'];
  411.         $vars['f_header_drpdwn_style'] = $snpshpwp_data['f_header_drpdwn']['style'];
  412.         $vars['f_header_drpdwn_weight'] = $snpshpwp_data['f_header_drpdwn']['weight'];
  413.     }
  414.     else {
  415.         $vars['f_header_drpdwn_face'] = $snpshpwp_data['f_header_drpdwnggl']['face'];
  416.         $vars['f_header_drpdwn_size'] = $snpshpwp_data['f_header_drpdwnggl']['size'];
  417.         $vars['f_header_drpdwn_style'] = $snpshpwp_data['f_header_drpdwnggl']['style'];
  418.         $vars['f_header_drpdwn_weight'] = $snpshpwp_data['f_header_drpdwnggl']['weight'];
  419.     }
  420.  
  421.  
  422.     /* breadcrumbs vars */
  423.     $vars['breadcrumbs_height'] = $snpshpwp_data['breadcrumbs_height'].'px';
  424.  
  425.  
  426.     $vars['s_breadcrumbs_bg'] = $snpshpwp_data['s_breadcrumbs_bg'];
  427.     $vars['s_breadcrumbs_txt'] = $snpshpwp_data['s_breadcrumbs_txt'];
  428.     $vars['s_breadcrumbs_lnk'] = $snpshpwp_data['s_breadcrumbs_lnk'];
  429.     $vars['s_breadcrumbs_lnkhvr'] = $snpshpwp_data['s_breadcrumbs_lnkhvr'];
  430.     $vars['s_breadcrumbs_brdr'] = $snpshpwp_data['s_breadcrumbs_brdr'];
  431.  
  432.  
  433.     if ( $snpshpwp_data['f_breadcrumbs_ggl_on'] !== '1' ) {
  434.         $vars['f_breadcrumbs_face'] = $snpshpwp_data['f_breadcrumbs']['face'];
  435.         $vars['f_breadcrumbs_size'] = $snpshpwp_data['f_breadcrumbs']['size'];
  436.         $vars['f_breadcrumbs_style'] = $snpshpwp_data['f_breadcrumbs']['style'];
  437.         $vars['f_breadcrumbs_weight'] = $snpshpwp_data['f_breadcrumbs']['weight'];
  438.     }
  439.     else {
  440.         $vars['f_breadcrumbs_face'] = $snpshpwp_data['f_breadcrumbs_ggl']['face'];
  441.         $vars['f_breadcrumbs_size'] = $snpshpwp_data['f_breadcrumbs_ggl']['size'];
  442.         $vars['f_breadcrumbs_style'] = $snpshpwp_data['f_breadcrumbs_ggl']['style'];
  443.         $vars['f_breadcrumbs_weight'] = $snpshpwp_data['f_breadcrumbs_ggl']['weight'];
  444.     }
  445.  
  446.  
  447.     /* footer vars */
  448.     $vars['footer_height'] = $snpshpwp_data['footer_height'].'px';
  449.     $vars['footer_width'] = $snpshpwp_data['footer_width'].'px';
  450.     $vars['custom-css-snpshp_limit_width'] = $snpshpwp_data['custom-css-snpshp_limit_width'].'px';
  451.  
  452.     $vars['s_footer_tpbrdr'] = $snpshpwp_data['s_footer_tpbrdr'];
  453.     $vars['s_footer_bg'] = $snpshpwp_data['s_footer_bg'];
  454.     $vars['s_footer_txt'] = $snpshpwp_data['s_footer_txt'];
  455.     $vars['s_footer_hdr'] = $snpshpwp_data['s_footer_hdr'];
  456.     $vars['s_footer_lnk'] = $snpshpwp_data['s_footer_lnk'];
  457.     $vars['s_footer_lnkhvr'] = $snpshpwp_data['s_footer_lnkhvr'];
  458.  
  459.     $vars['s_footer_lmnt_bg'] = $snpshpwp_data['s_footer_lmnt_bg'];
  460.     $vars['s_footer_lmnt_txt'] = $snpshpwp_data['s_footer_lmnt_txt'];
  461.     $vars['s_footer_lmnt_lnk'] = $snpshpwp_data['s_footer_lmnt_lnk'];
  462.     $vars['s_footer_lmnt_lnkhvr'] = $snpshpwp_data['s_footer_lmnt_lnkhvr'];
  463.     $vars['s_footer_lmnt_brdr'] = $snpshpwp_data['s_footer_lmnt_brdr'];
  464.  
  465.     if ( $snpshpwp_data['f_footer_wtggl_on'] !== '1' ) {
  466.         $vars['f_footer_wt_face'] = $snpshpwp_data['f_footer_wt']['face'];
  467.         $vars['f_footer_wt_size'] = $snpshpwp_data['f_footer_wt']['size'];
  468.         $vars['f_footer_wt_style'] = $snpshpwp_data['f_footer_wt']['style'];
  469.         $vars['f_footer_wt_weight'] = $snpshpwp_data['f_footer_wt']['weight'];
  470.     }
  471.     else {
  472.         $vars['f_footer_wt_face'] = $snpshpwp_data['f_footer_wtggl']['face'];
  473.         $vars['f_footer_wt_size'] = $snpshpwp_data['f_footer_wtggl']['size'];
  474.         $vars['f_footer_wt_style'] = $snpshpwp_data['f_footer_wtggl']['style'];
  475.         $vars['f_footer_wt_weight'] = $snpshpwp_data['f_footer_wtggl']['weight'];
  476.     }
  477.  
  478.     if ( $snpshpwp_data['f_footer_wtxtggl_on'] !== '1' ) {
  479.         $vars['f_footer_wtxt_face'] = $snpshpwp_data['f_footer_wtxt']['face'];
  480.         $vars['f_footer_wtxt_size'] = $snpshpwp_data['f_footer_wtxt']['size'];
  481.         $vars['f_footer_wtxt_style'] = $snpshpwp_data['f_footer_wtxt']['style'];
  482.         $vars['f_footer_wtxt_weight'] = $snpshpwp_data['f_footer_wtxt']['weight'];
  483.     }
  484.     else {
  485.         $vars['f_footer_wtxt_face'] = $snpshpwp_data['f_footer_wtxtggl']['face'];
  486.         $vars['f_footer_wtxt_size'] = $snpshpwp_data['f_footer_wtxtggl']['size'];
  487.         $vars['f_footer_wtxt_style'] = $snpshpwp_data['f_footer_wtxtggl']['style'];
  488.         $vars['f_footer_wtxt_weight'] = $snpshpwp_data['f_footer_wtxtggl']['weight'];
  489.     }
  490.  
  491.     if ( $snpshpwp_data['f_footer_fbrggl_on'] !== '1' ) {
  492.         $vars['f_footer_fbr_face'] = $snpshpwp_data['f_footer_fbr']['face'];
  493.         $vars['f_footer_fbr_size'] = $snpshpwp_data['f_footer_fbr']['size'];
  494.         $vars['f_footer_fbr_style'] = $snpshpwp_data['f_footer_fbr']['style'];
  495.         $vars['f_footer_fbr_weight'] = $snpshpwp_data['f_footer_fbr']['weight'];
  496.     }
  497.     else {
  498.         $vars['f_footer_fbr_face'] = $snpshpwp_data['f_footer_fbrggl']['face'];
  499.         $vars['f_footer_fbr_size'] = $snpshpwp_data['f_footer_fbrggl']['size'];
  500.         $vars['f_footer_fbr_style'] = $snpshpwp_data['f_footer_fbrggl']['style'];
  501.         $vars['f_footer_fbr_weight'] = $snpshpwp_data['f_footer_fbrggl']['weight'];
  502.     }
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.     /* pages and posts vars */
  510.  
  511.     $vars['s_post_bg'] = $snpshpwp_data['s_post_bg'];
  512.     $vars['s_post_txt'] = $snpshpwp_data['s_post_txt'];
  513.     $vars['s_post_hdr'] = $snpshpwp_data['s_post_hdr'];
  514.     $vars['s_post_lnk'] = $snpshpwp_data['s_post_lnk'];
  515.     $vars['s_post_lnkhvr'] = $snpshpwp_data['s_post_lnkhvr'];
  516.     $vars['s_post_brdr'] = $snpshpwp_data['s_post_brdr'];
  517.     $vars['s_post_bttn'] = $snpshpwp_data['s_post_bttn'];
  518.     $vars['s_post_bttnhvr'] = $snpshpwp_data['s_post_bttnhvr'];
  519.     $vars['s_post_bttnlnk'] = $snpshpwp_data['s_post_bttnlnk'];
  520.     $vars['s_post_bttnlnkhvr'] = $snpshpwp_data['s_post_bttnlnkhvr'];
  521.  
  522.     if ( $snpshpwp_data['f_post_mnggl_on'] !== '1' ) {
  523.         $vars['f_post_mn_face'] = $snpshpwp_data['f_post_mn']['face'];
  524.         $vars['f_post_mn_size'] = $snpshpwp_data['f_post_mn']['size'];
  525.         $vars['f_post_mn_style'] = $snpshpwp_data['f_post_mn']['style'];
  526.         $vars['f_post_mn_weight'] = $snpshpwp_data['f_post_mn']['weight'];
  527.     }
  528.     else {
  529.         $vars['f_post_mn_face'] = $snpshpwp_data['f_post_mnggl']['face'];
  530.         $vars['f_post_mn_size'] = $snpshpwp_data['f_post_mnggl']['size'];
  531.         $vars['f_post_mn_style'] = $snpshpwp_data['f_post_mnggl']['style'];
  532.         $vars['f_post_mn_weight'] = $snpshpwp_data['f_post_mnggl']['weight'];
  533.     }
  534.  
  535.     if ( $snpshpwp_data['f_post_hdrggl_on'] !== '1' ) {
  536.         $vars['f_post_hdr_face'] = $snpshpwp_data['f_post_hdr']['face'];
  537.         $vars['f_post_hdr_size'] = $snpshpwp_data['f_post_hdr']['size'];
  538.         $vars['f_post_hdr_style'] = $snpshpwp_data['f_post_hdr']['style'];
  539.         $vars['f_post_hdr_weight'] = $snpshpwp_data['f_post_hdr']['weight'];
  540.     }
  541.     else {
  542.         $vars['f_post_hdr_face'] = $snpshpwp_data['f_post_hdrggl']['face'];
  543.         $vars['f_post_hdr_size'] = $snpshpwp_data['f_post_hdrggl']['size'];
  544.         $vars['f_post_hdr_style'] = $snpshpwp_data['f_post_hdrggl']['style'];
  545.         $vars['f_post_hdr_weight'] = $snpshpwp_data['f_post_hdrggl']['weight'];
  546.     }
  547.  
  548.     if ( $snpshpwp_data['f_post_crsvggl_on'] !== '1' ) {
  549.         $vars['f_post_crsv_face'] = $snpshpwp_data['f_post_crsv']['face'];
  550.         $vars['f_post_crsv_size'] = $snpshpwp_data['f_post_crsv']['size'];
  551.         $vars['f_post_crsv_style'] = $snpshpwp_data['f_post_crsv']['style'];
  552.         $vars['f_post_crsv_weight'] = $snpshpwp_data['f_post_crsv']['weight'];
  553.     }
  554.     else {
  555.         $vars['f_post_crsv_face'] = $snpshpwp_data['f_post_crsvggl']['face'];
  556.         $vars['f_post_crsv_size'] = $snpshpwp_data['f_post_crsvggl']['size'];
  557.         $vars['f_post_crsv_style'] = $snpshpwp_data['f_post_crsvggl']['style'];
  558.         $vars['f_post_crsv_weight'] = $snpshpwp_data['f_post_crsvggl']['weight'];
  559.     }
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.     $vars['content_width'] = $snpshpwp_data['content_width'];
  584.     $vars['fimage_width'] = ( isset($snpshpwp_data['fimage_width']) ? $snpshpwp_data['fimage_width'].'px' : '960px' );
  585.     $vars['fimage_height'] = ( isset($snpshpwp_data['fimage_height']) ? $snpshpwp_data['fimage_height'].'px' : '600px' );
  586.  
  587.  
  588.  
  589.     $vars['single_fimage_width'] = ( isset($snpshpwp_data['single_fimage_width']) ? $snpshpwp_data['single_fimage_width'].'px' : '1200px' );
  590.     $vars['single_fimage_height'] = ( isset($snpshpwp_data['single_fimage_height']) ? $snpshpwp_data['single_fimage_height'].'px' : '400px' );
  591.  
  592.  
  593.     $vars['fb_content_width'] = (intval($snpshpwp_data['content_width'])).'px';
  594.     $vars['fb_hres_c'] = (intval($snpshpwp_data['fb_hres_c'])/2).'px';
  595.     $vars['fb_hres_w'] = (intval($snpshpwp_data['fb_hres_w'])).'px';
  596.     $vars['fb_mres_w'] = (intval($snpshpwp_data['fb_mres_w'])).'px';
  597.     $vars['fb_mres_c'] = (intval($snpshpwp_data['fb_mres_c'])/2).'px';
  598.     $vars['fb_mres_s'] = (intval($snpshpwp_data['fb_mres_s']) == 1 ) ? '1' : '0';
  599.     $vars['fb_lres_w'] = (intval($snpshpwp_data['fb_lres_w'])).'px';
  600.     $vars['fb_lres_c'] = (intval($snpshpwp_data['fb_lres_c'])/2).'px';
  601.     $vars['fb_lres_s'] = (intval($snpshpwp_data['fb_lres_s']) == 1 ) ? '1' : '0';
  602.  
  603.     return $vars;
  604. }
  605. endif;
  606. add_filter( 'less_vars', 'snpshpwp_less', 10, 2 );
  607.  
  608.  
  609.  
  610. /*
  611.  * Head CSS
  612. */
  613. if ( !function_exists('snpshpwp_wp_head') ) :
  614. function snpshpwp_wp_head() {
  615.     global $snpshpwp_data;
  616.  
  617.     if( $snpshpwp_data['custom-css'] !== '' || $snpshpwp_data['custom-css-med'] !== '' || $snpshpwp_data['custom-css-low'] !== '' ) :
  618.  
  619.         $curr_res = array();
  620.  
  621.         if ( $snpshpwp_data['custom-css-med'] !== '' ) {
  622.             $curr_res['med'] = array(
  623.                 'css'=>$snpshpwp_data['custom-css-med'],
  624.                 'res'=>$snpshpwp_data['fb_mres_w']
  625.             );
  626.         }
  627.         if ( $snpshpwp_data['custom-css-low'] !== '' ) {
  628.             $curr_res['low'] = array(
  629.                 'css'=>$snpshpwp_data['custom-css-low'],
  630.                 'res'=>$snpshpwp_data['fb_lres_w']
  631.             );
  632.         }
  633.  
  634.         echo "<style type='text/css'>";
  635.         if ( $snpshpwp_data['custom-css'] !== '' ) echo $snpshpwp_data['custom-css'];
  636.         foreach ( $curr_res as $k => $v ) {
  637.             printf( '@media (max-width: %1$spx) {%2$s}', $v['res'], $v['css'] );
  638.         }
  639.         echo "</style>";
  640.     endif;
  641.  
  642.     if( $snpshpwp_data['tracking-code'] != '' ) :
  643.         echo $snpshpwp_data['tracking-code'];
  644.     endif;
  645. }
  646. endif;
  647. add_action( 'wp_head', 'snpshpwp_wp_head' );
  648.  
  649.  
  650. /*
  651.  * Google Fonts
  652. */
  653. if ( !function_exists('snpshpwp_fonts') ) :
  654. function snpshpwp_fonts() {
  655.     global $snpshpwp_data;
  656.  
  657.  
  658.  
  659.     $font = array ();
  660.     if ( $snpshpwp_data['f_header_bar_mnggl_on'] == '1' )
  661.         $font[] = $snpshpwp_data['f_header_bar_mnggl']['face'];
  662.     if ( $snpshpwp_data['f_header_mnggl_on'] == '1' )
  663.         $font[] = $snpshpwp_data['f_header_mnggl']['face'];
  664.     if ( $snpshpwp_data['f_header_drpdwnggl_on'] == '1' )
  665.         $font[] = $snpshpwp_data['f_header_drpdwnggl']['face'];
  666.     if ( $snpshpwp_data['f_post_mnggl_on'] == '1' )
  667.         $font[] = $snpshpwp_data['f_post_mnggl']['face'];
  668.     if ( $snpshpwp_data['f_post_hdrggl_on'] == '1' )
  669.         $font[] = $snpshpwp_data['f_post_hdrggl']['face'];
  670.     if ( $snpshpwp_data['f_post_crsvggl_on'] == '1' )
  671.         $font[] = $snpshpwp_data['f_post_crsvggl']['face'];
  672.     if ( $snpshpwp_data['f_footer_wtggl_on'] == '1' )
  673.         $font[] = $snpshpwp_data['f_footer_wtggl']['face'];
  674.     if ( $snpshpwp_data['f_footer_wtxtggl_on'] == '1' )
  675.         $font[] = $snpshpwp_data['f_footer_wtxtggl']['face'];
  676.     if ( $snpshpwp_data['f_footer_fbrggl_on'] == '1' )
  677.         $font[] = $snpshpwp_data['f_footer_fbrggl']['face'];
  678.  
  679.  
  680.     $protocol = is_ssl() ? 'https' : 'http';
  681.  
  682.     $i = 0;
  683.     foreach ( array_unique($font) as $cf ) {
  684.         $i++;
  685.         $scf = str_replace(' ', '%20', $cf);
  686.         wp_enqueue_style( "snpshpwp-font-$i", $protocol."://fonts.googleapis.com/css?family=$scf%3A100%2C200%2C300%2C300italic%2C400%2C400italic%2C500%2C500italic%2C600%2C700%2C700italic%2C800&amp;subset=all" );
  687.     }
  688.  
  689. }
  690. endif;
  691. add_action( 'wp_enqueue_scripts', 'snpshpwp_fonts' );
  692.  
  693.  
  694. /*
  695.  * Widgets Init
  696. */
  697. if ( !function_exists('snpshpwp_widgets_init') ) :
  698. function snpshpwp_widgets_init() {
  699.  
  700.     global $snpshpwp_data;
  701.  
  702.     $snpshpwp_layout['widget_title_before'] = '<h3 class="snpshpwp_widget_title margin-bottom24">';
  703.     $snpshpwp_layout['widget_title_after'] = '</h3>';
  704.     $snpshpwp_layout['footer_widget_title_before'] = '<h3 class="snpshpwp_widget_title margin-bottom24">';
  705.     $snpshpwp_layout['footer_widget_title_after'] = '</h3>';
  706.  
  707.     register_sidebar( array (
  708.         'name' => __( 'Blog Archives Sidebar', 'snpshpwp' ),
  709.         'id' => 'sidebar-blog',
  710.         'before_widget' => '<aside id="%1$s" class="widget margin-top36 %2$s">',
  711.         'after_widget' => "</aside>",
  712.         'before_title' => $snpshpwp_layout['widget_title_before'],
  713.         'after_title' => $snpshpwp_layout['widget_title_after'],
  714.         'description' => __( 'This sidebar appears on Blog Archive pages.', 'snpshpwp' )
  715.     ) );
  716.  
  717.     register_sidebar( array (
  718.         'name' => __( 'Single Posts Sidebar', 'snpshpwp' ),
  719.         'id' => 'sidebar-single',
  720.         'before_widget' => '<aside id="%1$s" class="widget margin-top36 %2$s">',
  721.         'after_widget' => "</aside>",
  722.         'before_title' => $snpshpwp_layout['widget_title_before'],
  723.         'after_title' => $snpshpwp_layout['widget_title_after'],
  724.         'description' => __( 'This sidebar appears on Single Posts.', 'snpshpwp' )
  725.     ) );
  726.  
  727.     register_sidebar( array (
  728.         'name' => __( 'Pages Sidebar', 'snpshpwp' ),
  729.         'id' => 'sidebar-page',
  730.         'before_widget' => '<aside id="%1$s" class="widget margin-top36 %2$s">',
  731.         'after_widget' => "</aside>",
  732.         'before_title' => $snpshpwp_layout['widget_title_before'],
  733.         'after_title' => $snpshpwp_layout['widget_title_after'],
  734.         'description' => __( 'This sidebar appears on Pages.', 'snpshpwp' )
  735.     ) );
  736.  
  737.     if ( isset($snpshpwp_data['footer_widgets']) && $snpshpwp_data['footer_widgets'] !== '1' ) {
  738.         register_sidebar( array (
  739.             'name' => __( 'Footer 1', 'snpshpwp' ),
  740.             'id' => 'footer-1',
  741.             'before_widget' => '<aside id="%1$s" class="widget %2$s margin-top36">',
  742.             'after_widget' => "</aside>",
  743.             'before_title' => $snpshpwp_layout['footer_widget_title_before'],
  744.             'after_title' => $snpshpwp_layout['footer_widget_title_after']
  745.         ) );
  746.  
  747.         register_sidebar( array (
  748.             'name' => __( 'Footer 2', 'snpshpwp' ),
  749.             'id' => 'footer-2',
  750.             'before_widget' => '<aside id="%1$s" class="widget %2$s margin-top36">',
  751.             'after_widget' => "</aside>",
  752.             'before_title' => $snpshpwp_layout['footer_widget_title_before'],
  753.             'after_title' => $snpshpwp_layout['footer_widget_title_after']
  754.         ) );
  755.  
  756.         register_sidebar( array (
  757.             'name' => __( 'Footer 3', 'snpshpwp' ),
  758.             'id' => 'footer-3',
  759.             'before_widget' => '<aside id="%1$s" class="widget %2$s margin-top36">',
  760.             'after_widget' => "</aside>",
  761.             'before_title' => $snpshpwp_layout['footer_widget_title_before'],
  762.             'after_title' => $snpshpwp_layout['footer_widget_title_after']
  763.         ) );
  764.  
  765.         register_sidebar( array (
  766.             'name' => __( 'Footer 4', 'snpshpwp' ),
  767.             'id' => 'footer-4',
  768.             'before_widget' => '<aside id="%1$s" class="widget %2$s margin-top36">',
  769.             'after_widget' => "</aside>",
  770.             'before_title' => $snpshpwp_layout['footer_widget_title_before'],
  771.             'after_title' => $snpshpwp_layout['footer_widget_title_after']
  772.         ) );
  773.  
  774.         register_sidebar( array (
  775.             'name' => __( 'Footer 5', 'snpshpwp' ),
  776.             'id' => 'footer-5',
  777.             'before_widget' => '<aside id="%1$s" class="widget %2$s margin-top36">',
  778.             'after_widget' => "</aside>",
  779.             'before_title' => $snpshpwp_layout['footer_widget_title_before'],
  780.             'after_title' => $snpshpwp_layout['footer_widget_title_after']
  781.         ) );
  782.     }
  783.  
  784.  
  785.     if ( SNPSHPWP_WOOCOMMERCE === true ) {
  786.         register_sidebar( array (
  787.             'name' => __( 'Woocommerce Archive Sidebar', 'snpshpwp' ),
  788.             'id' => 'sidebar-woo',
  789.             'before_widget' => '<aside id="%1$s" class="widget margin-top36 %2$s">',
  790.             'after_widget' => "</aside>",
  791.             'before_title' => $snpshpwp_layout['widget_title_before'],
  792.             'after_title' => $snpshpwp_layout['widget_title_after'],
  793.             'description' => __( 'This sidebar appears on Woocommerce archive and shop pages.', 'snpshpwp' )
  794.         ) );
  795.  
  796.         register_sidebar( array (
  797.             'name' => __( 'Woocommerce Posts Sidebar', 'snpshpwp' ),
  798.             'id' => 'sidebar-woo-single',
  799.             'before_widget' => '<aside id="%1$s" class="widget margin-top36 %2$s">',
  800.             'after_widget' => "</aside>",
  801.             'before_title' => $snpshpwp_layout['widget_title_before'],
  802.             'after_title' => $snpshpwp_layout['widget_title_after'],
  803.             'description' => __( 'This sidebar appears on Woocommerce single posts.', 'snpshpwp' )
  804.         ) );
  805.  
  806.         if ( isset($snpshpwp_data['shop-widgets-before']) ) {
  807.             $shop_widgets_before = $snpshpwp_data['shop-widgets-before'];
  808.             if ( isset($snpshpwp_data['shop-widgets-before']) || $snpshpwp_data['shop-widgets-before'] !== 'none' ) :
  809.                 for ($i = 1; $i <= $shop_widgets_before; $i++) {
  810.                     register_sidebar( array (
  811.                         'name' => __( 'Shop Archives Widgets Before '.$i, 'snpshpwp' ),
  812.                         'id' => 'shop-widgets-before-'.$i,
  813.                         'before_widget' => '<aside id="%1$s" class="widget %2$s margin-bottom36">',
  814.                         'after_widget' => "</aside>",
  815.                         'before_title' => $snpshpwp_layout['widget_title_before'],
  816.                         'after_title' => $snpshpwp_layout['widget_title_after']
  817.                     ) );
  818.                 }
  819.             endif;
  820.         }
  821.  
  822.         if ( isset($snpshpwp_data['shop-widgets-after']) ) {
  823.             $shop_widgets_after = $snpshpwp_data['shop-widgets-after'];
  824.             if ( isset($snpshpwp_data['shop-widgets-after']) || $snpshpwp_data['shop-widgets-after'] !== 'none' ) :
  825.                 for ($i = 1; $i <= $shop_widgets_after; $i++) {
  826.                     register_sidebar( array (
  827.                         'name' => __( 'Shop Archives Widgets After '.$i, 'snpshpwp' ),
  828.                         'id' => 'shop-widgets-after-'.$i,
  829.                         'before_widget' => '<aside id="%1$s" class="widget %2$s margin-bottom36">',
  830.                         'after_widget' => "</aside>",
  831.                         'before_title' => $snpshpwp_layout['widget_title_before'],
  832.                         'after_title' => $snpshpwp_layout['widget_title_after']
  833.                     ) );
  834.                 }
  835.             endif;
  836.         }
  837.  
  838.         if ( isset($snpshpwp_data['product-widgets-before']) ) {
  839.             $product_widgets_before = $snpshpwp_data['product-widgets-before'];
  840.             if ( isset($snpshpwp_data['product-widgets-before']) || $snpshpwp_data['product-widgets-before'] !== 'none' ) :
  841.                 for ($i = 1; $i <= $product_widgets_before; $i++) {
  842.                     register_sidebar( array (
  843.                         'name' => __( 'Single Products Widgets Before '.$i, 'snpshpwp' ),
  844.                         'id' => 'product-widgets-before-'.$i,
  845.                         'before_widget' => '<aside id="%1$s" class="widget %2$s margin-bottom36">',
  846.                         'after_widget' => "</aside>",
  847.                         'before_title' => $snpshpwp_layout['widget_title_before'],
  848.                         'after_title' => $snpshpwp_layout['widget_title_after']
  849.                     ) );
  850.                 }
  851.             endif;
  852.         }
  853.  
  854.         if ( isset($snpshpwp_data['product-widgets-after']) ) {
  855.             $product_widgets_after = $snpshpwp_data['product-widgets-after'];
  856.             if ( isset($snpshpwp_data['product-widgets-after']) || $snpshpwp_data['product-widgets-after'] !== 'none' ) :
  857.                 for ($i = 1; $i <= $product_widgets_after; $i++) {
  858.                     register_sidebar( array (
  859.                         'name' => __( 'Single Products Widgets After '.$i, 'snpshpwp' ),
  860.                         'id' => 'product-widgets-after-'.$i,
  861.                         'before_widget' => '<aside id="%1$s" class="widget %2$s margin-bottom36">',
  862.                         'after_widget' => "</aside>",
  863.                         'before_title' => $snpshpwp_layout['widget_title_before'],
  864.                         'after_title' => $snpshpwp_layout['widget_title_after']
  865.                     ) );
  866.                 }
  867.             endif;
  868.         }
  869.     }
  870.  
  871.     if ( isset($snpshpwp_data['sidebar']) ) {
  872.         $sidebars = $snpshpwp_data['sidebar'];
  873.  
  874.         foreach ( $sidebars as $sidebar ) {
  875.             $title = sanitize_title( $sidebar['title'] );
  876.             register_sidebar( array (
  877.                 'name' => $sidebar['title'] ,
  878.                 'id' => $title,
  879.                 'before_widget' => '<aside id="%1$s" class="widget %2$s margin-top36">',
  880.                 'after_widget' => "</aside>",
  881.                 'before_title' => $snpshpwp_layout['widget_title_before'],
  882.                 'after_title' => $snpshpwp_layout['widget_title_after']
  883.             ) );
  884.         }
  885.     }
  886.  
  887.  
  888. }
  889. endif;
  890. add_action( 'widgets_init', 'snpshpwp_widgets_init' );
  891.  
  892. /**
  893.  * Breadcrumbs
  894. */
  895.     if ( !function_exists('snpshpwp_breadcrumbs') ) :
  896.     function snpshpwp_breadcrumbs() {
  897.         if ( is_home() || is_front_page() ) {
  898.             return;
  899.         }
  900.         global $snpshpwp_data;
  901.  
  902.         if ( ( $snpshpwp_data['breadcrumbs_active'] !== '1' ) || ( is_singular() && get_post_meta( get_the_ID(), 'snpshpwp_breadcrumbs', true ) !== '1' ) ) :
  903.  
  904.         printf('<div id="snpshpwp_breadcrumbs" class="snpshpwp_breadcrumbs"><div class="snpshpwp_container">');
  905.             breadcrumb_trail(
  906.                 array(
  907.                     'container' => 'nav',
  908.                     'separator' => ' / ',
  909.                     'labels'    => array(
  910.                         'browse' => ''
  911.                     )
  912.                 )
  913.             );
  914.         printf('</div></div>');
  915.         endif;
  916.     }
  917.     endif;
  918.     add_action('snpshpwp_before_content', 'snpshpwp_breadcrumbs', 5);
  919.  
  920.  
  921.  
  922.  
  923. /*
  924.  * WooCommerce Init
  925. */
  926.  
  927. if ( SNPSHPWP_WOOCOMMERCE === true ) {
  928.  
  929.     /* Image sizes */
  930.     if ( get_theme_mod('snpshpwp_woo_init') !== 'true' ) {
  931.         function snpshpwp_woocommerce_image_dimensions() {
  932.             $catalog = array(
  933.                 'width'     => '500',
  934.                 'height'    => '600',
  935.                 'crop'      => 1
  936.             );
  937.             $single = array(
  938.                 'width'     => '500',
  939.                 'height'    => '600',
  940.                 'crop'      => 1
  941.             );
  942.             $thumbnail = array(
  943.                 'width'     => '200',
  944.                 'height'    => '200',
  945.                 'crop'      => 1
  946.             );
  947.  
  948.             update_option( 'shop_catalog_image_size', $catalog );
  949.             update_option( 'shop_single_image_size', $single );
  950.             update_option( 'shop_thumbnail_image_size', $thumbnail );
  951.  
  952.             set_theme_mod('snpshpwp_woo_init', 'true');
  953.         }
  954.         add_action( 'init', 'snpshpwp_woocommerce_image_dimensions', 1 );
  955.     }
  956.  
  957.     if ( !function_exists( 'snpshpwp_woo_product_navigation' ) ) :
  958.     function snpshpwp_woo_product_navigation ($post_id, $categories_as_array, $position) {
  959.         $query_args = array( 'post__in' => array($post_id), 'posts_per_page' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'tax_query' => array(
  960.             array(
  961.                 'taxonomy' => 'product_cat',
  962.                 'field' => 'id',
  963.                 'terms' => $categories_as_array
  964.             )));
  965.         $r_single = new WP_Query($query_args);
  966.         if ($r_single->have_posts()) {
  967.             $r_single->the_post();
  968.             $out = sprintf('<a href="%2$s" class="snpshpwp_singlenav_%1$s" title="%3$s">%4$s</a>', $position, get_permalink(), esc_attr(get_the_title() ? get_the_title() : get_the_ID()), ( $position == 'next' ? '&gt;' : '&lt;' ) );
  969.             wp_reset_query();
  970.             return $out;
  971.         }
  972.     }
  973.     endif;
  974.  
  975.     if ( !function_exists( 'snpshpwp_product_navigation' ) ) :
  976.     function snpshpwp_product_navigation(){
  977.         if (defined('DOING_AJAX') && DOING_AJAX)
  978.             return;
  979.  
  980.         if ( is_singular('product') ) {
  981.             global $post;
  982.  
  983.             $terms = wp_get_post_terms( $post->ID, 'product_cat' );
  984.  
  985.             $cats_array = array();
  986.  
  987.             foreach ( $terms as $term ) $cats_array[] = $term->term_id;
  988.  
  989.             if ( empty($cats_array) ) return;
  990.  
  991.             $query_args = array('posts_per_page' => -1, 'post_status' => 'publish', 'post_type' => 'product', 'tax_query' => array(
  992.                 array(
  993.                 'taxonomy' => 'product_cat',
  994.                 'field' => 'id',
  995.                 'terms' => $cats_array
  996.                 )));
  997.             $r = new WP_Query($query_args);
  998.  
  999.             if ($r->post_count > 2) {
  1000.  
  1001.                 $prev_product_id = -1;
  1002.                 $next_product_id = -1;
  1003.          
  1004.                 $found_product = false;
  1005.                 $i = 0;
  1006.  
  1007.                 $current_product_index = $i;
  1008.                 $current_product_id = get_the_ID();
  1009.  
  1010.                 if ($r->have_posts()) {
  1011.                     while ($r->have_posts()) {
  1012.                         $r->the_post();
  1013.                         $current_id = get_the_ID();
  1014.  
  1015.                         if ($current_id == $current_product_id) {
  1016.                             $found_product = true;
  1017.                             $current_product_index = $i;
  1018.                         }
  1019.  
  1020.                         $is_first = ($current_product_index == 1);
  1021.  
  1022.                         if ($is_first) {
  1023.                             $prev_product_id = -1;
  1024.                         } else {
  1025.                             if (!$found_product && $current_id != $current_product_id) {
  1026.                                 $prev_product_id = get_the_ID();
  1027.                             }
  1028.                         }
  1029.  
  1030.                         if ($i == 0) {
  1031.                             $next_product_id = get_the_ID();
  1032.                         }
  1033.  
  1034.                         if ($found_product && $i == $current_product_index + 1) {
  1035.                             $next_product_id = get_the_ID();
  1036.                         }
  1037.  
  1038.                         $i++;
  1039.                     }
  1040.  
  1041.                     if ($prev_product_id != -1) { $prev = snpshpwp_woo_product_navigation($prev_product_id, $cats_array, "prev"); } else { $prev = ''; }
  1042.                     if ($next_product_id != -1) { $next = snpshpwp_woo_product_navigation($next_product_id, $cats_array, "next"); } else { $next = ''; }
  1043.                 }
  1044.  
  1045.                 wp_reset_query();
  1046.             }
  1047.         }
  1048.         printf('<span class="snpshpwp_woo_single_navigation">%1$s%2$s</span>', $prev, $next);
  1049.     }
  1050.     endif;
  1051.     add_action('woocommerce_single_product_summary', 'snpshpwp_product_navigation', 0);
  1052.  
  1053.  
  1054.  
  1055.  
  1056.     global $snpshpwp_data;
  1057.  
  1058.     add_theme_support( 'woocommerce' );
  1059.     add_filter( 'woocommerce_enqueue_styles', '__return_false' );
  1060.  
  1061.     $woo_per_page = ( isset( $snpshpwp_data['woo_per_page'] ) ? $snpshpwp_data['woo_per_page'] : 10 );
  1062.     add_filter( 'loop_shop_per_page', create_function( '$cols', 'return '.$woo_per_page.';' ), 20 );
  1063.  
  1064.     remove_action( 'woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0);
  1065.    
  1066.     if ( is_woocommerce() ) {
  1067.         remove_action('snpshpwp_before_content', 'snpshpwp_breadcrumbs', 5);
  1068.         add_action('snpshpwp_before_content', 'woocommerce_breadcrumb', 5);
  1069.     }
  1070.  
  1071.     remove_action( 'woocommerce_before_single_product','woocommerce_show_messages', 10, 0);
  1072.     add_action('snpshpwp_before_content', 'wc_print_notices', 10);
  1073.  
  1074. /*
  1075.     function woo_related_products_limit() {
  1076.         global $product;
  1077.        
  1078.         $args['posts_per_page'] = 6;
  1079.         return $args;
  1080.     }
  1081.     add_filter( 'woocommerce_related_products_args', 'woo_related_products_limit' );
  1082. */
  1083.  
  1084.  
  1085.     /* Disable tabs */
  1086.     function woo_remove_product_tabs( $tabs ) {
  1087.         unset( $tabs['additional_information'] );
  1088.         return $tabs;
  1089.     }
  1090.     add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
  1091.  
  1092.     /* Override related */
  1093.     function woocommerce_output_related_products() {
  1094.         $woo_rel_per_page = ( isset( $snpshpwp_data['woo_rel_per_page'] ) ? $snpshpwp_data['woo_rel_per_page'] : 4 );
  1095.         $rel_defaults = array(
  1096.             'posts_per_page' => $woo_rel_per_page,
  1097.             'columns' => 1,
  1098.             'orderby' => 'rand'
  1099.         );
  1100.         woocommerce_related_products($rel_defaults);
  1101.     }
  1102.  
  1103.     if ( !function_exists( 'snpshpwp_enqueue_woocommerce_style' ) ) :
  1104.     function snpshpwp_enqueue_woocommerce_style(){
  1105.         wp_register_style( 'woocommerce', get_template_directory_uri() . '/woocommerce/style.css' );
  1106.         if ( class_exists( 'woocommerce' ) ) {
  1107.             wp_enqueue_style( 'woocommerce' );
  1108.         }
  1109.         wp_enqueue_style( 'snpshpwp-less-woo', get_stylesheet_directory_uri() . '/less/woo.less' );
  1110.     }
  1111.     endif;
  1112.     add_action( 'wp_enqueue_scripts', 'snpshpwp_enqueue_woocommerce_style' );
  1113.  
  1114.  
  1115.     /* Single filters */
  1116.     if ( !function_exists( 'snpshpwp_woo_single_sku' ) ) :
  1117.     function snpshpwp_woo_single_sku() {
  1118.         global $product;
  1119.         if ( wc_product_sku_enabled() && ( $product->get_sku() || $product->is_type( 'variable' ) ) ) : ?><span class="sku_wrapper"><?php _e( 'SKU:', 'woocommerce' ); ?> <span class="sku" itemprop="sku"><?php echo ( $sku = $product->get_sku() ) ? $sku : __( 'N/A', 'woocommerce' ); ?></span></span><?php
  1120.         endif;
  1121.     }
  1122.     endif;
  1123.     add_action('woocommerce_single_product_summary', 'snpshpwp_woo_single_sku', 15);
  1124.  
  1125.     if ( !function_exists( 'snpshpwp_woo_single_additional' ) ) :
  1126.     function snpshpwp_woo_single_additional() {
  1127.         global $woocommerce, $post, $product;
  1128.         $product->list_attributes();
  1129.     }
  1130.     endif;
  1131.     add_action('woocommerce_single_product_summary', 'snpshpwp_woo_single_additional', 25);
  1132.  
  1133.  
  1134.     /* Woo loop filters */
  1135.     if ( !function_exists( 'snpshpwp_woo_loop_cat' ) ) :
  1136.     function snpshpwp_woo_loop_cat(){
  1137.         global $product;
  1138.         echo '</a>';
  1139.         echo '<div class="snpshpwp_wooa_wrap"><div class="snpshpwp_wooa_wrap_inner">';
  1140.         printf('<a href="#" class="button snpshpwp_quick_view" data-product="%2$s"><span>%1$s</span> <span><i class="snpshp-wp-plus"></i></span></a>', __('Quick look', 'snpshpwp'), get_the_ID());
  1141.  
  1142.  
  1143.         printf('<a href="%1$s">', get_permalink() );
  1144.     }
  1145.     endif;
  1146.  
  1147.     add_action('woocommerce_before_shop_loop_item_title', 'snpshpwp_woo_loop_cat', 15);
  1148.     remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5);
  1149.     remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10);
  1150.     add_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_rating', 5);
  1151.     add_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_price', 15);
  1152.  
  1153.  
  1154.     if ( !function_exists( 'snpshpwp_woo_close_archive' ) ) :
  1155.     function snpshpwp_woo_close_archive(){
  1156.         echo '</div></div>';
  1157.     }
  1158.     endif;
  1159.     add_action('woocommerce_after_shop_loop_item', 'snpshpwp_woo_close_archive', 15);
  1160.  
  1161.  
  1162.  
  1163.     /*
  1164.      * SNPSHPWP Quick View
  1165.     */
  1166.     if ( ! function_exists('snpshpwp_woo_quickview')) :
  1167.     function snpshpwp_woo_quickview() {
  1168.  
  1169.     $currId = $_POST['product_id'];
  1170.  
  1171.     $product = get_product( $currId );
  1172.  
  1173.     $out = '';
  1174.     $curr_imgs = '';
  1175.  
  1176.     $size = sizeof( get_the_terms( $currId, 'product_cat' ) );
  1177.     $curr_cat = $product->get_categories( ', ', '<span class="snpshpwp_quickview_categories">' . _n( '', '', $size, 'snpshpwp' ) . ' ', '</span>' );
  1178.  
  1179.     $curr_price = '<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">';
  1180.     $curr_price .= '<p class="price">'.$product->get_price_html().'</p>';
  1181.     $curr_price .= ($product->is_in_stock() ? '' : '<span class="outofstock">'.__('Out of stock', 'snpshpwp').'</span>' );
  1182.     $curr_price .= '</div>';
  1183.  
  1184.     $curr_title = sprintf('<a href="%2$s" title="%1$s" class="snpshpwp_quickview_title">%1$s</a>', get_the_title($currId), get_the_permalink($currId) );
  1185.  
  1186.     $curr_cart = sprintf( '<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" class="button %s product_type_%s">%s</a>',
  1187.         esc_url( $product->add_to_cart_url() ),
  1188.         esc_attr( $product->id ),
  1189.         esc_attr( $product->get_sku() ),
  1190.         $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
  1191.         esc_attr( $product->product_type ),
  1192.         esc_html( $product->add_to_cart_text() )
  1193.     );
  1194.  
  1195.     if ( has_post_thumbnail($currId) ) {
  1196.  
  1197.         $image_title = esc_attr( get_the_title( get_post_thumbnail_id($currId) ) );
  1198.         $image_link  = wp_get_attachment_url( get_post_thumbnail_id($currId) );
  1199.         $curr_imgs .= '<div class="snpshpwp_quickview_slide">'.get_the_post_thumbnail( $currId, apply_filters( 'single_product_large_thumbnail_size', 'full' ), array(
  1200.             'title' => $image_title
  1201.             ) ).'</div>';
  1202.  
  1203.         $attachment_ids = $product->get_gallery_attachment_ids();
  1204.  
  1205.  
  1206.         foreach ( $attachment_ids as $attachment_id ) {
  1207.  
  1208.             $image_link = wp_get_attachment_image( $attachment_id, 'full' );
  1209.  
  1210.             if ( ! $image_link )
  1211.                 continue;
  1212.  
  1213.  
  1214.             $curr_imgs .= '<div class="snpshpwp_quickview_slide">'.$image_link.'</div>';
  1215.  
  1216.  
  1217.         }
  1218.  
  1219.  
  1220.     }
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.     $out .= sprintf('
  1227.     <div class="snpshpwp_quickview_slider_wrap">
  1228.     <div class="snpshpwp_quickview_slider">
  1229.     %1$s
  1230.     </div>
  1231.     </div>
  1232.     ', $curr_imgs );
  1233.  
  1234.  
  1235.     $out .= sprintf('
  1236.     <div class="snpshpwp_quickview_content">
  1237.     %1$s
  1238.     %2$s
  1239.     %4$s
  1240.     <div class="snpshpwp_quickview_text">%3$s</div>
  1241.     %5$s
  1242. <div style="font-size: 12px;  margin-top: 10px;">
  1243. <img src="http://www.blownwind.it/wp-content/themes/blownwind-child/img/whatsApp.png" alt="whatsApp" class="whatsApp" style="float:left;">
  1244. Servizio WhatsApp +39 3272842748
  1245. </div>
  1246.     </div>
  1247.     ', $curr_cat, $curr_title, $product->post->post_content, $curr_price, $curr_cart );
  1248.  
  1249.  
  1250.  
  1251.     $html ='<div id="snpshpwp_woo_quickview"><div class="snpshpwp_woo_quickview_inner"><a href="#" class="snpshpwp_quickview_close"><span>X</span></a>' . $out . '<div class="clearfix"></div></div></div>';
  1252.  
  1253.         die($html);
  1254.         exit;
  1255.     }
  1256.     endif;
  1257.     add_action('wp_ajax_nopriv_snpshpwp_woo_quickview', 'snpshpwp_woo_quickview');
  1258.     add_action('wp_ajax_snpshpwp_woo_quickview', 'snpshpwp_woo_quickview');
  1259.  
  1260.  
  1261.  
  1262.  
  1263.  
  1264.     if ( !function_exists( 'snpshpwp_woocart' ) ) :
  1265.     function snpshpwp_woocart() {
  1266.         global $woocommerce;
  1267.         printf('<div class="float_left snpshpwp_woo_shopping_cart"><a class="snpshpwp_cartcont cart-contents" href="#" title="%2$s"><span class="snpshpwp_wciw"><i class="snpshp-wp-bag"></i><span class="snpshpwp_cartico">%3$s</span></span></a>', $woocommerce->cart->get_cart_url(), __('View your shopping cart', 'snpshpwp'), sprintf(_n('%d', '%d', $woocommerce->cart->cart_contents_count, 'snpshpwp'), $woocommerce->cart->cart_contents_count), $woocommerce->cart->get_cart_total() );
  1268.  
  1269.         if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) {
  1270.             echo '<div id="snpshpwp_woocart" class="snpshpwp_shopping_cart">';
  1271.                 echo '<h3><span>'. $woocommerce->cart->cart_contents_count .'</span> '.__('Products in your basket', 'snpshpwp').'</h3>';
  1272.             foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
  1273.                 $_product = $values['data'];
  1274.                 if ( $_product->exists() && $values['quantity'] > 0 ) {
  1275.                     ?>
  1276.                     <div class = "snpshpwp_cart_item">
  1277.                        
  1278.  
  1279.                         <div class="snpshpwp-cart-thumbnail">
  1280.                             <?php
  1281.                                 $thumbnail = apply_filters( 'snpshpwp-square', $_product->get_image(), $values, $cart_item_key );
  1282.  
  1283.                                 if ( ! $_product->is_visible() || ( ! empty( $_product->variation_id ) && ! $_product->parent_is_visible() ) )
  1284.                                     echo $thumbnail;
  1285.                                 else
  1286.                                     printf('<a href="%s">%s</a>', esc_url( get_permalink( apply_filters('woocommerce_in_cart_product_id', $values['product_id'] ) ) ), $thumbnail );
  1287.                             ?>
  1288.                         </div>
  1289.  
  1290.                         <div class="snpshpwp-cart-name">
  1291.                             <?php
  1292.                                 if ( ! $_product->is_visible() || ( ! empty( $_product->variation_id ) && ! $_product->parent_is_visible() ) )
  1293.                                     echo apply_filters( 'woocommerce_in_cart_product_title', $_product->get_title(), $values, $cart_item_key );
  1294.                                 else
  1295.                                     printf('<a href="%s">%s</a>', esc_url( get_permalink( apply_filters('woocommerce_in_cart_product_id', $values['product_id'] ) ) ), apply_filters('woocommerce_in_cart_product_title', $_product->get_title(), $values, $cart_item_key ) );
  1296.  
  1297.                                 // Meta data
  1298.                                 echo $woocommerce->cart->get_item_data( $values ) . ' X ';
  1299.                                 $product_quantity = esc_attr( $values['quantity'] );
  1300.                                 echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key );
  1301.  
  1302.  
  1303.                                 // Backorder notification
  1304.                                 if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $values['quantity'] ) )
  1305.                                     echo '<p class="backorder_notification">' . __( 'Available on backorder', 'snpshpwp' ) . '</p>';
  1306.  
  1307.                                 echo apply_filters( 'woocommerce_cart_item_subtotal', $woocommerce->cart->get_product_subtotal( $_product, $values['quantity'] ), $values, $cart_item_key );
  1308.                             ?>
  1309.                         </div>
  1310.  
  1311.                         <div class="snpshpwp-cart-remove">
  1312.                             <?php
  1313.                                 echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf('<a href="%s" class="remove" title="%s">&times;</a>', esc_url( $woocommerce->cart->get_remove_url( $cart_item_key ) ), __( 'Remove this item', 'snpshpwp' ) ), $cart_item_key );
  1314.                             ?>
  1315.                         </div>
  1316.  
  1317.                     </div>
  1318.                     <?php
  1319.                 }
  1320.             }
  1321.             printf('<a href="%2$s" class="snpshpwp_cart_button div_view_cart float_left">%1$s</a>','Vai al carrello', $woocommerce->cart->get_cart_url());
  1322.             printf('<a href="%2$s" class="snpshpwp_cart_button div_checkout float_right">%1$s</a>','Completa Ordine', $woocommerce->cart->get_checkout_url());
  1323.         echo '</div></div>';
  1324.         }
  1325.         else {
  1326.             $shop = woocommerce_get_page_id( 'shop' ) ? get_the_title( woocommerce_get_page_id( 'shop' ) ) : '';
  1327.             echo '<div id="snpshpwp_woocart" class="snpshpwp_shopping_cart snpshpwp_empty_cart">
  1328.                     '.__('Your shopping cart is empty','snpshpwp').' '.__('Why not add some items in our','snpshpwp').' <a href="'. get_permalink( woocommerce_get_page_id( 'shop' ) ).'">' . __('Shop', 'snpshpwp') . '</a>
  1329.                     </div></div>';
  1330.         }
  1331.     }
  1332.     endif;
  1333.  
  1334.  
  1335.  
  1336.  
  1337.  
  1338.  
  1339.  
  1340.  
  1341. // Ensure cart contents update when products are added to the cart via AJAX
  1342. if ( !function_exists( 'snpshpwp_woocommerce_header_add_to_cart_fragment' ) ) :
  1343. function snpshpwp_woocommerce_header_add_to_cart_fragment( $fragments ) {
  1344.     global $woocommerce;
  1345.  
  1346.     ob_start();
  1347.  
  1348.                 printf('<div class="float_left snpshpwp_element_woo-cart"><a class="snpshpwp_cartcont cart-contents" href="#" title="%2$s"><span class="snpshpwp_wciw"><i class="snpshp-wp-bag"></i><span class="snpshpwp_cartico">%3$s</span></span></a>', $woocommerce->cart->get_cart_url(), __('View your shopping cart', 'snpshpwp'), sprintf(_n('%d', '%d', $woocommerce->cart->cart_contents_count, 'snpshpwp'), $woocommerce->cart->cart_contents_count), $woocommerce->cart->get_cart_total() );
  1349.  
  1350.         if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) {
  1351.             echo '<div id="snpshpwp_woocart" class="snpshpwp_shopping_cart">';
  1352.  
  1353.                 echo '<h3><span>'. $woocommerce->cart->cart_contents_count .'</span> '.__('Products in your basket', 'snpshpwp').'</h3>';
  1354.  
  1355.             foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
  1356.                 $_product = $values['data'];
  1357.                 if ( $_product->exists() && $values['quantity'] > 0 ) {
  1358.                     ?>
  1359.                     <div class = "snpshpwp_cart_item">
  1360.                        
  1361.                         <div class="snpshpwp-cart-thumbnail">
  1362.                             <?php
  1363.                                 $thumbnail = apply_filters( 'snpshpwp-square', $_product->get_image(), $values, $cart_item_key );
  1364.  
  1365.                                 if ( ! $_product->is_visible() || ( ! empty( $_product->variation_id ) && ! $_product->parent_is_visible() ) )
  1366.                                     echo $thumbnail;
  1367.                                 else
  1368.                                     printf('<a href="%s">%s</a>', esc_url( get_permalink( apply_filters('woocommerce_in_cart_product_id', $values['product_id'] ) ) ), $thumbnail );
  1369.                             ?>
  1370.                         </div>
  1371.  
  1372.                         <div class="snpshpwp-cart-name">
  1373.                             <?php
  1374.                                 if ( ! $_product->is_visible() || ( ! empty( $_product->variation_id ) && ! $_product->parent_is_visible() ) )
  1375.                                     echo apply_filters( 'woocommerce_in_cart_product_title', $_product->get_title(), $values, $cart_item_key );
  1376.                                 else
  1377.                                     printf('<a href="%s">%s</a>', esc_url( get_permalink( apply_filters('woocommerce_in_cart_product_id', $values['product_id'] ) ) ), apply_filters('woocommerce_in_cart_product_title', $_product->get_title(), $values, $cart_item_key ) );
  1378.  
  1379.                                 // Meta data
  1380.                                 echo $woocommerce->cart->get_item_data( $values ) . ' X ';
  1381.                                 $product_quantity = esc_attr( $values['quantity'] );
  1382.                                 echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key );
  1383.  
  1384.                                 // Backorder notification
  1385.                                 if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $values['quantity'] ) )
  1386.                                     echo '<p class="backorder_notification">' . __( 'Available on backorder', 'snpshpwp' ) . '</p>';
  1387.  
  1388.                                 echo apply_filters( 'woocommerce_cart_item_subtotal', $woocommerce->cart->get_product_subtotal( $_product, $values['quantity'] ), $values, $cart_item_key );
  1389.                             ?>
  1390.                         </div>
  1391.  
  1392.                         <div class="snpshpwp-cart-remove">
  1393.                             <?php
  1394.                                 echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf('<a href="%s" class="remove" title="%s">&times;</a>', esc_url( $woocommerce->cart->get_remove_url( $cart_item_key ) ), __( 'Remove this item', 'snpshpwp' ) ), $cart_item_key );
  1395.                             ?>
  1396.                         </div>
  1397.  
  1398.                     </div>
  1399.                     <?php
  1400.                 }
  1401.             }
  1402.             printf('<a href="%2$s" class="snpshpwp_cart_button div_view_cart float_left">%1$s</a>',Vai al Carrello', $woocommerce->cart->get_cart_url());
  1403.             printf('<a href="%2$s" class="snpshpwp_cart_button div_checkout float_right">%1$s</a>','Completa Ordine', $woocommerce->cart->get_checkout_url());
  1404.         echo '</div></li>';
  1405.         }
  1406.         else {
  1407.             $shop = woocommerce_get_page_id( 'shop' ) ? get_the_title( woocommerce_get_page_id( 'shop' ) ) : '';
  1408.             echo '<div id="snpshpwp_woocart" class="snpshpwp_shopping_cart snpshpwp_empty_cart text-center">
  1409.                     '.__('Your shopping cart is empty','snpshpwp').' '.__('Why not add some items in our','snpshpwp').' <a href="'. get_permalink( woocommerce_get_page_id( 'shop' ) ).'">' . __('Shop', 'snpshpwp') . '</a>
  1410.                     </div></div>';
  1411.         }
  1412.    
  1413.     $fragments['div.snpshpwp_element_woo-cart'] = ob_get_clean();
  1414.    
  1415.     return $fragments;
  1416.    
  1417. }
  1418. endif;
  1419. add_filter('add_to_cart_fragments', 'snpshpwp_woocommerce_header_add_to_cart_fragment');
  1420.  
  1421.  
  1422.  
  1423. }
  1424.  
  1425.  
  1426. /*
  1427. * SnapShopWP Pagination
  1428. */
  1429. if ( !function_exists('snpshpwp_pagination') ) :
  1430. function snpshpwp_pagination($pages = '', $page = '', $range = 3, $ajax = '') {
  1431.     if ( $page == '' ) {
  1432.         global $paged;
  1433.         if ( empty( $paged ) ) $paged = 1;
  1434.     }
  1435.     else {
  1436.         $paged = $page;
  1437.     }
  1438.  
  1439.     $out = '';
  1440.     $showitems = 3;
  1441.  
  1442.     if ( $pages == '' ) {
  1443.         global $wp_query;
  1444.         $pages = $wp_query->max_num_pages;
  1445.         if ( !$pages ) {
  1446.             $pages = 1;
  1447.         }
  1448.     }
  1449.  
  1450.     if ( $ajax !== '' && $ajax !== 'no' ) {
  1451.         $ajaxload = 'onclick="snpshpwp_ajaxload_portfolio(jQuery(this)); return false;"';
  1452.     }
  1453.     else {
  1454.         $ajaxload = '';
  1455.     }
  1456.  
  1457.     if ( 1 != $pages ) {
  1458.         $out .= "<nav class='snpshpwp_pagination_wrapper'>";
  1459.         $out .= '<div class="snpshpwp_pagination_info">' . __('Pages', 'snpshpwp') . ': ' . $paged . ' ' . __('of', 'snpshpwp') . ' '  . $pages . '</div>';
  1460.         $out .= "<ul>";
  1461.  
  1462.         if ( $paged > 1 ) {
  1463.             $out .= "<li class=\"snpshpwp_pagination_normal snpshpwp_left\"><a title=\"" . __('View newer posts', 'snpshpwp') . "\" href=\"" . get_pagenum_link( $paged - 1 ) . "\" class=\"previous\" " . $ajaxload . ">&lt;&lt;<span class='display_none snpshpwp_page'>". ($paged - 1)."</span></a></li>";
  1464.         }
  1465.  
  1466.  
  1467.         for ( $i = 1; $i <= $pages; $i++ ) {
  1468.             if ( 1 != $pages && ( !( $i >= $paged + 3 || $i <= $paged - 3) || $pages <= $showitems ) ) {
  1469.                 $out .= ( $paged == $i ) ? "<li class=\"snpshpwp_pagination_square\"><a class=\"current\">" . $i . "</a></li>" : "<li class=\"snpshpwp_pagination_square\"><a title='" . __( 'View page number', 'snpshpwp' ) . " " . $i . "' href='" . get_pagenum_link( $i ) . "' class=\"inactive\" " .$ajaxload . ">" . $i . "<span class='display_none snpshpwp_page'>" . $i . "</span></a></li>";
  1470.             }
  1471.  
  1472.         }
  1473.  
  1474.         if ( $paged < $pages ) {
  1475.             $out .= "<li class=\"snpshpwp_pagination_normal snpshpwp_right\"><a title=\"" . __( 'View earlier posts', 'snpshpwp' ) . "\" href=\"" . get_pagenum_link( $paged + 1 ) . "\" class=\"next\" " . $ajaxload . ">&gt;&gt;<span class='display_none snpshpwp_page'>".( $paged + 1 )."</span></a></li>";
  1476.         }
  1477.  
  1478.  
  1479.         $out .= "</ul></nav>";
  1480.     }
  1481.     return $out;
  1482. }
  1483. endif;
  1484.  
  1485.  
  1486. /*
  1487. * SnapShopWP Pagination Mini
  1488. */
  1489. if ( !function_exists('snpshpwp_mini_pagination') ) :
  1490. function snpshpwp_mini_pagination($pages = '', $page = '', $range = 3, $ajax = '', $title = '') {
  1491.     if ( $page == '' ) {
  1492.         global $paged;
  1493.         if ( empty( $paged ) ) $paged = 1;
  1494.     }
  1495.     else {
  1496.     $paged = $page;
  1497.     }
  1498.     $next_page = $paged + 1;
  1499.     $prev_page = $paged - 1;
  1500.     $showitems = 3;
  1501.     $out = '';
  1502.  
  1503.     if ( $pages == '' ) {
  1504.         global $wp_query;
  1505.         $pages = $wp_query->max_num_pages;
  1506.         if ( !$pages ) {
  1507.             $pages = 1;
  1508.         }
  1509.     }
  1510.  
  1511.     if ( $ajax == 'false' ) {
  1512.         $ajaxload = '';
  1513.  
  1514.         if ( 1 != $pages ) {
  1515.             $out .= "<nav class='snpshpwp_pagination_wrapper'>";
  1516.             $out .= '<div class="snpshpwp_pagination_info">' . __('Pages', 'snpshpwp') . ': ' . $paged . ' ' . __('of', 'snpshpwp') . ' '  . $pages . '</div>';
  1517.             $out .= "<ul>";
  1518.             if ( $paged > 1 ) {
  1519.                 $out .= "<li class=\"snpshpwp_pagination_normal snpshpwp_left\"><a title=\"" . __('View newer posts', 'snpshpwp') . "\" href=\"" . get_pagenum_link( $paged - 1 ) . "\" class=\"previous\" " . $ajaxload . ">&lt;&lt;<span class='display_none snpshpwp_page'>". ($paged - 1)."</span></a></li>";
  1520.             }
  1521.             for ( $i = 1; $i <= $pages; $i++ ) {
  1522.                 if ( 1 != $pages && ( !( $i >= $paged + 3 || $i <= $paged - 3) || $pages <= $showitems ) ) {
  1523.                     $out .= ( $paged == $i ) ? "<li class=\"snpshpwp_pagination_square\"><a class=\"current\">" . $i . "</a></li>" : "<li class=\"snpshpwp_pagination_square\"><a title='" . __( 'View page number', 'snpshpwp' ) . " " . $i . "' href='" . get_pagenum_link( $i ) . "' class=\"inactive\" " .$ajaxload . ">" . $i . "<span class='display_none snpshpwp_page'>" . $i . "</span></a></li>";
  1524.                 }
  1525.             }
  1526.             if ( $paged < $pages ) {
  1527.                 $out .= "<li class=\"snpshpwp_pagination_normal snpshpwp_right\"><a title=\"" . __( 'View earlier posts', 'snpshpwp' ) . "\" href=\"" . get_pagenum_link( $paged + 1 ) . "\" class=\"next\" " . $ajaxload . ">&gt;&gt;<span class='display_none snpshpwp_page'>".( $paged + 1 )."</span></a></li>";
  1528.             }
  1529.             $out .= "</ul></nav>";
  1530.         }
  1531.     }
  1532.     else {
  1533.         $ajaxload = 'onclick="snpshpwp_ajaxload(jQuery(this)); return false;"';
  1534.         if ( 1 != $pages ) {
  1535.             $out .= "<nav class='snpshpwp_pagination_wrapper snpshpwp_pagination_ajax'>";
  1536.             $out .= "<ul>";
  1537.             if ( $paged > 1 ) {
  1538.                 $out .= "<li class=\"snpshpwp_pagination_square snpshpwp_left\"><a title=\"" . __('View newer posts', 'snpshpwp') . "\" href=\"" . get_pagenum_link( $paged - 1 ) . "\" class=\"previous\" " . $ajaxload . ">&lt;<span class='display_none snpshpwp_page'>". ($paged - 1)."</span></a></li>";
  1539.             }
  1540.             else {
  1541.                 $out .= "<li class=\"snpshpwp_pagination_square\"><a class=\"current\">&lt;</a></li>";
  1542.             }
  1543.             if ( $paged < $pages ) {
  1544.                 $out .= "<li class=\"snpshpwp_pagination_square snpshpwp_right\"><a title=\"" . __( 'View earlier posts', 'snpshpwp' ) . "\" href=\"" . get_pagenum_link( $paged + 1 ) . "\" class=\"next\" " . $ajaxload . ">&gt;<span class='display_none snpshpwp_page'>".( $paged + 1 )."</span></a></li>";
  1545.             }
  1546.             else {
  1547.                 $out .= "<li class=\"snpshpwp_pagination_square\"><a class=\"current\">&gt;</a></li>";
  1548.             }
  1549.             $out .= "</ul></nav>";
  1550.         }
  1551.     }
  1552.  
  1553.  
  1554.     return $out;
  1555. }
  1556. endif;
  1557.  
  1558.  
  1559. /**
  1560. * Pagination Top WooCommerce
  1561. */
  1562. if ( !function_exists( 'snpshpwp_mini_woo_pagination' ) ) :
  1563. function snpshpwp_mini_woo_pagination($pages = '', $page = '', $range = 3, $ajax = '', $title = '') {
  1564.     if ( $page == '' ) {
  1565.         global $paged;
  1566.         if ( empty( $paged ) ) $paged = 1;
  1567.     }
  1568.     else {
  1569.     $paged = $page;
  1570.     }
  1571.     $next_page = $paged + 1;
  1572.     $prev_page = $paged - 1;
  1573.     $showitems = 5;
  1574.     $out = '';
  1575.  
  1576.     if ( $pages == '' ) {
  1577.         global $wp_query;
  1578.         $pages = $wp_query->max_num_pages;
  1579.         if ( !$pages ) {
  1580.             $pages = 2;
  1581.         }
  1582.     }
  1583.  
  1584.     if ( $ajax == 'false' ) {
  1585.         $ajaxload = '';
  1586.  
  1587.         if ( 1 != $pages ) {
  1588.             $out .= "<nav class='snpshpwp_pagination_wrapper'>";
  1589.             $out .= '<div class="snpshpwp_pagination_info">' . __('Pages', 'snpshpwp') . ': ' . $paged . ' ' . __('of', 'snpshpwp') . ' '  . $pages . '</div>';
  1590.             $out .= "<ul>";
  1591.  
  1592.             if ( $paged > 1 ) {
  1593.                 $out .= "<li class=\"snpshpwp_pagination_normal snpshpwp_left\"><a title=\"" . __('View newer posts', 'snpshpwp') . "\" href=\"" . get_pagenum_link( $paged - 1 ) . "\" class=\"previous\" " . $ajaxload . ">&lt;&lt;<span class='display_none snpshpwp_page'>". ($paged - 1)."</span></a></li>";
  1594.             }
  1595.             for ( $i = 1; $i <= $pages; $i++ ) {
  1596.                 if ( 1 != $pages && ( !( $i >= $paged + 3 || $i <= $paged - 3) || $pages <= $showitems ) ) {
  1597.                     $out .= ( $paged == $i ) ? "<li class=\"snpshpwp_pagination_square\"><a class=\"current\">" . $i . "</a></li>" : "<li class=\"snpshpwp_pagination_square\"><a title='" . __( 'View page number', 'snpshpwp' ) . " " . $i . "' href='" . get_pagenum_link( $i ) . "' class=\"inactive\" " .$ajaxload . ">" . $i . "<span class='display_none snpshpwp_page'>" . $i . "</span></a></li>";
  1598.                 }
  1599.             }
  1600.             if ( $paged < $pages ) {
  1601.                 $out .= "<li class=\"snpshpwp_pagination_normal snpshpwp_right\"><a title=\"" . __( 'View earlier posts', 'snpshpwp' ) . "\" href=\"" . get_pagenum_link( $paged + 1 ) . "\" class=\"next\" " . $ajaxload . ">&gt;&gt;<span class='display_none snpshpwp_page'>".( $paged + 1 )."</span></a></li>";
  1602.             }
  1603.             $out .= "</ul></nav>";
  1604.         }
  1605.     }
  1606.     else {
  1607.         $ajaxload = 'onclick="snpshpwp_ajaxload_send_woo(jQuery(this)); return false;"';
  1608.  
  1609.         if ( 1 != $pages ) {
  1610.             $out .= "<nav class='snpshpwp_pagination_wrapper snpshpwp_pagination_ajax'>";
  1611.             $out .= "<ul>";
  1612.             if ( $paged > 1 ) {
  1613.                 $out .= "<li class=\"snpshpwp_pagination_square snpshpwp_left\"><a title=\"" . __('View newer posts', 'snpshpwp') . "\" href=\"" . get_pagenum_link( $paged - 1 ) . "\" class=\"previous\" " . $ajaxload . ">&lt;<span class='display_none snpshpwp_page'>". ($paged - 1)."</span></a></li>";
  1614.             }
  1615.             else {
  1616.                 $out .= "<li class=\"snpshpwp_pagination_square\"><a class=\"current\">&lt;</a></li>";
  1617.             }
  1618.             if ( $paged < $pages ) {
  1619.                 $out .= "<li class=\"snpshpwp_pagination_square snpshpwp_right\"><a title=\"" . __( 'View earlier posts', 'snpshpwp' ) . "\" href=\"" . get_pagenum_link( $paged + 1 ) . "\" class=\"next\" " . $ajaxload . ">&gt;<span class='display_none snpshpwp_page'>".( $paged + 1 )."</span></a></li>";
  1620.             }
  1621.             else {
  1622.                 $out .= "<li class=\"snpshpwp_pagination_square\"><a class=\"current\">&gt;</a></li>";
  1623.             }
  1624.             $out .= "</ul></nav>";
  1625.         }
  1626.     }
  1627.  
  1628.     return $out;
  1629. }
  1630. endif;
  1631.  
  1632.  
  1633. /**
  1634. * Pagination WooCommerce
  1635. */
  1636. if ( !function_exists( 'snpshpwp_mini_woo_pagination_cat' ) ) :
  1637. function snpshpwp_mini_woo_pagination_cat($pages = '', $paged = '', $offset = '', $ajax = '', $title = '') {
  1638.  
  1639.     $out = '';
  1640.     $pages = ceil($pages/$offset);
  1641.    
  1642.     if ( $ajax !== '' && $ajax !== 'no' ) {
  1643.          $ajaxload = 'onclick="snpshpwp_ajaxload_send_woo_cat(jQuery(this)); return false;"';
  1644.     }
  1645.     else {
  1646.          $ajaxload = '';
  1647.     }
  1648.  
  1649.     if ( 1 != $pages ) {
  1650.         $out .= "<nav class='snpshpwp_pagination_wrapper'>";
  1651.         $out .= '<div class="snpshpwp_pagination_info">' . __('Pages', 'snpshpwp') . ': ' . $paged . ' ' . __('of', 'snpshpwp') . ' '  . $pages . '</div>';
  1652.         $out .= "<ul>";
  1653.  
  1654.         if ( $paged > 1 ) {
  1655.             $out .= "<li class=\"snpshpwp_pagination_normal snpshpwp_left\"><a title=\"" . __('View newer posts', 'snpshpwp') . "\" href=\"" . get_pagenum_link( $paged - 1 ) . "\" class=\"previous bold_font\" " . $ajaxload . ">&lt;&lt;<span class='display_none snpshpwp_page'>". ($paged - 1)."</span></a></li>";
  1656.         }
  1657.  
  1658.  
  1659.         for ( $i = 1; $i <= $pages; $i++ ) {
  1660.             if ( 1 != $pages && ( !( $i >= $paged + 3 || $i <= $paged - 3) || $pages <= $showitems ) ) {
  1661.                 $out .= ( $paged == $i ) ? "<li class=\"snpshpwp_pagination_square\"><a class=\"current\">" . $i . "</a></li>" : "<li class=\"snpshpwp_pagination_square\"><a title='" . __( 'View page number', 'snpshpwp' ) . " " . $i . "' href='" . get_pagenum_link( $i ) . "' class=\"inactive\" " .$ajaxload . ">" . $i . "<span class='display_none snpshpwp_page'>" . $i . "</span></a></li>";
  1662.             }
  1663.             elseif ( $i == $paged + 3 ) {
  1664.                 $out .= '<li><a class="current">...</a></li>';
  1665.             }
  1666.             elseif ( $i == $paged - 3 ) {
  1667.                 $out .= '<li><a class="current">...</a></li>';
  1668.             }
  1669.  
  1670.         }
  1671.  
  1672.         if ( $paged < $pages ) {
  1673.             $out .= "<li class=\"snpshpwp_pagination_normal snpshpwp_right\"><a title=\"" . __( 'View earlier posts', 'snpshpwp' ) . "\" href=\"" . get_pagenum_link( $paged + 1 ) . "\" class=\"next bold_font\" " . $ajaxload . ">&gt;&gt;<span class='display_none snpshpwp_page'>".( $paged + 1 )."</span></a></li>";
  1674.         }
  1675.  
  1676.  
  1677.         $out .= "</ul></nav>";
  1678.     }
  1679.     return $out;
  1680. }
  1681. endif;
  1682.  
  1683. /*
  1684. * Template for comments and pingbacks
  1685. */
  1686. if ( !function_exists( 'snpshpwp_comment' ) ) :
  1687. function snpshpwp_comment( $comment, $args, $depth ) {
  1688.     $GLOBALS['comment'] = $comment;
  1689.     switch ( $comment->comment_type ) :
  1690.    
  1691.         case '' : ?>
  1692. <li <?php comment_class('single_comment'); ?> id="li-comment-<?php comment_ID(); ?>">
  1693.     <div id="comment-<?php comment_ID(); ?>" class="snpshpwp_div_comment border-box">
  1694.         <?php echo get_avatar( $comment, 200 ); ?>
  1695.         <div class="snpshpwp_comment_bubble">
  1696.             <div class="snpshpwpcomment_meta margin-bottom12 snpshpwp_header_font a-inherit">
  1697.                 <h6 class="comment_date_meta uppercase margin-bottom6"><?php echo get_comment_date(); ?></h6>
  1698.                 <h4 class="comment_author_meta uppercase snpshpwp_theme_color"><?php echo get_comment_author_link(); ?></h4>
  1699.             </div>
  1700.  
  1701.             <div class="snpshpwp_comment_text">
  1702.                 <?php
  1703.                     comment_text();
  1704.                     if ( $comment->comment_approved == '0' ) :
  1705.                 ?>
  1706.                 <p class="moderation">
  1707.                     <?php _e( 'Your comment is awaiting moderation.', 'snpshpwp' ); ?>
  1708.                 </p>
  1709.                 <?php endif; ?>
  1710.             </div>
  1711.  
  1712.             <div class="snpshpwp_comment_edit snpshpwp_header_font uppercase">
  1713.                 <?php
  1714.                     comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) );
  1715.                     edit_comment_link( __( 'Edit', 'snpshpwp' ), ' ' );
  1716.                 ?>
  1717.             </div>
  1718.         </div>
  1719.     </div>
  1720.     <?php
  1721.         break;
  1722.         case 'pingback'  :
  1723.     ?>
  1724. <li class="post pingback">
  1725.     <p>
  1726.     <?php
  1727.         _e( 'Pingback:', 'snpshpwp' );
  1728.         comment_author_link();
  1729.         edit_comment_link( __('(Edit)', 'snpshpwp'), ' ' );
  1730.     ?>
  1731.     </p>
  1732.     <?php
  1733.         break;
  1734.         case 'trackback' :
  1735.     ?>
  1736. <li class="post pingback">
  1737.     <p>
  1738.     <?php
  1739.         _e( 'Pingback:', 'snpshpwp' );
  1740.         comment_author_link();
  1741.         edit_comment_link( __('(Edit)', 'snpshpwp'), ' ' );
  1742.     ?>
  1743.     </p>
  1744.     <?php
  1745.         break;
  1746.         default :
  1747.             die( __('Invalid options.', 'snpshpwp') );
  1748.         endswitch;
  1749.     }
  1750. endif;
  1751.  
  1752.  
  1753. /*
  1754. * SnapShopWP Blog AJAX
  1755. */
  1756. if ( ! function_exists('snpshpwp_ajaxload_send')) :
  1757. function snpshpwp_ajaxload_send() {
  1758.     $out = '';
  1759.     $post_counter = 0;
  1760.     $add_class = '';
  1761.  
  1762.     $query_string = $_POST['data'];
  1763.     $current_page = snpshpwp_get_between($query_string, 'paged=', '&');
  1764.     $type = $_POST['type'];
  1765.     $page = $_POST['page'];
  1766.     $ajax = $_POST['ajax'];
  1767.     $words = $_POST['excerpt'];
  1768.     $columns = $_POST['columns'];
  1769.     $align = $_POST['align'];
  1770.     $pagination = $_POST['pagination'];
  1771.     $show_category = $_POST['show_category'];
  1772.     $show_date = $_POST['show_date'];
  1773.     $show_author = $_POST['show_author'];
  1774.     $show_comments = $_POST['show_comments'];
  1775.  
  1776.     $format = get_post_format();
  1777.     $image_size = ( get_theme_mod('fimage_override') == 1 && $format !== 'gallery' ? 'full' : 'snpshpwp-fullblog' );
  1778.  
  1779.     $query_string = str_replace('paged='.$current_page.'&', 'paged='.$page.'&', $query_string);
  1780.     $snpshpwp_posts = new WP_Query( $query_string );
  1781.     if ( $snpshpwp_posts->have_posts() ) :
  1782.         $out .= "@@@!SPLIT!@@@<div class='snpshpwp_blog {$type}' data-string='{$query_string}' data-shortcode='{$words}|{$columns}|{$align}|{$pagination}|{$show_category}|{$show_date}|{$show_author}|{$show_comments}'>";
  1783.  
  1784.             $out .= '<div class="snpshpwp_blog_separate anivia_row fbuilder_row"><div>';
  1785.             while( $snpshpwp_posts->have_posts() ): $snpshpwp_posts->the_post();
  1786.  
  1787.                 if ( $add_class !== '' ) $out .= '</div></div><div class="snpshpwp_blog_separate anivia_row fbuilder_row"><div>';
  1788.  
  1789.                 $feat_area = '';
  1790.                 $heading = '';
  1791.                 $post_counter++;
  1792.  
  1793.                 if ( false === $format || $format == 'aside' || $format == 'chat' || $format == 'status' ) {
  1794.                     $format = 'standard';
  1795.                 }
  1796.  
  1797.                 $out .= '<div class="' . implode( ' ', get_post_class() ) . ' snpshpwp_post fbuilder_column fbuilder_column-1-' . $columns . '">';
  1798.  
  1799.                 if ( !strpos($type, 'snpshpwp_type_0') ) {
  1800.                     $feat_area .= snpshpwp_get_featarea( $image_size, $format );
  1801.                 }
  1802.                 else {
  1803.                     $feat_area .= get_the_post_thumbnail( get_the_ID(), 'snpshpwp-square' );
  1804.                 }
  1805.  
  1806.                 if ( $format !== 'quote' ) {
  1807.                     $heading .= '<h3 class="snpshpwp_blog_title"><a href="'.get_permalink().'" rel="bookmark">' . get_the_title() . '</a></h3>';
  1808.                 }
  1809.  
  1810.                 if ( $show_category == 'true' || $show_date == 'true' || $show_author == 'true' || $show_comments == 'true' ) {
  1811.  
  1812.                     $heading .= '<div class="snpshpwp_posts_meta">';
  1813.  
  1814.                     if ( $show_category == 'true' ) {
  1815.                         $heading .= '<div class="snpshpwp_category_meta">'.__('Published in', 'snpshpwp').' '.get_the_category_list( ', ' ).'</div> ';
  1816.                     }
  1817.  
  1818.                     if ( $show_date == 'true' ) {
  1819.                         $timecode = get_the_date();
  1820.                         $heading .= '<div class="snpshpwp_date_meta">'.__('on ').'<a href="'.get_month_link( get_the_time('Y'), get_the_time('m') ).'" title="'.__('View all posts this month', 'snpshpwp').'">'.$timecode.'</a></div> ';
  1821.                     }
  1822.  
  1823.                     if ( $show_author == 'true' ) {
  1824.                         $heading .= '<div class="snpshpwp_author_meta">'.__('by', 'snpshpwp').' '.get_the_author_link().'</div> ';
  1825.                     }
  1826.  
  1827.                     if ( $show_comments == 'true' ) {
  1828.                         $num_comments = get_comments_number();
  1829.                         if ( comments_open() ) {
  1830.                             if ( $num_comments == 0 ) {
  1831.                                 $comments = __('still no comments', 'snpshpwp');
  1832.                             } elseif ( $num_comments > 1 ) {
  1833.                                 $comments = $num_comments . ' ' . __('Comments', 'snpshpwp');
  1834.                             } else {
  1835.                                 $comments = __('1 Comment', 'snpshpwp');
  1836.                             }
  1837.                             $write_comments = __('with', 'snpshpwp') . ' ' . '<a href="' . get_comments_link() .'">'. $comments.'</a>';
  1838.                         } else {
  1839.                             $write_comments =  __('Comments are off for this post.', 'snpshpwp');
  1840.                         }
  1841.                         $heading .= '<div class="snpshpwp_comment_meta">'.$write_comments.'</div>';
  1842.                     }
  1843.  
  1844.                     $heading .= '</div>';
  1845.  
  1846.                 }
  1847.  
  1848.                 $out .= $feat_area . '<div class="snpshpwp_post">' . $heading;
  1849.                 if ( $format !== 'quote' ) {
  1850.                     if ( $words !== '0' ) {
  1851.                         $excerpt = get_the_excerpt();
  1852.                         $out .= '<div class="snpshpwp_excerpt">'.snpshpwp_string_limit_words( $excerpt, $words ).'</div>';
  1853.                     }
  1854.                 }
  1855.  
  1856.                 $out .= '</div><div class="clearfix"></div></div>';
  1857.  
  1858.                 if ( $post_counter == $columns ){
  1859.                     $post_counter = 0;
  1860.                     $add_class = 'new_row';
  1861.                 }
  1862.                 else {
  1863.                     $add_class = '';
  1864.                 }
  1865.             endwhile;
  1866.             $out .= '</div></div>';
  1867.  
  1868.         $out .=  '<div class="clearfix"></div>';
  1869.  
  1870.         $out .= '</div>';
  1871.         if ( $pagination == 'true') $out .= snpshpwp_mini_pagination($snpshpwp_posts->max_num_pages, $page, 3, $ajax, '');
  1872.  
  1873.     endif;
  1874.  
  1875.     die($out);
  1876.     exit;
  1877. }
  1878. endif;
  1879. add_action('wp_ajax_nopriv_snpshpwp_ajaxload_send', 'snpshpwp_ajaxload_send');
  1880. add_action('wp_ajax_snpshpwp_ajaxload_send', 'snpshpwp_ajaxload_send');
  1881.  
  1882.  
  1883. /**
  1884. * Ajax Load WooCommerce Products
  1885. */
  1886. if ( !function_exists('snpshpwp_ajaxload_send_woo') ) :
  1887. function snpshpwp_ajaxload_send_woo() {
  1888.     global $woocommerce, $woocommerce_loop;
  1889.     $query_string = $_POST['data'];
  1890.     $current_page = snpshpwp_get_between($query_string, 'paged=', '&');
  1891.     $page = $_POST['page'];
  1892.     $ajax = $_POST['ajax'];
  1893.     $bot_margin = $_POST['bot_margin'];
  1894.     $columns= $_POST['columns'];
  1895.     $args = str_replace('paged='.$current_page.'&', 'paged='.$page.'&', $query_string);
  1896.    
  1897.     $woocommerce_loop['columns'] = $columns;
  1898.  
  1899.     ob_start();
  1900.  
  1901.     $products = new WP_Query( $args );
  1902.  
  1903.     if ( $products->have_posts() ) : ?>
  1904.  
  1905.         <?php woocommerce_product_loop_start(); ?>
  1906.  
  1907.             <?php while ( $products->have_posts() ) : $products->the_post(); ?>
  1908.  
  1909.  
  1910.                 <?php woocommerce_get_template_part( 'content', 'product' ); ?>
  1911.  
  1912.             <?php endwhile; // end of the loop. ?>
  1913.  
  1914.         <?php woocommerce_product_loop_end(); ?>
  1915.  
  1916.     <?php endif;
  1917.  
  1918.     wp_reset_postdata();
  1919.  
  1920.     die('<div class="woocommerce">' . ob_get_clean() . '</div>'.snpshpwp_mini_woo_pagination($products->max_num_pages, $page, 1, $ajax));
  1921. }
  1922. endif;
  1923. add_action('wp_ajax_nopriv_snpshpwp_ajaxload_send_woo', 'snpshpwp_ajaxload_send_woo');
  1924. add_action('wp_ajax_snpshpwp_ajaxload_send_woo', 'snpshpwp_ajaxload_send_woo');
  1925.  
  1926.  
  1927. /**
  1928. * Ajax Load WooCommerce Categories
  1929. */
  1930. if ( !function_exists('snpshpwp_ajaxload_send_woo_cat') ) :
  1931. function snpshpwp_ajaxload_send_woo_cat() {
  1932.     global $woocommerce, $woocommerce_loop;
  1933.     $current_page = $_POST['page'];
  1934.     $page = $_POST['page'];
  1935.     $ajax = $_POST['ajax'];
  1936.     $bot_margin = $_POST['bot_margin'];
  1937.     $columns= $_POST['columns'];
  1938.     $per_page = $_POST['per_page'];
  1939.     $order = $_POST['order'];
  1940.     $orderby = $_POST['orderby'];
  1941.     $ids = $_POST['ids'];
  1942.     $hide_empty = 1;
  1943.     $parent = '';
  1944.  
  1945.         $ids = explode( ',', $ids );
  1946.         $ids = array_map( 'trim', $ids );
  1947.  
  1948.         $args = array(
  1949.             'orderby'    => $orderby,
  1950.             'order'      => $order,
  1951.             'hide_empty' => 1,
  1952.             'include'    => $ids,
  1953.             'pad_counts' => true,
  1954.             'child_of'   => $parent,
  1955.             'parent'     => '',
  1956.             'offset'     => $per_page*($page-1)
  1957.         );
  1958.  
  1959.         $product_categories = get_terms( 'product_cat', $args );
  1960.         $cat_num = count($product_categories);
  1961.         $product_categories = array_slice( $product_categories, $per_page*($page-1), $per_page );
  1962.  
  1963.         $pagination = snpshpwp_mini_woo_pagination_cat($cat_num, $current_page, $per_page, 'yes');
  1964.  
  1965.         if ( $parent !== "" ) {
  1966.             $product_categories = wp_list_filter( $product_categories, array( 'parent' => $parent ) );
  1967.         }
  1968.  
  1969.         if ( $hide_empty ) {
  1970.             foreach ( $product_categories as $key => $category ) {
  1971.                 if ( $category->count == 0 ) {
  1972.                     unset( $product_categories[ $key ] );
  1973.                 }
  1974.             }
  1975.         }
  1976.  
  1977.         $woocommerce_loop['columns'] = $columns;
  1978.  
  1979.         ob_start();
  1980.  
  1981.         // Reset loop/columns globals when starting a new loop
  1982.         $woocommerce_loop['loop'] = $woocommerce_loop['column'] = '';
  1983.  
  1984.         if ( $product_categories ) {
  1985.  
  1986.             woocommerce_product_loop_start();
  1987.  
  1988.             foreach ( $product_categories as $category ) {
  1989.  
  1990.                 wc_get_template( 'content-product_cat.php', array(
  1991.                     'category' => $category
  1992.                 ) );
  1993.  
  1994.             }
  1995.  
  1996.             woocommerce_product_loop_end();
  1997.  
  1998.         }
  1999.  
  2000.         woocommerce_reset_loop();
  2001.  
  2002.         $shortcode = ob_get_clean();
  2003.  
  2004.     die('<div class="woocommerce">' . $shortcode . '</div>'.snpshpwp_mini_woo_pagination_cat($cat_num, $page, $per_page, 'yes'));
  2005. }
  2006. endif;
  2007. add_action('wp_ajax_nopriv_snpshpwp_ajaxload_send_woo_cat', 'snpshpwp_ajaxload_send_woo_cat');
  2008. add_action('wp_ajax_snpshpwp_ajaxload_send_woo_cat', 'snpshpwp_ajaxload_send_woo_cat');
  2009.  
  2010.  
  2011. /*
  2012. * SnapShopWP Read More Link
  2013. */
  2014. if ( ! function_exists('snpshpwp_remove_more_link')) :
  2015. function snpshpwp_remove_more_link( $link ) {
  2016.     return sprintf('<a href="%1$s" rel="nofollow" class="snpshpwp_read_more block">%2$s</a>', get_permalink(), __('Read More', 'snpshpwp') );
  2017. }
  2018. endif;
  2019. add_filter( 'the_content_more_link', 'snpshpwp_remove_more_link' );
  2020.  
  2021.  
  2022.  
  2023. /*
  2024. * SnapShopWP Footer Elements
  2025. */
  2026. if ( !function_exists( 'snpshpwp_elements' ) ) :
  2027. function snpshpwp_elements($position = '', $location = 'header') {
  2028.     global $snpshpwp_data;
  2029.     foreach ( $snpshpwp_data[$location.'_'.$position]['enabled'] as $n => $t ) :
  2030.     if ( $n == 'placebo' ) continue;
  2031.     printf( '<div class="float_left snpshpwp_element_%1$s">', $n, $position );
  2032.     switch ($n) :
  2033.         case 'login-link':
  2034.             if ( $location == 'header' || $location == 'header_bar' ) {
  2035.                 $registration_enabled = get_option('users_can_register');
  2036.                 if ( $registration_enabled ) {
  2037.                     $class = '';
  2038.                 } else {
  2039.                     $class = ' snpshpwp_disable';
  2040.                 }
  2041.                 if(!is_user_logged_in()) {
  2042.                     echo '<a href="#">'.__('Log in', 'snpshpwp').'</a>';
  2043.                     echo '<div class="snpshpwp_login_element'.$class.'">';
  2044.                     echo '<div class="snpshpwp_login_element_column">';
  2045.                     echo snpshpwp_login_form();
  2046.                     echo '</div>';
  2047.                     echo '<div class="snpshpwp_login_element_column">';
  2048.                     echo snpshpwp_registration_form();
  2049.                     echo '</div>';
  2050.                     echo '<div class="clearfix"></div>';
  2051.                     echo '</div>';
  2052.                 } else {
  2053.                     echo '<a href="' . wp_logout_url( home_url() ) . '" title="Logout">' . __('Logout', 'snpshpwp') . '</a>';
  2054.                 }
  2055.             }
  2056.             else {
  2057.                 wp_loginout();
  2058.             }
  2059.         break;
  2060.         case 'language-bar':
  2061.             $languages = $snpshpwp_data['language'];
  2062.             $first_key = key($languages);
  2063.             printf ( '<a href="#" class="language_selected"><span>%1$s</span><i class="snpshp-wp-down"></i></a><ul>', $languages[$first_key]['language'] );
  2064.                 foreach ( $languages as $language ) {
  2065.                     $flag = $language['flag'];
  2066.                     $lang = $language['language'];
  2067.                     $langurl = $language['langurl'];
  2068.                     printf('<li><a href="%2$s">%1$s</a><img src="%3$s" alt="%4$s" /></li>', $lang, $langurl, get_template_directory_uri().'/images/flags/'.$flag, esc_attr($lang));
  2069.                 }
  2070.             echo '</ul>';
  2071.         break;
  2072.         case 'network-icons':
  2073.             if ( $snpshpwp_data[$location.'_networks'] == 'none' ) {
  2074.                 break;
  2075.             }
  2076.             $networks = $snpshpwp_data['contact'][$snpshpwp_data[$location.'_networks']]['contact'];
  2077.             foreach ( $networks as $network ) {
  2078.                 printf( '<a href="%1$s" class="snpshpwp_social"><img src="%2$s/images/socials/%3$s" alt="%1$s" /></a>', $network['socialnetworksurl'], get_bloginfo ( 'template_directory' ), $network['socialnetworks'], $position );
  2079.             }
  2080.         break;
  2081.         case 'tagline':
  2082.             echo $snpshpwp_data[$location.'_tagline'];
  2083.         break;
  2084.         case 'to-the-top':
  2085.             printf( '<a href="#snpshpwp_wrapper" title="%1$s">%2$s</a>', __('UP!','snpshpwp'), ( $snpshpwp_data['footer_up_text'] !== '' ? $snpshpwp_data['footer_up_text'] : '<i class="snpshp-wp-up"></i>' ) );
  2086.         break;
  2087.         case 'tagline-alt':
  2088.             echo $snpshpwp_data[$location.'_tagline_alt'];
  2089.         break;
  2090.         case 'menu':
  2091.         if ( $snpshpwp_data[$location.'_menu'] !== 'none' ) {
  2092.         ?>
  2093.             <nav class="snpshpwp_nav">
  2094.                 <?php wp_nav_menu( array( 'menu' => $snpshpwp_data[$location.'_menu'], 'depth' => ( $location !== 'footer' ? '4' : '1'), 'fallback_cb' => 'snpshpwp_list_pages', 'container' => false, 'menu_id' => '', 'menu_class' => 'snpshpwp_menu' ) ); ?>
  2095.             </nav>
  2096.         <?php
  2097.             if ( $location == 'header' ) {
  2098.         ?>
  2099.             <a href="#" class="snpshpwp_responsive_trigger" data-position="<?php echo $position; ?>"><i class="snpshp-wp-bars"></i></a>
  2100.         <?php
  2101.             }
  2102.         } else {
  2103.             snpshpwp_list_pages();
  2104.         }
  2105.  
  2106.         break;
  2107.         case 'search':
  2108.         ?>
  2109.             <a id="snpshpwp_srch_trggr" href="#"><i class="snpshp-wp-search"></i></a>
  2110.             <div class="snpshpwp_srch_bx">
  2111.                 <form action="<?php echo home_url( '/' ); ?>" method="get">
  2112.                 <?php
  2113.                     if ( SNPSHPWP_WOOCOMMERCE === true ) {
  2114.                 ?>
  2115.                     <div class="snpshpwp_srch_slct">
  2116.                         <a id="snpshpwp_srch_slct_trggr" href="#" class="snpshpwp_srch_slct_trggr">
  2117.                         <?php
  2118.                             $curr_cats = get_terms( 'product_cat', array( 'hide_empty'=>0) );
  2119.                             if ( isset($_GET['product_cat']) ) {
  2120.                                 $curr_term = get_term_by( 'slug', $_GET['product_cat'], 'product_cat' );
  2121.                                 echo $curr_term->name;
  2122.                             }
  2123.                             else {
  2124.                                 _e('All', 'snpshpwp');
  2125.                             }
  2126.                         ?>
  2127.                         </a>
  2128.                         <ul class="snpshpwp_product_cats">
  2129.                             <li class="snpshpwp_sct_all"><a href="#" data-cat="-1"><?php _e('All', 'snpshpwp'); ?></a></li>
  2130.                         <?php
  2131.                             $curr_cats = get_terms( 'product_cat', array( 'hide_empty'=>0) );
  2132.                             foreach ( $curr_cats as $curr ) {
  2133.                                 printf('<li class="snpshpwp_sct_%2$s"><a href="#" data-cat="%2$s">%1$s</a></li>', $curr->name, $curr->slug, ( isset($_GET['product_cat'] ) && $_GET['product_cat'] == $curr->slug ? ' selected="selected"' : '' ));
  2134.                             }
  2135.                        
  2136.                         ?>
  2137.                         </ul>
  2138.                         <input name="product_cat" type="hidden" value="<?php echo ( isset($_GET['product_cat']) ? $curr_term->slug : '' ); ?>" />
  2139.                     </div>
  2140.                 <?php
  2141.                     }
  2142.                 ?>
  2143.                     <div class="snpshpwp_srch_inpt">
  2144.                         <input class="snpshpwp_inpt" name="s" type="text" value="" placeholder="<?php echo ( SNPSHPWP_WOOCOMMERCE === true ? __('Search products', 'snpshpwp') : __('Search the website', 'snpshpwp') ); ?>" />
  2145.                     </div>
  2146.                     <button type="submit"  class="snpshpwp_srch_sbmt" value="Submit"><i class="snpshp-wp-search"></i></button>
  2147.                     <div class="clearfix"></div>
  2148.                 </form>
  2149.             </div>
  2150.         <?php
  2151.         break;
  2152.         case 'logo':
  2153.             ?>
  2154.             <a href="<?php echo home_url(); ?>" class="snpshpwp_logo" title="<?php esc_attr(bloginfo('description')); ?>">
  2155.                 <img src="<?php echo $snpshpwp_data[$location.'_logo']; ?>" alt="<?php esc_attr(bloginfo('name')); ?>" />
  2156.             </a>
  2157.             <?php
  2158.         break;
  2159.         case 'woo-cart':
  2160.             if ( SNPSHPWP_WOOCOMMERCE === true )
  2161.                 snpshpwp_woocart();
  2162.         break;
  2163.         case 'sidenav':
  2164.             printf('<a id="snpshpwp_sdnv_%1$s" href="#" data-navigation="snpshpwp_sdnv_%1$s_bar" data-position="%1$s"><i class="snpshp-wp-bars"></i></a>', $position);
  2165.         break;
  2166.     endswitch;
  2167.     echo '</div>';
  2168.     endforeach;
  2169. }
  2170. endif;
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.  
  2177. /*
  2178. * SnapShopWP Custom Functions
  2179. */
  2180.  
  2181. // SnapShopWP List Pages
  2182. function snpshpwp_list_pages(){
  2183.     echo '<ul class="snpshpwp_menu">';
  2184.     wp_list_pages( array( 'title_li' => '', 'depth' => '1' ));
  2185.     echo '</ul>';
  2186.     return;
  2187. }
  2188.  
  2189. // SnapShopWP List Pages
  2190. function snpshpwp_add_options_link() {
  2191.     global $wp_admin_bar;
  2192.     $wp_admin_bar -> add_menu( array(
  2193.         'parent' => 'site-name',
  2194.         'id' => 'snpshpwp_options',
  2195.         'title' => __('SnapShop Options', 'snpshpwp'),
  2196.         'href' => admin_url( 'themes.php?page=snpshpwp_options' ),
  2197.         'meta' => false
  2198.     ));
  2199. }
  2200. add_action( 'wp_before_admin_bar_render', 'snpshpwp_add_options_link' );
  2201.  
  2202.  
  2203. // String limit by char
  2204. if ( ! function_exists('snpshpwp_string_limit_words'))
  2205. {
  2206.     function snpshpwp_string_limit_words($str, $n = 500, $end_char = '...')
  2207.     {
  2208.         if ( $n == 0 ) return;
  2209.         if (strlen($str) < $n)
  2210.         {
  2211.             return $str;
  2212.         }
  2213.  
  2214.         $str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str));
  2215.  
  2216.         if (strlen($str) <= $n)
  2217.         {
  2218.             return $str;
  2219.         }
  2220.  
  2221.         $out = "";
  2222.         foreach (explode(' ', trim($str)) as $val)
  2223.         {
  2224.             $out .= $val.' ';
  2225.  
  2226.             if (strlen($out) >= $n)
  2227.             {
  2228.                 $out = trim($out);
  2229.                 return (strlen($out) == strlen($str)) ? $out : $out.$end_char;
  2230.             }
  2231.         }
  2232.     }
  2233. }
  2234.  
  2235. // Hex to RGB
  2236. function snpshpwp_hex2rgb($hex) {
  2237.     $hex = str_replace("#", "", $hex);
  2238.  
  2239.     if(strlen($hex) == 3) {
  2240.         $r = hexdec(substr($hex,0,1).substr($hex,0,1));
  2241.         $g = hexdec(substr($hex,1,1).substr($hex,1,1));
  2242.         $b = hexdec(substr($hex,2,1).substr($hex,2,1));
  2243.     } else {
  2244.         $r = hexdec(substr($hex,0,2));
  2245.         $g = hexdec(substr($hex,2,2));
  2246.         $b = hexdec(substr($hex,4,2));
  2247.     }
  2248.     $rgb = array($r, $g, $b);
  2249.     //return implode(",", $rgb);
  2250.     return $rgb;
  2251. }
  2252.  
  2253. // get_between. string function
  2254. function snpshpwp_get_between($content,$start,$end){
  2255.     $r = explode($start, $content);
  2256.     if (isset($r[1])){
  2257.         $r = explode($end, $r[1]);
  2258.         return $r[0];
  2259.     }
  2260.     return '';
  2261. }
  2262.  
  2263. // snpshpwp_split. split string
  2264. function snpshpwp_split($string,$needle,$nth){
  2265. $max = strlen($string);
  2266. $n = 0;
  2267. for($i=0;$i<$max;$i++){
  2268.     if($string[$i]==$needle){
  2269.         $n++;
  2270.         if($n>=$nth){
  2271.             break;
  2272.         }
  2273.     }
  2274. }
  2275. $arr[] = mb_substr($string,0,$i);
  2276. $arr[] = mb_substr($string,$i+1,$max);
  2277.  
  2278. return $arr;
  2279. }
  2280.  
  2281. // Adds featured images thumbnails
  2282. add_filter( 'manage_posts_columns', 'snpshpwp_posts_columns', 5 );
  2283. add_action( 'manage_posts_custom_column', 'snpshpwp_posts_custom_columns', 5, 2 );
  2284. function snpshpwp_posts_columns( $defaults ) {
  2285.     $defaults['post_thumbs'] = __( 'Featured image', 'snpshpwp' );
  2286.     return $defaults;
  2287. }
  2288. function snpshpwp_posts_custom_columns( $column_name, $id ) {
  2289.     if( $column_name === 'post_thumbs' ) {
  2290.         echo the_post_thumbnail( array( 60, 60 ) );
  2291.     }
  2292. }
  2293.  
  2294.  
  2295. /*
  2296. * Widgets
  2297. */
  2298. include_once('widgets/socialbro/socialbro.php');
  2299. // Tweeter Widget
  2300. class SnapShopWP_Twitter_Widget extends WP_Widget {
  2301.     function SnapShopWP_Twitter_Widget() {
  2302.         $widget_ops = array(
  2303.             'classname' => 'widget-snpshpwp-twitter twitter_module',
  2304.             'description' => __( 'Show your twitter feeds', 'snpshpwp' )
  2305.         );
  2306.         $this->WP_Widget( 'snpshpwp_twitter', '+ SnapShopWP Twitter', $widget_ops );
  2307.     }
  2308.  
  2309.     function widget( $args, $instance ) {
  2310.         extract( $args, EXTR_SKIP );
  2311.         echo $before_widget;
  2312.         $title = empty($instance['title']) ? '' : apply_filters( 'widget_title', $instance['title'] );
  2313.         $user = empty($instance['user']) ? '' : apply_filters( 'widget_user', $instance['user'] );
  2314.         $count = empty($instance['count']) ? '' : apply_filters( 'widget_count', $instance['count'] );
  2315.         if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }
  2316.  
  2317.         echo snpshpwp_twitter_feed( $user, $count );
  2318.         echo $after_widget;
  2319.     }
  2320.  
  2321.     function update( $new_instance, $old_instance ) {
  2322.         $instance = $old_instance;
  2323.         $instance['title'] = strip_tags( $new_instance['title'] );
  2324.         $instance['user'] = strip_tags( $new_instance['user'] );
  2325.         $instance['count'] = strip_tags( $new_instance['count'] );
  2326.         return $instance;
  2327.     }
  2328.  
  2329.     function form( $instance ) {
  2330.         $instance = wp_parse_args(
  2331.         (array) $instance, array(
  2332.             'title' => '',
  2333.             'user' => '',
  2334.             'count' => 5
  2335.         ) );
  2336.         $title = strip_tags( $instance['title'] );
  2337.         $user = strip_tags( $instance['user'] );
  2338.         $count = strip_tags( $instance['count'] );
  2339. ?>
  2340.         <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title', 'snpshpwp' ); ?> :</label>
  2341.         <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>
  2342.         <p><label for="<?php echo $this->get_field_id( 'user' ); ?>"><?php _e( 'User', 'snpshpwp' ); ?> :</label>
  2343.         <input class="widefat" id="<?php echo $this->get_field_id( 'user' ); ?>" name="<?php echo $this->get_field_name( 'user' ); ?>" type="text" value="<?php echo esc_attr( $user ); ?>" /></p>
  2344.         <p><label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _e( 'Count', 'snpshpwp' ); ?> :</label>
  2345.         <input class="widefat" id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>" type="text" value="<?php echo esc_attr( $count ); ?>" /></p>
  2346. <?php }
  2347. }
  2348. add_action( 'widgets_init', create_function('', 'return register_widget("SnapShopWP_Twitter_Widget");' ) );
  2349.  
  2350. // Post widgets
  2351. class SnapShopWP_Categories_Widget extends WP_Widget {
  2352.     function SnapShopWP_Categories_Widget() {
  2353.         $widget_ops = array(
  2354.             'classname' => 'widget-snpshpwp-cat',
  2355.             'description' => __( 'Show category posts', 'snpshpwp') );
  2356.         $this->WP_Widget( 'snpshpwp_category', '+ SnapShopWP Category Posts', $widget_ops );
  2357.     }
  2358.  
  2359.     function widget( $args, $instance ) {
  2360.         extract( $args, EXTR_SKIP );
  2361.         echo $before_widget;
  2362.         $title = empty( $instance['title'] ) ? '' : apply_filters( 'widget_title', $instance['title'] );
  2363.         if ( isset( $instance['order'] ) ) : $order = $instance['order']; else : $order = 'date'; endif;
  2364.         if ( isset( $instance['category'] ) ) : $category = $instance['category']; else : $category = '-1'; endif;
  2365.         if ( isset( $instance['number'] ) ) : $number = $instance['number']; else : $number = '5'; endif;
  2366.         if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }
  2367.         echo '<ul>';
  2368.  
  2369.         $out = '';
  2370.         $query_string = array(
  2371.             'post_type' => 'post',
  2372.             'posts_per_page' => $number,
  2373.             'ignore_sticky_posts' => true,
  2374.             'orderby' => $order
  2375.             );
  2376.         if ( $category !== "-1" ){
  2377.             $query_string = $query_string + array(
  2378.                 'cat' => $category
  2379.                 );
  2380.         }
  2381.  
  2382.         $snpshpwp_posts = new WP_Query( $query_string );
  2383.         if ( $snpshpwp_posts->have_posts() ) :
  2384.             while( $snpshpwp_posts->have_posts() ): $snpshpwp_posts->the_post();
  2385.                 $out .= '<li>';
  2386.  
  2387.                 $out .= '<div class="snpshpwp_dticn"><div class="snpshpwp_dticn_day">'.get_the_time('d').'</div><div class="snpshpwp_dticn_month">'.get_the_time('M').'</div></div>';
  2388.  
  2389.                 $out .= sprintf('<h3><a href="%1$s" title="%2$s">%2$s</a></h3>', get_permalink(), get_the_title() );
  2390.  
  2391.                 $num_comments = get_comments_number();
  2392.                 if ( comments_open() ) {
  2393.                     if ( $num_comments == 0 ) {
  2394.                         $comments = __('Leave a comment', 'division');
  2395.                     } elseif ( $num_comments > 1 ) {
  2396.                         $comments = $num_comments . __(' Comments', 'division');
  2397.                     } else {
  2398.                         $comments = __('1 Comment', 'division');
  2399.                     }
  2400.                     $write_comments = '<a href="' . get_comments_link() .'">'. $comments.'</a>';
  2401.                 } else {
  2402.                     $write_comments =  __('Comments are off for this post.', 'division');
  2403.                 }
  2404.  
  2405.                 $out .= sprintf('<div class="snpshpwp_blog_comments">%1$s</div>', $write_comments );
  2406.                 $out .= '<div class="clearfix"></div>';
  2407.  
  2408.                 $out .= '</li>';
  2409.             endwhile;
  2410.         endif;
  2411.         wp_reset_query();
  2412.         echo $out;
  2413.  
  2414.         echo '</ul>';
  2415.         echo $after_widget;
  2416.     }
  2417.    
  2418.     function update( $new_instance, $old_instance ) {
  2419.         $instance = $old_instance;
  2420.         $instance['title'] = strip_tags( $new_instance['title'] );
  2421.         $instance['order'] = strip_tags( $new_instance['order'] );
  2422.         $instance['category'] = strip_tags( $new_instance['category'] );
  2423.         $instance['number'] = strip_tags( $new_instance['number'] );
  2424.        
  2425.         return $instance;
  2426.     }
  2427.    
  2428.     function form( $instance ) {
  2429.         $instance = wp_parse_args(
  2430.         (array) $instance, array(
  2431.             'title' => '',
  2432.             'order' => 'date',
  2433.             'category' => '34',
  2434.             'number' => '5'
  2435.         ) );
  2436.         $title = strip_tags( $instance['title'] );
  2437.         $number = strip_tags( $instance['number'] ); ?>
  2438.         <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title', 'snpshpwp' ); ?> : <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
  2439.         <p><label for="<?php echo $this->get_field_id('order'); ?>"><?php _e( 'Order', 'snpshpwp' ); ?> : <select id="<?php echo $this->get_field_id('order'); ?>" name="<?php echo $this->get_field_name('order'); ?>">
  2440.         <option value="date" <?php $selected = ( $instance['order'] === 'date') ? 'selected = "selected"' : ''; echo $selected; ?>><?php _e('Recent', 'snpshpwp'); ?></option>
  2441.         <option value="comment_count" <?php $selected = ( $instance['order'] === 'comment_count') ? 'selected = "selected"' : ''; echo $selected; ?>><?php _e('Popular', 'snpshpwp'); ?></option>
  2442.         <option value="rand" <?php $selected = ( $instance['order'] === 'rand') ? 'selected = "selected"' : ''; echo $selected; ?>><?php _e('Random', 'snpshpwp'); ?></option>
  2443.         <option value="author" <?php $selected = ( $instance['order'] === 'author') ? 'selected = "selected"' : ''; echo $selected; ?>><?php _e('Author', 'snpshpwp'); ?></option>
  2444.         <option value="title" <?php $selected = ( $instance['order'] === 'title') ? 'selected = "selected"' : ''; echo $selected; ?>><?php _e('Title', 'snpshpwp'); ?></option>
  2445.         </select></label></p>  
  2446.         <p><label for="<?php echo $this->get_field_id('category'); ?>"><?php _e( 'Category', 'snpshpwp' ); wp_dropdown_categories('show_option_none=All&show_count=1&orderby=name&echo=1&name='.$this->get_field_name('category').'&id='.$this->get_field_id('category').'&selected='. $instance['category'] .'');?></label></p>
  2447.         <p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e( 'Number of posts to display', 'snpshpwp' ); ?> : <input class="widefat" id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" /></label></p>
  2448. <?php
  2449.     }
  2450. }
  2451. add_action( 'widgets_init', create_function('', 'return register_widget("SnapShopWP_Categories_Widget");' ) );
  2452.  
  2453.  
  2454. // Twitter OAuth helper function
  2455. function getConnectionWithAccessToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) {
  2456.     $connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret);
  2457.     return $connection;
  2458. }
  2459.  
  2460. /*
  2461. * Twitter Feed
  2462. */
  2463. if ( !function_exists('snpshpwp_twitter_feed') ) :
  2464. function snpshpwp_twitter_feed($user = 'twitter', $count = '5'){
  2465.     $transient_key = $user . "_twitter_" . $count;
  2466.     $cached = get_transient( $transient_key );
  2467.  
  2468.     if ( false !== $cached ) {
  2469.         return $cached .= "\n" . '<!-- Returned from cache -->';
  2470.     }
  2471.  
  2472.     global $snpshpwp_data;
  2473.     $output = '';
  2474.     $i = 1;
  2475.  
  2476.     $twitteruser = $user;
  2477.     $notweets = $count;
  2478.  
  2479.     $consumerkey = $snpshpwp_data['twitter_ck'];
  2480.     $consumersecret = $snpshpwp_data['twitter_cs'];
  2481.     $accesstoken = $snpshpwp_data['twitter_at'];
  2482.     $accesstokensecret = $snpshpwp_data['twitter_ats'];
  2483.  
  2484.     $connection = getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);
  2485.     $tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser."&count=".$notweets);
  2486.     $data = json_decode( json_encode($tweets) );
  2487.     if ( is_array( $data ) ) :
  2488.     $output .= '<ul class="tweets-list list_null">';
  2489.     while ( $i <= $count ) {
  2490.         if( isset( $data[$i-1] ) ) {
  2491.             $feed = $data[( $i - 1 )]->text;
  2492.             $feed = str_pad( $feed, 3, ' ', STR_PAD_LEFT );
  2493.             $startat = stripos( $feed, '@' );
  2494.             $numat = substr_count( $feed, '@' );
  2495.             $numhash = substr_count( $feed, '#' );
  2496.             $numhttp = substr_count( $feed, 'http' );
  2497.             $feed = preg_replace( "#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $feed );
  2498.             $feed = preg_replace( "#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $feed );
  2499.             $feed = preg_replace( "/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $feed );
  2500.             $feed = preg_replace( "/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=\\1\" target=\"_blank\">#\\1</a>", $feed );
  2501.             $output .= sprintf('
  2502.             <li class="relative"><a href="http://www.twitter.com/%3$s" title="%4$s" target="_blank"><i class="snpshp-wp-twitter-alt"></i> <span class="snpshpwp_twauthor">%3$s</span> <span class="snpshpwp_twdate snpshpwp_sfont snpshpwp_theme_col">%2$s</span></a><div class="tweet-post padding-left48">%1$s</div></li>', $feed, snpshpwp_time_ago( strtotime( $data[($i-1)]->created_at ) ), $user, __('Visit us on twitter.com', 'snpshpwp') );
  2503.         }
  2504.         $i++;
  2505.     }
  2506.     $output .= '</ul>';
  2507.     set_transient( $transient_key, $output, 1800 );
  2508.     set_transient( $transient_key.'_backup', $output );
  2509.     return $output;
  2510.     else :
  2511.     $cached = get_transient( $transient_key.'_backup' );
  2512.     if ( false !== $cached ) {
  2513.         return $cached .= "\n" . '<!-- Returned from backup cache -->';
  2514.     }
  2515.     else {
  2516.         return __('Twitter unaviable', 'snpshpwp');
  2517.     }
  2518.     endif;
  2519. }
  2520. endif;
  2521.  
  2522.  
  2523. /*
  2524.  * Time Ago
  2525. */
  2526. if ( !function_exists('snpshpwp_time_ago') ) :
  2527. function snpshpwp_time_ago($date) {
  2528.     $chunks = array(
  2529.         array( 60 * 60 * 24 * 365 , __( 'year', 'snpshpwp' ), __( 'years', 'snpshpwp' ) ),
  2530.         array( 60 * 60 * 24 * 30 , __( 'month', 'snpshpwp' ), __( 'months', 'snpshpwp' ) ),
  2531.         array( 60 * 60 * 24 * 7, __( 'week', 'snpshpwp' ), __( 'weeks', 'snpshpwp' ) ),
  2532.         array( 60 * 60 * 24 , __( 'day', 'snpshpwp' ), __( 'days', 'snpshpwp' ) ),
  2533.         array( 60 * 60 , __( 'hour', 'snpshpwp' ), __( 'hours', 'snpshpwp' ) ),
  2534.         array( 60 , __( 'minute', 'snpshpwp' ), __( 'minutes', 'snpshpwp' ) ),
  2535.         array( 1, __( 'second', 'snpshpwp' ), __( 'seconds', 'snpshpwp' ) )
  2536.     );
  2537.     if ( !is_numeric( $date ) ) {
  2538.         $time_chunks = explode( ':', str_replace( ' ', ':', $date ) );
  2539.         $date_chunks = explode( '-', str_replace( ' ', '-', $date ) );
  2540.         $date = gmmktime( (int)$time_chunks[1], (int)$time_chunks[2], (int)$time_chunks[3], (int)$date_chunks[1], (int)$date_chunks[2], (int)$date_chunks[0] );
  2541.     }
  2542.     $current_time = current_time( 'mysql', $gmt = 0 );
  2543.     $newer_date = strtotime( $current_time );
  2544.     $since = $newer_date - $date;
  2545.     if ( 0 > $since )
  2546.         return __( 'sometime', 'snpshpwp' );
  2547.     for ( $i = 0, $j = count($chunks); $i < $j; $i++) {
  2548.         $seconds = $chunks[$i][0];
  2549.         if ( ( $count = floor($since / $seconds) ) != 0 )
  2550.             break;
  2551.     }
  2552.     $output = ( 1 == $count ) ? '1 <span class="text-ago">'. $chunks[$i][1] : $count . ' <span class="text-ago">' . $chunks[$i][2];
  2553.     if ( !(int)trim($output) ){
  2554.         $output = '0' . __( 'seconds', 'snpshpwp' );
  2555.     }
  2556.     $output .= __(' ago', 'snpshpwp').'</span>';
  2557.     return $output;
  2558. }
  2559. endif;
  2560.  
  2561.  
  2562. /*
  2563.  * Contact Form
  2564. */
  2565. if ( !function_exists('snpshpwp_contact_form') ) :
  2566. function snpshpwp_contact_form( $users = '1', $margin = ' style="margin-bottom:20px"' ) {
  2567.     global $snpshpwp_data, $snpshpwp_contact_form_id;
  2568.  
  2569.     if ( isset( $snpshpwp_data['contact'] ) ) $contact_options = $snpshpwp_data['contact'];
  2570.     if ( isset ( $snpshpwp_contact_form_id ) == false ) {
  2571.         global $snpshpwp_contact_form_id;
  2572.         $snpshpwp_contact_form_id = 1;
  2573.     }
  2574.     if( isset( $_POST['submitted-' . $snpshpwp_contact_form_id] ) ) {
  2575.         if( trim( $_POST['contactCaptcha'] ) === ''  ) {
  2576.             $captchaError = '<small>' . __( 'Please try again. Thank you!', 'darkone' ) . '</small>';
  2577.             $hasError = true;
  2578.         }
  2579.         elseif ( intval( $_POST['contactCaptcha'] ) !== intval( $_POST['contactCaptchaHid'] ) ) {
  2580.             $captchaError = '<small>' . __( 'Please try again. Thank you!', 'darkone' ) . '</small>';
  2581.             $hasError = true;
  2582.         }
  2583.         if( trim( $_POST['contactName'] ) === '' ) {
  2584.             $nameError = '<small>' . __( 'Please enter your name', 'snpshpwp' ) . '</small>';
  2585.             $hasError = true;
  2586.         } else {
  2587.             $name = wp_strip_all_tags(trim( $_POST['contactName'] ));
  2588.         }
  2589.         if( trim( $_POST['contactEmail'] ) === '' ) {
  2590.             $emailError = '<small>' . __( 'Please enter your email address', 'snpshpwp' ) . '</small>';
  2591.             $hasError = true;
  2592.         } else if ( !preg_match( "/^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$/i", trim( $_POST['contactEmail'] ) ) ) {
  2593.             $emailError = '<small>' . __('You entered an invalid email address', 'snpshpwp') . '</small>';
  2594.             $hasError = true;
  2595.         } else {
  2596.             $email = trim( $_POST['contactEmail'] );
  2597.         }
  2598.         if( trim( $_POST['contactWebsite'] ) !== '' ) {
  2599.             $website = esc_url(trim( $_POST['contactWebsite'] ));
  2600.         }
  2601.         if( trim( $_POST['commentsText'] ) === '' ) {
  2602.             $commentError = '<small>' . __( 'Please enter a message', 'snpshpwp' ) . '</small>';
  2603.             $hasError = true;
  2604.         } else {
  2605.             if ( function_exists( 'stripslashes' ) ) {
  2606.                 $comments = wp_strip_all_tags(stripslashes( trim( $_POST['commentsText'] ) ));
  2607.             } else {
  2608.                 $comments = wp_strip_all_tags(trim( $_POST['commentsText'] ));
  2609.             }
  2610.         }
  2611.         if ( !isset( $hasError ) ) {
  2612.         if ( $_POST['contactEmailSend'] == 'main' ) : $emailTo = $snpshpwp_data['main_contact']['email']; else : $emailTo = $contact_options[$_POST['contactEmailSend']]['email']; endif;
  2613.             $subject = get_bloginfo('name').' / From ' . $name;
  2614.             $body = "Name: $name \n\nEmail: $email \n\nWebsite: $website \n\nComments: $comments";
  2615.             $headers = 'From: ' . $name . ' <' . $emailTo . '>' . "\r\n" . 'Reply-To: ' . $email;
  2616.             wp_mail( $emailTo, $subject, $body, $headers );
  2617.             $emailSent = true;
  2618.         }
  2619.     }
  2620.     $output = '';
  2621.     $contactName = '';
  2622.     $contactEmail = '';
  2623.     $contactWebsite = '';
  2624.     $commentsText = '';
  2625.  
  2626.     $output .= sprintf( '<div class="contact_form_wrapper"%1$s>', $margin );
  2627.     if( isset( $emailSent ) && $emailSent == true ) {
  2628.         if ( $snpshpwp_data['contactform_message'] == '' ) {
  2629.             $output .= '<div class="success"><img src="'.$snpshpwp_data['logo'].'"/>'. __( 'Thanks, your email was sent successfully!', 'snpshpwp' ).'</div>';
  2630.         }
  2631.         else $output .= $snpshpwp_data['contactform_message'];
  2632.     }
  2633.     else {
  2634.  
  2635.         $permlink = get_permalink();
  2636.         if( isset( $hasError ) ) {
  2637.             $output .= '<span class="error send block"><small>! '.__( 'Sorry, an error occured', 'snpshpwp' ).'</small></span>';
  2638.         }
  2639.         $output .= sprintf( '<form action="%1$s#snpshpwp_cform" id="snpshpwp_cform" class="comment_form contact_form" method="post">', $permlink );
  2640.  
  2641.         $output .= '<div class="input_wrapper_select margin-bottom20">';
  2642.  
  2643.         if ( $snpshpwp_data['contact'] ) :
  2644.             $i = 1;
  2645.             $users_array = explode( ',', $users );
  2646.             if ( !is_array ( $users_array ) ) { $users_array[] = $users; }
  2647.             $curr_count = count($users_array);
  2648.             $output .= '<div><select name="contactEmailSend" class="input_field_select block" '.( $curr_count == 1 ? 'disabled' : '' ).'>';
  2649.  
  2650.             foreach ( $contact_options as $option ) {
  2651.                 if ( in_array ( $i, $users_array ) ) { $output .= '<option value="'. $i .'">'. $option['name'] .'</option>'; }
  2652.                 $i++;
  2653.             }
  2654.         $output .= '</select></div>';
  2655.         endif;
  2656.  
  2657.         $output .= '</div>';
  2658.  
  2659.         if ( isset( $_POST['contactEmail'] ) ) $contactEmail = esc_attr($_POST['contactEmail']);
  2660.  
  2661.         $output .= '<div class="input_wrapper">';
  2662.         if( isset( $emailError ) ) {
  2663.             $output .= '<span class="error block margin_alter">! '. $emailError .'</span>';
  2664.         }
  2665.         $output .= sprintf('<input type="text" name="contactEmail" class="input_field block margin-bottom20" value="%1$s" placeholder="%2$s"/>', $contactEmail, __('EMAIL ADDRESS', 'snpshpwp') );
  2666.  
  2667.         $output .= '</div>';
  2668.  
  2669.         if ( isset( $_POST['contactName'] ) ) $contactName = esc_attr($_POST['contactName']);
  2670.  
  2671.         $output .= '<div class="input_wrapper">';
  2672.         if( isset( $nameError ) ) {
  2673.             $output .= '<span class="error block">! '. $nameError .'</span>';
  2674.         }
  2675.         $output .= sprintf('<input type="text" name="contactName" class="input_field block margin-bottom20" value="%1$s" placeholder="%2$s"/>', $contactName, __('NAME', 'snpshpwp') );
  2676.  
  2677.         $output .= '</div>';
  2678.  
  2679.         if ( isset( $_POST['contactWebsite'] ) ) $contactWebsite = esc_url($_POST['contactWebsite']);
  2680.  
  2681.         $output .= '<div class="input_wrapper">';
  2682.         if( isset( $nameError ) ) {
  2683.             $output .= '<span class="error block">!</span>';
  2684.         }
  2685.         $output .= sprintf('<input type="text" name="contactWebsite" class="input_field block margin-bottom20" value="%1$s" placeholder="%2$s"/>', $contactWebsite, __('WEBSITE', 'snpshpwp') );
  2686.         $output .= '</div>';
  2687.  
  2688.         if( isset( $_POST['commentsText'] ) ) { if ( function_exists( 'stripslashes' ) ) { $commentsText = wp_strip_all_tags(stripslashes( $_POST['commentsText'] )); } else { $commentsText = wp_strip_all_tags($_POST['commentsText']); } }
  2689.  
  2690.         $output .= '<textarea name="commentsText" class="textarea_field block margin-bottom20"  placeholder="'.__('MESSAGE GOES HERE (MAX 300 CHARS)', 'snpshpwp').'">'. $commentsText .'</textarea>';
  2691.         if( isset( $commentError ) ) {
  2692.             $output .= '<span class="error block">! '. $commentError .'</span>';
  2693.         }
  2694.  
  2695.         $output .= '<input type="hidden" name="submitted-'. $snpshpwp_contact_form_id .'" value="true" />';
  2696.         $output .= '<div class="snpshpwp_captcha_wrap float_left">';
  2697.         $rand = rand(0,10);
  2698.         $rand2 = rand(0,10);
  2699.         $output .= '<p class="float_left">'.$rand.' + '.$rand2.' =</p>';
  2700.         $output .= '<div class="input_wrapper snpshpwp_captcha">';
  2701.        
  2702.         $output .= '<input name="contactCaptcha" class="snpshpwp_button block bg_color_default bg_color_main_hover color_white float_left" type="text" value="" />';
  2703.         $output .= '<input name="contactCaptchaHid" class="snpshpwp_button block bg_color_default bg_color_main_hover color_white float_left" type="hidden" value="'. ($rand + $rand2).'" />';
  2704.        
  2705.         $output .= '</div></div>';
  2706.         $output .= '<input class="snpshpwp_button block bg_color_default bg_color_main_hover color_white float_right" type="submit" value="'.__('Send Email', 'snpshpwp').'" />';
  2707.         $output .= '<div class="clearfix"></div>';
  2708.         if( isset( $captchaError ) ) {
  2709.             $output .= '<span class="error block">! '. $captchaError .'</span>';
  2710.         }
  2711.         $output .= '</form>';
  2712.  
  2713.     }
  2714.     $output .= '</div>';
  2715.     $snpshpwp_contact_form_id++;
  2716.     return $output;
  2717. }
  2718. endif;
  2719.  
  2720.  
  2721. /**
  2722.  * Get content with formatting
  2723. */
  2724. if ( !function_exists('get_the_content_with_formatting') ) :
  2725. function get_the_content_with_formatting ($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
  2726.     $content = get_the_content($more_link_text, $stripteaser, $more_file);
  2727.     $content = apply_filters('the_content', $content);
  2728.     $content = str_replace(']]>', ']]&gt;', $content);
  2729.     return $content;
  2730. }
  2731. endif;
  2732.  
  2733.  
  2734. /**
  2735.  * Custom excerpt lenght
  2736. */
  2737. if ( !function_exists('custom_excerpt_length') ) :
  2738. function custom_excerpt_length( $length ) {
  2739.     return 999;
  2740. }
  2741. endif;
  2742. add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
  2743.  
  2744.  
  2745. /**
  2746.  * Time difference
  2747. */
  2748. if ( !function_exists('time_difference') ) :
  2749. function time_difference($time_diff) {
  2750.     $args = array(
  2751.         'posts_per_page'   => 1,
  2752.         'offset'           => 0,
  2753.         'orderby'          => 'date',
  2754.         'order'            => 'ASC',
  2755.         'post_type'        => 'post',
  2756.         'post_status'      => 'publish',
  2757.         'suppress_filters' => true
  2758.     );
  2759.     $first_post = get_posts($args);
  2760.  
  2761.     $date = $first_post[0]->post_date_gmt;
  2762.  
  2763.     $chunks = array(
  2764.         'years' => array( 60 * 60 * 24 * 365 ),
  2765.         'months' => array( 60 * 60 * 24 * 30 ),
  2766.         'weeks' => array( 60 * 60 * 24 * 7 ),
  2767.         'days' => array( 60 * 60 * 24 )
  2768.     );
  2769.    
  2770.    
  2771.     if ( !is_numeric( $date ) ) {
  2772.         $time_chunks = explode( ':', str_replace( ' ', ':', $date ) );
  2773.         $date_chunks = explode( '-', str_replace( ' ', '-', $date ) );
  2774.         $date = gmmktime( (int)$time_chunks[1], (int)$time_chunks[2], (int)$time_chunks[3], (int)$date_chunks[1], (int)$date_chunks[2], (int)$date_chunks[0] );
  2775.     }
  2776.     $current_time = current_time( 'mysql', $gmt = 0 );
  2777.  
  2778.     $newer_date = strtotime( $current_time );
  2779.     $since = $newer_date - $date;
  2780.     if ( 0 > $since )
  2781.         return __( 'sometime', 'snpshpwp' );
  2782.        
  2783.     $seconds = $chunks[$time_diff][0];
  2784.     $count = floor($since / $seconds);
  2785.  
  2786.     $output = ( 1 == $count ) ? '1' : $count;
  2787.  
  2788.     return $output;
  2789.  
  2790. }
  2791. endif;
  2792.  
  2793. /**
  2794.  * Posts metaboxes
  2795.  */
  2796. add_action( 'load-post.php', 'snpshpwp_page_meta_boxes_setup' );
  2797. add_action( 'load-post-new.php', 'snpshpwp_page_meta_boxes_setup' );
  2798.  
  2799.  
  2800. /**
  2801.  * Post Types
  2802. */
  2803. if ( !function_exists('snpshpwp_page_meta_boxes_setup') ) :
  2804. function snpshpwp_page_meta_boxes_setup() {
  2805.     add_action( 'add_meta_boxes', 'snpshpwp_add_page_meta_boxes' );
  2806.     add_action( 'save_post', 'snpshpwp_save_page_meta_boxes', 10, 2 );
  2807. }
  2808. endif;
  2809.  
  2810.  
  2811. /**
  2812.  * Post Types
  2813. */
  2814. if ( !function_exists('snpshpwp_add_page_meta_boxes') ) :
  2815. function snpshpwp_add_page_meta_boxes() {
  2816.     add_meta_box(
  2817.         'snpshpwp-revolution',
  2818.         esc_html__( 'SnapShopWP Full Width Revolution Slider', 'snpshpwp' ),
  2819.         'snpshpwp_revolution',
  2820.         'page',
  2821.         'normal',
  2822.         'high'
  2823.     );
  2824.  
  2825.     add_meta_box(
  2826.         'snpshpwp-page-options',
  2827.         esc_html__( 'SnapShopWP Page Options', 'snpshpwp' ),
  2828.         'snpshpwp_page_options',
  2829.         'page',
  2830.         'side',
  2831.         'default'
  2832.     );
  2833.  
  2834.     add_meta_box(
  2835.         'snpshpwp-post-options',
  2836.         esc_html__( 'SnapShopWP Post Options', 'snpshpwp' ),
  2837.         'snpshpwp_post_options',
  2838.         'post',
  2839.         'side',
  2840.         'default'
  2841.     );
  2842.  
  2843.     add_meta_box(
  2844.         'snpshpwp-post-type',
  2845.         __('SnapShopWP Post Type Settings', 'snpshpwp'),
  2846.         'snpshpwp_post_type',
  2847.         'post',
  2848.         'side',
  2849.         'default'
  2850.     );
  2851. }
  2852. endif;
  2853.  
  2854.  
  2855. /**
  2856.  * Post Types
  2857. */
  2858. if ( !function_exists('snpshpwp_post_type') ) :
  2859. function snpshpwp_post_type( $object, $box ) { ?>
  2860.     <p>
  2861.         <h4><?php _e('Video', 'snpshpwp'); ?></h4>
  2862.         <label for="snpshpwp-video-override"><?php _e( "Set featured area video embed (MP4)", 'snpshpwp' ); ?></label>
  2863.         <br />
  2864.         <textarea class="widefat" type="text" name="snpshpwp-video-override" id="snpshpwp-video-override"><?php echo esc_attr( get_post_meta( $object->ID, 'snpshpwp_video_override', true ) ); ?></textarea>
  2865.     </p>
  2866.     <p>
  2867.         <label for="snpshpwp-video-override"><?php _e( "Set featured area video embed (OGG)", 'snpshpwp' ); ?></label>
  2868.         <br />
  2869.         <textarea class="widefat" type="text" name="snpshpwp-video-override-ogg" id="snpshpwp-video-override-ogg"><?php echo esc_attr( get_post_meta( $object->ID, 'snpshpwp_video_override_ogg', true ) ); ?></textarea>
  2870.     </p>
  2871.     <p>
  2872.         <label for="snpshpwp-video-override"><?php _e( "Set featured area video embed from site", 'snpshpwp' ); ?></label>
  2873.         <br />
  2874.         <textarea class="widefat" type="text" name="snpshpwp-video-override-site" id="snpshpwp-video-override-site"><?php echo esc_attr( get_post_meta( $object->ID, 'snpshpwp_video_override_site', true ) ); ?></textarea>
  2875.     </p>
  2876.     <p>
  2877.         <h4><?php _e('Audio', 'snpshpwp'); ?></h4>
  2878.         <label for="snpshpwp-audio-override"><?php _e( "Set featured area audio embed", 'snpshpwp' ); ?></label>
  2879.         <br />
  2880.         <textarea class="widefat" type="text" name="snpshpwp-audio-override" id="snpshpwp-audio-override"><?php echo esc_attr( get_post_meta( $object->ID, 'snpshpwp_audio_override', true ) ); ?></textarea>
  2881.     </p>
  2882.     <p>
  2883.         <label for="snpshpwp-audio-override"><?php _e( "Set featured area audio embed (ogg)", 'snpshpwp' ); ?></label>
  2884.         <br />
  2885.         <textarea class="widefat" type="text" name="snpshpwp-audio-override-ogg" id="snpshpwp-audio-override-ogg"><?php echo esc_attr( get_post_meta( $object->ID, 'snpshpwp_audio_override_ogg', true ) ); ?></textarea>
  2886.     </p>
  2887.     <p>
  2888.         <label for="snpshpwp-audio-override"><?php _e( "Set featured area audio embed from site", 'snpshpwp' ); ?></label>
  2889.         <br />
  2890.         <textarea class="widefat" type="text" name="snpshpwp-audio-override-site" id="snpshpwp-audio-override-site"><?php echo esc_attr( get_post_meta( $object->ID, 'snpshpwp_audio_override_site', true ) ); ?></textarea>
  2891.     </p>
  2892.     <p>
  2893.         <h4><?php _e('Gallery', 'snpshpwp'); ?></h4>
  2894.         <label for="snpshpwp-gallery-override"><?php _e( "Override default post gallery", 'snpshpwp' ); ?></label>
  2895.         <br />
  2896.         <textarea class="widefat" type="text" name="snpshpwp-gallery-override" id="snpshpwp-gallery-override"><?php echo esc_attr( get_post_meta( $object->ID, 'snpshpwp_gallery_override', true ) ); ?></textarea>
  2897.     </p>
  2898.     <p>
  2899.         <h4><?php _e('Link', 'snpshpwp'); ?></h4>
  2900.         <label for="snpshpwp-link-override"><?php _e( "Set featured area link", 'snpshpwp' ); ?></label>
  2901.         <br />
  2902.         <textarea class="widefat" type="text" name="snpshpwp-link-override" id="snpshpwp-link-override"><?php echo esc_attr( get_post_meta( $object->ID, 'snpshpwp_link_override', true ) ); ?></textarea>
  2903.     </p>
  2904. <?php }
  2905. endif;
  2906.  
  2907.  
  2908. /**
  2909.  * Revolution Slider Metabox
  2910. */
  2911. if ( !function_exists('snpshpwp_revolution') ) :
  2912. function snpshpwp_revolution( $object, $box ) { ?>
  2913.     <?php wp_nonce_field( basename( __FILE__ ), 'snpshpwp_nonce' ); ?>
  2914.     <?php
  2915.         if ( in_array( 'revslider/revslider.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
  2916.             global $wpdb;
  2917.             $revsliders = array( 'none' );
  2918.             $current = get_post_meta( $object->ID, 'snpshpwp_revolution', true );
  2919.             if ( $current == '' ) {
  2920.                 $current = 'none';
  2921.             }
  2922.             $get_sliders = $wpdb->get_results('SELECT * FROM '.$wpdb->prefix.'revslider_sliders');
  2923.             if($get_sliders) {
  2924.                 foreach($get_sliders as $slider) {
  2925.                     $revsliders[$slider->alias] = $slider->alias;
  2926.                 }
  2927.             }
  2928.             else {
  2929.                 $revsliders = array ( 'none' => 'none' );
  2930.             }
  2931.         }
  2932.         else {
  2933.             $revsliders = array ( 'none' => 'none' );
  2934.         }
  2935.     ?>
  2936.     <p>
  2937.         <label for="snpshpwp-revolution"><?php _e( "Select Revolution Slider template to use one this page. This slider will be shown just bellow main navigation in full width.", 'snpshpwp' ); ?></label>
  2938.         <br /><br />
  2939.         <select name="snpshpwp-revolution" id="snpshpwp-revolution">
  2940.         <?php
  2941.             foreach ( $revsliders as $slider ) :
  2942.                 printf( '<option value="%1$s" %2$s>%1$s</option>', $slider, ( ( $slider == $current ) ? 'selected' : '' ) );
  2943.             endforeach;
  2944.         ?>
  2945.         </select>
  2946.     </p>
  2947. <?php }
  2948.  
  2949. function snpshpwp_page_options( $object, $box ) {
  2950.     global $snpshpwp_data;
  2951. ?>
  2952.     <p>
  2953.         <label for="snpshpwp-page-title"><input value="" type="checkbox" name="snpshpwp-page-title" id="snpshpwp-page-title" <?php if ( 1 == get_post_meta( $object->ID, 'snpshpwp_page_title', true ) ) echo 'checked="checked"'; ?>> <?php _e( "Remove page title", 'snpshpwp' ); ?></label>
  2954.     </p>
  2955.     <p>
  2956.         <label for="snpshpwp-breadcrumbs"><input value="" type="checkbox" name="snpshpwp-breadcrumbs" id="snpshpwp-breadcrumbs" <?php if ( 1 == get_post_meta( $object->ID, 'snpshpwp_breadcrumbs', true ) ) echo 'checked="checked"'; ?>> <?php _e( "Remove breadcrumbs", 'snpshpwp' ); ?></label>
  2957.     </p>
  2958.     <p>
  2959.         <label for="snpshpwp-padding"><input value="" type="checkbox" name="snpshpwp-padding" id="snpshpwp-padding" <?php if ( 1 == get_post_meta( $object->ID, 'snpshpwp_padding', true ) ) echo 'checked="checked"'; ?>> <?php _e( "Remove page padding", 'snpshpwp' ); ?></label>
  2960.     </p>
  2961.     <p>
  2962.         <label for="snpshpwp-sidebar-hide"><input value="" type="checkbox" name="snpshpwp-sidebar-hide" id="snpshpwp-sidebar-hide" <?php if ( 1 == get_post_meta( $object->ID, 'snpshpwp_sidebar_hide', true ) ) echo 'checked="checked"'; ?>> <?php _e( "Hide sidebar", 'snpshpwp' ); ?></label>
  2963.     </p>
  2964.     <p>
  2965.         <?php
  2966.             $snpshpwp_ready_sidebars = array( 'none' => 'none' );
  2967.             if ( isset($snpshpwp_data['sidebar']) ) {
  2968.                 $snpshpwp_sidebars = $snpshpwp_data['sidebar'];
  2969.                 foreach ( $snpshpwp_sidebars as $sidebar ) {
  2970.                     $snpshpwp_ready_sidebars = $snpshpwp_ready_sidebars + array(sanitize_title( $sidebar['title'] ) => $sidebar['title']);
  2971.                 }
  2972.             }
  2973.         ?>
  2974.         <label for="snpshpwp-sidebar-override"><?php _e( "Override sidebar", 'snpshpwp' ); ?></label>
  2975.         <br /><br />
  2976.         <select name="snpshpwp-sidebar-override" id="snpshpwp-sidebar-override">
  2977.         <?php
  2978.             foreach ( $snpshpwp_ready_sidebars as $sidebar ) :
  2979.                 printf( '<option value="%1$s" %2$s>%1$s</option>', $sidebar, ( ( $sidebar == $current ) ? 'selected' : '' ) );
  2980.             endforeach;
  2981.         ?>
  2982.         </select>
  2983.     </p>
  2984.     <p>
  2985.         <hr/>
  2986.         <?php _e('Override default page background', 'snpshpwp'); ?>
  2987.     </p>
  2988.     <p>
  2989.         <label for="snpshpwp-page-bg"><?php _e( "Select background type", 'snpshpwp' ); ?> :</label>
  2990.         <?php
  2991.             $feat_areas = array (
  2992.                     'none' => __('None', 'snpshpwp'),
  2993.                     'html5video' => __('HTML5 Video', 'snpshpwp'),
  2994.                     'videoembed' => __('Youtube Video Embed', 'snpshpwp')
  2995.                 );
  2996.             $current = get_post_meta( $object->ID, 'snpshpwp_page_bg', true );
  2997.             if ( $current == '' ) {
  2998.                 $current = 'none';
  2999.             }
  3000.             foreach ( $feat_areas as $s => $v ) :
  3001.         ?>
  3002.         <br />
  3003.         <input type="radio" name="snpshpwp-page-bg" id="snpshpwp-page-bg" value="<?php echo $s; ?>" <?php echo ( ( $s == $current ) ? 'checked' : '' ); ?>/> <?php echo $v; ?>
  3004.         <?php endforeach; ?>
  3005.     </p>
  3006.     <p>
  3007.         <label for="snpshpwp-pagevideo-mp4"><?php _e( "Enter video URL (MP4) / HTML5 Video.", 'snpshpwp' ); ?></label>
  3008.         <br />
  3009.         <textarea class="widefat" type="text" name="snpshpwp-pagevideo-mp4" id="snpshpwp-pagevideo-mp4"><?php echo esc_attr( get_post_meta( $object->ID, 'snpshpwp_pagevideo_mp4', true ) ); ?></textarea>
  3010.     </p>
  3011.     <p>
  3012.         <label for="snpshpwp-pagevideo-ogv"><?php _e( "Enter video URL (OGV) / HTML5 Video.", 'snpshpwp' ); ?></label>
  3013.         <br />
  3014.         <textarea class="widefat" type="text" name="snpshpwp-pagevideo-ogv" id="snpshpwp-pagevideo-ogv"><?php echo esc_attr( get_post_meta( $object->ID, 'snpshpwp_pagevideo_ogv', true ) ); ?></textarea>
  3015.     </p>
  3016.     <p>
  3017.         <label for="snpshpwp-pagevideo-embed"><?php _e( "Enter Youtube Video ID / Youtube Embed.", 'snpshpwp' ); ?></label>
  3018.         <br />
  3019.         <input class="widefat" type="text" name="snpshpwp-pagevideo-embed" id="snpshpwp-pagevideo-embed" value="<?php echo esc_attr( get_post_meta( $object->ID, 'snpshpwp_pagevideo_embed', true ) ); ?>" / >
  3020.     </p>
  3021.     <?php
  3022.         $mute = get_post_meta( $object->ID, 'snpshpwp_pagevideo_embed_mute', true );
  3023.     ?>
  3024.     <p>
  3025.         <label for="snpshpwp-pagevideo-embed-mute"><input value="" type="checkbox" name="snpshpwp-pagevideo-embed-mute" id="snpshpwp-pagevideo-embed-mute" <?php if ( 1 == $mute ) echo 'checked="checked"'; ?>> <?php _e( "Mute Youtube Video", 'snpshpwp' ); ?></label>
  3026.     </p>
  3027.     <?php
  3028.         $loop = get_post_meta( $object->ID, 'snpshpwp_pagevideo_embed_loop', true );
  3029.     ?>
  3030.     <p>
  3031.         <label for="snpshpwp-pagevideo-embed-loop"><input value="" type="checkbox" name="snpshpwp-pagevideo-embed-loop" id="snpshpwp-pagevideo-embed-loop" <?php if ( 1 == $loop ) echo 'checked="checked"'; ?>> <?php _e( "Loop Youtube Video", 'snpshpwp' ); ?></label>
  3032.     </p>
  3033.     <?php
  3034.         $hd = get_post_meta( $object->ID, 'snpshpwp_pagevideo_embed_hd', true );
  3035.     ?>
  3036.     <p>
  3037.         <label for="snpshpwp-pagevideo-embed-hd"><input value="" type="checkbox" name="snpshpwp-pagevideo-embed-hd" id="snpshpwp-pagevideo-embed-hd" <?php if ( 1 == $hd ) echo 'checked="checked"'; ?>> <?php _e( "HD Youtube Video", 'snpshpwp' ); ?></label>
  3038.     </p>
  3039. <?php
  3040. }
  3041. endif;
  3042.  
  3043. /**
  3044.  * Revolution Post Options
  3045. */
  3046. if ( !function_exists('snpshpwp_post_options') ) :
  3047. function snpshpwp_post_options( $object, $box ) {
  3048.     global $snpshpwp_data;
  3049.     ?>
  3050.     <?php wp_nonce_field( basename( __FILE__ ), 'snpshpwp_nonce' ); ?>
  3051.     <?php
  3052.         $hide_feat = get_post_meta( $object->ID, 'snpshpwp_hide_featarea', true );
  3053.         $hide_feat = ( $hide_feat == '' ? $snpshpwp_data['snpshpwp_hide_featarea'] : $hide_feat );
  3054.     ?>
  3055.     <p>
  3056.         <label for="snpshpwp-hide-featarea"><input value="" type="checkbox" name="snpshpwp-hide-featarea" id="snpshpwp-hide-featarea" <?php if ( 1 == $hide_feat ) echo 'checked="checked"'; ?>> <?php _e( "Hide featured area", 'snpshpwp' ); ?></label>
  3057.     </p>
  3058.     <?php
  3059.         $hide_title = get_post_meta( $object->ID, 'snpshpwp_hide_title', true );
  3060.         $hide_title = ( $hide_title == '' ? $snpshpwp_data['snpshpwp_hide_title'] : $hide_title );
  3061.     ?>
  3062.     <p>
  3063.         <label for="snpshpwp-hide-title"><input value="" type="checkbox" name="snpshpwp-hide-title" id="snpshpwp-hide-title" <?php if ( 1 == $hide_title ) echo 'checked="checked"'; ?>> <?php _e( "Hide title", 'snpshpwp' ); ?></label>
  3064.     </p>
  3065.  
  3066.     <?php
  3067.         $hide_tags = get_post_meta( $object->ID, 'snpshpwp_hide_tags', true );
  3068.         $hide_tags = ( $hide_tags == '' ? $snpshpwp_data['snpshpwp_hide_tags'] : $hide_tags );
  3069.     ?>
  3070.     <p>
  3071.         <label for="snpshpwp-hide-tags"><input value="" type="checkbox" name="snpshpwp-hide-tags" id="snpshpwp-hide-tags" <?php if ( 1 == $hide_tags ) echo 'checked="checked"'; ?>> <?php _e( "Hide tags", 'snpshpwp' ); ?></label>
  3072.     </p>
  3073.  
  3074.     <?php
  3075.         $hide_related_main = get_post_meta( $object->ID, 'snpshpwp_hide_related_main', true );
  3076.         $hide_related_main = ( $hide_related_main == '' ? $snpshpwp_data['snpshpwp_hide_related_main'] : $hide_related_main );
  3077.     ?>
  3078.     <p>
  3079.         <label for="snpshpwp-hide-related-main"><input value="" type="checkbox" name="snpshpwp-hide-related-main" id="snpshpwp-hide-related-main" <?php if ( 1 == $hide_related_main ) echo 'checked="checked"'; ?>> <?php _e( "Hide related posts", 'snpshpwp' ); ?></label>
  3080.     </p>
  3081.  
  3082.     <?php
  3083.         $hide_meta = get_post_meta( $object->ID, 'snpshpwp_hide_meta', true );
  3084.         $hide_meta = ( $hide_meta == '' ? $snpshpwp_data['snpshpwp_hide_meta'] : $hide_meta );
  3085.     ?>
  3086.     <p>
  3087.         <label for="snpshpwp-hide-meta"><input value="" type="checkbox" name="snpshpwp-hide-meta" id="snpshpwp-hide-meta" <?php if ( 1 == $hide_meta ) echo 'checked="checked"'; ?>> <?php _e( "Hide postmeta", 'snpshpwp' ); ?></label>
  3088.     </p>
  3089.  
  3090.     <?php
  3091.         $hide_author = get_post_meta( $object->ID, 'snpshpwp_hide_author', true );
  3092.         $hide_author = ( $hide_author == '' ? $snpshpwp_data['snpshpwp_hide_author'] : $hide_author );
  3093.     ?>
  3094.     <p>
  3095.         <label for="snpshpwp-hide-author"><input value="" type="checkbox" name="snpshpwp-hide-author" id="snpshpwp-hide-author" <?php if ( 1 == $hide_author ) echo 'checked="checked"'; ?>> <?php _e( "Hide sidebar author", 'snpshpwp' ); ?></label>
  3096.     </p>
  3097.  
  3098.     <?php
  3099.         $hide_postmeta = get_post_meta( $object->ID, 'snpshpwp_hide_postmeta', true );
  3100.         $hide_postmeta = ( $hide_postmeta == '' ? $snpshpwp_data['snpshpwp_hide_postmeta'] : $hide_postmeta );
  3101.     ?>
  3102.     <p>
  3103.         <label for="snpshpwp-hide-postmeta"><input value="" type="checkbox" name="snpshpwp-hide-postmeta" id="snpshpwp-hide-postmeta" <?php if ( 1 == $hide_postmeta ) echo 'checked="checked"'; ?>> <?php _e( "Hide sidebar post meta", 'snpshpwp' ); ?></label>
  3104.     </p>
  3105.  
  3106.     <?php
  3107.         $hide_share = get_post_meta( $object->ID, 'snpshpwp_hide_share', true );
  3108.         $hide_share = ( $hide_share == '' ? $snpshpwp_data['snpshpwp_hide_share'] : $hide_share );
  3109.     ?>
  3110.     <p>
  3111.         <label for="snpshpwp-hide-share"><input value="" type="checkbox" name="snpshpwp-hide-share" id="snpshpwp-hide-share" <?php if ( 1 == $hide_share ) echo 'checked="checked"'; ?>> <?php _e( "Hide sidebar social share", 'snpshpwp' ); ?></label>
  3112.     </p>
  3113.  
  3114.     <?php
  3115.         $hide_related_side = get_post_meta( $object->ID, 'snpshpwp_hide_related_side', true );
  3116.         $hide_related_side = ( $hide_related_side == '' ? $snpshpwp_data['snpshpwp_hide_related_side'] : $hide_related_side );
  3117.     ?>
  3118.     <p>
  3119.         <label for="snpshpwp-hide-related-side"><input value="" type="checkbox" name="snpshpwp-hide-related-side" id="snpshpwp-hide-related-side" <?php if ( 1 == $hide_related_side ) echo 'checked="checked"'; ?>> <?php _e( "Hide sidebar related posts", 'snpshpwp' ); ?></label>
  3120.     </p>
  3121.     <hr/>
  3122.     <p>
  3123.         <label for="snpshpwp-padding"><input value="" type="checkbox" name="snpshpwp-padding" id="snpshpwp-padding" <?php if ( 1 == get_post_meta( $object->ID, 'snpshpwp_padding', true ) ) echo 'checked="checked"'; ?>> <?php _e( "Remove padding", 'snpshpwp' ); ?></label>
  3124.     </p>
  3125.     <p>
  3126.         <label for="snpshpwp-breadcrumbs"><input value="" type="checkbox" name="snpshpwp-breadcrumbs" id="snpshpwp-breadcrumbs" <?php if ( 1 == get_post_meta( $object->ID, 'snpshpwp_breadcrumbs', true ) ) echo 'checked="checked"'; ?>> <?php _e( "Remove breadcrumbs", 'snpshpwp' ); ?></label>
  3127.     </p>
  3128.     <p>
  3129.         <label for="snpshpwp-sidebar-hide"><input value="" type="checkbox" name="snpshpwp-sidebar-hide" id="snpshpwp-sidebar-hide" <?php if ( 1 == get_post_meta( $object->ID, 'snpshpwp_sidebar_hide', true ) ) echo 'checked="checked"'; ?>> <?php _e( "Hide sidebar", 'snpshpwp' ); ?></label>
  3130.     </p>
  3131.     <p>
  3132.         <?php
  3133.             $snpshpwp_ready_sidebars = array( 'none' => 'none' );
  3134.             if ( isset($snpshpwp_data['sidebar']) ) {
  3135.                 $snpshpwp_sidebars = $snpshpwp_data['sidebar'];
  3136.                 foreach ( $snpshpwp_sidebars as $sidebar ) {
  3137.                     $snpshpwp_ready_sidebars = $snpshpwp_ready_sidebars + array(sanitize_title( $sidebar['title'] ) => $sidebar['title']);
  3138.                 }
  3139.             }
  3140.         ?>
  3141.         <label for="snpshpwp-sidebar-override"><?php _e( "Override sidebar", 'snpshpwp' ); ?></label>
  3142.         <br /><br />
  3143.         <select name="snpshpwp-sidebar-override" id="snpshpwp-sidebar-override">
  3144.         <?php
  3145.             $current = get_post_meta( $object->ID, 'snpshpwp_sidebar_override', true );
  3146.             foreach ( $snpshpwp_ready_sidebars as $sidebar ) :
  3147.                 printf( '<option value="%1$s" %2$s>%1$s</option>', $sidebar, ( ( $sidebar == $current ) ? 'selected' : '' ) );
  3148.             endforeach;
  3149.         ?>
  3150.         </select>
  3151.     </p>
  3152. <?php }
  3153. endif;
  3154.  
  3155.  
  3156. /**
  3157.  * Save Metaboxes
  3158. */
  3159. if ( !function_exists('snpshpwp_save_page_meta_boxes') ) :
  3160. function snpshpwp_save_page_meta_boxes( $post_id, $post ) {
  3161.  
  3162.     if ( !isset( $_POST['snpshpwp_nonce'] ) || !wp_verify_nonce( $_POST['snpshpwp_nonce'], basename( __FILE__ ) ) )
  3163.         return $post_id;
  3164.  
  3165.     $post_type = get_post_type_object( $post->post_type );
  3166.  
  3167.     if ( !current_user_can( $post_type->cap->edit_post, $post_id ) )
  3168.         return $post_id;
  3169.  
  3170.     $new_meta_values = array();
  3171.  
  3172.     $new_meta_values[] = ( isset( $_POST['snpshpwp-revolution'] ) ? $_POST['snpshpwp-revolution'] : '' );
  3173.     $new_meta_values[] = ( isset( $_POST['snpshpwp-padding'] ) ? 1 : 'no' );
  3174.     $new_meta_values[] = ( isset( $_POST['snpshpwp-page-title'] ) ? 1 : 'no' );
  3175.     $new_meta_values[] = ( isset( $_POST['snpshpwp-breadcrumbs'] ) ? 1 : 'no' );
  3176.     $new_meta_values[] = ( isset( $_POST['snpshpwp-hide-featarea'] ) ? 1 : 'no' );
  3177.     $new_meta_values[] = ( isset( $_POST['snpshpwp-hide-title'] ) ? 1 : 'no' );
  3178.     $new_meta_values[] = ( isset( $_POST['snpshpwp-hide-tags'] ) ? 1 : 'no' );
  3179.     $new_meta_values[] = ( isset( $_POST['snpshpwp-hide-related-main'] ) ? 1 : 'no' );
  3180.     $new_meta_values[] = ( isset( $_POST['snpshpwp-hide-meta'] ) ? 1 : 'no' );
  3181.     $new_meta_values[] = ( isset( $_POST['snpshpwp-hide-author'] ) ? 1 : 'no' );
  3182.     $new_meta_values[] = ( isset( $_POST['snpshpwp-hide-postmeta'] ) ? 1 : 'no' );
  3183.     $new_meta_values[] = ( isset( $_POST['snpshpwp-hide-share'] ) ? 1 : 'no' );
  3184.     $new_meta_values[] = ( isset( $_POST['snpshpwp-hide-related-side'] ) ? 1 : 'no' );
  3185.     $new_meta_values[] = ( isset( $_POST['snpshpwp-sidebar-hide'] ) ? 1 : 'no' );
  3186.     $new_meta_values[] = ( isset( $_POST['snpshpwp-sidebar-override'] ) ? $_POST['snpshpwp-sidebar-override'] : '' );
  3187.     $new_meta_values[] = ( isset( $_POST['snpshpwp-video-override'] ) ? $_POST['snpshpwp-video-override'] : '' );
  3188.     $new_meta_values[] = ( isset( $_POST['snpshpwp-video-override-ogg'] ) ? $_POST['snpshpwp-video-override-ogg'] : '' );
  3189.     $new_meta_values[] = ( isset( $_POST['snpshpwp-video-override-site'] ) ? $_POST['snpshpwp-video-override-site'] : '' );
  3190.     $new_meta_values[] = ( isset( $_POST['snpshpwp-audio-override'] ) ? $_POST['snpshpwp-audio-override'] : '' );
  3191.     $new_meta_values[] = ( isset( $_POST['snpshpwp-audio-override-ogg'] ) ? $_POST['snpshpwp-audio-override-ogg'] : '' );
  3192.     $new_meta_values[] = ( isset( $_POST['snpshpwp-audio-override-site'] ) ? $_POST['snpshpwp-audio-override-site'] : '' );
  3193.     $new_meta_values[] = ( isset( $_POST['snpshpwp-gallery-override'] ) ? $_POST['snpshpwp-gallery-override'] : '' );
  3194.     $new_meta_values[] = ( isset( $_POST['snpshpwp-link-override'] ) ? $_POST['snpshpwp-link-override'] : '' );
  3195.     $new_meta_values[] = ( isset( $_POST['snpshpwp-page-bg'] ) ? $_POST['snpshpwp-page-bg'] : '' );
  3196.     $new_meta_values[] = ( isset( $_POST['snpshpwp-pagevideo-mp4'] ) ? $_POST['snpshpwp-pagevideo-mp4'] : '' );
  3197.     $new_meta_values[] = ( isset( $_POST['snpshpwp-pagevideo-ogv'] ) ? $_POST['snpshpwp-pagevideo-ogv'] : '' );
  3198.     $new_meta_values[] = ( isset( $_POST['snpshpwp-pagevideo-embed'] ) ? $_POST['snpshpwp-pagevideo-embed'] : '' );
  3199.     $new_meta_values[] = ( isset( $_POST['snpshpwp-pagevideo-embed-mute'] ) ? 1 : 'no' );
  3200.     $new_meta_values[] = ( isset( $_POST['snpshpwp-pagevideo-embed-loop'] ) ? 1 : 'no' );
  3201.     $new_meta_values[] = ( isset( $_POST['snpshpwp-pagevideo-embed-hd'] ) ? 1 : 'no' );
  3202.  
  3203.     $meta_keys = array();
  3204.     $meta_keys[] = 'snpshpwp_revolution';
  3205.     $meta_keys[] = 'snpshpwp_padding';
  3206.     $meta_keys[] = 'snpshpwp_page_title';
  3207.     $meta_keys[] = 'snpshpwp_breadcrumbs';
  3208.     $meta_keys[] = 'snpshpwp_hide_featarea';
  3209.     $meta_keys[] = 'snpshpwp_hide_title';
  3210.     $meta_keys[] = 'snpshpwp_hide_tags';
  3211.     $meta_keys[] = 'snpshpwp_hide_related_main';
  3212.     $meta_keys[] = 'snpshpwp_hide_meta';
  3213.     $meta_keys[] = 'snpshpwp_hide_author';
  3214.     $meta_keys[] = 'snpshpwp_hide_postmeta';
  3215.     $meta_keys[] = 'snpshpwp_hide_share';
  3216.     $meta_keys[] = 'snpshpwp_hide_related_side';
  3217.     $meta_keys[] = 'snpshpwp_sidebar_hide';
  3218.     $meta_keys[] = 'snpshpwp_sidebar_override';
  3219.     $meta_keys[] = 'snpshpwp_video_override';
  3220.     $meta_keys[] = 'snpshpwp_video_override_ogg';
  3221.     $meta_keys[] = 'snpshpwp_video_override_site';
  3222.     $meta_keys[] = 'snpshpwp_audio_override';
  3223.     $meta_keys[] = 'snpshpwp_audio_override_ogg';
  3224.     $meta_keys[] = 'snpshpwp_audio_override_site';
  3225.     $meta_keys[] = 'snpshpwp_gallery_override';
  3226.     $meta_keys[] = 'snpshpwp_link_override';
  3227.     $meta_keys[] = 'snpshpwp_page_bg';
  3228.     $meta_keys[] = 'snpshpwp_pagevideo_mp4';
  3229.     $meta_keys[] = 'snpshpwp_pagevideo_ogv';
  3230.     $meta_keys[] = 'snpshpwp_pagevideo_embed';
  3231.     $meta_keys[] = 'snpshpwp_pagevideo_embed_mute';
  3232.     $meta_keys[] = 'snpshpwp_pagevideo_embed_loop';
  3233.     $meta_keys[] = 'snpshpwp_pagevideo_embed_hd';
  3234.  
  3235.     $meta_values = array();
  3236.  
  3237.     $i = 0;
  3238.  
  3239.     foreach ( $meta_keys as $meta_key ) {
  3240.        
  3241.         $meta_value = get_post_meta( $post_id, $meta_key, true );
  3242.        
  3243.         if ( $new_meta_values[$i] && '' == $meta_value )
  3244.             add_post_meta( $post_id, $meta_key, $new_meta_values[$i], true );
  3245.  
  3246.         elseif ( $new_meta_values[$i] && $new_meta_values[$i] != $meta_value )
  3247.             update_post_meta( $post_id, $meta_key, $new_meta_values[$i] );
  3248.  
  3249.         elseif ( '' == $new_meta_values[$i] && $meta_value )
  3250.             delete_post_meta( $post_id, $meta_key, $meta_value );
  3251.  
  3252.         $i++;
  3253.  
  3254.     }
  3255.  
  3256. }
  3257. endif;
  3258.  
  3259. /**
  3260.  * Get Featured Area
  3261. */
  3262. if ( !function_exists('snpshpwp_get_featarea') ) :
  3263. function snpshpwp_get_featarea( $feat_type )
  3264. {
  3265.     $type = get_post_format();
  3266.  
  3267.     $html = '';
  3268.     if($type != '')
  3269.     {
  3270.     $result;
  3271.  
  3272.     switch ($type) {
  3273.         case 'audio':
  3274.             $snpshpwp_audio_override = get_post_meta(get_the_ID(),'snpshpwp_audio_override',true);
  3275.             $snpshpwp_audio_override_ogg = get_post_meta(get_the_ID(),'snpshpwp_audio_override_ogg',true);
  3276.             $snpshpwp_audio_override_site = get_post_meta(get_the_ID(),'snpshpwp_audio_override_site',true);
  3277.                 if( ( $snpshpwp_audio_override !== '' ) || ( $snpshpwp_audio_override_ogg !== '' )) {
  3278.                     $add_poster = ( has_post_thumbnail() ? wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), $feat_type ) : '' );
  3279.                     $html = '<div class="snpshpwp_div_featarea snpshpwp_div_feat_'.$type.'">';
  3280.                     $html .= sprintf('<audio class="fullwidth block" preload="auto" loop="loop" controls%4$s>
  3281.                                 <source src="%1$s" type="audio/mpeg">
  3282.                                 <source src="%2$s" type="audio/ogg">
  3283.                                  %3$s
  3284.                             </audio>',$snpshpwp_audio_override,$snpshpwp_audio_override_ogg, __( 'Your browser does not support the audio tag.', 'snpshpwp' ), ( $add_poster !== '' ? ' poster="'.$add_poster[0].'"  data-image-replacement="'.$add_poster[0].'"' : ''));
  3285.                     }
  3286.                 else if ($snpshpwp_audio_override_site !== 'none' || $snpshpwp_audio_override_site !== '') {
  3287.                     $html = '<div class="snpshpwp_div_featarea snpshpwp_div_feat_'.$type.'">';
  3288.                     $html .= sprintf('%1$s',$snpshpwp_audio_override_site);
  3289.                 }
  3290.             break;
  3291.        
  3292.         case 'gallery':
  3293.             if ( SNPSHPWP_FBUILDER === true ) :
  3294.  
  3295.             if ( $feat_type == 'large' ) {
  3296.                 $feat_type = 'snpshpwp-fullblog';
  3297.             }
  3298.  
  3299.             $old_gallery_shortcode = get_post_meta(get_the_ID(),'snpshpwp_gallery_override',true);
  3300.             $shortcode = '[fbuilder_slider ';
  3301.             $ctype = 'ctype="';
  3302.             $image_url = 'image="';
  3303.             $image_link = 'image_link="';
  3304.             $image_link_type = 'image_link_type="';
  3305.             $shortcode_html = 'html="';
  3306.             $text_align = 'text_align="';
  3307.             $back_color = 'back_color="';
  3308.             $text_color = 'text_color="';
  3309.             $randId = rand();
  3310.             $html = '<div class="snpshpwp_div_featarea snpshpwp_div_feat_'.$type.' fbuilder_module" data-modid="'.$randId.'">';
  3311.             if( $old_gallery_shortcode != '' ) {
  3312.                 $old_gallery_shortcode = explode(' ',$old_gallery_shortcode);
  3313.                 $old_ids;
  3314.                 $num = count($old_gallery_shortcode);
  3315.                 for($i=0; $i<count($old_gallery_shortcode); $i++ ) {
  3316.                     $old_gallery_shortcode[$i] = explode('="',$old_gallery_shortcode[$i]);
  3317.                 }
  3318.                 $num = count($old_gallery_shortcode);
  3319.                 for($i=0; $i<count($old_gallery_shortcode); $i++ ) {
  3320.                     if($old_gallery_shortcode[$i][0] == 'ids')
  3321.                         $old_ids = explode(',',$old_gallery_shortcode[$i][1]);
  3322.                 }
  3323.                 $i = 0;
  3324.                 $last_id = explode('"',$old_ids[count($old_ids)-1]);
  3325.                 $old_ids[count($old_ids)-1] = $last_id[0];
  3326.                 $num_of_images = count($old_ids);
  3327.                 foreach ($old_ids as $old_id) {
  3328.                     $i++;
  3329.                     $ctype .= 'image';
  3330.                     $result = wp_get_attachment_image_src( intval($old_id), $feat_type);
  3331.                     $image_url .= sprintf('%1$s',$result[0]);
  3332.                     $shortcode_html .= '';
  3333.                     $text_align .= '';
  3334.                     $back_color .= '';
  3335.                     $text_color .= '';
  3336.                     if ($i<$num_of_images) {
  3337.                         $ctype .= '|';
  3338.                         $image_url .= '|';
  3339.                         $image_link .= '|';
  3340.                         $image_link_type .= '|';
  3341.                         $shortcode_html .= '|';
  3342.                         $text_align .= '|';
  3343.                         $back_color .= '|';
  3344.                         $text_color .= '|';
  3345.                     }
  3346.                     else {
  3347.                         $ctype .= '" ';
  3348.                         $image_url .= '" ';
  3349.                         $image_link .= '" ';
  3350.                         $image_link_type .= '" ';
  3351.                         $shortcode_html .= '" ';
  3352.                         $text_align .= '" ';
  3353.                         $back_color .= '" ';
  3354.                         $text_color .= '" ';
  3355.                     }
  3356.                 }
  3357.             }
  3358.             else if ( !empty($images) ){
  3359.                 $i = 0;
  3360.            
  3361.                 $images = get_attached_media( 'image' );
  3362.                 $num_of_images = count($images);
  3363.                 if ( !is_array($images) ) break;
  3364.                 $html = '<div class="snpshpwp_div_featarea snpshpwp_div_feat_'.$type.'fbuilder_module" data-modid="'.$randId.'">';
  3365.                 foreach ($images as $image) {
  3366.                     $i++;
  3367.                     $ctype .= 'image';
  3368.                     $result = wp_get_attachment_image_src( $image->ID, $feat_type);
  3369.                     $image_url .= sprintf('%1$s',$result[0]);
  3370.                     $image_link .= sprintf('%1$s|',$result[0]);
  3371.                     $image_link_type .= 'lightbox-image';
  3372.                     $shortcode_html .= '';
  3373.                     $text_align .= '';
  3374.                     $back_color .= '';
  3375.                     $text_color .= '';
  3376.                     if($i<$num_of_images) {
  3377.                         $ctype .= '|';
  3378.                         $image_url .= '|';
  3379.                         $image_link .= '|';
  3380.                         $image_link_type .= '|';
  3381.                         $shortcode_html .= '|';
  3382.                         $text_align .= '|';
  3383.                         $back_color .= '|';
  3384.                         $text_color .= '|';
  3385.                     }
  3386.                     else {
  3387.                         $ctype .= '" ';
  3388.                         $image_url .= '" ';
  3389.                         $image_link .= '" ';
  3390.                         $image_link_type .= '" ';
  3391.                         $shortcode_html .= '" ';
  3392.                         $text_align .= '" ';
  3393.                         $back_color .= '" ';
  3394.                         $text_color .= '" ';
  3395.                     }
  3396.                 }
  3397.             }
  3398.             $shortcode .= sprintf('%1$s %2$s %3$s %4$s %5$s %6$s %7$s %8$s auto_play="false" bot_margin=0 navigation="squared" pagination="false"][/fbuilder_slider]', $ctype, $image_url, $image_link, $image_link_type, $shortcode_html, $text_align, $back_color, $text_color);
  3399.             $html .= do_shortcode($shortcode);
  3400.  
  3401.         endif;
  3402.  
  3403.         break;
  3404.        
  3405.         case 'image':
  3406.  
  3407.             if ( has_post_thumbnail() ) {
  3408.                 $html = '<div class="snpshpwp_div_featarea snpshpwp_div_feat_'.$type.'">';
  3409.                 $html .= get_the_post_thumbnail(get_the_ID(),$feat_type);
  3410.             }
  3411.         break;
  3412.  
  3413.         case 'video':
  3414.             $snpshpwp_video_override = get_post_meta(get_the_ID(),'snpshpwp_video_override',true);
  3415.             $snpshpwp_video_override_ogg = get_post_meta(get_the_ID(),'snpshpwp_video_override_ogg',true);
  3416.             $snpshpwp_video_override_site = get_post_meta(get_the_ID(),'snpshpwp_video_override_site',true);
  3417.             if( ( $snpshpwp_video_override !== '' ) || ( $snpshpwp_video_override_ogg !== '' ) ) {
  3418.                 $add_poster = ( has_post_thumbnail() ? wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), $feat_type ) : '' );
  3419.                 $html = '<div class="snpshpwp_div_featarea snpshpwp_div_feat_'.$type.'">';
  3420.                 $html .= sprintf('<div class="video"><video class="fullwidth block" preload="auto" loop="loop" controls%4$s>
  3421.                                 <source src="%1$s" type="video/mp4">
  3422.                                 <source src="%2$s" type="video/ogg">
  3423.                                 %3$s
  3424.                         </video></div>',$snpshpwp_video_override,$snpshpwp_video_override_ogg, __( 'Your browser does not support the video tag.', 'snpshpwp' ), ( $add_poster !== '' ? ' poster="'.$add_poster[0].'"  data-image-replacement="'.$add_poster[0].'"' : ''));
  3425.                
  3426.             }
  3427.             else if ( $snpshpwp_video_override_site !== '' ) {
  3428.                 $html = '<div class="snpshpwp_div_featarea snpshpwp_div_feat_'.$type.'">';
  3429.                 $html .= sprintf('%1$s', $snpshpwp_video_override_site);
  3430.             }
  3431.         break;
  3432.         case 'link':
  3433.             $result = get_post_meta(get_the_ID(),'snpshpwp_link_override',true);
  3434.             if($result !== 'none' && $result !== '') {
  3435.                 $html = '<div class="snpshpwp_div_featarea snpshpwp_div_feat_link">';
  3436.                 $html .= sprintf( '<a href="%2$s" class="snpshpwp_image_hover_button" rel="bookmark">%1$s</a>', get_the_post_thumbnail(get_the_ID(),$feat_type), $result );
  3437.             }
  3438.         break;
  3439.         case 'quote':
  3440.             $html = '<div class="snpshpwp_div_featarea snpshpwp_div_feat_quote snpshpwp_header_font">';
  3441.             $html .= sprintf( '%1$s', get_the_content() );
  3442.         break;
  3443.         default:
  3444.             if ( has_post_thumbnail() ) {
  3445.                 $html = '<div class="snpshpwp_div_featarea snpshpwp_div_feat_'.$type.'">';
  3446.                 $html .= get_the_post_thumbnail(get_the_ID(),$feat_type);
  3447.             }
  3448.         break;
  3449.     }
  3450.     }
  3451.     else {
  3452.             if ( has_post_thumbnail() ) {
  3453.                 $html = '<div class="snpshpwp_div_featarea snpshpwp_div_feat_image">';
  3454.                 $html .= sprintf( '<a href="%1$s" class="snpshpwp_image">%2$s</a>', get_permalink(),  get_the_post_thumbnail(get_the_ID(),$feat_type) );
  3455.             }
  3456.            
  3457.     }
  3458.     if($html !== '')
  3459.         $html .= '</div>';
  3460.     return $html;
  3461. }
  3462. endif;
  3463.  
  3464.  
  3465. // Add Standard Post Type
  3466. function snpshpwp_query_format_standard($query) {
  3467.     if (isset($query->query_vars['post_format']) &&
  3468.         $query->query_vars['post_format'] == 'post-format-standard') {
  3469.         if (($post_formats = get_theme_support('post-formats')) &&
  3470.             is_array($post_formats[0]) && count($post_formats[0])) {
  3471.             $terms = array();
  3472.             foreach ($post_formats[0] as $format) {
  3473.                 $terms[] = 'post-format-'.$format;
  3474.             }
  3475.             $query->is_tax = null;
  3476.             unset($query->query_vars['post_format']);
  3477.             unset($query->query_vars['taxonomy']);
  3478.             unset($query->query_vars['term']);
  3479.             unset($query->query['post_format']);
  3480.             $query->set('tax_query', array(
  3481.                 'relation' => 'AND',
  3482.                 array(
  3483.                     'taxonomy' => 'post_format',
  3484.                     'terms' => $terms,
  3485.                     'field' => 'slug',
  3486.                     'operator' => 'NOT IN'
  3487.                 )
  3488.             ));
  3489.         }
  3490.     }
  3491. }
  3492. add_action('pre_get_posts', 'snpshpwp_query_format_standard');
  3493.  
  3494. /**
  3495.  * SNAPSHOP Search Filter
  3496. */
  3497. add_action( 'pre_get_posts', 'snpshpwp_search_filter' );
  3498. if ( !function_exists('snpshpwp_search_filter') ) :
  3499. function snpshpwp_search_filter( $query ) {
  3500. /*  if ( is_search() && !isset($_GET['post_type']) && $query->is_main_query() )
  3501.         $query->set( 'post_type', array( 'post', 'page' ) );
  3502.     return $query;*/
  3503. }
  3504. endif;
  3505.  
  3506.  
  3507. if ( SNPSHPWP_FBUILDER === true ) {
  3508.     /**
  3509.      * Frontend Builder Activate
  3510.     */
  3511.     if ( !function_exists('snpshpwp_factive') ) :
  3512.     function snpshpwp_factive() {
  3513.         global $fbuilder, $snpshpwp_data;
  3514.         $options = array (
  3515.             'bottom_margin' => $snpshpwp_data['fb_bmargin'],
  3516.             'high_rezolution_width' => $snpshpwp_data['content_width'],
  3517.             'high_rezolution_margin' => $snpshpwp_data['fb_hres_c'],
  3518.             'med_rezolution_width' => $snpshpwp_data['fb_mres_w'],
  3519.             'med_rezolution_margin' => $snpshpwp_data['fb_mres_c'],
  3520.             'med_rezolution_hide_sidebar' => ( $snpshpwp_data['fb_mres_s'] == 1 ) ? 'true' : 'false',
  3521.             'low_rezolution_width' => $snpshpwp_data['fb_lres_w'],
  3522.             'low_rezolution_margin' => $snpshpwp_data['fb_lres_c'],
  3523.             'low_rezolution_hide_sidebar' => ( $snpshpwp_data['fb_lres_s'] == 1 ) ? 'true' : 'false',
  3524.             'main_color' => $snpshpwp_data['theme_color'],
  3525.             'light_main_color' => $snpshpwp_data['theme_color'],
  3526.             'text_color' => $snpshpwp_data['theme_color_textt'],
  3527.             'title_color' => $snpshpwp_data['theme_color_dark'],
  3528.             'dark_back_color' => $snpshpwp_data['theme_color_dark'],
  3529.             'light_back_color' => $snpshpwp_data['theme_color_palee'],
  3530.             'dark_border_color' => $snpshpwp_data['theme_color_dark'],
  3531.             'light_border_color' => $snpshpwp_data['theme_color_palee']
  3532.         );
  3533.         $fbuilder->set_options($options);
  3534.     }
  3535.     endif;
  3536.     add_action('fbuilder_activate', 'snpshpwp_factive');
  3537.  
  3538.  
  3539.     /**
  3540.      * Frontend Builder Activate
  3541.     */
  3542.     if ( !function_exists('snpshpwp_addgroups') ) :
  3543.     function snpshpwp_addgroups() {
  3544.         global $fbuilder;
  3545.         $curr = array(
  3546.                 'id' => 'SNAPSHOP WooCommerce',
  3547.                 'label' => __('SNAPSHOP WooCommerce', 'snpshpwp'),
  3548.                 'img' => get_template_directory_uri() . '/images/fbuilder/ss_woo.png'
  3549.             );
  3550.         array_push($fbuilder->groups, $curr);
  3551.         $curr = array(
  3552.                 'id' => 'SNAPSHOP Elements',
  3553.                 'label' => __('SNAPSHOP Elements', 'snpshpwp'),
  3554.                 'img' => get_template_directory_uri() . '/images/fbuilder/ss_group.png'
  3555.             );
  3556.         array_push($fbuilder->groups, $curr);
  3557.  
  3558.     }
  3559.     endif;
  3560.     add_action('fbuilder_groups', 'snpshpwp_addgroups');
  3561. }
  3562.  
  3563.  
  3564. /**
  3565.  * Loop Actions
  3566. */
  3567.  
  3568.  
  3569.  
  3570.  
  3571.     if ( !function_exists('snpshpwp_get_sidebar') ) :
  3572.     function snpshpwp_get_sidebar($curr, $curr_sidebar, $curr_width, $curr_position) {
  3573.  
  3574.         if ( is_page() || is_single() ) {
  3575.             if ( get_post_meta( get_the_ID(),'snpshpwp_sidebar_hide', true ) == '1' ) return;
  3576.         }
  3577.  
  3578.         global $snpshpwp_data;
  3579.  
  3580.         if ( $snpshpwp_data[$curr_sidebar] !== '1' ) return;
  3581.  
  3582.         if ( $snpshpwp_data[$curr_sidebar.'-position'] !== $curr_position ) return;
  3583.  
  3584.         $sidebar_class = snpshpwp_get_class('sidebar', $curr_sidebar, $curr_width, ( $curr_position == '1' ? 'left' : 'right' ) );
  3585.  
  3586.         printf('<div class="%1$s">', $sidebar_class);
  3587.  
  3588.         if ( is_page() || is_single() ) {
  3589.             $curr_override = get_post_meta( get_the_ID(),'snpshpwp_sidebar_override', true );
  3590.  
  3591.             if ( $curr_override !== '' && $curr_override !== 'none' ) {
  3592.                 dynamic_sidebar( $curr_override );
  3593.             }
  3594.             else if ( $snpshpwp_data[$curr_sidebar] == '1' ) {
  3595.                 dynamic_sidebar( $curr_sidebar );
  3596.             }
  3597.         }
  3598.         else {
  3599.             dynamic_sidebar( $curr_sidebar );
  3600.         }
  3601.  
  3602.         printf('</div>');
  3603.  
  3604.     }
  3605.     endif;
  3606.  
  3607.  
  3608.  
  3609.     if ( !function_exists('snpshpwp_get_class') ) :
  3610.     function snpshpwp_get_class($curr, $curr_sidebar, $curr_width, $curr_position) {
  3611.  
  3612.         $classes = '';
  3613.         $post_class = array();
  3614.         $full_class = 'fbuilder_column fbuilder_column-1-1';
  3615.         global $snpshpwp_data;
  3616.  
  3617.         if ( $curr == 'sidebar' ) {
  3618.        
  3619.                 if ( is_page() || is_single() ) {
  3620.                     if ( get_post_meta( get_the_ID(),'snpshpwp_sidebar_hide', true ) == '1' ) return;
  3621.  
  3622. /*                  $curr_override = get_post_meta( get_the_ID(),'snpshpwp_sidebar_override', true );
  3623.  
  3624.                     if ( $curr_override !== '' || $curr_override !== 'none' ) return $full_class;*/
  3625.                 }
  3626.  
  3627.                 if ( $snpshpwp_data[$curr_sidebar] !== '1' ) return;
  3628.  
  3629.                 switch ($curr_width):
  3630.                 case '3' :
  3631.                 $sidebar_class = 'snpshpwp_sidebar_wrapper snpshpwp_sidebar_'.$curr_position.' fbuilder_column fbuilder_column-1-3';
  3632.                 break;
  3633.                 case '4' :
  3634.                 $sidebar_class = 'snpshpwp_sidebar_wrapper snpshpwp_sidebar_'.$curr_position.' fbuilder_column fbuilder_column-1-4';
  3635.                 break;
  3636.                 case '5' :
  3637.                 $sidebar_class = 'snpshpwp_sidebar_wrapper snpshpwp_sidebar_'.$curr_position.' fbuilder_column fbuilder_column-1-5';
  3638.                 break;
  3639.                 endswitch;
  3640.                
  3641.                 return $sidebar_class;
  3642.  
  3643.         }
  3644.         else if ( $curr == 'content') {
  3645.  
  3646.                 if ( is_page() || is_single() ) {
  3647.                     if ( get_post_meta( get_the_ID(),'snpshpwp_sidebar_hide', true ) == '1' ) return $full_class;
  3648.  
  3649.                     $curr_override = get_post_meta( get_the_ID(),'snpshpwp_sidebar_override', true );
  3650.  
  3651.                     //if ( $curr_override == 'none' ) return $full_class;
  3652.  
  3653.                 }
  3654.  
  3655.                 if ( $snpshpwp_data[$curr_sidebar] !== '1' ) return $full_class;
  3656.  
  3657.                 $sidebar_wrap_class = ( $snpshpwp_data[$curr_sidebar.'-position'] == 1 ? ' snpshpwp_sdbrctv_left' : ' snpshpwp_sdbrctv_right' );
  3658.  
  3659.                 switch ($curr_width):
  3660.                 case '3' :
  3661.                 $blog_class = 'fbuilder_column fbuilder_column-2-3';
  3662.                 break;
  3663.                 case '4' :
  3664.                 $blog_class = 'fbuilder_column fbuilder_column-3-4';
  3665.                 break;
  3666.                 case '5' :
  3667.                 $blog_class = 'fbuilder_column fbuilder_column-4-5';
  3668.                 break;
  3669.                 endswitch;
  3670.  
  3671.                 $blog_class = ' '.$blog_class.' '.$sidebar_wrap_class;
  3672.  
  3673.                 return $blog_class;
  3674.         }
  3675.  
  3676.     }
  3677.     endif;
  3678.  
  3679.  
  3680.  
  3681. /* nav_menu */
  3682. function snpshpwp_nav_menu_img( $item_output, $item, $depth, $args) {
  3683.     $curr_img = esc_attr( get_post_meta( $item->ID, 'snpshpwp_menu_item_bg', TRUE ) );
  3684.     $curr_img_pos = esc_attr( get_post_meta( $item->ID, 'snpshpwp_menu_item_bg_pos', TRUE ) );
  3685.     if ( !empty($curr_img) ) $curr_img = sprintf('<img src="%1$s" class="snpshpwp_nav_menu_bg" data-position="%2$s" alt="%3$s" />', $curr_img, $curr_img_pos, __('Menu background', 'snpshpwp') );
  3686.  
  3687.     if ( $depth !== 0 ) return $item_output;
  3688.     return $curr_img.$item_output;
  3689. }
  3690. add_filter( 'walker_nav_menu_start_el', 'snpshpwp_nav_menu_img', 10, 4);
  3691.  
  3692. function  snpshpwp_nav_menu_css() {
  3693.     global $pagenow;
  3694.  
  3695.     if ( $pagenow != 'nav-menus.php' )
  3696.         return;
  3697.     wp_enqueue_style('snpshpwp-navmenu-css', get_template_directory_uri() . '/lib/snpshpwp-menu/nav-menu.css');
  3698.  
  3699. }
  3700. add_action( "admin_print_styles", 'snpshpwp_nav_menu_css' );
  3701.  
  3702. function snpshpwp_nav_menu_js() {
  3703.     global $pagenow;
  3704.  
  3705.     if ( $pagenow != 'nav-menus.php' )
  3706.         return;
  3707.  
  3708.     wp_enqueue_script('snpshpwp-navmenu-js', get_template_directory_uri() . '/lib/snpshpwp-menu/nav-menu.js');
  3709.     if ( function_exists( 'wp_enqueue_media' ) )
  3710.         wp_enqueue_media();
  3711.  
  3712. }
  3713. add_action( "admin_enqueue_scripts", 'snpshpwp_nav_menu_js' );
  3714.  
  3715.  
  3716.  
  3717.  
  3718.  
  3719.  
  3720.  
  3721. function snpshpwp_registration_form() {
  3722.  
  3723.     // only show the registration form to non-logged-in members
  3724.     if(!is_user_logged_in()) {
  3725.  
  3726.         // check to make sure user registration is enabled
  3727.         $registration_enabled = get_option('users_can_register');
  3728.  
  3729.         // only show the registration form if allowed
  3730.         if($registration_enabled) {
  3731.             $output = snpshpwp_registration_form_fields();
  3732.         } else {
  3733.             $output = __('User registration is not enabled.', 'snpshpwp');
  3734.         }
  3735.         return $output;
  3736.     }
  3737. }
  3738.  
  3739. function snpshpwp_login_form() {
  3740.  
  3741.     if(!is_user_logged_in()) {
  3742.  
  3743.         $output = snpshpwp_login_form_fields();
  3744.     } else {
  3745.         // could show some logged in user info here
  3746.         $current_user = wp_get_current_user();
  3747.         $output = __("Logged in as", 'snpshpwp') . ' ' . $current_user->user_login;
  3748.     }
  3749.     return $output;
  3750. }
  3751.  
  3752.  
  3753. function snpshpwp_registration_form_fields() {
  3754.  
  3755.     ob_start(); ?>
  3756.         <h3><?php _e('Register New Account', 'snpshpwp'); ?></h3>
  3757.  
  3758.         <?php
  3759.         snpshpwp_show_error_messages(); ?>
  3760.  
  3761.         <form id="snpshpwp_login_registration" class="snpshpwp_login_registration" action="<?php echo home_url('/'); ?>" method="POST">
  3762.             <fieldset>
  3763.                 <p>
  3764.                     <label for="snpshpwp_user_login_reg"><?php _e('Username', 'snpshpwp'); ?></label>
  3765.                     <input name="snpshpwp_user_login" id="snpshpwp_user_login_reg" class="required" type="text" placeholder="<?php _e('Username', 'snpshpwp') ?>" />
  3766.                 </p>
  3767.                 <p>
  3768.                     <label for="snpshpwp_user_email_reg"><?php _e('Email', 'snpshpwp'); ?></label>
  3769.                     <input name="snpshpwp_user_email" id="snpshpwp_user_email_reg" class="required" type="email" placeholder="<?php _e('Email', 'snpshpwp') ?>" />
  3770.                 </p>
  3771.                 <p>
  3772.                     <label for="snpshpwp_user_password_reg"><?php _e('Password', 'snpshpwp'); ?></label>
  3773.                     <input name="snpshpwp_user_pass" id="snpshpwp_user_password_reg" class="required" type="password" placeholder="<?php _e('Password', 'snpshpwp') ?>" />
  3774.                 </p>
  3775.                 <p>
  3776.                     <label for="snpshpwp_user_password_again_reg"><?php _e('Repeat Password', 'snpshpwp'); ?></label>
  3777.                     <input name="snpshpwp_user_pass_confirm" id="snpshpwp_user_password_again_reg" class="required" type="password" placeholder="<?php _e('Repeat Password', 'snpshpwp') ?>" />
  3778.                 </p>
  3779.                 <p>
  3780.                     <input type="hidden" name="snpshpwp_register_nonce" value="<?php echo wp_create_nonce('snpshpwp-register-nonce'); ?>"/>
  3781.                     <input id="snpshpwp_login_register" type="submit" value="<?php _e('Register', 'snpshpwp'); ?>"/>
  3782.                 </p>
  3783.             </fieldset>
  3784.         </form>
  3785.     <?php
  3786.     return ob_get_clean();
  3787. }
  3788.  
  3789.  
  3790. function snpshpwp_login_form_fields() {
  3791.  
  3792.     ob_start(); ?>
  3793.         <h3><?php _e('Login', 'snpshpwp'); ?></h3>
  3794.  
  3795.         <?php
  3796.         // show any error messages after form submission
  3797.         snpshpwp_show_error_messages(); ?>
  3798.  
  3799.         <form id="snpshpwp_login_form"  class="snpshpwp_login_form" action="<?php echo home_url('/'); ?>" method="post">
  3800.             <fieldset>
  3801.                 <p>
  3802.                     <label for="snpshpwp_user_login"><?php _e('Username', 'snpshpwp'); ?></label>
  3803.                     <input name="snpshpwp_user_login" id="snpshpwp_user_login" class="required" type="text" placeholder="<?php _e('Username', 'snpshpwp') ?>" />
  3804.                 </p>
  3805.                 <p>
  3806.                     <label for="snpshpwp_user_pass"><?php _e('Password', 'snpshpwp'); ?></label>
  3807.                     <input name="snpshpwp_user_pass" id="snpshpwp_user_pass" class="required" type="password" placeholder="<?php _e('Password', 'snpshpwp') ?>" />
  3808.                 </p>
  3809.                 <p>
  3810.                     <input type="hidden" name="snpshpwp_login_nonce" value="<?php echo wp_create_nonce('snpshpwp-login-nonce'); ?>"/>
  3811.                     <input id="snpshpwp_login_submit" type="submit" value="<?php _e('Login', 'snpshpwp'); ?>"/>
  3812.                 </p>
  3813.                 <p>
  3814.                     <?php do_action( 'social_connect_form' ); ?>
  3815.                 </p>
  3816.             </fieldset>
  3817.         </form>
  3818.     <?php
  3819.     return ob_get_clean();
  3820. }
  3821.  
  3822. function snpshpwp_login_member() {
  3823.  
  3824.     if(isset($_POST['snpshpwp_login_nonce']) && wp_verify_nonce($_POST['snpshpwp_login_nonce'], 'snpshpwp-login-nonce')) {
  3825.  
  3826.         // this returns the user ID and other info from the user name
  3827.         $user = get_userdatabylogin($_POST['snpshpwp_user_login']);
  3828.  
  3829.         if(!$user) {
  3830.             // if the user name doesn't exist
  3831.             snpshpwp_errors()->add('empty_username', __('Invalid username', 'snpshpwp'));
  3832.         }
  3833.  
  3834.         if(!isset($_POST['snpshpwp_user_pass']) || $_POST['snpshpwp_user_pass'] == '') {
  3835.             // if no password was entered
  3836.             snpshpwp_errors()->add('empty_password', __('Please enter a password'));
  3837.         }
  3838.  
  3839.         // check the user's login with their password
  3840.         if(!wp_check_password($_POST['snpshpwp_user_pass'], $user->user_pass, $user->ID)) {
  3841.             // if the password is incorrect for the specified user
  3842.             snpshpwp_errors()->add('empty_password', __('Incorrect password', 'snpshpwp'));
  3843.         }
  3844.  
  3845.         // retrieve all error messages
  3846.         $errors = snpshpwp_errors()->get_error_messages();
  3847.  
  3848.         // only log the user in if there are no errors
  3849.         if(empty($errors)) {
  3850.  
  3851.             wp_setcookie($_POST['snpshpwp_user_login'], $_POST['snpshpwp_user_pass'], true);
  3852.             wp_set_current_user($user->ID, $_POST['snpshpwp_user_login']); 
  3853.             do_action('wp_login', $_POST['snpshpwp_user_login']);
  3854.  
  3855.             wp_redirect(home_url()); exit;
  3856.         }
  3857.     }
  3858. }
  3859. add_action('init', 'snpshpwp_login_member');
  3860.  
  3861. function snpshpwp_add_new_member() {
  3862.     if (isset( $_POST["snpshpwp_register_nonce"] ) && wp_verify_nonce($_POST['snpshpwp_register_nonce'], 'snpshpwp-register-nonce')) {
  3863.         $user_login     = $_POST["snpshpwp_user_login"];   
  3864.         $user_email     = $_POST["snpshpwp_user_email"];
  3865.         $user_pass      = $_POST["snpshpwp_user_pass"];
  3866.         $pass_confirm   = $_POST["snpshpwp_user_pass_confirm"];
  3867.  
  3868.  
  3869.         if(username_exists($user_login)) {
  3870.             // Username already registered
  3871.             snpshpwp_errors()->add('username_unavailable', __('Username already taken'));
  3872.         }
  3873.         if(!validate_username($user_login)) {
  3874.             // invalid username
  3875.             snpshpwp_errors()->add('username_invalid', __('Invalid username'));
  3876.         }
  3877.         if($user_login == '') {
  3878.             // empty username
  3879.             snpshpwp_errors()->add('username_empty', __('Please enter a username'));
  3880.         }
  3881.         if(!is_email($user_email)) {
  3882.             //invalid email
  3883.             snpshpwp_errors()->add('email_invalid', __('Invalid email'));
  3884.         }
  3885.         if(email_exists($user_email)) {
  3886.             //Email address already registered
  3887.             snpshpwp_errors()->add('email_used', __('Email already registered'));
  3888.         }
  3889.         if($user_pass == '') {
  3890.             // passwords do not match
  3891.             snpshpwp_errors()->add('password_empty', __('Please enter a password'));
  3892.         }
  3893.         if($user_pass != $pass_confirm) {
  3894.             // passwords do not match
  3895.             snpshpwp_errors()->add('password_mismatch', __('Passwords do not match'));
  3896.         }
  3897.  
  3898.         $errors = snpshpwp_errors()->get_error_messages();
  3899.  
  3900.         // only create the user in if there are no errors
  3901.         if(empty($errors)) {
  3902.  
  3903.             $new_user_id = wp_insert_user(array(
  3904.                     'user_login'        => $user_login,
  3905.                     'user_pass'         => $user_pass,
  3906.                     'user_email'        => $user_email,
  3907.                     'user_registered'   => date('Y-m-d H:i:s'),
  3908.                     'role'              => 'subscriber'
  3909.                 )
  3910.             );
  3911.             if($new_user_id) {
  3912.                 // send an email to the admin alerting them of the registration
  3913.                 wp_new_user_notification($new_user_id);
  3914.  
  3915.                 // log the new user in
  3916.                 wp_setcookie($user_login, $user_pass, true);
  3917.                 wp_set_current_user($new_user_id, $user_login);
  3918.                 do_action('wp_login', $user_login);
  3919.  
  3920.                 // send the newly created user to the home page after logging them in
  3921.                 wp_redirect(home_url()); exit;
  3922.             }
  3923.  
  3924.         }
  3925.  
  3926.     }
  3927. }
  3928. add_action('init', 'snpshpwp_add_new_member');
  3929.  
  3930. function snpshpwp_errors(){
  3931.     static $wp_error;
  3932.     return isset($wp_error) ? $wp_error : ($wp_error = new WP_Error(null, null, null));
  3933. }
  3934.  
  3935. function snpshpwp_show_error_messages() {
  3936.     if($codes = snpshpwp_errors()->get_error_codes()) {
  3937.         echo '<div class="snpshpwp_login_errors">';
  3938.         foreach($codes as $code){
  3939.             $message = snpshpwp_errors()->get_error_message($code);
  3940.             echo '<span class="error"><strong>' . __('Error') . '</strong>: ' . $message . '</span><br/>';
  3941.         }
  3942.         echo '</div>';
  3943.     }  
  3944. }
  3945.  
  3946. add_filter('social_connect_images_url', create_function( '$cols', 'return get_template_directory_uri() . "/images/login/";' ), 20 );
  3947.  
  3948. function snpshpwp_update() {
  3949.     if ( get_theme_mod('snpshpwp_version', false) === false ) {
  3950.         /* v1.0.1 init*/
  3951.         set_theme_mod('loader_active', '0');
  3952.         set_theme_mod('snpshpwp_version', '1.0.1');
  3953.     }
  3954. }
  3955. add_action('init', 'snpshpwp_update');
  3956.  
  3957. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement