Content Views – Post Grid & List for WordPress - Version 1.3.4.1

Version Description

  • Improvement: Clean up 'Read more' button code
  • Improvement: Remove unused code of Order setting
Download this release

Release Info

Developer PT Guy
Plugin Icon 128x128 Content Views – Post Grid & List for WordPress
Version 1.3.4.1
Comparing to
See all releases

Code changes from version 1.3.4 to 1.3.4.1

README.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: post, posts, page, pages, query, queries, search, display, show, grid, layout, author, blog, categories, category, comment, content, custom, editor, filter, Formatting, image, list, meta, plugin, responsive, shortcode, excerpt, title, tag, term, Taxonomy, thumbnail, pagination, date, scrollable, slider, collapsible
5
  Requires at least: 3.3
6
  Tested up to: 4.0
7
- Stable tag: 1.3.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -34,8 +34,8 @@ With [Content Views Pro](http://www.contentviewspro.com/?utm_source=wordpress&ut
34
  * Step 2 : Customize output (select a layout from 3 responsive layout, show title/content/excerpt/pagination ? ...)
35
  * Step 3 : Save View then paste the generated shortcode **[pt_view id="VIEW_ID"]** to editor of page/Text widget where you want to display your posts. If you are a developer, you can paste `<?php echo do_shortcode('[pt_view id="VIEW_ID"]'); ?>` to file in WordPress theme
36
 
37
- = A features list of Content Views plugin: =
38
 
 
39
 
40
  **in Step 1:**
41
 
@@ -144,6 +144,10 @@ You can create Unlimited Views, in Unlimited websites
144
 
145
  == Changelog ==
146
 
 
 
 
 
147
  = 1.3.4 =
148
  * Bug fixed: Read more button is invisible (color is white and no background color)
149
  * Update: Able to set 0 as 'Excerpt length'
@@ -278,6 +282,9 @@ You can create Unlimited Views, in Unlimited websites
278
 
279
  == Upgrade Notice ==
280
 
 
 
 
281
  = 1.3.4 =
282
  Bug fixed: Read more button is invisible (color is white and no background color). Update: Able to set 0 as 'Excerpt length'
283
 
4
  Tags: post, posts, page, pages, query, queries, search, display, show, grid, layout, author, blog, categories, category, comment, content, custom, editor, filter, Formatting, image, list, meta, plugin, responsive, shortcode, excerpt, title, tag, term, Taxonomy, thumbnail, pagination, date, scrollable, slider, collapsible
5
  Requires at least: 3.3
6
  Tested up to: 4.0
7
+ Stable tag: 1.3.4.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
34
  * Step 2 : Customize output (select a layout from 3 responsive layout, show title/content/excerpt/pagination ? ...)
35
  * Step 3 : Save View then paste the generated shortcode **[pt_view id="VIEW_ID"]** to editor of page/Text widget where you want to display your posts. If you are a developer, you can paste `<?php echo do_shortcode('[pt_view id="VIEW_ID"]'); ?>` to file in WordPress theme
36
 
 
37
 
38
+ = A features list of Content Views plugin: =
39
 
40
  **in Step 1:**
41
 
144
 
145
  == Changelog ==
146
 
147
+ = 1.3.4.1 =
148
+ * Improvement: Clean up 'Read more' button code
149
+ * Improvement: Remove unused code of Order setting
150
+
151
  = 1.3.4 =
152
  * Bug fixed: Read more button is invisible (color is white and no background color)
153
  * Update: Able to set 0 as 'Excerpt length'
282
 
283
  == Upgrade Notice ==
284
 
285
+ = 1.3.4.1 =
286
+ Improvement: Clean up 'Read more' button code. Improvement: Remove unused code of Order setting
287
+
288
  = 1.3.4 =
289
  Bug fixed: Read more button is invisible (color is white and no background color). Update: Able to set 0 as 'Excerpt length'
290
 
admin/assets/css/admin.css CHANGED
@@ -194,6 +194,7 @@ html {
194
  /* View shortcode text */
195
  #view-shortcode {
196
  background: #ADFFAD;
 
197
  margin-bottom: 20px;
198
  float: left;
199
  position: relative;
194
  /* View shortcode text */
195
  #view-shortcode {
196
  background: #ADFFAD;
197
+ cursor: pointer;
198
  margin-bottom: 20px;
199
  float: left;
200
  position: relative;
admin/views/view.php CHANGED
@@ -209,6 +209,8 @@ $options = array(
209
  'dependence' => array( 'content-type', 'page' ),
210
  ),
211
 
 
 
212
  // Limit
213
  array(
214
  'label' => array(
209
  'dependence' => array( 'content-type', 'page' ),
210
  ),
211
 
212
+ apply_filters( PT_CV_PREFIX_ . 'post_parent_settings', array() ),
213
+
214
  // Limit
215
  array(
216
  'label' => array(
content-views.php CHANGED
@@ -10,7 +10,7 @@
10
  * Plugin Name: Content Views
11
  * Plugin URI: http://wordpress.org/plugins/content-views-query-and-display-post-page/
12
  * Description: Query and display <strong>posts, pages</strong> in awesome layouts (<strong>grid, scrollable list, collapsible list</strong>) easier than ever, without coding!
13
- * Version: 1.3.4
14
  * Author: PT Guy
15
  * Author URI: http://profiles.wordpress.org/pt-guy
16
  * Text Domain: content-views
@@ -27,7 +27,7 @@ if ( ! defined( 'WPINC' ) ) {
27
  /*
28
  * Define Constant
29
  */
30
- define( 'PT_CV_VERSION', '1.3.4' );
31
  define( 'PT_CV_FILE', __FILE__ );
32
  $pt_cv_path = plugin_dir_path( __FILE__ );
33
  include_once( $pt_cv_path . 'includes/defines.php' );
10
  * Plugin Name: Content Views
11
  * Plugin URI: http://wordpress.org/plugins/content-views-query-and-display-post-page/
12
  * Description: Query and display <strong>posts, pages</strong> in awesome layouts (<strong>grid, scrollable list, collapsible list</strong>) easier than ever, without coding!
13
+ * Version: 1.3.4.1
14
  * Author: PT Guy
15
  * Author URI: http://profiles.wordpress.org/pt-guy
16
  * Text Domain: content-views
27
  /*
28
  * Define Constant
29
  */
30
+ define( 'PT_CV_VERSION', '1.3.4.1' );
31
  define( 'PT_CV_FILE', __FILE__ );
32
  $pt_cv_path = plugin_dir_path( __FILE__ );
33
  include_once( $pt_cv_path . 'includes/defines.php' );
includes/functions.php CHANGED
@@ -384,6 +384,9 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
384
  endwhile;
385
  endif;
386
 
 
 
 
387
  return $post_id;
388
  }
389
 
@@ -573,7 +576,10 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
573
  global $post;
574
 
575
  // Output HTML for this item
576
- $content_items[$post->ID] = PT_CV_Html::view_type_output( $view_type, $post );
 
 
 
577
  }
578
  } else {
579
  // Get no post found class
@@ -586,8 +592,8 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
586
  $content_items[] = sprintf( '<div class="%1$s">%2$s</div>', esc_attr( $_class ), balanceTags( $_text ) );
587
  }
588
 
589
- // Restore original Post Data
590
- wp_reset_postdata();
591
 
592
  // Filter array of items
593
  $content_items = apply_filters( PT_CV_PREFIX_ . 'content_items', $content_items );
@@ -650,7 +656,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
650
 
651
  // Parent page
652
  if ( $content_type == 'page' ) {
653
- $post_parent = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post_parent', $pt_view_settings );
654
  if ( ! empty( $post_parent ) ) {
655
  $args['post_parent'] = (int) $post_parent;
656
  }
@@ -803,40 +809,13 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
803
 
804
  // Order
805
  case 'order':
806
-
807
- $order_settings = array();
808
-
809
- // Advanced order by
810
- if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . $content_type . '-orderby', $pt_view_settings ) ) {
811
-
812
- // Get meta key to order by
813
- $meta_key = PT_CV_Functions::setting_value( PT_CV_PREFIX . $content_type . '-orderby', $pt_view_settings );
814
-
815
- // Use 'meta_value_num' for numeric values
816
- global $pt_content_type;
817
- $all_meta_numeric_values = apply_filters( PT_CV_PREFIX_ . 'meta_numeric_values', array() );
818
-
819
- // Get numeric values of selected content type
820
- $meta_numeric_values = isset( $all_meta_numeric_values[$pt_content_type] ) ? $all_meta_numeric_values[$pt_content_type] : array();
821
- $meta_orderby = array_key_exists( $meta_key, (array) $meta_numeric_values ) ? 'meta_value_num' : 'meta_value';
822
- $order_settings = array(
823
- 'meta_key' => isset( $meta_numeric_values[$meta_key] ) ? $meta_numeric_values[$meta_key] : $meta_key,
824
- 'orderby' => $meta_orderby,
825
- 'order' => PT_CV_Functions::setting_value( PT_CV_PREFIX . 'advanced-order', $pt_view_settings ),
826
- );
827
-
828
- } else {
829
- // Common order by
830
- $orderby = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'orderby', $pt_view_settings );
831
- $order_by_options = array_keys( PT_CV_Values::post_regular_orderby() );
832
-
833
- if ( in_array( $orderby, $order_by_options ) ) {
834
- $order_settings = array(
835
- 'orderby' => $orderby,
836
- 'order' => PT_CV_Functions::setting_value( PT_CV_PREFIX . 'order', $pt_view_settings )
837
- );
838
- }
839
- }
840
 
841
  $args = array_merge( $args, $order_settings );
842
  break;
384
  endwhile;
385
  endif;
386
 
387
+ // Restore $wp_query and original Post Data
388
+ wp_reset_query();
389
+
390
  return $post_id;
391
  }
392
 
576
  global $post;
577
 
578
  // Output HTML for this item
579
+ $post_id = apply_filters( PT_CV_PREFIX_ . 'show_this_post', $post->ID );
580
+ if ( $post_id ) {
581
+ $content_items[$post->ID] = PT_CV_Html::view_type_output( $view_type, $post );
582
+ }
583
  }
584
  } else {
585
  // Get no post found class
592
  $content_items[] = sprintf( '<div class="%1$s">%2$s</div>', esc_attr( $_class ), balanceTags( $_text ) );
593
  }
594
 
595
+ // Restore $wp_query and original Post Data
596
+ wp_reset_query();
597
 
598
  // Filter array of items
599
  $content_items = apply_filters( PT_CV_PREFIX_ . 'content_items', $content_items );
656
 
657
  // Parent page
658
  if ( $content_type == 'page' ) {
659
+ $post_parent = apply_filters( PT_CV_PREFIX_ . 'post_parent_id', PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post_parent', $pt_view_settings ) );
660
  if ( ! empty( $post_parent ) ) {
661
  $args['post_parent'] = (int) $post_parent;
662
  }
809
 
810
  // Order
811
  case 'order':
812
+ $order_settings = apply_filters(
813
+ PT_CV_PREFIX_ . 'order_setting',
814
+ array(
815
+ 'orderby' => PT_CV_Functions::setting_value( PT_CV_PREFIX . 'orderby', $pt_view_settings ),
816
+ 'order' => PT_CV_Functions::setting_value( PT_CV_PREFIX . 'order', $pt_view_settings ),
817
+ )
818
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
819
 
820
  $args = array_merge( $args, $order_settings );
821
  break;
includes/html.php CHANGED
@@ -455,23 +455,26 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
455
  switch ( $fargs['content']['show'] ) {
456
  case 'excerpt':
457
  $length = (int) $fargs['content']['length'];
458
-
459
  $readmore_btn = ' ...';
 
 
460
  if ( apply_filters( PT_CV_PREFIX_ . 'field_content_readmore_enable', 1, $fargs['content'] ) ) {
461
  $text = apply_filters( PT_CV_PREFIX_ . 'field_content_readmore_text', __( 'Read More', PT_CV_DOMAIN ), $fargs['content'] );
462
- $readmore = self::_field_href( $oargs, $post, $text, PT_CV_PREFIX . 'readmore' . ' btn btn-success btn-sm' );
463
  $readmore_btn .= '<br />' . $readmore;
464
  }
465
-
466
- $content = apply_filters( PT_CV_PREFIX_ . 'field_content_result', '', $fargs, $post );
467
 
468
- if ( empty( $content ) ) {
469
- if ( $length ) {
470
- $content = wp_trim_words( get_the_content(), $length, $readmore_btn );
471
- } else {
472
- $content = isset( $readmore ) ? $readmore : '';
473
- }
474
- }
 
 
 
475
  // Force balance tags
476
  $content = force_balance_tags( strip_shortcodes( $content ) );
477
 
455
  switch ( $fargs['content']['show'] ) {
456
  case 'excerpt':
457
  $length = (int) $fargs['content']['length'];
458
+ $readmore = '';
459
  $readmore_btn = ' ...';
460
+
461
+ // Read more button
462
  if ( apply_filters( PT_CV_PREFIX_ . 'field_content_readmore_enable', 1, $fargs['content'] ) ) {
463
  $text = apply_filters( PT_CV_PREFIX_ . 'field_content_readmore_text', __( 'Read More', PT_CV_DOMAIN ), $fargs['content'] );
464
+ $readmore .= self::_field_href( $oargs, $post, $text, PT_CV_PREFIX . 'readmore' . ' btn btn-success btn-sm' );
465
  $readmore_btn .= '<br />' . $readmore;
466
  }
 
 
467
 
468
+ // Filter content
469
+ $content = apply_filters( PT_CV_PREFIX_ . 'field_content_result', get_the_content(), $fargs, $post );
470
+
471
+ /*
472
+ * Trim some words, or show only button (if length = 0)
473
+ * Don't set $readmore_btn as 3rd parameter for wp_trim_words(),
474
+ * to show Read more button always (even if manual excerpt length < $length)
475
+ */
476
+ $content = $length ? rtrim( wp_trim_words( $content, $length, '' ), '.' ) . $readmore_btn : $readmore;
477
+
478
  // Force balance tags
479
  $content = force_balance_tags( strip_shortcodes( $content ) );
480