Advertisement
jegtheme

admin-functionality.php

Jul 14th, 2014
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 15.99 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * @author : jegbagus
  5.  */
  6.  
  7. if(!function_exists('jeg_print_block_size')) {
  8.     function jeg_print_block_size() {
  9.         return
  10.         "<div class='portfolioinputtitle'>Thumb Width :</div>
  11.         <select class='width'>
  12.             <option value='0.25'>1/4x width</option>
  13.             <option value='0.5'>1/2x width</option>
  14.             <option selected='selected' value='1'>1x width</option>
  15.             <option value='2'>2x width</option>
  16.             <option value='3'>3x width</option>
  17.         </select>
  18.         <span class='portfoliodesc'>On fullwidth layout, justified gallery, single ajax portfolio or cover portfolio, this option will be ignored</span>
  19.        
  20.         <div class='portfolioinputtitle'>Thumb Height :</div>
  21.         <select class='height'>
  22.             <option value='0.25'>1/4x height</option>
  23.             <option value='0.5'>1/2x height</option>
  24.             <option selected='selected' value='1'>1x height</option>
  25.             <option value='2'>2x height</option>
  26.             <option value='3'>3x height</option>
  27.         </select>
  28.         <span class='portfoliodesc'>On fullwidth layout, justified gallery, single ajax portfolio or cover portfolio, this option will be ignored</span>";
  29.     };
  30. }
  31.  
  32. if(!function_exists('jeg_check_block_size'))
  33. {
  34.     function jeg_check_block_size($blocksize, $compare) {
  35.         if($blocksize == $compare) {
  36.             return "selected=selected";
  37.         }
  38.     }
  39. }
  40.  
  41. if(!function_exists('jeg_build_width_option'))
  42. {
  43.     function jeg_build_width_option($mbid, $seq, $width, $height) {
  44.         return
  45.         "<div class='postoption widthsize'>
  46.             <h4>Thumb Width</h4>
  47.             <select name='{$mbid}[$seq][width]' class='replaceindex'>
  48.                 <option value='0.25' "  . jeg_check_block_size($width, "0.25") . ">1/4x width</option>
  49.                 <option value='0.5'  "  . jeg_check_block_size($width, "0.5") . ">1/2x width</option>
  50.                 <option value='1'    "  . jeg_check_block_size($width, "1") . ">1x width</option>
  51.                 <option value='2'    "  . jeg_check_block_size($width, "2") . ">2x width</option>
  52.                 <option value='3'    "  . jeg_check_block_size($width, "3") . ">3x width</option>
  53.             </select>
  54.             <span>On fullwidth layout, justified gallery, single ajax portfolio or cover portfolio, this option will be ignored</span>
  55.         </div>
  56.         <div class='postoption heightsize'>
  57.             <h4>Thumb Height</h4>
  58.             <select name='{$mbid}[$seq][height]' class='replaceindex'>
  59.                 <option value='0.25' "  . jeg_check_block_size($height, "0.25") . ">1/4x height</option>
  60.                 <option value='0.5'  "  . jeg_check_block_size($height, "0.5") . ">1/2x height</option>
  61.                 <option value='1'    "  . jeg_check_block_size($height, "1") . ">1x height</option>
  62.                 <option value='2'    "  . jeg_check_block_size($height, "2") . ">2x height</option>
  63.                 <option value='3'    "  . jeg_check_block_size($height, "3") . ">3x height</option>
  64.             </select>
  65.             <span>On fullwidth layout, justified gallery, single ajax portfolio or cover portfolio, this option will be ignored</span>
  66.         </div>";
  67.     }
  68. }
  69.  
  70. if(!function_exists('jeg_media_image_template'))
  71. {
  72.     function jeg_media_image_template($mbid, $seq = 0, $value = null, $option = null)
  73.     {
  74.  
  75.         if($value !== 'null') {
  76.             $imageid = isset($value['imageid']) ? $value['imageid'] : '';
  77.             $thumbimage = wp_get_attachment_image_src($value['imageid'], 'thumbnail');
  78.             $thumbimage = $thumbimage[0];
  79.             $imagetitle = isset($value['imagename']) ? $value['imagename'] : '';
  80.             $thumbwidth = isset($value['width']) ? $value['width'] : 1;
  81.             $thumbheight = isset($value['height']) ? $value['height'] : 1;
  82.         }
  83.        
  84.         $sizeblock = '';
  85.         if(!$option['nowidth']) {
  86.             $sizeblock = jeg_build_width_option($mbid, $seq, $thumbwidth, $thumbheight);
  87.         }
  88.  
  89.         return
  90.         "<div class='imageresult-list' data-result='image' data-index='{$seq}'>
  91.             <div class='imageresult-header'>
  92.                 <img class='imageresult-header-thumb' src='{$thumbimage}'/>
  93.                 <a class='imageresult-header-toogle' href='#'>detail</a>
  94.                 <a class='imageresult-header-delete' href='#'>delete</a>
  95.                 <div class='imageresult-header-title'>{$imagetitle}</div>
  96.             </div>
  97.             <div class='imageresult-body'>
  98.                 <table>
  99.                     <tr>
  100.                         <td><img class='imageresult-body-thumb' src='{$thumbimage}'/></td>
  101.                         <td class='imgresult-body-desc'>
  102.                             <input name='{$mbid}[$seq][imageid]' class='replaceindex image-index' type='hidden' value='{$imageid}'>
  103.                             <input name='{$mbid}[$seq][type]' class='replaceindex' type='hidden' value='image'>
  104.                             <h4>Image Title</h4>
  105.                             <input name='{$mbid}[$seq][imagename]' class='replaceindex showonlist image-title' type='text' value='{$imagetitle}'>
  106.                             {$sizeblock}
  107.                         </td>
  108.                     </tr>
  109.                 </table>
  110.             </div>
  111.         </div>";
  112.     }
  113. }
  114.  
  115.  
  116. if(!function_exists('jeg_media_youtube_template'))
  117. {
  118.     function jeg_media_youtube_template($mbid, $seq, $value, $option)
  119.     {
  120.         if($value !== 'null') {
  121.             $mediaurl = isset($value['mediaurl']) ? $value['mediaurl'] : '';
  122.             $mediacover = isset($value['mediacover']) ? $value['mediacover'] : '';
  123.             $mediatitle = isset($value['title']) ? $value['title'] : '';
  124.             $thumbwidth = isset($value['width']) ? $value['width'] : 1;
  125.             $thumbheight = isset($value['height']) ? $value['height'] : 1;
  126.         }
  127.        
  128.         $sizeblock = '';
  129.         if(!$option['nowidth']) {
  130.             $sizeblock = jeg_build_width_option($mbid, $seq, $thumbwidth, $thumbheight);
  131.         }
  132.  
  133.         if($option['videocover']) {
  134.             $mediaposter    = wp_get_attachment_image_src($mediacover, "thumbnail");
  135.             $videocover     =
  136.             "<tr>
  137.                 <td class='imgresult-body-desc uploadfile'>
  138.                     <h4>Image Cover</h4>
  139.                     <div class='jimg'>
  140.                         <img src='{$mediaposter[0]}'>
  141.                     </div>
  142.                     <input type='hidden' name='{$mbid}[$seq][mediacover]' class='videocover uploadtext replaceindex' value='{$mediacover}' />
  143.                     <div class='buttons'>
  144.                         <input type='button' value='Select Image' class='selectfileimage btn'/>
  145.                         <input type='button' value='x' class='removefile btn'/>
  146.                     </div>
  147.                 </td>
  148.             </tr>";
  149.         }
  150.  
  151.         return "
  152.         <div class='imageresult-list videoresult' data-result='youtube' data-index='{$seq}'>
  153.             <div class='imageresult-header'>
  154.                 <div class='imageresult-header-thumb portfolioyoutube'></div>
  155.                 <a class='imageresult-header-toogle' href='#'>detail</a>
  156.                 <a class='imageresult-header-delete' href='#'>delete</a>
  157.                 <div class='imageresult-header-title'>{$mediaurl}</div>
  158.             </div>
  159.             <div class='imageresult-body'>
  160.                 <table>
  161.                     <tr>
  162.                         <td class='imgresult-body-desc'>
  163.                             <h4>Youtube URL</h4>
  164.                             <input name='{$mbid}[$seq][type]' class='replaceindex' type='hidden' value='youtube'>
  165.                             <input name='{$mbid}[$seq][mediaurl]' class='replaceindex showonlist youtube-url' type='text' value='{$mediaurl}'>
  166.                         </td>
  167.                     </tr>
  168.                     <tr>
  169.                         <td class='imgresult-body-desc'>
  170.                             <h4>Youtube Title</h4>
  171.                             <input name='{$mbid}[$seq][title]' class='replaceindex videotitle' type='text' value='{$mediatitle}'>
  172.                         </td>
  173.                     </tr>
  174.                     {$videocover}
  175.                     <tr>
  176.                         <td class='imgresult-body-desc'>
  177.                             {$sizeblock}
  178.                         </td>
  179.                     </tr>
  180.                 </table>
  181.             </div>
  182.         </div>
  183.         ";
  184.     }
  185. }
  186.  
  187.  
  188. if(!function_exists('jeg_media_vimeo_template'))
  189. {
  190.     function jeg_media_vimeo_template($mbid, $seq, $value, $option)
  191.     {
  192.         if($value !== 'null') {
  193.             $mediaurl = $value['mediaurl'];
  194.             $mediacover = $value['mediacover'];        
  195.             $mediatitle = $value['title'];
  196.             $thumbwidth = isset($value['width']) ? $value['width'] : 1;
  197.             $thumbheight = isset($value['height']) ? $value['height'] : 1;
  198.         }
  199.  
  200.         if(!$option['nowidth']) {
  201.             $sizeblock = jeg_build_width_option($mbid, $seq, $thumbwidth, $thumbheight);
  202.         }
  203.        
  204.         if($option['videocover']) {
  205.             $mediaposter    = wp_get_attachment_image_src($mediacover, "thumbnail");
  206.             $videocover     =
  207.             "<tr>
  208.                 <td class='imgresult-body-desc uploadfile'>
  209.                     <h4>Image Cover</h4>
  210.                     <div class='jimg'>
  211.                         <img src='{$mediaposter[0]}'>
  212.                     </div>
  213.                     <input type='hidden' name='{$mbid}[$seq][mediacover]' class='videocover uploadtext replaceindex' value='{$mediacover}' />
  214.                     <div class='buttons'>
  215.                         <input type='button' value='Select Image' class='selectfileimage btn'/>
  216.                         <input type='button' value='x' class='removefile btn'/>
  217.                     </div>
  218.                 </td>
  219.             </tr>";
  220.         }
  221.  
  222.         return "
  223.         <div class='imageresult-list videoresult' data-result='vimeo' data-index='{$seq}'>
  224.             <div class='imageresult-header'>
  225.                 <div class='imageresult-header-thumb portfoliovimeo'></div>
  226.                 <a class='imageresult-header-toogle' href='#'>detail</a>
  227.                 <a class='imageresult-header-delete' href='#'>delete</a>
  228.                 <div class='imageresult-header-title'>{$mediaurl}</div>
  229.             </div>
  230.             <div class='imageresult-body'>
  231.                 <table>
  232.                     <tr>
  233.                         <td class='imgresult-body-desc'>
  234.                             <h4>Vimeo URL</h4>
  235.                             <input name='{$mbid}[$seq][type]' class='replaceindex' type='hidden' value='vimeo'>
  236.                             <input name='{$mbid}[$seq][mediaurl]' class='replaceindex showonlist vimeo-url' type='text' value='{$mediaurl}'>
  237.                         </td>
  238.                     </tr>
  239.                     <tr>
  240.                         <td class='imgresult-body-desc'>
  241.                             <h4>Vimeo Title</h4>
  242.                             <input name='{$mbid}[$seq][title]' class='replaceindex videotitle' type='text' value='{$mediatitle}'>
  243.                         </td>
  244.                     </tr>
  245.                     {$videocover}
  246.                     <tr>
  247.                         <td class='imgresult-body-desc'>
  248.                             {$sizeblock}
  249.                         </td>
  250.                     </tr>
  251.                 </table>
  252.             </div>
  253.         </div>
  254.         ";
  255.     }
  256. }
  257.  
  258.  
  259.  
  260. if(!function_exists('jeg_media_soundcloud_template'))
  261. {
  262.     function jeg_media_soundcloud_template($mbid, $seq, $value, $option)
  263.     {
  264.         if($value !== 'null') {
  265.             $mediaurl = $value['mediaurl'];
  266.             $mediacover = $value['mediacover'];
  267.             $mediatitle = $value['title'];
  268.             $thumbwidth = isset($value['width']) ? $value['width'] : 1;
  269.             $thumbheight = isset($value['height']) ? $value['height'] : 1;
  270.         }
  271.  
  272.         if(!$option['nowidth']) {
  273.             $sizeblock = jeg_build_width_option($mbid, $seq, $thumbwidth, $thumbheight);
  274.         }
  275.  
  276.         if($option['videocover']) {
  277.             $mediaposter    = wp_get_attachment_image_src($mediacover, "thumbnail");
  278.             $videocover     =
  279.             "<tr>
  280.                 <td class='imgresult-body-desc uploadfile'>
  281.                     <h4>Image Cover</h4>
  282.                     <div class='jimg'>
  283.                         <img src='{$mediaposter[0]}'>
  284.                     </div>
  285.                     <input type='hidden' name='{$mbid}[$seq][mediacover]' class='videocover uploadtext replaceindex' value='{$mediacover}' />
  286.                     <div class='buttons'>
  287.                         <input type='button' value='Select Image' class='selectfileimage btn'/>
  288.                         <input type='button' value='x' class='removefile btn'/>
  289.                     </div>
  290.                 </td>
  291.             </tr>";
  292.         }
  293.  
  294.         return "
  295.         <div class='imageresult-list videoresult' data-result='soundcloud' data-index='{$seq}'>
  296.             <div class='imageresult-header'>
  297.                 <div class='imageresult-header-thumb portfoliosoundcloud'></div>
  298.                 <a class='imageresult-header-toogle' href='#'>detail</a>
  299.                 <a class='imageresult-header-delete' href='#'>delete</a>
  300.                 <div class='imageresult-header-title'>{$mediaurl}</div>
  301.             </div>
  302.             <div class='imageresult-body'>
  303.                 <table>
  304.                     <tr>
  305.                         <td class='imgresult-body-desc'>
  306.                             <h4>Soundcloud URL</h4>
  307.                             <input name='{$mbid}[$seq][type]' class='replaceindex' type='hidden' value='soundcloud'>
  308.                             <input name='{$mbid}[$seq][mediaurl]' class='replaceindex showonlist soundcloud-url' type='text' value='{$mediaurl}'>
  309.                         </td>
  310.                     </tr>
  311.                     <tr>
  312.                         <td class='imgresult-body-desc'>
  313.                             <h4>Soundcloud Title</h4>
  314.                             <input name='{$mbid}[$seq][title]' class='replaceindex videotitle' type='text' value='{$mediatitle}'>
  315.                         </td>
  316.                     </tr>
  317.                     {$videocover}
  318.                     <tr>
  319.                         <td class='imgresult-body-desc'>
  320.                             {$sizeblock}
  321.                         </td>
  322.                     </tr>
  323.                 </table>
  324.             </div>
  325.         </div>
  326.         ";
  327.     }
  328. }
  329.  
  330.  
  331. if(!function_exists('jeg_media_html5video_template'))
  332. {
  333.     function jeg_media_html5video_template($mbid, $seq, $value, $option)
  334.     {
  335.         if($value !== 'null') {
  336.             $mediatitle = $value['title'];
  337.             $mediacover = $value['mediacover'];
  338.             $thumbwidth = isset($value['width']) ? $value['width'] : 1;
  339.             $thumbheight = isset($value['height']) ? $value['height'] : 1;
  340.  
  341.             $mp4 = $value['videomp4'];
  342.             $webm = $value['videowebm'];
  343.             $ogg = $value['videoogg'];
  344.         }
  345.  
  346.         if(!$option['nowidth']) {
  347.             $sizeblock = jeg_build_width_option($mbid, $seq, $thumbwidth, $thumbheight);
  348.         }
  349.  
  350.         if($option['videocover']) {
  351.             $mediaposter    = wp_get_attachment_image_src($mediacover, "thumbnail");
  352.             $videocover     =
  353.             "<tr>
  354.                 <td class='imgresult-body-desc uploadfile'>
  355.                     <h4>Image Cover</h4>
  356.                     <div class='jimg'>
  357.                         <img src='{$mediaposter[0]}'>
  358.                     </div>
  359.                     <input type='hidden' name='{$mbid}[$seq][mediacover]' class='videocover uploadtext replaceindex' value='{$mediacover}' />
  360.                     <div class='buttons'>
  361.                         <input type='button' value='Select Image' class='selectfileimage btn'/>
  362.                         <input type='button' value='x' class='removefile btn'/>
  363.                     </div>
  364.                 </td>
  365.             </tr>";
  366.         }
  367.  
  368.         return "
  369.         <div class='imageresult-list videoresult' data-result='html5video' data-index='{$seq}'>
  370.             <div class='imageresult-header'>
  371.                 <div class='imageresult-header-thumb portfoliohtml5video'></div>
  372.                 <a class='imageresult-header-toogle' href='#'>detail</a>
  373.                 <a class='imageresult-header-delete' href='#'>delete</a>
  374.                 <div class='imageresult-header-title'>{$mediatitle}</div>
  375.             </div>
  376.             <div class='imageresult-body'>
  377.                 <table>
  378.                     <tr>
  379.                         <td class='imgresult-body-desc'>
  380.                             <h4>HTML 5 Video Title</h4>
  381.                             <input name='{$mbid}[$seq][type]' class='replaceindex' type='hidden' value='html5video'>
  382.                             <input name='{$mbid}[$seq][title]' class='replaceindex videotitle showonlist' type='text' value='{$mediatitle}'>
  383.                         </td>
  384.                     </tr>
  385.                     <tr>
  386.                         <td class='imgresult-body-desc uploadfile'>
  387.                             <h4>MP4 Video</h4>
  388.                             <input name='{$mbid}[$seq][videomp4]' class='replaceindex videomp4 uploadtext' type='text' value='{$mp4}'>
  389.                             <input type='button' value='Select / Upload MP4' class='selectfile'/>
  390.                         </td>
  391.                     </tr>
  392.                     <tr>
  393.                         <td class='imgresult-body-desc uploadfile'>
  394.                             <h4>WEBM Video</h4>
  395.                             <input name='{$mbid}[$seq][videowebm]' class='replaceindex videowebm uploadtext' type='text' value='{$webm}'>
  396.                             <input type='button' value='Select / Upload WEBM' class='selectfile'/>
  397.                         </td>
  398.                     </tr>
  399.                     <tr>
  400.                         <td class='imgresult-body-desc uploadfile'>
  401.                             <h4>OGG Video</h4>
  402.                             <input name='{$mbid}[$seq][videoogg]' class='replaceindex videoogg uploadtext' type='text' value='{$ogg}'>
  403.                             <input type='button' value='Select / Upload OGG' class='selectfile'/>
  404.                         </td>
  405.                     </tr>
  406.                     {$videocover}
  407.                     <tr>
  408.                         <td class='imgresult-body-desc'>
  409.                             {$sizeblock}
  410.                         </td>
  411.                     </tr>
  412.                 </table>
  413.             </div>
  414.         </div>
  415.         ";
  416.     }
  417. }
  418.  
  419.  
  420. /**
  421.  * Check if landing page
  422.  */
  423. if(!function_exists('jeg_is_landing_template'))
  424. {
  425.     function jeg_is_landing_template ()
  426.     {
  427.         global $post;
  428.        
  429.         if(is_page()) {
  430.             $template = get_post_meta($post->ID,'_wp_page_template',true);     
  431.             if($template === 'template/template-landing-page.php' || $template === 'template/template-landing-page-vc.php'){
  432.                 return true;
  433.             }      
  434.         } else if(isset($post->post_type) && $post->post_type === 'portfolio') {       
  435.             $layout = get_post_meta($post->ID, 'portfolio_layout', true);
  436.             if($layout === 'landingpage') {
  437.                 return true;
  438.             }
  439.         }
  440.        
  441.         return false;
  442.     }  
  443. }
  444.  
  445.  
  446.  
  447. /***
  448.  * Change Repeating Title
  449.  */
  450.  
  451. function jeg_modify_repeating_title ($title, $g) {
  452.     $additionaltitle = '';
  453.     if(isset($g['childs']['section_id']) && isset($g['childs']['section_name'])) {
  454.         $sectionname = $g['childs']['section_name']->get_value();
  455.         $sectionid = $g['childs']['section_id']->get_value();
  456.         if(!empty($sectionname)) {
  457.             $additionaltitle = " > " . $g['childs']['section_name']->get_value();
  458.         } else if (!empty($sectionid)) {
  459.             $additionaltitle = " > " . $g['childs']['section_id']->get_value();
  460.         }
  461.     }
  462.    
  463.     if($additionaltitle !== '') {
  464.         $title = $title . $additionaltitle;
  465.     }
  466.    
  467.     return $title;
  468. }
  469.  
  470. add_filter( 'jeg_modify_repeating_title', 'jeg_modify_repeating_title', 10, 2 );
  471.  
  472.  
  473.  
  474.  
  475. /*** ****/
  476.  
  477. function jeg_dependencies_array ($dep) {
  478.     if(isset($_GET['page']) && $_GET['page'] === 'revslider') {
  479.         unset($dep['scripts']['paths']['shared']);
  480.     }
  481.     return $dep;
  482. }
  483.  
  484. add_filter('vp_dependencies_array', 'jeg_dependencies_array');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement