Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.12 KB | None | 0 0
  1. <?php
  2.  
  3. class partners_shortcode
  4. {
  5. public function register_shortcode($shortcodeName)
  6. {
  7. function shortcode_partners($atts, $content = null)
  8. {
  9. global $gt3_pbconfig;
  10. extract(shortcode_atts(array(
  11. ‘heading_size’ => $gt3_pbconfig[‘default_heading_in_module’],
  12. ‘heading_color’ =>,
  13. ‘heading_text’ =>,
  14. ‘number’ =>6,
  15. ‘url’ =>,
  16. ), $atts));
  17.  
  18. #heading
  19. if (strlen($heading_color) > 0) {
  20. $custom_color = “color:#{$heading_color};”;
  21. } else {$custom_color=;}
  22. if (strlen($heading_text) > 0) {
  23. echo<div class=’bg_title’><. $heading_size . ” style='” . $custom_color . “‘ class=’headInModule’>{$heading_text}</” . $heading_size . “></div>”;
  24. }
  25.  
  26. $wp_query = new WP_Query();
  27. $args = array(
  28. ‘post_type’ => ‘partners’,
  29. ‘order’ => ‘DESC’,
  30. ‘posts_per_page’ => -1,
  31. );
  32.  
  33. $wp_query->query($args);
  34.  
  35. $compile = ‘<div class=”module_content carouselslider sponsors_works items’.$number.'” data-count=”‘.$number.'”>
  36.  
  37. ‘;
  38. while ($wp_query->have_posts()) : $wp_query->the_post();
  39. $featured_image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), ‘single-post-thumbnail’ );
  40. if (strlen($featured_image[0])>0) {
  41. $featured_image_url = $featured_image[0];
  42. } else {
  43. $featured_image_url = aq_resize(IMGURL.’/wbg.jpg’, “170”, “60”, true);
  44. }
  45.  
  46. $partners_url = get_post_meta(get_the_ID(), “partners_url”, true);
  47.  
  48. $compile .= ‘
  49.  
  50. <div class=”item”>
  51. ‘.(strlen($partners_url)>0 ? “” : “”).’'.get_the_title().'‘.(strlen($partners_url)>0 ? “” : “”).’
  52. </div>
  53. ‘;
  54. endwhile;
  55.  
  56. $compile .= ‘
  57.  
  58. </div>’;
  59.  
  60. wp_reset_query();
  61.  
  62. return $compile;
  63. }
  64.  
  65. add_shortcode($shortcodeName, ‘shortcode_partners’);
  66. }
  67. }
  68.  
  69. #Shortcode name
  70. $shortcodeName = “partners”;
  71.  
  72. #Compile UI for admin panel
  73. #Don’t change this line
  74. global $compileShortcodeUI;
  75. $compileShortcodeUI .= “<div class=’whatInsert whatInsert_” . $shortcodeName . “‘>” . $defaultUI . “</div>”;
  76.  
  77. #Your code
  78. $compileShortcodeUI .= ”
  79. Type:
  80. <select name='. $shortcodeName . “_partners_type’ class='” . $shortcodeName . “_partners_type’>
  81. <option value=’type1′>Low</option>
  82. <option value=’type2′>Bold light</option>
  83. <option value=’type3′>Bold colored</option>
  84. <option value=’type4′>Bold dark</option>
  85. </select>
  86.  
  87. <script>
  88. function ” . $shortcodeName . “_handler() {
  89.  
  90. /* YOUR CODE HERE */
  91.  
  92. var partners_type = jQuery(‘.” . $shortcodeName . “_partners_type’).val();
  93.  
  94. /* END YOUR CODE */
  95.  
  96. /* COMPILE SHORTCODE LINE */
  97. var compileline = ‘[” . $shortcodeName . ” type=\”‘+partners_type+’\”][/” . $shortcodeName . “]’;
  98.  
  99. /* DO NOT CHANGE THIS LINE */
  100. jQuery(‘.whatInsert_” . $shortcodeName . “‘).html(compileline);
  101. }
  102. </script>
  103.  
  104. “;
  105.  
  106. #Register shortcode & set parameters
  107. $partners = new partners_shortcode();
  108. $partners->register_shortcode($shortcodeName);
  109.  
  110. #add shortcode to wysiwyg
  111. #$shortcodesUI[‘partners’] = array(“name” => $shortcodeName, “handler” => $compileShortcodeUI);
  112.  
  113. unset($compileShortcodeUI);
  114.  
  115. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement