PageRenderTime 33ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/finsys-master/wwwroot/wp-content/themes/auto/inc/vc-shortcode/thememove-blog.php

https://bitbucket.org/super-firma/zdrojove_soubory
PHP | 248 lines | 212 code | 22 blank | 14 comment | 12 complexity | 2a4c5bec463c1bb8c48a3e75cd5a8913 MD5 | raw file
  1. <?php
  2. /**
  3. * ThemeMove Blog Shortcode
  4. *
  5. * @version 1.0
  6. * @package ThemeMove
  7. */
  8. class WPBakeryShortCode_Thememove_Blog extends WPBakeryShortCode {
  9. public $query = '';
  10. public $num_pages = 0;
  11. public $paged;
  12. public $offset = 0;
  13. public function get_query( $atts ) {
  14. $total_posts = intval( $atts['total_posts'] ) != - 1 ? intval( $atts['total_posts'] ) : 1000;
  15. $posts_per_page = intval( $atts['posts_per_page'] ) > 0 ? intval( $atts['posts_per_page'] ) : 5;
  16. $this->paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
  17. $offset = $posts_per_page * ( $this->paged - 1 );
  18. $orderby = $atts['orderby'];
  19. $order = $atts['order'];
  20. $args = array(
  21. 'post_type' => 'post',
  22. 'offset' => $offset,
  23. 'post_count' => $total_posts,
  24. 'posts_per_page' => $posts_per_page,
  25. 'orderby' => $orderby,
  26. 'order' => $order,
  27. );
  28. $filter = $atts['filter'];
  29. $taxonomies = $atts['taxonomies'];
  30. if ( '' != $taxonomies ) {
  31. if ( 'category' == $filter ) {
  32. $args['cat'] = $taxonomies;
  33. }
  34. if ( 'tag' == $filter ) {
  35. $tag_arr = explode( ',', $taxonomies );
  36. $args['tag__in'] = $tag_arr;
  37. }
  38. }
  39. $this->query = new WP_Query( $args );
  40. $this->num_pages = intval( $atts['total_posts'] ) != - 1 ? ceil( $total_posts / $posts_per_page ) : $this->query->max_num_pages;
  41. }
  42. /***
  43. * Display navigation to next/previous set of posts when applicable.
  44. *
  45. * @return array|string
  46. */
  47. public function get_paging_nav() {
  48. global $wp_rewrite;
  49. // Don't print empty markup if there's only one page.
  50. if ( $this->num_pages < 2 ) {
  51. return '';
  52. }
  53. $pagenum_link = html_entity_decode( get_pagenum_link() );
  54. $query_args = array();
  55. $url_parts = explode( '?', $pagenum_link );
  56. if ( isset( $url_parts[1] ) ) {
  57. wp_parse_str( $url_parts[1], $query_args );
  58. }
  59. $pagenum_link = esc_url( remove_query_arg( array_keys( $query_args ), $pagenum_link ) );
  60. $pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
  61. $format = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
  62. $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%';
  63. // Set up paginated links.
  64. $links = paginate_links( array(
  65. 'base' => $pagenum_link,
  66. 'format' => $format,
  67. 'total' => $this->num_pages,
  68. 'current' => $this->paged,
  69. 'mid_size' => 1,
  70. 'add_args' => array_map( 'urlencode', $query_args ),
  71. 'prev_text' => '<i class="fa fa-angle-left"></i>',
  72. 'next_text' => '<i class="fa fa-angle-right"></i>',
  73. ) );
  74. if ( ! $links ) {
  75. return '';
  76. }
  77. return $links;
  78. }
  79. }
  80. // Mapping shortcode
  81. vc_map( array(
  82. 'name' => esc_html__( 'Blog', 'tm-renovation' ),
  83. 'base' => 'thememove_blog',
  84. 'category' => esc_html__( 'by THEMEMOVE', 'tm-renovation' ),
  85. 'params' => array(
  86. array(
  87. 'type' => 'dropdown',
  88. 'heading' => esc_html__( 'Post layout', 'tm-renovation' ),
  89. 'description' => esc_html__( 'Select a template to display post', 'tm-renovation' ),
  90. 'param_name' => 'layout',
  91. 'admin_label' => true,
  92. 'value' => array(
  93. esc_html__( 'List Post Layout', 'tm-renovation' ) => 'list',
  94. esc_html__( '1 Full Post then List Layout', 'tm-renovation' ) => 'full_list',
  95. esc_html__( 'Grid Post Layout', 'tm-renovation' ) => 'grid',
  96. esc_html__( '1 Full Post then Grid Layout', 'tm-renovation' ) => 'full_grid',
  97. esc_html__( 'Simple Post Layout', 'tm-renovation' ) => 'simple',
  98. ),
  99. ),
  100. array(
  101. 'type' => 'textfield',
  102. 'heading' => esc_html__( 'Total Posts', 'tm-renovation' ),
  103. 'param_name' => 'total_posts',
  104. 'value' => - 1,
  105. 'description' => esc_html__( 'Set max limit for items in grid or enter -1 to display all (limited to 1000)', 'tm-renovation' ),
  106. ),
  107. array(
  108. 'type' => 'textfield',
  109. 'heading' => esc_html__( 'Posts per page', 'tm-renovation' ),
  110. 'param_name' => 'posts_per_page',
  111. 'value' => 5,
  112. 'description' => esc_html__( 'Number of items to show per page', 'tm-renovation' ),
  113. ),
  114. array(
  115. 'type' => 'checkbox',
  116. 'param_name' => 'enable_share',
  117. 'value' => array( esc_html__( 'Show Share Buttons', 'tm-renovation' ) => 'true' ),
  118. 'dependency' => array( 'element' => 'layout', 'value' => array( 'list', 'full_list' ) ),
  119. ),
  120. array(
  121. 'type' => 'dropdown',
  122. 'heading' => __( 'Item Width', 'tm-renovation' ),
  123. 'description' => __( 'Enter item width in a row (has 12 columns)', 'tm-renovation' ),
  124. 'param_name' => 'item_width_md',
  125. 'value' => array(
  126. __( 'Default (6 columns - 1/2 - 2 items in a row)', 'tm-renovation' ) => 6,
  127. __( '1 columns - 1/1 - 12 items in a row', 'tm-renovation' ) => 1,
  128. __( '2 columns - 1/6 - 6 items in a row', 'tm-renovation' ) => 2,
  129. __( '3 columns - 1/4 - 4 items in a row', 'tm-renovation' ) => 3,
  130. __( '4 columns - 1/3 - 3 items in a row', 'tm-renovation' ) => 4,
  131. __( '6 columns - 1/2 - 2 items in a row', 'tm-renovation' ) => 6,
  132. __( '12 columns - 1/1 - 1 item in a row', 'tm-renovation' ) => 12,
  133. ),
  134. 'dependency' => array(
  135. 'element' => 'layout',
  136. 'value' => array( 'grid', 'full_grid' ),
  137. ),
  138. ),
  139. array(
  140. 'type' => 'dropdown',
  141. 'heading' => esc_html__( 'Number of posts in a row', 'tm-renovation' ),
  142. 'param_name' => 'number_of_columns_simple',
  143. 'value' => array(
  144. esc_html__( 'Default (2 posts)', 'tm-renovation' ) => 6,
  145. esc_html__( '12 posts', 'tm-renovation' ) => 1,
  146. esc_html__( '6 posts', 'tm-renovation' ) => 2,
  147. esc_html__( '4 posts', 'tm-renovation' ) => 3,
  148. esc_html__( '3 posts', 'tm-renovation' ) => 4,
  149. esc_html__( '2 posts', 'tm-renovation' ) => 6,
  150. esc_html__( '1 posts', 'tm-renovation' ) => 12,
  151. ),
  152. 'dependency' => array( 'element' => 'layout', 'value' => 'simple' ),
  153. ),
  154. array(
  155. 'group' => esc_html__( 'Data Settings', 'tm-renovation' ),
  156. 'type' => 'dropdown',
  157. 'heading' => esc_html__( 'Order by', 'tm-renovation' ),
  158. 'param_name' => 'orderby',
  159. 'description' => esc_html__( 'Select order type.', 'tm-renovation' ),
  160. 'value' => array(
  161. esc_html__( 'Date', 'tm-renovation' ) => 'date',
  162. esc_html__( 'Post ID', 'tm-renovation' ) => 'ID',
  163. esc_html__( 'Author', 'tm-renovation' ) => 'author',
  164. esc_html__( 'Title', 'tm-renovation' ) => 'title',
  165. esc_html__( 'Last modified date', 'tm-renovation' ) => 'modified',
  166. esc_html__( 'Random order', 'tm-renovation' ) => 'rand',
  167. ),
  168. ),
  169. array(
  170. 'group' => esc_html__( 'Data Settings', 'tm-renovation' ),
  171. 'type' => 'dropdown',
  172. 'heading' => esc_html__( 'Sorting', 'tm-renovation' ),
  173. 'param_name' => 'order',
  174. 'description' => esc_html__( 'Select sorting order.', 'tm-renovation' ),
  175. 'value' => array(
  176. esc_html__( 'Descending', 'tm-renovation' ) => 'DESC',
  177. esc_html__( 'Ascending', 'tm-renovation' ) => 'ASC',
  178. ),
  179. ),
  180. array(
  181. 'group' => esc_html__( 'Data Settings', 'tm-renovation' ),
  182. 'type' => 'dropdown',
  183. 'heading' => esc_html__( 'Filter by', 'tm-renovation' ),
  184. 'param_name' => 'filter',
  185. 'description' => esc_html__( 'Select filter source.', 'tm-renovation' ),
  186. 'value' => array(
  187. esc_html__( 'Categories', 'tm-renovation' ) => 'category',
  188. esc_html__( 'Tags', 'tm-renovation' ) => 'tag',
  189. ),
  190. ),
  191. array(
  192. 'group' => esc_html__( 'Data Settings', 'tm-renovation' ),
  193. 'type' => 'autocomplete',
  194. 'param_name' => 'taxonomies',
  195. 'description' => esc_html__( 'Enter categories, tags to filter.', 'tm-renovation' ),
  196. 'settings' => array(
  197. 'multiple' => true,
  198. 'min_length' => 1,
  199. 'groups' => true,
  200. 'unique_values' => true,
  201. 'display_inline' => true,
  202. 'delay' => 0,
  203. 'auto_focus' => true,
  204. 'values' => TM_Renovation_VC::get_taxonomy_for_autocomplete(),
  205. ),
  206. 'dependency' => array( 'element' => 'filter', 'value' => array( 'category', 'tag' ) ),
  207. ),
  208. array(
  209. 'group' => __( 'Responsive Options', 'tm-renovation' ),
  210. 'type' => 'thememove_responsive',
  211. 'heading' => __( 'Responsiveness', 'tm-renovation' ),
  212. 'param_name' => 'responsive',
  213. 'description' => __( 'Adjust Number of items in a row for different screen sizes.', 'tm-renovation' ),
  214. 'dependency' => array(
  215. 'element' => 'layout',
  216. 'value' => array( 'grid', 'full_grid' ),
  217. ),
  218. ),
  219. array(
  220. 'type' => 'textfield',
  221. 'heading' => esc_html__( 'Extra class name', 'tm-renovation' ),
  222. 'param_name' => 'el_class',
  223. 'description' => esc_html__( 'If you want to use multiple Google Maps in one page, please add a class name for them.', 'tm-renovation' ),
  224. ),
  225. ),
  226. ) );