Advertisement
GochiSiyan

custom module 4

Sep 19th, 2021
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.78 KB | None | 0 0
  1. <?php
  2. /**
  3. * @author : Jegtheme
  4. */
  5.  
  6. use JNEWS_VIDEO\Module\Block\Video_Block_View_Abstract;
  7.  
  8. class JNews_Video_Block4_View extends Video_Block_View_Abstract {
  9.  
  10. public function render_module( $attr, $column_class ) {
  11. $heading = $this->render_header( $attr );
  12. $name = 'video_4';
  13. $style_output = jnews_header_styling( $attr, $this->unique_id . ' ' );
  14. $style_output .= jnews_module_custom_color( $attr, $this->unique_id . ' ', $name );
  15. $content = $this->render_output( $attr, $column_class );
  16. $style = ! empty( $style_output ) ? "<style scoped>{$style_output}</style>" : '';
  17. $script = $this->render_script( $attr, $column_class );
  18. $nav_top = ( ! empty( $attr['nav_position_top'] ) ) ? 'nav_top' : '';
  19.  
  20. $output =
  21. "<div {$this->element_id($attr)} class=\"jnews_video jeg_postblock_{$name} jeg_postblock jeg_module_hook jeg_pagination_{$attr['pagination_mode']} {$column_class} {$this->unique_id} {$this->get_vc_class_name()} {$this->color_scheme()} {$attr['el_class']} {$nav_top}\" data-unique=\"{$this->unique_id}\">
  22. {$heading}
  23. {$content}
  24. {$style}
  25. {$script}
  26. </div>";
  27.  
  28. return $output;
  29. }
  30.  
  31. public function render_output( $attr, $column_class ) {
  32. if ( isset( $attr['results'] ) ) {
  33. $results = $attr['results'];
  34. } else {
  35. $results = $this->build_query( $attr );
  36. }
  37.  
  38. $navigation = $this->render_navigation( $attr, $results['next'], $results['prev'], $results['total_page'] );
  39.  
  40. if ( ! empty( $results['result'] ) ) {
  41. $content = $this->render_column( $results['result'], $column_class, $attr );
  42. } else {
  43. $content = $this->empty_content();
  44. }
  45.  
  46. return "<div class=\"jeg_block_container\">
  47. {$this->get_content_before($attr)}
  48. {$content}
  49. {$this->get_content_after($attr)}
  50. </div>
  51. <div class=\"jeg_block_navigation\">
  52. {$this->get_navigation_before($attr)}
  53. {$navigation}
  54. {$this->get_navigation_after($attr)}
  55. </div>";
  56. }
  57.  
  58. public function render_column( $result, $column_class, $attr = null ) {
  59. switch ( $column_class ) {
  60. case 'jeg_col_1o3':
  61. $content = $this->build_column_1( $result, $attr );
  62. break;
  63. case 'jeg_col_3o3':
  64. case 'jeg_col_2o3':
  65. default:
  66. $content = $this->build_column_2( $result, $attr );
  67. break;
  68. }
  69.  
  70. return $content;
  71. }
  72.  
  73. public function build_column_1( $results, $attr = null ) {
  74. $first_block = '';
  75. for ( $i = 0; $i < sizeof( $results ); $i ++ ) {
  76. $first_block .= $this->render_block_type_1( $results[ $i ], 'jnews-360x180', $attr );
  77. }
  78.  
  79. $output =
  80. "<div class=\"jeg_posts_wrap\">
  81. <div class=\"jeg_posts jeg_load_more_flag\">
  82. {$first_block}
  83. </div>
  84. </div>";
  85.  
  86. return $output;
  87. }
  88.  
  89. public function render_block_type_1( $post, $image_size, $attr = null ) {
  90. $thumbnail = $this->get_thumbnail( $post->ID, $image_size );
  91. $post_meta_style = $this->get_post_meta_style( $post, $attr );
  92.  
  93. $output =
  94. '<article ' . jnews_post_class( 'jeg_post jeg_pl_md_5', $post->ID ) . '>
  95. <div class="jeg_thumb">
  96. ' . jnews_edit_post( $post->ID ) . '
  97. <a href="' . get_the_permalink( $post ) . '">' . $thumbnail . '</a>
  98. ' . $this->additional_attribute( $post, $attr ) . '
  99. </div>
  100. <div class="jeg_postblock_content">
  101. <h3 class="jeg_post_title">
  102. <a href="' . get_the_permalink( $post ) . '">' . get_the_title( $post ) . '</a>
  103. </h3>
  104. ' . $post_meta_style . '
  105. <div class="jeg_post_excerpt">
  106. <p>' . $this->get_excerpt( $post ) . '</p>
  107. </div>' . '
  108. </div>
  109. </article>';
  110.  
  111. return $output;
  112. }
  113.  
  114. public function build_column_2( $results, $attr = null ) {
  115. $first_block = '';
  116. for ( $i = 0; $i < sizeof( $results ); $i ++ ) {
  117. $first_block .= $this->render_block_type_1( $results[ $i ], 'jnews-360x180', $attr );
  118. }
  119.  
  120. $output =
  121. "<div class=\"jeg_posts_wrap\">
  122. <div class=\"jeg_posts jeg_load_more_flag\">
  123. {$first_block}
  124. </div>
  125. </div>";
  126.  
  127. return $output;
  128. }
  129.  
  130. public function render_module_out_call( $result, $column_class, $attr = null ) {
  131. $name = 'video_4';
  132.  
  133. if ( ! empty( $result ) ) {
  134. $content = $this->render_column( $result, $column_class, $attr );
  135. } else {
  136. $content = $this->empty_content();
  137. }
  138.  
  139. $output =
  140. "<div class=\"jeg_postblock_{$name} jeg_postblock {$column_class}\">
  141. <div class=\"jeg_block_container\">
  142. {$content}
  143. </div>
  144. </div>";
  145.  
  146. return $output;
  147.  
  148. }
  149.  
  150. public function render_column_alt( $result, $column_class ) {
  151. switch ( $column_class ) {
  152. case 'jeg_col_1o3':
  153. $content = $this->build_column_1_alt( $result );
  154. break;
  155. case 'jeg_col_3o3':
  156. case 'jeg_col_2o3':
  157. default:
  158. $content = $this->build_column_2_alt( $result );
  159. break;
  160. }
  161.  
  162. return $content;
  163. }
  164.  
  165. public function build_column_1_alt( $results ) {
  166. $first_block = '';
  167. for ( $i = 0; $i < sizeof( $results ); $i ++ ) {
  168. $first_block .= $this->render_block_type_1( $results[ $i ], 'jnews-360x180' );
  169. }
  170.  
  171. $output = $first_block;
  172.  
  173. return $output;
  174. }
  175.  
  176. public function build_column_2_alt( $results ) {
  177. $first_block = '';
  178. for ( $i = 0; $i < sizeof( $results ); $i ++ ) {
  179. $first_block .= $this->render_block_type_1( $results[ $i ], 'jnews-360x180' );
  180. }
  181.  
  182. $output = $first_block;
  183.  
  184. return $output;
  185. }
  186.  
  187. }
  188.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement