rimpa

Shopkeeper

Aug 29th, 2016
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.18 KB | None | 0 0
  1. <?php
  2.  
  3. // DO NOT MODIFY
  4. define("THEME_SLUG", 'shopkeeper');
  5. define("THEME_NAME", 'Shopkeeper');
  6.  
  7. // theme textdomain - must be loaded before redux
  8. load_theme_textdomain( 'shopkeeper', get_template_directory() . '/languages' );
  9.  
  10. /******************************************************************************/
  11. /***************************** Theme Options **********************************/
  12. /******************************************************************************/
  13.  
  14. if ( !class_exists( 'ReduxFramework' ) && file_exists( dirname( __FILE__ ) . '/settings/redux/ReduxCore/framework.php' ) ) {
  15. require_once( dirname( __FILE__ ) . '/settings/redux/ReduxCore/framework.php' );
  16. }
  17. if ( !isset( $redux_demo ) && file_exists( dirname( __FILE__ ) . '/settings/shopkeeper.config.php' ) ) {
  18. require_once( dirname( __FILE__ ) . '/settings/shopkeeper.config.php' );
  19. }
  20.  
  21. global $shopkeeper_theme_options;
  22.  
  23.  
  24. /******************************************************************************/
  25. /******************************** Includes ************************************/
  26. /******************************************************************************/
  27.  
  28. require_once('inc/helpers/helpers.php');
  29.  
  30. if ( is_admin() ) require_once('backend/index.php'); // Backend
  31.  
  32. //Include Custom Posts
  33. include_once('inc/custom-posts/portfolio.php');
  34.  
  35.  
  36.  
  37. include_once('inc/custom-styles/custom-styles.php'); // Load Custom Styles
  38. include_once('inc/templates/post-meta.php'); // Load Post meta template
  39. include_once('inc/templates/template-tags.php'); // Load Template Tags
  40.  
  41. include_once('inc/widgets/social-media.php'); // Load Widget Social Media
  42.  
  43.  
  44.  
  45. //Include Shortcodes
  46. include_once('inc/shortcodes/product-categories.php');
  47. include_once('inc/shortcodes/socials.php');
  48. include_once('inc/shortcodes/from-the-blog.php');
  49. include_once('inc/shortcodes/google-map.php');
  50. include_once('inc/shortcodes/banner.php');
  51. include_once('inc/shortcodes/icon-box.php');
  52. include_once('inc/shortcodes/portfolio.php');
  53. include_once('inc/shortcodes/add-to-cart.php');
  54. include_once('inc/shortcodes/wc-mod-product.php');
  55.  
  56.  
  57.  
  58. //Include Metaboxes
  59. include_once('inc/metaboxes/page.php');
  60. include_once('inc/metaboxes/post.php');
  61. include_once('inc/metaboxes/portfolio.php');
  62. include_once('inc/metaboxes/product.php');
  63.  
  64.  
  65. //Custom Menu
  66. include_once('inc/custom-menu/custom-menu.php');
  67.  
  68. //Quick View
  69. include_once('inc/woocommerce/quick_view.php');
  70.  
  71.  
  72.  
  73.  
  74. /******************************************************************************/
  75. /************************ Plugin recommendations ******************************/
  76. /******************************************************************************/
  77.  
  78. require_once dirname( __FILE__ ) . '/inc/tgm/class-tgm-plugin-activation-mod.php';
  79. require_once dirname( __FILE__ ) . '/inc/tgm/plugins.php';
  80.  
  81.  
  82.  
  83.  
  84.  
  85. /******************************************************************************/
  86. /*************************** Visual Composer **********************************/
  87. /******************************************************************************/
  88.  
  89. if (class_exists('WPBakeryVisualComposerAbstract')) {
  90.  
  91. add_action( 'init', 'visual_composer_stuff' );
  92. function visual_composer_stuff() {
  93.  
  94. //disable update
  95. Vc_Manager::getInstance()->disableUpdater(true);
  96.  
  97. //enable vc on post types
  98. if(function_exists('vc_set_default_editor_post_types')) vc_set_default_editor_post_types( array('post','page','product','portfolio') );
  99.  
  100. // Modify and remove existing shortcodes from VC
  101. include_once('inc/shortcodes/visual-composer/custom_vc.php');
  102.  
  103. // VC Templates
  104. $vc_templates_dir = get_template_directory() . '/inc/shortcodes/visual-composer/vc_templates/';
  105. vc_set_template_dir($vc_templates_dir);
  106.  
  107. // Add new shortcodes to VC
  108. include_once('inc/shortcodes/visual-composer/from-the-blog.php');
  109. include_once('inc/shortcodes/visual-composer/social-media-profiles.php');
  110. include_once('inc/shortcodes/visual-composer/google-map.php');
  111. include_once('inc/shortcodes/visual-composer/banner.php');
  112. include_once('inc/shortcodes/visual-composer/icon-box.php');
  113. include_once('inc/shortcodes/visual-composer/portfolio.php');
  114.  
  115. // Add new Shop shortcodes to VC
  116. if (class_exists('WooCommerce')) {
  117. include_once('inc/shortcodes/visual-composer/wc-recent-products.php');
  118. include_once('inc/shortcodes/visual-composer/wc-featured-products.php');
  119. include_once('inc/shortcodes/visual-composer/wc-products-by-category.php');
  120. include_once('inc/shortcodes/visual-composer/wc-products-by-attribute.php');
  121. include_once('inc/shortcodes/visual-composer/wc-product-by-id-sku.php');
  122. include_once('inc/shortcodes/visual-composer/wc-products-by-ids-skus.php');
  123. include_once('inc/shortcodes/visual-composer/wc-sale-products.php');
  124. include_once('inc/shortcodes/visual-composer/wc-top-rated-products.php');
  125. include_once('inc/shortcodes/visual-composer/wc-best-selling-products.php');
  126. include_once('inc/shortcodes/visual-composer/wc-add-to-cart-button.php');
  127. include_once('inc/shortcodes/visual-composer/wc-product-categories.php');
  128. include_once('inc/shortcodes/visual-composer/wc-product-categories-grid.php');
  129. }
  130.  
  131. // Remove vc_teaser
  132. if (is_admin()) :
  133. function remove_vc_teaser() {
  134. remove_meta_box('vc_teaser', '' , 'side');
  135. }
  136. add_action( 'admin_head', 'remove_vc_teaser' );
  137. endif;
  138.  
  139. }
  140.  
  141. // Filter to replace default css class names for vc_row shortcode and vc_column
  142. /*add_filter( 'vc_shortcodes_css_class', 'custom_css_classes_for_vc_row_and_vc_column', 10, 2 );
  143. function custom_css_classes_for_vc_row_and_vc_column( $class_string, $tag ) {
  144.  
  145. if ( $tag == 'vc_row' || $tag == 'vc_row_inner' ) {
  146. $class_string = str_replace( 'vc_row-fluid', 'row', $class_string );
  147. }
  148.  
  149. if ( $tag == 'vc_column' || $tag == 'vc_column_inner' ) {
  150. $class_string = preg_replace( '/vc_col-xs-(\d{1,2})/', 'large-$1 columns column_container', $class_string );
  151. $class_string = preg_replace( '/vc_col-sm-(\d{1,2})/', 'large-$1 columns column_container', $class_string );
  152. $class_string = preg_replace( '/vc_col-md-(\d{1,2})/', 'large-$1 columns column_container', $class_string );
  153. $class_string = preg_replace( '/vc_col-lg-(\d{1,2})/', 'large-$1 columns column_container', $class_string );
  154. }
  155.  
  156. return $class_string;
  157.  
  158. }*/
  159.  
  160. }
  161.  
  162. /*add_action( 'vc_before_init', 'shopkeeper_vcSetAsTheme' );
  163. function shopkeeper_vcSetAsTheme() {
  164. vc_set_as_theme( $disable_updater = true );
  165. }*/
  166.  
  167.  
  168.  
  169. /******************************************************************************/
  170. /****************************** Ajax url **************************************/
  171. /******************************************************************************/
  172.  
  173. add_action('wp_head','shopkeeper_ajaxurl');
  174. function shopkeeper_ajaxurl() {
  175. ?>
  176. <script type="text/javascript">
  177. var shopkeeper_ajaxurl = '<?php echo admin_url('admin-ajax.php', 'relative'); ?>';
  178. </script>
  179. <?php
  180. }
  181.  
  182. /******************************************************************************/
  183. /************************ Ajax calls ******************************************/
  184. /******************************************************************************/
  185.  
  186. function refresh_dynamic_contents() {
  187. global $woocommerce, $yith_wcwl;
  188. $data = array(
  189. 'cart_count_products' => class_exists('WooCommerce') ? WC()->cart->get_cart_contents_count() : 0,
  190. 'wishlist_count_products' => class_exists('YITH_WCWL') ? yith_wcwl_count_products() : 0,
  191. );
  192. wp_send_json($data);
  193. }
  194. add_action( 'wp_ajax_refresh_dynamic_contents', 'refresh_dynamic_contents' );
  195. add_action( 'wp_ajax_nopriv_refresh_dynamic_contents', 'refresh_dynamic_contents' );
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. /******************************************************************************/
  203. /*********************** shopkeeper setup *************************************/
  204. /******************************************************************************/
  205.  
  206.  
  207. if ( ! function_exists( 'shopkeeper_setup' ) ) :
  208. function shopkeeper_setup() {
  209.  
  210. global $shopkeeper_theme_options;
  211.  
  212. // frontend presets
  213. if (isset($_GET["preset"])) {
  214. $preset = $_GET["preset"];
  215. } else {
  216. $preset = "";
  217. }
  218.  
  219. if ($preset != "") {
  220. if ( file_exists( dirname( __FILE__ ) . '/_presets/'.$preset.'.json' ) ) {
  221. $theme_options_json = file_get_contents( dirname( __FILE__ ) . '/_presets/'.$preset.'.json' );
  222. $shopkeeper_theme_options = json_decode($theme_options_json, true);
  223. }
  224. }
  225.  
  226. /** Theme support **/
  227. add_theme_support( 'title-tag' );
  228. add_theme_support( 'menus' );
  229. add_theme_support( 'automatic-feed-links' );
  230. add_theme_support( 'post-thumbnails' );
  231. add_theme_support( 'woocommerce');
  232. function custom_header_custom_bg() {
  233. add_theme_support( 'custom-header' );
  234. add_theme_support( 'custom-background' );
  235. }
  236.  
  237. add_post_type_support('page', 'excerpt');
  238.  
  239.  
  240. /** Add Image Sizes **/
  241. $shop_catalog_image_size = get_option( 'shop_catalog_image_size' );
  242. $shop_single_image_size = get_option( 'shop_single_image_size' );
  243. add_image_size('product_small_thumbnail', (int)$shop_catalog_image_size['width']/3, (int)$shop_catalog_image_size['height']/3, isset($shop_catalog_image_size['crop']) ? true : false); // made from shop_catalog_image_size
  244. add_image_size('shop_single_small_thumbnail', (int)$shop_single_image_size['width']/3, (int)$shop_single_image_size['height']/3, isset($shop_catalog_image_size['crop']) ? true : false); // made from shop_single_image_size
  245. add_image_size( 'blog-isotope', 620, 500, true );
  246.  
  247. /** Register menus **/
  248. register_nav_menus( array(
  249. 'top-bar-navigation' => __( 'Top Bar Navigation', 'shopkeeper' ),
  250. 'main-navigation' => __( 'Main Navigation', 'shopkeeper' ),
  251. 'footer-navigation' => __( 'Footer Navigation', 'shopkeeper' ),
  252. ) );
  253.  
  254. if ( (isset($shopkeeper_theme_options['main_header_off_canvas'])) && (trim($shopkeeper_theme_options['main_header_off_canvas']) == "1" ) ) {
  255. register_nav_menus( array(
  256. 'secondary_navigation' => __( 'Secondary Navigation (Off-Canvas)', 'shopkeeper' ),
  257. ) );
  258. }
  259.  
  260. if ( (isset($shopkeeper_theme_options['main_header_layout'])) && ( $shopkeeper_theme_options['main_header_layout'] == "2" ) ) {
  261. register_nav_menus( array(
  262. 'centered_header_left_navigation' => __( 'Centered Header - Left Navigation', 'shopkeeper' ),
  263. 'centered_header_right_navigation' => __( 'Centered Header - Right Navigation', 'shopkeeper' ),
  264. ) );
  265. }
  266.  
  267. /** WooCommerce Number of products displayed per page **/
  268. if ( (isset($shopkeeper_theme_options['products_per_page'])) ) {
  269. add_filter( 'loop_shop_per_page', create_function( '$cols', 'return ' . $shopkeeper_theme_options['products_per_page'] . ';' ), 20 );
  270. }
  271.  
  272. /******************************************************************************/
  273. /* WooCommerce remove review tab **********************************************/
  274. /******************************************************************************/
  275. if ( (isset($shopkeeper_theme_options['review_tab'])) && ($shopkeeper_theme_options['review_tab'] == "0" ) ) {
  276. add_filter( 'woocommerce_product_tabs', 'shopkeeper_remove_reviews_tab', 98);
  277. function shopkeeper_remove_reviews_tab($tabs) {
  278. unset($tabs['reviews']);
  279. return $tabs;
  280. }
  281. }
  282.  
  283. }
  284. endif; // shopkeeper_setup
  285. add_action( 'after_setup_theme', 'shopkeeper_setup' );
  286.  
  287. /******************************************************************************/
  288. /**************************** Enqueue styles **********************************/
  289. /******************************************************************************/
  290.  
  291. // frontend
  292. function shopkeeper_styles() {
  293.  
  294. global $shopkeeper_theme_options;
  295.  
  296. wp_enqueue_style('shopkeeper-foundation-app', get_template_directory_uri() . '/css/app.css', array(), '5.3.1', 'all' );
  297.  
  298. wp_enqueue_style('shopkeeper-animate', get_template_directory_uri() . '/css/animate.css', array(), '2.0', 'all' );
  299.  
  300. wp_enqueue_style('shopkeeper-font-awesome', get_template_directory_uri() . '/inc/fonts/font-awesome/css/font-awesome.min.css', array(), '4.0.3', 'all' );
  301. wp_enqueue_style('shopkeeper-font-linea-arrows', get_template_directory_uri() . '/inc/fonts/linea-fonts/arrows/styles.css', array(), '1.0', 'all' );
  302. wp_enqueue_style('shopkeeper-font-linea-basic', get_template_directory_uri() . '/inc/fonts/linea-fonts/basic/styles.css', array(), '1.0', 'all' );
  303. wp_enqueue_style('shopkeeper-font-linea-basic_elaboration', get_template_directory_uri() . '/inc/fonts/linea-fonts/basic_elaboration/styles.css', array(), '1.0', 'all' );
  304. wp_enqueue_style('shopkeeper-font-linea-ecommerce', get_template_directory_uri() . '/inc/fonts/linea-fonts/ecommerce/styles.css', array(), '1.0', 'all' );
  305. wp_enqueue_style('shopkeeper-font-linea-music', get_template_directory_uri() . '/inc/fonts/linea-fonts/music/styles.css', array(), '1.0', 'all' );
  306. wp_enqueue_style('shopkeeper-font-linea-software', get_template_directory_uri() . '/inc/fonts/linea-fonts/software/styles.css', array(), '1.0', 'all' );
  307. wp_enqueue_style('shopkeeper-font-linea-weather', get_template_directory_uri() . '/inc/fonts/linea-fonts/weather/styles.css', array(), '1.0', 'all' );
  308. wp_enqueue_style('shopkeeper-fresco', get_template_directory_uri() . '/css/fresco/fresco.css', array(), '1.3.0', 'all' );
  309. wp_enqueue_style('shopkeeper-idangerous-swiper', get_template_directory_uri() . '/css/idangerous.swiper.css', array(), '2.3', 'all' );
  310. wp_enqueue_style('shopkeeper-owl', get_template_directory_uri() . '/css/owl.carousel.css', array(), '1.3.1', 'all' );
  311. wp_enqueue_style('shopkeeper-owl-theme', get_template_directory_uri() . '/css/owl.theme.css', array(), '1.3.1', 'all' );
  312. wp_enqueue_style('shopkeeper-offcanvas', get_template_directory_uri() . '/css/offcanvas.css', array(), '1.0', 'all' );
  313. wp_enqueue_style('shopkeeper-nanoscroller', get_template_directory_uri() . '/css/nanoscroller.css', array(), '0.7.6', 'all' );
  314. wp_enqueue_style('shopkeeper-select2', get_template_directory_uri() . '/css/select2.css', array(), '3.4.5', 'all' );
  315. wp_enqueue_style('shopkeeper-easyzoom', get_template_directory_uri() . '/css/easyzoom.css', array(), '1.0', 'all' );
  316. wp_enqueue_style('shopkeeper-defaults', get_template_directory_uri() . '/css/defaults.css', array(), '1.0', 'all' );
  317. wp_enqueue_style('shopkeeper-woocommerce-overwrite', get_template_directory_uri() . '/css/woocommerce-overwrite.css', array(), '1.0', 'all' );
  318. wp_enqueue_style('shopkeeper-top-bar', get_template_directory_uri() . '/css/header-topbar.css', array(), '1.0', 'all' );
  319. wp_enqueue_style('shopkeeper-headers', get_template_directory_uri() . '/css/headers.css', array(), '1.0', 'all' );
  320. wp_enqueue_style('shopkeeper-menus', get_template_directory_uri() . '/css/navigations.css', array(), '1.0', 'all' );
  321.  
  322. if ( isset($shopkeeper_theme_options['main_header_layout']) ) {
  323. if ( $shopkeeper_theme_options['main_header_layout'] == "1" ) {
  324. wp_enqueue_style('shopkeeper-header-default', get_template_directory_uri() . '/css/header-default.css', array(), '1.0', 'all' );
  325. }
  326. elseif ( $shopkeeper_theme_options['main_header_layout'] == "2" ) {
  327. wp_enqueue_style('shopkeeper-header-centered-2menus', get_template_directory_uri() . '/css/header-centered-2menus.css', array(), '1.0', 'all' );
  328. }
  329. elseif ( $shopkeeper_theme_options['main_header_layout'] == "3" ) {
  330. wp_enqueue_style('shopkeeper-header-centered-menu-under', get_template_directory_uri() . '/css/header-centered-menu-under.css', array(), '1.0', 'all' );
  331. }
  332. }
  333. else {
  334. wp_enqueue_style('shopkeeper-header-default', get_template_directory_uri() . '/css/header-default.css', array(), '1.0', 'all' );
  335. }
  336.  
  337. if (isset($shopkeeper_theme_options['font_source']) && ($shopkeeper_theme_options['font_source'] == "2")) {
  338. if ( (isset($shopkeeper_theme_options['font_google_code'])) && ($shopkeeper_theme_options['font_google_code'] != "") ) {
  339. wp_enqueue_style('shopkeeper-font_google_code', $shopkeeper_theme_options['font_google_code'], array(), '1.0', 'all' );
  340. }
  341. }
  342.  
  343. wp_enqueue_style('shopkeeper-styles', get_template_directory_uri() . '/css/styles.css', array(), '1.0', 'all' );
  344. wp_enqueue_style('shopkeeper-responsive', get_template_directory_uri() . '/css/responsive.css', array(), '1.0', 'all' );
  345.  
  346. wp_enqueue_style('shopkeeper-default-style', get_stylesheet_uri());
  347.  
  348. }
  349. add_action( 'wp_enqueue_scripts', 'shopkeeper_styles', 99 );
  350.  
  351.  
  352.  
  353. // admin area
  354. function shopkeeper_admin_styles() {
  355. if ( is_admin() ) {
  356.  
  357. wp_enqueue_style("wp-color-picker");
  358. wp_enqueue_style("shopkeeper_admin_styles", get_template_directory_uri() . "/css/wp-admin-custom.css", false, "1.0", "all");
  359.  
  360. if (class_exists('WPBakeryVisualComposerAbstract')) {
  361. wp_enqueue_style('shopkeeper_visual_composer', get_template_directory_uri() .'/css/visual-composer.css', false, "1.0", 'all');
  362. wp_enqueue_style('shopkeeper-font-linea-arrows', get_template_directory_uri() . '/inc/fonts/linea-fonts/arrows/styles.css', false, '1.0', 'all' );
  363. wp_enqueue_style('shopkeeper-font-linea-basic', get_template_directory_uri() . '/inc/fonts/linea-fonts/basic/styles.css', false, '1.0', 'all' );
  364. wp_enqueue_style('shopkeeper-font-linea-basic_elaboration', get_template_directory_uri() . '/inc/fonts/linea-fonts/basic_elaboration/styles.css', false, '1.0', 'all' );
  365. wp_enqueue_style('shopkeeper-font-linea-ecommerce', get_template_directory_uri() . '/inc/fonts/linea-fonts/ecommerce/styles.css', false, '1.0', 'all' );
  366. wp_enqueue_style('shopkeeper-font-linea-music', get_template_directory_uri() . '/inc/fonts/linea-fonts/music/styles.css', false, '1.0', 'all' );
  367. wp_enqueue_style('shopkeeper-font-linea-software', get_template_directory_uri() . '/inc/fonts/linea-fonts/software/styles.css', false, '1.0', 'all' );
  368. wp_enqueue_style('shopkeeper-font-linea-weather', get_template_directory_uri() . '/inc/fonts/linea-fonts/weather/styles.css', false, '1.0', 'all' );
  369. }
  370. }
  371. }
  372. add_action( 'admin_enqueue_scripts', 'shopkeeper_admin_styles' );
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380. /******************************************************************************/
  381. /*************************** Enqueue scripts **********************************/
  382. /******************************************************************************/
  383.  
  384. // frontend
  385. function shopkeeper_scripts() {
  386.  
  387. global $shopkeeper_theme_options;
  388.  
  389. /** In Header **/
  390.  
  391. wp_enqueue_script('shopkeeper-google-maps', 'https://maps.googleapis.com/maps/api/js', array(), '1.0', FALSE);
  392.  
  393. if (isset($shopkeeper_theme_options['font_source']) && ($shopkeeper_theme_options['font_source'] == "3")) {
  394. if ( (isset($shopkeeper_theme_options['font_typekit_kit_id'])) && ($shopkeeper_theme_options['font_typekit_kit_id'] != "") ) {
  395. wp_enqueue_script('shopkeeper-font_typekit', '//use.typekit.net/'.$shopkeeper_theme_options['font_typekit_kit_id'].'.js', array(), NULL, FALSE );
  396. wp_enqueue_script('shopkeeper-font_typekit_exec', get_template_directory_uri() . '/js/typekit.js', array(), NULL, FALSE );
  397. }
  398. }
  399.  
  400. /** In Footer **/
  401.  
  402. wp_enqueue_script('shopkeeper-touchswipe', get_template_directory_uri() . '/js/jquery.touchSwipe.min.js', array('jquery'), '1.6.5', TRUE);
  403. wp_enqueue_script('shopkeeper-fitvids', get_template_directory_uri() . '/js/jquery.fitvids.js', array('jquery'), '1.0.3', TRUE);
  404. wp_enqueue_script('shopkeeper-idangerous-swiper', get_template_directory_uri() . '/js/idangerous.swiper-2.4.1.min.js', array('jquery'), '2.4.1', TRUE);
  405. wp_enqueue_script('shopkeeper-owl', get_template_directory_uri() . '/js/owl.carousel.min.js', array('jquery'), '1.3.1', TRUE);
  406. wp_enqueue_script('shopkeeper-fresco', get_template_directory_uri() . '/js/fresco.js', array('jquery'), '1.3.0', TRUE);
  407. wp_enqueue_script('shopkeeper-select2', get_template_directory_uri() . '/js/select2.min.js', array('jquery'), '3.5.1', TRUE);
  408. wp_enqueue_script('shopkeeper-nanoscroller', get_template_directory_uri() . '/js/jquery.nanoscroller.min.js', array('jquery'), '0.7.6', TRUE);
  409. wp_enqueue_script('shopkeeper-stellar', get_template_directory_uri() . '/js/jquery.stellar.min.js', array('jquery'), '0.6.2', TRUE);
  410.  
  411. wp_enqueue_script('shopkeeper-isotope', get_template_directory_uri() . '/js/isotope.pkgd.min.js', array('jquery'), 'v2.0.0', TRUE);
  412. wp_enqueue_script('shopkeeper-imagesloaded', get_template_directory_uri() . '/js/imagesloaded.js', array('jquery'), 'v3.1.4', TRUE);
  413.  
  414. wp_enqueue_script('shopkeeper-easyzoom', get_template_directory_uri() . '/js/easyzoom.js', array('jquery'), '1.0', TRUE);
  415.  
  416. wp_enqueue_script('shopkeeper-scripts', get_template_directory_uri() . '/js/scripts.js', array('jquery'), '1.0', TRUE);
  417.  
  418. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  419. wp_enqueue_script( 'comment-reply' );
  420. }
  421.  
  422. }
  423. add_action( 'wp_enqueue_scripts', 'shopkeeper_scripts', 99 );
  424.  
  425.  
  426.  
  427. // admin area
  428. function shopkeeper_admin_scripts() {
  429. if ( is_admin() ) {
  430. global $post_type;
  431.  
  432. if ( (isset($_GET['post_type']) && ($_GET['post_type'] == 'portfolio')) || ($post_type == 'portfolio')) :
  433. wp_enqueue_script("shopkeeper_admin_scripts", get_template_directory_uri() . "/js/wp-admin-portfolio.js", array('wp-color-picker'), false, "1.0");
  434. endif;
  435.  
  436. }
  437. }
  438. add_action( 'admin_enqueue_scripts', 'shopkeeper_admin_scripts' );
  439.  
  440.  
  441.  
  442.  
  443.  
  444. /*********************************************************************************************/
  445. /******************************** Tweak WP admin bar ****************************************/
  446. /*********************************************************************************************/
  447.  
  448. add_action( 'wp_head', 'shopkeeper_override_toolbar_margin', 11 );
  449. function shopkeeper_override_toolbar_margin() {
  450. if ( is_admin_bar_showing() ) {
  451. ?>
  452. <style type="text/css" media="screen">
  453. @media only screen and (max-width: 63.9375em) {
  454. html { margin-top: 0 !important; }
  455. * html body { margin-top: 0 !important; }
  456. }
  457. </style>
  458. <?php
  459. }
  460. }
  461.  
  462.  
  463. /******************************************************************************/
  464. /****** Register widgetized area and update sidebar with default widgets ******/
  465. /******************************************************************************/
  466.  
  467. function shopkeeper_widgets_init() {
  468.  
  469. $sidebars_widgets = wp_get_sidebars_widgets();
  470. $footer_area_widgets_counter = "0";
  471. if (isset($sidebars_widgets['footer-widget-area'])) $footer_area_widgets_counter = count($sidebars_widgets['footer-widget-area']);
  472.  
  473. switch ($footer_area_widgets_counter) {
  474. case 0:
  475. $footer_area_widgets_columns ='large-12';
  476. break;
  477. case 1:
  478. $footer_area_widgets_columns ='large-12';
  479. break;
  480. case 2:
  481. $footer_area_widgets_columns ='large-6';
  482. break;
  483. case 3:
  484. $footer_area_widgets_columns ='large-4';
  485. break;
  486. case 4:
  487. $footer_area_widgets_columns ='large-3';
  488. break;
  489. default:
  490. $footer_area_widgets_columns ='large-3';
  491. }
  492.  
  493. //default sidebar
  494. register_sidebar(array(
  495. 'name' => __( 'Sidebar', 'shopkeeper' ),
  496. 'id' => 'default-sidebar',
  497. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  498. 'after_widget' => '</aside>',
  499. 'before_title' => '<h3 class="widget-title">',
  500. 'after_title' => '</h3>',
  501. ));
  502.  
  503. //footer widget area
  504. register_sidebar( array(
  505. 'name' => __( 'Footer Widget Area', 'shopkeeper' ),
  506. 'id' => 'footer-widget-area',
  507. 'before_widget' => '<div class="' . $footer_area_widgets_columns . ' columns"><aside id="%1$s" class="widget %2$s">',
  508. 'after_widget' => '</aside></div>',
  509. 'before_title' => '<h3 class="widget-title">',
  510. 'after_title' => '</h3>',
  511. ) );
  512.  
  513. //catalog widget area
  514. register_sidebar( array(
  515. 'name' => __( 'Shop Sidebar', 'shopkeeper' ),
  516. 'id' => 'catalog-widget-area',
  517. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  518. 'after_widget' => '</aside>',
  519. 'before_title' => '<h3 class="widget-title">',
  520. 'after_title' => '</h3>',
  521. ) );
  522.  
  523. //offcanvas widget area
  524. register_sidebar( array(
  525. 'name' => __( 'Right Offcanvas Sidebar', 'shopkeeper' ),
  526. 'id' => 'offcanvas-widget-area',
  527. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  528. 'after_widget' => '</aside>',
  529. 'before_title' => '<h3 class="widget-title">',
  530. 'after_title' => '</h3>',
  531. ) );
  532. }
  533. add_action( 'widgets_init', 'shopkeeper_widgets_init' );
  534.  
  535.  
  536.  
  537.  
  538.  
  539. /******************************************************************************/
  540. /****** Remove Woocommerce prettyPhoto ***********************************************/
  541. /******************************************************************************/
  542.  
  543. add_action( 'wp_enqueue_scripts', 'shopkeeper_remove_woo_lightbox', 99 );
  544. function shopkeeper_remove_woo_lightbox() {
  545. wp_dequeue_script('prettyPhoto-init');
  546. }
  547.  
  548.  
  549.  
  550. /*********************************************************************************************/
  551. /****************************** WooCommerce Category Image ***********************************/
  552. /*********************************************************************************************/
  553.  
  554. if ( ! function_exists( 'woocommerce_add_category_header_img' ) ) :
  555. require_once('inc/addons/woocommerce-header-category-image.php');
  556. endif;
  557.  
  558.  
  559.  
  560. /******************************************************************************/
  561. /****** Add Fresco to Galleries ***********************************************/
  562. /******************************************************************************/
  563.  
  564. add_filter( 'wp_get_attachment_link', 'sant_prettyadd', 10, 6);
  565. function sant_prettyadd ($content, $id, $size, $permalink, $icon, $text) {
  566. if ($permalink) {
  567. return $content;
  568. }
  569. $content = preg_replace("/<a/","<span class=\"fresco\" data-fresco-group=\"\"", $content, 1);
  570. return $content;
  571. }
  572.  
  573.  
  574.  
  575. /******************************************************************************/
  576. /* Change breadcrumb separator on woocommerce page ****************************/
  577. /******************************************************************************/
  578.  
  579. add_filter( 'woocommerce_breadcrumb_defaults', 'jk_change_breadcrumb_delimiter' );
  580. function jk_change_breadcrumb_delimiter( $defaults ) {
  581. // Change the breadcrumb delimeter from '/' to '>'
  582. $defaults['delimiter'] = ' &gt; ';
  583. return $defaults;
  584. }
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592. /******************************************************************************/
  593. /****** Add Font Awesome to Redux *********************************************/
  594. /******************************************************************************/
  595.  
  596. function newIconFont() {
  597.  
  598. wp_register_style(
  599. 'redux-font-awesome',
  600. get_template_directory_uri() . '/inc/fonts/font-awesome/css/font-awesome.min.css',
  601. array(),
  602. time(),
  603. 'all'
  604. );
  605. wp_enqueue_style( 'redux-font-awesome' );
  606. }
  607. add_action( 'redux/page/shopkeeper_theme_options/enqueue', 'newIconFont' );
  608.  
  609.  
  610.  
  611.  
  612. /******************************************************************************/
  613. /* Remove Admin Bar - Only display to administrators **************************/
  614. /******************************************************************************/
  615.  
  616. add_action('after_setup_theme', 'remove_admin_bar');
  617. function remove_admin_bar() {
  618. if (!current_user_can('administrator') && !is_admin()) {
  619. show_admin_bar(false);
  620. }
  621. }
  622.  
  623.  
  624.  
  625.  
  626. /******************************************************************************/
  627. /* WooCommerce Update Number of Items in the cart *****************************/
  628. /******************************************************************************/
  629.  
  630. add_action('woocommerce_ajax_added_to_cart', 'shopkeeper_ajax_added_to_cart');
  631. function shopkeeper_ajax_added_to_cart() {
  632.  
  633. add_filter('add_to_cart_fragments', 'shopkeeper_shopping_bag_items_number');
  634. function shopkeeper_shopping_bag_items_number( $fragments )
  635. {
  636. global $woocommerce;
  637. ob_start(); ?>
  638.  
  639. <script>
  640. (function($){
  641. $('.shopping-bag-button').trigger('click');
  642. })(jQuery);
  643. </script>
  644.  
  645. <span class="shopping_bag_items_number"><?php echo esc_html(WC()->cart->get_cart_contents_count()); ?></span>
  646.  
  647. <?php
  648. $fragments['.shopping_bag_items_number'] = ob_get_clean();
  649. return $fragments;
  650. }
  651.  
  652. }
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659. /******************************************************************************/
  660. /* WooCommerce Number of Related Products *************************************/
  661. /******************************************************************************/
  662.  
  663. function woocommerce_output_related_products() {
  664. $atts = array(
  665. 'posts_per_page' => '6',
  666. 'orderby' => 'rand'
  667. );
  668. woocommerce_related_products($atts);
  669. }
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676. /******************************************************************************/
  677. /* WooCommerce Add data-src & lazyOwl to Thumbnails ***************************/
  678. /******************************************************************************/
  679. function woocommerce_get_product_thumbnail( $size = 'product_small_thumbnail', $placeholder_width = 0, $placeholder_height = 0 ) {
  680. global $post;
  681.  
  682. if ( has_post_thumbnail() ) {
  683. $image_src = wp_get_attachment_image_src( get_post_thumbnail_id(), 'shop_catalog' );
  684. return get_the_post_thumbnail( $post->ID, $size, array('data-src' => $image_src[0], 'class' => 'lazyOwl') );
  685. //return '<div><img data-src="' . $image_src[0] . '" class="lazyOwl"></div>';
  686. } elseif ( wc_placeholder_img_src() ) {
  687. return wc_placeholder_img( $size );
  688. }
  689. }
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696. /******************************************************************************/
  697. /* WooCommerce Wrap Oembed Stuff **********************************************/
  698. /******************************************************************************/
  699. add_filter('embed_oembed_html', 'shopkeeper_embed_oembed_html', 99, 4);
  700. function shopkeeper_embed_oembed_html($html, $url, $attr, $post_id) {
  701. return '<div class="video-container">' . $html . '</div>';
  702. }
  703.  
  704.  
  705.  
  706.  
  707. /******************************************************************************/
  708. /* Share Product **************************************************************/
  709. /******************************************************************************/
  710.  
  711. function getbowtied_single_share_product() {
  712. global $post, $product, $shopkeeper_theme_options;
  713. if ( (isset($shopkeeper_theme_options['sharing_options'])) && ($shopkeeper_theme_options['sharing_options'] == "1" ) ) :
  714. ?>
  715.  
  716. <div class="product_socials_wrapper show-share-text-on-mobiles">
  717. <div class="row">
  718. <div class="large-12 columns">
  719.  
  720. <div class="share-product-text">
  721. <?php _e('Share this product', 'shopkeeper' ); ?>
  722. </div><!--.share-product-text-->
  723.  
  724. <?php
  725. //Get the Thumbnail URL
  726. $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), false, '' );
  727. ?>
  728.  
  729. <div class="product_socials_wrapper_inner">
  730. <a href="//www.facebook.com/sharer.php?u=<?php the_permalink(); ?>" target="_blank" class="social_media social_media_facebook"><i class="fa fa-facebook"></i></a>
  731. <a href="//twitter.com/share?url=<?php the_permalink(); ?>" target="_blank" class="social_media social_media_twitter"><i class="fa fa-twitter"></i></a>
  732. <a href="//plus.google.com/share?url=<?php the_permalink(); ?>" target="_blank" class="social_media social_media_googleplus"><i class="fa fa-google-plus"></i></a>
  733. <a href="//pinterest.com/pin/create/button/?url=<?php the_permalink(); ?>&amp;media=<?php echo esc_url($src[0]) ?>&amp;description=<?php echo urlencode(get_the_title()); ?>" target="_blank" class="social_media social_media_pinterest"><i class="fa fa-pinterest"></i></a>
  734. </div><!--.product_socials_wrapper_inner-->
  735.  
  736. </div>
  737. </div>
  738. </div><!--.product_socials_wrapper-->
  739.  
  740. <?php
  741. endif;
  742. }
  743. add_filter( 'getbowtied_woocommerce_before_single_product_summary_data_tabs', 'getbowtied_single_share_product', 50 );
  744.  
  745.  
  746.  
  747.  
  748.  
  749. /******************************************************************************/
  750. /****** WooCommerce Wishlist YITH Ajax Hook ***********************************/
  751. /******************************************************************************/
  752.  
  753. /*function wishlist_shortcode_offcanvas() {
  754. echo do_shortcode('[shopkeeper_yith_wcwl_wishlist]');
  755. die;
  756. }
  757. add_action('wp_ajax_wishlist_shortcode', 'wishlist_shortcode_offcanvas');
  758. add_action('wp_ajax_nopriv_wishlist_shortcode', 'wishlist_shortcode_offcanvas');*/
  759.  
  760.  
  761.  
  762. /******************************************************************************/
  763. /****** Set woocommerce images sizes ******************************************/
  764. /******************************************************************************/
  765.  
  766. /**
  767. * Hook in on activation
  768. */
  769. global $pagenow;
  770. if ( is_admin() && isset( $_GET['activated'] ) && $pagenow == 'themes.php' ) add_action( 'init', 'shopkeeper_woocommerce_image_dimensions', 1 );
  771.  
  772. /**
  773. * Define image sizes
  774. */
  775. function shopkeeper_woocommerce_image_dimensions() {
  776. $catalog = array(
  777. 'width' => '350', // px
  778. 'height' => '435', // px
  779. 'crop' => 1 // true
  780. );
  781.  
  782. $single = array(
  783. 'width' => '570', // px
  784. 'height' => '708', // px
  785. 'crop' => 1 // true
  786. );
  787.  
  788. $thumbnail = array(
  789. 'width' => '70', // px
  790. 'height' => '87', // px
  791. 'crop' => 1 // false
  792. );
  793.  
  794. // Image sizes
  795. update_option( 'shop_catalog_image_size', $catalog ); // Product category thumbs
  796. update_option( 'shop_single_image_size', $single ); // Single product image
  797. update_option( 'shop_thumbnail_image_size', $thumbnail ); // Image gallery thumbs
  798. }
  799.  
  800. if ( ! function_exists('shopkeeper_woocommerce_image_dimensions') ) :
  801. function shopkeeper_woocommerce_image_dimensions() {
  802. global $pagenow;
  803.  
  804. if ( ! isset( $_GET['activated'] ) || $pagenow != 'themes.php' ) {
  805. return;
  806. }
  807.  
  808. $catalog = array(
  809. 'width' => '350', // px
  810. 'height' => '435', // px
  811. 'crop' => 1 // true
  812. );
  813.  
  814. $single = array(
  815. 'width' => '570', // px
  816. 'height' => '708', // px
  817. 'crop' => 1 // true
  818. );
  819.  
  820. $thumbnail = array(
  821. 'width' => '70', // px
  822. 'height' => '87', // px
  823. 'crop' => 0 // false
  824. );
  825.  
  826. // Image sizes
  827. update_option( 'shop_catalog_image_size', $catalog ); // Product category thumbs
  828. update_option( 'shop_single_image_size', $single ); // Single product image
  829. update_option( 'shop_thumbnail_image_size', $thumbnail ); // Image gallery thumbs
  830. }
  831. add_action( 'after_switch_theme', 'shopkeeper_woocommerce_image_dimensions', 1 );
  832. endif;
  833.  
  834. if ( ! isset( $content_width ) ) $content_width = 900;
Advertisement
Add Comment
Please, Sign In to add comment