Version Description
- Remove shortcodes in excerpt
- Fix Scroll bug when click Show/Hide preview
- Update Pagination setting
- Optimize filters system
- Compatibility update
Download this release
Release Info
Developer | PT Guy |
Plugin | Content Views – Post Grid & List for WordPress |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.6 to 1.2.0
- README.txt +22 -10
- admin/assets/js/admin.js +16 -15
- admin/views/view.php +2 -2
- content-views.php +2 -2
- includes/functions.php +86 -75
- includes/hooks.php +3 -3
- includes/html-viewtype.php +12 -11
- includes/html.php +37 -34
- includes/settings.php +35 -12
- public/assets/js/public.js +6 -1
README.txt
CHANGED
@@ -4,17 +4,18 @@ 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, shortcode, thumbnail, title, content, excerpt, meta, date, author, term, taxonomy, pagination, grid, scrollable, collapsible, list, slide, layout, ui
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 3.9.1
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
-
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
Have you ever wanted to:
|
16 |
|
17 |
-
* display
|
|
|
18 |
* display posts in responsive grid layout
|
19 |
* display posts in descending order of Title
|
20 |
* replace boring Next, Prev button of WordPress theme by a beautiful pagination
|
@@ -27,9 +28,9 @@ How do you do?
|
|
27 |
|
28 |
It is not easy as ABC, isn't it?
|
29 |
|
30 |
-
But now, with Content Views plugin, you can do above things in
|
31 |
|
32 |
-
[Content Views plugin](http://www.contentviewspro.com/?utm_source=wordpress&utm_medium=post&utm_campaign=content-views "Visit Content Views website") provides
|
33 |
|
34 |
* Step 1 : Select criteria (author, category, tag...) to query your wanted posts
|
35 |
* Step 2 : Select a nice layout to display posts
|
@@ -63,11 +64,12 @@ Also, you can import/export 'View' to use in other WordPress sites (Please check
|
|
63 |
|
64 |
= More amazing features: =
|
65 |
|
66 |
-
*
|
67 |
-
* More beautiful output & powerful settings of Grid, Collapsible List, Scrollable List
|
68 |
* Display posts in more Awesome layouts: Pinterest, Timeline
|
|
|
69 |
* Drag & drop to change display order of fields (thumbnail, title, content, meta fields)
|
70 |
-
* Customize Font settings for Title, Content
|
|
|
71 |
* Customize style & text of "Read more" button
|
72 |
* Additional pagination option
|
73 |
* And much more...
|
@@ -90,13 +92,13 @@ Just give a try (30 day money back guarantee), then you will know how it is awes
|
|
90 |
|
91 |
1. Navigate to the 'Add New' in the plugins dashboard
|
92 |
2. Navigate to the 'Upload' area
|
93 |
-
3. Select `
|
94 |
4. Click 'Install Now'
|
95 |
5. Activate the plugin in the Plugin dashboard
|
96 |
|
97 |
= Using FTP =
|
98 |
|
99 |
-
1. Download `
|
100 |
2. Extract the `pt-content-views` directory to your computer
|
101 |
3. Upload the `pt-content-views` directory to the `/wp-content/plugins/` directory
|
102 |
4. Activate the plugin in the Plugin dashboard
|
@@ -146,6 +148,13 @@ You can create Unlimited Views, in Unlimited websites
|
|
146 |
|
147 |
== Changelog ==
|
148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
= 1.1.6 =
|
150 |
* Fix bug auto selected terms which its value is number in Taxonomy settings box
|
151 |
|
@@ -190,6 +199,9 @@ You can create Unlimited Views, in Unlimited websites
|
|
190 |
|
191 |
== Upgrade Notice ==
|
192 |
|
|
|
|
|
|
|
193 |
= 1.1.6 =
|
194 |
Fix bug auto selected terms which its value is number in Taxonomy settings box
|
195 |
|
4 |
Tags: post, posts, page, pages, query, queries, search, display, show, shortcode, thumbnail, title, content, excerpt, meta, date, author, term, taxonomy, pagination, grid, scrollable, collapsible, list, slide, layout, ui
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 3.9.1
|
7 |
+
Stable tag: 1.2.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
+
Display custom posts any where (home page, sidebar, footer widget) in responsive layouts (grid, list) easier than ever, without coding!
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
Have you ever wanted to:
|
16 |
|
17 |
+
* display some specific posts in home page of your WordPress site
|
18 |
+
* display multiple posts in a page
|
19 |
* display posts in responsive grid layout
|
20 |
* display posts in descending order of Title
|
21 |
* replace boring Next, Prev button of WordPress theme by a beautiful pagination
|
28 |
|
29 |
It is not easy as ABC, isn't it?
|
30 |
|
31 |
+
But now, with Content Views plugin, you can do above things in minutes, without any line of code.
|
32 |
|
33 |
+
[Content Views plugin](http://www.contentviewspro.com/?utm_source=wordpress&utm_medium=post&utm_campaign=content-views "Visit Content Views website") provides an intuitive form to query posts and display posts in **responsive** layouts (grid, scrollable list, collapsible list) quickly & easily, in very 3 simple steps:
|
34 |
|
35 |
* Step 1 : Select criteria (author, category, tag...) to query your wanted posts
|
36 |
* Step 2 : Select a nice layout to display posts
|
64 |
|
65 |
= More amazing features: =
|
66 |
|
67 |
+
* Woocommerce support
|
|
|
68 |
* Display posts in more Awesome layouts: Pinterest, Timeline
|
69 |
+
* More beautiful output & powerful settings of Grid, Collapsible List, Scrollable List
|
70 |
* Drag & drop to change display order of fields (thumbnail, title, content, meta fields)
|
71 |
+
* Customize Font settings for Title, Content, Meta fields
|
72 |
+
* Custom style for Thumbnail
|
73 |
* Customize style & text of "Read more" button
|
74 |
* Additional pagination option
|
75 |
* And much more...
|
92 |
|
93 |
1. Navigate to the 'Add New' in the plugins dashboard
|
94 |
2. Navigate to the 'Upload' area
|
95 |
+
3. Select `content-views-query-and-display-post-page.zip` from your computer
|
96 |
4. Click 'Install Now'
|
97 |
5. Activate the plugin in the Plugin dashboard
|
98 |
|
99 |
= Using FTP =
|
100 |
|
101 |
+
1. Download `content-views-query-and-display-post-page.zip`
|
102 |
2. Extract the `pt-content-views` directory to your computer
|
103 |
3. Upload the `pt-content-views` directory to the `/wp-content/plugins/` directory
|
104 |
4. Activate the plugin in the Plugin dashboard
|
148 |
|
149 |
== Changelog ==
|
150 |
|
151 |
+
= 1.2.0 =
|
152 |
+
* Remove shortcodes in excerpt
|
153 |
+
* Fix Scroll bug when click Show/Hide preview
|
154 |
+
* Update Pagination setting
|
155 |
+
* Optimize filters system
|
156 |
+
* Compatibility update
|
157 |
+
|
158 |
= 1.1.6 =
|
159 |
* Fix bug auto selected terms which its value is number in Taxonomy settings box
|
160 |
|
199 |
|
200 |
== Upgrade Notice ==
|
201 |
|
202 |
+
= 1.2.0 =
|
203 |
+
Remove shortcodes in excerpt. Fix Scroll bug when click Show/Hide preview. Update Pagination setting. Optimize filters system. Compatibility update
|
204 |
+
|
205 |
= 1.1.6 =
|
206 |
Fix bug auto selected terms which its value is number in Taxonomy settings box
|
207 |
|
admin/assets/js/admin.js
CHANGED
@@ -404,18 +404,6 @@
|
|
404 |
$preview.removeClass('in');
|
405 |
}
|
406 |
|
407 |
-
/**
|
408 |
-
* Send request
|
409 |
-
*/
|
410 |
-
if ($self.options.can_preview) {
|
411 |
-
|
412 |
-
// Get settings data
|
413 |
-
var data = $('#' + _prefix + 'form-view').serialize();
|
414 |
-
|
415 |
-
// Call handle function
|
416 |
-
$self._preview_request($preview, data, _nonce, $this_btn);
|
417 |
-
}
|
418 |
-
|
419 |
/**
|
420 |
* Animation
|
421 |
*/
|
@@ -428,6 +416,16 @@
|
|
428 |
$('html, body').animate({
|
429 |
scrollTop: $preview.offset().top - 100
|
430 |
}, $self.options.scroll_time);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
431 |
} else {
|
432 |
// Scroll to previous position
|
433 |
$('html, body').animate({
|
@@ -438,7 +436,9 @@
|
|
438 |
$this_btn.html(PT_CV_ADMIN.btn.preview.show);
|
439 |
|
440 |
// Enable preview
|
441 |
-
|
|
|
|
|
442 |
}
|
443 |
});
|
444 |
},
|
@@ -469,11 +469,12 @@
|
|
469 |
data : data,
|
470 |
beforeSend: function () {
|
471 |
// Show loading icon
|
472 |
-
preview_box.next().toggleClass('hidden');
|
473 |
},
|
474 |
}).done(function (response) {
|
|
|
475 |
// Hide loading icon
|
476 |
-
preview_box.next().
|
477 |
|
478 |
// Update content of Preview box
|
479 |
preview_box.html(response);
|
404 |
$preview.removeClass('in');
|
405 |
}
|
406 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
/**
|
408 |
* Animation
|
409 |
*/
|
416 |
$('html, body').animate({
|
417 |
scrollTop: $preview.offset().top - 100
|
418 |
}, $self.options.scroll_time);
|
419 |
+
|
420 |
+
/// Send request
|
421 |
+
$preview.css('opacity', '0.2');
|
422 |
+
// Show loading icon
|
423 |
+
$preview.next().removeClass('hidden');
|
424 |
+
|
425 |
+
// Get settings data
|
426 |
+
var data = $('#' + _prefix + 'form-view').serialize();
|
427 |
+
// Call handle function
|
428 |
+
$self._preview_request($preview, data, _nonce, $this_btn);
|
429 |
} else {
|
430 |
// Scroll to previous position
|
431 |
$('html, body').animate({
|
436 |
$this_btn.html(PT_CV_ADMIN.btn.preview.show);
|
437 |
|
438 |
// Enable preview
|
439 |
+
setTimeout(function(){
|
440 |
+
$self.options.can_preview = 1;
|
441 |
+
}, $self.options.scroll_time);
|
442 |
}
|
443 |
});
|
444 |
},
|
469 |
data : data,
|
470 |
beforeSend: function () {
|
471 |
// Show loading icon
|
472 |
+
// preview_box.next().toggleClass('hidden');
|
473 |
},
|
474 |
}).done(function (response) {
|
475 |
+
preview_box.css('opacity', '1');
|
476 |
// Hide loading icon
|
477 |
+
preview_box.next().addClass('hidden');
|
478 |
|
479 |
// Update content of Preview box
|
480 |
preview_box.html(response);
|
admin/views/view.php
CHANGED
@@ -145,7 +145,7 @@ $options = array(
|
|
145 |
),
|
146 |
|
147 |
apply_filters( PT_CV_PREFIX_ . 'custom_filters', array() ),
|
148 |
-
|
149 |
// Common Filters
|
150 |
array(
|
151 |
'label' => array(
|
@@ -334,7 +334,7 @@ $options = array(
|
|
334 |
'options' => PT_CV_Values::taxonomy_list(),
|
335 |
'std' => '',
|
336 |
'class' => 'taxonomy-item',
|
337 |
-
'desc' => __( 'Select checkbox of taxonomies to filter their terms', PT_CV_DOMAIN ),
|
338 |
),
|
339 |
),
|
340 |
),
|
145 |
),
|
146 |
|
147 |
apply_filters( PT_CV_PREFIX_ . 'custom_filters', array() ),
|
148 |
+
|
149 |
// Common Filters
|
150 |
array(
|
151 |
'label' => array(
|
334 |
'options' => PT_CV_Values::taxonomy_list(),
|
335 |
'std' => '',
|
336 |
'class' => 'taxonomy-item',
|
337 |
+
'desc' => __( 'Select checkbox of taxonomies to filter posts by their terms', PT_CV_DOMAIN ),
|
338 |
),
|
339 |
),
|
340 |
),
|
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.
|
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.
|
31 |
define( 'PT_CV_FILE', __FILE__ );
|
32 |
include_once( plugin_dir_path( __FILE__ ) . 'includes/defines.php' );
|
33 |
|
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.2.0
|
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.2.0' );
|
31 |
define( 'PT_CV_FILE', __FILE__ );
|
32 |
include_once( plugin_dir_path( __FILE__ ) . 'includes/defines.php' );
|
33 |
|
includes/functions.php
CHANGED
@@ -199,7 +199,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
199 |
static function settings_keys( $prefix, $options ) {
|
200 |
$result = array();
|
201 |
foreach ( $options as $option ) {
|
202 |
-
if ( $option['params'] ) {
|
203 |
foreach ( $option['params'] as $params ) {
|
204 |
// If name of setting match with prefix string, got it name
|
205 |
if ( isset( $params['name'] ) && substr( $params['name'], 0, strlen( $prefix ) ) === $prefix ) {
|
@@ -216,12 +216,13 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
216 |
* Get value of some setting options by prefix
|
217 |
*
|
218 |
* @param string $prefix The prefix in name of setting options
|
219 |
-
* @param type $settings_ The settings array
|
220 |
*/
|
221 |
-
static function settings_values_by_prefix( $prefix
|
|
|
|
|
222 |
$result = array();
|
223 |
|
224 |
-
foreach ( $
|
225 |
// If name of setting match with prefix string, got it name
|
226 |
if ( substr( $name, 0, strlen( $prefix ) ) === $prefix ) {
|
227 |
$result[substr( $name, strlen( $prefix ) )] = $value;
|
@@ -239,12 +240,15 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
239 |
* @return string
|
240 |
*/
|
241 |
static function post_terms( $post ) {
|
|
|
242 |
// List of HTML link to terms
|
243 |
$links = array();
|
244 |
|
245 |
// Get list of taxonomies
|
246 |
$taxonomies = get_taxonomies( '', 'names' );
|
247 |
|
|
|
|
|
248 |
// Get lists of terms of this post
|
249 |
$terms = wp_get_object_terms( $post->ID, $taxonomies );
|
250 |
|
@@ -407,13 +411,15 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
407 |
}
|
408 |
|
409 |
// Escaped value appropriate for use in a SQL query
|
410 |
-
$
|
|
|
411 |
foreach ( $settings as $key => $value ) {
|
412 |
-
$
|
413 |
}
|
414 |
|
415 |
// Get content type
|
416 |
-
|
|
|
417 |
|
418 |
/**
|
419 |
* Get Query parameters
|
@@ -426,54 +432,55 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
426 |
);
|
427 |
|
428 |
// Post in
|
429 |
-
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__in', $
|
430 |
-
$post_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__in', $
|
431 |
$args['post__in'] = array_map( 'intval', array_filter( $post_in ) );
|
432 |
}
|
433 |
|
434 |
// Post not in
|
435 |
-
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__not_in', $
|
436 |
-
$post_not_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__not_in', $
|
437 |
$args['post__not_in'] = array_map( 'intval', array_filter( $post_not_in ) );
|
438 |
}
|
439 |
|
440 |
// Parent page
|
441 |
if ( $content_type == 'page' ) {
|
442 |
-
$post_parent = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post_parent', $
|
443 |
if ( ! empty( $post_parent ) ) {
|
444 |
$args['post_parent'] = (int) $post_parent;
|
445 |
}
|
446 |
}
|
447 |
|
448 |
// Advance settings
|
449 |
-
PT_CV_Functions::view_get_advanced_settings( $
|
450 |
|
451 |
/**
|
452 |
* Get Display parameters
|
453 |
*/
|
|
|
454 |
$dargs = array();
|
455 |
|
456 |
// Get view type
|
457 |
-
$view_type = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'view-type', $
|
458 |
|
459 |
$dargs['view-type'] = $view_type;
|
460 |
|
461 |
// Field settings of a item
|
462 |
-
PT_CV_Functions::view_get_display_settings( $
|
463 |
|
464 |
// Pagination settings
|
465 |
-
PT_CV_Functions::view_get_pagination_settings( $
|
466 |
|
467 |
// Other settings
|
468 |
-
PT_CV_Functions::view_get_other_settings( $
|
469 |
|
470 |
// View type settings
|
471 |
-
$dargs['view-type-settings'] = PT_CV_Functions::settings_values_by_prefix( PT_CV_PREFIX . $view_type . '-'
|
472 |
|
473 |
-
$dargs = apply_filters( PT_CV_PREFIX_ . 'all_display_settings', $dargs
|
474 |
|
475 |
// Validate settings before processing, if some required parameters are missing, show error and exit
|
476 |
-
$error = apply_filters( PT_CV_PREFIX_ . 'validate_settings', array(), $
|
477 |
|
478 |
// Return error message
|
479 |
if ( $error ) {
|
@@ -488,13 +495,13 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
488 |
$content_items = array();
|
489 |
|
490 |
// The Query
|
491 |
-
$args = apply_filters( PT_CV_PREFIX_ . 'query_parameters', $args
|
492 |
|
493 |
-
do_action( PT_CV_PREFIX_ . 'before_query'
|
494 |
|
495 |
$pt_query = new WP_Query( $args );
|
496 |
|
497 |
-
do_action( PT_CV_PREFIX_ . 'after_query'
|
498 |
|
499 |
// The Loop
|
500 |
if ( $pt_query->have_posts() ) {
|
@@ -503,7 +510,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
503 |
global $post;
|
504 |
|
505 |
// Output HTML for this item
|
506 |
-
$content_items[] = PT_CV_Html::view_type_output( $view_type, $
|
507 |
}
|
508 |
} else {
|
509 |
// Get no post found class
|
@@ -523,12 +530,12 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
523 |
* Output Pagination
|
524 |
*/
|
525 |
$current_page = ( isset( $pargs['page'] ) && $pargs['page'] > 1 ) ? $pargs['page'] : 1;
|
526 |
-
$html = PT_CV_Html::content_items_wrap( $content_items, $
|
527 |
|
528 |
// Append Pagination HTML if this is first page, or not Ajax calling
|
529 |
if ( $args['posts_per_page'] > 0 && $current_page === 1 ) {
|
530 |
// Total post founds
|
531 |
-
$found_posts = apply_filters( PT_CV_PREFIX_ . 'found_posts', $pt_query->found_posts
|
532 |
|
533 |
// Total number of items
|
534 |
$total_items = ( $args['limit'] > 0 && $found_posts > $args['limit'] ) ? $args['limit'] : $found_posts;
|
@@ -536,7 +543,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
536 |
// Total number of pages
|
537 |
$max_num_pages = ceil( $total_items / $args['posts_per_page'] );
|
538 |
|
539 |
-
$html .= "\n" . PT_CV_Html::pagination_output( $max_num_pages, $
|
540 |
}
|
541 |
|
542 |
return $html;
|
@@ -545,26 +552,26 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
545 |
/**
|
546 |
* Get Advance settings
|
547 |
*
|
548 |
-
* @param array $settings_ The settings array
|
549 |
* @param array $args The parameters array
|
550 |
* @param string $content_type The content type
|
551 |
*/
|
552 |
-
static function view_get_advanced_settings(
|
|
|
553 |
|
554 |
-
$advanced_settings = (array) PT_CV_Functions::setting_value( PT_CV_PREFIX . 'advanced-settings', $
|
555 |
if ( $advanced_settings ) {
|
556 |
foreach ( $advanced_settings as $setting ) {
|
557 |
switch ( $setting ) {
|
558 |
|
559 |
// Author
|
560 |
case 'author':
|
561 |
-
$author_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'author__in', $
|
562 |
|
563 |
// Check if using Wordpress version 3.7 or higher
|
564 |
$version_gt_37 = PT_CV_Functions::wp_version_compare( '3.7' );
|
565 |
|
566 |
if ( $version_gt_37 ) {
|
567 |
-
$author_not_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'author__not_in', $
|
568 |
|
569 |
// Author in
|
570 |
if ( ! empty( $author_in[0] ) ) {
|
@@ -600,17 +607,17 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
600 |
case 'status':
|
601 |
$args = array_merge(
|
602 |
$args, array(
|
603 |
-
'post_status' => PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post_status', $
|
604 |
)
|
605 |
);
|
606 |
break;
|
607 |
|
608 |
// Search
|
609 |
case 'search':
|
610 |
-
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 's', $
|
611 |
$args = array_merge(
|
612 |
$args, array(
|
613 |
-
's' => PT_CV_Functions::setting_value( PT_CV_PREFIX . 's', $
|
614 |
)
|
615 |
);
|
616 |
}
|
@@ -619,7 +626,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
619 |
// Taxonomy
|
620 |
case 'taxonomy':
|
621 |
// No taxonomy found
|
622 |
-
if ( ! PT_CV_Functions::setting_value( PT_CV_PREFIX . 'taxonomy', $
|
623 |
break;
|
624 |
}
|
625 |
|
@@ -627,24 +634,24 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
627 |
$taxonomy_setting = array();
|
628 |
|
629 |
// Selected taxonomies
|
630 |
-
$taxonomies = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'taxonomy', $
|
631 |
|
632 |
// Get Terms & criterias (In, Not in)
|
633 |
foreach ( $taxonomies as $taxonomy ) {
|
634 |
|
635 |
// If found setting for taxonomy
|
636 |
-
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '__in', $
|
637 |
$taxonomy_setting[] = array(
|
638 |
'taxonomy' => $taxonomy,
|
639 |
'field' => 'slug',
|
640 |
-
'terms' => (array) PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '__in', $
|
641 |
);
|
642 |
}
|
643 |
-
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '__not_in', $
|
644 |
$taxonomy_setting[] = array(
|
645 |
'taxonomy' => $taxonomy,
|
646 |
'field' => 'slug',
|
647 |
-
'terms' => (array) PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '__not_in', $
|
648 |
'operator' => 'NOT IN',
|
649 |
);
|
650 |
}
|
@@ -652,7 +659,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
652 |
|
653 |
// Get Taxonomy relation if there are more than 1 selected taxonomies | set In & Not in of a taxonomy
|
654 |
if ( count( $taxonomies ) > 1 || count( $taxonomy_setting ) > 1 ) {
|
655 |
-
$taxonomy_setting['relation'] = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'taxonomy-relation', $
|
656 |
}
|
657 |
|
658 |
// Filter taxonomy with Custom post types
|
@@ -667,29 +674,32 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
667 |
$order_settings = array();
|
668 |
|
669 |
// Advanced order by
|
670 |
-
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . $content_type . '-orderby', $
|
671 |
|
672 |
// Get meta key to order by
|
673 |
-
$meta_key = PT_CV_Functions::setting_value( PT_CV_PREFIX . $content_type . '-orderby', $
|
674 |
|
675 |
// Use 'meta_value_num' for numeric values
|
676 |
-
$
|
677 |
-
$
|
|
|
|
|
|
|
678 |
$order_settings = array(
|
679 |
-
'meta_key' => $meta_key,
|
680 |
'orderby' => $meta_orderby,
|
681 |
-
'order' => PT_CV_Functions::setting_value( PT_CV_PREFIX . 'advanced-order', $
|
682 |
);
|
683 |
|
684 |
} else {
|
685 |
// Common order by
|
686 |
|
687 |
-
$orderby = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'orderby', $
|
688 |
$order_by_options = array_keys( PT_CV_Values::post_regular_orderby() );
|
689 |
if ( in_array( $orderby, $order_by_options ) ) {
|
690 |
$order_settings = array(
|
691 |
'orderby' => $orderby,
|
692 |
-
'order' => PT_CV_Functions::setting_value( PT_CV_PREFIX . 'order', $
|
693 |
);
|
694 |
}
|
695 |
}
|
@@ -707,32 +717,32 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
707 |
/**
|
708 |
* Get Fields settings
|
709 |
*
|
710 |
-
* @param array $settings_ The settings array
|
711 |
* @param array $dargs The settings array of Fields
|
712 |
*/
|
713 |
-
static function view_get_display_settings(
|
|
|
714 |
|
715 |
$view_type = $dargs['view-type'];
|
716 |
|
717 |
/**
|
718 |
* Layout format
|
719 |
*/
|
720 |
-
$dargs['layout-format'] = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'layout-format', $
|
721 |
|
722 |
/**
|
723 |
* Columns count & Rows count
|
724 |
*/
|
725 |
-
$dargs['number-columns'] = PT_CV_Functions::setting_value( PT_CV_PREFIX . $view_type . '-' . 'number-columns', $
|
726 |
-
$dargs['number-rows'] = PT_CV_Functions::setting_value( PT_CV_PREFIX . $view_type . '-' . 'number-rows', $
|
727 |
|
728 |
/**
|
729 |
* Fields settings
|
730 |
*/
|
731 |
-
$cfields_settings = PT_CV_Functions::settings_values_by_prefix( PT_CV_PREFIX . 'show-field-'
|
732 |
$cfields = (array) array_keys( (array) $cfields_settings );
|
733 |
foreach ( $cfields as $field ) {
|
734 |
// If show this field
|
735 |
-
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'show-field-' . $field, $
|
736 |
// Add this field to display fields list
|
737 |
$dargs['fields'][] = $field;
|
738 |
|
@@ -746,9 +756,9 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
746 |
|
747 |
$fields = array( 'position', 'size', 'style' );
|
748 |
$prefix = PT_CV_PREFIX . 'field-thumbnail-';
|
749 |
-
PT_CV_Functions::settings_values( $fields, $field_setting, $
|
750 |
|
751 |
-
$dargs['field-settings'][$field] = apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_setting_values', $field_setting, $
|
752 |
|
753 |
break;
|
754 |
|
@@ -758,12 +768,12 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
758 |
$field_setting = array();
|
759 |
|
760 |
$prefix = PT_CV_PREFIX . 'meta-fields-';
|
761 |
-
$meta_fields_settings = PT_CV_Functions::settings_values_by_prefix( PT_CV_PREFIX . 'meta-fields-'
|
762 |
$fields = (array) array_keys( (array) $meta_fields_settings );
|
763 |
|
764 |
-
PT_CV_Functions::settings_values( $fields, $field_setting, $
|
765 |
|
766 |
-
$dargs['field-settings'][$field] = apply_filters( PT_CV_PREFIX_ . 'field_meta_fields_setting_values', $field_setting, $
|
767 |
|
768 |
break;
|
769 |
|
@@ -774,13 +784,13 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
774 |
|
775 |
$prefix = PT_CV_PREFIX . 'field-content-';
|
776 |
$fields = PT_CV_Functions::settings_keys( 'field-content-', PT_CV_Settings::field_settings() );
|
777 |
-
PT_CV_Functions::settings_values( $fields, $field_setting, $
|
778 |
|
779 |
if ( $field_setting['show'] == 'excerpt' ) {
|
780 |
-
$field_setting = array_merge( $field_setting, PT_CV_Functions::settings_values_by_prefix( PT_CV_PREFIX . 'field-excerpt-'
|
781 |
}
|
782 |
|
783 |
-
$dargs['field-settings'][$field] = apply_filters( PT_CV_PREFIX_ . 'field_content_setting_values', $field_setting, $
|
784 |
|
785 |
break;
|
786 |
|
@@ -794,27 +804,27 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
794 |
/**
|
795 |
* Get Pagination settings
|
796 |
*
|
797 |
-
* @param array $settings_ The settings array
|
798 |
* @param array $dargs The settings array of Fields
|
799 |
* @param array $args The parameters array
|
800 |
* @param array $pargs The pagination settings array
|
801 |
*/
|
802 |
-
static function view_get_pagination_settings(
|
|
|
803 |
|
804 |
// Get Limit value
|
805 |
-
$limit = trim( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'limit', $
|
806 |
$limit = ( empty( $limit ) || $limit === '-1' ) ? 10000000 : (int) $limit;
|
807 |
$args['limit'] = $args['posts_per_page'] = $limit;
|
808 |
$offset = 0;
|
809 |
|
810 |
// Get pagination enable/disable
|
811 |
-
$pagination = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'enable-pagination', $
|
812 |
if ( $pagination ) {
|
813 |
$field_setting = array();
|
814 |
|
815 |
$prefix = PT_CV_PREFIX . 'pagination-';
|
816 |
$fields = PT_CV_Functions::settings_keys( 'pagination-', PT_CV_Settings::settings_pagination() );
|
817 |
-
PT_CV_Functions::settings_values( $fields, $field_setting, $
|
818 |
|
819 |
$dargs['pagination-settings'] = apply_filters( PT_CV_PREFIX_ . 'pagination_settings', $field_setting );
|
820 |
|
@@ -834,7 +844,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
834 |
}
|
835 |
}
|
836 |
|
837 |
-
$offset = apply_filters( PT_CV_PREFIX_ . 'settings_args_offset', $offset
|
838 |
|
839 |
// Not reaching out of limit
|
840 |
if ( $offset < $limit ) {
|
@@ -846,17 +856,18 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
846 |
/**
|
847 |
* Get Other settings
|
848 |
*
|
849 |
-
* @param array $settings_ The settings array
|
850 |
* @param array $dargs The settings array of Fields
|
851 |
*/
|
852 |
-
static function view_get_other_settings(
|
|
|
|
|
853 |
$field_setting = array();
|
854 |
|
855 |
$prefix = PT_CV_PREFIX . 'other-';
|
856 |
$fields = PT_CV_Functions::settings_keys( 'other-', PT_CV_Settings::settings_other() );
|
857 |
-
PT_CV_Functions::settings_values( $fields, $field_setting, $
|
858 |
|
859 |
-
$dargs['other-settings'] = apply_filters( PT_CV_PREFIX_ . 'other_settings', $field_setting
|
860 |
}
|
861 |
|
862 |
/**
|
199 |
static function settings_keys( $prefix, $options ) {
|
200 |
$result = array();
|
201 |
foreach ( $options as $option ) {
|
202 |
+
if ( isset( $option['params'] ) ) {
|
203 |
foreach ( $option['params'] as $params ) {
|
204 |
// If name of setting match with prefix string, got it name
|
205 |
if ( isset( $params['name'] ) && substr( $params['name'], 0, strlen( $prefix ) ) === $prefix ) {
|
216 |
* Get value of some setting options by prefix
|
217 |
*
|
218 |
* @param string $prefix The prefix in name of setting options
|
|
|
219 |
*/
|
220 |
+
static function settings_values_by_prefix( $prefix ) {
|
221 |
+
global $pt_view_settings;
|
222 |
+
|
223 |
$result = array();
|
224 |
|
225 |
+
foreach ( $pt_view_settings as $name => $value ) {
|
226 |
// If name of setting match with prefix string, got it name
|
227 |
if ( substr( $name, 0, strlen( $prefix ) ) === $prefix ) {
|
228 |
$result[substr( $name, strlen( $prefix ) )] = $value;
|
240 |
* @return string
|
241 |
*/
|
242 |
static function post_terms( $post ) {
|
243 |
+
|
244 |
// List of HTML link to terms
|
245 |
$links = array();
|
246 |
|
247 |
// Get list of taxonomies
|
248 |
$taxonomies = get_taxonomies( '', 'names' );
|
249 |
|
250 |
+
$taxonomies = apply_filters( PT_CV_PREFIX_ . 'taxonomies_list', $taxonomies );
|
251 |
+
|
252 |
// Get lists of terms of this post
|
253 |
$terms = wp_get_object_terms( $post->ID, $taxonomies );
|
254 |
|
411 |
}
|
412 |
|
413 |
// Escaped value appropriate for use in a SQL query
|
414 |
+
global $pt_view_settings;
|
415 |
+
$pt_view_settings = array();
|
416 |
foreach ( $settings as $key => $value ) {
|
417 |
+
$pt_view_settings[$key] = esc_sql( $value );
|
418 |
}
|
419 |
|
420 |
// Get content type
|
421 |
+
global $pt_content_type;
|
422 |
+
$pt_content_type = $content_type = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'content-type', $pt_view_settings );
|
423 |
|
424 |
/**
|
425 |
* Get Query parameters
|
432 |
);
|
433 |
|
434 |
// Post in
|
435 |
+
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__in', $pt_view_settings ) ) {
|
436 |
+
$post_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__in', $pt_view_settings ) );
|
437 |
$args['post__in'] = array_map( 'intval', array_filter( $post_in ) );
|
438 |
}
|
439 |
|
440 |
// Post not in
|
441 |
+
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__not_in', $pt_view_settings ) ) {
|
442 |
+
$post_not_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post__not_in', $pt_view_settings ) );
|
443 |
$args['post__not_in'] = array_map( 'intval', array_filter( $post_not_in ) );
|
444 |
}
|
445 |
|
446 |
// Parent page
|
447 |
if ( $content_type == 'page' ) {
|
448 |
+
$post_parent = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post_parent', $pt_view_settings );
|
449 |
if ( ! empty( $post_parent ) ) {
|
450 |
$args['post_parent'] = (int) $post_parent;
|
451 |
}
|
452 |
}
|
453 |
|
454 |
// Advance settings
|
455 |
+
PT_CV_Functions::view_get_advanced_settings( $args, $content_type );
|
456 |
|
457 |
/**
|
458 |
* Get Display parameters
|
459 |
*/
|
460 |
+
global $dargs;
|
461 |
$dargs = array();
|
462 |
|
463 |
// Get view type
|
464 |
+
$view_type = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'view-type', $pt_view_settings );
|
465 |
|
466 |
$dargs['view-type'] = $view_type;
|
467 |
|
468 |
// Field settings of a item
|
469 |
+
PT_CV_Functions::view_get_display_settings( $dargs );
|
470 |
|
471 |
// Pagination settings
|
472 |
+
PT_CV_Functions::view_get_pagination_settings( $dargs, $args, $pargs );
|
473 |
|
474 |
// Other settings
|
475 |
+
PT_CV_Functions::view_get_other_settings( $dargs );
|
476 |
|
477 |
// View type settings
|
478 |
+
$dargs['view-type-settings'] = PT_CV_Functions::settings_values_by_prefix( PT_CV_PREFIX . $view_type . '-' );
|
479 |
|
480 |
+
$dargs = apply_filters( PT_CV_PREFIX_ . 'all_display_settings', $dargs );
|
481 |
|
482 |
// Validate settings before processing, if some required parameters are missing, show error and exit
|
483 |
+
$error = apply_filters( PT_CV_PREFIX_ . 'validate_settings', array(), $args );
|
484 |
|
485 |
// Return error message
|
486 |
if ( $error ) {
|
495 |
$content_items = array();
|
496 |
|
497 |
// The Query
|
498 |
+
$args = apply_filters( PT_CV_PREFIX_ . 'query_parameters', $args );
|
499 |
|
500 |
+
do_action( PT_CV_PREFIX_ . 'before_query' );
|
501 |
|
502 |
$pt_query = new WP_Query( $args );
|
503 |
|
504 |
+
do_action( PT_CV_PREFIX_ . 'after_query' );
|
505 |
|
506 |
// The Loop
|
507 |
if ( $pt_query->have_posts() ) {
|
510 |
global $post;
|
511 |
|
512 |
// Output HTML for this item
|
513 |
+
$content_items[] = PT_CV_Html::view_type_output( $view_type, $post );
|
514 |
}
|
515 |
} else {
|
516 |
// Get no post found class
|
530 |
* Output Pagination
|
531 |
*/
|
532 |
$current_page = ( isset( $pargs['page'] ) && $pargs['page'] > 1 ) ? $pargs['page'] : 1;
|
533 |
+
$html = PT_CV_Html::content_items_wrap( $content_items, $current_page, $args['posts_per_page'] );
|
534 |
|
535 |
// Append Pagination HTML if this is first page, or not Ajax calling
|
536 |
if ( $args['posts_per_page'] > 0 && $current_page === 1 ) {
|
537 |
// Total post founds
|
538 |
+
$found_posts = apply_filters( PT_CV_PREFIX_ . 'found_posts', $pt_query->found_posts );
|
539 |
|
540 |
// Total number of items
|
541 |
$total_items = ( $args['limit'] > 0 && $found_posts > $args['limit'] ) ? $args['limit'] : $found_posts;
|
543 |
// Total number of pages
|
544 |
$max_num_pages = ceil( $total_items / $args['posts_per_page'] );
|
545 |
|
546 |
+
$html .= "\n" . PT_CV_Html::pagination_output( $max_num_pages, $id );
|
547 |
}
|
548 |
|
549 |
return $html;
|
552 |
/**
|
553 |
* Get Advance settings
|
554 |
*
|
|
|
555 |
* @param array $args The parameters array
|
556 |
* @param string $content_type The content type
|
557 |
*/
|
558 |
+
static function view_get_advanced_settings( &$args, $content_type ) {
|
559 |
+
global $pt_view_settings;
|
560 |
|
561 |
+
$advanced_settings = (array) PT_CV_Functions::setting_value( PT_CV_PREFIX . 'advanced-settings', $pt_view_settings );
|
562 |
if ( $advanced_settings ) {
|
563 |
foreach ( $advanced_settings as $setting ) {
|
564 |
switch ( $setting ) {
|
565 |
|
566 |
// Author
|
567 |
case 'author':
|
568 |
+
$author_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'author__in', $pt_view_settings ) );
|
569 |
|
570 |
// Check if using Wordpress version 3.7 or higher
|
571 |
$version_gt_37 = PT_CV_Functions::wp_version_compare( '3.7' );
|
572 |
|
573 |
if ( $version_gt_37 ) {
|
574 |
+
$author_not_in = PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'author__not_in', $pt_view_settings ) );
|
575 |
|
576 |
// Author in
|
577 |
if ( ! empty( $author_in[0] ) ) {
|
607 |
case 'status':
|
608 |
$args = array_merge(
|
609 |
$args, array(
|
610 |
+
'post_status' => PT_CV_Functions::string_to_array( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'post_status', $pt_view_settings, 'publish' ) ),
|
611 |
)
|
612 |
);
|
613 |
break;
|
614 |
|
615 |
// Search
|
616 |
case 'search':
|
617 |
+
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 's', $pt_view_settings ) ) {
|
618 |
$args = array_merge(
|
619 |
$args, array(
|
620 |
+
's' => PT_CV_Functions::setting_value( PT_CV_PREFIX . 's', $pt_view_settings ),
|
621 |
)
|
622 |
);
|
623 |
}
|
626 |
// Taxonomy
|
627 |
case 'taxonomy':
|
628 |
// No taxonomy found
|
629 |
+
if ( ! PT_CV_Functions::setting_value( PT_CV_PREFIX . 'taxonomy', $pt_view_settings ) ) {
|
630 |
break;
|
631 |
}
|
632 |
|
634 |
$taxonomy_setting = array();
|
635 |
|
636 |
// Selected taxonomies
|
637 |
+
$taxonomies = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'taxonomy', $pt_view_settings );
|
638 |
|
639 |
// Get Terms & criterias (In, Not in)
|
640 |
foreach ( $taxonomies as $taxonomy ) {
|
641 |
|
642 |
// If found setting for taxonomy
|
643 |
+
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '__in', $pt_view_settings ) ) {
|
644 |
$taxonomy_setting[] = array(
|
645 |
'taxonomy' => $taxonomy,
|
646 |
'field' => 'slug',
|
647 |
+
'terms' => (array) PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '__in', $pt_view_settings ),
|
648 |
);
|
649 |
}
|
650 |
+
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '__not_in', $pt_view_settings ) ) {
|
651 |
$taxonomy_setting[] = array(
|
652 |
'taxonomy' => $taxonomy,
|
653 |
'field' => 'slug',
|
654 |
+
'terms' => (array) PT_CV_Functions::setting_value( PT_CV_PREFIX . $taxonomy . '__not_in', $pt_view_settings ),
|
655 |
'operator' => 'NOT IN',
|
656 |
);
|
657 |
}
|
659 |
|
660 |
// Get Taxonomy relation if there are more than 1 selected taxonomies | set In & Not in of a taxonomy
|
661 |
if ( count( $taxonomies ) > 1 || count( $taxonomy_setting ) > 1 ) {
|
662 |
+
$taxonomy_setting['relation'] = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'taxonomy-relation', $pt_view_settings, 'AND' );
|
663 |
}
|
664 |
|
665 |
// Filter taxonomy with Custom post types
|
674 |
$order_settings = array();
|
675 |
|
676 |
// Advanced order by
|
677 |
+
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . $content_type . '-orderby', $pt_view_settings ) ) {
|
678 |
|
679 |
// Get meta key to order by
|
680 |
+
$meta_key = PT_CV_Functions::setting_value( PT_CV_PREFIX . $content_type . '-orderby', $pt_view_settings );
|
681 |
|
682 |
// Use 'meta_value_num' for numeric values
|
683 |
+
global $pt_content_type;
|
684 |
+
$all_meta_numeric_values = apply_filters( PT_CV_PREFIX_ . 'meta_numeric_values', array() );
|
685 |
+
// Get numeric values of selected content type
|
686 |
+
$meta_numeric_values = isset( $all_meta_numeric_values[$pt_content_type] ) ? $all_meta_numeric_values[$pt_content_type] : array();
|
687 |
+
$meta_orderby = array_key_exists( $meta_key, (array) $meta_numeric_values ) ? 'meta_value_num' : 'meta_value';
|
688 |
$order_settings = array(
|
689 |
+
'meta_key' => isset( $meta_numeric_values[$meta_key] ) ? $meta_numeric_values[$meta_key] : $meta_key,
|
690 |
'orderby' => $meta_orderby,
|
691 |
+
'order' => PT_CV_Functions::setting_value( PT_CV_PREFIX . 'advanced-order', $pt_view_settings ),
|
692 |
);
|
693 |
|
694 |
} else {
|
695 |
// Common order by
|
696 |
|
697 |
+
$orderby = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'orderby', $pt_view_settings );
|
698 |
$order_by_options = array_keys( PT_CV_Values::post_regular_orderby() );
|
699 |
if ( in_array( $orderby, $order_by_options ) ) {
|
700 |
$order_settings = array(
|
701 |
'orderby' => $orderby,
|
702 |
+
'order' => PT_CV_Functions::setting_value( PT_CV_PREFIX . 'order', $pt_view_settings )
|
703 |
);
|
704 |
}
|
705 |
}
|
717 |
/**
|
718 |
* Get Fields settings
|
719 |
*
|
|
|
720 |
* @param array $dargs The settings array of Fields
|
721 |
*/
|
722 |
+
static function view_get_display_settings( &$dargs ) {
|
723 |
+
global $pt_view_settings;
|
724 |
|
725 |
$view_type = $dargs['view-type'];
|
726 |
|
727 |
/**
|
728 |
* Layout format
|
729 |
*/
|
730 |
+
$dargs['layout-format'] = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'layout-format', $pt_view_settings );
|
731 |
|
732 |
/**
|
733 |
* Columns count & Rows count
|
734 |
*/
|
735 |
+
$dargs['number-columns'] = PT_CV_Functions::setting_value( PT_CV_PREFIX . $view_type . '-' . 'number-columns', $pt_view_settings, 1 );
|
736 |
+
$dargs['number-rows'] = PT_CV_Functions::setting_value( PT_CV_PREFIX . $view_type . '-' . 'number-rows', $pt_view_settings, 1 );
|
737 |
|
738 |
/**
|
739 |
* Fields settings
|
740 |
*/
|
741 |
+
$cfields_settings = PT_CV_Functions::settings_values_by_prefix( PT_CV_PREFIX . 'show-field-' );
|
742 |
$cfields = (array) array_keys( (array) $cfields_settings );
|
743 |
foreach ( $cfields as $field ) {
|
744 |
// If show this field
|
745 |
+
if ( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'show-field-' . $field, $pt_view_settings ) ) {
|
746 |
// Add this field to display fields list
|
747 |
$dargs['fields'][] = $field;
|
748 |
|
756 |
|
757 |
$fields = array( 'position', 'size', 'style' );
|
758 |
$prefix = PT_CV_PREFIX . 'field-thumbnail-';
|
759 |
+
PT_CV_Functions::settings_values( $fields, $field_setting, $pt_view_settings, $prefix );
|
760 |
|
761 |
+
$dargs['field-settings'][$field] = apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_setting_values', $field_setting, $prefix );
|
762 |
|
763 |
break;
|
764 |
|
768 |
$field_setting = array();
|
769 |
|
770 |
$prefix = PT_CV_PREFIX . 'meta-fields-';
|
771 |
+
$meta_fields_settings = PT_CV_Functions::settings_values_by_prefix( PT_CV_PREFIX . 'meta-fields-' );
|
772 |
$fields = (array) array_keys( (array) $meta_fields_settings );
|
773 |
|
774 |
+
PT_CV_Functions::settings_values( $fields, $field_setting, $pt_view_settings, $prefix );
|
775 |
|
776 |
+
$dargs['field-settings'][$field] = apply_filters( PT_CV_PREFIX_ . 'field_meta_fields_setting_values', $field_setting, $prefix );
|
777 |
|
778 |
break;
|
779 |
|
784 |
|
785 |
$prefix = PT_CV_PREFIX . 'field-content-';
|
786 |
$fields = PT_CV_Functions::settings_keys( 'field-content-', PT_CV_Settings::field_settings() );
|
787 |
+
PT_CV_Functions::settings_values( $fields, $field_setting, $pt_view_settings, $prefix );
|
788 |
|
789 |
if ( $field_setting['show'] == 'excerpt' ) {
|
790 |
+
$field_setting = array_merge( $field_setting, PT_CV_Functions::settings_values_by_prefix( PT_CV_PREFIX . 'field-excerpt-' ) );
|
791 |
}
|
792 |
|
793 |
+
$dargs['field-settings'][$field] = apply_filters( PT_CV_PREFIX_ . 'field_content_setting_values', $field_setting, $prefix );
|
794 |
|
795 |
break;
|
796 |
|
804 |
/**
|
805 |
* Get Pagination settings
|
806 |
*
|
|
|
807 |
* @param array $dargs The settings array of Fields
|
808 |
* @param array $args The parameters array
|
809 |
* @param array $pargs The pagination settings array
|
810 |
*/
|
811 |
+
static function view_get_pagination_settings( &$dargs, &$args, $pargs ) {
|
812 |
+
global $pt_view_settings;
|
813 |
|
814 |
// Get Limit value
|
815 |
+
$limit = trim( PT_CV_Functions::setting_value( PT_CV_PREFIX . 'limit', $pt_view_settings ) );
|
816 |
$limit = ( empty( $limit ) || $limit === '-1' ) ? 10000000 : (int) $limit;
|
817 |
$args['limit'] = $args['posts_per_page'] = $limit;
|
818 |
$offset = 0;
|
819 |
|
820 |
// Get pagination enable/disable
|
821 |
+
$pagination = PT_CV_Functions::setting_value( PT_CV_PREFIX . 'enable-pagination', $pt_view_settings );
|
822 |
if ( $pagination ) {
|
823 |
$field_setting = array();
|
824 |
|
825 |
$prefix = PT_CV_PREFIX . 'pagination-';
|
826 |
$fields = PT_CV_Functions::settings_keys( 'pagination-', PT_CV_Settings::settings_pagination() );
|
827 |
+
PT_CV_Functions::settings_values( $fields, $field_setting, $pt_view_settings, $prefix );
|
828 |
|
829 |
$dargs['pagination-settings'] = apply_filters( PT_CV_PREFIX_ . 'pagination_settings', $field_setting );
|
830 |
|
844 |
}
|
845 |
}
|
846 |
|
847 |
+
$offset = apply_filters( PT_CV_PREFIX_ . 'settings_args_offset', $offset );
|
848 |
|
849 |
// Not reaching out of limit
|
850 |
if ( $offset < $limit ) {
|
856 |
/**
|
857 |
* Get Other settings
|
858 |
*
|
|
|
859 |
* @param array $dargs The settings array of Fields
|
860 |
*/
|
861 |
+
static function view_get_other_settings( &$dargs ) {
|
862 |
+
global $pt_view_settings;
|
863 |
+
|
864 |
$field_setting = array();
|
865 |
|
866 |
$prefix = PT_CV_PREFIX . 'other-';
|
867 |
$fields = PT_CV_Functions::settings_keys( 'other-', PT_CV_Settings::settings_other() );
|
868 |
+
PT_CV_Functions::settings_values( $fields, $field_setting, $pt_view_settings, $prefix );
|
869 |
|
870 |
+
$dargs['other-settings'] = apply_filters( PT_CV_PREFIX_ . 'other_settings', $field_setting );
|
871 |
}
|
872 |
|
873 |
/**
|
includes/hooks.php
CHANGED
@@ -21,7 +21,7 @@ if ( ! class_exists( 'PT_CV_Hooks' ) ) {
|
|
21 |
*/
|
22 |
static function init() {
|
23 |
// Filter Output
|
24 |
-
add_filter( PT_CV_PREFIX_ . 'validate_settings', array( __CLASS__, 'filter_validate_settings' ), 10,
|
25 |
|
26 |
// Do action
|
27 |
}
|
@@ -30,10 +30,10 @@ if ( ! class_exists( 'PT_CV_Hooks' ) ) {
|
|
30 |
* Validate settings filter
|
31 |
*
|
32 |
* @param string $error The error message
|
33 |
-
* @param array $dargs The Display parameters array
|
34 |
* @param array $args The Query parameters array
|
35 |
*/
|
36 |
-
public static function filter_validate_settings( $errors, $
|
|
|
37 |
|
38 |
// echo "<pre>";
|
39 |
// var_dump( 'query args', $args );
|
21 |
*/
|
22 |
static function init() {
|
23 |
// Filter Output
|
24 |
+
add_filter( PT_CV_PREFIX_ . 'validate_settings', array( __CLASS__, 'filter_validate_settings' ), 10, 2 );
|
25 |
|
26 |
// Do action
|
27 |
}
|
30 |
* Validate settings filter
|
31 |
*
|
32 |
* @param string $error The error message
|
|
|
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 );
|
includes/html-viewtype.php
CHANGED
@@ -21,12 +21,12 @@ if ( ! class_exists( 'PT_CV_Html_ViewType' ) ) {
|
|
21 |
* Wrap content of Grid type
|
22 |
*
|
23 |
* @param array $content_items The array of Raw HTML output (is not wrapped) of each item
|
24 |
-
* @param array $dargs The array of Display settings
|
25 |
* @param array $content The output array
|
26 |
*
|
27 |
* @return array Array of rows, each row contains columns
|
28 |
*/
|
29 |
-
static function grid_wrapper( $content_items,
|
|
|
30 |
|
31 |
// -- Get column span
|
32 |
$columns = ( (int) $dargs['number-columns'] < count( $content_items ) ) ? (int) $dargs['number-columns'] : count( $content_items );
|
@@ -62,7 +62,7 @@ if ( ! class_exists( 'PT_CV_Html_ViewType' ) ) {
|
|
62 |
$_span_width = ( $idx == count( $items_per_row ) - 1 ) ? $span_width_last : $span_width;
|
63 |
|
64 |
// Wrap content of item
|
65 |
-
$row_html[] = PT_CV_Html::content_item_wrap( $content_item, $span_class . $_span_width
|
66 |
}
|
67 |
|
68 |
$content[] = sprintf( '<div class="%1$s">%2$s</div>', esc_attr( $row_class ), implode( "\n", $row_html ) );
|
@@ -73,12 +73,12 @@ if ( ! class_exists( 'PT_CV_Html_ViewType' ) ) {
|
|
73 |
* Wrap content of Collapsible List type
|
74 |
*
|
75 |
* @param array $content_items The array of Raw HTML output (is not wrapped) of each item
|
76 |
-
* @param array $dargs The array of Display settings
|
77 |
* @param array $content The output array
|
78 |
*
|
79 |
* @return string Collapsible list, wrapped in a "panel-group" div
|
80 |
*/
|
81 |
-
static function collapsible_wrapper( $content_items,
|
|
|
82 |
|
83 |
// Generate random id for the wrapper of Collapsible list
|
84 |
$random_id = PT_CV_Functions::string_random();
|
@@ -108,12 +108,12 @@ if ( ! class_exists( 'PT_CV_Html_ViewType' ) ) {
|
|
108 |
* Wrap content of Scrollable list
|
109 |
*
|
110 |
* @param array $content_items The array of Raw HTML output (is not wrapped) of each item
|
111 |
-
* @param array $dargs The array of Display settings
|
112 |
* @param array $content The output array
|
113 |
*
|
114 |
* @return array Array of rows, each row contains columns
|
115 |
*/
|
116 |
-
static function scrollable_wrapper( $content_items,
|
|
|
117 |
|
118 |
// ID for the wrapper of scrollable list
|
119 |
$wrapper_id = PT_CV_Functions::string_random();
|
@@ -121,12 +121,12 @@ if ( ! class_exists( 'PT_CV_Html_ViewType' ) ) {
|
|
121 |
// Store all output of Scrollale list (indicators, content, controls)
|
122 |
$scrollable_html = array();
|
123 |
|
124 |
-
$scrollable_content_data = self::scrollable_content( $content_items
|
125 |
$count_slides = $scrollable_content_data['count_slides'];
|
126 |
$scrollable_content = $scrollable_content_data['scrollable_content'];
|
127 |
|
128 |
// Js code
|
129 |
-
$interval = apply_filters( PT_CV_PREFIX_ . 'scrollable_interval', 'false'
|
130 |
$js = "$('#$wrapper_id').carousel({ interval : $interval })";
|
131 |
|
132 |
$scrollable_html[] = PT_CV_Html::inline_script( $js );
|
@@ -151,11 +151,12 @@ if ( ! class_exists( 'PT_CV_Html_ViewType' ) ) {
|
|
151 |
* HTML output of item in Scrollable List
|
152 |
*
|
153 |
* @param array $content_items The array of Raw HTML output (is not wrapped) of each item
|
154 |
-
* @param array $dargs The array of Display settings
|
155 |
*
|
156 |
* @return array
|
157 |
*/
|
158 |
-
static function scrollable_content( $content_items
|
|
|
|
|
159 |
// Store content of a Scrollable list
|
160 |
$scrollable_content = array();
|
161 |
|
21 |
* Wrap content of Grid type
|
22 |
*
|
23 |
* @param array $content_items The array of Raw HTML output (is not wrapped) of each item
|
|
|
24 |
* @param array $content The output array
|
25 |
*
|
26 |
* @return array Array of rows, each row contains columns
|
27 |
*/
|
28 |
+
static function grid_wrapper( $content_items, &$content ) {
|
29 |
+
global $dargs;
|
30 |
|
31 |
// -- Get column span
|
32 |
$columns = ( (int) $dargs['number-columns'] < count( $content_items ) ) ? (int) $dargs['number-columns'] : count( $content_items );
|
62 |
$_span_width = ( $idx == count( $items_per_row ) - 1 ) ? $span_width_last : $span_width;
|
63 |
|
64 |
// Wrap content of item
|
65 |
+
$row_html[] = PT_CV_Html::content_item_wrap( $content_item, $span_class . $_span_width );
|
66 |
}
|
67 |
|
68 |
$content[] = sprintf( '<div class="%1$s">%2$s</div>', esc_attr( $row_class ), implode( "\n", $row_html ) );
|
73 |
* Wrap content of Collapsible List type
|
74 |
*
|
75 |
* @param array $content_items The array of Raw HTML output (is not wrapped) of each item
|
|
|
76 |
* @param array $content The output array
|
77 |
*
|
78 |
* @return string Collapsible list, wrapped in a "panel-group" div
|
79 |
*/
|
80 |
+
static function collapsible_wrapper( $content_items, &$content ) {
|
81 |
+
global $dargs;
|
82 |
|
83 |
// Generate random id for the wrapper of Collapsible list
|
84 |
$random_id = PT_CV_Functions::string_random();
|
108 |
* Wrap content of Scrollable list
|
109 |
*
|
110 |
* @param array $content_items The array of Raw HTML output (is not wrapped) of each item
|
|
|
111 |
* @param array $content The output array
|
112 |
*
|
113 |
* @return array Array of rows, each row contains columns
|
114 |
*/
|
115 |
+
static function scrollable_wrapper( $content_items, &$content ) {
|
116 |
+
global $dargs;
|
117 |
|
118 |
// ID for the wrapper of scrollable list
|
119 |
$wrapper_id = PT_CV_Functions::string_random();
|
121 |
// Store all output of Scrollale list (indicators, content, controls)
|
122 |
$scrollable_html = array();
|
123 |
|
124 |
+
$scrollable_content_data = self::scrollable_content( $content_items );
|
125 |
$count_slides = $scrollable_content_data['count_slides'];
|
126 |
$scrollable_content = $scrollable_content_data['scrollable_content'];
|
127 |
|
128 |
// Js code
|
129 |
+
$interval = apply_filters( PT_CV_PREFIX_ . 'scrollable_interval', 'false' );
|
130 |
$js = "$('#$wrapper_id').carousel({ interval : $interval })";
|
131 |
|
132 |
$scrollable_html[] = PT_CV_Html::inline_script( $js );
|
151 |
* HTML output of item in Scrollable List
|
152 |
*
|
153 |
* @param array $content_items The array of Raw HTML output (is not wrapped) of each item
|
|
|
154 |
*
|
155 |
* @return array
|
156 |
*/
|
157 |
+
static function scrollable_content( $content_items ) {
|
158 |
+
global $dargs;
|
159 |
+
|
160 |
// Store content of a Scrollable list
|
161 |
$scrollable_content = array();
|
162 |
|
includes/html.php
CHANGED
@@ -163,11 +163,11 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
163 |
* Get Output HTML of a View type
|
164 |
*
|
165 |
* @param string $view_type The view type (grid, collapse...)
|
166 |
-
* @param array $dargs The array of Display settings
|
167 |
* @param object $post The post object
|
168 |
* @param string $style The style of view type (main, style2...)
|
169 |
*/
|
170 |
-
static function view_type_output( $view_type, $
|
|
|
171 |
$content = NULL;
|
172 |
|
173 |
if ( empty( $view_type ) ) {
|
@@ -194,7 +194,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
194 |
$fargs['layout-format'] = $dargs['layout-format'];
|
195 |
|
196 |
// Get HTML output of field
|
197 |
-
$fields_html[$field_name] = self::field_item_html( $field_name, $post, $fargs
|
198 |
}
|
199 |
|
200 |
// Get HTML content of view type, with specific style
|
@@ -216,15 +216,16 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
216 |
*
|
217 |
* @param array $html_item The HTML output of a item
|
218 |
* @param string $class The extra wrapper class of a item, such as col span
|
219 |
-
* @param array $dargs The array of Display settings
|
220 |
*
|
221 |
* @return string Full HTML output of a item
|
222 |
*/
|
223 |
-
static function content_item_wrap( $html_item, $class = ''
|
|
|
|
|
224 |
if ( empty( $html_item ) ) {
|
225 |
return '';
|
226 |
}
|
227 |
-
if ( $dargs ) {
|
228 |
// If only show Title
|
229 |
if ( isset( $dargs['fields'] ) && count( (array) $dargs['fields'] ) == 1 && $dargs['fields'][0] === 'title' ) {
|
230 |
$class .= ' ' . PT_CV_PREFIX . 'only-title';
|
@@ -242,13 +243,14 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
242 |
* Wrap content of all items
|
243 |
*
|
244 |
* @param array $content_items The array of Raw HTML output (is not wrapped) of each item
|
245 |
-
* @param array $dargs The array of Display settings
|
246 |
* @param int $current_page The current page
|
247 |
* @param int $post_per_page The number of posts per page
|
248 |
*
|
249 |
* @return string Full HTML output for Content View
|
250 |
*/
|
251 |
-
static function content_items_wrap( $content_items, $
|
|
|
|
|
252 |
if ( empty( $content_items ) ) {
|
253 |
return '';
|
254 |
}
|
@@ -263,21 +265,21 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
263 |
// Grid
|
264 |
case 'grid':
|
265 |
|
266 |
-
PT_CV_Html_ViewType::grid_wrapper( $content_items, $
|
267 |
|
268 |
break;
|
269 |
|
270 |
// Collapsible List
|
271 |
case 'collapsible':
|
272 |
|
273 |
-
PT_CV_Html_ViewType::collapsible_wrapper( $content_items, $
|
274 |
|
275 |
break;
|
276 |
|
277 |
// Scrollable List
|
278 |
case 'scrollable':
|
279 |
|
280 |
-
PT_CV_Html_ViewType::scrollable_wrapper( $content_items, $
|
281 |
|
282 |
break;
|
283 |
|
@@ -287,7 +289,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
287 |
$content[] = PT_CV_Html::content_item_wrap( $content_item );
|
288 |
}
|
289 |
|
290 |
-
$content = apply_filters( PT_CV_PREFIX_ . 'content_items_wrap', $content, $content_items, $
|
291 |
|
292 |
break;
|
293 |
}
|
@@ -296,11 +298,11 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
296 |
$content_list = balanceTags( implode( "\n", $content ) );
|
297 |
|
298 |
// Custom attribute of a page
|
299 |
-
$page_attr_ = apply_filters( PT_CV_PREFIX_ . 'page_attr', '', $view_type, $
|
300 |
$page_attr = strip_tags( $page_attr_ );
|
301 |
|
302 |
// Wrap items in 'page' wrapper
|
303 |
-
$wrap_in_page = apply_filters( PT_CV_PREFIX_ . 'wrap_in_page', true
|
304 |
if ( $wrap_in_page ) {
|
305 |
// Wrap in page wrapper
|
306 |
$html = sprintf( '<div id="%s" class="%s" %s>%s</div>', esc_attr( PT_CV_PREFIX . 'page' . '-' . $current_page ), esc_attr( PT_CV_PREFIX . 'page' ), $page_attr, $content_list );
|
@@ -320,7 +322,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
320 |
|
321 |
$output = sprintf( '<div class="%s" id="%s" %s>%s</div>', esc_attr( implode( ' ', array_filter( $view_class ) ) ), esc_attr( $view_id ), $page_attr, $html );
|
322 |
|
323 |
-
do_action( PT_CV_PREFIX_ . 'store_view_data', $view_id
|
324 |
} else {
|
325 |
$output = $html;
|
326 |
}
|
@@ -334,11 +336,12 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
334 |
* @param string $field_name The name of field
|
335 |
* @param object $post The post object
|
336 |
* @param array $fargs The array of Field settings
|
337 |
-
* @param array $dargs The settings array of Fields
|
338 |
*
|
339 |
* @return string
|
340 |
*/
|
341 |
-
static function field_item_html( $field_name, $post, $fargs
|
|
|
|
|
342 |
if ( empty( $field_name ) ) {
|
343 |
return '';
|
344 |
}
|
@@ -357,7 +360,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
357 |
break;
|
358 |
}
|
359 |
|
360 |
-
$html = self::_field_thumbnail( $post, $fargs
|
361 |
|
362 |
break;
|
363 |
|
@@ -405,7 +408,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
405 |
case 'excerpt':
|
406 |
$length = (int) $fargs['content']['length'];
|
407 |
$readmore = '<br />' . PT_CV_Html::link_button( get_permalink(), 'success', __( 'Read More' ), PT_CV_PREFIX . 'readmore', 'btn-sm' );
|
408 |
-
$content = wp_trim_words( get_the_content(), $length, ' ...' . apply_filters( PT_CV_PREFIX_ . 'field_content_readmore', $readmore, $fargs['content'], get_permalink() ) );
|
409 |
break;
|
410 |
|
411 |
case 'full':
|
@@ -430,7 +433,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
430 |
break;
|
431 |
}
|
432 |
|
433 |
-
$html = self::_field_meta( $post, $fargs['meta-fields']
|
434 |
|
435 |
break;
|
436 |
|
@@ -473,11 +476,11 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
473 |
*
|
474 |
* @param object $post The post object
|
475 |
* @param array $fargs The settings of this field
|
476 |
-
* @param array $dargs The settings array
|
477 |
*
|
478 |
* @return string
|
479 |
*/
|
480 |
-
static function _field_thumbnail( $post, $fargs
|
|
|
481 |
|
482 |
// Get layout format
|
483 |
$layout_format = $fargs['layout-format'];
|
@@ -507,7 +510,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
507 |
// Check if has thumbnail ( has_post_thumbnail doesn't works )
|
508 |
$has_thumbnail = get_the_post_thumbnail( $post_id );
|
509 |
if ( ! empty( $has_thumbnail ) ) {
|
510 |
-
$thumbnail_size = (array) apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_dimension_output', $dimensions, $fargs
|
511 |
$thumbnail_size = count( $thumbnail_size ) > 1 ? $thumbnail_size : $thumbnail_size[0];
|
512 |
$html = get_the_post_thumbnail( $post_id, $thumbnail_size, $gargs );
|
513 |
} else {
|
@@ -526,11 +529,10 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
526 |
*
|
527 |
* @param object $post The post object
|
528 |
* @param array $fargs The settings of this field
|
529 |
-
* @param array $dargs The settings array of Fields
|
530 |
*
|
531 |
* @return string
|
532 |
*/
|
533 |
-
static function _field_meta( $post, $fargs
|
534 |
|
535 |
$html = array();
|
536 |
|
@@ -580,7 +582,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
580 |
$author_class = apply_filters( PT_CV_PREFIX_ . 'field_meta_author_class', 'author' );
|
581 |
|
582 |
$author_html = sprintf( '<span class="%s">%s <a href="%s" rel="author">%s</a></span>', esc_attr( $author_class ), __( 'by', PT_CV_DOMAIN ), esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), get_the_author() );
|
583 |
-
$html['author'] = apply_filters( PT_CV_PREFIX_ . 'field_meta_author_html', $author_html, $post
|
584 |
break;
|
585 |
|
586 |
default:
|
@@ -589,7 +591,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
589 |
}
|
590 |
|
591 |
// Merge fields, or let them as seperate items in array
|
592 |
-
$merge_fields = apply_filters( PT_CV_PREFIX_ . 'field_meta_merge_fields', true
|
593 |
|
594 |
if ( $merge_fields ) {
|
595 |
$result = PT_CV_Html::_field_meta_wrap( $html );
|
@@ -637,28 +639,29 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
637 |
* Output pagination
|
638 |
*
|
639 |
* @param type $max_num_pages The total of pages
|
640 |
-
* @param array $dargs The settings array of Fields
|
641 |
* @param string $view_id The current view id
|
642 |
*
|
643 |
* @return type
|
644 |
*/
|
645 |
-
static function pagination_output( $max_num_pages, $
|
|
|
646 |
|
647 |
if ( ! $max_num_pages || (int) $max_num_pages === 1 ) {
|
648 |
return '';
|
649 |
}
|
650 |
|
651 |
-
$
|
652 |
|
653 |
$style = isset( $dargs['pagination-settings']['style'] ) ? $dargs['pagination-settings']['style'] : 'regular';
|
654 |
if ( $style == 'regular' ) {
|
655 |
-
$
|
656 |
} else {
|
657 |
-
$
|
658 |
}
|
659 |
-
|
660 |
// Add loading icon
|
661 |
-
$
|
|
|
|
|
662 |
|
663 |
return $output;
|
664 |
}
|
163 |
* Get Output HTML of a View type
|
164 |
*
|
165 |
* @param string $view_type The view type (grid, collapse...)
|
|
|
166 |
* @param object $post The post object
|
167 |
* @param string $style The style of view type (main, style2...)
|
168 |
*/
|
169 |
+
static function view_type_output( $view_type, $post, $style = 'main' ) {
|
170 |
+
global $dargs;
|
171 |
$content = NULL;
|
172 |
|
173 |
if ( empty( $view_type ) ) {
|
194 |
$fargs['layout-format'] = $dargs['layout-format'];
|
195 |
|
196 |
// Get HTML output of field
|
197 |
+
$fields_html[$field_name] = self::field_item_html( $field_name, $post, $fargs );
|
198 |
}
|
199 |
|
200 |
// Get HTML content of view type, with specific style
|
216 |
*
|
217 |
* @param array $html_item The HTML output of a item
|
218 |
* @param string $class The extra wrapper class of a item, such as col span
|
|
|
219 |
*
|
220 |
* @return string Full HTML output of a item
|
221 |
*/
|
222 |
+
static function content_item_wrap( $html_item, $class = '' ) {
|
223 |
+
global $dargs;
|
224 |
+
|
225 |
if ( empty( $html_item ) ) {
|
226 |
return '';
|
227 |
}
|
228 |
+
if ( is_array( $dargs ) ) {
|
229 |
// If only show Title
|
230 |
if ( isset( $dargs['fields'] ) && count( (array) $dargs['fields'] ) == 1 && $dargs['fields'][0] === 'title' ) {
|
231 |
$class .= ' ' . PT_CV_PREFIX . 'only-title';
|
243 |
* Wrap content of all items
|
244 |
*
|
245 |
* @param array $content_items The array of Raw HTML output (is not wrapped) of each item
|
|
|
246 |
* @param int $current_page The current page
|
247 |
* @param int $post_per_page The number of posts per page
|
248 |
*
|
249 |
* @return string Full HTML output for Content View
|
250 |
*/
|
251 |
+
static function content_items_wrap( $content_items, $current_page, $post_per_page ) {
|
252 |
+
global $dargs;
|
253 |
+
|
254 |
if ( empty( $content_items ) ) {
|
255 |
return '';
|
256 |
}
|
265 |
// Grid
|
266 |
case 'grid':
|
267 |
|
268 |
+
PT_CV_Html_ViewType::grid_wrapper( $content_items, $content );
|
269 |
|
270 |
break;
|
271 |
|
272 |
// Collapsible List
|
273 |
case 'collapsible':
|
274 |
|
275 |
+
PT_CV_Html_ViewType::collapsible_wrapper( $content_items, $content );
|
276 |
|
277 |
break;
|
278 |
|
279 |
// Scrollable List
|
280 |
case 'scrollable':
|
281 |
|
282 |
+
PT_CV_Html_ViewType::scrollable_wrapper( $content_items, $content );
|
283 |
|
284 |
break;
|
285 |
|
289 |
$content[] = PT_CV_Html::content_item_wrap( $content_item );
|
290 |
}
|
291 |
|
292 |
+
$content = apply_filters( PT_CV_PREFIX_ . 'content_items_wrap', $content, $content_items, $current_page, $post_per_page );
|
293 |
|
294 |
break;
|
295 |
}
|
298 |
$content_list = balanceTags( implode( "\n", $content ) );
|
299 |
|
300 |
// Custom attribute of a page
|
301 |
+
$page_attr_ = apply_filters( PT_CV_PREFIX_ . 'page_attr', '', $view_type, $content_items );
|
302 |
$page_attr = strip_tags( $page_attr_ );
|
303 |
|
304 |
// Wrap items in 'page' wrapper
|
305 |
+
$wrap_in_page = apply_filters( PT_CV_PREFIX_ . 'wrap_in_page', true );
|
306 |
if ( $wrap_in_page ) {
|
307 |
// Wrap in page wrapper
|
308 |
$html = sprintf( '<div id="%s" class="%s" %s>%s</div>', esc_attr( PT_CV_PREFIX . 'page' . '-' . $current_page ), esc_attr( PT_CV_PREFIX . 'page' ), $page_attr, $content_list );
|
322 |
|
323 |
$output = sprintf( '<div class="%s" id="%s" %s>%s</div>', esc_attr( implode( ' ', array_filter( $view_class ) ) ), esc_attr( $view_id ), $page_attr, $html );
|
324 |
|
325 |
+
do_action( PT_CV_PREFIX_ . 'store_view_data', $view_id );
|
326 |
} else {
|
327 |
$output = $html;
|
328 |
}
|
336 |
* @param string $field_name The name of field
|
337 |
* @param object $post The post object
|
338 |
* @param array $fargs The array of Field settings
|
|
|
339 |
*
|
340 |
* @return string
|
341 |
*/
|
342 |
+
static function field_item_html( $field_name, $post, $fargs ) {
|
343 |
+
global $dargs;
|
344 |
+
|
345 |
if ( empty( $field_name ) ) {
|
346 |
return '';
|
347 |
}
|
360 |
break;
|
361 |
}
|
362 |
|
363 |
+
$html = self::_field_thumbnail( $post, $fargs );
|
364 |
|
365 |
break;
|
366 |
|
408 |
case 'excerpt':
|
409 |
$length = (int) $fargs['content']['length'];
|
410 |
$readmore = '<br />' . PT_CV_Html::link_button( get_permalink(), 'success', __( 'Read More' ), PT_CV_PREFIX . 'readmore', 'btn-sm' );
|
411 |
+
$content = wp_trim_words( strip_shortcodes( get_the_content() ), $length, ' ...' . apply_filters( PT_CV_PREFIX_ . 'field_content_readmore', $readmore, $fargs['content'], get_permalink() ) );
|
412 |
break;
|
413 |
|
414 |
case 'full':
|
433 |
break;
|
434 |
}
|
435 |
|
436 |
+
$html = self::_field_meta( $post, $fargs['meta-fields'] );
|
437 |
|
438 |
break;
|
439 |
|
476 |
*
|
477 |
* @param object $post The post object
|
478 |
* @param array $fargs The settings of this field
|
|
|
479 |
*
|
480 |
* @return string
|
481 |
*/
|
482 |
+
static function _field_thumbnail( $post, $fargs ) {
|
483 |
+
global $dargs;
|
484 |
|
485 |
// Get layout format
|
486 |
$layout_format = $fargs['layout-format'];
|
510 |
// Check if has thumbnail ( has_post_thumbnail doesn't works )
|
511 |
$has_thumbnail = get_the_post_thumbnail( $post_id );
|
512 |
if ( ! empty( $has_thumbnail ) ) {
|
513 |
+
$thumbnail_size = (array) apply_filters( PT_CV_PREFIX_ . 'field_thumbnail_dimension_output', $dimensions, $fargs );
|
514 |
$thumbnail_size = count( $thumbnail_size ) > 1 ? $thumbnail_size : $thumbnail_size[0];
|
515 |
$html = get_the_post_thumbnail( $post_id, $thumbnail_size, $gargs );
|
516 |
} else {
|
529 |
*
|
530 |
* @param object $post The post object
|
531 |
* @param array $fargs The settings of this field
|
|
|
532 |
*
|
533 |
* @return string
|
534 |
*/
|
535 |
+
static function _field_meta( $post, $fargs ) {
|
536 |
|
537 |
$html = array();
|
538 |
|
582 |
$author_class = apply_filters( PT_CV_PREFIX_ . 'field_meta_author_class', 'author' );
|
583 |
|
584 |
$author_html = sprintf( '<span class="%s">%s <a href="%s" rel="author">%s</a></span>', esc_attr( $author_class ), __( 'by', PT_CV_DOMAIN ), esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), get_the_author() );
|
585 |
+
$html['author'] = apply_filters( PT_CV_PREFIX_ . 'field_meta_author_html', $author_html, $post );
|
586 |
break;
|
587 |
|
588 |
default:
|
591 |
}
|
592 |
|
593 |
// Merge fields, or let them as seperate items in array
|
594 |
+
$merge_fields = apply_filters( PT_CV_PREFIX_ . 'field_meta_merge_fields', true );
|
595 |
|
596 |
if ( $merge_fields ) {
|
597 |
$result = PT_CV_Html::_field_meta_wrap( $html );
|
639 |
* Output pagination
|
640 |
*
|
641 |
* @param type $max_num_pages The total of pages
|
|
|
642 |
* @param string $view_id The current view id
|
643 |
*
|
644 |
* @return type
|
645 |
*/
|
646 |
+
static function pagination_output( $max_num_pages, $view_id ) {
|
647 |
+
global $dargs;
|
648 |
|
649 |
if ( ! $max_num_pages || (int) $max_num_pages === 1 ) {
|
650 |
return '';
|
651 |
}
|
652 |
|
653 |
+
$pagination_btn = '';
|
654 |
|
655 |
$style = isset( $dargs['pagination-settings']['style'] ) ? $dargs['pagination-settings']['style'] : 'regular';
|
656 |
if ( $style == 'regular' ) {
|
657 |
+
$pagination_btn = sprintf( '<ul class="%s" data-totalpages="%s" data-id="%s"></ul>', PT_CV_PREFIX . 'pagination', esc_attr( $max_num_pages ), esc_attr( $view_id ) );
|
658 |
} else {
|
659 |
+
$pagination_btn = apply_filters( PT_CV_PREFIX_ . 'btn_more_html', $pagination_btn, $max_num_pages, $view_id );
|
660 |
}
|
|
|
661 |
// Add loading icon
|
662 |
+
$pagination_btn .= self::html_loading_img( 12, PT_CV_PREFIX . 'spinner' );
|
663 |
+
|
664 |
+
$output = apply_filters( PT_CV_PREFIX_ . 'pagination_output', $pagination_btn );
|
665 |
|
666 |
return $output;
|
667 |
}
|
includes/settings.php
CHANGED
@@ -36,21 +36,41 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
36 |
|
37 |
foreach ( $terms_of_taxonomies as $taxonomy_slug => $terms ) {
|
38 |
|
39 |
-
$result[$taxonomy_slug] = array(
|
|
|
40 |
// In
|
41 |
array(
|
42 |
'label' => array(
|
43 |
'text' => __( 'In ', PT_CV_DOMAIN ),
|
44 |
//'text' => __( 'In ', PT_CV_DOMAIN ) . $taxonomies[$taxonomy_slug],
|
45 |
),
|
46 |
-
'params'
|
47 |
array(
|
48 |
-
'type'
|
49 |
-
'
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
),
|
55 |
),
|
56 |
),
|
@@ -156,8 +176,8 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
156 |
array(
|
157 |
'type' => 'number',
|
158 |
'name' => $prefix . 'items-per-page',
|
159 |
-
'std' => '
|
160 |
-
'placeholder' => 'e.g.
|
161 |
'desc' => __( 'The number of items per page. If value of Limit option is not blank (empty), this value should be smaller than Limit value', PT_CV_DOMAIN ),
|
162 |
),
|
163 |
),
|
@@ -181,7 +201,7 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
181 |
),
|
182 |
);
|
183 |
|
184 |
-
$result = apply_filters( PT_CV_PREFIX_ . 'settings_pagination', $result );
|
185 |
|
186 |
return $result;
|
187 |
}
|
@@ -283,6 +303,9 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
283 |
'dependence' => array( $prefix2 . 'meta-fields', 'yes' ),
|
284 |
),
|
285 |
|
|
|
|
|
|
|
286 |
// Content settings
|
287 |
array(
|
288 |
'label' => array(
|
@@ -604,7 +627,7 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
604 |
array(
|
605 |
'type' => 'checkbox',
|
606 |
'name' => $prefix . 'taxonomy',
|
607 |
-
'options' => PT_CV_Values::yes_no( 'yes', __( 'Show
|
608 |
'std' => 'yes',
|
609 |
),
|
610 |
),
|
36 |
|
37 |
foreach ( $terms_of_taxonomies as $taxonomy_slug => $terms ) {
|
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( PT_CV_PREFIX_ . 'term_quick_filter_in',
|
51 |
+
array(
|
52 |
+
array(
|
53 |
+
'label' => array(
|
54 |
+
'text' => __( '', PT_CV_DOMAIN ),
|
55 |
+
),
|
56 |
+
'extra_setting' => array(
|
57 |
+
'params' => array(
|
58 |
+
'width' => 12,
|
59 |
+
),
|
60 |
+
),
|
61 |
+
'params' => array(
|
62 |
+
array(
|
63 |
+
'type' => 'select',
|
64 |
+
'name' => $taxonomy_slug . '__in[]',
|
65 |
+
'options' => $terms,
|
66 |
+
'std' => '',
|
67 |
+
'class' => 'select2',
|
68 |
+
'multiple' => '1',
|
69 |
+
),
|
70 |
+
),
|
71 |
+
),
|
72 |
+
)
|
73 |
+
),
|
74 |
),
|
75 |
),
|
76 |
),
|
176 |
array(
|
177 |
'type' => 'number',
|
178 |
'name' => $prefix . 'items-per-page',
|
179 |
+
'std' => '5',
|
180 |
+
'placeholder' => 'e.g. 5',
|
181 |
'desc' => __( 'The number of items per page. If value of Limit option is not blank (empty), this value should be smaller than Limit value', PT_CV_DOMAIN ),
|
182 |
),
|
183 |
),
|
201 |
),
|
202 |
);
|
203 |
|
204 |
+
$result = apply_filters( PT_CV_PREFIX_ . 'settings_pagination', $result, $prefix );
|
205 |
|
206 |
return $result;
|
207 |
}
|
303 |
'dependence' => array( $prefix2 . 'meta-fields', 'yes' ),
|
304 |
),
|
305 |
|
306 |
+
// Taxonomies settings
|
307 |
+
apply_filters( PT_CV_PREFIX_ . 'settings_taxonomies_display', array() ),
|
308 |
+
|
309 |
// Content settings
|
310 |
array(
|
311 |
'label' => array(
|
627 |
array(
|
628 |
'type' => 'checkbox',
|
629 |
'name' => $prefix . 'taxonomy',
|
630 |
+
'options' => PT_CV_Values::yes_no( 'yes', __( 'Show Taxonomies (categories, tags...)', PT_CV_DOMAIN ) ),
|
631 |
'std' => 'yes',
|
632 |
),
|
633 |
),
|
public/assets/js/public.js
CHANGED
@@ -71,7 +71,12 @@
|
|
71 |
|
72 |
var view_id = this_.attr('data-id');
|
73 |
var spinner = this_.next('.' + _prefix + 'spinner');
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
// For Timeline
|
77 |
if ( pages_holder.hasClass(_prefix + 'timeline') ) {
|
71 |
|
72 |
var view_id = this_.attr('data-id');
|
73 |
var spinner = this_.next('.' + _prefix + 'spinner');
|
74 |
+
|
75 |
+
var pagination_wrapper = this_;
|
76 |
+
if (this_.parent('.' + _prefix + 'pagination-wrapper').length) {
|
77 |
+
pagination_wrapper = this_.parent('.' + _prefix + 'pagination-wrapper');
|
78 |
+
}
|
79 |
+
var pages_holder = pagination_wrapper.prev('.' + _prefix + 'view');
|
80 |
|
81 |
// For Timeline
|
82 |
if ( pages_holder.hasClass(_prefix + 'timeline') ) {
|