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

Version Description

  • Update: Restructure Taxonomy filter (remove "Not In" list, add operator[In, Not in, And])
Download this release

Release Info

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

Code changes from version 1.3.1.2 to 1.3.1.3

README.txt CHANGED
@@ -1,14 +1,14 @@
1
- === Query posts by category, author... and display posts on a Page in Grid layout without coding - Content Views ===
2
  Contributors: pt-guy
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=JGUF974QBRKQE
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: 3.9.1
7
- Stable tag: 1.3.1.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- It is easy as 1, 2, 3 to query your WordPress posts by category, tag, author... and display your posts on any Page in a responsive Grid, List layout without any line of code!
12
 
13
  == Description ==
14
 
@@ -142,6 +142,9 @@ You can create Unlimited Views, in Unlimited websites
142
 
143
  == Changelog ==
144
 
 
 
 
145
  = 1.3.1.2 =
146
  * Bug fixed: Loosing translation (WPML) in Ajax pagination
147
  * Improvement: Performance optimization (when get settings of View)
@@ -244,6 +247,9 @@ You can create Unlimited Views, in Unlimited websites
244
 
245
  == Upgrade Notice ==
246
 
 
 
 
247
  = 1.3.1.2 =
248
  Bug fixed: Loosing translation (WPML) in Ajax pagination. Improvement: Performance optimization (when get settings of View). Improvement: Update style if only Title is selected to display (to have a more beautiful list of Posts title)
249
 
1
+ === Query posts by category... and display posts on page in grid layout without coding - Content Views ===
2
  Contributors: pt-guy
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=JGUF974QBRKQE
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: 3.9.2
7
+ Stable tag: 1.3.1.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ It is easy as 1, 2, 3 to query your posts by category, tag, author... and display your posts on any Page in a responsive Grid layout without coding!
12
 
13
  == Description ==
14
 
142
 
143
  == Changelog ==
144
 
145
+ = 1.3.1.3 =
146
+ * Update: Restructure Taxonomy filter (remove "Not In" list, add operator[In, Not in, And])
147
+
148
  = 1.3.1.2 =
149
  * Bug fixed: Loosing translation (WPML) in Ajax pagination
150
  * Improvement: Performance optimization (when get settings of View)
247
 
248
  == Upgrade Notice ==
249
 
250
+ = 1.3.1.3 =
251
+ Update: Restructure Taxonomy filter (remove "Not In" list, add operator[In, Not in, And])
252
+
253
  = 1.3.1.2 =
254
  Bug fixed: Loosing translation (WPML) in Ajax pagination. Improvement: Performance optimization (when get settings of View). Improvement: Update style if only Title is selected to display (to have a more beautiful list of Posts title)
255
 
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.1.2
14
  * Author: Palace Of Themes
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.1.2' );
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.1.3
14
  * Author: Palace Of Themes
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.1.3' );
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
@@ -424,12 +424,41 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
424
  if ( $post_id ) {
425
  $view_settings = get_post_meta( $post_id, PT_CV_META_SETTINGS, true );
426
 
 
 
 
 
 
427
  return is_array( $view_settings ) ? $view_settings : array();
428
  }
429
 
430
  return array();
431
  }
432
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
433
  /**
434
  * Process view $settings array, return HTML output
435
  *
@@ -737,21 +766,15 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
737
 
738
  // Get Terms & criterias (In, Not in)
739
  foreach ( $taxonomies as $taxonomy ) {
 
 
 
740
 
741
- // If found setting for taxonomy
742
- if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '__in', $pt_view_settings ) ) {
743
- $taxonomy_setting[] = array(
744
- 'taxonomy' => $taxonomy,
745
- 'field' => 'slug',
746
- 'terms' => (array) PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '__in', $pt_view_settings ),
747
- );
748
- }
749
- if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '__not_in', $pt_view_settings ) ) {
750
  $taxonomy_setting[] = array(
751
  'taxonomy' => $taxonomy,
752
  'field' => 'slug',
753
- 'terms' => (array) PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '__not_in', $pt_view_settings ),
754
- 'operator' => 'NOT IN',
755
  );
756
  }
757
  }
424
  if ( $post_id ) {
425
  $view_settings = get_post_meta( $post_id, PT_CV_META_SETTINGS, true );
426
 
427
+ /* Backward compatibility
428
+ * since 1.3.2
429
+ */
430
+ self::view_backward_comp( $view_settings );
431
+
432
  return is_array( $view_settings ) ? $view_settings : array();
433
  }
434
 
435
  return array();
436
  }
437
 
438
+ /**
439
+ * Update values for some new options in new version (from options in old version)
440
+ *
441
+ * @param type $view_settings
442
+ */
443
+ static function view_backward_comp( &$view_settings ) {
444
+ if ( ! $view_settings )
445
+ return $view_settings;
446
+
447
+ $taxonomies = isset( $view_settings[ PT_CV_PREFIX . 'taxonomy'] ) ? $view_settings[ PT_CV_PREFIX . 'taxonomy'] : array();
448
+ if ( $taxonomies ) {
449
+ $list = array( '__in', '__not_in' );
450
+ foreach ( $taxonomies as $taxonomy ) {
451
+ // Check if IN/NOT IN list has values. NOT IN list will overwite IN list
452
+ foreach ( $list as $ltype ) {
453
+ if ( isset( $view_settings[PT_CV_PREFIX . $taxonomy . $ltype] ) ) {
454
+ $view_settings[PT_CV_PREFIX . $taxonomy . '-terms'] = $view_settings[PT_CV_PREFIX . $taxonomy . $ltype];
455
+ $view_settings[PT_CV_PREFIX . $taxonomy . '-operator'] = ( $ltype == '__in' ) ? 'IN' : 'NOT IN';
456
+ }
457
+ }
458
+ }
459
+ }
460
+ }
461
+
462
  /**
463
  * Process view $settings array, return HTML output
464
  *
766
 
767
  // Get Terms & criterias (In, Not in)
768
  foreach ( $taxonomies as $taxonomy ) {
769
+ if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '-terms', $pt_view_settings ) ) {
770
+ // Get operator
771
+ $operator = PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '-operator', $pt_view_settings, 'IN' );
772
 
 
 
 
 
 
 
 
 
 
773
  $taxonomy_setting[] = array(
774
  'taxonomy' => $taxonomy,
775
  'field' => 'slug',
776
+ 'terms' => (array) PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '-terms', $pt_view_settings ),
777
+ 'operator' => $operator,
778
  );
779
  }
780
  }
includes/html.php CHANGED
@@ -529,7 +529,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
529
  // Get thumbnail dimensions
530
  $dimensions = PT_CV_Functions::field_thumbnail_dimensions( $fargs );
531
  $dimensions = (array) apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_dimension_output', $dimensions, $fargs );
532
-
533
  // Check if has thumbnail ( has_post_thumbnail doesn't works )
534
  $has_thumbnail = get_the_post_thumbnail( $post_id );
535
  if ( ! empty( $has_thumbnail ) ) {
@@ -813,7 +813,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
813
  'data' => '',
814
  'prefix' => '',
815
  ), $is_admin, $options );
816
-
817
  PT_CV_Asset::enqueue( $data['name'], $data['type'], $data['data'], $data['prefix'] );
818
  }
819
 
529
  // Get thumbnail dimensions
530
  $dimensions = PT_CV_Functions::field_thumbnail_dimensions( $fargs );
531
  $dimensions = (array) apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_dimension_output', $dimensions, $fargs );
532
+
533
  // Check if has thumbnail ( has_post_thumbnail doesn't works )
534
  $has_thumbnail = get_the_post_thumbnail( $post_id );
535
  if ( ! empty( $has_thumbnail ) ) {
813
  'data' => '',
814
  'prefix' => '',
815
  ), $is_admin, $options );
816
+
817
  PT_CV_Asset::enqueue( $data['name'], $data['type'], $data['data'], $data['prefix'] );
818
  }
819
 
includes/settings.php CHANGED
@@ -38,57 +38,37 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
38
 
39
  $result[$taxonomy_slug] = array(
40
 
41
- // In
42
  array(
43
  'label' => array(
44
- 'text' => __( 'In ', PT_CV_DOMAIN ),
45
- //'text' => __( 'In ', PT_CV_DOMAIN ) . $taxonomies[$taxonomy_slug],
46
  ),
47
  'params' => array(
48
  array(
49
- 'type' => 'group',
50
- 'params' => apply_filters(
51
- PT_CV_PREFIX_ . 'term_quick_filter_in',
52
- array(
53
- array(
54
- 'label' => array(
55
- 'text' => __( '', PT_CV_DOMAIN ),
56
- ),
57
- 'extra_setting' => array(
58
- 'params' => array(
59
- 'width' => 12,
60
- ),
61
- ),
62
- 'params' => array(
63
- array(
64
- 'type' => 'select',
65
- 'name' => $taxonomy_slug . '__in[]',
66
- 'options' => $terms,
67
- 'std' => '',
68
- 'class' => 'select2',
69
- 'multiple' => '1',
70
- ),
71
- ),
72
- ),
73
- )
74
- ),
75
  ),
76
  ),
77
  ),
78
- // Not In
 
 
 
 
79
  array(
80
  'label' => array(
81
- 'text' => __( 'Not in ', PT_CV_DOMAIN ),
82
- //'text' => __( 'Not in ', PT_CV_DOMAIN ) . $taxonomies[$taxonomy_slug],
83
  ),
84
  'params' => array(
85
  array(
86
- 'type' => 'select',
87
- 'name' => $taxonomy_slug . '__not_in[]',
88
- 'options' => $terms,
89
- 'std' => '',
90
- 'class' => 'select2',
91
- 'multiple' => '1',
92
  ),
93
  ),
94
  ),
38
 
39
  $result[$taxonomy_slug] = array(
40
 
41
+ // Select term to filter
42
  array(
43
  'label' => array(
44
+ 'text' => __( 'Select terms', PT_CV_DOMAIN ),
 
45
  ),
46
  'params' => array(
47
  array(
48
+ 'type' => 'select',
49
+ 'name' => $taxonomy_slug . '-terms[]',
50
+ 'options' => $terms,
51
+ 'std' => '',
52
+ 'class' => 'select2',
53
+ 'multiple' => '1',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  ),
55
  ),
56
  ),
57
+
58
+ // Quick filter
59
+ apply_filters( PT_CV_PREFIX_ . 'term_quick_filter', array() ),
60
+
61
+ //Operator
62
  array(
63
  'label' => array(
64
+ 'text' => __( 'Operator', PT_CV_DOMAIN ),
 
65
  ),
66
  'params' => array(
67
  array(
68
+ 'type' => 'radio',
69
+ 'name' => $taxonomy_slug . '-operator',
70
+ 'options' => PT_CV_Values::taxonomy_operators(),
71
+ 'std' => 'IN',
 
 
72
  ),
73
  ),
74
  ),
includes/values.php CHANGED
@@ -41,25 +41,25 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
41
 
42
  return $result;
43
  }
44
-
45
  /**
46
  * Get list of post types and related taxonomies
47
- *
48
  * @return array
49
  */
50
  static function post_types_vs_taxonomies() {
51
  // Get post types
52
  $args = apply_filters( PT_CV_PREFIX_ . 'post_types', array( 'public' => true, 'show_ui' => true, '_builtin' => true ) );
53
  $post_types = get_post_types( $args );
54
-
55
  // Get taxonomies of post types
56
  $result = array();
57
-
58
  foreach ( $post_types as $post_type ) {
59
  $taxonomy_names = get_object_taxonomies( $post_type );
60
  $result[$post_type] = $taxonomy_names;
61
  }
62
-
63
  return $result;
64
  }
65
 
@@ -95,6 +95,18 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
95
  );
96
  }
97
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  /**
99
  * Get taxonomies of Post type
100
  *
41
 
42
  return $result;
43
  }
44
+
45
  /**
46
  * Get list of post types and related taxonomies
47
+ *
48
  * @return array
49
  */
50
  static function post_types_vs_taxonomies() {
51
  // Get post types
52
  $args = apply_filters( PT_CV_PREFIX_ . 'post_types', array( 'public' => true, 'show_ui' => true, '_builtin' => true ) );
53
  $post_types = get_post_types( $args );
54
+
55
  // Get taxonomies of post types
56
  $result = array();
57
+
58
  foreach ( $post_types as $post_type ) {
59
  $taxonomy_names = get_object_taxonomies( $post_type );
60
  $result[$post_type] = $taxonomy_names;
61
  }
62
+
63
  return $result;
64
  }
65
 
95
  );
96
  }
97
 
98
+ /**
99
+ * Operator to join. Possible values are 'IN'(default), 'NOT IN', 'AND'.
100
+ * @return type
101
+ */
102
+ static function taxonomy_operators() {
103
+ return array(
104
+ 'IN' => __( 'IN (A post is displayed only if it associated with one of values in terms list)', PT_CV_DOMAIN ),
105
+ 'NOT IN' => __( 'NOT IN (A post is displayed only if it did NOT associated with any values in terms list)', PT_CV_DOMAIN ),
106
+ 'AND' => __( 'AND (A post is displayed only if it associated with all values in terms list)', PT_CV_DOMAIN ),
107
+ );
108
+ }
109
+
110
  /**
111
  * Get taxonomies of Post type
112
  *