Advertisement
baliniz

Fix Pinterest Share on Product Page

Feb 10th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 40.60 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. function jeg_get_loading_type ()
  5. {
  6.     $loadingpage = get_theme_mod('loader_general');
  7.  
  8.     // alter page id
  9.     global $post;
  10.     $pageid = ($post !== null) ? jeg_alter_woo_page_id(get_the_ID()) : null;
  11.  
  12.     // check if loader overrided
  13.     if(vp_metabox('jkreativ_general.override_loader', null, $pageid)) {
  14.         $loadingpage = vp_metabox('jkreativ_general.override_loader_group.0.page_loader', null, $pageid);
  15.     }
  16.  
  17.     return $loadingpage;
  18. }
  19.  
  20. function jeg_is_using_loading() {
  21.     if(jeg_get_loading_type() === 'none') {
  22.         return false;
  23.     } else {
  24.         return true;
  25.     }
  26. }
  27.  
  28. function jlog($var) {
  29.     echo '<pre>';
  30.     print_r($var);
  31.     echo '</pre>';
  32. }
  33.  
  34. function jeg_get_calling_method(){
  35.     $e = new Exception();
  36.     $trace = $e->getTrace();
  37.     //position 0 would be the line that called this function so we ignore it
  38.     $last_call = $trace[1];
  39.     echo "<pre>";
  40.     print_r($last_call);
  41.     echo "</pre>";
  42. }
  43.  
  44. function jeg_check_page_type()
  45. {
  46.     $type = array();
  47.  
  48.     if(is_home())           array_push($type, 'is_home');
  49.     if(is_front_page())     array_push($type, 'is_front_page');
  50.     if(is_404())            array_push($type, 'is_404');
  51.     if(is_search())         array_push($type, 'is_search');
  52.     if(is_date())           array_push($type, 'is_date');
  53.     if(is_author())         array_push($type, 'is_author');
  54.     if(is_category())       array_push($type, 'is_category');
  55.     if(is_tag())            array_push($type, 'is_tag');
  56.     if(is_tax())            array_push($type, 'is_tax');
  57.     if(is_archive())        array_push($type, 'is_archive');
  58.     if(is_single())         array_push($type, 'is_single');
  59.     if(is_attachment())     array_push($type, 'is_attachment');
  60.     if(is_page())           array_push($type, 'is_page');
  61.  
  62.     return implode(', ', $type);
  63. }
  64.  
  65.  
  66. /** woocommerce alter page id **/
  67. function jeg_alter_woo_page_id($pageid) {
  68.     if(function_exists('is_woocommerce')) {
  69.         if(is_shop()) {
  70.             return woocommerce_get_page_id('shop');
  71.         }
  72.     } else {
  73.         return $pageid;
  74.     }
  75. }
  76.  
  77. /***
  78.  * navigation setup
  79.  **/
  80.  
  81. function jeg_get_navigation_setup($pageid = null) {
  82.     $navobj = array();
  83.     $navobj['navpos'] = get_theme_mod('default_navigation', 'side');
  84.     $navobj['navcollapse'] = get_theme_mod('default_collapse_navigator', false);
  85.     $navobj['navtopmenu'] = get_theme_mod('default_menuheader_navigator', true);
  86.     $navobj['navtopcenter'] = get_theme_mod('centering_top_navigator', false);
  87.     $navobj['navtoptwoline'] = get_theme_mod('twoline_top_navigator', false);
  88.     $navobj['navtopsmaller'] = get_theme_mod('smaller_navigator', false);
  89.     $navobj['boxedcontent'] = get_theme_mod('boxed_content', false);
  90.  
  91.     if($navobj['navpos'] === 'transparent') {
  92.         $navobj['navtoptwoline'] = 0;
  93.         $navobj['navtopcenter'] = get_theme_mod('centering_top_navigator_transparent', false);
  94.         $navobj['navtopsmaller'] = get_theme_mod('smaller_navigator_transparent', false);
  95.         $navobj['boxedcontent'] = get_theme_mod('boxed_content_transparent', false);
  96.     }
  97.  
  98.     // alter page id
  99.     $pageid = jeg_alter_woo_page_id($pageid);
  100.  
  101.     // check if page setting overrided on single page
  102.     $pageid = ($pageid === null) ? JEG_PAGE_ID : $pageid ;
  103.     if(vp_metabox('jkreativ_general.override_navigation', null, $pageid)) {
  104.         $navobj['navpos'] = vp_metabox('jkreativ_general.override_navigation_group.0.navigation_position', 'side', $pageid);
  105.         $navobj['navcollapse'] = vp_metabox('jkreativ_general.override_navigation_group.0.default_collapse_navigator', false, $pageid);
  106.         $navobj['navtopmenu'] = vp_metabox('jkreativ_general.override_navigation_group.0.default_menuheader_navigator', true, $pageid);
  107.         $navobj['navtopcenter'] = vp_metabox('jkreativ_general.override_navigation_group.0.centering_top_navigator', false, $pageid);
  108.         $navobj['navtoptwoline'] = vp_metabox('jkreativ_general.override_navigation_group.0.twoline_top_navigator', false, $pageid);
  109.         $navobj['navtopsmaller'] = vp_metabox('jkreativ_general.override_navigation_group.0.smaller_navigator', false, $pageid);
  110.         $navobj['boxedcontent'] = vp_metabox('jkreativ_general.override_navigation_group.0.boxed_content', false, $pageid);
  111.  
  112.         if($navobj['navpos'] === 'transparent') {
  113.             $navobj['navtoptwoline'] = 0;
  114.             $navobj['navtopcenter'] = vp_metabox('jkreativ_general.override_navigation_group.0.centering_top_navigator_transparent', false, $pageid);
  115.             $navobj['navtopsmaller'] = vp_metabox('jkreativ_general.override_navigation_group.0.smaller_navigator_transparent', false, $pageid);
  116.             $navobj['boxedcontent'] = vp_metabox('jkreativ_general.override_navigation_group.0.boxed_content_transparent', false, $pageid);
  117.         }
  118.  
  119.     }
  120.  
  121.     return $navobj;
  122. }
  123.  
  124.  
  125. function jeg_get_additional_body_class ()
  126. {
  127.     $classstring = array();
  128.     $navobj = jeg_get_navigation_setup();
  129.  
  130.     if($navobj['navpos'] === 'top') {
  131.         array_push($classstring, "horizontalnav");
  132.  
  133.         if($navobj['navtoptwoline']) {
  134.             array_push($classstring, "topnavtwoline");
  135.         }
  136.  
  137.         if($navobj['navtopsmaller']) {
  138.             array_push($classstring, "topnavsmaller");
  139.         }
  140.  
  141.         if($navobj['boxedcontent']) {
  142.             array_push($classstring, "boxcontent");
  143.         }
  144.     } else  if($navobj['navpos'] === 'side') {
  145.         array_push($classstring, "sidenav");
  146.  
  147.         if($navobj['navcollapse']) {
  148.             array_push($classstring, "sidebarcollapse");
  149.         }
  150.         if(!$navobj['navtopmenu']) {
  151.             array_push($classstring, "noheadermenu");
  152.         }
  153.     } else if($navobj['navpos'] === 'transparent') {
  154.         array_push($classstring, "horizontalnav");
  155.         array_push($classstring, "toptransparent");
  156.  
  157.         if($navobj['navtopsmaller']) {
  158.             array_push($classstring, "topnavsmaller");
  159.         }
  160.  
  161.         if($navobj['boxedcontent']) {
  162.             array_push($classstring, "boxcontent");
  163.         }
  164.  
  165.         global $post;
  166.  
  167.         if($post !== null) {
  168.             $template = get_post_meta($post->ID,'_wp_page_template',true);
  169.  
  170.             if($template === 'template/template-fsslider-iosslider.php' || $template === 'template/template-fsslider-kenburn.php' || $template === 'template/template-fsslider-serviceslider.php' || $template === 'template/template-fsslider-media.php') {
  171.                 array_push($classstring, "fullscreenslider");
  172.             } else if($template === 'template/template-landing-page.php' || $template === 'template/template-landing-page-vc.php'){
  173.                 array_push($classstring, "landingtransparent");
  174.             } else {
  175.                 array_push($classstring, "normaltransparent");
  176.             }
  177.         } else {
  178.             array_push($classstring, "normaltransparent");
  179.         }
  180.     }
  181.  
  182.     global $post;
  183.     if(is_single()){
  184.         if($post->post_type === 'portfolio') {
  185.             $layout = get_post_meta($post->ID, 'portfolio_layout', true);
  186.             array_push($classstring , "portfolio-" . $layout);
  187.         } else {
  188.             $layout = vp_metabox('jkreativ_blog_template.template.0.single_blog_template', vp_option('joption.single_blog_template', 'normal'));
  189.             array_push($classstring , "blog-" . $layout);
  190.         }
  191.     }
  192.  
  193.  
  194.     // append landing page style
  195.     if(jeg_is_landing_template()) {
  196.         array_push($classstring , "landingpage");
  197.     }
  198.  
  199.     array_push($classstring , "jkreativ");
  200.  
  201.     return $classstring;
  202. }
  203.  
  204.  
  205. /**
  206.  * Detect retina device
  207.  */
  208. function jeg_is_retina_device()
  209. {
  210.     if(isset($_COOKIE["device_pixel_ratio"])) {
  211.         return $_COOKIE["device_pixel_ratio"] > 1;
  212.     } else {
  213.         return false;
  214.     }
  215. }
  216.  
  217.  
  218. /**
  219.  * social icon
  220.  */
  221. function jeg_populate_social () {
  222.     $socialarray = array();
  223.  
  224.     // facebook
  225.     if(vp_option('joption.social_facebook')) {
  226.         $socialarray[] = array(
  227.             'icon'  => 'fa fa-facebook',
  228.             'class' => 'social-facebook',
  229.             'url'   => vp_option('joption.social_facebook'),
  230.             'text'  => 'Facebook'
  231.         );
  232.     }
  233.  
  234.     // twitter
  235.     if(vp_option('joption.social_twitter')) {
  236.         $socialarray[] = array(
  237.             'icon'  => 'fa fa-twitter',
  238.             'class' => 'social-twitter',
  239.             'url'   => vp_option('joption.social_twitter'),
  240.             'text'  => 'Twitter'
  241.         );
  242.     }
  243.  
  244.     // linked in
  245.     if(vp_option('joption.social_linkedin')) {
  246.         $socialarray[] = array(
  247.             'icon'  => 'fa fa-linkedin',
  248.             'class' => 'social-linkedin',
  249.             'url'   => vp_option('joption.social_linkedin'),
  250.             'text'  => 'Linked In'
  251.         );
  252.     }
  253.  
  254.     // Google Plus
  255.     if(vp_option('joption.social_googleplus')) {
  256.         $socialarray[] = array(
  257.             'icon'  => 'fa fa-google-plus',
  258.             'class' => 'social-googleplus',
  259.             'url'   => vp_option('joption.social_googleplus'),
  260.             'text'  => 'Google Plus'
  261.         );
  262.     }
  263.  
  264.     // Pinterest
  265.     if(vp_option('joption.social_pinterest')) {
  266.         $socialarray[] = array(
  267.             'icon'  => 'fa fa-pinterest',
  268.             'class' => 'social-pinterest',
  269.             'url'   => vp_option('joption.social_pinterest'),
  270.             'text'  => 'Pinterest'
  271.         );
  272.     }
  273.  
  274.     // Github
  275.     if(vp_option('joption.social_github')) {
  276.         $socialarray[] = array(
  277.             'icon'  => 'fa fa-github',
  278.             'class' => 'social-github',
  279.             'url'   => vp_option('joption.social_github'),
  280.             'text'  => 'Github'
  281.         );
  282.     }
  283.  
  284.     // Flickr
  285.     if(vp_option('joption.social_flickr')) {
  286.         $socialarray[] = array(
  287.             'icon'  => 'fa fa-flickr',
  288.             'class' => 'social-flickr',
  289.             'url'   => vp_option('joption.social_flickr'),
  290.             'text'  => 'Flickr'
  291.         );
  292.     }
  293.  
  294.     // Tumblr
  295.     if(vp_option('joption.social_tumblr')) {
  296.         $socialarray[] = array(
  297.             'icon'  => 'fa fa-tumblr',
  298.             'class' => 'social-tumblr',
  299.             'url'   => vp_option('joption.social_tumblr'),
  300.             'text'  => 'Tumblr'
  301.         );
  302.     }
  303.  
  304.     // Dribbble
  305.     if(vp_option('joption.social_dribbble')) {
  306.         $socialarray[] = array(
  307.             'icon'  => 'fa fa-dribbble',
  308.             'class' => 'social-dribbble',
  309.             'url'   => vp_option('joption.social_dribbble'),
  310.             'text'  => 'Dribbble'
  311.         );
  312.     }
  313.  
  314.     // Soundcloud
  315.     if(vp_option('joption.social_soundcloud')) {
  316.         $socialarray[] = array(
  317.             'icon'  => 'fa fa-soundcloud',
  318.             'class' => 'social-soundcloud',
  319.             'url'   => vp_option('joption.social_soundcloud'),
  320.             'text'  => 'Soundcloud'
  321.         );
  322.     }
  323.  
  324.     // Behance
  325.     if(vp_option('joption.social_behance')) {
  326.         $socialarray[] = array(
  327.             'icon'  => 'fa fa-behance',
  328.             'class' => 'social-behance',
  329.             'url'   => vp_option('joption.social_behance'),
  330.             'text'  => 'Behance'
  331.         );
  332.     }
  333.  
  334.     // instagram
  335.     if(vp_option('joption.social_instagram')) {
  336.         $socialarray[] = array(
  337.             'icon'  => 'fa fa-instagram',
  338.             'class' => 'social-instagram',
  339.             'url'   => vp_option('joption.social_instagram'),
  340.             'text'  => 'Instagram'
  341.         );
  342.     }
  343.  
  344.     // Vimeo
  345.     if(vp_option('joption.social_vimeo')) {
  346.         $socialarray[] = array(
  347.             'icon'  => 'fa fa-vimeo-square',
  348.             'class' => 'social-vimeo',
  349.             'url'   => vp_option('joption.social_vimeo'),
  350.             'text'  => 'Vimeo'
  351.         );
  352.     }
  353.  
  354.     // Youtube
  355.     if(vp_option('joption.social_youtube')) {
  356.         $socialarray[] = array(
  357.             'icon'  => 'fa fa-youtube',
  358.             'class' => 'social-youtube',
  359.             'url'   => vp_option('joption.social_youtube'),
  360.             'text'  => 'youtube'
  361.         );
  362.     }
  363.  
  364.     // 500px
  365.     if(vp_option('joption.social_500px')) {
  366.         $socialarray[] = array(
  367.             'icon'  => 'icon-500px',
  368.             'class' => 'social-500px',
  369.             'url'   => vp_option('joption.social_500px'),
  370.             'text'  => '500px'
  371.         );
  372.     }
  373.  
  374.     // vk
  375.     if(vp_option('joption.social_vk')) {
  376.         $socialarray[] = array(
  377.             'icon'  => 'fa fa-vk',
  378.             'class' => 'social-vk',
  379.             'url'   => vp_option('joption.social_vk'),
  380.             'text'  => 'vk'
  381.         );
  382.     }
  383.  
  384.     return $socialarray;
  385. }
  386.  
  387. function jeg_social_icon($withtext)
  388. {
  389.     $html = "<ul>";
  390.  
  391.     $socialarray = jeg_populate_social();
  392.     foreach($socialarray as $soc) {
  393.         if($withtext) {
  394.             $html .= "<li><a target='_blank' href='" . $soc['url'] . "' class='" . $soc['class'] . "'><i class='" . $soc['icon'] . "'></i>" . $soc['text'] . "</a></li>";
  395.         } else {
  396.             $html .= "<li><a target='_blank' href='" . $soc['url'] . "' class='" . $soc['class'] . "'><i class='" . $soc['icon'] . "'></i></a></li>";
  397.         }
  398.  
  399.     }
  400.  
  401.     $html .= "</ul>";
  402.  
  403.     return $html;
  404. }
  405.  
  406.  
  407. /*** featured heading ***/
  408. if(!function_exists('jeg_get_featured_heading'))
  409. {
  410.     function jeg_get_featured_heading($postid, $w, $h)
  411.     {
  412.         $blogitemtype = vp_metabox('jkreativ_blog_format.format', null, $postid);
  413.         $featured = '';
  414.         switch ($blogitemtype) {
  415.             case 'standard':
  416.                 $imgfeatured = wp_get_attachment_image_src( get_post_thumbnail_id($postid), 'full');
  417.                 if(!empty($imgfeatured)) {
  418.                     $imgfeatured = jeg_image_resizer($imgfeatured[0], $w);
  419.                     $featured =
  420.                     "<a href='" . get_permalink($postid) . "'>
  421.                         <img src='" .  $imgfeatured . "' alt='" . get_the_title($postid) . "'>
  422.                     </a>";
  423.                 }
  424.                 break;
  425.             case 'imgslider':
  426.                 $imgarr = vp_metabox('jkreativ_blog_slider.binding_group');
  427.                 if(!empty($imgarr)) {
  428.                     $imghtml = '';
  429.                     foreach($imgarr as $img) {
  430.                         $imagecontent = jeg_get_image_attachment($img['image']);
  431.                         $imgfeatured = jeg_image_resizer($imagecontent, $w, $h);
  432.                         $imghtml .= "<img src='{$imgfeatured}' alt='{$img['image']}'/>";
  433.                     }
  434.  
  435.                     $featured=
  436.                     "<div class='article-slider-wrapper loading'>
  437.                         <div class='article-image-slider'>
  438.                             {$imghtml}
  439.                         </div>
  440.                     </div>";
  441.                 }
  442.                 break;
  443.             case 'vimeo':
  444.                 if(vp_metabox('jkreativ_blog_vimeo.vimeo_video_url')) {
  445.                     $featured =
  446.                     "<div data-type='vimeo' data-src='" . vp_metabox('jkreativ_blog_vimeo.vimeo_video_url') . "'>
  447.                         <div class='video-container'></div>
  448.                     </div>";
  449.                 }
  450.                 break;
  451.             case 'youtube':
  452.                 if(vp_metabox('jkreativ_blog_youtube.youtube_video_url')) {
  453.                     $featured =
  454.                     "<div data-type='youtube' data-src='" . vp_metabox('jkreativ_blog_youtube.youtube_video_url') . "'>
  455.                         <div class='video-container'></div>
  456.                     </div>";
  457.                 }
  458.                 break;
  459.             case 'soundcloud':
  460.                 if(vp_metabox('jkreativ_blog_soundcloud.soundcloud_url')) {
  461.                     $featured =
  462.                     "<div data-type='soundcloud' data-src='" . vp_metabox('jkreativ_blog_soundcloud.soundcloud_url') . "'>
  463.                         <div class='video-container'></div>
  464.                     </div>";
  465.                 }
  466.                 break;
  467.             case 'html5video':
  468.                 $featured =
  469.                 "<div data-type='html5video'
  470.                     data-mp4='"     . vp_metabox('jkreativ_blog_html5video.videomp4')   . "'
  471.                     data-webm='"    . vp_metabox('jkreativ_blog_html5video.videowebm')  . "'
  472.                     data-ogg='"     . vp_metabox('jkreativ_blog_html5video.videoogg') . "'
  473.                     data-cover='"   . jeg_get_image_attachment(vp_metabox('jkreativ_blog_html5video.cover')) . "'>
  474.                     <div class='video-container'></div>
  475.                 </div>";
  476.                 break;
  477.             case 'ads':
  478.                 break;
  479.         }
  480.  
  481.         return $featured;
  482.     }
  483. }
  484.  
  485. if(!function_exists('jeg_get_featured_masonry_heading'))
  486. {
  487.     function jeg_get_featured_masonry_heading($postid, $w, $h) {
  488.         $blogitemtype = vp_metabox('jkreativ_blog_format.format', null, $postid);
  489.         $featured = '';
  490.         switch ($blogitemtype) {
  491.             case 'standard':
  492.                 $imgfeatured = wp_get_attachment_image_src( get_post_thumbnail_id($postid), 'full');
  493.                 if(!empty($imgfeatured)) {
  494.                     $imgfeatured = jeg_image_resizer($imgfeatured[0], $w);
  495.                     $featured =
  496.                     "<a href='" . get_permalink($postid) . "'>
  497.                         <div class='article-image'>
  498.                             <img src='". $imgfeatured ."' alt='" . get_the_title($postid) . "'>
  499.                         </div>
  500.                     </a>";
  501.                 }
  502.                 break;
  503.             case 'imgslider':
  504.                 $imgarr = vp_metabox('jkreativ_blog_slider.binding_group');
  505.                 if(!empty($imgarr)) {
  506.                     $imghtml = '';
  507.                     foreach($imgarr as $img) {
  508.                         $imagecontent = jeg_get_image_attachment($img['image']);
  509.                         $imgfeatured = jeg_image_resizer($imagecontent, $w, $h);
  510.                         $imghtml .= "<img src='{$imgfeatured}' alt='{$img['image']}'/>";
  511.                     }
  512.  
  513.                     $featured=
  514.                     "<div class='article-fotorama'>
  515.                         <div class='article-image-slider'>
  516.                             {$imghtml}
  517.                         </div>
  518.                     </div>";
  519.                 }
  520.                 break;
  521.             case 'vimeo':
  522.                 if(vp_metabox('jkreativ_blog_vimeo.vimeo_video_url')) {
  523.                     $featured =
  524.                     "<div data-type='vimeo' data-src='" . vp_metabox('jkreativ_blog_vimeo.vimeo_video_url') . "'>
  525.                         <div class='video-container'></div>
  526.                     </div>";
  527.                 }
  528.                 break;
  529.             case 'youtube':
  530.                 if(vp_metabox('jkreativ_blog_youtube.youtube_video_url')) {
  531.                     $featured =
  532.                     "<div data-type='youtube' data-src='" . vp_metabox('jkreativ_blog_youtube.youtube_video_url') . "'>
  533.                         <div class='video-container'></div>
  534.                     </div>";
  535.                 }
  536.                 break;
  537.             case 'soundcloud':
  538.                 if(vp_metabox('jkreativ_blog_soundcloud.soundcloud_url')) {
  539.                     $featured =
  540.                     "<div data-type='soundcloud' data-src='" . vp_metabox('jkreativ_blog_soundcloud.soundcloud_url') . "'>
  541.                         <div class='video-container'></div>
  542.                     </div>";
  543.                 }
  544.                 break;
  545.             case 'html5video':
  546.                 $featured =
  547.                 "<div data-type='html5video'
  548.                     data-mp4='"     . vp_metabox('jkreativ_blog_html5video.videomp4')   . "'
  549.                     data-webm='"    . vp_metabox('jkreativ_blog_html5video.videowebm')  . "'
  550.                     data-ogg='"     . vp_metabox('jkreativ_blog_html5video.videoogg') . "'
  551.                     data-cover='"   . jeg_get_image_attachment(vp_metabox('jkreativ_blog_html5video.cover')) . "'>
  552.                     <div class='video-container'></div>
  553.                 </div>";
  554.                 break;
  555.             case 'ads':
  556.                 break;
  557.         }
  558.  
  559.         return $featured;
  560.  
  561.     }
  562. }
  563.  
  564.  
  565. // page featured heading
  566. if(!function_exists('jeg_get_page_featured_heading'))
  567. {
  568.     function jeg_get_page_featured_heading($w, $h)
  569.     {
  570.         $blogitemtype = vp_metabox('jkreativ_page_heading.heading_type');
  571.         $featured = '';
  572.         switch ($blogitemtype) {
  573.             case 'standard':
  574.                 if(vp_metabox('jkreativ_page_heading.standard.0.image')) {
  575.                     $imagecover = jeg_get_image_attachment(vp_metabox('jkreativ_page_heading.standard.0.image'));
  576.                     $imgfeatured = jeg_image_resizer($imagecover, $w);
  577.                     $featured =
  578.                     "<a href='" . get_permalink() . "'>
  579.                         <img src='" .  $imgfeatured . "' alt='" . vp_metabox('jkreativ_blog_standard.image_name') . "'>
  580.                     </a>";
  581.                 }
  582.                 break;
  583.             case 'imgslider':
  584.                 $imgarr = vp_metabox('jkreativ_page_heading.imageslider');
  585.                 if(!empty($imgarr)) {
  586.                     $imghtml = '';
  587.                     foreach($imgarr as $img) {
  588.                         $imagecover = jeg_get_image_attachment($img['image']);
  589.                         $imgfeatured = jeg_image_resizer($imagecover, $w, $h);
  590.                         $imghtml .= "<img src='{$imgfeatured}' alt='{$img['image']}'/>";
  591.                     }
  592.  
  593.                     $featured=
  594.                     "<div class='article-slider-wrapper loading'>
  595.                         <div class='article-image-slider'>
  596.                             {$imghtml}
  597.                         </div>
  598.                     </div>";
  599.                 }
  600.                 break;
  601.             case 'vimeo':
  602.                 if(vp_metabox('jkreativ_page_heading.vimeo.0.vimeo_video_url')) {
  603.                     $featured =
  604.                     "<div data-type='vimeo' data-src='" . vp_metabox('jkreativ_page_heading.vimeo.0.vimeo_video_url') . "'>
  605.                         <div class='video-container'></div>
  606.                     </div>";
  607.                 }
  608.                 break;
  609.             case 'youtube':
  610.                 if(vp_metabox('jkreativ_page_heading.youtube.0.youtube_video_url')) {
  611.                     $featured =
  612.                     "<div data-type='youtube' data-src='" . vp_metabox('jkreativ_page_heading.youtube.0.youtube_video_url') . "'>
  613.                         <div class='video-container'></div>
  614.                     </div>";
  615.                 }
  616.                 break;
  617.             case 'soundcloud':
  618.                 if(vp_metabox('jkreativ_page_heading.soundcloud.0.soundcloud_url')) {
  619.                     $featured =
  620.                     "<div data-type='soundcloud' data-src='" . vp_metabox('jkreativ_page_heading.soundcloud.0.soundcloud_url') . "'>
  621.                         <div class='video-container'></div>
  622.                     </div>";
  623.                 }
  624.                 break;
  625.             case 'html5video':
  626.                 $imagecover = jeg_get_image_attachment(vp_metabox('jkreativ_page_heading.html5video.0.cover'));
  627.                 $featured =
  628.                 "<div data-type='html5video'
  629.                     data-mp4='"     . vp_metabox('jkreativ_page_heading.html5video.0.videomp4') . "'
  630.                     data-webm='"    . vp_metabox('jkreativ_page_heading.html5video.0.videowebm') . "'
  631.                     data-ogg='"     . vp_metabox('jkreativ_page_heading.html5video.0.videoogg') . "'
  632.                     data-cover='"   . $imagecover . "'>
  633.                     <div class='video-container'></div>
  634.                 </div>";
  635.                 break;
  636.             case 'ads':
  637.                 break;
  638.         }
  639.  
  640.         return $featured;
  641.     }
  642. }
  643.  
  644.  
  645.  
  646. if(!function_exists('jeg_get_portfolio_featured_heading'))
  647. {
  648.     function jeg_get_portfolio_featured_heading($postid)
  649.     {
  650.         $portfolioitem = get_post_meta($postid, 'jkreativ_portfolio_gallery', true);
  651.         $featured = '';
  652.  
  653.         if(!empty($portfolioitem)) {
  654.             foreach($portfolioitem as $idx => $portfolio) {
  655.                 $portfoliotype = $portfolio['type'];
  656.                 $loadclass = ( $idx === 0 ) ? "loaded" : "notloaded";
  657.                 $mediacover = '';
  658.  
  659.                 if(isset($portfolio['mediacover'])) {
  660.                     $mediacover = jeg_get_image_attachment($portfolio['mediacover']);
  661.                     $mediacoversize = wp_get_attachment_image_src($portfolio['mediacover'], 'full');
  662.                 }
  663.  
  664.                 switch ($portfoliotype) {
  665.                     case 'image' :
  666.                         $image = wp_get_attachment_image_src($portfolio['imageid'], 'full');
  667.                         $thumb = jeg_image_resizer($image[0], 90, 90);
  668.  
  669.                         if($idx === 0) {
  670.                             $featured .=
  671.                             "<div class='portfolio-content-holder item' data-type='image' data-title='{$portfolio['imagename']}' data-thumb='{$thumb}'>
  672.                                 <img src='{$image[0]}' class='{$loadclass}' data-width='{$image[1]}' data-height='{$image[2]}'/>
  673.                             </div>";
  674.                         } else {
  675.                             $featured .=
  676.                             "<div class='portfolio-content-holder item' data-type='image' data-title='{$portfolio['imagename']}' data-thumb='{$thumb}'>
  677.                                 <img src='' data-src='{$image[0]}' class='{$loadclass}' data-width='{$image[1]}' data-height='{$image[2]}'/>
  678.                             </div>";
  679.                         }
  680.  
  681.                         break;
  682.                     case 'youtube' :
  683.                     case 'vimeo' :
  684.                         $thumb = jeg_image_resizer($mediacover, 90, 90);
  685.                         if($idx === 0) {
  686.                             $featured .=
  687.                             "<div class='portfolio-content-holder item' data-type='{$portfoliotype}' data-src='{$portfolio['mediaurl']}' data-title='{$portfolio['title']}' data-thumb='{$thumb}'>
  688.                                 <div class='portfoliovideo-wrapper'>
  689.                                     <img src='{$mediacover}' class='{$loadclass}' data-width='{$mediacoversize[1]}' data-height='{$mediacoversize[2]}'/>
  690.                                     <div class='videooverlay'></div>
  691.                                 </div>
  692.                                 <div class='portfoliovideo-container'><div class='video-container'></div></div>
  693.                             </div>";
  694.                         } else {
  695.                             $featured .=
  696.                             "<div class='portfolio-content-holder item' data-type='{$portfoliotype}' data-src='{$portfolio['mediaurl']}' data-title='{$portfolio['title']}' data-thumb='{$thumb}'>
  697.                                 <div class='portfoliovideo-wrapper'>
  698.                                     <img src='' data-src='{$mediacover}' class='{$loadclass}' data-width='{$mediacoversize[1]}' data-height='{$mediacoversize[2]}'/>
  699.                                     <div class='videooverlay'></div>
  700.                                 </div>
  701.                                 <div class='portfoliovideo-container'><div class='video-container'></div></div>
  702.                             </div>";
  703.                         }
  704.                         break;
  705.                     case 'html5video' :
  706.                         $thumb = jeg_image_resizer($mediacover, 90, 90);
  707.                         if($idx === 0) {
  708.                             $featured .=
  709.                             "<div class='portfolio-content-holder item' data-type='{$portfoliotype}' data-mp4='{$portfolio['videomp4']}' data-webm='{$portfolio['videowebm']}' data-ogg='{$portfolio['videoogg']}' data-title='{$portfolio['title']}' data-thumb='{$thumb}'>
  710.                                 <div class='portfoliovideo-wrapper'>
  711.                                     <img src='{$mediacover}' class='{$loadclass}' data-width='{$mediacoversize[1]}' data-height='{$mediacoversize[2]}'/>
  712.                                     <div class='videooverlay'></div>
  713.                                 </div>
  714.                                 <div class='portfoliovideo-container'><div class='html5-video-container'></div></div>
  715.                             </div>";
  716.                         } else {
  717.                             $featured .=
  718.                             "<div class='portfolio-content-holder item' data-type='{$portfoliotype}' data-cover='{$mediacover}' data-mp4='{$portfolio['videomp4']}' data-webm='{$portfolio['videowebm']}' data-ogg='{$portfolio['videoogg']}' data-title='{$portfolio['title']}' data-thumb='{$thumb}'>
  719.                                 <div class='portfoliovideo-wrapper'>
  720.                                     <img src='' data-src='{$mediacover}' class='{$loadclass}' data-width='{$mediacoversize[1]}' data-height='{$mediacoversize[2]}'/>
  721.                                     <div class='videooverlay'></div>
  722.                                 </div>
  723.                                 <div class='portfoliovideo-container'><div class='html5-video-container'></div></div>
  724.                             </div>";
  725.                         }
  726.                         break;
  727.                     case 'soundcloud' :
  728.                         $thumb = jeg_image_resizer($mediacover, 90, 90);
  729.                         $featured .=
  730.                         "<div class='portfolio-content-holder item' data-type='soundcloud' data-src='{$portfolio['mediaurl']}' data-title='{$portfolio['title']}' data-thumb='{$thumb}'>
  731.                             <div class='video-container'></div>
  732.                         </div>";
  733.                         break;
  734.                     default:
  735.                         break;
  736.                 }
  737.             }
  738.         }
  739.  
  740.         return $featured;
  741.     }
  742. }
  743.  
  744.  
  745.  
  746. /** next prev item **/
  747.  
  748. if ( ! function_exists( 'jeg_next_prev_portfolio' ) )
  749. {
  750.     function jeg_next_prev_portfolio($parentid, $currentid, $to, $category = '')
  751.     {
  752.         $portfolioquery = array(
  753.             'post_type' => 'portfolio',
  754.             'meta_query' => array(
  755.                array(
  756.                    'key' => 'portfolio_parent',
  757.                    'value' => array($parentid),
  758.                    'compare' => 'IN',
  759.                )
  760.             ),
  761.             'orderby' => 'menu_order',
  762.             'order' => 'ASC',
  763.             'nopaging' => true
  764.         );
  765.  
  766.  
  767.         if($category !== '') {
  768.             $portfolioquery['tax_query'] =
  769.             array(
  770.                 array(
  771.                     'taxonomy'  =>  'portfolio_category',
  772.                     'terms'     =>  $category,
  773.                     'field'     => 'id',
  774.                     'operator'  => 'IN'
  775.                 )
  776.             );
  777.         }
  778.  
  779.         $query = new WP_Query($portfolioquery);
  780.  
  781.         $result = $query->posts;
  782.         $currentpost = 0;
  783.  
  784.         foreach($result as $key => $res) {
  785.             if($currentid === $res->ID) {
  786.                 $currentpost = $key;
  787.                 break;
  788.             }
  789.         }
  790.  
  791.         if($to === 'next') {
  792.             $nextpost = $currentpost + 1;
  793.             if($nextpost >= sizeof($result)) {
  794.                 $nextpost = 0;
  795.             }
  796.  
  797.             $nextcontent = $result[$nextpost];
  798.             return $nextcontent->ID;
  799.         } else {
  800.             $prevpost = $currentpost - 1;
  801.             if($prevpost < 0) {
  802.                 $prevpost = sizeof($result) - 1;
  803.             }
  804.             $prevcontent = $result[$prevpost];
  805.             return $prevcontent->ID;
  806.         }
  807.     }
  808. }
  809.  
  810. /** next prev item **/
  811.  
  812.  
  813. /*** excerpt setup ***/
  814.  
  815. function jeg_excerpt_masonry_length () {
  816.     return 30;
  817. }
  818.  
  819. function jeg_excerpt_length( $length )
  820. {
  821.     return 50;
  822. }
  823.  
  824. if ( ! function_exists( 'jeg_continue_reading_link' ) )
  825. {
  826.     function jeg_continue_reading_link() {
  827.         return ' <a class="readmore" href="'. esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'jeg_textdomain' ) . '</a>';
  828.     }
  829. }
  830.  
  831. function jeg_auto_excerpt_more( $more ) {
  832.     return ' &hellip;' . jeg_continue_reading_link();
  833. }
  834.  
  835. function jeg_continue_reading_link() {
  836.     return ' <a class="readmore" href="'. esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'jeg_textdomain' ) . '</a>';
  837. }
  838.  
  839. function jeg_custom_excerpt_more( $output ) {
  840.     if ( has_excerpt() && ! is_attachment() ) {
  841.         $output .= jeg_continue_reading_link();
  842.     }
  843.     return $output;
  844. }
  845.  
  846. add_filter( 'excerpt_length', 'jeg_excerpt_length' );
  847. add_filter( 'excerpt_more', 'jeg_auto_excerpt_more' );
  848.  
  849.  
  850. /**
  851.  * Jeg Pagination
  852.  *
  853.  * @todo need to fix this functionality, on some number of page, its doesn't work as expected
  854.  **/
  855. function jlimitme ($type = "high", $point, $limit){
  856.     if($type == "high") {
  857.         return  ( $point > $limit ) ? $limit : $point;
  858.     } else {
  859.         return  ( $point > $limit ) ? $point : $limit;
  860.     }
  861. }
  862.  
  863. function jeg_posts_link_attributes() {
  864.     return 'class="btn"';
  865. }
  866.  
  867. function jeg_new_pagination($pageid, $curpage, $totalPage = 0, $step = 2)
  868. {
  869.     if($totalPage > 1) {
  870.         $pagingCount = ( $step * 2 ) + 1;
  871.  
  872.         $html = '<div class="pagedot">';
  873.  
  874.         if( $curpage > $step + 1 && $totalPage > $pagingCount ) {
  875.             $html .= "<a data-page='1' href='" . get_pagenum_link(1) . "'><span>&laquo</span></a>";
  876.         }
  877.         if( $curpage > 1 && $pagingCount < $totalPage ) {
  878.             $html .= get_previous_posts_link('<span>&lsaquo;</span>');
  879.         }
  880.  
  881.         /** loop page **/
  882.         for($i = jlimitme('low', $curpage - $step, 1) ; $i <= jlimitme('high', $totalPage , $curpage + $step) ; $i++){
  883.             if($i == $curpage) {
  884.                 $html .= '<span>'.$i.'</span>';
  885.             } else {
  886.                 $html .= "<a data-page='{$i}' href='" . get_pagenum_link($i) . "'><span>{$i}</span></a>";
  887.             }
  888.         }
  889.  
  890.         if( $curpage < $totalPage && $pagingCount < $totalPage ) {
  891.             $html .= get_next_posts_link('<span>&rsaquo;</span>');
  892.         }
  893.  
  894.         if( $curpage < $totalPage - 1 && $curpage + $step + 1 <= $totalPage && $pagingCount < $totalPage ) {
  895.             $html .= "<a data-page='{$totalPage}' href='" . get_pagenum_link($totalPage) . "'><span>&raquo;</span></a>";
  896.         }
  897.  
  898.         $html .= "</div>";
  899.  
  900.         $html .= "<div class='pagetext'>
  901.             <span class='pagenow'>" . __('Page','jeg_textdomain') . "  <strong class='curpage'>{$curpage}</strong></span>
  902.             <span class='pagetotal'>" . __('From','jeg_textdomain') . "  <strong class='totalpage'>{$totalPage}</strong></span>
  903.         </div>";
  904.  
  905.         return $html;
  906.     } else {
  907.         return ;
  908.     }
  909. }
  910.  
  911.  
  912.  
  913. /***
  914.  * Post View Count
  915.  */
  916.  function jeg_get_post_views($postID) {
  917.     $count_key = 'post_views_count';
  918.     $count = get_post_meta($postID, $count_key, true);
  919.     if($count==''){
  920.         delete_post_meta($postID, $count_key);
  921.         add_post_meta($postID, $count_key, '0');
  922.         return "0 View";
  923.     }
  924.     return $count.' Views';
  925. }
  926.  
  927. function jeg_set_post_views($postID) {
  928.     $count_key = 'post_views_count';
  929.     $count = get_post_meta($postID, $count_key, true);
  930.     if($count=='') {
  931.         $count = 0;
  932.         delete_post_meta($postID, $count_key);
  933.         add_post_meta($postID, $count_key, '0');
  934.     } else{
  935.         $count++;
  936.         update_post_meta($postID, $count_key, $count);
  937.     }
  938. }
  939.  
  940.  
  941. /** comment **/
  942. function jeg_get_wordpress_comment()
  943. {
  944.     $number = get_comments_number();
  945.  
  946.     if ( $number > 1 ) {
  947.         $output = str_replace('%', number_format_i18n($number), __('% Comments', 'jeg_textdomain'));
  948.     }
  949.     elseif ( $number == 0 ) {
  950.         $output = __('No Comments', 'jeg_textdomain');
  951.     }
  952.     else { // must be one
  953.         $output = __('1 Comment', 'jeg_textdomain');
  954.     }
  955.  
  956.     return $output;
  957. }
  958.  
  959.  
  960.  
  961. function jeg_comment($comment, $args, $depth) {
  962.     $GLOBALS['comment'] = $comment;
  963. ?>
  964. <li <?php comment_class(); ?>>
  965.     <div id="comment-<?php comment_ID(); ?>">
  966.         <div class="coment-box">
  967.             <div class="coment-box-inner">
  968.                 <div class="comment-autor">
  969.                     <?php echo get_avatar($comment,$size='80',$default='' ); ?>
  970.                 </div>
  971.  
  972.                 <div class="comment-meta">
  973.                     <ul>
  974.                         <li class="addby">
  975.                             <div class="authorcomment"><?php comment_author_link(); ?></div>
  976.                             <span data-comment-id="<?php comment_ID(); ?>" class="replycomment"><?php _e('Reply', 'jeg_textdomain'); ?></span>
  977.                             <span class="closecommentform"><?php _e('Cancel Reply', 'jeg_textdomain'); ?></span>
  978.                         </li>
  979.                         <li class="addtime"><?php echo get_comment_date('F j, Y'); ?></li>
  980.                     </ul>
  981.                 </div>
  982.  
  983.                 <div class="comment-text">
  984.                     <?php
  985.                     if($comment->comment_approved == '0') :
  986.                         echo "<em class=\"comment-moderation-text\">" . __("Your comment is awaiting moderation", "jeg_textdomain") . "</em>";
  987.                     endif;
  988.                     echo '<p>' . get_comment_text() . '</p>';
  989.                     ?>
  990.                 </div>
  991.                 <div style="clear: both;"></div>
  992.             </div>
  993.         </div>
  994.     </div>
  995. </li>
  996. <?php
  997. }
  998.  
  999.  
  1000. /** location builder **/
  1001.  
  1002. function jeg_location_block($idx, $location) {
  1003.     $html = '<div class="locationlist"><div data-index="'. $idx .'" class="mapitem">';
  1004.     if($location['title_leading'] !== '') {
  1005.         $html .= '<h4>' . $location['title_leading'] . ' : ' . $location['title'] . '</h4>';
  1006.     } else {
  1007.         $html .= '<h4>' . $location['title'] . '</h4>';
  1008.     }
  1009.     $html .= '<div class="mapdetail"><ul>';
  1010.  
  1011.     if($location['address'] !== '') {
  1012.         $html .= '<li><div class="detail">' . $location['address'] . '</div></li>';
  1013.     }
  1014.     if($location['address_second'] !== '') {
  1015.         $html .= '<li><div class="detail">' . $location['address_second'] . '</div></li>';
  1016.     }
  1017.     if($location['phone'] !== '') {
  1018.         $html .= '<li><div class="detail">' . $location['phone'] . '</div></li>';
  1019.     }
  1020.     if($location['email'] !== '') {
  1021.         $html .= '<li><div class="detail">' . $location['email'] . '</div></li>';
  1022.     }
  1023.     if($location['website'] !== '') {
  1024.         $html .= '<li><div class="detail"><a target="_blank" href="' . $location['website'] . '">' . $location['website'] . '</a></div></li>';
  1025.     }
  1026.  
  1027.     $html .= '</ul></div><div class="mapwrapper mapbutton"><span class="button-text">' . __('GET DIRECTION', 'jeg_textdomain') . '</span></div>';
  1028.     $html .= '</div></div>';
  1029.  
  1030.     return $html;
  1031. }
  1032.  
  1033.  
  1034. function jeg_info_window($idx, $location) {
  1035.     $html = '<div class="infowindow" data-lat="' . $location['x'] . '" data-lng="' . $location['y'] . '">';
  1036.     $html .= '<div class="infowindow-wrapper">';
  1037.     $html .= '<h4>' . $location['title'] . '</h4>';
  1038.     $html .= '<ul>';
  1039.  
  1040.     if($location['address'] !== '') {
  1041.         $html .= '<li><div class="detail">' . $location['address'] . '</div></li>';
  1042.     }
  1043.     if($location['address_second'] !== '') {
  1044.         $html .= '<li><div class="detail">' . $location['address_second'] . '</div></li>';
  1045.     }
  1046.     if($location['phone'] !== '') {
  1047.         $html .= '<li><div class="detail">' . $location['phone'] . '</div></li>';
  1048.     }
  1049.     if($location['email'] !== '') {
  1050.         $html .= '<li><div class="detail">' . $location['email'] . '</div></li>';
  1051.     }
  1052.     if($location['website'] !== '') {
  1053.         $html .= '<li><div class="detail">' . $location['website'] . '</div></li>';
  1054.     }
  1055.  
  1056.     $html .= '</ul></div><div class="closeme"></div></div>';
  1057.  
  1058.     return $html;
  1059. }
  1060.  
  1061.  
  1062. function jeg_get_all_portfolio_category ($pageid) {
  1063.     $category = array();
  1064.  
  1065.     $query = new WP_Query(array(
  1066.         'post_type' => 'portfolio',
  1067.         'meta_query' => array(
  1068.             array(
  1069.                 'key' => 'portfolio_parent',
  1070.                 'value' => array($pageid),
  1071.                 'compare' => 'IN',
  1072.             )
  1073.         ),
  1074.         'orderby' => 'menu_order',
  1075.         'order' => 'ASC',
  1076.         'nopaging' => true
  1077.     ));
  1078.  
  1079.     $result = $query->posts;
  1080.     foreach($result as $key => $value) {
  1081.         $termlist = get_the_terms($value->ID, JEG_PORTFOLIO_CATEGORY);
  1082.         if( !empty($termlist) ) {
  1083.             foreach($termlist as $termkey => $termvalue) {
  1084.                 $category[$termkey] = $termvalue->name;
  1085.             }
  1086.         }
  1087.     }
  1088.  
  1089.     return $category;
  1090. }
  1091.  
  1092.  
  1093. function jeg_to_slug($str)
  1094. {
  1095.     $replace    = '-';
  1096.     $trans = array(
  1097.         '&\#\d+?;'              => '',
  1098.         '&\S+?;'                => '',
  1099.         '\s+'                   => $replace,
  1100.         '[^a-z0-9\-\._]'        => '',
  1101.         $replace.'+'            => $replace,
  1102.         $replace.'$'            => $replace,
  1103.         '^'.$replace            => $replace,
  1104.         '\.+$'                  => ''
  1105.     );
  1106.  
  1107.     $str = strip_tags($str);
  1108.  
  1109.     foreach ($trans as $key => $val) :
  1110.         $str = preg_replace("#".$key."#i", $val, $str);
  1111.     endforeach;
  1112.  
  1113.     return trim(stripslashes(strtolower($str)));
  1114. }
  1115.  
  1116.  
  1117. /**** woo commerce ****/
  1118.  
  1119. function jeg_share_item() {
  1120.     $html = '';
  1121.     $postid = get_the_ID();
  1122.  
  1123.     $image = jeg_get_image_attachment( get_post_thumbnail_id(get_the_ID()), 'full' );
  1124.  
  1125.     $html =
  1126.     "<div class='normal-sharrre-container normal-post-sharrre'>
  1127.         <div class='twitter-share-block'
  1128.             data-url='" . get_permalink($postid) . "'
  1129.             data-text='" . get_the_title() . "'
  1130.             data-title='" . __('Tweet','jeg_textdomain') . "'></div>
  1131.         <div class='facebook-share-block'
  1132.             data-url='" . get_permalink($postid) . "'
  1133.             data-text='" . get_the_title() . "'
  1134.             data-title='" . __('Like','jeg_textdomain') . "'></div>
  1135.         <div class='googleplus-share-block'
  1136.             data-url='" . get_permalink($postid) . "'
  1137.             data-text='" . get_the_title() . "'
  1138.             data-title='" . __('Share','jeg_textdomain') . "'></div>
  1139.         <div class='pinterest-share-block'
  1140.             data-url='" . get_permalink($postid) . "'
  1141.             data-text='" . get_the_title() . "'
  1142.             data-image='" . $image . "'
  1143.             data-title='" . __('Pin','jeg_textdomain') . "'></div>
  1144.     </div>
  1145.     <div class='clearfix'></div>";
  1146.  
  1147.     echo $html;
  1148. }
  1149.  
  1150. add_filter('woocommerce_share', 'jeg_share_item');
  1151.  
  1152.  
  1153.  
  1154. if ( ! function_exists( 'jeg_woocommerce_content' ) )
  1155. {
  1156.     function jeg_woocommerce_content() {
  1157.         if ( is_singular( 'product' ) ) {
  1158.             while ( have_posts() ) {
  1159.                 the_post();
  1160.                 woocommerce_get_template_part( 'content', 'single-product' );
  1161.             }
  1162.         } else {
  1163.             if ( have_posts() ) {
  1164.                 woocommerce_get_template_part( 'content', 'shop' );
  1165.             } else {
  1166.                 woocommerce_get_template( 'loop/no-products-found.php' );
  1167.             }
  1168.         }
  1169.     }
  1170. }
  1171.  
  1172. if( ! function_exists('jeg_encodeURIComponent'))
  1173. {
  1174.     function jeg_encodeURIComponent($str) {
  1175.         $revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')');
  1176.         return strtr(rawurlencode($str), $revert);
  1177.     }
  1178. }
  1179.  
  1180.  
  1181.  
  1182. if( ! function_exists('jeg_get_query_paged')) {
  1183.     function jeg_get_query_paged () {
  1184.         $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
  1185.         $page = ( get_query_var('page') ) ? get_query_var('page') : 1;
  1186.         return ( $paged > $page ) ? $paged : $page;
  1187.     }
  1188. }
  1189.  
  1190.  
  1191. function jeg_get_google_font() {
  1192.     $font = vp_get_gwf_family();
  1193.     $fontlist = array();
  1194.     $fontlist[] = '';
  1195.     foreach($font as $fl){
  1196.         $fontlist[$fl['value']] = $fl['label'];
  1197.     }
  1198.     return $fontlist;
  1199. }
  1200.  
  1201. function jeg_hext_rgb($hex){
  1202.     return sscanf($hex, "#%02x%02x%02x");
  1203. }
  1204.  
  1205. function jeg_get_gallery_product_data($postid)
  1206. {
  1207.     $data = array();
  1208.  
  1209.     $data['overwrite_gallery']  = vp_metabox('jkreativ_product.overwrite_gallery', null, $postid);
  1210.     $data['gallery_layout']     = 'normal';
  1211.     $data['product_width']      = 400;
  1212.     $data['product_height']     = 1;
  1213.     $data['justified_height']   = 250;
  1214.     $data['user_margin']        = 1;
  1215.     $data['margin_size']        = 5;
  1216.     $data['expand_script']      = 'magnific';
  1217.     $data['scale_mode']         = 'fit';
  1218.  
  1219.     if($data['overwrite_gallery']) {
  1220.         $data['product_fullwidth'] = vp_metabox('jkreativ_product.gallery.0.single_product_fullwidth', null, $postid);
  1221.         if($data['product_fullwidth']) {
  1222.             $data['gallery_layout']     = vp_metabox('jkreativ_product.gallery.0.grid_gallery.0.product_single_type', 'normal', $postid);
  1223.             $data['product_width']      = vp_metabox('jkreativ_product.gallery.0.grid_gallery.0.single_product_width', 400, $postid);
  1224.             $data['product_height']     = vp_metabox('jkreativ_product.gallery.0.grid_gallery.0.single_item_height', 1, $postid);
  1225.             $data['justified_height']   = vp_metabox('jkreativ_product.gallery.0.grid_gallery.0.single_justified_height', 1, $postid);
  1226.             $data['user_margin']        = vp_metabox('jkreativ_product.gallery.0.grid_gallery.0.single_product_use_margin', 1, $postid);
  1227.             $data['margin_size']        = vp_metabox('jkreativ_product.gallery.0.grid_gallery.0.single_product_margin_size', 5, $postid);
  1228.             $data['expand_script']      = vp_metabox('jkreativ_product.gallery.0.grid_gallery.0.single_expand_mode', 'magnific', $postid);
  1229.             $data['scale_mode']         = vp_metabox('jkreativ_product.gallery.0.grid_gallery.0.single_scale_mode', 'fit', $postid);
  1230.         }
  1231.     } else {
  1232.         $data['product_fullwidth'] = vp_option('joption.single_product_fullwidth');
  1233.         if($data['product_fullwidth']) {
  1234.             $data['gallery_layout']     = vp_option('joption.product_single_type', 'normal', $postid);
  1235.             $data['product_width']      = vp_option('joption.single_product_width', 400);
  1236.             $data['product_height']     = vp_option('joption.single_item_height', 1);
  1237.             $data['justified_height']   = vp_option('joption.single_justified_height', 250);
  1238.             $data['user_margin']        = vp_option('joption.single_product_use_margin', 1);
  1239.             $data['margin_size']        = vp_option('joption.single_product_margin_size', 5);
  1240.             $data['expand_script']      = vp_option('joption.single_expand_mode', 'magnific');
  1241.             $data['scale_mode']         = vp_option('joption.single_scale_mode', 'fit');
  1242.         }
  1243.     }
  1244.  
  1245.     return $data;
  1246. }
  1247.  
  1248.  
  1249. function jeg_get_image_attachment($imageid)
  1250. {
  1251.     $imagedata = wp_get_attachment_image_src($imageid, "full");
  1252.     return $imagedata[0];
  1253. }
  1254.  
  1255.  
  1256. /**
  1257.  * Jkreativ cache method
  1258.  * use template base caching
  1259.  */
  1260.  
  1261. class Jeg_Fragment_Cache {
  1262.     var $key;
  1263.     var $ttl;
  1264.  
  1265.     public function __construct( $key, $ttl ) {
  1266.         $this->key = $key;
  1267.         $this->ttl = $ttl;
  1268.     }
  1269.  
  1270.     public function output()
  1271.     {
  1272.         $output = get_transient( $this->key );
  1273.         if ( !empty( $output ) ) {
  1274.             echo $output;
  1275.             return true;
  1276.         } else {
  1277.             ob_start();
  1278.             return false;
  1279.         }
  1280.     }
  1281.  
  1282.     public function store()
  1283.     {
  1284.         $output = ob_get_flush();
  1285.         set_transient( $this->key, $output, $this->ttl );
  1286.     }
  1287. }
  1288.  
  1289. function jeg_is_in_cache_list($slug, $name) {
  1290.     return apply_filters('jeg_check_in_cache_list', false, $slug, $name);
  1291. }
  1292.  
  1293. function jeg_get_template_part($slug, $name = null)
  1294. {
  1295.     if(jeg_is_in_cache_list($slug, $name)) {
  1296.         if(!is_null($name)) {
  1297.             $slug = $slug . '-' . $name;
  1298.         }
  1299.         $frag = new Jeg_Fragment_Cache( $slug, 60*60*24*7 );
  1300.         if ( !$frag->output() ) {
  1301.             get_template_part($slug, $name);
  1302.             $frag->store();
  1303.         }
  1304.     } else {
  1305.         get_template_part($slug, $name);
  1306.     }
  1307. }
  1308.  
  1309. function jeg_get_slider_id() {
  1310.     global $post;
  1311.     if($post->post_type === 'portfolio') {
  1312.         $layout = get_post_meta($post->ID, 'portfolio_layout', true);
  1313.  
  1314.         if($layout === 'landingpage') {
  1315.             $sliderid = vp_metabox('jkreativ_portfolio_landing.heading_slider');
  1316.         } else if($layout === 'landingpagevc') {
  1317.             $sliderid = vp_metabox('jkreativ_portfolio_landing_vc.heading_slider');
  1318.         }
  1319.  
  1320.     } else {
  1321.         $template = get_post_meta($post->ID,'_wp_page_template',true);
  1322.         if($template === "template/template-landing-page.php") {
  1323.             $sliderid = vp_metabox('jkreativ_page_landing.heading_slider');
  1324.         } else if($template === "template/template-landing-page-vc.php") {
  1325.             $sliderid = vp_metabox('jkreativ_page_landing_vc.heading_slider');
  1326.         }
  1327.     }
  1328.     return $sliderid;
  1329. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement