Version Description
- New feature: Able to use Normal pagination (without Ajax)
- Update: Add filter allows to customize labels for pagination
Download this release
Release Info
Developer | PT Guy |
Plugin | Content Views – Post Grid & List for WordPress |
Version | 1.5.0 |
Comparing to | |
See all releases |
Code changes from version 1.4.9 to 1.5.0
- README.txt +5 -1
- admin/includes/templates/settings-section-two.php +7 -5
- admin/views/view.php +5 -3
- assets/bootstrap-paginator/bootstrap-paginator.min.js +1 -1
- content-views.php +2 -2
- includes/functions.php +101 -10
- includes/html.php +27 -6
- includes/settings.php +43 -8
- includes/values.php +16 -0
- public/assets/css/public.css +15 -0
- public/assets/js/public.js +1 -1
README.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
4 |
Tags: post, posts, page, pages, query, queries, search, display, show, grid, layout, author, blog, categories, category, comment, content, custom, editor, filter, Formatting, image, list, meta, plugin, responsive, shortcode, excerpt, title, tag, term, Taxonomy, thumbnail, pagination, date, scrollable, slider, collapsible
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 4.1
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -144,6 +144,10 @@ You can create Unlimited Views, in Unlimited websites
|
|
144 |
|
145 |
== Changelog ==
|
146 |
|
|
|
|
|
|
|
|
|
147 |
= 1.4.9 =
|
148 |
* Update: Able to check/uncheck to allow HTML tags in excerpt (to preventing broken HTML output)
|
149 |
|
4 |
Tags: post, posts, page, pages, query, queries, search, display, show, grid, layout, author, blog, categories, category, comment, content, custom, editor, filter, Formatting, image, list, meta, plugin, responsive, shortcode, excerpt, title, tag, term, Taxonomy, thumbnail, pagination, date, scrollable, slider, collapsible
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 4.1
|
7 |
+
Stable tag: 1.5.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
144 |
|
145 |
== Changelog ==
|
146 |
|
147 |
+
= 1.5.0 =
|
148 |
+
* New feature: Able to use Normal pagination (without Ajax)
|
149 |
+
* Update: Add filter allows to customize labels for pagination
|
150 |
+
|
151 |
= 1.4.9 =
|
152 |
* Update: Able to check/uncheck to allow HTML tags in excerpt (to preventing broken HTML output)
|
153 |
|
admin/includes/templates/settings-section-two.php
CHANGED
@@ -1,5 +1,3 @@
|
|
1 |
-
<hr>
|
2 |
-
|
3 |
<style>
|
4 |
#pt-cv-features {padding-right: 0; margin-bottom: 30px;}
|
5 |
#pt-cv-features * {font-size: 14px;}
|
@@ -7,6 +5,10 @@
|
|
7 |
#pt-cv-features .col-md-6 {padding: 0;}
|
8 |
</style>
|
9 |
|
|
|
|
|
|
|
|
|
10 |
<h2>Want more powerful features?</h2>
|
11 |
|
12 |
<div class="col-md-12" id="pt-cv-features">
|
@@ -40,14 +42,14 @@
|
|
40 |
</div>
|
41 |
</div>
|
42 |
|
43 |
-
<a style="font-size: 18px;" href="http://sample.contentviewspro.com/?utm_source=
|
44 |
<br>
|
45 |
</div>
|
46 |
|
47 |
<p style="margin-top: 20px;">
|
48 |
-
<a href="http://www.contentviewspro.com/pricing/?utm_source=settings_page
|
49 |
or
|
50 |
-
<a href="http://sample.contentviewspro.com/?utm_source=
|
51 |
</p>
|
52 |
|
53 |
<hr>
|
|
|
|
|
1 |
<style>
|
2 |
#pt-cv-features {padding-right: 0; margin-bottom: 30px;}
|
3 |
#pt-cv-features * {font-size: 14px;}
|
5 |
#pt-cv-features .col-md-6 {padding: 0;}
|
6 |
</style>
|
7 |
|
8 |
+
<h3>⇒ <a style="font-size: 18px;" href="http://www.contentviewspro.com/docs/?utm_source=settings_page" target="_blank">Content Views Documentation</a></h3>
|
9 |
+
|
10 |
+
<hr>
|
11 |
+
|
12 |
<h2>Want more powerful features?</h2>
|
13 |
|
14 |
<div class="col-md-12" id="pt-cv-features">
|
42 |
</div>
|
43 |
</div>
|
44 |
|
45 |
+
<h3>» <a style="font-size: 18px;" href="http://sample.contentviewspro.com/?utm_source=settings_page" target="_blank">See all features</a></h3>
|
46 |
<br>
|
47 |
</div>
|
48 |
|
49 |
<p style="margin-top: 20px;">
|
50 |
+
<a href="http://www.contentviewspro.com/pricing/?utm_source=settings_page" target="_blank" class="btn btn-success">Upgrade now</a>
|
51 |
or
|
52 |
+
<a href="http://sample.contentviewspro.com/?utm_source=settings_page" target="_blank" class="btn btn-info">Check demo site</a>
|
53 |
</p>
|
54 |
|
55 |
<hr>
|
admin/views/view.php
CHANGED
@@ -148,7 +148,7 @@ $options = array(
|
|
148 |
),
|
149 |
|
150 |
// Upgrade to Pro
|
151 |
-
|
152 |
'label' => array(
|
153 |
'text' => '',
|
154 |
),
|
@@ -163,7 +163,7 @@ $options = array(
|
|
163 |
'content' => sprintf( '<p class="text-muted">→ %s</p>', __( 'Filter custom content type (or post type) ?', PT_CV_DOMAIN ) . sprintf( ' <a href="%s" target="_blank">%s</a>', esc_url( 'http://www.contentviewspro.com/pricing/?utm_source=client&utm_medium=view' ), __( 'Please upgrade to Pro', PT_CV_DOMAIN ) ) ),
|
164 |
),
|
165 |
),
|
166 |
-
)
|
167 |
|
168 |
apply_filters( PT_CV_PREFIX_ . 'custom_filters', array() ),
|
169 |
|
@@ -213,6 +213,8 @@ $options = array(
|
|
213 |
),
|
214 |
),
|
215 |
),
|
|
|
|
|
216 |
|
217 |
// Parent page
|
218 |
array(
|
@@ -460,7 +462,7 @@ $options = array(
|
|
460 |
'type' => 'text',
|
461 |
'name' => 's',
|
462 |
'std' => '',
|
463 |
-
'desc' => __( 'Enter the keyword to searching for posts', PT_CV_DOMAIN ),
|
464 |
),
|
465 |
),
|
466 |
),
|
148 |
),
|
149 |
|
150 |
// Upgrade to Pro
|
151 |
+
! get_option( 'pt_cv_version_pro' ) ? array(
|
152 |
'label' => array(
|
153 |
'text' => '',
|
154 |
),
|
163 |
'content' => sprintf( '<p class="text-muted">→ %s</p>', __( 'Filter custom content type (or post type) ?', PT_CV_DOMAIN ) . sprintf( ' <a href="%s" target="_blank">%s</a>', esc_url( 'http://www.contentviewspro.com/pricing/?utm_source=client&utm_medium=view' ), __( 'Please upgrade to Pro', PT_CV_DOMAIN ) ) ),
|
164 |
),
|
165 |
),
|
166 |
+
) : '',
|
167 |
|
168 |
apply_filters( PT_CV_PREFIX_ . 'custom_filters', array() ),
|
169 |
|
213 |
),
|
214 |
),
|
215 |
),
|
216 |
+
|
217 |
+
apply_filters( PT_CV_PREFIX_ . 'exclude_extra_settings', array() ),
|
218 |
|
219 |
// Parent page
|
220 |
array(
|
462 |
'type' => 'text',
|
463 |
'name' => 's',
|
464 |
'std' => '',
|
465 |
+
'desc' => __( 'Enter the keyword to searching for posts', PT_CV_DOMAIN ) . apply_filters( PT_CV_PREFIX_ . 'searchby_keyword_desc', '' ),
|
466 |
),
|
467 |
),
|
468 |
),
|
assets/bootstrap-paginator/bootstrap-paginator.min.js
CHANGED
@@ -15,4 +15,4 @@
|
|
15 |
* See the License for the specific language governing permissions and
|
16 |
* limitations under the License.
|
17 |
*/
|
18 |
-
(function(
|
15 |
* See the License for the specific language governing permissions and
|
16 |
* limitations under the License.
|
17 |
*/
|
18 |
+
(function(f){var d=function(a,b){this.init(a,b)},e=null;d.prototype={init:function(b,c){this.$element=f(b);var h=(c&&c.bootstrapMajorVersion)?c.bootstrapMajorVersion:f.fn.bootstrapPaginator.defaults.bootstrapMajorVersion,a=this.$element.attr("id");if(h===2&&!this.$element.is("div")){throw"in Bootstrap version 2 the pagination must be a div element. Or if you are using Bootstrap pagination 3. Please specify it in bootstrapMajorVersion in the option"}else{if(h>2&&!this.$element.is("ul")){throw"in Bootstrap version 3 the pagination root item must be an ul element."}}this.currentPage=1;this.lastPage=1;this.setOptions(c);this.initialized=true},setOptions:function(a){this.options=f.extend({},(this.options||f.fn.bootstrapPaginator.defaults),a);this.totalPages=parseInt(this.options.totalPages,10);this.numberOfPages=parseInt(this.options.numberOfPages,10);if(a&&typeof(a.currentPage)!=="undefined"){this.setCurrentPage(a.currentPage)}this.listen();this.render();if(!this.initialized&&this.lastPage!==this.currentPage){this.$element.trigger("page-changed",[this.lastPage,this.currentPage])}},listen:function(){this.$element.off("page-clicked");this.$element.off("page-changed");if(typeof(this.options.onPageClicked)==="function"){this.$element.bind("page-clicked",this.options.onPageClicked)}if(typeof(this.options.onPageChanged)==="function"){this.$element.on("page-changed",this.options.onPageChanged)}this.$element.bind("page-clicked",this.onPageClicked)},destroy:function(){this.$element.off("page-clicked");this.$element.off("page-changed");this.$element.removeData("bootstrapPaginator");this.$element.empty()},show:function(a){this.setCurrentPage(a);this.render();if(this.lastPage!==this.currentPage){this.$element.trigger("page-changed",[this.lastPage,this.currentPage])}},showNext:function(){var a=this.getPages();if(a.next){this.show(a.next)}},showPrevious:function(){var a=this.getPages();if(a.prev){this.show(a.prev)}},showFirst:function(){var a=this.getPages();if(a.first){this.show(a.first)}},showLast:function(){var a=this.getPages();if(a.last){this.show(a.last)}},onPageItemClicked:function(b){var c=b.data.type,a=b.data.page;this.$element.trigger("page-clicked",[b,c,a])},onPageClicked:function(c,j,i,b){var a=f(c.currentTarget);switch(i){case"first":a.bootstrapPaginator("showFirst");break;case"prev":a.bootstrapPaginator("showPrevious");break;case"next":a.bootstrapPaginator("showNext");break;case"last":a.bootstrapPaginator("showLast");break;case"page":a.bootstrapPaginator("show",b);break}},render:function(){var b=this.getValueFromOption(this.options.containerClass,this.$element),a=this.options.size||"normal",p=this.options.alignment||"left",w=this.getPages(),r=this.options.bootstrapMajorVersion===2?f("<ul></ul>"):this.$element,i=this.options.bootstrapMajorVersion===2?this.getValueFromOption(this.options.listContainerClass,r):null,s=null,v=null,t=null,c=null,x=null,u=0;switch(a.toLowerCase()){case"large":case"small":case"mini":this.$element.addClass(f.fn.bootstrapPaginator.sizeArray[this.options.bootstrapMajorVersion][a.toLowerCase()]);break;default:break}if(this.options.bootstrapMajorVersion===2){switch(p.toLowerCase()){case"center":this.$element.addClass("pagination-centered");break;case"right":this.$element.addClass("pagination-right");break;default:break}}this.$element.addClass(b);this.$element.empty();if(this.options.bootstrapMajorVersion===2){this.$element.append(r);r.addClass(i)}this.pageRef=[];if(w.first){s=this.buildPageItem("first",w.first);if(s){r.append(s)}}if(w.prev){v=this.buildPageItem("prev",w.prev);if(v){r.append(v)}}for(u=0;u<w.length;u=u+1){x=this.buildPageItem("page",w[u]);if(x){r.append(x)}}if(w.next){t=this.buildPageItem("next",w.next);if(t){r.append(t)}}if(w.last){c=this.buildPageItem("last",w.last);if(c){r.append(c)}}},buildPageItem:function(m,o){var c=f("<li></li>"),q=f("<a></a>"),a="",b="",r=this.options.itemContainerClass(m,o,this.currentPage),p=this.getValueFromOption(this.options.itemContentClass,m,o,this.currentPage),n=null;switch(m){case"first":if(!this.getValueFromOption(this.options.shouldShowPage,m,o,this.currentPage)){return}a=this.options.itemTexts(m,o,this.currentPage);b=this.options.tooltipTitles(m,o,this.currentPage);break;case"last":if(!this.getValueFromOption(this.options.shouldShowPage,m,o,this.currentPage)){return}a=this.options.itemTexts(m,o,this.currentPage);b=this.options.tooltipTitles(m,o,this.currentPage);break;case"prev":if(!this.getValueFromOption(this.options.shouldShowPage,m,o,this.currentPage)){return}a=this.options.itemTexts(m,o,this.currentPage);b=this.options.tooltipTitles(m,o,this.currentPage);break;case"next":if(!this.getValueFromOption(this.options.shouldShowPage,m,o,this.currentPage)){return}a=this.options.itemTexts(m,o,this.currentPage);b=this.options.tooltipTitles(m,o,this.currentPage);break;case"page":if(!this.getValueFromOption(this.options.shouldShowPage,m,o,this.currentPage)){return}a=this.options.itemTexts(m,o,this.currentPage);b=this.options.tooltipTitles(m,o,this.currentPage);break}c.addClass(r).append(q);q.addClass(p).html(a).on("click",null,{type:m,page:o},f.proxy(this.onPageItemClicked,this));if(this.options.pageUrl){q.attr("href",this.getValueFromOption(this.options.pageUrl,m,o,this.currentPage))}if(this.options.useBootstrapTooltip){n=f.extend({},this.options.bootstrapTooltipOptions,{title:b});q.tooltip(n)}else{q.attr("title",b)}return c},setCurrentPage:function(a){if(a>this.totalPages||a<1){throw"Page out of range"}this.lastPage=this.currentPage;this.currentPage=parseInt(a,10)},getPages:function(){var b=this.totalPages,a=(this.currentPage%this.numberOfPages===0)?(parseInt(this.currentPage/this.numberOfPages,10)-1)*this.numberOfPages+1:parseInt(this.currentPage/this.numberOfPages,10)*this.numberOfPages+1,i=[],c=0,j=0;a=a<1?1:a;for(c=a,j=0;j<this.numberOfPages&&c<=b;c=c+1,j=j+1){i.push(c)}i.first=1;if(this.currentPage>1){i.prev=this.currentPage-1}else{i.prev=1}if(this.currentPage<b){i.next=this.currentPage+1}else{i.next=b}i.last=b;i.current=this.currentPage;i.total=b;i.numberOfPages=this.options.numberOfPages;return i},getValueFromOption:function(a){var c=null,b=Array.prototype.slice.call(arguments,1);if(typeof a==="function"){c=a.apply(this,b)}else{c=a}return c}};e=f.fn.bootstrapPaginator;f.fn.bootstrapPaginator=function(a){var b=arguments,c=null;f(this).each(function(o,n){var l=f(n),m=l.data("bootstrapPaginator"),p=(typeof a!=="object")?null:a;if(!m){m=new d(this,p);l=f(m.$element);l.data("bootstrapPaginator",m);return}if(typeof a==="string"){if(m[a]){c=m[a].apply(m,Array.prototype.slice.call(b,1))}else{throw"Method "+a+" does not exist"}}else{c=m.setOptions(a)}});return c};f.fn.bootstrapPaginator.sizeArray={"2":{large:"pagination-large",small:"pagination-small",mini:"pagination-mini"},"3":{large:"pagination-lg",small:"pagination-sm",mini:""}};f.fn.bootstrapPaginator.defaults={containerClass:"",size:"normal",alignment:"left",bootstrapMajorVersion:2,listContainerClass:"",itemContainerClass:function(c,b,a){return(b===a)?"active":""},itemContentClass:function(c,b,a){return""},currentPage:1,numberOfPages:5,totalPages:1,pageUrl:function(c,b,a){return null},onPageClicked:null,onPageChanged:null,useBootstrapTooltip:false,shouldShowPage:function(c,b,a){var h=true;switch(c){case"first":h=(a!==1);break;case"prev":h=(a!==1);break;case"next":h=(a!==this.totalPages);break;case"last":h=(a!==this.totalPages);break;case"page":h=true;break}return h},itemTexts:function(c,b,a){switch(c){case"first":return PT_CV_PAGINATION.first;case"prev":return PT_CV_PAGINATION.prev;case"next":return PT_CV_PAGINATION.next;case"last":return PT_CV_PAGINATION.last;case"page":return b}},tooltipTitles:function(c,b,a){switch(c){case"first":return PT_CV_PAGINATION.goto_first;case"prev":return PT_CV_PAGINATION.goto_prev;case"next":return PT_CV_PAGINATION.goto_next;case"last":return PT_CV_PAGINATION.goto_last;case"page":return(b===a)?PT_CV_PAGINATION.current_page+" "+b:PT_CV_PAGINATION.goto_page+" "+b}},bootstrapTooltipOptions:{animation:true,html:true,placement:"top",selector:false,title:"",container:false}};f.fn.bootstrapPaginator.Constructor=d}(window.jQuery));
|
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: PT Guy
|
15 |
* Author URI: http://profiles.wordpress.org/pt-guy
|
16 |
* Text Domain: content-views
|
@@ -27,7 +27,7 @@ if ( ! defined( 'WPINC' ) ) {
|
|
27 |
/*
|
28 |
* Define Constant
|
29 |
*/
|
30 |
-
define( 'PT_CV_VERSION', '1.
|
31 |
define( 'PT_CV_FILE', __FILE__ );
|
32 |
$pt_cv_path = plugin_dir_path( __FILE__ );
|
33 |
include_once( $pt_cv_path . 'includes/defines.php' );
|
10 |
* Plugin Name: Content Views
|
11 |
* Plugin URI: http://wordpress.org/plugins/content-views-query-and-display-post-page/
|
12 |
* Description: Query and display <strong>posts, pages</strong> in awesome layouts (<strong>grid, scrollable list, collapsible list</strong>) easier than ever, without coding!
|
13 |
+
* Version: 1.5.0
|
14 |
* Author: PT Guy
|
15 |
* Author URI: http://profiles.wordpress.org/pt-guy
|
16 |
* Text Domain: content-views
|
27 |
/*
|
28 |
* Define Constant
|
29 |
*/
|
30 |
+
define( 'PT_CV_VERSION', '1.5.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
@@ -435,7 +435,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
435 |
* @return string
|
436 |
*/
|
437 |
static function array_get_first_key( $args ) {
|
438 |
-
return current( array_keys( $args ) );
|
439 |
}
|
440 |
|
441 |
/**
|
@@ -642,11 +642,12 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
642 |
/**
|
643 |
* Output Pagination
|
644 |
*/
|
645 |
-
$current_page = (
|
646 |
$html = PT_CV_Html::content_items_wrap( $content_items, $current_page, $args['posts_per_page'], $id );
|
647 |
|
648 |
// Append Pagination HTML if this is first page, or not Ajax calling
|
649 |
-
|
|
|
650 |
// Total post founds
|
651 |
$found_posts = apply_filters( PT_CV_PREFIX_ . 'found_posts', $pt_query->found_posts );
|
652 |
|
@@ -657,7 +658,7 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
657 |
$max_num_pages = ceil( $total_items / $args['posts_per_page'] );
|
658 |
|
659 |
// Output pagination
|
660 |
-
$html .= "\n" . PT_CV_Html::pagination_output( $max_num_pages, $session_id );
|
661 |
}
|
662 |
|
663 |
return $html;
|
@@ -987,13 +988,13 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
987 |
$args['posts_per_page'] = $posts_per_page;
|
988 |
|
989 |
// Get offset
|
990 |
-
|
991 |
-
|
|
|
992 |
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
}
|
997 |
}
|
998 |
}
|
999 |
|
@@ -1204,6 +1205,96 @@ if ( ! class_exists( 'PT_CV_Functions' ) ) {
|
|
1204 |
<?php
|
1205 |
}
|
1206 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1207 |
|
1208 |
}
|
1209 |
|
435 |
* @return string
|
436 |
*/
|
437 |
static function array_get_first_key( $args ) {
|
438 |
+
return current( array_keys( (array) $args ) );
|
439 |
}
|
440 |
|
441 |
/**
|
642 |
/**
|
643 |
* Output Pagination
|
644 |
*/
|
645 |
+
$current_page = self::get_current_page( $pargs );
|
646 |
$html = PT_CV_Html::content_items_wrap( $content_items, $current_page, $args['posts_per_page'], $id );
|
647 |
|
648 |
// Append Pagination HTML if this is first page, or not Ajax calling
|
649 |
+
$type = isset( $dargs['pagination-settings']['type'] ) ? $dargs['pagination-settings']['type'] : 'ajax';
|
650 |
+
if ( $args['posts_per_page'] > 0 && ( ( $type == 'ajax' && $current_page === 1 ) || $type == 'normal' ) ) {
|
651 |
// Total post founds
|
652 |
$found_posts = apply_filters( PT_CV_PREFIX_ . 'found_posts', $pt_query->found_posts );
|
653 |
|
658 |
$max_num_pages = ceil( $total_items / $args['posts_per_page'] );
|
659 |
|
660 |
// Output pagination
|
661 |
+
$html .= "\n" . PT_CV_Html::pagination_output( $max_num_pages, $current_page, $session_id );
|
662 |
}
|
663 |
|
664 |
return $html;
|
988 |
$args['posts_per_page'] = $posts_per_page;
|
989 |
|
990 |
// Get offset
|
991 |
+
$paged = self::get_current_page( $pargs );
|
992 |
+
|
993 |
+
$offset = $posts_per_page * ( (int) $paged - 1 );
|
994 |
|
995 |
+
// Update posts_per_page
|
996 |
+
if ( intval( $args['posts_per_page'] ) > $limit - $offset ) {
|
997 |
+
$args['posts_per_page'] = $limit - $offset;
|
|
|
998 |
}
|
999 |
}
|
1000 |
|
1205 |
<?php
|
1206 |
}
|
1207 |
}
|
1208 |
+
|
1209 |
+
/**
|
1210 |
+
* Generate pagination button for each page
|
1211 |
+
* @param string $class Class name
|
1212 |
+
* @param string $this_page Page number
|
1213 |
+
* @param string $label Page label
|
1214 |
+
*/
|
1215 |
+
static function pagination_generate_link( $class, $this_page, $label = '' ) {
|
1216 |
+
$data_page = '';
|
1217 |
+
|
1218 |
+
if ( ! $label ) {
|
1219 |
+
$label = $this_page;
|
1220 |
+
$data_page = sprintf( ' data-page="%s"', $this_page );
|
1221 |
+
}
|
1222 |
+
|
1223 |
+
$html = sprintf( '<a%s href="%s">%s</a>', $data_page, add_query_arg( 'vpage', $this_page ), $label );
|
1224 |
+
$class = $class ? sprintf( ' class="%s"', esc_attr( $class ) ) : '';
|
1225 |
+
|
1226 |
+
return sprintf( '<li%s>%s</li>', $class, $html );
|
1227 |
+
}
|
1228 |
+
|
1229 |
+
/**
|
1230 |
+
* Pagination output
|
1231 |
+
*
|
1232 |
+
* @param int $total_pages Total pages
|
1233 |
+
* @param int $current_page Current page number
|
1234 |
+
* @param int $pages_to_show Number of page to show
|
1235 |
+
*/
|
1236 |
+
static function pagination( $total_pages, $current_page = 1, $pages_to_show = 4 ) {
|
1237 |
+
if ( $total_pages == 1 )
|
1238 |
+
return '';
|
1239 |
+
|
1240 |
+
$pages_to_show = apply_filters( PT_CV_PREFIX_ . 'pages_to_show', $pages_to_show );
|
1241 |
+
|
1242 |
+
// Define labels
|
1243 |
+
$labels = apply_filters( PT_CV_PREFIX_ . 'pagination_label', array(
|
1244 |
+
'prev' => '‹',
|
1245 |
+
'next' => '›',
|
1246 |
+
'first' => '«',
|
1247 |
+
'last' => '»',
|
1248 |
+
) );
|
1249 |
+
|
1250 |
+
$start = ( ( $current_page - $pages_to_show ) > 0 ) ? $current_page - $pages_to_show : 1;
|
1251 |
+
$end = ( ( $current_page + $pages_to_show ) < $total_pages ) ? $current_page + $pages_to_show : $total_pages;
|
1252 |
+
|
1253 |
+
$html = '';
|
1254 |
+
|
1255 |
+
$compared_page = 1;
|
1256 |
+
// First
|
1257 |
+
if ( $start > $compared_page ) {
|
1258 |
+
$html .= self::pagination_generate_link( '', $compared_page, $labels['first'] );
|
1259 |
+
}
|
1260 |
+
// Prev
|
1261 |
+
if ( $current_page > $compared_page ) {
|
1262 |
+
$html .= self::pagination_generate_link( '', $current_page - 1, $labels['prev'] );
|
1263 |
+
}
|
1264 |
+
|
1265 |
+
for ( $i = $start ; $i <= $end; $i++ ) {
|
1266 |
+
$html .= self::pagination_generate_link( ( $current_page == $i ) ? 'active' : '', $i );
|
1267 |
+
}
|
1268 |
+
|
1269 |
+
$compared_page = $total_pages;
|
1270 |
+
// Next
|
1271 |
+
if ( $current_page < $total_pages ) {
|
1272 |
+
$html .= self::pagination_generate_link( '', $current_page + 1, $labels['next'] );
|
1273 |
+
}
|
1274 |
+
// Last
|
1275 |
+
if ( $end < $compared_page ) {
|
1276 |
+
$html .= self::pagination_generate_link( '', $compared_page, $labels['last'] );
|
1277 |
+
}
|
1278 |
+
|
1279 |
+
return $html;
|
1280 |
+
}
|
1281 |
+
|
1282 |
+
/**
|
1283 |
+
* Get current page number
|
1284 |
+
*/
|
1285 |
+
static function get_current_page( $pargs ) {
|
1286 |
+
$paged = 1;
|
1287 |
+
|
1288 |
+
if ( ! empty( $pargs['page'] ) ) {
|
1289 |
+
$paged = intval( $pargs['page'] );
|
1290 |
+
}
|
1291 |
+
|
1292 |
+
if ( ! empty( $_GET['vpage'] ) ) {
|
1293 |
+
$paged = intval( $_GET['vpage'] );
|
1294 |
+
}
|
1295 |
+
|
1296 |
+
return $paged;
|
1297 |
+
}
|
1298 |
|
1299 |
}
|
1300 |
|
includes/html.php
CHANGED
@@ -324,8 +324,10 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
324 |
$html = $content_list;
|
325 |
}
|
326 |
|
327 |
-
|
328 |
-
|
|
|
|
|
329 |
// Get wrapper class of a view
|
330 |
$view_class = apply_filters( PT_CV_PREFIX_ . 'view_class', array( PT_CV_PREFIX . 'view', PT_CV_PREFIX . $view_type ) );
|
331 |
|
@@ -339,7 +341,7 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
339 |
$output = $html;
|
340 |
}
|
341 |
|
342 |
-
$before_output =
|
343 |
|
344 |
return balanceTags( $before_output ) . balanceTags( $output );
|
345 |
}
|
@@ -733,11 +735,12 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
733 |
* Output pagination
|
734 |
*
|
735 |
* @param type $max_num_pages The total of pages
|
|
|
736 |
* @param string $session_id The session ID of current view
|
737 |
*
|
738 |
* @return type
|
739 |
*/
|
740 |
-
static function pagination_output( $max_num_pages, $session_id ) {
|
741 |
global $dargs;
|
742 |
|
743 |
if ( ! $max_num_pages || (int) $max_num_pages === 1 ) {
|
@@ -747,15 +750,17 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
747 |
$pagination_btn = '';
|
748 |
|
749 |
$style = isset( $dargs['pagination-settings']['style'] ) ? $dargs['pagination-settings']['style'] : 'regular';
|
|
|
750 |
if ( $style == 'regular' ) {
|
751 |
-
$pagination_btn = sprintf( '<ul class="%s" data-totalpages="%s" data-sid="%s"
|
752 |
} else {
|
753 |
$pagination_btn = apply_filters( PT_CV_PREFIX_ . 'btn_more_html', $pagination_btn, $max_num_pages, $session_id );
|
754 |
}
|
755 |
// Add loading icon
|
756 |
$pagination_btn .= self::html_loading_img( 12, PT_CV_PREFIX . 'spinner' );
|
757 |
|
758 |
-
$
|
|
|
759 |
|
760 |
return $output;
|
761 |
}
|
@@ -873,6 +878,22 @@ if ( ! class_exists( 'PT_CV_Html' ) ) {
|
|
873 |
'_nonce' => wp_create_nonce( PT_CV_PREFIX_ . 'ajax_nonce' ),
|
874 |
)
|
875 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
876 |
}
|
877 |
|
878 |
/**
|
324 |
$html = $content_list;
|
325 |
}
|
326 |
|
327 |
+
$type = isset( $dargs['pagination-settings']['type'] ) ? $dargs['pagination-settings']['type'] : 'ajax';
|
328 |
+
$display = ( $type == 'ajax' && $current_page === 1 ) || $type == 'normal';
|
329 |
+
|
330 |
+
if ( $display ) {
|
331 |
// Get wrapper class of a view
|
332 |
$view_class = apply_filters( PT_CV_PREFIX_ . 'view_class', array( PT_CV_PREFIX . 'view', PT_CV_PREFIX . $view_type ) );
|
333 |
|
341 |
$output = $html;
|
342 |
}
|
343 |
|
344 |
+
$before_output = $display ? apply_filters( PT_CV_PREFIX_ . 'before_output_html', '' ) : '';
|
345 |
|
346 |
return balanceTags( $before_output ) . balanceTags( $output );
|
347 |
}
|
735 |
* Output pagination
|
736 |
*
|
737 |
* @param type $max_num_pages The total of pages
|
738 |
+
* @param type $current_page The current pages
|
739 |
* @param string $session_id The session ID of current view
|
740 |
*
|
741 |
* @return type
|
742 |
*/
|
743 |
+
static function pagination_output( $max_num_pages, $current_page, $session_id ) {
|
744 |
global $dargs;
|
745 |
|
746 |
if ( ! $max_num_pages || (int) $max_num_pages === 1 ) {
|
750 |
$pagination_btn = '';
|
751 |
|
752 |
$style = isset( $dargs['pagination-settings']['style'] ) ? $dargs['pagination-settings']['style'] : 'regular';
|
753 |
+
$type = isset( $dargs['pagination-settings']['type'] ) ? $dargs['pagination-settings']['type'] : 'ajax';
|
754 |
if ( $style == 'regular' ) {
|
755 |
+
$pagination_btn = sprintf( '<ul class="%s" data-totalpages="%s" data-sid="%s">%s</ul>', PT_CV_PREFIX . 'pagination' . ' ' . PT_CV_PREFIX . $type . ' pagination', esc_attr( $max_num_pages ), esc_attr( $session_id ), PT_CV_Functions::pagination( $max_num_pages, $current_page ) );
|
756 |
} else {
|
757 |
$pagination_btn = apply_filters( PT_CV_PREFIX_ . 'btn_more_html', $pagination_btn, $max_num_pages, $session_id );
|
758 |
}
|
759 |
// Add loading icon
|
760 |
$pagination_btn .= self::html_loading_img( 12, PT_CV_PREFIX . 'spinner' );
|
761 |
|
762 |
+
$wrapper_class = apply_filters( PT_CV_PREFIX_ . 'pagination_class', '' );
|
763 |
+
$output = apply_filters( PT_CV_PREFIX_ . 'pagination_output', sprintf( '<div class="%s">%s</div>', $wrapper_class . ' ' . PT_CV_PREFIX . 'pagination-wrapper', $pagination_btn ) );
|
764 |
|
765 |
return $output;
|
766 |
}
|
878 |
'_nonce' => wp_create_nonce( PT_CV_PREFIX_ . 'ajax_nonce' ),
|
879 |
)
|
880 |
);
|
881 |
+
|
882 |
+
// Localize for Pagination script
|
883 |
+
PT_CV_Asset::localize_script(
|
884 |
+
'bootstrap-paginator', PT_CV_PREFIX_UPPER . 'PAGINATION', array(
|
885 |
+
'first' => apply_filters( PT_CV_PREFIX_ . 'pagination_first', '«' ),
|
886 |
+
'prev' => apply_filters( PT_CV_PREFIX_ . 'pagination_prev', '‹' ),
|
887 |
+
'next' => apply_filters( PT_CV_PREFIX_ . 'pagination_next', '›' ),
|
888 |
+
'last' => apply_filters( PT_CV_PREFIX_ . 'pagination_last', '»' ),
|
889 |
+
'goto_first' => apply_filters( PT_CV_PREFIX_ . 'goto_first', __( 'Go to first page', PT_CV_DOMAIN ) ),
|
890 |
+
'goto_prev' => apply_filters( PT_CV_PREFIX_ . 'goto_prev', __( 'Go to previous page', PT_CV_DOMAIN ) ),
|
891 |
+
'goto_next' => apply_filters( PT_CV_PREFIX_ . 'goto_next', __( 'Go to next page', PT_CV_DOMAIN ) ),
|
892 |
+
'goto_last' => apply_filters( PT_CV_PREFIX_ . 'goto_last', __( 'Go to last page', PT_CV_DOMAIN ) ),
|
893 |
+
'current_page' => apply_filters( PT_CV_PREFIX_ . 'current_page', __( 'Current page is', PT_CV_DOMAIN ) ),
|
894 |
+
'goto_page' => apply_filters( PT_CV_PREFIX_ . 'goto_page', __( 'Go to page', PT_CV_DOMAIN ) ),
|
895 |
+
)
|
896 |
+
);
|
897 |
}
|
898 |
|
899 |
/**
|
includes/settings.php
CHANGED
@@ -166,18 +166,53 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
166 |
),
|
167 |
'dependence' => array( 'enable-pagination', 'yes' ),
|
168 |
),
|
169 |
-
|
170 |
-
// Pagination
|
171 |
array(
|
172 |
'label' => array(
|
173 |
-
'text' => __( 'Pagination
|
174 |
),
|
175 |
'params' => array(
|
176 |
array(
|
177 |
'type' => 'radio',
|
178 |
-
'name' => $prefix . '
|
179 |
-
'options' => PT_CV_Values::
|
180 |
-
'std' =>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
),
|
182 |
),
|
183 |
'dependence' => array( 'enable-pagination', 'yes' ),
|
@@ -249,7 +284,7 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
249 |
),
|
250 |
|
251 |
// Upgrade to Pro
|
252 |
-
|
253 |
'label' => array(
|
254 |
'text' => '',
|
255 |
),
|
@@ -264,7 +299,7 @@ if ( ! class_exists( 'PT_CV_Settings' ) ) {
|
|
264 |
'content' => sprintf( '<p class="text-muted" style="margin-top: -10px; margin-bottom: 15px;">→ %s</p>', __( 'Customize display order of above fields by a simple drag-and-drop ?', PT_CV_DOMAIN ) . sprintf( ' <a href="%s" target="_blank">%s</a>', esc_url( 'http://www.contentviewspro.com/pricing/?utm_source=client&utm_medium=view' ), __( 'Please upgrade to Pro', PT_CV_DOMAIN ) ) ),
|
265 |
),
|
266 |
),
|
267 |
-
)
|
268 |
|
269 |
// Title settings
|
270 |
apply_filters( PT_CV_PREFIX_ . 'settings_title_display', array(), $prefix, $prefix2 ),
|
166 |
),
|
167 |
'dependence' => array( 'enable-pagination', 'yes' ),
|
168 |
),
|
169 |
+
|
170 |
+
// Pagination Type
|
171 |
array(
|
172 |
'label' => array(
|
173 |
+
'text' => __( 'Pagination type', PT_CV_DOMAIN ),
|
174 |
),
|
175 |
'params' => array(
|
176 |
array(
|
177 |
'type' => 'radio',
|
178 |
+
'name' => $prefix . 'type',
|
179 |
+
'options' => PT_CV_Values::pagination_types(),
|
180 |
+
'std' => 'ajax',
|
181 |
+
),
|
182 |
+
),
|
183 |
+
'dependence' => array( 'enable-pagination', 'yes' ),
|
184 |
+
),
|
185 |
+
|
186 |
+
// Pagination Style
|
187 |
+
array(
|
188 |
+
'label' => array(
|
189 |
+
'text' => '',
|
190 |
+
),
|
191 |
+
'extra_setting' => array(
|
192 |
+
'params' => array(
|
193 |
+
'width' => 12,
|
194 |
+
),
|
195 |
+
),
|
196 |
+
'params' => array(
|
197 |
+
array(
|
198 |
+
'type' => 'group',
|
199 |
+
'params' => array(
|
200 |
+
array(
|
201 |
+
'label' => array(
|
202 |
+
'text' => __( 'Pagination style', PT_CV_DOMAIN ),
|
203 |
+
),
|
204 |
+
'params' => array(
|
205 |
+
array(
|
206 |
+
'type' => 'radio',
|
207 |
+
'name' => $prefix . 'style',
|
208 |
+
'options' => PT_CV_Values::pagination_styles(),
|
209 |
+
'std' => PT_CV_Functions::array_get_first_key( PT_CV_Values::pagination_styles() ),
|
210 |
+
'desc' => __( 'Output style for Ajax pagination', PT_CV_DOMAIN ),
|
211 |
+
),
|
212 |
+
),
|
213 |
+
'dependence' => array( $prefix . 'type', 'normal', '!=' ),
|
214 |
+
),
|
215 |
+
),
|
216 |
),
|
217 |
),
|
218 |
'dependence' => array( 'enable-pagination', 'yes' ),
|
284 |
),
|
285 |
|
286 |
// Upgrade to Pro
|
287 |
+
! get_option( 'pt_cv_version_pro' ) ? array(
|
288 |
'label' => array(
|
289 |
'text' => '',
|
290 |
),
|
299 |
'content' => sprintf( '<p class="text-muted" style="margin-top: -10px; margin-bottom: 15px;">→ %s</p>', __( 'Customize display order of above fields by a simple drag-and-drop ?', PT_CV_DOMAIN ) . sprintf( ' <a href="%s" target="_blank">%s</a>', esc_url( 'http://www.contentviewspro.com/pricing/?utm_source=client&utm_medium=view' ), __( 'Please upgrade to Pro', PT_CV_DOMAIN ) ) ),
|
300 |
),
|
301 |
),
|
302 |
+
) : '',
|
303 |
|
304 |
// Title settings
|
305 |
apply_filters( PT_CV_PREFIX_ . 'settings_title_display', array(), $prefix, $prefix2 ),
|
includes/values.php
CHANGED
@@ -196,6 +196,22 @@ if ( ! class_exists( 'PT_CV_Values' ) ) {
|
|
196 |
);
|
197 |
}
|
198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
/**
|
200 |
* Paging styles
|
201 |
*
|
196 |
);
|
197 |
}
|
198 |
|
199 |
+
/**
|
200 |
+
* Paging types
|
201 |
+
*
|
202 |
+
* @return array
|
203 |
+
*/
|
204 |
+
static function pagination_types() {
|
205 |
+
$result = array(
|
206 |
+
'ajax' => __( 'Ajax', PT_CV_DOMAIN ),
|
207 |
+
'normal' => __( 'Normal', PT_CV_DOMAIN ),
|
208 |
+
);
|
209 |
+
|
210 |
+
$result = apply_filters( PT_CV_PREFIX_ . 'pagination_types', $result );
|
211 |
+
|
212 |
+
return $result;
|
213 |
+
}
|
214 |
+
|
215 |
/**
|
216 |
* Paging styles
|
217 |
*
|
public/assets/css/public.css
CHANGED
@@ -157,6 +157,21 @@
|
|
157 |
margin-bottom: 50px;
|
158 |
}
|
159 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
/* View type : Collapsible List */
|
161 |
.pt-cv-collapsible .panel-heading {
|
162 |
padding: 0;
|
157 |
margin-bottom: 50px;
|
158 |
}
|
159 |
|
160 |
+
.pt-cv-pagination-wrapper {
|
161 |
+
clear: both;
|
162 |
+
position: relative;
|
163 |
+
}
|
164 |
+
|
165 |
+
.pt-cv-pagination.pagination {
|
166 |
+
-webkit-box-shadow: none !important;
|
167 |
+
box-shadow: none !important;
|
168 |
+
margin-left: 0;
|
169 |
+
}
|
170 |
+
|
171 |
+
.pt-cv-pagination li.active a {
|
172 |
+
border-color: rgba(66, 139, 202, 0.2) !important;
|
173 |
+
}
|
174 |
+
|
175 |
/* View type : Collapsible List */
|
176 |
.pt-cv-collapsible .panel-heading {
|
177 |
padding: 0;
|
public/assets/js/public.js
CHANGED
@@ -50,7 +50,7 @@
|
|
50 |
var _prefix = PT_CV_PUBLIC._prefix;
|
51 |
|
52 |
// Bootstrap paginator
|
53 |
-
$('.' + _prefix + 'pagination').each(function () {
|
54 |
var this_ = $(this);
|
55 |
var total_pages = $(this).attr('data-totalpages');
|
56 |
$(this).bootstrapPaginator({
|
50 |
var _prefix = PT_CV_PUBLIC._prefix;
|
51 |
|
52 |
// Bootstrap paginator
|
53 |
+
$('.' + _prefix + 'pagination.' + _prefix + 'ajax').each(function () {
|
54 |
var this_ = $(this);
|
55 |
var total_pages = $(this).attr('data-totalpages');
|
56 |
$(this).bootstrapPaginator({
|