Advertisement
Guest User

Untitled

a guest
Nov 13th, 2014
931
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 173.11 KB | None | 0 0
  1. <?php
  2. // **********************************************************************//
  3. // ! Set Content Width
  4. // **********************************************************************//
  5. if (!isset( $content_width )) $content_width = 1170;
  6.  
  7. @ini_set( 'upload_max_size' , '64M' );
  8. @ini_set( 'post_max_size', '64M');
  9. @ini_set( 'max_execution_time', '300' );
  10.  
  11. // **********************************************************************//
  12. // ! Include CSS and JS
  13. // **********************************************************************//
  14. if(!function_exists('etheme_enqueue_styles')) {
  15. function etheme_enqueue_styles() {
  16. global $etheme_responsive;
  17.  
  18. $custom_css = etheme_get_option('custom_css');
  19.  
  20. if ( !is_admin() ) {
  21. wp_enqueue_style("style",get_template_directory_uri().'/style.css');
  22. //wp_enqueue_style("theme_style",get_template_directory_uri().'/css/style.css');
  23. //echo "<link href='".get_template_directory_uri().'/css/style.less'."' rel='stylesheet/less' type='text/css'/>";
  24. wp_enqueue_style("font-lato","http://fonts.googleapis.com/css?family=Lato:300,400,700,300italic");
  25. wp_enqueue_style("font-open-sans","http://fonts.googleapis.com/css?family=Open+Sans:300,400,700,300italic");
  26.  
  27.  
  28. if($etheme_responsive){
  29. wp_enqueue_style("responsive",get_template_directory_uri().'/css/responsive.css');
  30. }
  31.  
  32. if($custom_css) {
  33. wp_enqueue_style("custom",get_template_directory_uri().'/custom.css');
  34. }
  35.  
  36. $etheme_color_version = etheme_get_option('main_color_scheme');
  37.  
  38. if($etheme_color_version=='dark') {
  39. wp_enqueue_style("dark",get_template_directory_uri().'/css/dark.css');
  40. }
  41.  
  42. $script_depends = array();
  43.  
  44. if(class_exists('WooCommerce')) {
  45. $script_depends = array('wc-add-to-cart-variation');
  46. }
  47.  
  48.  
  49. wp_enqueue_script('head', get_template_directory_uri().'/js/head.js');
  50. if(etheme_get_option('product_img_hover') == 'tooltip')
  51. wp_enqueue_script('tooltip', get_template_directory_uri().'/js/tooltip.js');
  52. wp_enqueue_script('jquery');
  53. //wp_enqueue_script('flexslider', get_template_directory_uri().'/js/jquery.flexslider-min.js');
  54. wp_enqueue_script('all_plugins', get_template_directory_uri().'/js/plugins.min.js',$script_depends,false,true);
  55. wp_enqueue_script('etheme', get_template_directory_uri().'/js/etheme.js',$script_depends,false,true);
  56. //wp_enqueue_script('emodal', get_template_directory_uri().'/js/emodal.js',array(),false,true);
  57. //wp_enqueue_script('magnific-popup', get_template_directory_uri().'/js/jquery.magnific-popup.min.js',array(),false,true);
  58. //wp_enqueue_script('hoverIntent', get_template_directory_uri().'/js/jquery.hoverIntent.js',array(),false,true);
  59. wp_enqueue_script('waypoints', get_template_directory_uri().'/js/waypoints.min.js',array(),false,true);
  60. //wp_enqueue_script('masonry', get_template_directory_uri().'/js/jquery.masonry.min.js',array(),false,true);
  61. //wp_enqueue_script('mousewheel', get_template_directory_uri().'/js/jquery.mousewheel.js',array(),false,true);
  62. //wp_enqueue_script('easing', get_template_directory_uri().'/js/jquery.easing-1.3.js');
  63. ////wp_enqueue_script('iosslider', get_template_directory_uri().'/js/jquery.iosslider.min.js');
  64. //wp_enqueue_script('owlcarousel', get_template_directory_uri().'/js/owl.carousel.min.js');
  65. //wp_enqueue_script('touch', get_template_directory_uri().'/js/touch.js',array(),false,true);
  66. //wp_enqueue_script('cookie', get_template_directory_uri().'/js/cookie.js',array(),false,true);
  67. //wp_enqueue_script('zoom', get_template_directory_uri().'/js/zoom.js',array(),false,true);
  68. //wp_enqueue_script('cbpQTRotator', get_template_directory_uri().'/js/jquery.cbpQTRotator.min.js',array(),false,true);
  69. //wp_enqueue_script('nicescroll', get_template_directory_uri().'/js/jquery.nicescroll.min.js',array(),false,true);
  70. //wp_enqueue_script('bootstrap', get_template_directory_uri().'/js/bootstrap.min.js',array(),false,true);
  71. //wp_enqueue_script('favico', get_template_directory_uri().'/js/favico-0.3.0.min.js',array(),false,true);
  72.  
  73. //wp_enqueue_style('woocommerce_prettyPhoto_css', get_template_directory_uri().'/css/prettyPhoto.css');
  74. //wp_enqueue_script('prettyPhoto', get_template_directory_uri().'/js/jquery.prettyPhoto.js',array(),false,true);
  75. //wp_enqueue_script('prettyPhoto-init', get_template_directory_uri().'/js/prettyPhoto-init.js',array(),false,true);
  76.  
  77. }
  78. }
  79. }
  80.  
  81. add_action( 'wp_enqueue_scripts', 'etheme_enqueue_styles', 30);
  82.  
  83. // **********************************************************************//
  84. // ! Function for disabling Responsive layout
  85. // **********************************************************************//
  86. if(!function_exists('etheme_set_responsive')) {
  87. function etheme_set_responsive() {
  88. global $etheme_responsive;
  89. $etheme_responsive = etheme_get_option('responsive');
  90. if(isset($_COOKIE['responsive'])) {
  91. $etheme_responsive = false;
  92. }
  93. if(isset($_GET['responsive']) && $_GET['responsive'] == 'off') {
  94. if (!isset($_COOKIE['responsive'])) {
  95. setcookie('responsive', 1, time()+1209600, COOKIEPATH, COOKIE_DOMAIN, false);
  96. }
  97. wp_redirect(get_home_url()); exit();
  98. }elseif(isset($_GET['responsive']) && $_GET['responsive'] == 'on') {
  99. if (isset($_COOKIE['responsive'])) {
  100. setcookie('responsive', 1, time()-1209600, COOKIEPATH, COOKIE_DOMAIN, false);
  101. }
  102. wp_redirect(get_home_url()); exit();
  103. }
  104. }
  105. }
  106.  
  107. add_action( 'init', 'etheme_set_responsive');
  108.  
  109. // **********************************************************************//
  110. // ! Exclude some css from minifier
  111. // **********************************************************************//
  112.  
  113.  
  114. add_filter('bwp_minify_style_ignore', 'et_exclude_css');
  115.  
  116. if(!function_exists('et_exclude_css')) {
  117. function et_exclude_css($excluded) {
  118. $excluded = array('font-awesome');
  119. return $excluded;
  120. }
  121. }
  122.  
  123.  
  124. // **********************************************************************//
  125. // ! Add classes to body
  126. // **********************************************************************//
  127. add_filter('body_class','et_add_body_classes');
  128. if(!function_exists('et_add_body_classes')) {
  129. function et_add_body_classes($classes) {
  130. if(etheme_get_option('top_panel')) $classes[] = 'topPanel-enabled ';
  131. if(etheme_get_option('right_panel')) $classes[] = 'rightPanel-enabled ';
  132. if(etheme_get_option('fixed_nav')) $classes[] = 'fixNav-enabled ';
  133. if(etheme_get_option('fade_animation')) $classes[] = 'fadeIn-enabled ';
  134. if(etheme_get_option('cats_accordion')) $classes[] = 'accordion-enabled ';
  135. if(!class_exists('Woocommerce') || etheme_get_option('just_catalog') || !etheme_get_option('cart_widget')) $classes[] = 'top-cart-disabled ';
  136. $classes[] = 'banner-mask-'.etheme_get_option('banner_mask');
  137. $classes[] = etheme_get_option('main_layout');
  138. return $classes;
  139. }
  140. }
  141. // **********************************************************************//
  142. // ! Ititialize theme confoguration and variables
  143. // **********************************************************************//
  144. add_action('wp_head', 'etheme_init');
  145. if(!function_exists('etheme_init')) {
  146. function etheme_init() {
  147. global $etheme_responsive;
  148. foreach(etheme_get_chosen_google_font() as $font) {
  149. ?>
  150. <link href='http://fonts.googleapis.com/css?family=<?php echo $font; ?>' rel='stylesheet' type='text/css'/>
  151. <?php
  152. }
  153. ?>
  154.  
  155. <style type="text/css">
  156.  
  157. <?php if ( etheme_get_option('sale_icon') ) : ?>
  158. .label-icon.sale-label {
  159. width: <?php echo (etheme_get_option('sale_icon_width')) ? etheme_get_option('sale_icon_width') : 67 ?>px;
  160. height: <?php echo (etheme_get_option('sale_icon_height')) ? etheme_get_option('sale_icon_height') : 67 ?>px;
  161. }
  162. .label-icon.sale-label { background-image: url(<?php echo (etheme_get_option('sale_icon_url')) ? etheme_get_option('sale_icon_url') : get_template_directory_uri() .'/images/label-sale.png' ?>); }
  163. <?php endif; ?>
  164.  
  165. <?php if ( etheme_get_option('new_icon') ) : ?>
  166. .label-icon.new-label {
  167. width: <?php echo (etheme_get_option('new_icon_width')) ? etheme_get_option('new_icon_width') : 67 ?>px;
  168. height: <?php echo (etheme_get_option('new_icon_height')) ? etheme_get_option('new_icon_height') : 67 ?>px;
  169. }
  170. .label-icon.new-label { background-image: url(<?php echo (etheme_get_option('new_icon_url')) ? etheme_get_option('new_icon_url') : get_template_directory_uri() .'/images/label-new.png' ?>); }
  171.  
  172. <?php endif; ?>
  173.  
  174. </style>
  175.  
  176. <div id="styles-bg">
  177. <style type="text/css">
  178. <?php $bg = etheme_get_option('background_img'); ?>
  179. body {
  180. <?php if(!empty($bg['background-color'])): ?> background-color: <?php echo $bg['background-color']; ?>;<?php endif; ?>
  181. <?php if(!empty($bg['background-image'])): ?> background-image: url(<?php echo $bg['background-image']; ?>) ; <?php endif; ?>
  182. <?php if(!empty($bg['background-attachment'])): ?> background-attachment: <?php echo $bg['background-attachment']; ?>;<?php endif; ?>
  183. <?php if(!empty($bg['background-repeat'])): ?> background-repeat: <?php echo $bg['background-repeat']; ?>;<?php endif; ?>
  184. <?php if(!empty($bg['background-color'])): ?> background-color: <?php echo $bg['background-color']; ?>;<?php endif; ?>
  185. <?php if(!empty($bg['background-position'])): ?> background-position: <?php echo $bg['background-position']; ?>;<?php endif; ?>
  186. <?php if(etheme_get_option('background_cover') == 'enable'): ?>
  187. background-size: cover;
  188. <?php endif; ?>
  189. }
  190. </style>
  191. </div>
  192. <?php
  193.  
  194. $selectors = array();
  195. $selectors['main_font'] = '
  196. .dropcap,
  197. blockquote,
  198. .team-member .member-mask .mask-text fieldset legend,
  199. .button,
  200. button,
  201. .coupon .button,
  202. input[type="submit"],
  203. .font2,
  204. .shopping-cart-widget .totals,
  205. .main-nav .menu > li > a,
  206. .menu-wrapper .menu .nav-sublist-dropdown .menu-parent-item > a,
  207. .fixed-header .menu .nav-sublist-dropdown .menu-parent-item > a,
  208. .fixed-header .menu > li > a,
  209. .side-block .close-block,
  210. .side-area .widget-title,
  211. .et-mobile-menu li > a,
  212. .page-heading .row-fluid .span12 > .back-to,
  213. .breadcrumbs .back-to,
  214. .recent-post-mini a,
  215. .etheme_widget_recent_comments ul li .post-title,
  216. .product_list_widget a,
  217. .widget_price_filter .widget-title,
  218. .widget_layered_nav .widget-title,
  219. .widget_price_filter h4,
  220. .widget_layered_nav h4,
  221. .products-list .product .product-name,
  222. .table.products-table th,
  223. .table.products-table .product-name a,
  224. .table.products-table .product-name dl dt,
  225. .table.products-table .product-name dl dd,
  226. .cart_totals .table .total th strong,
  227. .cart_totals .table .total td strong .amount,
  228. .pricing-table table .plan-price,
  229. .pricing-table table.table thead:first-child tr:first-child th,
  230. .pricing-table.style3 table .plan-price sup,
  231. .pricing-table.style2 table .plan-price sup,
  232. .pricing-table ul li.row-title,
  233. .pricing-table ul li.row-price,
  234. .pricing-table.style2 ul li.row-price sup,
  235. .pricing-table.style3 ul li.row-price sup,
  236. .tabs .tab-title,
  237. .left-bar .left-titles .tab-title-left,
  238. .right-bar .left-titles .tab-title-left,
  239. .slider-container .show-all-posts,
  240. .bc-type-variant2 .woocommerce-breadcrumb,
  241. .bc-type-variant2 .breadcrumbs
  242. ';
  243.  
  244. $selectors['font_color'] = '
  245. body,
  246. select,
  247. .products-small .product-item a,
  248. .woocommerce-breadcrumb,
  249. #breadcrumb,
  250. .woocommerce-breadcrumb a,
  251. #breadcrumb a,
  252. .etheme_widget_recent_comments .comment_link a,
  253. .product-categories li ul a,
  254. .product_list_widget del .amount,
  255. .page-numbers li a,
  256. .page-numbers li span,
  257. .pagination li a,
  258. .pagination li span,
  259. .images .main-image-slider ul.slides .zoom-link:hover,
  260. .quantity .qty,
  261. .price .from,
  262. .price del,
  263. .shopping-cart-widget .cart-summ .items,
  264. .shopping-cart-widget .cart-summ .for-label,
  265. .posted-in a,
  266. .tabs .tab-title,
  267. .toggle-element .open-this,
  268. .blog-post .post-info .posted-in a,
  269. .menu-type1 .menu ul > li > a,
  270. .post-next-prev a
  271.  
  272. ';
  273. $selectors['active_color'] = '
  274. a:hover,
  275. .button:hover,
  276. button:hover,
  277. input[type="submit"]:hover,
  278. .menu-icon:hover,
  279. .widget_layered_nav ul li:hover,
  280. .page-numbers li span,
  281. .pagination li span,
  282. .page-numbers li a:hover,
  283. .pagination li a:hover,
  284. .largest,
  285. .thumbnail:hover i,
  286. .demo-icons .demo-icon:hover,
  287. .demo-icons .demo-icon:hover i,
  288. .switchToGrid:hover,
  289. .switchToList:hover,
  290. .switcher-active,
  291. .switcher-active:hover,
  292. .emodal .close-modal:hover,
  293. .prev.page-numbers:hover:after,
  294. .next.page-numbers:hover:after,
  295. strong.active,
  296. span.active,
  297. em.active,
  298. a.active,
  299. p.active,
  300. .shopping-cart-widget .cart-summ .price-summ,
  301. .products-small .product-item h5 a:hover,
  302. .slider-container .slider-next:hover:before,
  303. .slider-container .slider-prev:hover:before,
  304. .fullwidthbanner-container .tp-rightarrow.default:hover:before,
  305. .fullwidthbanner-container .tp-leftarrow.default:hover:before,
  306. .side-area .close-block:hover i,
  307. .back-to-top:hover, .back-to-top:hover i,
  308. .product-info .single_add_to_wishlist:hover:before,
  309. .images .main-image-slider ul.slides .zoom-link i:hover,
  310. .footer_menu li:hover:before,
  311. .main-nav .menu > li.current-menu-parent > a,
  312. .main-nav .menu > li.current-menu-item > a,
  313. .page-numbers .next:hover:before,
  314. .pagination .next:hover:before,
  315. .etheme_twitter .tweet a,
  316. .small-slider-arrow.arrow-left:hover,
  317. .small-slider-arrow.arrow-right:hover,
  318. .active2:hover,
  319. .active2,
  320. .checkout-steps-nav a.button.active,
  321. .checkout-steps-nav a.button.active:hover,
  322. .button.active,
  323. button.active,
  324. input[type="submit"].active,
  325. .widget_categories .current-cat a,
  326. div.dark_rounded .pp_contract:hover,
  327. div.dark_rounded .pp_expand:hover,
  328. div.dark_rounded .pp_close:hover,
  329. .etheme_cp .etheme_cp_head .etheme_cp_btn_close:hover,
  330. .hover-icon:hover,
  331. .side-area-icon:hover,
  332. .etheme_cp .etheme_cp_content .etheme_cp_section .etheme_cp_section_header .etheme_cp_btn_clear:hover,
  333. .header-type-3 .main-nav .menu-wrapper .menu > li.current-menu-item > a,
  334. .header-type-3 .main-nav .menu-wrapper .menu > li.current-menu-parent > a,
  335. .header-type-3 .main-nav .menu-wrapper .menu > li > a:hover,
  336. .fixed-header .menu > li.current-menu-item > a,
  337. .fixed-header .menu > li > a:hover,
  338. .main-nav .menu > li > a:hover,
  339. .product-categories > li > a:hover,
  340. .custom-info-block.a-right span,
  341. .custom-info-block.a-left span,
  342. .custom-info-block a i:hover,
  343. .product-categories > li.current-cat > a,
  344. .menu-wrapper .menu .nav-sublist-dropdown .menu-parent-item > a:hover,
  345. .woocommerce .woocommerce-breadcrumb a:hover,
  346. .woocommerce-page .woocommerce-breadcrumb a:hover,
  347. .product-info .posted_in a:hover,
  348. .slide-item .product .products-page-cats a:hover,
  349. .products-grid .product .products-page-cats a:hover,
  350. .widget_layered_nav ul li:hover a,
  351. .page-heading .row-fluid .span12 > .back-to:hover,
  352. .breadcrumbs .back-to:hover,
  353. #breadcrumb a:hover,
  354. .links li a:hover,
  355. .menu-wrapper .menu > .nav-sublist-dropdown .menu-parent-item ul li:hover,
  356. .menu-wrapper .menu > .nav-sublist-dropdown .menu-parent-item ul li:hover a,
  357. .menu-wrapper .menu ul > li > a:hover,
  358. .filled.active,
  359. .shopping-cart-widget .cart-summ a:hover,
  360. .product-categories > li > ul > li > a:hover,
  361. .product-categories > li > ul > li > a:hover + span,
  362. .product-categories ul.children li > a:hover,
  363. .product-categories ul.children li > a:hover + span,
  364. .product-categories > li.current-cat > a+span,
  365. .widget_nav_menu .current-menu-item a,
  366. .widget_nav_menu .current-menu-item:before,
  367. .fixed-menu-type2 .fixed-header .nav-sublist-dropdown li a:hover,
  368. .product-category h5:hover,
  369. .product-categories .children li.current-cat,
  370. .product-categories .children li.current-cat a,
  371. .product-categories .children li.current-cat span,
  372. .pricing-table ul li.row-price,
  373. .product-category:hover h5,
  374. .widget_nav_menu li a:hover,
  375. .widget_nav_menu li:hover:before,
  376. .list li:before,
  377. .blog-post .post-info a:hover,
  378. .show-all-posts:hover,
  379. .cbp-qtrotator .testimonial-author .excerpt,
  380. .top-bar .wishlist-link a:hover span,
  381. .menu-type2 .menu .nav-sublist-dropdown .menu-parent-item li:hover:before,
  382. .back-to-top:hover:before,
  383. .tabs .tab-title:hover,
  384. .flex-direction-nav a:hover,
  385. .widget_layered_nav ul li a:hover,
  386. .widget_layered_nav ul li:hover,
  387. .product-categories .open-this:hover,
  388. .widget_categories li:hover:before,
  389. .etheme-social-icons li a:hover,
  390. .product-categories > li.opened .open-this:hover,
  391. .slider-container .show-all-posts:hover,
  392. .widget_layered_nav ul li.chosen .count,
  393. .widget_layered_nav ul li.chosen a,
  394. .widget_layered_nav ul li.chosen a:before,
  395. .recent-post-mini strong,
  396. .menu-wrapper .menu ul > li:hover:before,
  397. .fixed-header .menu ul > li:hover:before,
  398. .team-member .member-mask .mask-text a:hover,
  399. .show-quickly:hover,
  400. .header-type-6 .top-bar .top-links .submenu-dropdown ul li a:hover,
  401. .header-type-6 .top-bar .top-links .submenu-dropdown ul li:hover:before,
  402. .side-area-icon i:hover:before,
  403. .menu-icon i:hover:before
  404. ';
  405.  
  406. // important
  407. $selectors['active_color_important'] = '
  408. .hover-icon:hover
  409. ';
  410.  
  411. // Price COLOR!
  412. $selectors['pricecolor'] = '
  413. .products-small .product-item .price,
  414. .product_list_widget .amount,
  415. .cart_totals .table .total .amount,
  416. .price
  417. ';
  418.  
  419. $selectors['active_bg'] = '
  420. .filled:hover,
  421. .progress-bar > div,
  422. .active2:hover,
  423. .button.active:hover,
  424. button.active:hover,
  425. input[type="submit"].active:hover,
  426. .checkout-steps-nav a.button.active:hover,
  427. .portfolio-filters .active,
  428. .product-info .single_add_to_cart_button,
  429. .product-info .single_add_to_wishlist:hover,
  430. .checkout-button.button,
  431. .checkout-button.button:hover,
  432. .header-type-6 .top-bar,
  433. .filled.active,
  434. .block-with-ico.ico-position-top i,
  435. .added-text,
  436. .etheme_cp_btn_show,
  437. .toolbar .switchToList:hover,
  438. .toolbar .switchToList.switcher-active,
  439. .toolbar .switchToGrid:hover,
  440. .toolbar .switchToGrid.switcher-active,
  441. .button.white.filled:hover,
  442. .button.active,
  443. .button.active2,
  444. .button.white:hover
  445. ';
  446. $selectors['active_border'] = '
  447. .button:hover,
  448. button:hover,
  449. .button.white.filled:hover,
  450. input[type="submit"]:hover,
  451. .button.active,
  452. button.active,
  453. input[type="submit"].active,
  454. .filled:hover,
  455. .widget_layered_nav ul li:hover,
  456. .page-numbers li span,
  457. .pagination li span,
  458. .page-numbers li a:hover,
  459. .pagination li a:hover,
  460. .switchToGrid:hover,
  461. .switchToList:hover,
  462. .toolbar .switchToGrid.switcher-active,
  463. .toolbar .switchToList.switcher-active,
  464. textarea:focus,
  465. input[type="text"]:focus,
  466. input[type="password"]:focus,
  467. input[type="datetime"]:focus,
  468. input[type="datetime-local"]:focus,
  469. input[type="date"]:focus,
  470. input[type="month"]:focus,
  471. input[type="time"]:focus,
  472. input[type="week"]:focus,
  473. input[type="number"]:focus,
  474. input[type="email"]:focus,
  475. input[type="url"]:focus,
  476. input[type="search"]:focus,
  477. input[type="tel"]:focus,
  478. input[type="color"]:focus,
  479. .uneditable-input:focus,
  480. .active2,
  481. .woocommerce.widget_price_filter .ui-slider .ui-slider-range,
  482. .woocommerce-page .widget_price_filter .ui-slider .ui-slider-range,
  483. .checkout-steps-nav a.button.active,
  484. .product-info .single_add_to_cart_button,
  485. .main-nav .menu > li.current-menu-parent > a:before,
  486. .main-nav .menu > li.current-menu-item > a:before,
  487. .cta-block.style-filled,
  488. .search #searchform input[type="text"]:focus,
  489. .product-categories .open-this:hover,
  490. .product-categories > li.opened .open-this:hover
  491.  
  492. ';
  493.  
  494.  
  495. $selectors['darken_color'] = '
  496. ';
  497.  
  498. $selectors['darken_bg'] = '
  499. .woocommerce.widget_price_filter .ui-slider .ui-slider-handle
  500. ';
  501.  
  502. $selectors['darken_border'] = '
  503. ';
  504. ?>
  505.  
  506. <style type="text/css">
  507. <?php echo jsString($selectors['font_color']); ?> { color: #6f6f6f; }
  508. </style>
  509.  
  510. <?php
  511. $activeColor = (etheme_get_option('activecol')) ? etheme_get_option('activecol') : '#d7a200';
  512. $priceColor = (etheme_get_option('pricecolor')) ? etheme_get_option('pricecolor') : '#d7a200';
  513.  
  514. $rgb = hex2rgb($activeColor);
  515.  
  516. $darkenRgb = array();
  517.  
  518. $darkenRgb[0] = $rgb[0] - 30;
  519. $darkenRgb[1] = $rgb[1] - 30;
  520. $darkenRgb[2] = $rgb[2] - 30;
  521.  
  522. $darkenColor = 'rgb('.$darkenRgb[0].','.$darkenRgb[1].','.$darkenRgb[2].')';
  523.  
  524. ?>
  525.  
  526. <div id="styles-main-color">
  527. <style type="text/css">
  528. <?php echo jsString($selectors['active_color']); ?> { color: <?php echo $activeColor; ?>; }
  529.  
  530. <?php echo jsString($selectors['active_color_important']); ?> { color: <?php echo $activeColor; ?>!important; }
  531.  
  532. <?php echo jsString($selectors['active_bg']); ?> { background-color: <?php echo $activeColor; ?>; }
  533.  
  534. <?php echo jsString($selectors['active_border']); ?> { border-color: <?php echo $activeColor; ?>; }
  535.  
  536. </style>
  537. </div>
  538.  
  539. <div id="styles-price-color">
  540. <style type="text/css">
  541. <?php echo jsString($selectors['pricecolor']); ?> { color: <?php echo $priceColor; ?>; }
  542. </style>
  543. </div>
  544.  
  545. <div id="styles-darken-color">
  546. <style type="text/css">
  547. <?php echo jsString($selectors['darken_color']); ?> { color: <?php echo $darkenColor; ?>; }
  548.  
  549. <?php echo jsString($selectors['darken_bg']); ?> { background-color: <?php echo $darkenColor; ?>; }
  550.  
  551. <?php echo jsString($selectors['darken_border']); ?> { border-color: <?php echo $darkenColor; ?>; }
  552.  
  553. </style>
  554. </div>
  555.  
  556. <style>
  557. .woocommerce.widget_price_filter .ui-slider .ui-slider-range,
  558. .woocommerce-page .widget_price_filter .ui-slider .ui-slider-range{
  559. background: <?php echo 'rgba('.$rgb[0].','.$rgb[1].','.$rgb[2].',0.35)' ?>;
  560. }
  561.  
  562. </style>
  563.  
  564. <style type="text/css">
  565. <?php $h1 = etheme_get_option('h1'); ?>
  566. <?php $h2 = etheme_get_option('h2'); ?>
  567. <?php $h3 = etheme_get_option('h3'); ?>
  568. <?php $h4 = etheme_get_option('h4'); ?>
  569. <?php $h5 = etheme_get_option('h5'); ?>
  570. <?php $h6 = etheme_get_option('h6'); ?>
  571. <?php $sfont = etheme_get_option('sfont'); ?>
  572. <?php $mainfont = etheme_get_option('mainfont'); ?>
  573.  
  574. body {
  575. <?php if(!empty($sfont['font-color'])) :?> color: <?php echo $sfont['font-color'].';'; endif; ?>
  576. <?php if(!empty($sfont['font-family'])): ?> font-family: <?php echo $sfont['font-family'].';'; endif; ?>
  577. <?php if(!empty($sfont['google-font'])): ?> font-family: <?php echo str_replace("+", " ", $sfont['google-font']).';'; endif; ?>
  578. <?php if(!empty($sfont['font-size'])): ?> font-size: <?php echo $sfont['font-size'].';'; endif; ?>
  579. <?php if(!empty($sfont['font-style'])): ?> font-style: <?php echo $sfont['font-style'].';'; endif; ?>
  580. <?php if(!empty($sfont['font-weight'])): ?> font-weight: <?php echo $sfont['font-weight'].';'; endif; ?>
  581. <?php if(!empty($sfont['font-variant'])): ?> font-variant: <?php echo $sfont['font-variant'].';'; endif; ?>
  582. <?php if(!empty($sfont['letter-spacing'])): ?> letter-spacing: <?php echo $sfont['letter-spacing'].';'; endif; ?>
  583. <?php if(!empty($sfont['line-height'])): ?> line-height: <?php echo $sfont['line-height'].';'; endif; ?>
  584. <?php if(!empty($sfont['text-decoration'])): ?> text-decoration: <?php echo $sfont['text-decoration'].';'; endif; ?>
  585. <?php if(!empty($sfont['text-transform'])): ?> text-transform: <?php echo $sfont['text-transform'].';'; endif; ?>
  586. }
  587.  
  588. h1 {
  589. <?php if(!empty($h1['font-color'])) :?> color: <?php echo $h1['font-color'].';'; endif; ?>
  590. <?php if(!empty($h1['font-family'])): ?> font-family: <?php echo $h1['font-family'].';'; endif; ?>
  591. <?php if(!empty($h1['google-font'])): ?> font-family: <?php echo str_replace("+", " ", $h1['google-font']).';'; endif; ?>
  592. <?php if(!empty($h1['font-size'])): ?> font-size: <?php echo $h1['font-size'].';'; endif; ?>
  593. <?php if(!empty($h1['font-style'])): ?> font-style: <?php echo $h1['font-style'].';'; endif; ?>
  594. <?php if(!empty($h1['font-weight'])): ?> font-weight: <?php echo $h1['font-weight'].';'; endif; ?>
  595. <?php if(!empty($h1['font-variant'])): ?> font-variant: <?php echo $h1['font-variant'].';'; endif; ?>
  596. <?php if(!empty($h1['letter-spacing'])): ?> letter-spacing: <?php echo $h1['letter-spacing'].';'; endif; ?>
  597. <?php if(!empty($h1['line-height'])): ?> line-height: <?php echo $h1['line-height'].';'; endif; ?>
  598. <?php if(!empty($h1['text-decoration'])): ?> text-decoration: <?php echo $h1['text-decoration'].';'; endif; ?>
  599. <?php if(!empty($h1['text-transform'])): ?> text-transform: <?php echo $h1['text-transform'].';'; endif; ?>
  600. }
  601. h2 {
  602. <?php if(!empty($h2['font-color'])) :?> color: <?php echo $h2['font-color'].';'; endif; ?>
  603. <?php if(!empty($h2['font-family'])): ?> font-family: <?php echo $h2['font-family'].';'; endif; ?>
  604. <?php if(!empty($h2['google-font'])): ?> font-family: <?php echo str_replace("+", " ", $h2['google-font']).';'; endif; ?>
  605. <?php if(!empty($h2['font-size'])): ?> font-size: <?php echo $h2['font-size'].';'; endif; ?>
  606. <?php if(!empty($h2['font-style'])): ?> font-style: <?php echo $h2['font-style'].';'; endif; ?>
  607. <?php if(!empty($h2['font-weight'])): ?> font-weight: <?php echo $h2['font-weight'].';'; endif; ?>
  608. <?php if(!empty($h2['font-variant'])): ?> font-variant: <?php echo $h2['font-variant'].';'; endif; ?>
  609. <?php if(!empty($h2['letter-spacing'])): ?> letter-spacing: <?php echo $h2['letter-spacing'].';'; endif; ?>
  610. <?php if(!empty($h2['line-height'])): ?> line-height: <?php echo $h2['line-height'].';'; endif; ?>
  611. <?php if(!empty($h2['text-decoration'])): ?> text-decoration: <?php echo $h2['text-decoration'].';'; endif; ?>
  612. <?php if(!empty($h2['text-transform'])): ?> text-transform: <?php echo $h2['text-transform'].';'; endif; ?>
  613. }
  614. h3 {
  615. <?php if(!empty($h3['font-color'])) :?> color: <?php echo $h3['font-color'].';'; endif; ?>
  616. <?php if(!empty($h3['font-family'])): ?> font-family: <?php echo $h3['font-family'].';'; endif; ?>
  617. <?php if(!empty($h3['google-font'])): ?> font-family: <?php echo str_replace("+", " ", $h3['google-font']).';'; endif; ?>
  618. <?php if(!empty($h3['font-size'])): ?> font-size: <?php echo $h3['font-size'].';'; endif; ?>
  619. <?php if(!empty($h3['font-style'])): ?> font-style: <?php echo $h3['font-style'].';'; endif; ?>
  620. <?php if(!empty($h3['font-weight'])): ?> font-weight: <?php echo $h3['font-weight'].';'; endif; ?>
  621. <?php if(!empty($h3['font-variant'])): ?> font-variant: <?php echo $h3['font-variant'].';'; endif; ?>
  622. <?php if(!empty($h3['letter-spacing'])): ?> letter-spacing: <?php echo $h3['letter-spacing'].';'; endif; ?>
  623. <?php if(!empty($h3['line-height'])): ?> line-height: <?php echo $h3['line-height'].';'; endif; ?>
  624. <?php if(!empty($h3['text-decoration'])): ?> text-decoration: <?php echo $h3['text-decoration'].';'; endif; ?>
  625. <?php if(!empty($h3['text-transform'])): ?> text-transform: <?php echo $h3['text-transform'].';'; endif; ?>
  626. }
  627. h4 {
  628. <?php if(!empty($h4['font-color'])) :?> color: <?php echo $h4['font-color'].';'; endif; ?>
  629. <?php if(!empty($h4['font-family'])): ?> font-family: <?php echo $h4['font-family'].';'; endif; ?>
  630. <?php if(!empty($h4['google-font'])): ?> font-family: <?php echo str_replace("+", " ", $h4['google-font']).';'; endif; ?>
  631. <?php if(!empty($h4['font-size'])): ?> font-size: <?php echo $h4['font-size'].';'; endif; ?>
  632. <?php if(!empty($h4['font-style'])): ?> font-style: <?php echo $h4['font-style'].';'; endif; ?>
  633. <?php if(!empty($h4['font-weight'])): ?> font-weight: <?php echo $h4['font-weight'].';'; endif; ?>
  634. <?php if(!empty($h4['font-variant'])): ?> font-variant: <?php echo $h4['font-variant'].';'; endif; ?>
  635. <?php if(!empty($h4['letter-spacing'])): ?> letter-spacing: <?php echo $h4['letter-spacing'].';'; endif; ?>
  636. <?php if(!empty($h4['line-height'])): ?> line-height: <?php echo $h4['line-height'].';'; endif; ?>
  637. <?php if(!empty($h4['text-decoration'])): ?> text-decoration: <?php echo $h4['text-decoration'].';'; endif; ?>
  638. <?php if(!empty($h4['text-transform'])): ?> text-transform: <?php echo $h4['text-transform'].';'; endif; ?>
  639. }
  640. h5 {
  641. <?php if(!empty($h5['font-color'])) :?> color: <?php echo $h5['font-color'].';'; endif; ?>
  642. <?php if(!empty($h5['font-family'])): ?> font-family: <?php echo $h5['font-family'].';'; endif; ?>
  643. <?php if(!empty($h5['google-font'])): ?> font-family: <?php echo str_replace("+", " ", $h5['google-font']).';'; endif; ?>
  644. <?php if(!empty($h5['font-size'])): ?> font-size: <?php echo $h5['font-size'].';'; endif; ?>
  645. <?php if(!empty($h5['font-style'])): ?> font-style: <?php echo $h5['font-style'].';'; endif; ?>
  646. <?php if(!empty($h5['font-weight'])): ?> font-weight: <?php echo $h5['font-weight'].';'; endif; ?>
  647. <?php if(!empty($h5['font-variant'])): ?> font-variant: <?php echo $h5['font-variant'].';'; endif; ?>
  648. <?php if(!empty($h5['letter-spacing'])): ?> letter-spacing: <?php echo $h5['letter-spacing'].';'; endif; ?>
  649. <?php if(!empty($h5['line-height'])): ?> line-height: <?php echo $h5['line-height'].';'; endif; ?>
  650. <?php if(!empty($h5['text-decoration'])): ?> text-decoration: <?php echo $h5['text-decoration'].';'; endif; ?>
  651. <?php if(!empty($h5['text-transform'])): ?> text-transform: <?php echo $h5['text-transform'].';'; endif; ?>
  652. }
  653. h6 {
  654. <?php if(!empty($h6['font-color'])) :?> color: <?php echo $h6['font-color'].';'; endif; ?>
  655. <?php if(!empty($h6['font-family'])): ?> font-family: <?php echo $h6['font-family'].';'; endif; ?>
  656. <?php if(!empty($h6['google-font'])): ?> font-family: <?php echo str_replace("+", " ", $h6['google-font']).';'; endif; ?>
  657. <?php if(!empty($h6['font-size'])): ?> font-size: <?php echo $h6['font-size'].';'; endif; ?>
  658. <?php if(!empty($h6['font-style'])): ?> font-style: <?php echo $h6['font-style'].';'; endif; ?>
  659. <?php if(!empty($h6['font-weight'])): ?> font-weight: <?php echo $h6['font-weight'].';'; endif; ?>
  660. <?php if(!empty($h6['font-variant'])): ?> font-variant: <?php echo $h6['font-variant'].';'; endif; ?>
  661. <?php if(!empty($h6['letter-spacing'])): ?> letter-spacing: <?php echo $h6['letter-spacing'].';'; endif; ?>
  662. <?php if(!empty($h6['line-height'])): ?> line-height: <?php echo $h6['line-height'].';'; endif; ?>
  663. <?php if(!empty($h6['text-decoration'])): ?> text-decoration: <?php echo $h6['text-decoration'].';'; endif; ?>
  664. <?php if(!empty($h6['text-transform'])): ?> text-transform: <?php echo $h6['text-transform'].';'; endif; ?>
  665. }
  666. <?php echo jsString($selectors['main_font']); ?> {
  667. <?php if(!empty($mainfont['font-color'])) :?> color: <?php echo $mainfont['font-color'].';'; endif; ?>
  668. <?php if(!empty($mainfont['font-family'])): ?> font-family: <?php echo $mainfont['font-family'].';'; endif; ?>
  669. <?php if(!empty($mainfont['google-font'])): ?> font-family: <?php echo str_replace("+", " ", $mainfont['google-font']).';'; endif; ?>
  670. <?php if(!empty($mainfont['font-size'])): ?> font-size: <?php echo $mainfont['font-size'].';'; endif; ?>
  671. <?php if(!empty($mainfont['font-style'])): ?> font-style: <?php echo $mainfont['font-style'].';'; endif; ?>
  672. <?php if(!empty($mainfont['font-weight'])): ?> font-weight: <?php echo $mainfont['font-weight'].';'; endif; ?>
  673. <?php if(!empty($mainfont['font-variant'])): ?> font-variant: <?php echo $mainfont['font-variant'].';'; endif; ?>
  674. <?php if(!empty($mainfont['letter-spacing'])): ?> letter-spacing: <?php echo $mainfont['letter-spacing'].';'; endif; ?>
  675. <?php if(!empty($mainfont['line-height'])): ?> line-height: <?php echo $mainfont['line-height'].';'; endif; ?>
  676. <?php if(!empty($mainfont['text-decoration'])): ?> text-decoration: <?php echo $mainfont['text-decoration'].';'; endif; ?>
  677. <?php if(!empty($mainfont['text-transform'])): ?> text-transform: <?php echo $mainfont['text-transform'].';'; endif; ?>
  678. }
  679. </style>
  680. <script type="text/javascript">
  681. var active_color_selector = '<?php echo jsString($selectors['active_color']); ?>';
  682. var active_bg_selector = '<?php echo jsString($selectors['active_bg']); ?>';
  683. var active_border_selector = '<?php echo jsString($selectors['active_border']); ?>';
  684. var active_color_default = '<?php echo $activeColor; ?>';
  685. var bg_default = '<?php etheme_option('backgroundcol') ?>';
  686. var pattern_default = '<?php if(!empty($bg['background-image'])): echo $bg['background-image']; endif; ?>';
  687.  
  688.  
  689. var ajaxFilterEnabled = <?php echo (etheme_get_option('ajax_filter')) ? 1 : 0; ?>;
  690. var successfullyAdded = '<?php _e('successfully added to your shopping cart', ETHEME_DOMAIN) ?>';
  691. var view_mode_default = '<?php echo etheme_get_option('view_mode'); ?>';
  692. var catsAccordion = false;
  693. <?php if (etheme_get_option('cats_accordion')) {
  694. ?>
  695. catsAccordion = true;
  696. <?php
  697. } ?>
  698. <?php if (class_exists('WooCommerce')) {
  699. global $woocommerce;
  700. ?>
  701. var checkoutUrl = '<?php echo esc_url( $woocommerce->cart->get_checkout_url() ); ?>';
  702. var contBtn = '<?php _e('Continue shopping', ETHEME_DOMAIN) ?>';
  703. var checkBtn = '<?php _e('Checkout', ETHEME_DOMAIN) ?>';
  704. <?php
  705. } ?>
  706. <?php if(etheme_get_option('nice_scroll')): ?>
  707. jQuery(document).ready(function(){
  708. jQuery("body").niceScroll({
  709. hidecursordelay: 100000,
  710. scrollspeed: 60,
  711. cursorwidth: 6,
  712. cursorborder: '1px solid #909090',
  713. cursorborderradius: 0,
  714. horizrailenabled:false
  715. });
  716. });
  717. <?php endif; ?>
  718. </script>
  719.  
  720. <?php if ($etheme_responsive): ?>
  721. <style type="text/css">
  722. @import url("<?php echo get_template_directory_uri(); ?>/css/large-resolution.css") (min-width:<?php echo (etheme_get_option('responsive_from')) ? etheme_get_option('responsive_from') : '1440' ; ?>px);
  723. </style>
  724. <?php endif;
  725. }
  726. }
  727.  
  728.  
  729. // **********************************************************************//
  730. // ! Add theme support
  731. // **********************************************************************//
  732.  
  733. if(function_exists('add_theme_support')) {
  734. add_theme_support('post-thumbnails', array('post'));
  735. add_theme_support( 'automatic-feed-links' );
  736. add_theme_support( 'woocommerce' );
  737. }
  738. // **********************************************************************//
  739. // ! Add admin styles and scripts
  740. // **********************************************************************//
  741.  
  742. add_action('admin_init', 'etheme_load_admin_styles');
  743. function etheme_load_admin_styles() {
  744. wp_enqueue_style('farbtastic');
  745. wp_enqueue_style('etheme_admin_css', ETHEME_CODE_CSS_URL.'/admin.css');
  746. }
  747. add_action('admin_init','etheme_add_admin_script', 1130);
  748.  
  749. function etheme_add_admin_script(){
  750. add_thickbox();
  751. wp_enqueue_script('theme-preview');
  752. wp_enqueue_script('common');
  753. wp_enqueue_script('wp-lists');
  754. wp_enqueue_script('postbox');
  755. wp_enqueue_script('farbtastic');
  756. wp_enqueue_script('etheme_admin_js', ETHEME_CODE_JS_URL.'/admin.js',array('wpb_php_js','wpb_js_composer_js_view','wpb_js_composer_js_custom_views'),false,true);
  757. wp_enqueue_style("font-awesome",get_template_directory_uri().'/css/font-awesome.min.css');
  758. wp_enqueue_style("font-lato","http://fonts.googleapis.com/css?family=Lato:300,400,700,300italic");
  759. }
  760.  
  761.  
  762. // **********************************************************************//
  763. // ! Menus
  764. // **********************************************************************//
  765. if(!function_exists('etheme_register_menus')) {
  766. function etheme_register_menus() {
  767. register_nav_menus(array(
  768. 'main-menu' => __('Main menu', ETHEME_DOMAIN),
  769. 'mobile-menu' => __('Mobile menu', ETHEME_DOMAIN),
  770. 'account-menu' => __('Account menu', ETHEME_DOMAIN)
  771. ));
  772. }
  773. }
  774.  
  775. add_action('init', 'etheme_register_menus');
  776.  
  777. // **********************************************************************//
  778. // ! Get logo
  779. // **********************************************************************//
  780. if (!function_exists('etheme_logo')) {
  781. function etheme_logo() {
  782. $logoimg = etheme_get_option('logo');
  783. $logoimg = apply_filters('etheme_logo_src',$logoimg); ?>
  784. <?php if($logoimg): ?>
  785. <a href="<?php echo home_url(); ?>"><img src="<?php echo $logoimg ?>" alt="<?php bloginfo( 'description' ); ?>" /></a>
  786. <?php else: ?>
  787. <a href="<?php echo home_url(); ?>"><img src="<?php echo PARENT_URL.'/images/logo.png'; ?>" alt="<?php bloginfo('name'); ?>"></a>
  788. <?php endif ;
  789. }
  790. }
  791.  
  792.  
  793. if(!function_exists('etheme_top_links')) {
  794. function etheme_top_links() {
  795. ?>
  796. <ul class="links">
  797. <?php if ( is_user_logged_in() ) : ?>
  798. <?php if(class_exists('Woocommerce')): ?> <li class="my-account-link"><a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>"><?php _e( 'Your Account', ETHEME_DOMAIN ); ?></a>
  799. <div class="submenu-dropdown">
  800. <?php if ( has_nav_menu( 'account-menu' ) ) : ?>
  801. <?php wp_nav_menu(array(
  802. 'theme_location' => 'account-menu',
  803. 'before' => '',
  804. 'after' => '',
  805. 'link_before' => '',
  806. 'link_after' => '',
  807. 'depth' => 4,
  808. 'fallback_cb' => false
  809. )); ?>
  810. <?php else: ?>
  811. <h4 class="a-center">Set your account menu in <em>Apperance &gt; Menus</em></h4>
  812. <?php endif; ?>
  813. </div>
  814. </li><?php endif; ?>
  815. <li class="logout-link"><a href="<?php echo wp_logout_url(home_url()); ?>"><?php _e( 'Logout', ETHEME_DOMAIN ); ?></a></li>
  816. <?php else : ?>
  817. <?php
  818. $reg_id = etheme_tpl2id('et-registration.php');
  819. $reg_url = get_permalink($reg_id);
  820. ?>
  821. <?php if(class_exists('Woocommerce')): ?><li class="login-link"><a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>"><?php _e( 'Sign In', ETHEME_DOMAIN ); ?></a></li><?php endif; ?>
  822. <?php if(!empty($reg_id)): ?><li class="register-link"><a href="<?php echo $reg_url; ?>"><?php _e( 'Register', ETHEME_DOMAIN ); ?></a></li><?php endif; ?>
  823. <?php endif; ?>
  824. </ul>
  825. <?php
  826. }
  827. }
  828.  
  829. // **********************************************************************//
  830. // ! Header Type
  831. // **********************************************************************//
  832. function get_header_type() {
  833. return etheme_get_option('header_type');
  834. }
  835.  
  836. add_filter('custom_header_filter', 'get_header_type',10);
  837.  
  838.  
  839. // **********************************************************************//
  840. // ! Footer Type
  841. // **********************************************************************//
  842. function get_footer_type() {
  843. return etheme_get_option('footer_type');
  844. }
  845.  
  846. add_filter('custom_footer_filter', 'get_footer_type',10);
  847.  
  848.  
  849. // **********************************************************************//
  850. // ! Function to display comments
  851. // **********************************************************************//
  852.  
  853.  
  854. if(!function_exists('etheme_comments')) {
  855. function etheme_comments($comment, $args, $depth) {
  856. $GLOBALS['comment'] = $comment;
  857. if(get_comment_type() == 'pingback' || get_comment_type() == 'trackback') :
  858. ?>
  859.  
  860. <li id="comment-<?php comment_ID(); ?>" class="pingback">
  861. <div class="comment-block row-fluid">
  862. <div class="span12">
  863. <div class="author-link"><?php _e('Pingback:', ETHEME_DOMAIN) ?></div>
  864. <div class="comment-reply"> <?php edit_comment_link(); ?></div>
  865. <?php comment_author_link(); ?>
  866.  
  867. </div>
  868. </div>
  869. <?php
  870. elseif(get_comment_type() == 'comment') :?>
  871.  
  872. <li id="comment-<?php comment_ID(); ?>" <?php comment_class(); ?>>
  873. <div class="comment-block row-fluid">
  874.  
  875. <div class="row-fluid comment-heading">
  876. <div class="comment-author-avatar">
  877. <?php
  878. $avatar_size = 170;
  879. echo get_avatar($comment, $avatar_size);
  880. ?>
  881. </div>
  882. <div class="author-link"><?php comment_author_link(); ?></div><br>
  883. <div class="comment-date"><?php comment_date(); ?> - <?php comment_time(); ?></div>
  884. <div class="comment-reply"> <?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))); ?></div>
  885. </div>
  886.  
  887. <div class="row-fluid">
  888.  
  889. <?php if ($comment->comment_approved == '0'): ?>
  890. <p class="awaiting-moderation"><?php __('Your comment is awaiting moderation.', ETHEME_DOMAIN) ?></p>
  891. <?php endif ?>
  892.  
  893. <?php comment_text(); ?>
  894.  
  895. </div>
  896. </div>
  897.  
  898. <?php endif;
  899. }
  900. }
  901.  
  902. // **********************************************************************//
  903. // ! Custom Comment Form
  904. // **********************************************************************//
  905.  
  906. if(!function_exists('etheme_custom_comment_form')) {
  907. function etheme_custom_comment_form($defaults) {
  908. $defaults['comment_notes_before'] = '';
  909. $defaults['comment_notes_after'] = '';
  910. $dafaults['id_form'] = 'comments_form';
  911.  
  912. $defaults['comment_field'] = '<label for="comment">'.__('Comment', ETHEME_DOMAIN).'</label><div class="comment-form-comment row-fluid"><textarea class="span8 required-field" id="comment" name="comment" cols="45" rows="12" aria-required="true"></textarea></div>';
  913.  
  914. return $defaults;
  915. }
  916. }
  917.  
  918. add_filter('comment_form_defaults', 'etheme_custom_comment_form');
  919.  
  920. if(!function_exists('etheme_custom_comment_form_fields')) {
  921. function etheme_custom_comment_form_fields() {
  922. $commenter = wp_get_current_commenter();
  923. $req = get_option('require_name_email');
  924. $reqT = '<span class="required">*</span>';
  925. $aria_req = ($req ? " aria-required='true'" : ' ');
  926.  
  927. $fields = array(
  928. 'author' => '<p class="comment-form-author">'.
  929. '<label for="author">'.__('Name', ETHEME_DOMAIN).' '.($req ? $reqT : '').'</label>'.
  930. '<div class="row-fluid">'.
  931. '<input id="author" name="author" type="text" class="span5 ' . ($req ? ' required-field' : '') . '" value="' . esc_attr($commenter['comment_author']) . '" size="30" ' . $aria_req . '>'.
  932. '</div>'.
  933. '</p>',
  934. 'email' => '<p class="comment-form-email">'.
  935. '<label for="email">'.__('Email', ETHEME_DOMAIN).' '.($req ? $reqT : '').'</label>'.
  936. '<div class="row-fluid">'.
  937. '<input id="email" name="email" type="text" class="span5' . ($req ? ' required-field' : '') . '" value="' . esc_attr($commenter['comment_author_email']) . '" size="30" ' . $aria_req . '>'.
  938. '</div>'.
  939. '</p>',
  940. 'url' => '<p class="comment-form-url">'.
  941. '<label for="url">'.__('Website', ETHEME_DOMAIN).'</label>'.
  942. '<div class="row-fluid">'.
  943. '<input id="url" name="url" type="text" class="span5" value="' . esc_attr($commenter['comment_author_url']) . '" size="30">'.
  944. '</div>'.
  945. '</p>'
  946. );
  947.  
  948. return $fields;
  949. }
  950. }
  951.  
  952. add_filter('comment_form_default_fields', 'etheme_custom_comment_form_fields');
  953. // **********************************************************************//
  954. // ! Register Sidebars
  955. // **********************************************************************//
  956.  
  957. if(function_exists('register_sidebar')) {
  958. register_sidebar(array(
  959. 'name' => __('Main Sidebar', ETHEME_DOMAIN),
  960. 'id' => 'main-sidebar',
  961. 'description' => __('The main sidebar area', ETHEME_DOMAIN),
  962. 'before_widget' => '<div id="%1$s" class="sidebar-widget %2$s">',
  963. 'after_widget' => '</div><!-- //sidebar-widget -->',
  964. 'before_title' => '<h4 class="widget-title">',
  965. 'after_title' => '</h4>',
  966. ));
  967. register_sidebar(array(
  968. 'name' => __('Shop Sidebar', ETHEME_DOMAIN),
  969. 'id' => 'shop-sidebar',
  970. 'description' => __('Shop page widget area', ETHEME_DOMAIN),
  971. 'before_widget' => '<div id="%1$s" class="sidebar-widget %2$s">',
  972. 'after_widget' => '</div><!-- //sidebar-widget -->',
  973. 'before_title' => '<h4 class="widget-title">',
  974. 'after_title' => '</h4>',
  975. ));
  976. register_sidebar(array(
  977. 'name' => __('Single product page Sidebar', ETHEME_DOMAIN),
  978. 'id' => 'single-sidebar',
  979. 'description' => __('Single product page widget area', ETHEME_DOMAIN),
  980. 'before_widget' => '<div id="%1$s" class="sidebar-widget %2$s">',
  981. 'after_widget' => '</div><!-- //sidebar-widget -->',
  982. 'before_title' => '<h4 class="widget-title">',
  983. 'after_title' => '</h4>',
  984. ));
  985. register_sidebar(array(
  986. 'name' => __('Shopping cart sidebar', ETHEME_DOMAIN),
  987. 'id' => 'cart-sidebar',
  988. 'description' => __('Area after cart totals block', ETHEME_DOMAIN),
  989. 'before_widget' => '<div id="%1$s" class="sidebar-widget %2$s">',
  990. 'after_widget' => '</div><!-- //sidebar-widget -->',
  991. 'before_title' => '<h4 class="widget-title">',
  992. 'after_title' => '</h4>',
  993. ));
  994. register_sidebar(array(
  995. 'name' => __('Right side panel area', ETHEME_DOMAIN),
  996. 'id' => 'right-panel-sidebar',
  997. 'description' => __('Right side panel widget area', ETHEME_DOMAIN),
  998. 'before_widget' => '<div id="%1$s" class="sidebar-widget %2$s">',
  999. 'after_widget' => '</div><!-- //sidebar-widget -->',
  1000. 'before_title' => '<h4 class="widget-title">',
  1001. 'after_title' => '</h4>',
  1002. ));
  1003. register_sidebar(array(
  1004. 'name' => __('Hidden top panel area', ETHEME_DOMAIN),
  1005. 'id' => 'top-panel-sidebar',
  1006. 'description' => __('Hidden top panel widget area', ETHEME_DOMAIN),
  1007. 'before_widget' => '<div id="%1$s" class="sidebar-widget %2$s">',
  1008. 'after_widget' => '</div><!-- //sidebar-widget -->',
  1009. 'before_title' => '<h4 class="widget-title">',
  1010. 'after_title' => '</h4>',
  1011. ));
  1012. register_sidebar(array(
  1013. 'name' => __('Place in header top bar', ETHEME_DOMAIN),
  1014. 'id' => 'languages-sidebar',
  1015. 'description' => __('Can be used for placing languages switcher of some contacts information.', ETHEME_DOMAIN),
  1016. 'before_widget' => '<div id="%1$s" class="%2$s">',
  1017. 'after_widget' => '</div><!-- //sidebar-widget -->',
  1018. 'before_title' => '<h4 class="widget-title">',
  1019. 'after_title' => '</h4>',
  1020. ));
  1021.  
  1022. register_sidebar(array(
  1023. 'name' => __('Prefooter Row', ETHEME_DOMAIN),
  1024. 'id' => 'prefooter',
  1025. 'before_widget' => '<div id="%1$s" class="prefooter-sidebar-widget %2$s">',
  1026. 'after_widget' => '</div><!-- //prefooter-sidebar-widget -->',
  1027. 'before_title' => '<h4 class="widget-title">',
  1028. 'after_title' => '</h4>',
  1029. ));
  1030.  
  1031.  
  1032. register_sidebar(array(
  1033. 'name' => __('Footer 1', ETHEME_DOMAIN),
  1034. 'id' => 'footer1',
  1035. 'before_widget' => '<div id="%1$s" class="footer-sidebar-widget %2$s">',
  1036. 'after_widget' => '</div><!-- //footer-sidebar-widget -->',
  1037. 'before_title' => '<h4 class="widget-title">',
  1038. 'after_title' => '</h4>',
  1039. ));
  1040.  
  1041. register_sidebar(array(
  1042. 'name' => __('Footer 2', ETHEME_DOMAIN),
  1043. 'id' => 'footer2',
  1044. 'before_widget' => '<div id="%1$s" class="footer-sidebar-widget %2$s">',
  1045. 'after_widget' => '</div><!-- //sidebar-widget -->',
  1046. 'before_title' => '<h4 class="widget-title">',
  1047. 'after_title' => '</h4>',
  1048. ));
  1049.  
  1050.  
  1051. register_sidebar(array(
  1052. 'name' => __('Footer Copyright', ETHEME_DOMAIN),
  1053. 'id' => 'footer9',
  1054. 'before_widget' => '<div id="%1$s" class="footer-sidebar-widget %2$s">',
  1055. 'after_widget' => '</div><!-- //footer-sidebar-widget -->',
  1056. 'before_title' => '<h4 class="widget-title">',
  1057. 'after_title' => '</h4>',
  1058. ));
  1059.  
  1060. register_sidebar(array(
  1061. 'name' => __('Footer Links', ETHEME_DOMAIN),
  1062. 'id' => 'footer10',
  1063. 'before_widget' => '<div id="%1$s" class="footer-sidebar-widget %2$s">',
  1064. 'after_widget' => '</div><!-- //footer-sidebar-widget -->',
  1065. 'before_title' => '<h4 class="widget-title">',
  1066. 'after_title' => '</h4>',
  1067. ));
  1068. }
  1069.  
  1070. // **********************************************************************//
  1071. // ! Set exerpt
  1072. // **********************************************************************//
  1073. function etheme_excerpt_length( $length ) {
  1074. return 35;
  1075. }
  1076.  
  1077. add_filter( 'excerpt_length', 'etheme_excerpt_length', 999 );
  1078.  
  1079. function etheme_excerpt_more( $more ) {
  1080. return '...';
  1081. }
  1082.  
  1083. add_filter('excerpt_more', 'etheme_excerpt_more');
  1084.  
  1085. // **********************************************************************//
  1086. // ! Contact page functions
  1087. // **********************************************************************//
  1088. if(!function_exists('isValidEmail')){
  1089. function isValidEmail($email){
  1090. return filter_var($email, FILTER_VALIDATE_EMAIL);
  1091. }
  1092. }
  1093.  
  1094.  
  1095. // **********************************************************************//
  1096. // ! Posted info
  1097. // **********************************************************************//
  1098. if(!function_exists('etheme_posted_info')) {
  1099. function etheme_posted_info ($title = ''){
  1100. $posted_by = '<div class="post-info">';
  1101. $posted_by .= '<span class="posted-on">';
  1102. $posted_by .= __('Posted on', ETHEME_DOMAIN).' ';
  1103. $posted_by .= get_the_time(get_option('date_format')).' ';
  1104. $posted_by .= get_the_time(get_option('time_format')).' ';
  1105. $posted_by .= '</span>';
  1106. $posted_by .= '<span class="posted-by"> '.__('by', ETHEME_DOMAIN).' '.get_the_author_link().'</span>';
  1107. $posted_by .= '</div>';
  1108. return $title.$posted_by;
  1109. }
  1110. }
  1111.  
  1112. // **********************************************************************//
  1113. // ! Posts Teaser Grid
  1114. // **********************************************************************//
  1115. if(!function_exists('etheme_teaser')) {
  1116. function etheme_teaser($atts, $content = null) {
  1117. $title = $grid_columns_count = $grid_teasers_count = $grid_layout = $grid_link = $grid_link_target = $pagination = '';
  1118. $grid_template = $grid_thumb_size = $grid_posttypes = $grid_taxomonies = $grid_categories = $posts_in = $posts_not_in = '';
  1119. $grid_content = $el_class = $width = $orderby = $order = $el_position = $isotope_item = $isotope_class = $posted_by = $posted_block = $hover_mask = $border = '';
  1120. extract(shortcode_atts(array(
  1121. 'title' => '',
  1122. 'grid_columns_count' => 4,
  1123. 'grid_teasers_count' => 8,
  1124. 'grid_layout' => 'title_thumbnail_text', // title_thumbnail_text, thumbnail_title_text, thumbnail_text, thumbnail_title, thumbnail, title_text
  1125. 'grid_link' => 'link_post', // link_post, link_image, link_image_post, link_no
  1126. 'grid_link_target' => '_self',
  1127. 'grid_template' => 'grid', //grid, carousel
  1128. 'grid_thumb_size' => '500x300',
  1129. 'grid_posttypes' => '',
  1130. 'border' => 'on',
  1131. 'pagination' => 'show',
  1132. 'posted_block' => 'show',
  1133. 'hover_mask' => 'show',
  1134. 'grid_taxomonies' => '',
  1135. 'grid_categories' => '',
  1136. 'posts_in' => '',
  1137. 'posts_not_in' => '',
  1138. 'grid_content' => 'teaser', // teaser, content
  1139. 'el_class' => '',
  1140. 'width' => '1/1',
  1141. 'orderby' => NULL,
  1142. 'order' => 'DESC',
  1143. 'el_position' => ''
  1144. ), $atts));
  1145.  
  1146. if ( $grid_template == 'grid' || $grid_template == 'filtered_grid') {
  1147. $isotope_item = 'et_isotope-item ';
  1148. } else if ( $grid_template == 'carousel' ) {
  1149. $isotope_item = '';
  1150. }
  1151.  
  1152. $output = '';
  1153.  
  1154. $el_class = WPBakeryShortCode::getExtraClass( $el_class );
  1155. $width = '';//wpb_translateColumnWidthToSpan( $width );
  1156. $li_span_class = et_translateColumnsCountToSpanClass( $grid_columns_count );
  1157.  
  1158.  
  1159. $query_args = array();
  1160.  
  1161. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  1162.  
  1163. $query_args['paged'] = $paged;
  1164.  
  1165. $not_in = array();
  1166. if ( $posts_not_in != '' ) {
  1167. $posts_not_in = str_ireplace(" ", "", $posts_not_in);
  1168. $not_in = explode(",", $posts_not_in);
  1169. }
  1170.  
  1171. $link_target = $grid_link_target=='_blank' ? ' target="_blank"' : '';
  1172.  
  1173.  
  1174. //exclude current post/page from query
  1175. if ( $posts_in == '' ) {
  1176. global $post;
  1177. array_push($not_in, $post->ID);
  1178. }
  1179. else if ( $posts_in != '' ) {
  1180. $posts_in = str_ireplace(" ", "", $posts_in);
  1181. $query_args['post__in'] = explode(",", $posts_in);
  1182. }
  1183. if ( $posts_in == '' || $posts_not_in != '' ) {
  1184. $query_args['post__not_in'] = $not_in;
  1185. }
  1186.  
  1187. // Post teasers count
  1188. if ( $grid_teasers_count != '' && !is_numeric($grid_teasers_count) ) $grid_teasers_count = -1;
  1189. if ( $grid_teasers_count != '' && is_numeric($grid_teasers_count) ) $query_args['posts_per_page'] = $grid_teasers_count;
  1190.  
  1191. // Post types
  1192. $pt = array();
  1193. if ( $grid_posttypes != '' ) {
  1194. $grid_posttypes = explode(",", $grid_posttypes);
  1195. foreach ( $grid_posttypes as $post_type ) {
  1196. array_push($pt, $post_type);
  1197. }
  1198. $query_args['post_type'] = $pt;
  1199. }
  1200.  
  1201. // Taxonomies
  1202.  
  1203. $taxonomies = array();
  1204. if ( $grid_taxomonies != '' ) {
  1205. $grid_taxomonies = explode(",", $grid_taxomonies);
  1206. foreach ( $grid_taxomonies as $taxom ) {
  1207. array_push($taxonomies, $taxom);
  1208. }
  1209. }
  1210.  
  1211. // Narrow by categories
  1212. if ( $grid_categories != '' ) {
  1213. $grid_categories = explode(",", $grid_categories);
  1214. $gc = array();
  1215. foreach ( $grid_categories as $grid_cat ) {
  1216. array_push($gc, $grid_cat);
  1217. }
  1218. $gc = implode(",", $gc);
  1219. ////http://snipplr.com/view/17434/wordpress-get-category-slug/
  1220. $query_args['category_name'] = $gc;
  1221.  
  1222. $taxonomies = get_taxonomies('', 'object');
  1223. $query_args['tax_query'] = array('relation' => 'OR');
  1224. foreach ( $taxonomies as $t ) {
  1225. if ( in_array($t->object_type[0], $pt) ) {
  1226. $query_args['tax_query'][] = array(
  1227. 'taxonomy' => $t->name,//$t->name,//'portfolio_category',
  1228. 'terms' => $grid_categories,
  1229. 'field' => 'slug',
  1230. );
  1231. }
  1232. }
  1233. }
  1234.  
  1235. // Order posts
  1236. if ( $orderby != NULL ) {
  1237. $query_args['orderby'] = $orderby;
  1238. }
  1239. $query_args['order'] = $order;
  1240.  
  1241. // Run query
  1242. $my_query = new WP_Query($query_args);
  1243. //global $_wp_additional_image_sizes;
  1244.  
  1245. $teasers = '';
  1246. $teaser_categories = Array();
  1247. if($grid_template == 'filtered_grid' && empty($grid_taxomonies)) {
  1248. $taxonomies = get_object_taxonomies(!empty($query_args['post_type']) ? $query_args['post_type'] : get_post_types(array('public' => false, 'name' => 'attachment'), 'names', 'NOT'));
  1249. }
  1250.  
  1251. if($posted_block == 'show') {
  1252. add_filter('vc_teaser_grid_title', 'etheme_posted_info');
  1253. }
  1254.  
  1255. $posts_Ids = array();
  1256.  
  1257. while ( $my_query->have_posts() ) {
  1258. $link_title_start = $link_image_start = $p_link = $link_image_end = $p_img_large = '';
  1259.  
  1260. $my_query->the_post();
  1261.  
  1262. $posts_Ids[] = $my_query->post->ID;
  1263.  
  1264.  
  1265. $categories_css = '';
  1266. if( $grid_template == 'filtered_grid' ) {
  1267. /** @var $post_cate``gories get list of categories */
  1268. // $post_categories = get_the_category($my_query->post->ID);
  1269. $post_categories = wp_get_object_terms($my_query->post->ID, ($taxonomies));
  1270. if(!is_wp_error($post_categories)) {
  1271. foreach($post_categories as $cat) {
  1272. if(!in_array($cat->term_id, $teaser_categories)) {
  1273. $teaser_categories[] = $cat->term_id;
  1274. }
  1275. $categories_css .= ' grid-cat-'.$cat->term_id;
  1276. }
  1277. }
  1278.  
  1279. }
  1280. $post_title = the_title("", "", false);
  1281. $post_id = $my_query->post->ID;
  1282.  
  1283. $teaser_post_type = 'posts_grid_teaser_'.$my_query->post->post_type . ' ';
  1284. if($grid_content == 'teaser') {
  1285. $content = apply_filters('the_excerpt', get_the_excerpt());
  1286. } else {
  1287. $content = get_the_content();
  1288. $content = apply_filters('the_content', $content);
  1289. $content = str_replace(']]>', ']]&gt;', $content);
  1290. }
  1291.  
  1292. // $content = ( $grid_content == 'teaser' ) ? apply_filters('the_excerpt', get_the_excerpt()) : get_the_content(); //TODO: get_the_content() rewrite more WP native way.
  1293. $content = wpautop($content);
  1294. $link = '';
  1295. $thumbnail = '';
  1296.  
  1297. // Read more link
  1298. if ( $grid_link != 'link_no' ) {
  1299. $link = '<a class="more-link" href="'. get_permalink($post_id) .'"'.$link_target.' title="'. sprintf( esc_attr__( 'Permalink to %s', 'js_composer' ), the_title_attribute( 'echo=0' ) ).'">'. __("Read more", "js_composer") .'</a>';
  1300. }
  1301.  
  1302. // Thumbnail logic
  1303. if ( in_array($grid_layout, array('title_thumbnail_text', 'thumbnail_title_text', 'thumbnail_text', 'thumbnail_title', 'thumbnail', 'title_text') ) ) {
  1304. $post_thumbnail = $p_img_large = '';
  1305. //$attach_id = get_post_thumbnail_id($post_id);
  1306.  
  1307. $post_thumbnail = wpb_getImageBySize(array( 'post_id' => $post_id, 'thumb_size' => $grid_thumb_size ));
  1308. $thumbnail = $post_thumbnail['thumbnail'];
  1309. $p_img_large = $post_thumbnail['p_img_large'];
  1310. }
  1311.  
  1312. // Link logic
  1313. if ( $grid_link != 'link_no' ) {
  1314. $p_video = '';
  1315. if ( $grid_link == 'link_image' || $grid_link == 'link_image_post' ) {
  1316. $p_video = get_post_meta($post_id, "_p_video", true);
  1317. }
  1318.  
  1319. if ( $grid_link == 'link_post' ) {
  1320. $link_image_start = '<a class="link_image" href="'.get_permalink($post_id).'"'.$link_target.' title="'.sprintf( esc_attr__( 'Permalink to %s', 'js_composer' ), the_title_attribute( 'echo=0' ) ).'">';
  1321. $link_title_start = '<a class="link_title" href="'.get_permalink($post_id).'"'.$link_target.' title="'.sprintf( esc_attr__( 'Permalink to %s', 'js_composer' ), the_title_attribute( 'echo=0' ) ).'">';
  1322. }
  1323. else if ( $grid_link == 'link_image' ) {
  1324. if ( $p_video != "" ) {
  1325. $p_link = $p_video;
  1326. } else {
  1327. $p_link = $p_img_large[0];
  1328. }
  1329. $link_image_start = '<a class="link_image prettyphoto" href="'.$p_link.'"'.$link_target.' title="'.the_title_attribute('echo=0').'">';
  1330. $link_title_start = '<a class="link_title prettyphoto" href="'.$p_link.'"'.$link_target.' title="'.the_title_attribute('echo=0').'">';
  1331. }
  1332. else if ( $grid_link == 'link_image_post' ) {
  1333. if ( $p_video != "" ) {
  1334. $p_link = $p_video;
  1335. } else {
  1336. $p_link = $p_img_large[0];
  1337. }
  1338. $link_image_start = '<a class="link_image prettyphoto" href="'.$p_link.'"'.$link_target.' title="'.the_title_attribute('echo=0').'">';
  1339. $link_title_start = '<a class="link_title" href="'.get_permalink($post_id).'"'.$link_target.' title="'.sprintf( esc_attr__( 'Permalink to %s', 'js_composer' ), the_title_attribute( 'echo=0' ) ).'">';
  1340. }
  1341. $link_title_end = $link_image_end = '</a>';
  1342. } else {
  1343. $link_image_start = '';
  1344. $link_title_start = '';
  1345. $link_title_end = $link_image_end = '';
  1346. }
  1347.  
  1348. if($hover_mask == 'show') {
  1349. $link_image_end .= '
  1350.  
  1351. <div class="block-mask">
  1352. <div class="mask-content">
  1353. <a href="'.etheme_get_image(get_post_thumbnail_id($post_id)).'" rel="lightbox"><i class="icon-resize-full"></i></a>
  1354. <a href="'.get_permalink($post_id).'"><i class="icon-link"></i></a>
  1355. </div>
  1356. </div>
  1357. ';
  1358. }
  1359.  
  1360. $teasers .= '<div class="'.$isotope_item.apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $li_span_class, 'vc_teaser_grid_li').$categories_css.'">';
  1361. // If grid layout is: Title + Thumbnail + Text
  1362. if ( $grid_layout == 'title_thumbnail_text' ) {
  1363. if ( $post_title ) {
  1364. $to_filter = '<h4 class="post-title">' . $link_title_start . $post_title . $link_title_end . '</h2>';
  1365. $teasers .= apply_filters('vc_teaser_grid_title', $to_filter, array("grid_layout" => $grid_layout, "ID" => $post_id, "title" => $post_title, "media_link" => $p_link) );
  1366. }
  1367. if ( $thumbnail ) {
  1368. $to_filter = '<div class="post-thumb">' . $link_image_start . $thumbnail . $link_image_end .'</div>';
  1369. $teasers .= apply_filters('vc_teaser_grid_thumbnail', $to_filter, array("grid_layout" => $grid_layout, "ID" => $post_id, "thumbnail" => $thumbnail, "media_link" => $p_link) );
  1370. }
  1371. if ( $content ) {
  1372. $to_filter = '<div class="entry-content">' . $content . '</div>';
  1373. $teasers .= apply_filters('vc_teaser_grid_content', $to_filter, array("grid_layout" => $grid_layout, "ID" => $post_id, "content" => $content, "media_link" => $p_link) );
  1374. }
  1375. }
  1376. // If grid layout is: Thumbnail + Title + Text
  1377. else if ( $grid_layout == 'thumbnail_title_text' ) {
  1378. if ( $thumbnail ) {
  1379. $to_filter = '<div class="post-thumb">' . $link_image_start . $thumbnail . $link_image_end .'</div>';
  1380. $teasers .= apply_filters('vc_teaser_grid_thumbnail', $to_filter, array("grid_layout" => $grid_layout, "ID" => $post_id, "thumbnail" => $thumbnail, "media_link" => $p_link) );
  1381. }
  1382.  
  1383. if ( $post_title && $content ) {
  1384. $teasers .= '<div class="teaser-post-info">';
  1385. }
  1386.  
  1387. if ( $post_title ) {
  1388. $to_filter = '<h4 class="post-title">' . $link_title_start . $post_title . $link_title_end . '</h2>';
  1389. $teasers .= apply_filters('vc_teaser_grid_title', $to_filter, array("grid_layout" => $grid_layout, "ID" => $post_id, "title" => $post_title, "media_link" => $p_link) );
  1390. }
  1391. if ( $content ) {
  1392. $to_filter = '<div class="entry-content">' . $content . '</div>';
  1393. $teasers .= apply_filters('vc_teaser_grid_content', $to_filter, array("grid_layout" => $grid_layout, "ID" => $post_id, "content" => $content, "media_link" => $p_link) );
  1394. }
  1395.  
  1396. if ( $post_title && $content ) {
  1397. $teasers .= '</div>';
  1398. }
  1399. }
  1400. // If grid layout is: Thumbnail + Text
  1401. else if ( $grid_layout == 'thumbnail_text' ) {
  1402. if ( $thumbnail ) {
  1403. $to_filter = '<div class="post-thumb">' . $link_image_start . $thumbnail . $link_image_end .'</div>';
  1404. $teasers .= apply_filters('vc_teaser_grid_thumbnail', $to_filter, array("grid_layout" => $grid_layout, "ID" => $post_id, "thumbnail" => $thumbnail, "media_link" => $p_link) );
  1405. }
  1406. if ( $content ) {
  1407. $to_filter = '<div class="teaser-post-info entry-content">' . $content . '</div>';
  1408. $teasers .= apply_filters('vc_teaser_grid_content', $to_filter, array("grid_layout" => $grid_layout, "ID" => $post_id, "content" => $content, "media_link" => $p_link) );
  1409. }
  1410. }
  1411. // If grid layout is: Thumbnail + Title
  1412. else if ( $grid_layout == 'thumbnail_title' ) {
  1413. if ( $thumbnail ) {
  1414. $to_filter = '<div class="post-thumb">' . $link_image_start . $thumbnail . $link_image_end .'</div>';
  1415. $teasers .= apply_filters('vc_teaser_grid_thumbnail', $to_filter, array("grid_layout" => $grid_layout, "ID" => $post_id, "thumbnail" => $thumbnail, "media_link" => $p_link) );
  1416. }
  1417. if ( $post_title ) {
  1418. $to_filter = '<h4 class="teaser-post-info post-title">' . $link_title_start . $post_title . $link_title_end . '</h2>';
  1419. $teasers .= apply_filters('vc_teaser_grid_title', $to_filter, array("grid_layout" => $grid_layout, "ID" => $post_id, "title" => $post_title, "media_link" => $p_link) );
  1420. }
  1421. }
  1422. // If grid layout is: Thumbnail
  1423. else if ( $grid_layout == 'thumbnail' ) {
  1424. if ( $thumbnail ) {
  1425. $to_filter = '<div class="post-thumb">' . $link_image_start . $thumbnail . $link_image_end .'</div>';
  1426. $teasers .= apply_filters('vc_teaser_grid_thumbnail', $to_filter, array("grid_layout" => $grid_layout, "ID" => $post_id, "thumbnail" => $thumbnail, "media_link" => $p_link) );
  1427. }
  1428. }
  1429. // If grid layout is: Title + Text
  1430. else if ( $grid_layout == 'title_text' ) {
  1431. if ( $post_title ) {
  1432. $to_filter = '<h4 class="post-title">' . $link_title_start . $post_title . $link_title_end . '</h2>';
  1433. $teasers .= apply_filters('vc_teaser_grid_title', $to_filter, array("grid_layout" => $grid_layout, "ID" => $post_id, "title" => $post_title, "media_link" => $p_link) );
  1434. }
  1435. if ( $content ) {
  1436. $to_filter = '<div class="entry-content">' . $content . '</div>';
  1437. $teasers .= apply_filters('vc_teaser_grid_content', $to_filter, array("grid_layout" => $grid_layout, "ID" => $post_id, "content" => $content, "media_link" => $p_link) );
  1438. }
  1439. }
  1440.  
  1441. $teasers .= '</div> ' . WPBakeryShortCode::endBlockComment('single teaser');
  1442. } // endwhile loop
  1443. wp_reset_query();
  1444.  
  1445. if( $grid_template == 'filtered_grid' && $teasers && !empty($teaser_categories)) {
  1446. /*
  1447. $categories_list = wp_list_categories(array(
  1448. 'orderby' => 'name',
  1449. 'walker' => new Teaser_Grid_Category_Walker(),
  1450. 'include' => implode(',', $teaser_categories),
  1451. 'show_option_none' => __('No categories', 'js_composer'),
  1452. 'echo' => false
  1453. ));
  1454. */
  1455. $categories_array = get_terms(($taxonomies), array(
  1456. 'orderby' => 'name',
  1457. 'include' => implode(',', $teaser_categories)
  1458. ));
  1459.  
  1460. $categories_list_output = '<ul class="et_categories_filter clearfix">';
  1461. $categories_list_output .= '<li class="active"><a href="#" data-filter="*" class="button active">' . __('All', 'js_composer') . '</a></li>';
  1462. if(!is_wp_error($categories_array)) {
  1463. foreach($categories_array as $cat) {
  1464. $categories_list_output .= '<li><a href="#" data-filter=".grid-cat-'.$cat->term_id.'" class="button">' . esc_attr($cat->name) . '</a></li>';
  1465. }
  1466. }
  1467. $categories_list_output.= '</ul><div class="clearfix"></div>';
  1468. } else {
  1469. $categories_list_output = '';
  1470. }
  1471.  
  1472. $box_id = rand(1000,10000);
  1473.  
  1474. if($grid_template == 'grid' || $grid_template == 'filtered_grid') {
  1475. $isotope_class = 'et_isotope';
  1476. } else {
  1477. $isotope_class = 'teaser-carousel-'.$box_id;
  1478. }
  1479.  
  1480. if ( $teasers ) { $teasers = '<div class="teaser_grid_container isotope-container">'.$categories_list_output.'<div class="'.$isotope_class.' et_row clearfix">'. $teasers .'</div></div>'; }
  1481. else { $teasers = __("Nothing found." , "js_composer"); }
  1482.  
  1483. $posttypes_teasers = '';
  1484.  
  1485.  
  1486.  
  1487. if ( is_array($grid_posttypes) ) {
  1488. //$posttypes_teasers_ar = explode(",", $grid_posttypes);
  1489. $posttypes_teasers_ar = $grid_posttypes;
  1490. foreach ( $posttypes_teasers_ar as $post_type ) {
  1491. $posttypes_teasers .= 'wpb_teaser_grid_'.$post_type . ' ';
  1492. }
  1493. }
  1494.  
  1495. $grid_class = 'wpb_'.$grid_template . ' columns_count_'.$grid_columns_count . ' grid_layout-'.$grid_layout . ' ' . $grid_layout.'_' . ' ' . 'columns_count_'.$grid_columns_count.'_'.$grid_layout . ' ' . $posttypes_teasers.' teaser-border-'.$border.' post-by-info-'.$posted_block;
  1496. $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'wpb_teaser_grid wpb_content_element '.$grid_class.$width.$el_class);
  1497.  
  1498. $output .= "\n\t".'<div class="'.$css_class.'">';
  1499. $output .= "\n\t\t".'<div class="wpb_wrapper">';
  1500. $output .= ($title != '' ) ? "\n\t\t\t".'<h3 class="title"><span>'.$title.'</span></h3>' : '';
  1501. //$output .= wpb_widget_title(array('title' => $title, 'extraclass' => 'wpb_teaser_grid_heading'));
  1502. $output .= $teasers;
  1503. $output .= "\n\t\t".'</div> '.WPBakeryShortCode::endBlockComment('.wpb_wrapper');
  1504. $output .= "\n\t".'</div> '.WPBakeryShortCode::endBlockComment('.wpb_teaser_grid');
  1505. if($pagination == 'show') {
  1506. $output .= etheme_pagination($my_query, $paged);
  1507. }
  1508. if ( $grid_template == 'carousel' ) {
  1509.  
  1510. $output .= "<script type='text/javascript'>";
  1511. $output .= 'jQuery(".teaser-carousel-'.$box_id.'").owlCarousel({';
  1512. $output .= 'items:4,';
  1513. $output .= 'lazyLoad : true,';
  1514. $output .= 'navigation: true,';
  1515. $output .= 'navigationText:false,';
  1516. $output .= 'rewindNav: false,';
  1517. $output .= 'itemsCustom: [[0, 1], [479,2], [619,2], [768,4], [1200, 4], [1600, 4]]';
  1518. $output .= '});';
  1519.  
  1520. $output .= '</script>';
  1521. }
  1522.  
  1523. remove_all_filters('vc_teaser_grid_title');
  1524.  
  1525. return $output;
  1526. }
  1527.  
  1528. }
  1529.  
  1530. if(!function_exists('etheme_pagination')) {
  1531. function etheme_pagination($wp_query, $paged, $pages = '', $range = 2) {
  1532. $output = '';
  1533. $showitems = ($range * 2)+1;
  1534.  
  1535. if(empty($paged)) $paged = 1;
  1536.  
  1537. if($pages == '')
  1538. {
  1539. $pages = $wp_query->max_num_pages;
  1540. if(!$pages)
  1541. {
  1542. $pages = 1;
  1543. }
  1544. }
  1545.  
  1546. if(1 != $pages)
  1547. {
  1548. $output .= "<nav class='portfolio-pagination'>";
  1549. $output .= '<ul class="page-numbers">';
  1550. if($paged > 2 && $paged > $range+1 && $showitems < $pages) $output .= "<li><a href='".get_pagenum_link(1)."' class='prev page-numbers'>prev</a></li>";
  1551.  
  1552. for ($i=1; $i <= $pages; $i++)
  1553. {
  1554. if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
  1555. {
  1556. $output .= ($paged == $i)? "<li><span class='page-numbers current'>".$i."</span></li>":"<li><a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a></li>";
  1557. }
  1558. }
  1559.  
  1560. if ($paged < $pages && $showitems < $pages) $output .= "<li><a href='".get_pagenum_link($paged + 1)."' class='next page-numbers'>next</a></li>";
  1561. $output .= '</ul>';
  1562. $output .= "</nav>\n";
  1563. }
  1564.  
  1565. return $output;
  1566. }
  1567. }
  1568.  
  1569. // **********************************************************************//
  1570. // ! Create products grid by args
  1571. // **********************************************************************//
  1572. if(!function_exists('etheme_products')) {
  1573. function etheme_products($args,$title = false, $columns = 4){
  1574. global $wpdb, $woocommerce_loop;
  1575. ob_start();
  1576.  
  1577. $products = new WP_Query( $args );
  1578. $class = $title_output = '';
  1579. $shop_url = get_permalink(woocommerce_get_page_id('shop'));
  1580.  
  1581. if ($title != '') {
  1582. $title_output = '<h2 class="title"><span>'.$title.'</span></h2>';
  1583. }
  1584.  
  1585. $woocommerce_loop['columns'] = $columns;
  1586.  
  1587. if ( $products->have_posts() ) : echo $title_output; ?>
  1588. <?php woocommerce_product_loop_start(); ?>
  1589.  
  1590. <?php while ( $products->have_posts() ) : $products->the_post(); ?>
  1591.  
  1592. <?php woocommerce_get_template_part( 'content', 'product' ); ?>
  1593.  
  1594. <?php endwhile; // end of the loop. ?>
  1595.  
  1596. <?php woocommerce_product_loop_end(); ?>
  1597.  
  1598. <?php endif;
  1599.  
  1600. wp_reset_postdata();
  1601.  
  1602. return '<div class="woocommerce">' . ob_get_clean() . '</div>';
  1603.  
  1604. }
  1605. }
  1606. // **********************************************************************//
  1607. // ! Create products slider by args
  1608. // **********************************************************************//
  1609. if(!function_exists('etheme_create_slider')) {
  1610. function etheme_create_slider($args, $slider_args = array()){//, $title = false, $shop_link = true, $slider_type = false, $items = '[[0, 1], [479,2], [619,2], [768,4], [1200, 4], [1600, 4]]', $style = 'default'
  1611. global $wpdb, $woocommerce_loop;
  1612. $product_per_row = etheme_get_option('prodcuts_per_row');
  1613. extract(shortcode_atts(array(
  1614. 'title' => false,
  1615. 'shop_link' => false,
  1616. 'slider_type' => false,
  1617. 'items' => '[[0, 1], [479,2], [619,2], [768,4], [1200, 4], [1600, 4]]',
  1618. 'style' => 'default',
  1619. 'block_id' => false
  1620. ), $slider_args));
  1621.  
  1622. $box_id = rand(1000,10000);
  1623. $multislides = new WP_Query( $args );
  1624. $shop_url = get_permalink(woocommerce_get_page_id('shop'));
  1625. $class = $title_output = '';
  1626. if(!$slider_type) {
  1627. $woocommerce_loop['lazy-load'] = true;
  1628. $woocommerce_loop['style'] = $style;
  1629. }
  1630.  
  1631. if($multislides->post_count > 1) {
  1632. $class .= ' posts-count-gt1';
  1633. }
  1634. if($multislides->post_count < 4) {
  1635. $class .= ' posts-count-lt4';
  1636. }
  1637. if ( $multislides->have_posts() ) :
  1638. if ($title) {
  1639. $title_output = '<h2 class="title"><span>'.$title.'</span></h2>';
  1640. }
  1641. echo '<div class="slider-container '.$class.'">';
  1642. echo $title_output;
  1643. if($shop_link && $title)
  1644. echo '<a href="'.$shop_url.'" class="show-all-posts hidden-tablet hidden-phone">'.__('View more products', ETHEME_DOMAIN).'</a>';
  1645. echo '<div class="items-slider products-slider '.$slider_type.'-container slider-'.$box_id.'">';
  1646. echo '<div class="slider '.$slider_type.'-wrapper">';
  1647. $_i=0;
  1648. if($block_id && $block_id != '') {
  1649. echo '<div class=" '.$slider_type.'-slide">';
  1650. echo et_get_block($block_id);
  1651. echo '</div><!-- slide-item -->';
  1652. }
  1653. while ($multislides->have_posts()) : $multislides->the_post();
  1654. $_i++;
  1655.  
  1656. if(class_exists('Woocommerce')) {
  1657. global $product;
  1658. if (!$product->is_visible()) continue;
  1659. echo '<div class="slide-item product-slide '.$slider_type.'-slide">';
  1660. woocommerce_get_template_part( 'content', 'product' );
  1661. echo '</div><!-- slide-item -->';
  1662. }
  1663.  
  1664. endwhile;
  1665. echo '</div><!-- slider -->';
  1666. echo '</div><!-- products-slider -->';
  1667. echo '</div><!-- slider-container -->';
  1668. endif;
  1669. wp_reset_query();
  1670. unset($woocommerce_loop['lazy-load']);
  1671. unset($woocommerce_loop['style']);
  1672.  
  1673. if($items != '[[0, 1], [479,2], [619,2], [768,4], [1200, 4], [1600, 4]]') {
  1674. $items = '[[0, '.$items['phones'].'], [479,'.$items['phones'].'], [619,'.$items['tablet'].'], [768,'.$items['tablet'].'], [1200, '.$items['notebook'].'], [1600, '.$items['desktop'].']]';
  1675. }
  1676. if(!$slider_type) {
  1677. echo '
  1678.  
  1679. <script type="text/javascript">
  1680. jQuery(".slider-'.$box_id.' .slider").owlCarousel({
  1681. items:4,
  1682. lazyLoad : true,
  1683. navigation: true,
  1684. navigationText:false,
  1685. rewindNav: false,
  1686. itemsCustom: '.$items.'
  1687. });
  1688.  
  1689. </script>
  1690. ';
  1691. } elseif($slider_type == 'swiper') {
  1692. echo '
  1693.  
  1694. <script type="text/javascript">
  1695. if(jQuery(window).width() > 767) {
  1696. jQuery(".slider-'.$box_id.'").etFullWidth();
  1697. var mySwiper'.$box_id.' = new Swiper(".slider-'.$box_id.'",{
  1698. keyboardControl: true,
  1699. centeredSlides: true,
  1700. calculateHeight : true,
  1701. slidesPerView: "auto"
  1702. })
  1703. } else {
  1704. var mySwiper'.$box_id.' = new Swiper(".slider-'.$box_id.'",{
  1705. calculateHeight : true
  1706. })
  1707. }
  1708.  
  1709. jQuery(function($){
  1710. $(".slider-'.$box_id.' .slide-item").click(function(){
  1711. mySwiper'.$box_id.'.swipeTo($(this).index());
  1712. $(".lookbook-index").removeClass("active");
  1713. $(this).addClass("active");
  1714. });
  1715.  
  1716. $(".slider-'.$box_id.' .slide-item a").click(function(e){
  1717. if($(this).parents(".swiper-slide-active").length < 1) {
  1718. e.preventDefault();
  1719. }
  1720. });
  1721. }, jQuery);
  1722. </script>
  1723. ';
  1724. }
  1725.  
  1726. }
  1727. }
  1728.  
  1729.  
  1730. if(!function_exists('etheme_create_flex_slider')) {
  1731. function etheme_create_flex_slider($args,$title = false, $shop_link = true, $sidebar_slider = false){
  1732. global $wpdb;
  1733. $product_per_row = etheme_get_option('prodcuts_per_row');
  1734. $box_id = rand(1000,10000);
  1735. $multislides = new WP_Query( $args );
  1736. $sliderHeight = etheme_get_option('default_slider_height');
  1737. $shop_url = get_permalink(woocommerce_get_page_id('shop'));
  1738. $class = '';
  1739. if($sidebar_slider) {
  1740. $class .= ' sidebar-slider-flex';
  1741. $sliderHeight = 410;
  1742. }
  1743.  
  1744. if($multislides->post_count > 1) {
  1745. $class .= ' posts-count-gt1';
  1746. }
  1747. if($multislides->post_count < 4) {
  1748. $class .= ' posts-count-lt4';
  1749. }
  1750. if ( $multislides->have_posts() ) :
  1751. if ($title) {
  1752. $title_output = '<h5 class="title"><span>'.$title.'</span></h5>';
  1753. }
  1754. echo '<div class="slider-container '.$class.'">';
  1755. echo $title_output;
  1756. if($shop_link)
  1757. echo '<a href="'.$shop_url.'" class="show-all-posts hidden-tablet hidden-phone">'.__('View more products', ETHEME_DOMAIN).'</a>';
  1758. echo '<div class="slider-viewport">';
  1759. echo '<div class="slider-'.$box_id.'">';
  1760. echo '<div class="slider">';
  1761. $_i=0;
  1762. echo '<div class="slide-item product-slide">';
  1763. while ($multislides->have_posts()) : $multislides->the_post();
  1764. $_i++;
  1765.  
  1766. if(class_exists('Woocommerce')) {
  1767. global $product;
  1768. if (!$product->is_visible()) continue;
  1769. woocommerce_get_template_part( 'content', 'product' );
  1770. if($sidebar_slider){
  1771. if($_i%2 == 0 && $_i != $multislides->post_count) {
  1772. echo '</div><!-- slide-item -->';
  1773. echo '<div class="slide-item product-slide">';
  1774. }
  1775. } else {
  1776. echo '</div><!-- slide-item -->';
  1777. echo '<div class="slide-item product-slide">';
  1778. }
  1779. }
  1780.  
  1781. endwhile;
  1782. echo '</div><!-- slide-item -->';
  1783. echo '</div><!-- slider -->';
  1784. echo '</div><!-- products-slider -->';
  1785. echo '</div><!-- slider-viewport -->';
  1786. echo '</div><!-- slider-container -->';
  1787. endif;
  1788. wp_reset_query();
  1789.  
  1790.  
  1791. echo '
  1792. <script type="text/javascript">
  1793. jQuery(document).ready(function($) {
  1794. jQuery(".slider-'.$box_id.'").flexslider({
  1795. selector: ".slider .slide-item",
  1796. animation: "slide",
  1797. slideshow: false,
  1798. animationLoop: false,
  1799. controlNav: true,
  1800. directionNav:true,
  1801. itemWidth:105,
  1802. itemMargin:0,
  1803. move: 1
  1804. });
  1805. });
  1806. </script>
  1807. ';
  1808.  
  1809. }
  1810. }
  1811.  
  1812.  
  1813. // **********************************************************************//
  1814. // ! Create posts slider by args
  1815. // **********************************************************************//
  1816. if(!function_exists('etheme_create_posts_slider')) {
  1817. function etheme_create_posts_slider($args,$title = false, $more_link = true, $date = false, $excerpt = false, $width = 300, $height = 200, $crop = true){
  1818. $box_id = rand(1000,10000);
  1819. $multislides = new WP_Query( $args );
  1820. $lightbox = etheme_get_option('blog_lightbox');
  1821. $sliderHeight = etheme_get_option('default_blog_slider_height');
  1822. $posts_url = get_permalink(get_option('page_for_posts'));
  1823. $class = '';
  1824. if($multislides->post_count > 1) {
  1825. $class = ' posts-count-gt1';
  1826. }
  1827. if($multislides->post_count < 4) {
  1828. $class .= ' posts-count-lt4';
  1829. }
  1830.  
  1831. if ( $multislides->have_posts() ) :
  1832. $title_output = '';
  1833. if ($title) {
  1834. $title_output = '<h2 class="title"><span>'.$title.'</span></h2>';
  1835. }
  1836. echo '<div class="slider-container '.$class.'">';
  1837. echo $title_output;
  1838. if($more_link)
  1839. echo '<a href="'.$posts_url.'" class="show-all-posts hidden-tablet hidden-phone">'.__('View more posts', ETHEME_DOMAIN).'</a>';
  1840. echo '<div class="items-slider posts-slider slider-'.$box_id.'">';
  1841. echo '<div class="slider">';
  1842. $_i=0;
  1843. while ($multislides->have_posts()) : $multislides->the_post();
  1844. $_i++;
  1845. echo '<div class="slide-item post-slide">';
  1846. if(has_post_thumbnail()){
  1847. echo '<div class="post-images">';
  1848. echo '<a href="'.get_permalink().'"><img src="' . etheme_get_image(false, $width, $height, true) . '" class="post-slide-img"></a>';
  1849.  
  1850. echo '<div class="blog-mask">';
  1851. echo '<div class="mask-content">';
  1852. if($lightbox):
  1853. echo '<a href="'.etheme_get_image(false).'" rel="lightbox"><i class="icon-resize-full"></i></a>';
  1854. endif;
  1855. echo '<a href="'.get_permalink().'"><i class="icon-link"></i></a>';
  1856. echo '</div>';
  1857. echo '</div>';
  1858. echo '</div>';
  1859. }
  1860.  
  1861. if($date){
  1862. echo '<div class="post-information">';
  1863. the_category(',&nbsp;');
  1864. echo ' '.get_the_date('M') . ' <span>' . get_the_date('d') . '</span>' . ', ' . get_the_date('Y');
  1865. echo '</div>';
  1866. }
  1867. echo '<h5><a href="'.get_permalink().'">' . get_the_title() . '</a></h5>';
  1868. if($excerpt) the_excerpt();
  1869. echo '</div><!-- slide-item -->';
  1870.  
  1871. endwhile;
  1872. echo '</div><!-- slider -->';
  1873. echo '</div><!-- items-slider -->';
  1874. echo '</div><div class="clear"></div><!-- slider-container -->';
  1875.  
  1876. echo '
  1877. <script type="text/javascript">
  1878. jQuery(".slider-'.$box_id.' .slider").owlCarousel({
  1879. items:4,
  1880. lazyLoad : true,
  1881. navigation: true,
  1882. navigationText:false,
  1883. rewindNav: false,
  1884. itemsCustom: [[0, 1], [479,2], [619,2], [768,4], [1200, 4], [1600, 4]]
  1885. });
  1886.  
  1887. </script>
  1888. ';
  1889.  
  1890. endif;
  1891. wp_reset_query();
  1892.  
  1893. }
  1894. }
  1895.  
  1896. // **********************************************************************//
  1897. // ! Custom sidebars
  1898. // **********************************************************************//
  1899.  
  1900. /**
  1901. *
  1902. * Function for adding sidebar (AJAX action)
  1903. */
  1904.  
  1905. function etheme_add_sidebar(){
  1906. if (!wp_verify_nonce($_GET['_wpnonce_etheme_widgets'],'etheme-add-sidebar-widgets') ) die( 'Security check' );
  1907. if($_GET['etheme_sidebar_name'] == '') die('Empty Name');
  1908. $option_name = 'etheme_custom_sidebars';
  1909. if(!get_option($option_name) || get_option($option_name) == '') delete_option($option_name);
  1910.  
  1911. $new_sidebar = $_GET['etheme_sidebar_name'];
  1912.  
  1913.  
  1914. if(get_option($option_name)) {
  1915. $et_custom_sidebars = etheme_get_stored_sidebar();
  1916. $et_custom_sidebars[] = trim($new_sidebar);
  1917. $result = update_option($option_name, $et_custom_sidebars);
  1918. }else{
  1919. $et_custom_sidebars[] = $new_sidebar;
  1920. $result2 = add_option($option_name, $et_custom_sidebars);
  1921. }
  1922.  
  1923.  
  1924. if($result) die('Updated');
  1925. elseif($result2) die('added');
  1926. else die('error');
  1927. }
  1928.  
  1929. /**
  1930. *
  1931. * Function for deleting sidebar (AJAX action)
  1932. */
  1933.  
  1934. function etheme_delete_sidebar(){
  1935. $option_name = 'etheme_custom_sidebars';
  1936. $del_sidebar = trim($_GET['etheme_sidebar_name']);
  1937.  
  1938. if(get_option($option_name)) {
  1939. $et_custom_sidebars = etheme_get_stored_sidebar();
  1940.  
  1941. foreach($et_custom_sidebars as $key => $value){
  1942. if($value == $del_sidebar)
  1943. unset($et_custom_sidebars[$key]);
  1944. }
  1945.  
  1946.  
  1947. $result = update_option($option_name, $et_custom_sidebars);
  1948. }
  1949.  
  1950. if($result) die('Deleted');
  1951. else die('error');
  1952. }
  1953.  
  1954. /**
  1955. *
  1956. * Function for registering previously stored sidebars
  1957. */
  1958. function etheme_register_stored_sidebar(){
  1959. $et_custom_sidebars = etheme_get_stored_sidebar();
  1960. if(is_array($et_custom_sidebars)) {
  1961. foreach($et_custom_sidebars as $name){
  1962. register_sidebar( array(
  1963. 'name' => ''.$name.'',
  1964. 'id' => $name,
  1965. 'class' => 'etheme_custom_sidebar',
  1966. 'before_widget' => '<div id="%1$s" class="widget-container %2$s">',
  1967. 'after_widget' => '</div>',
  1968. 'before_title' => '<h3 class="widget-title">',
  1969. 'after_title' => '</h3>',
  1970. ) );
  1971. }
  1972. }
  1973.  
  1974. }
  1975.  
  1976. /**
  1977. *
  1978. * Function gets stored sidebar array
  1979. */
  1980. function etheme_get_stored_sidebar(){
  1981. $option_name = 'etheme_custom_sidebars';
  1982. return get_option($option_name);
  1983. }
  1984.  
  1985.  
  1986. /**
  1987. *
  1988. * Add form after all widgets
  1989. */
  1990. function etheme_sidebar_form(){
  1991. ?>
  1992.  
  1993. <form action="<?php echo admin_url( 'widgets.php' ); ?>" method="post" id="etheme_add_sidebar_form">
  1994. <h2>Custom Sidebar</h2>
  1995. <?php wp_nonce_field( 'etheme-add-sidebar-widgets', '_wpnonce_etheme_widgets', false ); ?>
  1996. <input type="text" name="etheme_sidebar_name" id="etheme_sidebar_name" />
  1997. <button type="submit" class="button-primary" value="add-sidebar">Add Sidebar</button>
  1998. </form>
  1999. <script type="text/javascript">
  2000. var sidebarForm = jQuery('#etheme_add_sidebar_form');
  2001. var sidebarFormNew = sidebarForm.clone();
  2002. sidebarForm.remove();
  2003. jQuery('#widgets-right').append('<div style="clear:both;"></div>');
  2004. jQuery('#widgets-right').append(sidebarFormNew);
  2005.  
  2006. sidebarFormNew.submit(function(e){
  2007. e.preventDefault();
  2008. var data = {
  2009. 'action':'etheme_add_sidebar',
  2010. '_wpnonce_etheme_widgets': jQuery('#_wpnonce_etheme_widgets').val(),
  2011. 'etheme_sidebar_name': jQuery('#etheme_sidebar_name').val(),
  2012. };
  2013. //console.log(data);
  2014. jQuery.ajax({
  2015. url: ajaxurl,
  2016. data: data,
  2017. success: function(response){
  2018. console.log(response);
  2019. window.location.reload(true);
  2020.  
  2021. },
  2022. error: function(data) {
  2023. console.log('error');
  2024.  
  2025. }
  2026. });
  2027. });
  2028.  
  2029. </script>
  2030. <?php
  2031. }
  2032.  
  2033. add_action( 'sidebar_admin_page', 'etheme_sidebar_form', 30 );
  2034. add_action('wp_ajax_etheme_add_sidebar', 'etheme_add_sidebar');
  2035. add_action('wp_ajax_etheme_delete_sidebar', 'etheme_delete_sidebar');
  2036. add_action( 'widgets_init', 'etheme_register_stored_sidebar' );
  2037.  
  2038.  
  2039. // **********************************************************************//
  2040. // ! Get sidebar
  2041. // **********************************************************************//
  2042.  
  2043. if(!function_exists('etheme_get_sidebar')) {
  2044. function etheme_get_sidebar ($name = false) {
  2045. do_action( 'get_sidebar', $name );
  2046. if($name) {
  2047. include(TEMPLATEPATH . '/sidebar-'.$name.'.php');
  2048. }else{
  2049. include(TEMPLATEPATH . '/sidebar.php');
  2050. }
  2051. }
  2052. }
  2053.  
  2054. // **********************************************************************//
  2055. // ! Site breadcrumbs
  2056. // **********************************************************************//
  2057. if(!function_exists('etheme_breadcrumbs')) {
  2058. function etheme_breadcrumbs() {
  2059.  
  2060. $showOnHome = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show
  2061. $delimiter = '<span class="delimeter">/</span>'; // delimiter between crumbs
  2062. $home = __('Home', ETHEME_DOMAIN); // text for the 'Home' link
  2063. $blogPage = __('Blog', ETHEME_DOMAIN);
  2064. $showCurrent = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show
  2065. $before = '<span class="current">'; // tag before the current crumb
  2066. $after = '</span>'; // tag after the current crumb
  2067.  
  2068. global $post;
  2069. $homeLink = home_url();
  2070.  
  2071. if (is_front_page()) {
  2072.  
  2073. if ($showOnHome == 1) echo '<div id="crumbs"><a href="' . $homeLink . '">' . $home . '</a></div>';
  2074.  
  2075. } else {
  2076.  
  2077. echo '<div class="breadcrumbs">';
  2078. echo '<div id="breadcrumb">';
  2079. echo '<a href="' . $homeLink . '">' . $home . '</a> ' . $delimiter . ' ';
  2080.  
  2081. if ( is_category() ) {
  2082. $thisCat = get_category(get_query_var('cat'), false);
  2083. if ($thisCat->parent != 0) echo get_category_parents($thisCat->parent, TRUE, ' ' . $delimiter . ' ');
  2084. echo $before . 'Archive by category "' . single_cat_title('', false) . '"' . $after;
  2085.  
  2086. } elseif ( is_search() ) {
  2087. echo $before . 'Search results for "' . get_search_query() . '"' . $after;
  2088.  
  2089. } elseif ( is_day() ) {
  2090. echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
  2091. echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
  2092. echo $before . get_the_time('d') . $after;
  2093.  
  2094. } elseif ( is_month() ) {
  2095. echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
  2096. echo $before . get_the_time('F') . $after;
  2097.  
  2098. } elseif ( is_year() ) {
  2099. echo $before . get_the_time('Y') . $after;
  2100.  
  2101. } elseif ( is_single() && !is_attachment() ) {
  2102. if ( get_post_type() == 'etheme_portfolio' ) {
  2103. $portfolioId = etheme_tpl2id('portfolio.php');
  2104. $portfolioLink = get_permalink($portfolioId);
  2105. $post_type = get_post_type_object(get_post_type());
  2106. $slug = $post_type->rewrite;
  2107. echo '<a href="' . $portfolioLink . '/">' . $post_type->labels->name . '</a>';
  2108. if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
  2109. } elseif ( get_post_type() != 'post' ) {
  2110. $post_type = get_post_type_object(get_post_type());
  2111. $slug = $post_type->rewrite;
  2112. echo '<a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a>';
  2113. if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
  2114. } else {
  2115. $cat = get_the_category(); $cat = $cat[0];
  2116. $cats = get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
  2117. if ($showCurrent == 0) $cats = preg_replace("#^(.+)\s$delimiter\s$#", "$1", $cats);
  2118. echo $cats;
  2119. if ($showCurrent == 1) echo $before . get_the_title() . $after;
  2120. }
  2121.  
  2122. } elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) {
  2123. $post_type = get_post_type_object(get_post_type());
  2124. echo $before . $post_type->labels->singular_name . $after;
  2125.  
  2126. } elseif ( is_attachment() ) {
  2127. $parent = get_post($post->post_parent);
  2128. //$cat = get_the_category($parent->ID); $cat = $cat[0];
  2129. //echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
  2130. //echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a>';
  2131. if ($showCurrent == 1) echo ' ' . $before . get_the_title() . $after;
  2132.  
  2133. } elseif ( is_page() && !$post->post_parent ) {
  2134. if ($showCurrent == 1) echo $before . get_the_title() . $after;
  2135.  
  2136. } elseif ( is_page() && $post->post_parent ) {
  2137. $parent_id = $post->post_parent;
  2138. $breadcrumbs = array();
  2139. while ($parent_id) {
  2140. $page = get_page($parent_id);
  2141. $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
  2142. $parent_id = $page->post_parent;
  2143. }
  2144. $breadcrumbs = array_reverse($breadcrumbs);
  2145. for ($i = 0; $i < count($breadcrumbs); $i++) {
  2146. echo $breadcrumbs[$i];
  2147. if ($i != count($breadcrumbs)-1) echo ' ' . $delimiter . ' ';
  2148. }
  2149. if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
  2150.  
  2151. } elseif ( is_tag() ) {
  2152. echo $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after;
  2153.  
  2154. } elseif ( is_author() ) {
  2155. global $author;
  2156. $userdata = get_userdata($author);
  2157. echo $before . 'Articles posted by ' . $userdata->display_name . $after;
  2158.  
  2159. } elseif ( is_404() ) {
  2160. echo $before . 'Error 404' . $after;
  2161. }else{
  2162.  
  2163. echo $blogPage;
  2164. }
  2165.  
  2166. if ( get_query_var('paged') ) {
  2167. if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
  2168. echo ' ('.__('Page') . ' ' . get_query_var('paged').')';
  2169. if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
  2170. }
  2171.  
  2172. echo '</div>';
  2173. et_back_to_page();
  2174. echo '</div>';
  2175.  
  2176. }
  2177. }
  2178. }
  2179.  
  2180. if(!function_exists('et_back_to_page')) {
  2181. function et_back_to_page() {
  2182. echo '<a class="back-to" href="javascript: history.go(-1)"><span>‹</span>'.__('Return to Previous Page',ETHEME_DOMAIN).'</a>';
  2183. }
  2184. }
  2185. // **********************************************************************//
  2186. // ! Footer Demo Widgets
  2187. // **********************************************************************//
  2188.  
  2189. if(!function_exists('etheme_footer_demo')) {
  2190. function etheme_footer_demo($position){
  2191. switch ($position) {
  2192. case 'footer2':
  2193.  
  2194. ?>
  2195.  
  2196. <div class="row-fluid">
  2197. <div class="span3">
  2198. <h4 class="widget-title">About Company</h4>
  2199. <div>
  2200. <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod aliqua, sed do eiusmod aliqua.</p>
  2201.  
  2202. <h6>Contact information</h6>
  2203. 30 South Park Avenue
  2204. San Francisco, CA 94108
  2205. Phone: +78 123 456 789
  2206. </div>
  2207.  
  2208. </div>
  2209. <div class="span3">
  2210. <?php
  2211. $args = array(
  2212. 'widget_id' => 'etheme_widget_recent_comments',
  2213. 'before_widget' => '<div class="footer-sidebar-widget etheme_widget_recent_comments">',
  2214. 'after_widget' => '</div><!-- //sidebar-widget -->',
  2215. 'before_title' => '<h4 class="widget-title">',
  2216. 'after_title' => '</h4>'
  2217. );
  2218.  
  2219. $instance = array(
  2220. 'number' => 2,
  2221. 'title' => __('Recent Comments', ETHEME_DOMAIN)
  2222. );
  2223.  
  2224.  
  2225. $widget = new Etheme_Recent_Comments_Widget();
  2226. $widget->widget($args, $instance);
  2227. ?>
  2228. </div>
  2229. <div class="span3">
  2230. <?php
  2231. echo do_shortcode('[vc_wp_posts show_date="1" title="Recent Posts" number="3"]');
  2232. ?>
  2233. </div>
  2234. <div class="span3">
  2235. <?php
  2236. $args = array(
  2237. 'widget_id' => 'etheme_widget_flickr',
  2238. 'before_widget' => '<div class="footer-sidebar-widget etheme_widget_flickr">',
  2239. 'after_widget' => '</div><!-- //sidebar-widget -->',
  2240. 'before_title' => '<h4 class="widget-title">',
  2241. 'after_title' => '</h4>'
  2242. );
  2243.  
  2244. $instance = array(
  2245. 'screen_name' => 'envato',
  2246. 'number' => 6,
  2247. 'show_button' => 1,
  2248. 'title' => __('Flickr Photos', ETHEME_DOMAIN)
  2249. );
  2250.  
  2251.  
  2252. $widget = new Etheme_Flickr_Widget();
  2253. $widget->widget($args, $instance);
  2254. ?>
  2255. </div>
  2256. </div>
  2257.  
  2258. <?php
  2259.  
  2260. break;
  2261. case 'footer9':
  2262. ?>
  2263. <p><a href="<?php home_url(); ?>"><img src="<?php echo PARENT_URL.'/images/'; ?>logo-small.png" class="logo-small"></a></p>
  2264. <?php
  2265. break;
  2266. case 'footer10':
  2267. ?>
  2268. <p style="line-height: 35px;"><?php _e('Wordpress DEMO Store. All Rights Reserved.', ETHEME_DOMAIN) ?><p>
  2269. <?php
  2270. break;
  2271. }
  2272. }
  2273. }
  2274.  
  2275. // **********************************************************************//
  2276. // ! Replace variation images
  2277. // **********************************************************************//
  2278.  
  2279. if(!function_exists('etheme_replace_variation_images')) {
  2280. function etheme_replace_variation_images($variations, $width = 1000, $height = 1000, $crop = false) {
  2281.  
  2282. $newVariations = $variations;
  2283.  
  2284. foreach ($variations as $key => $value) {
  2285. $attachment_id = get_post_thumbnail_id( $variations[$key]['variation_id'] );
  2286.  
  2287. $newImage = etheme_get_image($attachment_id, $width, $height, $crop);
  2288.  
  2289. $newVariations[$key]['image_src'] = $newImage;
  2290. }
  2291.  
  2292. return $newVariations;
  2293. }
  2294. }
  2295.  
  2296.  
  2297. // **********************************************************************//
  2298. // ! Wishlist
  2299. // **********************************************************************//
  2300.  
  2301. //add_action('woocommerce_after_add_to_cart_button', 'etheme_wishlist_btn', 20);
  2302. //add_action('woocommerce_after_shop_loop_item', 'etheme_wishlist_btn', 20);
  2303.  
  2304. if(!function_exists('etheme_wishlist_btn')) {
  2305. function etheme_wishlist_btn() {
  2306. if(class_exists('YITH_WCWL'))
  2307. echo do_shortcode('[yith_wcwl_add_to_wishlist]');
  2308. }
  2309. }
  2310.  
  2311. // **********************************************************************//
  2312. // ! Get page sidebar position
  2313. // **********************************************************************//
  2314.  
  2315. if(!function_exists('etheme_get_page_sidebar')) {
  2316. function etheme_get_page_sidebar() {
  2317. $result = array(
  2318. 'position' => '',
  2319. 'responsive' => '',
  2320. 'sidebarname' => '',
  2321. 'page_heading' => 'enable',
  2322. 'page_slider' => 'no_slider',
  2323. 'sidebar_span' => 'span4',
  2324. 'content_span' => 'span8'
  2325. );
  2326.  
  2327.  
  2328. $result['responsive'] = etheme_get_option('blog_sidebar_responsive');
  2329. $result['position'] = etheme_get_option('blog_sidebar');
  2330. $result['page_heading'] = etheme_get_custom_field('page_heading');
  2331. $result['page_slider'] = etheme_get_custom_field('page_slider');
  2332. $page_sidebar_state = etheme_get_custom_field('sidebar_state');
  2333. $sidebar_width = etheme_get_custom_field('sidebar_width');
  2334. $widgetarea = etheme_get_custom_field('widget_area');
  2335.  
  2336. if($sidebar_width != '') {
  2337. $content_width = 12 - $sidebar_width;
  2338. $result['sidebar_span'] = 'span'.$sidebar_width;
  2339. $result['content_span'] = 'span'.$content_width;
  2340. }
  2341. if($widgetarea != '') {
  2342. $result['sidebarname'] = 'custom';
  2343. }
  2344. if($page_sidebar_state != '') {
  2345. $result['position'] = $page_sidebar_state;
  2346. }
  2347. if($result['position'] == 'no_sidebar') {
  2348. $result['position'] = 'without';
  2349. $result['content_span'] = 'span12';
  2350. }
  2351.  
  2352. return $result;
  2353.  
  2354. }
  2355. }
  2356.  
  2357.  
  2358. // **********************************************************************//
  2359. // ! Get blog sidebar position
  2360. // **********************************************************************//
  2361.  
  2362. if(!function_exists('etheme_get_blog_sidebar')) {
  2363. function etheme_get_blog_sidebar() {
  2364.  
  2365. $result = array(
  2366. 'position' => '',
  2367. 'responsive' => '',
  2368. 'sidebarname' => '',
  2369. 'sidebar_span' => 'span4',
  2370. 'content_span' => 'span8',
  2371. 'blog_layout' => 'default',
  2372. );
  2373.  
  2374. $result['responsive'] = etheme_get_option('blog_sidebar_responsive');
  2375. $result['position'] = etheme_get_option('blog_sidebar');
  2376. $result['blog_layout'] = etheme_get_option('blog_layout');
  2377.  
  2378. $result['blog_layout'] = apply_filters('custom_blog_layout', $result['blog_layout']);
  2379.  
  2380. if($result['position'] == 'no_sidebar' || $result['blog_layout'] == 'grid') {
  2381. $result['position'] = 'without';
  2382. $result['content_span'] = 'span12';
  2383. }
  2384.  
  2385. return $result;
  2386.  
  2387. }
  2388. }
  2389.  
  2390. // **********************************************************************//
  2391. // ! Get shop sidebar position
  2392. // **********************************************************************//
  2393.  
  2394. if(!function_exists('etheme_get_shop_sidebar')) {
  2395. function etheme_get_shop_sidebar() {
  2396.  
  2397. $result = array(
  2398. 'position' => 'left',
  2399. 'responsive' => '',
  2400. 'product_per_row' => 3,
  2401. 'product_page_sidebar' => true,
  2402. 'sidebar_span' => 'span3',
  2403. 'content_span' => 'span9'
  2404. );
  2405.  
  2406. $result['product_page_sidebar'] = etheme_get_option('product_page_sidebar');
  2407. $result['responsive'] = etheme_get_option('blog_sidebar_responsive');
  2408. $result['position'] = etheme_get_option('grid_sidebar');
  2409. $result['product_per_row'] = etheme_get_option('prodcuts_per_row');
  2410.  
  2411.  
  2412. $result['product_per_row'] = apply_filters('shop_column_count', $result['product_per_row']);
  2413. $result['product_page_sidebar'] = apply_filters('shop_sidebar', $result['product_page_sidebar']);
  2414.  
  2415. if(!$result['product_page_sidebar']) {
  2416. $result['position'] = 'without';
  2417. $result['content_span'] = 'span12';
  2418. }
  2419.  
  2420.  
  2421. if($result['product_per_row'] == 6){
  2422. $result['position'] = 'without';
  2423. $result['content_span'] = 'span12';
  2424. }
  2425.  
  2426. return $result;
  2427. }
  2428. }
  2429.  
  2430. // **********************************************************************//
  2431. // ! Get single product page sidebar position
  2432. // **********************************************************************//
  2433.  
  2434. if(!function_exists('etheme_get_single_product_sidebar')) {
  2435. function etheme_get_single_product_sidebar() {
  2436.  
  2437. $result = array(
  2438. 'position' => 'left',
  2439. 'responsive' => '',
  2440. 'images_span' => '5',
  2441. 'meta_span' => '4'
  2442. );
  2443.  
  2444. $result['single_product_sidebar'] = is_active_sidebar('single-sidebar');
  2445. $result['responsive'] = etheme_get_option('blog_sidebar_responsive');
  2446. $result['position'] = etheme_get_option('single_sidebar');
  2447.  
  2448. $result['single_product_sidebar'] = apply_filters('single_product_sidebar', $result['single_product_sidebar']);
  2449.  
  2450. if(!$result['single_product_sidebar'] || $result['position'] == 'no_sidebar') {
  2451. $result['position'] = 'without';
  2452. $result['images_span'] = '6';
  2453. $result['meta_span'] = '6';
  2454. }
  2455.  
  2456. return $result;
  2457. }
  2458. }
  2459.  
  2460.  
  2461.  
  2462. // **********************************************************************//
  2463. // ! Custom navigation
  2464. // **********************************************************************//
  2465.  
  2466. class Et_Navigation extends Walker_Nav_Menu
  2467. {
  2468. function start_lvl( &$output, $depth = 0, $args = array() ) {
  2469. $display_depth = ($depth + 1);
  2470. if($display_depth == '1') {
  2471. $class_names = 'nav-sublist-dropdown';
  2472. $container = 'container';
  2473. } else {
  2474. $class_names = 'nav-sublist';
  2475. $container = '';
  2476. }
  2477.  
  2478. $indent = str_repeat("\t", $depth);
  2479.  
  2480. $output .= "\n$indent<div class=".$class_names."><div class='".$container."'><ul>\n";
  2481. }
  2482.  
  2483. function end_lvl( &$output, $depth = 1, $args = array() ) {
  2484. $indent = str_repeat("\t", $depth);
  2485. $output .= "$indent</ul></div></div>\n";
  2486. }
  2487.  
  2488. function start_el ( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
  2489. global $wp_query;
  2490. $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
  2491.  
  2492. $class_names = $value = '';
  2493.  
  2494. $classes = empty( $item->classes ) ? array() : (array) $item->classes;
  2495. $classes[] = 'menu-item-' . $item->ID;
  2496.  
  2497. $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
  2498. $class_names = ' class="' . esc_attr( $class_names ) . '"';
  2499.  
  2500. $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
  2501. $id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';
  2502.  
  2503. $output .= $indent . '<li' . $id . $value . $class_names .'>';
  2504.  
  2505. $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
  2506. $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
  2507. $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
  2508. $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
  2509.  
  2510. $description = '';
  2511. if(strpos($class_names,'image-item') !== false){$description = '<img src="'.do_shortcode($item->description).'" alt=" "/>';}
  2512.  
  2513. $item_output = $args->before;
  2514. $item_output .= '<a'. $attributes .'>';
  2515. $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
  2516. $item_output .= $description;
  2517. $item_output .= '</a>';
  2518. $item_output .= $args->after;
  2519.  
  2520. $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
  2521. }
  2522.  
  2523.  
  2524. }
  2525.  
  2526. // **********************************************************************//
  2527. // ! http://codex.wordpress.org/Function_Reference/wp_nav_menu#How_to_add_a_parent_class_for_menu_item
  2528. // **********************************************************************//
  2529.  
  2530. add_filter( 'wp_nav_menu_objects', 'add_menu_parent_class' );
  2531. function add_menu_parent_class( $items ) {
  2532.  
  2533. $parents = array();
  2534. foreach ( $items as $item ) {
  2535. if ( $item->menu_item_parent && $item->menu_item_parent > 0 ) {
  2536. $parents[] = $item->menu_item_parent;
  2537. }
  2538. }
  2539.  
  2540. foreach ( $items as $item ) {
  2541. if ( in_array( $item->ID, $parents ) ) {
  2542. $item->classes[] = 'menu-parent-item';
  2543. }
  2544. }
  2545.  
  2546. return $items;
  2547. }
  2548.  
  2549.  
  2550. // **********************************************************************//
  2551. // ! Enable shortcodes in text widgets
  2552. // **********************************************************************//
  2553. add_filter('widget_text', 'do_shortcode');
  2554.  
  2555. // **********************************************************************//
  2556. // ! Add GOOGLE fonts
  2557. // **********************************************************************//
  2558. /*
  2559. $content = json_decode($content, true);
  2560. echo '<pre>';
  2561. //print_r($content);
  2562. foreach($content['items'] as $font) {
  2563. //print_r($font);
  2564. echo "'".str_replace(" ", "+", $font['family'])."' => '".$font['family']."',<br>";
  2565. }
  2566. echo '</pre>';*/
  2567.  
  2568. if(!function_exists('etheme_recognized_google_font_families')) {
  2569. function etheme_recognized_google_font_families( $array, $field_id ) {
  2570. $array = array(
  2571. 'Open+Sans' => '"Open Sans", sans-serif',
  2572. 'Droid+Sans' => '"Droid Sans", sans-serif',
  2573. 'Lato' => '"Lato"',
  2574. 'Cardo' => '"Cardo"',
  2575. 'Roboto' => '"Roboto"',
  2576. 'Fauna+One' => '"Fauna One"',
  2577. 'Oswald' => '"Oswald"',
  2578. 'Yanone+Kaffeesatz' => '"Yanone Kaffeesatz"',
  2579. 'Muli' => '"Muli"',
  2580. 'ABeeZee' => 'ABeeZee',
  2581. 'Abel' => 'Abel',
  2582. 'Abril+Fatface' => 'Abril Fatface',
  2583. 'Aclonica' => 'Aclonica',
  2584. 'Acme' => 'Acme',
  2585. 'Actor' => 'Actor',
  2586. 'Adamina' => 'Adamina',
  2587. 'Advent+Pro' => 'Advent Pro',
  2588. 'Aguafina+Script' => 'Aguafina Script',
  2589. 'Akronim' => 'Akronim',
  2590. 'Aladin' => 'Aladin',
  2591. 'Aldrich' => 'Aldrich',
  2592. 'Alef' => 'Alef',
  2593. 'Alegreya' => 'Alegreya',
  2594. 'Alegreya+SC' => 'Alegreya SC',
  2595. 'Alex+Brush' => 'Alex Brush',
  2596. 'Alfa+Slab+One' => 'Alfa Slab One',
  2597. 'Alice' => 'Alice',
  2598. 'Alike' => 'Alike',
  2599. 'Alike+Angular' => 'Alike Angular',
  2600. 'Allan' => 'Allan',
  2601. 'Allerta' => 'Allerta',
  2602. 'Allerta+Stencil' => 'Allerta Stencil',
  2603. 'Allura' => 'Allura',
  2604. 'Almendra' => 'Almendra',
  2605. 'Almendra+Display' => 'Almendra Display',
  2606. 'Almendra+SC' => 'Almendra SC',
  2607. 'Amarante' => 'Amarante',
  2608. 'Amaranth' => 'Amaranth',
  2609. 'Amatic+SC' => 'Amatic SC',
  2610. 'Amethysta' => 'Amethysta',
  2611. 'Anaheim' => 'Anaheim',
  2612. 'Andada' => 'Andada',
  2613. 'Andika' => 'Andika',
  2614. 'Angkor' => 'Angkor',
  2615. 'Annie+Use+Your+Telescope' => 'Annie Use Your Telescope',
  2616. 'Anonymous+Pro' => 'Anonymous Pro',
  2617. 'Antic' => 'Antic',
  2618. 'Antic+Didone' => 'Antic Didone',
  2619. 'Antic+Slab' => 'Antic Slab',
  2620. 'Anton' => 'Anton',
  2621. 'Arapey' => 'Arapey',
  2622. 'Arbutus' => 'Arbutus',
  2623. 'Arbutus+Slab' => 'Arbutus Slab',
  2624. 'Architects+Daughter' => 'Architects Daughter',
  2625. 'Archivo+Black' => 'Archivo Black',
  2626. 'Archivo+Narrow' => 'Archivo Narrow',
  2627. 'Arimo' => 'Arimo',
  2628. 'Arizonia' => 'Arizonia',
  2629. 'Armata' => 'Armata',
  2630. 'Artifika' => 'Artifika',
  2631. 'Arvo' => 'Arvo',
  2632. 'Asap' => 'Asap',
  2633. 'Asset' => 'Asset',
  2634. 'Astloch' => 'Astloch',
  2635. 'Asul' => 'Asul',
  2636. 'Atomic+Age' => 'Atomic Age',
  2637. 'Aubrey' => 'Aubrey',
  2638. 'Audiowide' => 'Audiowide',
  2639. 'Autour+One' => 'Autour One',
  2640. 'Average' => 'Average',
  2641. 'Average+Sans' => 'Average Sans',
  2642. 'Averia+Gruesa+Libre' => 'Averia Gruesa Libre',
  2643. 'Averia+Libre' => 'Averia Libre',
  2644. 'Averia+Sans+Libre' => 'Averia Sans Libre',
  2645. 'Averia+Serif+Libre' => 'Averia Serif Libre',
  2646. 'Bad+Script' => 'Bad Script',
  2647. 'Balthazar' => 'Balthazar',
  2648. 'Bangers' => 'Bangers',
  2649. 'Basic' => 'Basic',
  2650. 'Battambang' => 'Battambang',
  2651. 'Baumans' => 'Baumans',
  2652. 'Bayon' => 'Bayon',
  2653. 'Belgrano' => 'Belgrano',
  2654. 'Belleza' => 'Belleza',
  2655. 'BenchNine' => 'BenchNine',
  2656. 'Bentham' => 'Bentham',
  2657. 'Berkshire+Swash' => 'Berkshire Swash',
  2658. 'Bevan' => 'Bevan',
  2659. 'Bigelow+Rules' => 'Bigelow Rules',
  2660. 'Bigshot+One' => 'Bigshot One',
  2661. 'Bilbo' => 'Bilbo',
  2662. 'Bilbo+Swash+Caps' => 'Bilbo Swash Caps',
  2663. 'Bitter' => 'Bitter',
  2664. 'Black+Ops+One' => 'Black Ops One',
  2665. 'Bokor' => 'Bokor',
  2666. 'Bonbon' => 'Bonbon',
  2667. 'Boogaloo' => 'Boogaloo',
  2668. 'Bowlby+One' => 'Bowlby One',
  2669. 'Bowlby+One+SC' => 'Bowlby One SC',
  2670. 'Brawler' => 'Brawler',
  2671. 'Bree+Serif' => 'Bree Serif',
  2672. 'Bubblegum+Sans' => 'Bubblegum Sans',
  2673. 'Bubbler+One' => 'Bubbler One',
  2674. 'Buda' => 'Buda',
  2675. 'Buenard' => 'Buenard',
  2676. 'Butcherman' => 'Butcherman',
  2677. 'Butterfly+Kids' => 'Butterfly Kids',
  2678. 'Cabin' => 'Cabin',
  2679. 'Cabin+Condensed' => 'Cabin Condensed',
  2680. 'Cabin+Sketch' => 'Cabin Sketch',
  2681. 'Caesar+Dressing' => 'Caesar Dressing',
  2682. 'Cagliostro' => 'Cagliostro',
  2683. 'Calligraffitti' => 'Calligraffitti',
  2684. 'Cambo' => 'Cambo',
  2685. 'Candal' => 'Candal',
  2686. 'Cantarell' => 'Cantarell',
  2687. 'Cantata+One' => 'Cantata One',
  2688. 'Cantora+One' => 'Cantora One',
  2689. 'Capriola' => 'Capriola',
  2690. 'Cardo' => 'Cardo',
  2691. 'Carme' => 'Carme',
  2692. 'Carrois+Gothic' => 'Carrois Gothic',
  2693. 'Carrois+Gothic+SC' => 'Carrois Gothic SC',
  2694. 'Carter+One' => 'Carter One',
  2695. 'Caudex' => 'Caudex',
  2696. 'Cedarville+Cursive' => 'Cedarville Cursive',
  2697. 'Ceviche+One' => 'Ceviche One',
  2698. 'Changa+One' => 'Changa One',
  2699. 'Chango' => 'Chango',
  2700. 'Chau+Philomene+One' => 'Chau Philomene One',
  2701. 'Chela+One' => 'Chela One',
  2702. 'Chelsea+Market' => 'Chelsea Market',
  2703. 'Chenla' => 'Chenla',
  2704. 'Cherry+Cream+Soda' => 'Cherry Cream Soda',
  2705. 'Cherry+Swash' => 'Cherry Swash',
  2706. 'Chewy' => 'Chewy',
  2707. 'Chicle' => 'Chicle',
  2708. 'Chivo' => 'Chivo',
  2709. 'Cinzel' => 'Cinzel',
  2710. 'Cinzel+Decorative' => 'Cinzel Decorative',
  2711. 'Clicker+Script' => 'Clicker Script',
  2712. 'Coda' => 'Coda',
  2713. 'Coda+Caption' => 'Coda Caption',
  2714. 'Codystar' => 'Codystar',
  2715. 'Combo' => 'Combo',
  2716. 'Comfortaa' => 'Comfortaa',
  2717. 'Coming+Soon' => 'Coming Soon',
  2718. 'Concert+One' => 'Concert One',
  2719. 'Condiment' => 'Condiment',
  2720. 'Content' => 'Content',
  2721. 'Contrail+One' => 'Contrail One',
  2722. 'Convergence' => 'Convergence',
  2723. 'Cookie' => 'Cookie',
  2724. 'Copse' => 'Copse',
  2725. 'Corben' => 'Corben',
  2726. 'Courgette' => 'Courgette',
  2727. 'Cousine' => 'Cousine',
  2728. 'Coustard' => 'Coustard',
  2729. 'Covered+By+Your+Grace' => 'Covered By Your Grace',
  2730. 'Crafty+Girls' => 'Crafty Girls',
  2731. 'Creepster' => 'Creepster',
  2732. 'Crete+Round' => 'Crete Round',
  2733. 'Crimson+Text' => 'Crimson Text',
  2734. 'Croissant+One' => 'Croissant One',
  2735. 'Crushed' => 'Crushed',
  2736. 'Cuprum' => 'Cuprum',
  2737. 'Cutive' => 'Cutive',
  2738. 'Cutive+Mono' => 'Cutive Mono',
  2739. 'Damion' => 'Damion',
  2740. 'Dancing+Script' => 'Dancing Script',
  2741. 'Dangrek' => 'Dangrek',
  2742. 'Dawning+of+a+New+Day' => 'Dawning of a New Day',
  2743. 'Days+One' => 'Days One',
  2744. 'Delius' => 'Delius',
  2745. 'Delius+Swash+Caps' => 'Delius Swash Caps',
  2746. 'Delius+Unicase' => 'Delius Unicase',
  2747. 'Della+Respira' => 'Della Respira',
  2748. 'Denk+One' => 'Denk One',
  2749. 'Devonshire' => 'Devonshire',
  2750. 'Didact+Gothic' => 'Didact Gothic',
  2751. 'Diplomata' => 'Diplomata',
  2752. 'Diplomata+SC' => 'Diplomata SC',
  2753. 'Domine' => 'Domine',
  2754. 'Donegal+One' => 'Donegal One',
  2755. 'Doppio+One' => 'Doppio One',
  2756. 'Dorsa' => 'Dorsa',
  2757. 'Dosis' => 'Dosis',
  2758. 'Dr+Sugiyama' => 'Dr Sugiyama',
  2759. 'Droid+Sans' => 'Droid Sans',
  2760. 'Droid+Sans+Mono' => 'Droid Sans Mono',
  2761. 'Droid+Serif' => 'Droid Serif',
  2762. 'Duru+Sans' => 'Duru Sans',
  2763. 'Dynalight' => 'Dynalight',
  2764. 'EB+Garamond' => 'EB Garamond',
  2765. 'Eagle+Lake' => 'Eagle Lake',
  2766. 'Eater' => 'Eater',
  2767. 'Economica' => 'Economica',
  2768. 'Electrolize' => 'Electrolize',
  2769. 'Elsie' => 'Elsie',
  2770. 'Elsie+Swash+Caps' => 'Elsie Swash Caps',
  2771. 'Emblema+One' => 'Emblema One',
  2772. 'Emilys+Candy' => 'Emilys Candy',
  2773. 'Engagement' => 'Engagement',
  2774. 'Englebert' => 'Englebert',
  2775. 'Enriqueta' => 'Enriqueta',
  2776. 'Erica+One' => 'Erica One',
  2777. 'Esteban' => 'Esteban',
  2778. 'Euphoria+Script' => 'Euphoria Script',
  2779. 'Ewert' => 'Ewert',
  2780. 'Exo' => 'Exo',
  2781. 'Expletus+Sans' => 'Expletus Sans',
  2782. 'Fanwood+Text' => 'Fanwood Text',
  2783. 'Fascinate' => 'Fascinate',
  2784. 'Fascinate+Inline' => 'Fascinate Inline',
  2785. 'Faster+One' => 'Faster One',
  2786. 'Fasthand' => 'Fasthand',
  2787. 'Fauna+One' => 'Fauna One',
  2788. 'Federant' => 'Federant',
  2789. 'Federo' => 'Federo',
  2790. 'Felipa' => 'Felipa',
  2791. 'Fenix' => 'Fenix',
  2792. 'Finger+Paint' => 'Finger Paint',
  2793. 'Fjalla+One' => 'Fjalla One',
  2794. 'Fjord+One' => 'Fjord One',
  2795. 'Flamenco' => 'Flamenco',
  2796. 'Flavors' => 'Flavors',
  2797. 'Fondamento' => 'Fondamento',
  2798. 'Fontdiner+Swanky' => 'Fontdiner Swanky',
  2799. 'Forum' => 'Forum',
  2800. 'Francois+One' => 'Francois One',
  2801. 'Freckle+Face' => 'Freckle Face',
  2802. 'Fredericka+the+Great' => 'Fredericka the Great',
  2803. 'Fredoka+One' => 'Fredoka One',
  2804. 'Freehand' => 'Freehand',
  2805. 'Fresca' => 'Fresca',
  2806. 'Frijole' => 'Frijole',
  2807. 'Fruktur' => 'Fruktur',
  2808. 'Fugaz+One' => 'Fugaz One',
  2809. 'GFS+Didot' => 'GFS Didot',
  2810. 'GFS+Neohellenic' => 'GFS Neohellenic',
  2811. 'Gabriela' => 'Gabriela',
  2812. 'Gafata' => 'Gafata',
  2813. 'Galdeano' => 'Galdeano',
  2814. 'Galindo' => 'Galindo',
  2815. 'Gentium+Basic' => 'Gentium Basic',
  2816. 'Gentium+Book+Basic' => 'Gentium Book Basic',
  2817. 'Geo' => 'Geo',
  2818. 'Geostar' => 'Geostar',
  2819. 'Geostar+Fill' => 'Geostar Fill',
  2820. 'Germania+One' => 'Germania One',
  2821. 'Gilda+Display' => 'Gilda Display',
  2822. 'Give+You+Glory' => 'Give You Glory',
  2823. 'Glass+Antiqua' => 'Glass Antiqua',
  2824. 'Glegoo' => 'Glegoo',
  2825. 'Gloria+Hallelujah' => 'Gloria Hallelujah',
  2826. 'Goblin+One' => 'Goblin One',
  2827. 'Gochi+Hand' => 'Gochi Hand',
  2828. 'Gorditas' => 'Gorditas',
  2829. 'Goudy+Bookletter+1911' => 'Goudy Bookletter 1911',
  2830. 'Graduate' => 'Graduate',
  2831. 'Grand+Hotel' => 'Grand Hotel',
  2832. 'Gravitas+One' => 'Gravitas One',
  2833. 'Great+Vibes' => 'Great Vibes',
  2834. 'Griffy' => 'Griffy',
  2835. 'Gruppo' => 'Gruppo',
  2836. 'Gudea' => 'Gudea',
  2837. 'Habibi' => 'Habibi',
  2838. 'Hammersmith+One' => 'Hammersmith One',
  2839. 'Hanalei' => 'Hanalei',
  2840. 'Hanalei+Fill' => 'Hanalei Fill',
  2841. 'Handlee' => 'Handlee',
  2842. 'Hanuman' => 'Hanuman',
  2843. 'Happy+Monkey' => 'Happy Monkey',
  2844. 'Headland+One' => 'Headland One',
  2845. 'Henny+Penny' => 'Henny Penny',
  2846. 'Herr+Von+Muellerhoff' => 'Herr Von Muellerhoff',
  2847. 'Holtwood+One+SC' => 'Holtwood One SC',
  2848. 'Homemade+Apple' => 'Homemade Apple',
  2849. 'Homenaje' => 'Homenaje',
  2850. 'IM+Fell+DW+Pica' => 'IM Fell DW Pica',
  2851. 'IM+Fell+DW+Pica+SC' => 'IM Fell DW Pica SC',
  2852. 'IM+Fell+Double+Pica' => 'IM Fell Double Pica',
  2853. 'IM+Fell+Double+Pica+SC' => 'IM Fell Double Pica SC',
  2854. 'IM+Fell+English' => 'IM Fell English',
  2855. 'IM+Fell+English+SC' => 'IM Fell English SC',
  2856. 'IM+Fell+French+Canon' => 'IM Fell French Canon',
  2857. 'IM+Fell+French+Canon+SC' => 'IM Fell French Canon SC',
  2858. 'IM+Fell+Great+Primer' => 'IM Fell Great Primer',
  2859. 'IM+Fell+Great+Primer+SC' => 'IM Fell Great Primer SC',
  2860. 'Iceberg' => 'Iceberg',
  2861. 'Iceland' => 'Iceland',
  2862. 'Imprima' => 'Imprima',
  2863. 'Inconsolata' => 'Inconsolata',
  2864. 'Inder' => 'Inder',
  2865. 'Indie+Flower' => 'Indie Flower',
  2866. 'Inika' => 'Inika',
  2867. 'Irish+Grover' => 'Irish Grover',
  2868. 'Istok+Web' => 'Istok Web',
  2869. 'Italiana' => 'Italiana',
  2870. 'Italianno' => 'Italianno',
  2871. 'Jacques+Francois' => 'Jacques Francois',
  2872. 'Jacques+Francois+Shadow' => 'Jacques Francois Shadow',
  2873. 'Jim+Nightshade' => 'Jim Nightshade',
  2874. 'Jockey+One' => 'Jockey One',
  2875. 'Jolly+Lodger' => 'Jolly Lodger',
  2876. 'Josefin+Sans' => 'Josefin Sans',
  2877. 'Josefin+Slab' => 'Josefin Slab',
  2878. 'Joti+One' => 'Joti One',
  2879. 'Judson' => 'Judson',
  2880. 'Julee' => 'Julee',
  2881. 'Julius+Sans+One' => 'Julius Sans One',
  2882. 'Junge' => 'Junge',
  2883. 'Jura' => 'Jura',
  2884. 'Just+Another+Hand' => 'Just Another Hand',
  2885. 'Just+Me+Again+Down+Here' => 'Just Me Again Down Here',
  2886. 'Kameron' => 'Kameron',
  2887. 'Karla' => 'Karla',
  2888. 'Kaushan+Script' => 'Kaushan Script',
  2889. 'Kavoon' => 'Kavoon',
  2890. 'Keania+One' => 'Keania One',
  2891. 'Kelly+Slab' => 'Kelly Slab',
  2892. 'Kenia' => 'Kenia',
  2893. 'Khmer' => 'Khmer',
  2894. 'Kite+One' => 'Kite One',
  2895. 'Knewave' => 'Knewave',
  2896. 'Kotta+One' => 'Kotta One',
  2897. 'Koulen' => 'Koulen',
  2898. 'Kranky' => 'Kranky',
  2899. 'Kreon' => 'Kreon',
  2900. 'Kristi' => 'Kristi',
  2901. 'Krona+One' => 'Krona One',
  2902. 'La+Belle+Aurore' => 'La Belle Aurore',
  2903. 'Lancelot' => 'Lancelot',
  2904. 'Lato' => 'Lato',
  2905. 'League+Script' => 'League Script',
  2906. 'Leckerli+One' => 'Leckerli One',
  2907. 'Ledger' => 'Ledger',
  2908. 'Lekton' => 'Lekton',
  2909. 'Lemon' => 'Lemon',
  2910. 'Libre+Baskerville' => 'Libre Baskerville',
  2911. 'Life+Savers' => 'Life Savers',
  2912. 'Lilita+One' => 'Lilita One',
  2913. 'Lily+Script+One' => 'Lily Script One',
  2914. 'Limelight' => 'Limelight',
  2915. 'Linden+Hill' => 'Linden Hill',
  2916. 'Lobster' => 'Lobster',
  2917. 'Lobster+Two' => 'Lobster Two',
  2918. 'Londrina+Outline' => 'Londrina Outline',
  2919. 'Londrina+Shadow' => 'Londrina Shadow',
  2920. 'Londrina+Sketch' => 'Londrina Sketch',
  2921. 'Londrina+Solid' => 'Londrina Solid',
  2922. 'Lora' => 'Lora',
  2923. 'Love+Ya+Like+A+Sister' => 'Love Ya Like A Sister',
  2924. 'Loved+by+the+King' => 'Loved by the King',
  2925. 'Lovers+Quarrel' => 'Lovers Quarrel',
  2926. 'Luckiest+Guy' => 'Luckiest Guy',
  2927. 'Lusitana' => 'Lusitana',
  2928. 'Lustria' => 'Lustria',
  2929. 'Macondo' => 'Macondo',
  2930. 'Macondo+Swash+Caps' => 'Macondo Swash Caps',
  2931. 'Magra' => 'Magra',
  2932. 'Maiden+Orange' => 'Maiden Orange',
  2933. 'Mako' => 'Mako',
  2934. 'Marcellus' => 'Marcellus',
  2935. 'Marcellus+SC' => 'Marcellus SC',
  2936. 'Marck+Script' => 'Marck Script',
  2937. 'Margarine' => 'Margarine',
  2938. 'Marko+One' => 'Marko One',
  2939. 'Marmelad' => 'Marmelad',
  2940. 'Marvel' => 'Marvel',
  2941. 'Mate' => 'Mate',
  2942. 'Mate+SC' => 'Mate SC',
  2943. 'Maven+Pro' => 'Maven Pro',
  2944. 'McLaren' => 'McLaren',
  2945. 'Meddon' => 'Meddon',
  2946. 'MedievalSharp' => 'MedievalSharp',
  2947. 'Medula+One' => 'Medula One',
  2948. 'Megrim' => 'Megrim',
  2949. 'Meie+Script' => 'Meie Script',
  2950. 'Merienda' => 'Merienda',
  2951. 'Merienda+One' => 'Merienda One',
  2952. 'Merriweather' => 'Merriweather',
  2953. 'Merriweather+Sans' => 'Merriweather Sans',
  2954. 'Metal' => 'Metal',
  2955. 'Metal+Mania' => 'Metal Mania',
  2956. 'Metamorphous' => 'Metamorphous',
  2957. 'Metrophobic' => 'Metrophobic',
  2958. 'Michroma' => 'Michroma',
  2959. 'Milonga' => 'Milonga',
  2960. 'Miltonian' => 'Miltonian',
  2961. 'Miltonian+Tattoo' => 'Miltonian Tattoo',
  2962. 'Miniver' => 'Miniver',
  2963. 'Miss+Fajardose' => 'Miss Fajardose',
  2964. 'Modern+Antiqua' => 'Modern Antiqua',
  2965. 'Molengo' => 'Molengo',
  2966. 'Molle' => 'Molle',
  2967. 'Monda' => 'Monda',
  2968. 'Monofett' => 'Monofett',
  2969. 'Monoton' => 'Monoton',
  2970. 'Monsieur+La+Doulaise' => 'Monsieur La Doulaise',
  2971. 'Montaga' => 'Montaga',
  2972. 'Montez' => 'Montez',
  2973. 'Montserrat' => 'Montserrat',
  2974. 'Montserrat+Alternates' => 'Montserrat Alternates',
  2975. 'Montserrat+Subrayada' => 'Montserrat Subrayada',
  2976. 'Moul' => 'Moul',
  2977. 'Moulpali' => 'Moulpali',
  2978. 'Mountains+of+Christmas' => 'Mountains of Christmas',
  2979. 'Mouse+Memoirs' => 'Mouse Memoirs',
  2980. 'Mr+Bedfort' => 'Mr Bedfort',
  2981. 'Mr+Dafoe' => 'Mr Dafoe',
  2982. 'Mr+De+Haviland' => 'Mr De Haviland',
  2983. 'Mrs+Saint+Delafield' => 'Mrs Saint Delafield',
  2984. 'Mrs+Sheppards' => 'Mrs Sheppards',
  2985. 'Muli' => 'Muli',
  2986. 'Mystery+Quest' => 'Mystery Quest',
  2987. 'Neucha' => 'Neucha',
  2988. 'Neuton' => 'Neuton',
  2989. 'New+Rocker' => 'New Rocker',
  2990. 'News+Cycle' => 'News Cycle',
  2991. 'Niconne' => 'Niconne',
  2992. 'Nixie+One' => 'Nixie One',
  2993. 'Nobile' => 'Nobile',
  2994. 'Nokora' => 'Nokora',
  2995. 'Norican' => 'Norican',
  2996. 'Nosifer' => 'Nosifer',
  2997. 'Nothing+You+Could+Do' => 'Nothing You Could Do',
  2998. 'Noticia+Text' => 'Noticia Text',
  2999. 'Noto+Sans' => 'Noto Sans',
  3000. 'Noto+Serif' => 'Noto Serif',
  3001. 'Nova+Cut' => 'Nova Cut',
  3002. 'Nova+Flat' => 'Nova Flat',
  3003. 'Nova+Mono' => 'Nova Mono',
  3004. 'Nova+Oval' => 'Nova Oval',
  3005. 'Nova+Round' => 'Nova Round',
  3006. 'Nova+Script' => 'Nova Script',
  3007. 'Nova+Slim' => 'Nova Slim',
  3008. 'Nova+Square' => 'Nova Square',
  3009. 'Numans' => 'Numans',
  3010. 'Nunito' => 'Nunito',
  3011. 'Odor+Mean+Chey' => 'Odor Mean Chey',
  3012. 'Offside' => 'Offside',
  3013. 'Old+Standard+TT' => 'Old Standard TT',
  3014. 'Oldenburg' => 'Oldenburg',
  3015. 'Oleo+Script' => 'Oleo Script',
  3016. 'Oleo+Script+Swash+Caps' => 'Oleo Script Swash Caps',
  3017. 'Open+Sans' => 'Open Sans',
  3018. 'Open+Sans+Condensed' => 'Open Sans Condensed',
  3019. 'Oranienbaum' => 'Oranienbaum',
  3020. 'Orbitron' => 'Orbitron',
  3021. 'Oregano' => 'Oregano',
  3022. 'Orienta' => 'Orienta',
  3023. 'Original+Surfer' => 'Original Surfer',
  3024. 'Oswald' => 'Oswald',
  3025. 'Over+the+Rainbow' => 'Over the Rainbow',
  3026. 'Overlock' => 'Overlock',
  3027. 'Overlock+SC' => 'Overlock SC',
  3028. 'Ovo' => 'Ovo',
  3029. 'Oxygen' => 'Oxygen',
  3030. 'Oxygen+Mono' => 'Oxygen Mono',
  3031. 'PT+Mono' => 'PT Mono',
  3032. 'PT+Sans' => 'PT Sans',
  3033. 'PT+Sans+Caption' => 'PT Sans Caption',
  3034. 'PT+Sans+Narrow' => 'PT Sans Narrow',
  3035. 'PT+Serif' => 'PT Serif',
  3036. 'PT+Serif+Caption' => 'PT Serif Caption',
  3037. 'Pacifico' => 'Pacifico',
  3038. 'Paprika' => 'Paprika',
  3039. 'Parisienne' => 'Parisienne',
  3040. 'Passero+One' => 'Passero One',
  3041. 'Passion+One' => 'Passion One',
  3042. 'Pathway+Gothic+One' => 'Pathway Gothic One',
  3043. 'Patrick+Hand' => 'Patrick Hand',
  3044. 'Patrick+Hand+SC' => 'Patrick Hand SC',
  3045. 'Patua+One' => 'Patua One',
  3046. 'Paytone+One' => 'Paytone One',
  3047. 'Peralta' => 'Peralta',
  3048. 'Permanent+Marker' => 'Permanent Marker',
  3049. 'Petit+Formal+Script' => 'Petit Formal Script',
  3050. 'Petrona' => 'Petrona',
  3051. 'Philosopher' => 'Philosopher',
  3052. 'Piedra' => 'Piedra',
  3053. 'Pinyon+Script' => 'Pinyon Script',
  3054. 'Pirata+One' => 'Pirata One',
  3055. 'Plaster' => 'Plaster',
  3056. 'Play' => 'Play',
  3057. 'Playball' => 'Playball',
  3058. 'Playfair+Display' => 'Playfair Display',
  3059. 'Playfair+Display+SC' => 'Playfair Display SC',
  3060. 'Podkova' => 'Podkova',
  3061. 'Poiret+One' => 'Poiret One',
  3062. 'Poller+One' => 'Poller One',
  3063. 'Poly' => 'Poly',
  3064. 'Pompiere' => 'Pompiere',
  3065. 'Pontano+Sans' => 'Pontano Sans',
  3066. 'Port+Lligat+Sans' => 'Port Lligat Sans',
  3067. 'Port+Lligat+Slab' => 'Port Lligat Slab',
  3068. 'Prata' => 'Prata',
  3069. 'Preahvihear' => 'Preahvihear',
  3070. 'Press+Start+2P' => 'Press Start 2P',
  3071. 'Princess+Sofia' => 'Princess Sofia',
  3072. 'Prociono' => 'Prociono',
  3073. 'Prosto+One' => 'Prosto One',
  3074. 'Puritan' => 'Puritan',
  3075. 'Purple+Purse' => 'Purple Purse',
  3076. 'Quando' => 'Quando',
  3077. 'Quantico' => 'Quantico',
  3078. 'Quattrocento' => 'Quattrocento',
  3079. 'Quattrocento+Sans' => 'Quattrocento Sans',
  3080. 'Questrial' => 'Questrial',
  3081. 'Quicksand' => 'Quicksand',
  3082. 'Quintessential' => 'Quintessential',
  3083. 'Qwigley' => 'Qwigley',
  3084. 'Racing+Sans+One' => 'Racing Sans One',
  3085. 'Radley' => 'Radley',
  3086. 'Raleway' => 'Raleway',
  3087. 'Raleway+Dots' => 'Raleway Dots',
  3088. 'Rambla' => 'Rambla',
  3089. 'Rammetto+One' => 'Rammetto One',
  3090. 'Ranchers' => 'Ranchers',
  3091. 'Rancho' => 'Rancho',
  3092. 'Rationale' => 'Rationale',
  3093. 'Redressed' => 'Redressed',
  3094. 'Reenie+Beanie' => 'Reenie Beanie',
  3095. 'Revalia' => 'Revalia',
  3096. 'Ribeye' => 'Ribeye',
  3097. 'Ribeye+Marrow' => 'Ribeye Marrow',
  3098. 'Righteous' => 'Righteous',
  3099. 'Risque' => 'Risque',
  3100. 'Roboto' => 'Roboto',
  3101. 'Roboto+Condensed' => 'Roboto Condensed',
  3102. 'Roboto+Slab' => 'Roboto Slab',
  3103. 'Rochester' => 'Rochester',
  3104. 'Rock+Salt' => 'Rock Salt',
  3105. 'Rokkitt' => 'Rokkitt',
  3106. 'Romanesco' => 'Romanesco',
  3107. 'Ropa+Sans' => 'Ropa Sans',
  3108. 'Rosario' => 'Rosario',
  3109. 'Rosarivo' => 'Rosarivo',
  3110. 'Rouge+Script' => 'Rouge Script',
  3111. 'Ruda' => 'Ruda',
  3112. 'Rufina' => 'Rufina',
  3113. 'Ruge+Boogie' => 'Ruge Boogie',
  3114. 'Ruluko' => 'Ruluko',
  3115. 'Rum+Raisin' => 'Rum Raisin',
  3116. 'Ruslan+Display' => 'Ruslan Display',
  3117. 'Russo+One' => 'Russo One',
  3118. 'Ruthie' => 'Ruthie',
  3119. 'Rye' => 'Rye',
  3120. 'Sacramento' => 'Sacramento',
  3121. 'Sail' => 'Sail',
  3122. 'Salsa' => 'Salsa',
  3123. 'Sanchez' => 'Sanchez',
  3124. 'Sancreek' => 'Sancreek',
  3125. 'Sansita+One' => 'Sansita One',
  3126. 'Sarina' => 'Sarina',
  3127. 'Satisfy' => 'Satisfy',
  3128. 'Scada' => 'Scada',
  3129. 'Schoolbell' => 'Schoolbell',
  3130. 'Seaweed+Script' => 'Seaweed Script',
  3131. 'Sevillana' => 'Sevillana',
  3132. 'Seymour+One' => 'Seymour One',
  3133. 'Shadows+Into+Light' => 'Shadows Into Light',
  3134. 'Shadows+Into+Light+Two' => 'Shadows Into Light Two',
  3135. 'Shanti' => 'Shanti',
  3136. 'Share' => 'Share',
  3137. 'Share+Tech' => 'Share Tech',
  3138. 'Share+Tech+Mono' => 'Share Tech Mono',
  3139. 'Shojumaru' => 'Shojumaru',
  3140. 'Short+Stack' => 'Short Stack',
  3141. 'Siemreap' => 'Siemreap',
  3142. 'Sigmar+One' => 'Sigmar One',
  3143. 'Signika' => 'Signika',
  3144. 'Signika+Negative' => 'Signika Negative',
  3145. 'Simonetta' => 'Simonetta',
  3146. 'Sintony' => 'Sintony',
  3147. 'Sirin+Stencil' => 'Sirin Stencil',
  3148. 'Six+Caps' => 'Six Caps',
  3149. 'Skranji' => 'Skranji',
  3150. 'Slackey' => 'Slackey',
  3151. 'Smokum' => 'Smokum',
  3152. 'Smythe' => 'Smythe',
  3153. 'Sniglet' => 'Sniglet',
  3154. 'Snippet' => 'Snippet',
  3155. 'Snowburst+One' => 'Snowburst One',
  3156. 'Sofadi+One' => 'Sofadi One',
  3157. 'Sofia' => 'Sofia',
  3158. 'Sonsie+One' => 'Sonsie One',
  3159. 'Sorts+Mill+Goudy' => 'Sorts Mill Goudy',
  3160. 'Source+Code+Pro' => 'Source Code Pro',
  3161. 'Source+Sans+Pro' => 'Source Sans Pro',
  3162. 'Special+Elite' => 'Special Elite',
  3163. 'Spicy+Rice' => 'Spicy Rice',
  3164. 'Spinnaker' => 'Spinnaker',
  3165. 'Spirax' => 'Spirax',
  3166. 'Squada+One' => 'Squada One',
  3167. 'Stalemate' => 'Stalemate',
  3168. 'Stalinist+One' => 'Stalinist One',
  3169. 'Stardos+Stencil' => 'Stardos Stencil',
  3170. 'Stint+Ultra+Condensed' => 'Stint Ultra Condensed',
  3171. 'Stint+Ultra+Expanded' => 'Stint Ultra Expanded',
  3172. 'Stoke' => 'Stoke',
  3173. 'Strait' => 'Strait',
  3174. 'Sue+Ellen+Francisco' => 'Sue Ellen Francisco',
  3175. 'Sunshiney' => 'Sunshiney',
  3176. 'Supermercado+One' => 'Supermercado One',
  3177. 'Suwannaphum' => 'Suwannaphum',
  3178. 'Swanky+and+Moo+Moo' => 'Swanky and Moo Moo',
  3179. 'Syncopate' => 'Syncopate',
  3180. 'Tangerine' => 'Tangerine',
  3181. 'Taprom' => 'Taprom',
  3182. 'Tauri' => 'Tauri',
  3183. 'Telex' => 'Telex',
  3184. 'Tenor+Sans' => 'Tenor Sans',
  3185. 'Text+Me+One' => 'Text Me One',
  3186. 'The+Girl+Next+Door' => 'The Girl Next Door',
  3187. 'Tienne' => 'Tienne',
  3188. 'Tinos' => 'Tinos',
  3189. 'Titan+One' => 'Titan One',
  3190. 'Titillium+Web' => 'Titillium Web',
  3191. 'Trade+Winds' => 'Trade Winds',
  3192. 'Trocchi' => 'Trocchi',
  3193. 'Trochut' => 'Trochut',
  3194. 'Trykker' => 'Trykker',
  3195. 'Tulpen+One' => 'Tulpen One',
  3196. 'Ubuntu' => 'Ubuntu',
  3197. 'Ubuntu+Condensed' => 'Ubuntu Condensed',
  3198. 'Ubuntu+Mono' => 'Ubuntu Mono',
  3199. 'Ultra' => 'Ultra',
  3200. 'Uncial+Antiqua' => 'Uncial Antiqua',
  3201. 'Underdog' => 'Underdog',
  3202. 'Unica+One' => 'Unica One',
  3203. 'UnifrakturCook' => 'UnifrakturCook',
  3204. 'UnifrakturMaguntia' => 'UnifrakturMaguntia',
  3205. 'Unkempt' => 'Unkempt',
  3206. 'Unlock' => 'Unlock',
  3207. 'Unna' => 'Unna',
  3208. 'VT323' => 'VT323',
  3209. 'Vampiro+One' => 'Vampiro One',
  3210. 'Varela' => 'Varela',
  3211. 'Varela+Round' => 'Varela Round',
  3212. 'Vast+Shadow' => 'Vast Shadow',
  3213. 'Vibur' => 'Vibur',
  3214. 'Vidaloka' => 'Vidaloka',
  3215. 'Viga' => 'Viga',
  3216. 'Voces' => 'Voces',
  3217. 'Volkhov' => 'Volkhov',
  3218. 'Vollkorn' => 'Vollkorn',
  3219. 'Voltaire' => 'Voltaire',
  3220. 'Waiting+for+the+Sunrise' => 'Waiting for the Sunrise',
  3221. 'Wallpoet' => 'Wallpoet',
  3222. 'Walter+Turncoat' => 'Walter Turncoat',
  3223. 'Warnes' => 'Warnes',
  3224. 'Wellfleet' => 'Wellfleet',
  3225. 'Wendy+One' => 'Wendy One',
  3226. 'Wire+One' => 'Wire One',
  3227. 'Yanone+Kaffeesatz' => 'Yanone Kaffeesatz',
  3228. 'Yellowtail' => 'Yellowtail',
  3229. 'Yeseva+One' => 'Yeseva One',
  3230. 'Yesteryear' => 'Yesteryear',
  3231. 'Zeyada' => 'Zeyada'
  3232.  
  3233. );
  3234.  
  3235. return $array;
  3236.  
  3237. }
  3238. }
  3239.  
  3240.  
  3241. if(!function_exists('etheme_get_chosen_google_font')) {
  3242. function etheme_get_chosen_google_font() {
  3243. $chosenFonts = array();
  3244. $fontOptions = array(
  3245. etheme_get_option('mainfont'),
  3246. etheme_get_option('h1'),
  3247. etheme_get_option('h2'),
  3248. etheme_get_option('h3'),
  3249. etheme_get_option('h4'),
  3250. etheme_get_option('h5'),
  3251. etheme_get_option('h6'),
  3252. etheme_get_option('sfont')
  3253. );
  3254.  
  3255. foreach($fontOptions as $value){
  3256. if(!empty($value['google-font']) && $value['google-font'] != 'Open+Sans')
  3257. $chosenFonts[] = $value['google-font'];
  3258. }
  3259.  
  3260. return array_unique($chosenFonts);
  3261. }
  3262. }
  3263.  
  3264.  
  3265.  
  3266. // **********************************************************************//
  3267. // ! Custom meta fields to categories
  3268. // **********************************************************************//
  3269. if(function_exists('get_term_meta')){
  3270.  
  3271. function etheme_taxonomy_edit_meta_field($term, $taxonomy) {
  3272. $id = $term->term_id;
  3273. $term_meta = get_term_meta($id,'cat_meta');
  3274.  
  3275. if(!$term_meta){$term_meta = add_term_meta($id, 'cat_meta', '');}
  3276. ?>
  3277. <tr class="form-field">
  3278. <th scope="row" valign="top"><label for="term_meta[cat_header]"><?php _e( 'Category Header', ETHEME_DOMAIN ); ?></label></th>
  3279. <td>
  3280. <?php
  3281.  
  3282. $content = esc_attr( $term_meta[0]['cat_header'] ) ? esc_attr( $term_meta[0]['cat_header'] ) : '';
  3283. wp_editor($content,'term_meta[cat_header]');
  3284.  
  3285. ?>
  3286. </td>
  3287. </tr>
  3288. <?php
  3289. }
  3290.  
  3291. add_action( 'product_cat_edit_form_fields', 'etheme_taxonomy_edit_meta_field', 20, 2 );
  3292.  
  3293. // **********************************************************************//
  3294. // ! Save meta fields
  3295. // **********************************************************************//
  3296. function save_taxonomy_custom_meta( $term_id ) {
  3297. if ( isset( $_POST['term_meta'] ) ) {
  3298. $term_meta = get_term_meta($term_id,'cat_meta');
  3299. $cat_keys = array_keys( $_POST['term_meta'] );
  3300. foreach ( $cat_keys as $key ) {
  3301. if ( isset ( $_POST['term_meta'][$key] ) ) {
  3302. $term_meta[$key] = $_POST['term_meta'][$key];
  3303. }
  3304. }
  3305. // Save the option array.
  3306. update_term_meta($term_id, 'cat_meta', $term_meta);
  3307.  
  3308. }
  3309. }
  3310. add_action( 'edited_product_cat', 'save_taxonomy_custom_meta', 10, 2 );
  3311. }
  3312.  
  3313.  
  3314.  
  3315. // **********************************************************************//
  3316. // ! Load option tree plugin
  3317. // **********************************************************************//
  3318.  
  3319. add_filter( 'ot_show_pages', '__return_false' );
  3320. add_filter( 'ot_show_new_layout', '__return_false' );
  3321. add_filter( 'ot_theme_mode', '__return_true' );
  3322. load_template( trailingslashit( get_template_directory() ) . 'option-tree/ot-loader.php' );
  3323.  
  3324. // **********************************************************************//
  3325. // ! Add google analytics code
  3326. // **********************************************************************//
  3327. add_action('init', 'et_google_analytics');
  3328. if(!function_exists('et_google_analytics')) {
  3329. function et_google_analytics() {
  3330. $googleCode = etheme_get_option('google_code');
  3331.  
  3332. if(empty($googleCode)) return;
  3333.  
  3334. if(strpos($googleCode,'UA-') === 0) {
  3335.  
  3336. $googleCode = "
  3337.  
  3338. <script type='text/javascript'>
  3339.  
  3340. var _gaq = _gaq || [];
  3341. _gaq.push(['_setAccount', '".$googleCode."']);
  3342. _gaq.push(['_trackPageview']);
  3343.  
  3344. (function() {
  3345. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  3346. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  3347. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  3348. })();
  3349.  
  3350. </script>
  3351.  
  3352. ";
  3353. }
  3354.  
  3355. add_action('wp_head', 'et_print_google_code');
  3356. }
  3357.  
  3358. function et_print_google_code() {
  3359. $googleCode = etheme_get_option('google_code');
  3360.  
  3361. if(!empty($googleCode)) {
  3362. echo $googleCode;
  3363. }
  3364. }
  3365.  
  3366. }
  3367.  
  3368. // **********************************************************************//
  3369. // ! Twitter API functions
  3370. // **********************************************************************//
  3371. function etheme_capture_tweets($consumer_key,$consumer_secret,$user_token,$user_secret,$user, $count) {
  3372.  
  3373. $connection = getConnectionWithAccessToken($consumer_key,$consumer_secret,$user_token, $user_secret);
  3374. $params = array(
  3375. 'screen_name' => $user,
  3376. 'count' => $count
  3377. );
  3378.  
  3379. $content = $connection->get("statuses/user_timeline",$params);
  3380.  
  3381. //prar($content);
  3382.  
  3383. return json_encode($content);
  3384. }
  3385.  
  3386. function getConnectionWithAccessToken($consumer_key,$consumer_secret,$oauth_token, $oauth_token_secret) {
  3387. $connection = new TwitterOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
  3388. return $connection;
  3389. }
  3390.  
  3391.  
  3392. function etheme_tweet_linkify($tweet) {
  3393. $tweet = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $tweet);
  3394. $tweet = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $tweet);
  3395. $tweet = preg_replace("/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $tweet);
  3396. $tweet = preg_replace("/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=\\1\" target=\"_blank\">#\\1</a>", $tweet);
  3397. return $tweet;
  3398. }
  3399.  
  3400. function etheme_store_tweets($file, $tweets) {
  3401. ob_start(); // turn on the output buffering
  3402. $fo = fopen($file, 'w'); // opens for writing only or will create if it's not there
  3403. if (!$fo) return etheme_print_tweet_error(error_get_last());
  3404. $fr = fwrite($fo, $tweets); // writes to the file what was grabbed from the previous function
  3405. if (!$fr) return etheme_print_tweet_error(error_get_last());
  3406. fclose($fo); // closes
  3407. ob_end_flush(); // finishes and flushes the output buffer;
  3408. }
  3409.  
  3410. function etheme_pick_tweets($file) {
  3411. ob_start(); // turn on the output buffering
  3412. $fo = fopen($file, 'r'); // opens for reading only
  3413. if (!$fo) return etheme_print_tweet_error(error_get_last());
  3414. $fr = fread($fo, filesize($file));
  3415. if (!$fr) return etheme_print_tweet_error(error_get_last());
  3416. fclose($fo);
  3417. ob_end_flush();
  3418. return $fr;
  3419. }
  3420.  
  3421. function etheme_print_tweet_error($errorArray) {
  3422. return '<p class="eth-error">Error: ' . $errorArray['message'] . 'in ' . $errorArray['file'] . 'on line ' . $errorArray['line'] . '</p>';
  3423. }
  3424.  
  3425. function etheme_twitter_cache_enabled(){
  3426. return true;
  3427. }
  3428.  
  3429. function etheme_print_tweets($consumer_key,$consumer_secret,$user_token,$user_secret,$user, $count, $cachetime=50) {
  3430. if(etheme_twitter_cache_enabled()){
  3431. //setting the location to cache file
  3432. $cachefile = ETHEME_CODE_DIR . '/cache/twitterCache.json';
  3433.  
  3434. // the file exitsts but is outdated, update the cache file
  3435. if (file_exists($cachefile) && ( time() - $cachetime > filemtime($cachefile)) && filesize($cachefile) > 0) {
  3436. //capturing fresh tweets
  3437. $tweets = etheme_capture_tweets($consumer_key,$consumer_secret,$user_token,$user_secret,$user, $count);
  3438. $tweets_decoded = json_decode($tweets, true);
  3439. //if get error while loading fresh tweets - load outdated file
  3440. if(isset($tweets_decoded['error'])) {
  3441. $tweets = etheme_pick_tweets($cachefile);
  3442. }
  3443. //else store fresh tweets to cache
  3444. else
  3445. etheme_store_tweets($cachefile, $tweets);
  3446. }
  3447. //file doesn't exist or is empty, create new cache file
  3448. elseif (!file_exists($cachefile) || filesize($cachefile) == 0) {
  3449. $tweets = etheme_capture_tweets($consumer_key,$consumer_secret,$user_token,$user_secret,$user, $count);
  3450. $tweets_decoded = json_decode($tweets, true);
  3451. //if request fails, and there is no old cache file - print error
  3452. if(isset($tweets_decoded['error']))
  3453. return 'Error: ' . $tweets_decoded['error'];
  3454. //make new cache file with request results
  3455. else
  3456. etheme_store_tweets($cachefile, $tweets);
  3457. }
  3458. //file exists and is fresh
  3459. //load the cache file
  3460. else {
  3461. $tweets = etheme_pick_tweets($cachefile);
  3462. }
  3463. } else{
  3464. $tweets = etheme_capture_tweets($consumer_key,$consumer_secret,$user_token,$user_secret,$user, $count);
  3465. }
  3466.  
  3467. $tweets = json_decode($tweets, true);
  3468. $html = '';
  3469. foreach ($tweets as $tweet) {
  3470. $html .= '<div class="tweet">' . $tweet['text'] . '</div>';
  3471. }
  3472. $html = etheme_tweet_linkify($html);
  3473. return $html;
  3474. }
  3475.  
  3476.  
  3477.  
  3478. // **********************************************************************//
  3479. // ! Related posts
  3480. // **********************************************************************//
  3481.  
  3482. if(!function_exists('et_get_related_posts')) {
  3483. function et_get_related_posts($postId = false, $limit = 5){
  3484. global $post;
  3485. if(!$postId) {
  3486. $postId = $post->ID;
  3487. }
  3488. $categories = get_the_category($postId);
  3489. if ($categories) {
  3490. $category_ids = array();
  3491. foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
  3492.  
  3493. $args = array(
  3494. 'category__in' => $category_ids,
  3495. 'post__not_in' => array($postId),
  3496. 'showposts'=>$limit, // Number of related posts that will be shown.
  3497. 'caller_get_posts'=>1
  3498. );
  3499. etheme_create_posts_slider($args);
  3500. }
  3501. }
  3502. }
  3503.  
  3504. // **********************************************************************//
  3505. // ! Custom Static Blocks Post Type
  3506. // **********************************************************************//
  3507.  
  3508. add_action('init', 'et_register_static_blocks');
  3509.  
  3510. if(!function_exists('et_register_static_blocks')) {
  3511. function et_register_static_blocks() {
  3512. $labels = array(
  3513. 'name' => _x( 'Static Blocks', 'post type general name', ETHEME_DOMAIN ),
  3514. 'singular_name' => _x( 'Block', 'post type singular name', ETHEME_DOMAIN ),
  3515. 'add_new' => _x( 'Add New', 'static block', ETHEME_DOMAIN ),
  3516. 'add_new_item' => sprintf( __( 'Add New %s', ETHEME_DOMAIN ), __( 'Static Blocks', ETHEME_DOMAIN ) ),
  3517. 'edit_item' => sprintf( __( 'Edit %s', ETHEME_DOMAIN ), __( 'Static Blocks', ETHEME_DOMAIN ) ),
  3518. 'new_item' => sprintf( __( 'New %s', ETHEME_DOMAIN ), __( 'Static Blocks', ETHEME_DOMAIN ) ),
  3519. 'all_items' => sprintf( __( 'All %s', ETHEME_DOMAIN ), __( 'Static Blocks', ETHEME_DOMAIN ) ),
  3520. 'view_item' => sprintf( __( 'View %s', ETHEME_DOMAIN ), __( 'Static Blocks', ETHEME_DOMAIN ) ),
  3521. 'search_items' => sprintf( __( 'Search %a', ETHEME_DOMAIN ), __( 'Static Blocks', ETHEME_DOMAIN ) ),
  3522. 'not_found' => sprintf( __( 'No %s Found', ETHEME_DOMAIN ), __( 'Static Blocks', ETHEME_DOMAIN ) ),
  3523. 'not_found_in_trash' => sprintf( __( 'No %s Found In Trash', ETHEME_DOMAIN ), __( 'Static Blocks', ETHEME_DOMAIN ) ),
  3524. 'parent_item_colon' => '',
  3525. 'menu_name' => __( 'Static Blocks', ETHEME_DOMAIN )
  3526.  
  3527. );
  3528. $args = array(
  3529. 'labels' => $labels,
  3530. 'public' => true,
  3531. 'publicly_queryable' => true,
  3532. 'show_ui' => true,
  3533. 'show_in_menu' => true,
  3534. 'query_var' => true,
  3535. 'rewrite' => array( 'slug' => 'staticblocks' ),
  3536. 'capability_type' => 'post',
  3537. 'has_archive' => 'staticblocks',
  3538. 'hierarchical' => false,
  3539. 'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes' ),
  3540. 'menu_position' => 8
  3541. );
  3542. register_post_type( 'staticblocks', $args );
  3543. }
  3544. }
  3545.  
  3546. if(!function_exists('et_get_static_blocks')) {
  3547. function et_get_static_blocks () {
  3548. $return_array = array();
  3549. $args = array( 'post_type' => 'staticblocks', 'posts_per_page' => 50);
  3550.  
  3551. $myposts = get_posts( $args );
  3552. $i=0;
  3553. foreach ( $myposts as $post ) {
  3554. $i++;
  3555. $return_array[$i]['label'] = get_the_title($post->ID);
  3556. $return_array[$i]['value'] = $post->ID;
  3557. }
  3558.  
  3559. return $return_array;
  3560. }
  3561. }
  3562.  
  3563. if(!function_exists('et_show_block')) {
  3564. function et_show_block ($id) {
  3565. echo do_shortcode(get_post_field('post_content', $id));
  3566. }
  3567. }
  3568.  
  3569.  
  3570. if(!function_exists('et_get_block')) {
  3571. function et_get_block ($id) {
  3572. return do_shortcode(get_post_field('post_content', $id));
  3573. }
  3574. }
  3575.  
  3576.  
  3577. // **********************************************************************//
  3578. // ! Promo Popup
  3579. // **********************************************************************//
  3580. add_action('after_page_wrapper', 'et_promo_popup');
  3581. if(!function_exists('et_promo_popup')) {
  3582. function et_promo_popup() {
  3583. if(!etheme_get_option('promo_popup')) return;
  3584. $bg = etheme_get_option('pp_bg');
  3585. $padding = etheme_get_option('pp_padding');
  3586. ?>
  3587. <a class="etheme-popup " href="#etheme-popup">Open modal</a>
  3588.  
  3589. <div id="etheme-popup" class="white-popup-block mfp-hide">
  3590. <?php echo do_shortcode(etheme_get_option('pp_content')); ?>
  3591. <a class="popup-modal-dismiss" href="#"><i class="icon-remove"></i></a>
  3592. <p class="checkbox-label">
  3593. <input type="checkbox" value="do-not-show" name="showagain" id="showagain" class="showagain" />
  3594. <label for="showagain">Don't show this popup again</label>
  3595. </p>
  3596. </div>
  3597. <style type="text/css">
  3598. #etheme-popup {
  3599. width: <?php echo (etheme_get_option('pp_width') != '') ? etheme_get_option('pp_width') : 770 ; ?>px;
  3600. height: <?php echo (etheme_get_option('pp_height') != '') ? etheme_get_option('pp_height') : 350 ; ?>px;
  3601. <?php if(!empty($bg['background-color'])): ?> background-color: <?php echo $bg['background-color']; ?>;<?php endif; ?>
  3602. <?php if(!empty($bg['background-image'])): ?> background-image: url(<?php echo $bg['background-image']; ?>) ; <?php endif; ?>
  3603. <?php if(!empty($bg['background-attachment'])): ?> background-attachment: <?php echo $bg['background-attachment']; ?>;<?php endif; ?>
  3604. <?php if(!empty($bg['background-repeat'])): ?> background-repeat: <?php echo $bg['background-repeat']; ?>;<?php endif; ?>
  3605. <?php if(!empty($bg['background-color'])): ?> background-color: <?php echo $bg['background-color']; ?>;<?php endif; ?>
  3606. <?php if(!empty($bg['background-position'])): ?> background-position: <?php echo $bg['background-position']; ?>;<?php endif; ?>
  3607. }
  3608. </style>
  3609. <?php
  3610. }
  3611. }
  3612.  
  3613.  
  3614. // **********************************************************************//
  3615. // ! QR Code generation
  3616. // **********************************************************************//
  3617. if(!function_exists('generate_qr_code')) {
  3618. function generate_qr_code($text='QR Code', $title = 'QR Code', $size = 128, $class = '', $self_link = false, $lightbox = false ) {
  3619. if($self_link) {
  3620. global $wp;
  3621. $text = @$_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://';
  3622. if ( $_SERVER['SERVER_PORT'] != '80' )
  3623. $text .= $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'];
  3624. else
  3625. $text .= $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
  3626. }
  3627. $image = 'https://chart.googleapis.com/chart?chs=' . $size . 'x' . $size . '&cht=qr&chld=H|1&chl=' . $text;
  3628.  
  3629. if($lightbox) {
  3630. $class .= ' qr-lighbox';
  3631. $output = '<a href="'.$image.'" rel="lightbox" class="'.$class.'">'.$title.'</a>';
  3632. } else{
  3633. $class .= ' qr-image';
  3634. $output = '<img src="'.$image.'" class="'.$class.'" />';
  3635. }
  3636.  
  3637. return $output;
  3638. }
  3639. }
  3640.  
  3641.  
  3642. // **********************************************************************//
  3643. // ! Helper functions
  3644. // **********************************************************************//
  3645. if(!function_exists('pr')) {
  3646. function pr($arr) {
  3647. echo '<pre>';
  3648. print_r($arr);
  3649. echo '</pre>';
  3650. }
  3651. }
  3652.  
  3653. if(!function_exists('jsString')) {
  3654. function jsString($str='') {
  3655. return trim(preg_replace("/('|\"|\r?\n)/", '', $str));
  3656. }
  3657. }
  3658. if(!function_exists('hex2rgb')) {
  3659. function hex2rgb($hex) {
  3660. $hex = str_replace("#", "", $hex);
  3661.  
  3662. if(strlen($hex) == 3) {
  3663. $r = hexdec(substr($hex,0,1).substr($hex,0,1));
  3664. $g = hexdec(substr($hex,1,1).substr($hex,1,1));
  3665. $b = hexdec(substr($hex,2,1).substr($hex,2,1));
  3666. } else {
  3667. $r = hexdec(substr($hex,0,2));
  3668. $g = hexdec(substr($hex,2,2));
  3669. $b = hexdec(substr($hex,4,2));
  3670. }
  3671. $rgb = array($r, $g, $b);
  3672. //return implode(",", $rgb); // returns the rgb values separated by commas
  3673. return $rgb; // returns an array with the rgb values
  3674. }
  3675. }
  3676.  
  3677. if(!function_exists('trunc')) {
  3678. function trunc($phrase, $max_words) {
  3679. $phrase_array = explode(' ',$phrase);
  3680. if(count($phrase_array) > $max_words && $max_words > 0)
  3681. $phrase = implode(' ',array_slice($phrase_array, 0, $max_words)).' ...';
  3682. return $phrase;
  3683. }
  3684. }
  3685.  
  3686. if(!function_exists('et_get_icons')) {
  3687. function et_get_icons() {
  3688. $iconsArray = array("compass","collapse","collapse-top","expand","eur","euro","gbp","usd","dollar","inr","rupee","jpy","yen","cny","renminbi","krw","won","btc","bitcoin","file","file-text","sort-by-alphabet","sort-by-alphabet-alt","sort-by-attributes","sort-by-attributes-alt","sort-by-order","sort-by-order-alt","thumbs-up","thumbs-down","youtube-sign","youtube","xing","xing-sign","youtube-play","dropbox","stackexchange","instagram","flickr","adn","bitbucket","bitbucket-sign","tumblr","tumblr-sign","long-arrow-down","long-arrow-up","long-arrow-left","long-arrow-right","apple","windows","android","linux","dribbble","skype","foursquare","trello","female","male","gittip","sun","moon","archive","bug","vk","weibo","renren","adjust","anchor","archive","asterisk","ban-circle","bar-chart","barcode","beaker","beer","bell","bell-alt","bolt","book","bookmark","bookmark-empty","briefcase","bug","building","bullhorn","bullseye","calendar","calendar-empty","camera","camera-retro","certificate","check","check-empty","check-minus","check-sign","circle","circle-blank","cloud","cloud-download","cloud-upload","code","code-fork","coffee","cog","cogs","collapse","collapse-alt","collapse-top","comment","comment-alt","comments","comments-alt","compass","credit-card","crop","dashboard","desktop","download","download-alt","edit","edit-sign","ellipsis-horizontal","ellipsis-vertical","envelope","envelope-alt","eraser","exchange","exclamation","exclamation-sign","expand","expand-alt","external-link","external-link-sign","eye-close","eye-open","facetime-video","female","fighter-jet","film","filter","fire","fire-extinguisher","flag","flag-alt","flag-checkered","folder-close","folder-close-alt","folder-open","folder-open-alt","food","frown","gamepad","gear","gears","gift","glass","globe","group","hdd","headphones","heart","heart-empty","home","inbox","info","info-sign","key","keyboard","laptop","leaf","legal","lemon","level-down","level-up","lightbulb","location-arrow","lock","magic","magnet","mail-forward","mail-reply","mail-reply-all","male","map-marker","meh","microphone","microphone-off","minus","minus-sign","minus-sign-alt","mobile-phone","money","moon","move","music","off","ok","ok-circle","ok-sign","pencil","phone","phone-sign","picture","plane","plus","plus-sign","plus-sign-alt","power-off","print","pushpin","puzzle-piece","qrcode","question","question-sign","quote-left","quote-right","random","refresh","remove","remove-circle","remove-sign","reorder","reply","reply-all","resize-horizontal","resize-vertical","retweet","road","rocket","rss","rss-sign","screenshot","search","share","share-alt","share-sign","shield","shopping-cart","sign-blank","signal","signin","signout","sitemap","smile","sort","sort-by-alphabet","sort-by-alphabet-alt","sort-by-attributes","sort-by-attributes-alt","sort-by-order","sort-by-order-alt","sort-down","sort-up","spinner","star","star-empty","star-half","star-half-empty","star-half-full","subscript","suitcase","sun","superscript","tablet","tag","tags","tasks","terminal","thumbs-down","thumbs-down-alt","thumbs-up","thumbs-up-alt","ticket","time","tint","trash","trophy","truck","umbrella","unchecked","unlock","unlock-alt","upload","upload-alt","user","volume-down","volume-off","volume-up","warning-sign","wrench","zoom-in","zoom-out","bitcoin","btc","cny","dollar","eur","euro","gbp","inr","jpy","krw","renminbi","rupee","usd","won","yen","align-center","align-justify","align-left","align-right","bold","columns","copy","cut","eraser","file","file-alt","file-text","file-text-alt","font","indent-left","indent-right","italic","link","list","list-alt","list-ol","list-ul","paper-clip","paperclip","paste","repeat","rotate-left","rotate-right","save","strikethrough","table","text-height","text-width","th","th-large","th-list","underline","undo","unlink","angle-down","angle-left","angle-right","angle-up","arrow-down","arrow-left","arrow-right","arrow-up","caret-down","caret-left","caret-right","caret-up","chevron-down","chevron-left","chevron-right","chevron-sign-down","chevron-sign-left","chevron-sign-right","chevron-sign-up","chevron-up","circle-arrow-down","circle-arrow-left","circle-arrow-right","circle-arrow-up","double-angle-down","double-angle-left","double-angle-right","double-angle-up","hand-down","hand-left","hand-right","hand-up","long-arrow-down","long-arrow-left","long-arrow-right","long-arrow-up","backward","eject","fast-backward","fast-forward","forward","fullscreen","pause","play","play-circle","play-sign","resize-full","resize-small","step-backward","step-forward","stop","youtube-play","adn","android","apple","bitbucket","bitbucket-sign","bitcoin","btc","css3","dribbble","dropbox","facebook","facebook-sign","flickr","foursquare","github","github-alt","github-sign","gittip","google-plus","google-plus-sign","html5","instagram","linkedin","linkedin-sign","linux","maxcdn","pinterest","pinterest-sign","renren","skype","stackexchange","trello","tumblr","tumblr-sign","twitter","twitter-sign","vk","weibo","windows","xing","xing-sign","youtube","youtube-play","youtube-sign","ambulance","h-sign","hospital","medkit","plus-sign-alt","stethoscope","user-md");
  3689.  
  3690. return array_unique($iconsArray);
  3691.  
  3692. }
  3693. }
  3694.  
  3695.  
  3696.  
  3697. if(!function_exists('vc_icon_form_field')) {
  3698. function vc_icon_form_field($settings, $value) {
  3699. $settings_line = '';
  3700. $selected = '';
  3701. $array = et_get_icons();
  3702. if($value != '') {
  3703. $array = array_diff($array, array($value));
  3704. array_unshift($array,$value);
  3705. }
  3706.  
  3707. $settings_line .= '<div class="et-icon-selector">';
  3708. $settings_line .= '<input type="hidden" value="'.$value.'" name="'.$settings['param_name'].'" class="et-hidden-icon wpb_vc_param_value wpb-icon-select '.$settings['param_name'].' '.$settings['type'] . '">';
  3709. foreach ($array as $icon) {
  3710. if ($value == $icon) {
  3711. $selected = 'selected';
  3712. }
  3713. $settings_line .= '<span class="et-select-icon '.$selected.'" data-icon-name='.$icon.'><i class="icon-'.$icon.'"></i></span>';
  3714. $selected = '';
  3715. }
  3716.  
  3717. $settings_line .= '<script>';
  3718. $settings_line .= 'jQuery(".et-select-icon").click(function(){';
  3719. $settings_line .= 'var iconName = jQuery(this).data("icon-name");';
  3720. $settings_line .= 'console.log(iconName);';
  3721. $settings_line .= 'if(!jQuery(this).hasClass("selected")) {';
  3722. $settings_line .= 'jQuery(".et-select-icon").removeClass("selected");';
  3723. $settings_line .= 'jQuery(this).addClass("selected");';
  3724. $settings_line .= 'jQuery(this).parent().find(".et-hidden-icon").val(iconName);';
  3725. $settings_line .= '}';
  3726.  
  3727. $settings_line .= '});';
  3728. $settings_line .= '</script>';
  3729.  
  3730. $settings_line .= '</div>';
  3731. return $settings_line;
  3732. }
  3733. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement