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

Version Description

  • Tested up to: 4.2.2
  • Bug fixed: Fix WordPress bug which can't get valid thumbnail if meta field "_thumbnail_id" is string value instead of integer value
  • Update: Add class for taxonomies in View output
  • Bug fixed: Multiple paginations don't work in same page
  • Update: Restructure plugin's core functions
Download this release

Release Info

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

Code changes from version 1.5.7.1 to 1.6.0

README.txt CHANGED
@@ -3,8 +3,8 @@ 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, column, 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.2.1
7
- Stable tag: 1.5.7.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -165,6 +165,13 @@ function my_move_bootstrap( $args ) {
165
 
166
  == Changelog ==
167
 
 
 
 
 
 
 
 
168
  = 1.5.7.1 =
169
  * Update: Show confirm message before close a View page to prevent missing changes
170
  * Tested up to: 4.2.1
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, column, 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.2.2
7
+ Stable tag: 1.6.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
165
 
166
  == Changelog ==
167
 
168
+ = 1.6.0 =
169
+ * Tested up to: 4.2.2
170
+ * Bug fixed: Fix WordPress bug which can't get valid thumbnail if meta field "_thumbnail_id" is string value instead of integer value
171
+ * Update: Add class for taxonomies in View output
172
+ * Bug fixed: Multiple paginations don't work in same page
173
+ * Update: Restructure plugin's core functions
174
+
175
  = 1.5.7.1 =
176
  * Update: Show confirm message before close a View page to prevent missing changes
177
  * Tested up to: 4.2.1
admin/assets/css/admin.css CHANGED
@@ -9,6 +9,8 @@
9
  */
10
 
11
  /* Overwrite WP */
 
 
12
  .update-nag {
13
  display: none;
14
  }
@@ -106,6 +108,7 @@ html {
106
  }
107
 
108
  .pt-cv-w200 select,
 
109
  .pt-cv-w200 radio {
110
  width: 200px;
111
  float: left;
9
  */
10
 
11
  /* Overwrite WP */
12
+ .wrap .updated,
13
+ .wrap .error,
14
  .update-nag {
15
  display: none;
16
  }
108
  }
109
 
110
  .pt-cv-w200 select,
111
+ .pt-cv-w200 input,
112
  .pt-cv-w200 radio {
113
  width: 200px;
114
  float: left;
admin/assets/js/admin.js CHANGED
@@ -12,6 +12,8 @@
12
  "use strict";
13
 
14
  $.PT_CV_Admin = $.PT_CV_Admin || { };
 
 
15
 
16
  $.PT_CV_Admin = function ( options ) {
17
  this.options = options;
@@ -72,7 +74,9 @@
72
  /**
73
  * Toggle Taxonomy Relation setting by number of selected taxonomies
74
  *
75
- * @returns void
 
 
76
  */
77
  _do_toggle_taxonomy_relation: function ( $taxonomy_relation, $wrap_taxonomies ) {
78
  var $self = this;
@@ -352,7 +356,7 @@
352
  /**
353
  * Preview handle
354
  *
355
- * @param string _nonce
356
  * @returns {undefined}
357
  */
358
  preview: function ( _nonce ) {
@@ -419,10 +423,10 @@
419
  /**
420
  * Send preview Ajax request
421
  *
422
- * @param object preview_box The jqurey object
423
- * @param string _data
424
- * @param string _nonce The generated nonce
425
- * @param object $this_btn The Show/Hide preview button
426
  * @returns void
427
  */
428
  _preview_request: function ( preview_box, _data, _nonce, $this_btn ) {
@@ -440,8 +444,12 @@
440
  $.ajax( {
441
  type: "POST",
442
  url: ajaxurl,
443
- data: data,
444
  } ).done( function ( response ) {
 
 
 
 
445
  preview_box.css( 'opacity', '1' );
446
  // Hide loading icon
447
  preview_box.next().addClass( 'hidden' );
@@ -456,7 +464,7 @@
456
  $self.options.can_preview = 0;
457
 
458
  // Trigger action, to recall function such as pagination, pinterest render layout...
459
- $( 'body' ).trigger( _prefix + 'custom-trigger' );
460
  } );
461
  },
462
  /**
@@ -501,6 +509,10 @@
501
 
502
  /**
503
  * Toggle 'Layout format' when change 'View type'
 
 
 
 
504
  */
505
  var fn_layout_format = function ( this_val, layout_format ) {
506
  var expect_val = [ 'scrollable' ];
@@ -629,9 +641,8 @@
629
  } );
630
 
631
  // Handle Pagination actions
632
- $( 'body' ).bind( _prefix + 'custom-trigger', function () {
633
- var $pt_cv_public_js = new $.PT_CV_Public( { _prefix: _prefix, _autoload: 0 } );
634
- $pt_cv_public_js.pagination();
635
  } );
636
 
637
  // Prevent missing changes
@@ -650,7 +661,7 @@
650
  }
651
  return message;
652
  }
653
- }
654
- },
655
  };
656
  }( jQuery ) );
12
  "use strict";
13
 
14
  $.PT_CV_Admin = $.PT_CV_Admin || { };
15
+ PT_CV_ADMIN = PT_CV_ADMIN || { };
16
+ ajaxurl = ajaxurl || { };
17
 
18
  $.PT_CV_Admin = function ( options ) {
19
  this.options = options;
74
  /**
75
  * Toggle Taxonomy Relation setting by number of selected taxonomies
76
  *
77
+ * @param {type} $taxonomy_relation
78
+ * @param {type} $wrap_taxonomies
79
+ * @returns {undefined}
80
  */
81
  _do_toggle_taxonomy_relation: function ( $taxonomy_relation, $wrap_taxonomies ) {
82
  var $self = this;
356
  /**
357
  * Preview handle
358
  *
359
+ * @param {string} _nonce
360
  * @returns {undefined}
361
  */
362
  preview: function ( _nonce ) {
423
  /**
424
  * Send preview Ajax request
425
  *
426
+ * @param {object} preview_box The jqurey object
427
+ * @param {string} _data
428
+ * @param {string} _nonce The generated nonce
429
+ * @param {object} $this_btn The Show/Hide preview button
430
  * @returns void
431
  */
432
  _preview_request: function ( preview_box, _data, _nonce, $this_btn ) {
444
  $.ajax( {
445
  type: "POST",
446
  url: ajaxurl,
447
+ data: data
448
  } ).done( function ( response ) {
449
+ if ( response == -1 ) {
450
+ location.reload();
451
+ }
452
+
453
  preview_box.css( 'opacity', '1' );
454
  // Hide loading icon
455
  preview_box.next().addClass( 'hidden' );
464
  $self.options.can_preview = 0;
465
 
466
  // Trigger action, to recall function such as pagination, pinterest render layout...
467
+ $( 'body' ).trigger( _prefix + 'admin-preview' );
468
  } );
469
  },
470
  /**
509
 
510
  /**
511
  * Toggle 'Layout format' when change 'View type'
512
+ *
513
+ * @param {type} this_val
514
+ * @param {type} layout_format
515
+ * @returns {undefined}
516
  */
517
  var fn_layout_format = function ( this_val, layout_format ) {
518
  var expect_val = [ 'scrollable' ];
641
  } );
642
 
643
  // Handle Pagination actions
644
+ $( 'body' ).bind( _prefix + 'admin-preview', function () {
645
+ new $.PT_CV_Public( { _prefix: _prefix } );
 
646
  } );
647
 
648
  // Prevent missing changes
661
  }
662
  return message;
663
  }
664
+ };
665
+ }
666
  };
667
  }( jQuery ) );
admin/views/view.php CHANGED
@@ -110,7 +110,7 @@ PT_CV_Functions::view_submit();
110
 
111
  <!-- Save -->
112
  <input type="submit" class="btn btn-primary pull-right <?php echo esc_attr( PT_CV_PREFIX ); ?>save-view" value="<?php _e( 'Save', PT_CV_DOMAIN ); ?>">
113
- <?php do_action( PT_CV_PREFIX_ . 'admin_more_buttons' ); ?>
114
 
115
  <!-- Nav tabs -->
116
  <ul class="nav nav-tabs">
110
 
111
  <!-- Save -->
112
  <input type="submit" class="btn btn-primary pull-right <?php echo esc_attr( PT_CV_PREFIX ); ?>save-view" value="<?php _e( 'Save', PT_CV_DOMAIN ); ?>">
113
+ <?php do_action( PT_CV_PREFIX_ . 'admin_more_buttons' ); ?>
114
 
115
  <!-- Nav tabs -->
116
  <ul class="nav nav-tabs">
content-views.php CHANGED
@@ -11,7 +11,7 @@
11
  * Plugin Name: Content Views
12
  * Plugin URI: http://wordpress.org/plugins/content-views-query-and-display-post-page/
13
  * Description: Query and display <strong>posts, pages</strong> in awesome layouts (<strong>grid, scrollable list, collapsible list</strong>) easier than ever, without coding!
14
- * Version: 1.5.7.1
15
  * Author: PT Guy
16
  * Author URI: http://profiles.wordpress.org/pt-guy
17
  * Text Domain: content-views
@@ -27,7 +27,7 @@ if ( !defined( 'WPINC' ) ) {
27
  /*
28
  * Define Constant
29
  */
30
- define( 'PT_CV_VERSION', '1.5.7.1' );
31
  define( 'PT_CV_FILE', __FILE__ );
32
  $pt_cv_path = plugin_dir_path( __FILE__ );
33
  include_once( $pt_cv_path . 'includes/defines.php' );
11
  * Plugin Name: Content Views
12
  * Plugin URI: http://wordpress.org/plugins/content-views-query-and-display-post-page/
13
  * Description: Query and display <strong>posts, pages</strong> in awesome layouts (<strong>grid, scrollable list, collapsible list</strong>) easier than ever, without coding!
14
+ * Version: 1.6.0
15
  * Author: PT Guy
16
  * Author URI: http://profiles.wordpress.org/pt-guy
17
  * Text Domain: content-views
27
  /*
28
  * Define Constant
29
  */
30
+ define( 'PT_CV_VERSION', '1.6.0' );
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
@@ -249,11 +249,12 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
249
  $string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string );
250
 
251
  # allow some tags
252
- global $dargs;
 
253
  # predefined allowable HTML tags
254
  $allowable_tags = (array) apply_filters( PT_CV_PREFIX_ . 'allowable_tags', array( '<a>', '<br>', '<strong>', '<em>', '<strike>', '<i>', '<ul>', '<ol>', '<li>' ) );
255
  $allowed_tags = '';
256
- if ( !empty( $dargs[ 'field-settings' ][ 'content' ][ 'allow_html' ] ) ) {
257
  $allowed_tags = implode( '', $allowable_tags );
258
 
259
  // Changes double line-breaks in the text into HTML paragraphs (<p>, <br>)
@@ -335,16 +336,17 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
335
  * @param bool $backend Get settings from Backend form
336
  */
337
  static function settings_values_by_prefix( $prefix, $backend = FALSE ) {
338
- global $pt_view_settings;
339
 
340
- if ( !$pt_view_settings && $backend ) {
 
 
341
  global $pt_cv_admin_settings;
342
- $pt_view_settings = $pt_cv_admin_settings;
343
  }
344
 
345
  $result = array();
346
 
347
- foreach ( (array) $pt_view_settings as $name => $value ) {
348
  // If name of setting match with prefix string, got it name
349
  if ( substr( $name, 0, strlen( $prefix ) ) === $prefix ) {
350
  $result[ substr( $name, strlen( $prefix ) ) ] = $value;
@@ -362,7 +364,7 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
362
  * @return string
363
  */
364
  static function post_terms( $post ) {
365
- global $pt_post_terms;
366
 
367
 
368
  // List of HTML link to terms
@@ -381,13 +383,13 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
381
 
382
  foreach ( $terms as $term ) {
383
  $links[] = sprintf(
384
- '<a href="%1$s" title="%2$s %3$s">%3$s</a>', esc_url( get_term_link( $term, $term->taxonomy ) ), __( 'View all posts in', PT_CV_DOMAIN ), $term->name
385
  );
386
 
387
- if ( !isset( $pt_post_terms[ $post_id ] ) ) {
388
- $pt_post_terms[ $post_id ] = array();
389
  }
390
- $pt_post_terms[ $post_id ][ $term->slug ] = $term->name;
391
  }
392
 
393
  return implode( ', ', $links );
@@ -582,40 +584,59 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
582
  * if processed => hide it
583
  * @since 1.5.2
584
  */
585
- global $processed_views, $pt_cv_shortcode_params;
586
- // Same View but has different shortcode parameters => consider as 2 different Views
587
- $vid = $id . '-' . md5( serialize( $pt_cv_shortcode_params ) );
588
- if ( !empty( $processed_views[ $vid ] ) ) {
589
- return '';
590
  }
591
- $processed_views[ $vid ] = 1;
592
 
593
- // Escaped value appropriate for use in a SQL query
594
- global $pt_view_settings;
 
 
595
 
596
- $pt_view_settings = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
597
  foreach ( $settings as $key => $value ) {
598
- $pt_view_settings[ $key ] = esc_sql( $value );
599
  }
 
600
 
601
  // Get content type
602
- global $pt_content_type;
603
- $pt_content_type = $content_type = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'content-type', $pt_view_settings );
604
- $content_type = apply_filters( PT_CV_PREFIX_ . 'content_type', $content_type, $id );
605
 
606
  // Get view type
607
- global $pt_view_type;
608
- $pt_view_type = $view_type = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'view-type', $pt_view_settings );
609
-
610
- // Store display settings
611
- global $dargs, $pt_query_args, $pt_view_sid;
612
 
 
613
  $session_id = ( $pargs && isset( $pargs[ 'session_id' ] ) ) ? $pargs[ 'session_id' ] : 0;
614
 
615
- // If is pagination request
 
 
 
 
 
 
 
616
  if ( $session_id ) {
617
- if ( empty( $pt_view_sid ) ) {
618
- $pt_view_sid = $session_id;
619
  }
620
 
621
  $session_data = array_merge(
@@ -625,20 +646,17 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
625
  $args = $session_data[ '$args' ];
626
  $dargs = $session_data[ '$dargs' ];
627
  } else {
628
- // If id is passed, assign it to session id, otherwise, generate random number
629
- $pt_view_sid = $session_id = $id ? $id : PT_CV_Functions::string_random();
630
 
631
  // Store settings
632
  set_transient( PT_CV_PREFIX . 'view-settings-' . $session_id, $settings, 7 * DAY_IN_SECONDS );
633
  }
634
 
 
635
  if ( empty( $args ) || empty( $dargs ) ) {
636
- $args = PT_CV_Functions::view_filter_settings( $content_type, $pt_view_settings );
637
- $dargs = PT_CV_Functions::view_display_settings( $view_type );
638
-
639
- // Filter
640
- $dargs = apply_filters( PT_CV_PREFIX_ . 'all_display_settings', $dargs );
641
- $args = apply_filters( PT_CV_PREFIX_ . 'query_parameters', $args );
642
 
643
  // Store view data
644
  set_transient(
@@ -652,6 +670,11 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
652
  // Pagination settings
653
  PT_CV_Functions::view_get_pagination_settings( $dargs, $args, $pargs );
654
 
 
 
 
 
 
655
  // Validate settings, if some required parameters are missing, show error and exit
656
  $error = apply_filters( PT_CV_PREFIX_ . 'validate_settings', array(), $args );
657
 
@@ -660,35 +683,34 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
660
  return ( implode( '</p><p>', $error ) );
661
  }
662
 
663
- // Update global query parameters variable
664
- $pt_query_args = $args;
665
-
666
- do_action( PT_CV_PREFIX_ . 'add_global_variables' );
667
-
668
  /**
669
- * Output Items
670
  */
671
  $pt_query = array();
 
672
  // What kind of content to display
673
- global $pt_display_what;
674
 
675
- $pt_display_what = apply_filters( PT_CV_PREFIX_ . 'display_what', 'post' );
676
- if ( $pt_display_what === 'post' ) {
677
  // Get $content_items & $pt_query
678
  extract( self::get_posts_list( $args, $view_type ) );
679
  } else {
 
680
  $content_items = apply_filters( PT_CV_PREFIX_ . 'view_content', array() );
681
  }
682
 
 
 
 
683
  /**
684
- * Output Pagination
685
  */
686
  $current_page = self::get_current_page( $pargs );
687
- $html = PT_CV_Html::content_items_wrap( $content_items, $current_page, $args[ 'posts_per_page' ], $id );
688
 
689
  // Append Pagination HTML if this is first page, or not Ajax calling
690
- $type = isset( $dargs[ 'pagination-settings' ][ 'type' ] ) ? $dargs[ 'pagination-settings' ][ 'type' ] : 'ajax';
691
- if ( $pt_query && $args[ 'posts_per_page' ] > 0 && ( ( $type == 'ajax' && $current_page === 1 ) || $type == 'normal' ) ) {
692
  // Total post founds
693
  $found_posts = apply_filters( PT_CV_PREFIX_ . 'found_posts', $pt_query->found_posts );
694
 
@@ -702,6 +724,9 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
702
  $html .= "\n" . PT_CV_Html::pagination_output( $max_num_pages, $current_page, $session_id );
703
  }
704
 
 
 
 
705
  return $html;
706
  }
707
 
@@ -722,6 +747,9 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
722
 
723
  $pt_query = new WP_Query( $args );
724
 
 
 
 
725
  do_action( PT_CV_PREFIX_ . 'after_query' );
726
 
727
  // The Loop
@@ -750,21 +778,18 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
750
  // Restore $wp_query and original Post Data
751
  wp_reset_query();
752
 
753
- // Filter array of items
754
- $content_items = apply_filters( PT_CV_PREFIX_ . 'content_items', $content_items );
755
-
756
- return array( 'content_items' => $content_items, 'pt_query' => $pt_query );
757
  }
758
 
759
  /**
760
  * Get query parameters of View
761
  *
762
  * @param string $content_type The current content type
763
- * @param array $pt_view_settings The settings of View
764
  *
765
  * @return array
766
  */
767
- static function view_filter_settings( $content_type, $pt_view_settings ) {
768
  /**
769
  * Get Query parameters
770
  * Set default values
@@ -776,27 +801,30 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
776
  );
777
 
778
  // Post in
779
- if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__in', $pt_view_settings ) ) {
780
- $post_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__in', $pt_view_settings ) );
781
  $args[ 'post__in' ] = array_map( 'intval', array_filter( $post_in ) );
782
  }
783
 
784
  // Post not in
785
- if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__not_in', $pt_view_settings ) ) {
786
- $post_not_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__not_in', $pt_view_settings ) );
787
  $args[ 'post__not_in' ] = array_map( 'intval', array_filter( $post_not_in ) );
788
  }
789
 
790
- $args[ 'post__not_in' ] = apply_filters( PT_CV_PREFIX_ . 'post__not_in', isset( $args[ 'post__not_in' ] ) ? $args[ 'post__not_in' ] : array(), $pt_view_settings );
791
 
792
  // Parent page
793
  if ( $content_type == 'page' ) {
794
- $post_parent = apply_filters( PT_CV_PREFIX_ . 'post_parent_id', PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post_parent', $pt_view_settings ) );
795
  if ( !empty( $post_parent ) ) {
796
  $args[ 'post_parent' ] = (int) $post_parent;
797
  }
798
  }
799
 
 
 
 
800
  // Advance settings
801
  PT_CV_Functions::view_get_advanced_settings( $args, $content_type );
802
 
@@ -810,10 +838,7 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
810
  *
811
  * @return array
812
  */
813
- static function view_display_settings( $view_type ) {
814
- /**
815
- * Get Display parameters
816
- */
817
  $dargs = array();
818
 
819
  $dargs[ 'view-type' ] = $view_type;
@@ -827,6 +852,9 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
827
  // View type settings
828
  $dargs[ 'view-type-settings' ] = PT_CV_Functions::settings_values_by_prefix( PT_CV_PREFIX . $view_type . '-' );
829
 
 
 
 
830
  return $dargs;
831
  }
832
 
@@ -837,22 +865,23 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
837
  * @param string $content_type The content type
838
  */
839
  static function view_get_advanced_settings( &$args, $content_type ) {
840
- global $pt_view_settings;
841
 
842
- $advanced_settings = (array) PT_CV_Functions::setting_value( PT_CV_PREFIX . 'advanced-settings', $pt_view_settings );
 
 
843
  if ( $advanced_settings ) {
844
  foreach ( $advanced_settings as $setting ) {
845
  switch ( $setting ) {
846
 
847
  // Author
848
  case 'author':
849
- $author_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'author__in', $pt_view_settings ) );
850
 
851
  // Check if using Wordpress version 3.7 or higher
852
  $version_gt_37 = PT_CV_Functions::wp_version_compare( '3.7' );
853
 
854
  if ( $version_gt_37 ) {
855
- $author_not_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'author__not_in', $pt_view_settings ) );
856
 
857
  // Author in
858
  if ( !empty( $author_in[ 0 ] ) ) {
@@ -888,17 +917,17 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
888
  case 'status':
889
  $args = array_merge(
890
  $args, array(
891
- 'post_status' => PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post_status', $pt_view_settings, 'publish' ) ),
892
  )
893
  );
894
  break;
895
 
896
  // Search
897
  case 'search':
898
- if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 's', $pt_view_settings ) ) {
899
  $args = array_merge(
900
  $args, array(
901
- 's' => PT_CV_Functions::setting_value( PT_CV_PREFIX . 's', $pt_view_settings ),
902
  )
903
  );
904
  }
@@ -907,7 +936,7 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
907
  // Taxonomy
908
  case 'taxonomy':
909
  // No taxonomy found
910
- if ( !PT_CV_Functions::setting_value( PT_CV_PREFIX . 'taxonomy', $pt_view_settings ) ) {
911
  break;
912
  }
913
 
@@ -915,18 +944,18 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
915
  $taxonomy_setting = array();
916
 
917
  // Selected taxonomies
918
- $taxonomies = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'taxonomy', $pt_view_settings );
919
 
920
  // Get Terms & criterias (In, Not in)
921
  foreach ( $taxonomies as $taxonomy ) {
922
- if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '-terms', $pt_view_settings ) ) {
923
  // Get operator
924
- $operator = PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '-operator', $pt_view_settings, 'IN' );
925
 
926
  $taxonomy_setting[] = array(
927
  'taxonomy' => $taxonomy,
928
  'field' => 'slug',
929
- 'terms' => (array) PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '-terms', $pt_view_settings ),
930
  'operator' => $operator,
931
  'include_children' => apply_filters( PT_CV_PREFIX_ . 'include_children', true )
932
  );
@@ -935,7 +964,7 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
935
 
936
  // Get Taxonomy relation if there are more than 1 selected taxonomies | set In & Not in of a taxonomy
937
  if ( count( $taxonomies ) > 1 || count( $taxonomy_setting ) > 1 ) {
938
- $taxonomy_setting[ 'relation' ] = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'taxonomy-relation', $pt_view_settings, 'AND' );
939
  }
940
 
941
  // Filter taxonomy with Custom post types
@@ -948,8 +977,8 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
948
  case 'order':
949
  $order_settings = apply_filters(
950
  PT_CV_PREFIX_ . 'order_setting', array(
951
- 'orderby' => PT_CV_Functions::setting_value( PT_CV_PREFIX . 'orderby', $pt_view_settings ),
952
- 'order' => PT_CV_Functions::setting_value( PT_CV_PREFIX . 'order', $pt_view_settings ),
953
  )
954
  );
955
 
@@ -969,20 +998,21 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
969
  * @param array $dargs The settings array of Fields
970
  */
971
  static function view_get_display_settings( &$dargs ) {
972
- global $pt_view_settings;
 
973
 
974
  $view_type = $dargs[ 'view-type' ];
975
 
976
  /**
977
  * Layout format
978
  */
979
- $dargs[ 'layout-format' ] = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'layout-format', $pt_view_settings );
980
 
981
  /**
982
  * Columns count & Rows count
983
  */
984
- $dargs[ 'number-columns' ] = apply_filters( PT_CV_PREFIX_ . 'item_per_row', PT_CV_Functions::setting_value( PT_CV_PREFIX . $view_type . '-' . 'number-columns', $pt_view_settings, 1 ) );
985
- $dargs[ 'number-rows' ] = PT_CV_Functions::setting_value( PT_CV_PREFIX . $view_type . '-' . 'number-rows', $pt_view_settings, 1 );
986
 
987
  /**
988
  * Fields settings
@@ -991,7 +1021,7 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
991
  $cfields = (array) array_keys( (array) $cfields_settings );
992
  foreach ( $cfields as $field ) {
993
  // If show this field
994
- if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'show-field-' . $field, $pt_view_settings ) ) {
995
  // Add this field to display fields list
996
  $dargs[ 'fields' ][] = $field;
997
 
@@ -1053,16 +1083,17 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
1053
  * @param array $pargs The pagination settings array
1054
  */
1055
  static function view_get_pagination_settings( &$dargs, &$args, $pargs ) {
1056
- global $pt_view_settings;
 
1057
 
1058
  // Get Limit value
1059
- $limit = trim( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'limit', $pt_view_settings ) );
1060
  $limit = ( empty( $limit ) || $limit === '-1' ) ? 10000000 : (int) $limit;
1061
  $args[ 'limit' ] = $args[ 'posts_per_page' ] = $limit;
1062
  $offset = 0;
1063
 
1064
  // Get pagination enable/disable
1065
- $pagination = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'enable-pagination', $pt_view_settings );
1066
  if ( $pagination ) {
1067
  $prefix = PT_CV_PREFIX . 'pagination-';
1068
  $field_setting = PT_CV_Functions::settings_values_by_prefix( $prefix );
@@ -1173,12 +1204,18 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
1173
  ), $atts
1174
  );
1175
 
1176
- global $pt_cv_shortcode_params;
1177
- $pt_cv_shortcode_params = $atts;
1178
-
1179
  // View meta id
1180
  $id = esc_sql( $atts[ 'id' ] );
1181
 
 
 
 
 
 
 
 
 
 
1182
  // Get View settings
1183
  $settings = PT_CV_Functions::view_get_settings( $id );
1184
 
@@ -1194,10 +1231,16 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
1194
  * @param string $html
1195
  */
1196
  static function view_final_output( $html ) {
1197
- // Print View assets
1198
- ob_start();
1199
- PT_CV_Html::assets_of_view_types();
1200
- $view_assets = ob_get_clean();
 
 
 
 
 
 
1201
 
1202
  return $html . $view_assets;
1203
  }
@@ -1225,7 +1268,6 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
1225
  * Callback function for ajax Preview action 'preview_request'
1226
  */
1227
  static function ajax_callback_preview_request() {
1228
-
1229
  // Validate request
1230
  check_ajax_referer( PT_CV_PREFIX_ . 'ajax_nonce', 'ajax_nonce' );
1231
 
@@ -1235,10 +1277,14 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
1235
  $settings = array();
1236
  parse_str( $_POST[ 'data' ], $settings );
1237
 
 
 
 
1238
  // Show View output
1239
- echo balanceTags( PT_CV_Functions::view_process_settings( null, $settings ) );
1240
 
1241
  do_action( PT_CV_PREFIX_ . 'preview_footer' );
 
1242
  // Must exit
1243
  die;
1244
  }
@@ -1270,7 +1316,7 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
1270
  self::switch_language( $language );
1271
 
1272
  // Show View output
1273
- echo balanceTags( PT_CV_Functions::view_process_settings( null, $settings, $pargs ) );
1274
 
1275
  // Must exit
1276
  die;
@@ -1383,6 +1429,65 @@ if ( !class_exists( 'PT_CV_Functions' ) ) {
1383
  return $paged;
1384
  }
1385
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1386
  }
1387
 
1388
  }
249
  $string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string );
250
 
251
  # allow some tags
252
+
253
+ $dargs = PT_CV_Functions::get_global_variable( 'dargs' );
254
  # predefined allowable HTML tags
255
  $allowable_tags = (array) apply_filters( PT_CV_PREFIX_ . 'allowable_tags', array( '<a>', '<br>', '<strong>', '<em>', '<strike>', '<i>', '<ul>', '<ol>', '<li>' ) );
256
  $allowed_tags = '';
257
+ if ( apply_filters( PT_CV_PREFIX_ . 'enable_options', !empty( $dargs[ 'field-settings' ][ 'content' ][ 'allow_html' ] ), 'allow_html' ) ) {
258
  $allowed_tags = implode( '', $allowable_tags );
259
 
260
  // Changes double line-breaks in the text into HTML paragraphs (<p>, <br>)
336
  * @param bool $backend Get settings from Backend form
337
  */
338
  static function settings_values_by_prefix( $prefix, $backend = FALSE ) {
 
339
 
340
+ $view_settings = PT_CV_Functions::get_global_variable( 'view_settings' );
341
+
342
+ if ( !$view_settings && $backend ) {
343
  global $pt_cv_admin_settings;
344
+ $view_settings = $pt_cv_admin_settings;
345
  }
346
 
347
  $result = array();
348
 
349
+ foreach ( (array) $view_settings as $name => $value ) {
350
  // If name of setting match with prefix string, got it name
351
  if ( substr( $name, 0, strlen( $prefix ) ) === $prefix ) {
352
  $result[ substr( $name, strlen( $prefix ) ) ] = $value;
364
  * @return string
365
  */
366
  static function post_terms( $post ) {
367
+ global $pt_cv_item_terms;
368
 
369
 
370
  // List of HTML link to terms
383
 
384
  foreach ( $terms as $term ) {
385
  $links[] = sprintf(
386
+ '<a href="%1$s" title="%2$s %3$s" class="%4$s">%3$s</a>', esc_url( get_term_link( $term, $term->taxonomy ) ), __( 'View all posts in', PT_CV_DOMAIN ), $term->name, PT_CV_PREFIX . 'tax-' . $term->slug
387
  );
388
 
389
+ if ( !isset( $pt_cv_item_terms[ $post_id ] ) ) {
390
+ $pt_cv_item_terms[ $post_id ] = array();
391
  }
392
+ $pt_cv_item_terms[ $post_id ][ $term->slug ] = $term->name;
393
  }
394
 
395
  return implode( ', ', $links );
584
  * if processed => hide it
585
  * @since 1.5.2
586
  */
587
+ global $pt_cv_processed_view, $pt_cv_glb, $pt_cv_id;
588
+
589
+ // Init global array
590
+ if ( !isset( $pt_cv_glb ) ) {
591
+ $pt_cv_glb = array();
592
  }
 
593
 
594
+ $view_id = !empty( $id ) ? $id : PT_CV_Functions::string_random();
595
+ if ( !isset( $pt_cv_glb[ $view_id ] ) ) {
596
+ $pt_cv_glb[ $view_id ] = array();
597
+ }
598
 
599
+ if ( empty( $pargs ) ) {
600
+ // Same View but has different shortcode parameters => consider as 2 different Views
601
+ $sc_params = isset( $pt_cv_glb[ $view_id ][ 'shortcode_params' ] ) ? $pt_cv_glb[ $view_id ][ 'shortcode_params' ] : PT_CV_Functions::string_random();
602
+ $vid = $view_id . '-' . md5( serialize( $sc_params ) );
603
+ if ( !empty( $pt_cv_processed_view[ $vid ] ) ) {
604
+ return '';
605
+ }
606
+ $pt_cv_processed_view[ $vid ] = 1;
607
+ }
608
+
609
+ /**
610
+ * 1. Get View settings
611
+ */
612
+ $view_settings = array();
613
  foreach ( $settings as $key => $value ) {
614
+ $view_settings[ $key ] = esc_sql( $value );
615
  }
616
+ $pt_cv_glb[ $view_id ][ 'view_settings' ] = $view_settings;
617
 
618
  // Get content type
619
+ $content_type = apply_filters( PT_CV_PREFIX_ . 'content_type', PT_CV_Functions::setting_value( PT_CV_PREFIX . 'content-type', $view_settings ), $id );
620
+ $pt_cv_glb[ $view_id ][ 'content_type' ] = $content_type;
 
621
 
622
  // Get view type
623
+ $view_type = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'view-type', $view_settings );
624
+ $pt_cv_glb[ $view_id ][ 'view_type' ] = $view_type;
 
 
 
625
 
626
+ // If is pagination request
627
  $session_id = ( $pargs && isset( $pargs[ 'session_id' ] ) ) ? $pargs[ 'session_id' ] : 0;
628
 
629
+ // Store main View ID
630
+ // If parent View is not finished
631
+ if ( !isset( $pt_cv_glb[ $pt_cv_id ][ 'finished' ] ) ) {
632
+ $pt_cv_main_id = !empty( $pt_cv_id ) ? $pt_cv_id : $view_id;
633
+ } else {
634
+ $pt_cv_main_id = $view_id;
635
+ }
636
+
637
  if ( $session_id ) {
638
+ if ( empty( $pt_cv_id ) ) {
639
+ $pt_cv_id = $session_id;
640
  }
641
 
642
  $session_data = array_merge(
646
  $args = $session_data[ '$args' ];
647
  $dargs = $session_data[ '$dargs' ];
648
  } else {
649
+ // Assign view id as current View
650
+ $pt_cv_id = $session_id = $view_id;
651
 
652
  // Store settings
653
  set_transient( PT_CV_PREFIX . 'view-settings-' . $session_id, $settings, 7 * DAY_IN_SECONDS );
654
  }
655
 
656
+ // Extract Query & Display settings from settings array
657
  if ( empty( $args ) || empty( $dargs ) ) {
658
+ $dargs = apply_filters( PT_CV_PREFIX_ . 'all_display_settings', PT_CV_Functions::view_display_settings( $view_type, $dargs ) );
659
+ $args = apply_filters( PT_CV_PREFIX_ . 'query_parameters', PT_CV_Functions::view_filter_settings( $content_type, $view_settings ) );
 
 
 
 
660
 
661
  // Store view data
662
  set_transient(
670
  // Pagination settings
671
  PT_CV_Functions::view_get_pagination_settings( $dargs, $args, $pargs );
672
 
673
+ // Update global query parameters variable
674
+ $pt_cv_glb[ $view_id ][ 'dargs' ] = $dargs;
675
+ $pt_cv_glb[ $view_id ][ 'args' ] = $args;
676
+ do_action( PT_CV_PREFIX_ . 'add_global_variables' );
677
+
678
  // Validate settings, if some required parameters are missing, show error and exit
679
  $error = apply_filters( PT_CV_PREFIX_ . 'validate_settings', array(), $args );
680
 
683
  return ( implode( '</p><p>', $error ) );
684
  }
685
 
 
 
 
 
 
686
  /**
687
+ * 2. Output Items
688
  */
689
  $pt_query = array();
690
+
691
  // What kind of content to display
692
+ $pt_cv_glb[ $view_id ][ 'display_what' ] = apply_filters( PT_CV_PREFIX_ . 'display_what', 'post' );
693
 
694
+ if ( $pt_cv_glb[ $view_id ][ 'display_what' ] === 'post' ) {
695
+ // Display posts
696
  // Get $content_items & $pt_query
697
  extract( self::get_posts_list( $args, $view_type ) );
698
  } else {
699
+ // Display categories...
700
  $content_items = apply_filters( PT_CV_PREFIX_ . 'view_content', array() );
701
  }
702
 
703
+ // Restore main View id
704
+ $pt_cv_id = $pt_cv_main_id;
705
+
706
  /**
707
+ * 3. Output Pagination
708
  */
709
  $current_page = self::get_current_page( $pargs );
710
+ $html = PT_CV_Html::content_items_wrap( $content_items, $current_page, $args[ 'posts_per_page' ], $view_id );
711
 
712
  // Append Pagination HTML if this is first page, or not Ajax calling
713
+ if ( $pt_query && $args[ 'posts_per_page' ] > 0 && PT_CV_Functions::is_pagination( $dargs, $current_page ) ) {
 
714
  // Total post founds
715
  $found_posts = apply_filters( PT_CV_PREFIX_ . 'found_posts', $pt_query->found_posts );
716
 
724
  $html .= "\n" . PT_CV_Html::pagination_output( $max_num_pages, $current_page, $session_id );
725
  }
726
 
727
+ // Reset View ID
728
+ $pt_cv_glb[ $pt_cv_id ][ 'finished' ] = 1;
729
+
730
  return $html;
731
  }
732
 
747
 
748
  $pt_query = new WP_Query( $args );
749
 
750
+ //DEBUG_QUERY
751
+ //print_r( $pt_query->request );
752
+
753
  do_action( PT_CV_PREFIX_ . 'after_query' );
754
 
755
  // The Loop
778
  // Restore $wp_query and original Post Data
779
  wp_reset_query();
780
 
781
+ return array( 'content_items' => apply_filters( PT_CV_PREFIX_ . 'content_items', $content_items ), 'pt_query' => $pt_query );
 
 
 
782
  }
783
 
784
  /**
785
  * Get query parameters of View
786
  *
787
  * @param string $content_type The current content type
788
+ * @param array $view_settings The settings of View
789
  *
790
  * @return array
791
  */
792
+ static function view_filter_settings( $content_type, $view_settings ) {
793
  /**
794
  * Get Query parameters
795
  * Set default values
801
  );
802
 
803
  // Post in
804
+ if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__in', $view_settings ) ) {
805
+ $post_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__in', $view_settings ) );
806
  $args[ 'post__in' ] = array_map( 'intval', array_filter( $post_in ) );
807
  }
808
 
809
  // Post not in
810
+ if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__not_in', $view_settings ) ) {
811
+ $post_not_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__not_in', $view_settings ) );
812
  $args[ 'post__not_in' ] = array_map( 'intval', array_filter( $post_not_in ) );
813
  }
814
 
815
+ $args[ 'post__not_in' ] = apply_filters( PT_CV_PREFIX_ . 'post__not_in', isset( $args[ 'post__not_in' ] ) ? $args[ 'post__not_in' ] : array(), $view_settings );
816
 
817
  // Parent page
818
  if ( $content_type == 'page' ) {
819
+ $post_parent = apply_filters( PT_CV_PREFIX_ . 'post_parent_id', PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post_parent', $view_settings ) );
820
  if ( !empty( $post_parent ) ) {
821
  $args[ 'post_parent' ] = (int) $post_parent;
822
  }
823
  }
824
 
825
+ // Force suppress filters
826
+ $args[ 'suppress_filters' ] = true;
827
+
828
  // Advance settings
829
  PT_CV_Functions::view_get_advanced_settings( $args, $content_type );
830
 
838
  *
839
  * @return array
840
  */
841
+ static function view_display_settings( $view_type, &$dargs = null ) {
 
 
 
842
  $dargs = array();
843
 
844
  $dargs[ 'view-type' ] = $view_type;
852
  // View type settings
853
  $dargs[ 'view-type-settings' ] = PT_CV_Functions::settings_values_by_prefix( PT_CV_PREFIX . $view_type . '-' );
854
 
855
+ global $pt_cv_glb, $pt_cv_id;
856
+ $pt_cv_glb[ $pt_cv_id ][ 'dargs' ] = $dargs;
857
+
858
  return $dargs;
859
  }
860
 
865
  * @param string $content_type The content type
866
  */
867
  static function view_get_advanced_settings( &$args, $content_type ) {
 
868
 
869
+ $view_settings = PT_CV_Functions::get_global_variable( 'view_settings' );
870
+
871
+ $advanced_settings = (array) PT_CV_Functions::setting_value( PT_CV_PREFIX . 'advanced-settings', $view_settings );
872
  if ( $advanced_settings ) {
873
  foreach ( $advanced_settings as $setting ) {
874
  switch ( $setting ) {
875
 
876
  // Author
877
  case 'author':
878
+ $author_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'author__in', $view_settings ) );
879
 
880
  // Check if using Wordpress version 3.7 or higher
881
  $version_gt_37 = PT_CV_Functions::wp_version_compare( '3.7' );
882
 
883
  if ( $version_gt_37 ) {
884
+ $author_not_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'author__not_in', $view_settings ) );
885
 
886
  // Author in
887
  if ( !empty( $author_in[ 0 ] ) ) {
917
  case 'status':
918
  $args = array_merge(
919
  $args, array(
920
+ 'post_status' => PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post_status', $view_settings, 'publish' ) ),
921
  )
922
  );
923
  break;
924
 
925
  // Search
926
  case 'search':
927
+ if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 's', $view_settings ) ) {
928
  $args = array_merge(
929
  $args, array(
930
+ 's' => PT_CV_Functions::setting_value( PT_CV_PREFIX . 's', $view_settings ),
931
  )
932
  );
933
  }
936
  // Taxonomy
937
  case 'taxonomy':
938
  // No taxonomy found
939
+ if ( !PT_CV_Functions::setting_value( PT_CV_PREFIX . 'taxonomy', $view_settings ) ) {
940
  break;
941
  }
942
 
944
  $taxonomy_setting = array();
945
 
946
  // Selected taxonomies
947
+ $taxonomies = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'taxonomy', $view_settings );
948
 
949
  // Get Terms & criterias (In, Not in)
950
  foreach ( $taxonomies as $taxonomy ) {
951
+ if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '-terms', $view_settings ) ) {
952
  // Get operator
953
+ $operator = PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '-operator', $view_settings, 'IN' );
954
 
955
  $taxonomy_setting[] = array(
956
  'taxonomy' => $taxonomy,
957
  'field' => 'slug',
958
+ 'terms' => (array) PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '-terms', $view_settings ),
959
  'operator' => $operator,
960
  'include_children' => apply_filters( PT_CV_PREFIX_ . 'include_children', true )
961
  );
964
 
965
  // Get Taxonomy relation if there are more than 1 selected taxonomies | set In & Not in of a taxonomy
966
  if ( count( $taxonomies ) > 1 || count( $taxonomy_setting ) > 1 ) {
967
+ $taxonomy_setting[ 'relation' ] = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'taxonomy-relation', $view_settings, 'AND' );
968
  }
969
 
970
  // Filter taxonomy with Custom post types
977
  case 'order':
978
  $order_settings = apply_filters(
979
  PT_CV_PREFIX_ . 'order_setting', array(
980
+ 'orderby' => PT_CV_Functions::setting_value( PT_CV_PREFIX . 'orderby', $view_settings ),
981
+ 'order' => PT_CV_Functions::setting_value( PT_CV_PREFIX . 'order', $view_settings ),
982
  )
983
  );
984
 
998
  * @param array $dargs The settings array of Fields
999
  */
1000
  static function view_get_display_settings( &$dargs ) {
1001
+
1002
+ $view_settings = PT_CV_Functions::get_global_variable( 'view_settings' );
1003
 
1004
  $view_type = $dargs[ 'view-type' ];
1005
 
1006
  /**
1007
  * Layout format
1008
  */
1009
+ $dargs[ 'layout-format' ] = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'layout-format', $view_settings );
1010
 
1011
  /**
1012
  * Columns count & Rows count
1013
  */
1014
+ $dargs[ 'number-columns' ] = apply_filters( PT_CV_PREFIX_ . 'item_per_row', PT_CV_Functions::setting_value( PT_CV_PREFIX . $view_type . '-' . 'number-columns', $view_settings, 1 ) );
1015
+ $dargs[ 'number-rows' ] = PT_CV_Functions::setting_value( PT_CV_PREFIX . $view_type . '-' . 'number-rows', $view_settings, 1 );
1016
 
1017
  /**
1018
  * Fields settings
1021
  $cfields = (array) array_keys( (array) $cfields_settings );
1022
  foreach ( $cfields as $field ) {
1023
  // If show this field
1024
+ if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'show-field-' . $field, $view_settings ) ) {
1025
  // Add this field to display fields list
1026
  $dargs[ 'fields' ][] = $field;
1027
 
1083
  * @param array $pargs The pagination settings array
1084
  */
1085
  static function view_get_pagination_settings( &$dargs, &$args, $pargs ) {
1086
+
1087
+ $view_settings = PT_CV_Functions::get_global_variable( 'view_settings' );
1088
 
1089
  // Get Limit value
1090
+ $limit = trim( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'limit', $view_settings ) );
1091
  $limit = ( empty( $limit ) || $limit === '-1' ) ? 10000000 : (int) $limit;
1092
  $args[ 'limit' ] = $args[ 'posts_per_page' ] = $limit;
1093
  $offset = 0;
1094
 
1095
  // Get pagination enable/disable
1096
+ $pagination = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'enable-pagination', $view_settings );
1097
  if ( $pagination ) {
1098
  $prefix = PT_CV_PREFIX . 'pagination-';
1099
  $field_setting = PT_CV_Functions::settings_values_by_prefix( $prefix );
1204
  ), $atts
1205
  );
1206
 
 
 
 
1207
  // View meta id
1208
  $id = esc_sql( $atts[ 'id' ] );
1209
 
1210
+ if ( !$id )
1211
+ return 'No view ID';
1212
+
1213
+ // View shortcode parameters
1214
+ global $pt_cv_glb, $pt_cv_sub_id;
1215
+ $pt_cv_glb[ $id ] = array();
1216
+ $pt_cv_glb[ $id ][ 'shortcode_params' ] = $atts;
1217
+ $pt_cv_sub_id = $id;
1218
+
1219
  // Get View settings
1220
  $settings = PT_CV_Functions::view_get_settings( $id );
1221
 
1231
  * @param string $html
1232
  */
1233
  static function view_final_output( $html ) {
1234
+ global $pt_cv_id, $pt_cv_sub_id;
1235
+
1236
+ //DEBUG_STYLE
1237
+ $view_assets = '';
1238
+ if ( $pt_cv_id == $pt_cv_sub_id ) {
1239
+ // Print View assets
1240
+ ob_start();
1241
+ PT_CV_Html::assets_of_view_types();
1242
+ $view_assets = ob_get_clean();
1243
+ }
1244
 
1245
  return $html . $view_assets;
1246
  }
1268
  * Callback function for ajax Preview action 'preview_request'
1269
  */
1270
  static function ajax_callback_preview_request() {
 
1271
  // Validate request
1272
  check_ajax_referer( PT_CV_PREFIX_ . 'ajax_nonce', 'ajax_nonce' );
1273
 
1277
  $settings = array();
1278
  parse_str( $_POST[ 'data' ], $settings );
1279
 
1280
+ // Get View id
1281
+ $view_id = self::url_extract_param( 'id' );
1282
+
1283
  // Show View output
1284
+ echo balanceTags( PT_CV_Functions::view_process_settings( $view_id, $settings ) );
1285
 
1286
  do_action( PT_CV_PREFIX_ . 'preview_footer' );
1287
+
1288
  // Must exit
1289
  die;
1290
  }
1316
  self::switch_language( $language );
1317
 
1318
  // Show View output
1319
+ echo balanceTags( PT_CV_Functions::view_process_settings( $session_id, $settings, $pargs ) );
1320
 
1321
  // Must exit
1322
  die;
1429
  return $paged;
1430
  }
1431
 
1432
+ /**
1433
+ * If has pagination
1434
+ *
1435
+ * @param array $dargs
1436
+ * @param int $current_page
1437
+ * @return bool
1438
+ */
1439
+ static function is_pagination( $dargs, $current_page ) {
1440
+ // Get ajax type
1441
+ $type = isset( $dargs[ 'pagination-settings' ][ 'type' ] ) ? $dargs[ 'pagination-settings' ][ 'type' ] : 'ajax';
1442
+
1443
+ // Get page number of non-ajax pagination
1444
+ $vpage = (int) self::url_extract_param( 'vpage', 1 );
1445
+
1446
+ return $type == 'normal' || ( $type == 'ajax' && ( $current_page === 1 || !empty( $_GET[ 'vpage' ] ) ) && !( $current_page === 1 && $vpage > 1 ) );
1447
+ }
1448
+
1449
+ /**
1450
+ * Extract param's value from URL
1451
+ *
1452
+ * @param string $pname Name of parameter
1453
+ * @return string
1454
+ */
1455
+ static function url_extract_param( $pname, $default = null ) {
1456
+ $query = array();
1457
+ // Get url to extract data
1458
+ $url = $_SERVER[ 'REQUEST_URI' ];
1459
+ if ( strpos( $url, 'admin-ajax.php' ) !== false ) {
1460
+ $url = $_SERVER[ 'HTTP_REFERER' ];
1461
+ }
1462
+
1463
+ $parts = parse_url( $url );
1464
+ if ( isset( $parts[ 'query' ] ) ) {
1465
+ parse_str( $parts[ 'query' ], $query );
1466
+
1467
+ return !empty( $query[ $pname ] ) ? $query[ $pname ] : $default;
1468
+ }
1469
+
1470
+ return $default;
1471
+ }
1472
+
1473
+ /**
1474
+ * Get global variable
1475
+ *
1476
+ * @global array $pt_cv_glb
1477
+ * @global string $pt_cv_id
1478
+ * @param string $variable
1479
+ * @return mixed
1480
+ */
1481
+ static function get_global_variable( $variable ) {
1482
+ global $pt_cv_glb, $pt_cv_id;
1483
+ if ( !$pt_cv_glb || !$pt_cv_id )
1484
+ return null;
1485
+
1486
+ $value = isset( $pt_cv_glb[ $pt_cv_id ][ $variable ] ) ? $pt_cv_glb[ $pt_cv_id ][ $variable ] : null;
1487
+
1488
+ return $value;
1489
+ }
1490
+
1491
  }
1492
 
1493
  }
includes/hooks.php CHANGED
@@ -33,7 +33,8 @@ if ( !class_exists( 'PT_CV_Hooks' ) ) {
33
  * @param array $args The Query parameters array
34
  */
35
  public static function filter_validate_settings( $errors, $args ) {
36
- global $dargs;
 
37
 
38
  // echo "<pre>";
39
  // var_dump( 'query args', $args );
@@ -41,7 +42,7 @@ if ( !class_exists( 'PT_CV_Hooks' ) ) {
41
  // echo "<pre>";
42
  // var_dump( 'display args', $dargs );
43
  // echo "</pre>";
44
- // Prefix string for error message
45
  $messages = array(
46
  'field' => array(
47
  'select' => __( 'Please select an option in : ', PT_CV_DOMAIN ),
33
  * @param array $args The Query parameters array
34
  */
35
  public static function filter_validate_settings( $errors, $args ) {
36
+
37
+ $dargs = PT_CV_Functions::get_global_variable( 'dargs' );
38
 
39
  // echo "<pre>";
40
  // var_dump( 'query args', $args );
42
  // echo "<pre>";
43
  // var_dump( 'display args', $dargs );
44
  // echo "</pre>";
45
+
46
  $messages = array(
47
  'field' => array(
48
  'select' => __( 'Please select an option in : ', PT_CV_DOMAIN ),
includes/html-viewtype.php CHANGED
@@ -27,7 +27,8 @@ if ( !class_exists( 'PT_CV_Html_ViewType' ) ) {
27
  * @return array
28
  */
29
  static function process_column_width( $content_items ) {
30
- global $dargs;
 
31
 
32
  // -- Get column span
33
 
@@ -63,7 +64,8 @@ if ( !class_exists( 'PT_CV_Html_ViewType' ) ) {
63
  * @return array Array of rows, each row contains columns
64
  */
65
  static function grid_wrapper( $content_items, &$content ) {
66
- global $pt_cv_enable_filter;
 
67
 
68
  list( $columns, $span_width_last, $span_width, $span_class, $row_class ) = self::process_column_width( $content_items );
69
 
@@ -89,7 +91,7 @@ if ( !class_exists( 'PT_CV_Html_ViewType' ) ) {
89
  $list_item = implode( "\n", $row_html );
90
 
91
  // Only wrap in row if shuffle filter is not enable
92
- if ( $pt_cv_enable_filter != 'yes' ) {
93
  $list_item = sprintf( '<div class="%s">%s</div>', esc_attr( $row_class ), $list_item );
94
  }
95
 
@@ -139,7 +141,8 @@ if ( !class_exists( 'PT_CV_Html_ViewType' ) ) {
139
  * @return array Array of rows, each row contains columns
140
  */
141
  static function scrollable_wrapper( $content_items, &$content ) {
142
- global $dargs;
 
143
 
144
  // ID for the wrapper of scrollable list
145
  $wrapper_id = PT_CV_Functions::string_random();
@@ -184,7 +187,8 @@ if ( !class_exists( 'PT_CV_Html_ViewType' ) ) {
184
  * @return array
185
  */
186
  static function scrollable_content( $content_items ) {
187
- global $dargs;
 
188
 
189
  // Store content of a Scrollable list
190
  $scrollable_content = array();
27
  * @return array
28
  */
29
  static function process_column_width( $content_items ) {
30
+
31
+ $dargs = PT_CV_Functions::get_global_variable( 'dargs' );
32
 
33
  // -- Get column span
34
 
64
  * @return array Array of rows, each row contains columns
65
  */
66
  static function grid_wrapper( $content_items, &$content ) {
67
+
68
+ $enable_filter = PT_CV_Functions::get_global_variable( 'enable_filter' );
69
 
70
  list( $columns, $span_width_last, $span_width, $span_class, $row_class ) = self::process_column_width( $content_items );
71
 
91
  $list_item = implode( "\n", $row_html );
92
 
93
  // Only wrap in row if shuffle filter is not enable
94
+ if ( $enable_filter != 'yes' ) {
95
  $list_item = sprintf( '<div class="%s">%s</div>', esc_attr( $row_class ), $list_item );
96
  }
97
 
141
  * @return array Array of rows, each row contains columns
142
  */
143
  static function scrollable_wrapper( $content_items, &$content ) {
144
+
145
+ $dargs = PT_CV_Functions::get_global_variable( 'dargs' );
146
 
147
  // ID for the wrapper of scrollable list
148
  $wrapper_id = PT_CV_Functions::string_random();
187
  * @return array
188
  */
189
  static function scrollable_content( $content_items ) {
190
+
191
+ $dargs = PT_CV_Functions::get_global_variable( 'dargs' );
192
 
193
  // Store content of a Scrollable list
194
  $scrollable_content = array();
includes/html.php CHANGED
@@ -168,7 +168,8 @@ if ( !class_exists( 'PT_CV_Html' ) ) {
168
  * @param string $style The style of view type (main, style2...)
169
  */
170
  static function view_type_output( $view_type, $post, $style = 'main' ) {
171
- global $dargs;
 
172
  $content = NULL;
173
 
174
  if ( empty( $view_type ) ) {
@@ -224,7 +225,8 @@ if ( !class_exists( 'PT_CV_Html' ) ) {
224
  * @return string Full HTML output of a item
225
  */
226
  static function content_item_wrap( $html_item, $class = '', $post_id = 0 ) {
227
- global $dargs;
 
228
 
229
  if ( empty( $html_item ) ) {
230
  return '';
@@ -265,17 +267,17 @@ if ( !class_exists( 'PT_CV_Html' ) ) {
265
  */
266
  static function content_items_wrap( $content_items, $current_page,
267
  $post_per_page, $id ) {
268
- global $dargs, $pt_cv_content_items;
 
269
 
270
  if ( empty( $content_items ) ) {
271
  return '';
272
  }
273
 
274
  // Assign as global variable
275
- $pt_cv_content_items = $content_items;
276
 
277
- $type = isset( $dargs[ 'pagination-settings' ][ 'type' ] ) ? $dargs[ 'pagination-settings' ][ 'type' ] : 'ajax';
278
- $display = ( $type == 'ajax' && $current_page === 1 ) || $type == 'normal';
279
 
280
  // 1. Before output
281
  $before_output = $display ? apply_filters( PT_CV_PREFIX_ . 'before_output_html', '' ) : '';
@@ -364,7 +366,8 @@ if ( !class_exists( 'PT_CV_Html' ) ) {
364
  * @return string
365
  */
366
  static function field_item_html( $field_name, $post, $fargs ) {
367
- global $dargs;
 
368
 
369
  if ( empty( $field_name ) ) {
370
  return '';
@@ -463,7 +466,8 @@ if ( !class_exists( 'PT_CV_Html' ) ) {
463
  * @return string
464
  */
465
  static function _field_content( $post, $fargs ) {
466
- global $dargs;
 
467
 
468
  // Get other settings
469
  $oargs = isset( $dargs[ 'other-settings' ] ) ? $dargs[ 'other-settings' ] : array();
@@ -578,7 +582,8 @@ if ( !class_exists( 'PT_CV_Html' ) ) {
578
  * @return string
579
  */
580
  static function _field_thumbnail( $post, $fargs ) {
581
- global $dargs;
 
582
 
583
  // Get layout format
584
  $layout_format = $fargs[ 'layout-format' ];
@@ -607,10 +612,10 @@ if ( !class_exists( 'PT_CV_Html' ) ) {
607
  $dimensions = (array) apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_dimension_output', $dimensions, $fargs );
608
 
609
  // Check if has thumbnail ( has_post_thumbnail doesn't works )
610
- $has_thumbnail = get_the_post_thumbnail( $post_id );
611
- if ( !empty( $has_thumbnail ) ) {
612
  $thumbnail_size = count( $dimensions ) > 1 ? $dimensions : $dimensions[ 0 ];
613
- $html = get_the_post_thumbnail( $post_id, $thumbnail_size, $gargs );
614
  $html = apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_image', $html, $post_id, $dimensions, $fargs );
615
  } else {
616
  $html = apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_not_found', $html, $post, $dimensions, $gargs );
@@ -752,7 +757,8 @@ if ( !class_exists( 'PT_CV_Html' ) ) {
752
  * @return type
753
  */
754
  static function pagination_output( $max_num_pages, $current_page, $session_id ) {
755
- global $dargs;
 
756
 
757
  if ( !$max_num_pages || (int) $max_num_pages === 1 ) {
758
  return '';
@@ -782,17 +788,14 @@ if ( !class_exists( 'PT_CV_Html' ) ) {
782
  * by merging css files to public/assets/css/public.css, js files to public/assets/js/public.js
783
  */
784
  static function assets_of_view_types() {
785
- global $processed_view_assets, $pt_view_sid;
786
 
787
  // If already processed | have no View on this page -> return
788
- if ( ( $processed_view_assets && isset( $processed_view_assets[ $pt_view_sid ] ) ) || !$pt_view_sid ) {
789
  return;
790
  }
791
  // Mark as processed
792
- if ( !$processed_view_assets ) {
793
- $processed_view_assets = array();
794
- }
795
- $processed_view_assets[ $pt_view_sid ] = 1;
796
 
797
  // Get settings option
798
  $options = get_option( PT_CV_OPTION_NAME );
168
  * @param string $style The style of view type (main, style2...)
169
  */
170
  static function view_type_output( $view_type, $post, $style = 'main' ) {
171
+
172
+ $dargs = PT_CV_Functions::get_global_variable( 'dargs' );
173
  $content = NULL;
174
 
175
  if ( empty( $view_type ) ) {
225
  * @return string Full HTML output of a item
226
  */
227
  static function content_item_wrap( $html_item, $class = '', $post_id = 0 ) {
228
+
229
+ $dargs = PT_CV_Functions::get_global_variable( 'dargs' );
230
 
231
  if ( empty( $html_item ) ) {
232
  return '';
267
  */
268
  static function content_items_wrap( $content_items, $current_page,
269
  $post_per_page, $id ) {
270
+ global $pt_cv_glb, $pt_cv_id;
271
+ $dargs = PT_CV_Functions::get_global_variable( 'dargs' );
272
 
273
  if ( empty( $content_items ) ) {
274
  return '';
275
  }
276
 
277
  // Assign as global variable
278
+ $pt_cv_glb[ $pt_cv_id ][ 'content_items' ] = $content_items;
279
 
280
+ $display = PT_CV_Functions::is_pagination( $dargs, $current_page );
 
281
 
282
  // 1. Before output
283
  $before_output = $display ? apply_filters( PT_CV_PREFIX_ . 'before_output_html', '' ) : '';
366
  * @return string
367
  */
368
  static function field_item_html( $field_name, $post, $fargs ) {
369
+
370
+ $dargs = PT_CV_Functions::get_global_variable( 'dargs' );
371
 
372
  if ( empty( $field_name ) ) {
373
  return '';
466
  * @return string
467
  */
468
  static function _field_content( $post, $fargs ) {
469
+
470
+ $dargs = PT_CV_Functions::get_global_variable( 'dargs' );
471
 
472
  // Get other settings
473
  $oargs = isset( $dargs[ 'other-settings' ] ) ? $dargs[ 'other-settings' ] : array();
582
  * @return string
583
  */
584
  static function _field_thumbnail( $post, $fargs ) {
585
+
586
+ $dargs = PT_CV_Functions::get_global_variable( 'dargs' );
587
 
588
  // Get layout format
589
  $layout_format = $fargs[ 'layout-format' ];
612
  $dimensions = (array) apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_dimension_output', $dimensions, $fargs );
613
 
614
  // Check if has thumbnail ( has_post_thumbnail doesn't works )
615
+ $thumbnail_id = get_post_thumbnail_id( $post_id );
616
+ if ( !empty( $thumbnail_id ) ) {
617
  $thumbnail_size = count( $dimensions ) > 1 ? $dimensions : $dimensions[ 0 ];
618
+ $html = wp_get_attachment_image( (int) $thumbnail_id, $thumbnail_size, false, $gargs );
619
  $html = apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_image', $html, $post_id, $dimensions, $fargs );
620
  } else {
621
  $html = apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_not_found', $html, $post, $dimensions, $gargs );
757
  * @return type
758
  */
759
  static function pagination_output( $max_num_pages, $current_page, $session_id ) {
760
+
761
+ $dargs = PT_CV_Functions::get_global_variable( 'dargs' );
762
 
763
  if ( !$max_num_pages || (int) $max_num_pages === 1 ) {
764
  return '';
788
  * by merging css files to public/assets/css/public.css, js files to public/assets/js/public.js
789
  */
790
  static function assets_of_view_types() {
791
+ global $pt_cv_glb, $pt_cv_id;
792
 
793
  // If already processed | have no View on this page -> return
794
+ if ( !empty( $pt_cv_glb[ $pt_cv_id ][ 'applied_assets' ] ) || !$pt_cv_id ) {
795
  return;
796
  }
797
  // Mark as processed
798
+ $pt_cv_glb[ $pt_cv_id ][ 'applied_assets' ] = 1;
 
 
 
799
 
800
  // Get settings option
801
  $options = get_option( PT_CV_OPTION_NAME );
public/assets/css/public.css CHANGED
@@ -166,6 +166,7 @@
166
  -webkit-box-shadow: none !important;
167
  box-shadow: none !important;
168
  margin-left: 0;
 
169
  }
170
 
171
  .pt-cv-pagination a {
166
  -webkit-box-shadow: none !important;
167
  box-shadow: none !important;
168
  margin-left: 0;
169
+ border: 0;
170
  }
171
 
172
  .pt-cv-pagination a {
public/assets/js/public.js CHANGED
@@ -13,16 +13,12 @@
13
 
14
  $.PT_CV_Public = $.PT_CV_Public || { };
15
 
 
 
16
  $.PT_CV_Public = function ( options ) {
17
- this.options = $.extend( {
18
- _autoload: 1
19
- }, options );
20
-
21
- // Autoload all registered functions
22
- if ( this.options._autoload !== 0 ) {
23
- this.move_bootstrap_to_top();
24
- this.pagination();
25
- }
26
  };
27
 
28
  $.PT_CV_Public.prototype = {
@@ -53,12 +49,18 @@
53
  var $self = this;
54
  var _prefix = PT_CV_PUBLIC._prefix;
55
 
 
 
 
 
 
56
  // Bootstrap paginator
57
  $( '.' + _prefix + 'pagination.' + _prefix + 'ajax' ).each( function () {
58
  var this_ = $( this );
59
  var total_pages = $( this ).attr( 'data-totalpages' );
60
  $( this ).bootstrapPaginator( {
61
  bootstrapMajorVersion: 3,
 
62
  totalPages: total_pages,
63
  shouldShowPage: function ( type, page, current ) {
64
  if ( total_pages && total_pages < 10 ) {
@@ -87,9 +89,9 @@
87
  /**
88
  * Get parameters to process pagination
89
  *
90
- * @param object this_
91
- * @param int selected_page
92
- * @param function callback
93
  * @returns {undefined}
94
  */
95
  _setup_pagination: function ( this_, selected_page, callback ) {
@@ -126,11 +128,11 @@
126
  /**
127
  * Get wrapper of selected page
128
  *
129
- * @param string session_id The session id of view
130
- * @param int selected_page The page to show
131
- * @param object spinner The jquery object of loading element
132
- * @param string pages_holder The selector expression of wrapper of pages
133
- * @param null|function callback The callback function
134
  * @returns void
135
  */
136
  _get_page: function ( session_id, selected_page, spinner, pages_holder, callback ) {
@@ -175,9 +177,9 @@
175
  /**
176
  * Show content of selected page
177
  *
178
- * @param int selected_page The page to show
179
- * @param string pages_holder The selector expression of wrapper of pages
180
- * @param null|function callback The callback function
181
  * @returns bool
182
  */
183
  _active_page: function ( selected_page, pages_holder, callback ) {
@@ -205,12 +207,6 @@
205
  }
206
 
207
  // Trigger to make Pinterest layout works when do pagination
208
- if ( $( '.' + _prefix + 'pinterest' ).length || $( '.' + _prefix + 'same-height' ).length ) {
209
- $( 'body' ).trigger( _prefix + 'custom-trigger' );
210
- $( window ).trigger( _prefix + 'resize' );
211
- }
212
-
213
- // Trigger action after pagination finished
214
  $( 'body' ).trigger( _prefix + 'pagination-finished' );
215
 
216
  return page_existed;
@@ -218,7 +214,6 @@
218
  };
219
 
220
  $( function () {
221
-
222
  var _prefix = PT_CV_PUBLIC._prefix;
223
 
224
  // Run at page load
13
 
14
  $.PT_CV_Public = $.PT_CV_Public || { };
15
 
16
+ PT_CV_PUBLIC = PT_CV_PUBLIC || { };
17
+
18
  $.PT_CV_Public = function ( options ) {
19
+ this.options = $.extend( { }, options );
20
+ this.move_bootstrap_to_top();
21
+ this.pagination();
 
 
 
 
 
 
22
  };
23
 
24
  $.PT_CV_Public.prototype = {
49
  var $self = this;
50
  var _prefix = PT_CV_PUBLIC._prefix;
51
 
52
+ // Get current page
53
+ var query_string = window.location.search;
54
+ var vpage = query_string.split( /vpage=/ );
55
+ var current_page = ( vpage[1] !== null && vpage[1] !== undefined ) ? parseInt( vpage[1] ) : 1;
56
+
57
  // Bootstrap paginator
58
  $( '.' + _prefix + 'pagination.' + _prefix + 'ajax' ).each( function () {
59
  var this_ = $( this );
60
  var total_pages = $( this ).attr( 'data-totalpages' );
61
  $( this ).bootstrapPaginator( {
62
  bootstrapMajorVersion: 3,
63
+ currentPage: current_page,
64
  totalPages: total_pages,
65
  shouldShowPage: function ( type, page, current ) {
66
  if ( total_pages && total_pages < 10 ) {
89
  /**
90
  * Get parameters to process pagination
91
  *
92
+ * @param {object} this_
93
+ * @param {int} selected_page
94
+ * @param {function} callback
95
  * @returns {undefined}
96
  */
97
  _setup_pagination: function ( this_, selected_page, callback ) {
128
  /**
129
  * Get wrapper of selected page
130
  *
131
+ * @param {string} session_id The session id of view
132
+ * @param {int} selected_page The page to show
133
+ * @param {object} spinner The jquery object of loading element
134
+ * @param {string} pages_holder The selector expression of wrapper of pages
135
+ * @param {function} callback The callback function
136
  * @returns void
137
  */
138
  _get_page: function ( session_id, selected_page, spinner, pages_holder, callback ) {
177
  /**
178
  * Show content of selected page
179
  *
180
+ * @param {int} selected_page The page to show
181
+ * @param {string} pages_holder The selector expression of wrapper of pages
182
+ * @param {function} callback The callback function
183
  * @returns bool
184
  */
185
  _active_page: function ( selected_page, pages_holder, callback ) {
207
  }
208
 
209
  // Trigger to make Pinterest layout works when do pagination
 
 
 
 
 
 
210
  $( 'body' ).trigger( _prefix + 'pagination-finished' );
211
 
212
  return page_existed;
214
  };
215
 
216
  $( function () {
 
217
  var _prefix = PT_CV_PUBLIC._prefix;
218
 
219
  // Run at page load
public/content-views.php CHANGED
@@ -55,8 +55,6 @@ class PT_Content_Views {
55
  // Update view count of post
56
  add_action( 'wp_head', array( &$this, 'update_view_count' ) );
57
 
58
- add_action( 'wp_head', array( &$this, 'init_global_variables' ) );
59
-
60
  // Output assets content at footer of page
61
  add_action( 'wp_footer', array( 'PT_CV_Html', 'assets_of_view_types' ), 100 );
62
 
@@ -320,14 +318,4 @@ class PT_Content_Views {
320
  }
321
  }
322
 
323
- /**
324
- * Init global variables
325
- *
326
- * @global type $processed_view_assets
327
- */
328
- public function init_global_variables() {
329
- global $processed_view_assets, $processed_views;
330
- $processed_view_assets = $processed_views = array();
331
- }
332
-
333
  }
55
  // Update view count of post
56
  add_action( 'wp_head', array( &$this, 'update_view_count' ) );
57
 
 
 
58
  // Output assets content at footer of page
59
  add_action( 'wp_footer', array( 'PT_CV_Html', 'assets_of_view_types' ), 100 );
60
 
318
  }
319
  }
320
 
 
 
 
 
 
 
 
 
 
 
321
  }
public/templates/scrollable/html/main.php CHANGED
@@ -12,7 +12,6 @@
12
  $html = array();
13
 
14
  $ex_cap_cls = PT_CV_PREFIX . 'cap-w-img';
15
- ;
16
 
17
  $img = strip_tags( isset( $fields_html[ 'thumbnail' ] ) ? $fields_html[ 'thumbnail' ] : '', '<img>' );
18
  if ( !empty( $img ) ) {
12
  $html = array();
13
 
14
  $ex_cap_cls = PT_CV_PREFIX . 'cap-w-img';
 
15
 
16
  $img = strip_tags( isset( $fields_html[ 'thumbnail' ] ) ? $fields_html[ 'thumbnail' ] : '', '<img>' );
17
  if ( !empty( $img ) ) {