Version Description
- December 9th 2020 =
- Load more placeholders
Download this release
Release Info
Developer | Kometschuh |
Plugin | Category Posts Widget |
Version | 4.9.9 |
Comparing to | |
See all releases |
Code changes from version 4.9.8 to 4.9.9
- cat-posts.php +82 -81
- class-virtual-widget.php +1 -11
- class-widget.php +68 -13
- js/admin/category-posts-widget.js +12 -1
- js/admin/category-posts-widget.min.js +1 -1
- js/frontend/loadmore.js +53 -37
- js/frontend/loadmore.min.js +1 -1
- loadmore.php +2 -2
- readme.txt +4 -1
- styles/admin/category-posts-widget.css +2 -2
cat-posts.php
CHANGED
@@ -12,7 +12,7 @@ Plugin Name: Category Posts Widget
|
|
12 |
Plugin URI: https://wordpress.org/plugins/category-posts/
|
13 |
Description: Adds a widget that shows the most recent posts from a single category.
|
14 |
Author: TipTopPress
|
15 |
-
Version: 4.9.
|
16 |
Author URI: http://tiptoppress.com
|
17 |
Text Domain: category-posts
|
18 |
Domain Path: /languages
|
@@ -25,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
25 |
exit;
|
26 |
}
|
27 |
|
28 |
-
const VERSION = '4.9.
|
29 |
const DOC_URL = 'http://tiptoppress.com/category-posts-widget/documentation-4-9/';
|
30 |
const PRO_URL = 'http://tiptoppress.com/term-and-category-based-posts-widget/';
|
31 |
const SUPPORT_URL = 'https://wordpress.org/support/plugin/category-posts/';
|
@@ -453,93 +453,94 @@ function equal_cover_content_height( $number, $widgetsettings ) {
|
|
453 |
?>
|
454 |
<script type="text/javascript">
|
455 |
if (typeof jQuery !== 'undefined') {
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
|
|
|
|
|
|
489 |
cat_posts_namespace.layout_wrap_text.add(_this);
|
490 |
-
} else {
|
491 |
-
jQuery(_this).find('img').one("load", function(){
|
492 |
-
cat_posts_namespace.layout_wrap_text.add(_this);
|
493 |
-
});
|
494 |
-
}
|
495 |
-
return;
|
496 |
-
},
|
497 |
-
<?php /* Handle post items */ echo "\r\n"; ?>
|
498 |
-
setClass : function (widget) {
|
499 |
-
// var _widget = jQuery(widget);
|
500 |
-
jQuery(widget).find('.cat-post-item').each(function(){
|
501 |
-
cat_posts_namespace.layout_wrap_text.handleLazyLoading(this);
|
502 |
});
|
503 |
-
return;
|
504 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
505 |
}
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
|
|
|
|
|
|
|
|
527 |
cat_posts_namespace.layout_img_size.replace(_this);
|
528 |
-
} else {
|
529 |
-
jQuery(_this).one("load", function(){
|
530 |
-
cat_posts_namespace.layout_img_size.replace(_this);
|
531 |
-
});
|
532 |
-
}
|
533 |
-
return;
|
534 |
-
},
|
535 |
-
setHeight : function (widget) {
|
536 |
-
jQuery(widget).find('.cat-post-item img').each(function(){
|
537 |
-
cat_posts_namespace.layout_img_size.handleLazyLoading(this);
|
538 |
});
|
539 |
-
return;
|
540 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
541 |
}
|
|
|
542 |
|
|
|
543 |
var widget = jQuery('#<?php echo esc_attr( $number ); ?>');
|
544 |
|
545 |
<?php /* do once on document ready */ echo "\r\n"; ?>
|
@@ -716,7 +717,7 @@ function default_settings() {
|
|
716 |
'template' => "%title%\n\n%thumb%",
|
717 |
'text_do_not_wrap_thumb' => false,
|
718 |
'enable_loadmore' => false,
|
719 |
-
'loadmore_text' => __( 'Load More', 'category-posts' ),
|
720 |
'loading_text' => __( 'Loading...', 'category-posts' ),
|
721 |
'date_range' => 'off',
|
722 |
'start_date' => '',
|
12 |
Plugin URI: https://wordpress.org/plugins/category-posts/
|
13 |
Description: Adds a widget that shows the most recent posts from a single category.
|
14 |
Author: TipTopPress
|
15 |
+
Version: 4.9.9
|
16 |
Author URI: http://tiptoppress.com
|
17 |
Text Domain: category-posts
|
18 |
Domain Path: /languages
|
25 |
exit;
|
26 |
}
|
27 |
|
28 |
+
const VERSION = '4.9.9';
|
29 |
const DOC_URL = 'http://tiptoppress.com/category-posts-widget/documentation-4-9/';
|
30 |
const PRO_URL = 'http://tiptoppress.com/term-and-category-based-posts-widget/';
|
31 |
const SUPPORT_URL = 'https://wordpress.org/support/plugin/category-posts/';
|
453 |
?>
|
454 |
<script type="text/javascript">
|
455 |
if (typeof jQuery !== 'undefined') {
|
456 |
+
|
457 |
+
var cat_posts_namespace = window.cat_posts_namespace || {};
|
458 |
+
cat_posts_namespace.layout_wrap_text = cat_posts_namespace.layout_wrap_text || {};
|
459 |
+
cat_posts_namespace.layout_img_size = cat_posts_namespace.layout_img_size || {};
|
460 |
+
|
461 |
+
cat_posts_namespace.layout_wrap_text = {
|
462 |
+
<?php /* Handle item */ echo "\r\n"; ?>
|
463 |
+
preWrap : function (widget) {
|
464 |
+
// var _widget = jQuery(widget);
|
465 |
+
jQuery(widget).find('.cat-post-item').each(function(){
|
466 |
+
var _that = jQuery(this);
|
467 |
+
_that.find('p.cpwp-excerpt-text').addClass('cpwp-wrap-text');
|
468 |
+
_that.find('p.cpwp-excerpt-text').closest('div').wrap('<div class="cpwp-wrap-text-stage"></div>');;
|
469 |
+
});
|
470 |
+
return;
|
471 |
+
},
|
472 |
+
<?php /* Handle add class */ echo "\r\n"; ?>
|
473 |
+
add : function(_this){
|
474 |
+
var _that = jQuery(_this);
|
475 |
+
if (_that.find('p.cpwp-excerpt-text').height() < _that.find('.cat-post-thumbnail').height()) { <?php /* don't move class to do the CSS hack, line's height is smaller as thumb */ echo "\r\n"; ?>
|
476 |
+
_that.find('p.cpwp-excerpt-text').closest('.cpwp-wrap-text-stage').removeClass( "cpwp-wrap-text" );
|
477 |
+
_that.find('p.cpwp-excerpt-text').addClass( "cpwp-wrap-text" ); <?php /* don't do the CSS hack, just set the class */ echo "\r\n"; ?>
|
478 |
+
}else{ <?php /* add the CSS hack, it's needed, text is wrapping, line's height is higher as thumb */ echo "\r\n"; ?>
|
479 |
+
_that.find('p.cpwp-excerpt-text').removeClass( "cpwp-wrap-text" );
|
480 |
+
_that.find('p.cpwp-excerpt-text').closest('.cpwp-wrap-text-stage').addClass( "cpwp-wrap-text" ); <?php /* text is wrapping, do the CSS hack */ echo "\r\n"; ?>
|
481 |
+
}
|
482 |
+
return;
|
483 |
+
},
|
484 |
+
<?php /* Wait for image is loaded */ echo "\r\n"; ?>
|
485 |
+
handleLazyLoading : function(_this) {
|
486 |
+
var width = jQuery(_this).find('img').width();
|
487 |
+
<?php /* image is loaded */ echo "\r\n"; ?>
|
488 |
+
if( 0 !== width ){
|
489 |
+
cat_posts_namespace.layout_wrap_text.add(_this);
|
490 |
+
} else {
|
491 |
+
jQuery(_this).find('img').one("load", function(){
|
492 |
cat_posts_namespace.layout_wrap_text.add(_this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
493 |
});
|
|
|
494 |
}
|
495 |
+
return;
|
496 |
+
},
|
497 |
+
<?php /* Handle post items */ echo "\r\n"; ?>
|
498 |
+
setClass : function (widget) {
|
499 |
+
// var _widget = jQuery(widget);
|
500 |
+
jQuery(widget).find('.cat-post-item').each(function(){
|
501 |
+
cat_posts_namespace.layout_wrap_text.handleLazyLoading(this);
|
502 |
+
});
|
503 |
+
return;
|
504 |
}
|
505 |
+
}
|
506 |
+
cat_posts_namespace.layout_img_size = {
|
507 |
+
<?php /* Handle replace */ echo "\r\n"; ?>
|
508 |
+
replace : function(_this){
|
509 |
+
var _that = jQuery(_this),
|
510 |
+
resp_w = _that.width(),
|
511 |
+
resp_h = _that.height(),
|
512 |
+
orig_w = _that.data('cat-posts-width'),
|
513 |
+
orig_h = _that.data('cat-posts-height');
|
514 |
+
<?php /* replace height */ echo "\r\n"; ?>
|
515 |
+
if( resp_w < orig_w ){
|
516 |
+
_that.height( resp_w * orig_h / orig_w );
|
517 |
+
} else {
|
518 |
+
_that.height( '' );
|
519 |
+
}
|
520 |
+
return;
|
521 |
+
},
|
522 |
+
<?php /* Wait for image is loaded */ echo "\r\n"; ?>
|
523 |
+
handleLazyLoading : function(_this) {
|
524 |
+
var width = jQuery(_this).width();
|
525 |
+
<?php /* image is loaded */ echo "\r\n"; ?>
|
526 |
+
if( 0 !== width ){
|
527 |
+
cat_posts_namespace.layout_img_size.replace(_this);
|
528 |
+
} else {
|
529 |
+
jQuery(_this).one("load", function(){
|
530 |
cat_posts_namespace.layout_img_size.replace(_this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
531 |
});
|
|
|
532 |
}
|
533 |
+
return;
|
534 |
+
},
|
535 |
+
setHeight : function (widget) {
|
536 |
+
jQuery(widget).find('.cat-post-item img').each(function(){
|
537 |
+
cat_posts_namespace.layout_img_size.handleLazyLoading(this);
|
538 |
+
});
|
539 |
+
return;
|
540 |
}
|
541 |
+
}
|
542 |
|
543 |
+
jQuery( document ).ready(function () {
|
544 |
var widget = jQuery('#<?php echo esc_attr( $number ); ?>');
|
545 |
|
546 |
<?php /* do once on document ready */ echo "\r\n"; ?>
|
717 |
'template' => "%title%\n\n%thumb%",
|
718 |
'text_do_not_wrap_thumb' => false,
|
719 |
'enable_loadmore' => false,
|
720 |
+
'loadmore_text' => sprintf( __( 'Load More (%s/%s)', 'category-posts' ), '%step%', '%all%'),
|
721 |
'loading_text' => __( 'Loading...', 'category-posts' ),
|
722 |
'date_range' => 'off',
|
723 |
'start_date' => '',
|
class-virtual-widget.php
CHANGED
@@ -173,6 +173,7 @@ class Virtual_Widget {
|
|
173 |
'thumb' => '.cat-post-thumbnail {margin: 5px 10px 5px 0;}',
|
174 |
'item_clenup' => '.cat-post-item:before {content: ""; clear: both;}',
|
175 |
'more_link' => '.cat-post-excerpt-more {display: inline-block;}',
|
|
|
176 |
);
|
177 |
|
178 |
if ( ! ( isset( $settings['disable_font_styles'] ) && $settings['disable_font_styles'] ) ) { // checks if disable font styles is not set.
|
@@ -182,17 +183,6 @@ class Virtual_Widget {
|
|
182 |
$styles['post-tax-childs'] = '[class*=cat-post-tax] * {display:inline-block;}';
|
183 |
}
|
184 |
|
185 |
-
/*
|
186 |
-
* The twenty seventeen theme have a border between the LI elements of a widget,
|
187 |
-
* so remove our border if we detect its use to avoid conflicting styling.
|
188 |
-
*/
|
189 |
-
if ( ! $is_shortcode && function_exists( 'twentyseventeen_setup' ) ) {
|
190 |
-
$styles['item_style'] = '.cat-post-item {list-style: none; list-style-type: none; margin: 0; padding: 3px 0 10px;}';
|
191 |
-
} else {
|
192 |
-
$styles['item_style'] = '.cat-post-item {border-bottom: 1px solid #ccc; list-style: none; list-style-type: none; margin: 3px 0 10px; padding: 3px 0;}';
|
193 |
-
$styles['last_item_style'] = '.cat-post-item:last-child {border-bottom: none;}';
|
194 |
-
}
|
195 |
-
|
196 |
// everything link related styling
|
197 |
// if we are dealing with "everything is a link" option, we need to add the clear:both to the a element, not the div.
|
198 |
if ( $everything_is_link ) {
|
173 |
'thumb' => '.cat-post-thumbnail {margin: 5px 10px 5px 0;}',
|
174 |
'item_clenup' => '.cat-post-item:before {content: ""; clear: both;}',
|
175 |
'more_link' => '.cat-post-excerpt-more {display: inline-block;}',
|
176 |
+
'item_style' => '.cat-post-item {list-style: none; margin: 3px 0 10px; padding: 3px 0;}',
|
177 |
);
|
178 |
|
179 |
if ( ! ( isset( $settings['disable_font_styles'] ) && $settings['disable_font_styles'] ) ) { // checks if disable font styles is not set.
|
183 |
$styles['post-tax-childs'] = '[class*=cat-post-tax] * {display:inline-block;}';
|
184 |
}
|
185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
// everything link related styling
|
187 |
// if we are dealing with "everything is a link" option, we need to add the clear:both to the a element, not the div.
|
188 |
if ( $everything_is_link ) {
|
class-widget.php
CHANGED
@@ -63,7 +63,17 @@ class Widget extends \WP_Widget {
|
|
63 |
}
|
64 |
|
65 |
// HTML generated by the core APIs.
|
66 |
-
$html = wp_get_attachment_image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
if ( ! $html ) {
|
68 |
return '';
|
69 |
}
|
@@ -395,8 +405,9 @@ class Widget extends \WP_Widget {
|
|
395 |
* @since 4.9
|
396 |
*/
|
397 |
public function loadMoreHTML( $instance ) {
|
|
|
398 |
|
399 |
-
if ( ! $instance['enable_loadmore'] ) {
|
400 |
return '';
|
401 |
}
|
402 |
|
@@ -418,11 +429,23 @@ class Widget extends \WP_Widget {
|
|
418 |
$id = str_replace( WIDGET_BASE_ID . '-', '', $this->number );
|
419 |
}
|
420 |
|
421 |
-
|
422 |
-
$
|
423 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
424 |
|
425 |
-
$ret .= '<button type="button" data-loading="' . esc_attr( $loading ) . '" data-id="' . esc_attr( $id ) .
|
|
|
|
|
|
|
|
|
426 |
$ret .= '</div>';
|
427 |
return $ret;
|
428 |
}
|
@@ -1069,6 +1092,8 @@ class Widget extends \WP_Widget {
|
|
1069 |
* are no applicable items.
|
1070 |
*/
|
1071 |
public function get_elements_HTML( $instance, $singular_id, $start, $number ) {
|
|
|
|
|
1072 |
$ret = array();
|
1073 |
|
1074 |
if ( 0 === count( $instance ) ) {
|
@@ -1087,6 +1112,12 @@ class Widget extends \WP_Widget {
|
|
1087 |
}
|
1088 |
$args = $this->queryArgs( $instance );
|
1089 |
$cat_posts = new \WP_Query( $args );
|
|
|
|
|
|
|
|
|
|
|
|
|
1090 |
$current_post_id = null;
|
1091 |
if ( '' !== $singular_id ) {
|
1092 |
$current_post_id = (int) $singular_id;
|
@@ -1737,11 +1768,15 @@ class Widget extends \WP_Widget {
|
|
1737 |
<p><?php esc_html_e( 'More Link settings', 'category-posts' ); ?></p>
|
1738 |
<div class="cpwp_ident">
|
1739 |
<?php
|
1740 |
-
echo $this->get_text_input_block_html
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
|
|
|
|
|
|
|
|
1745 |
?>
|
1746 |
<div class="cat-post-more-link-help" style="display:none;">
|
1747 |
<p><?php echo sprintf( __( 'Text in the \'more\' link. Can be text, HTML and <a target="_blank" href="%s">Dashicons</a>.', 'category-posts' ),
|
@@ -1924,8 +1959,28 @@ class Widget extends \WP_Widget {
|
|
1924 |
<div class="cpwp_ident">
|
1925 |
<?php echo $this->get_checkbox_block_html( $instance, 'enable_loadmore', esc_html__( 'Enable Load More', 'category-posts' ), true ); ?>
|
1926 |
<div class="loadmore-settings" style="display:<?php echo ( $instance['enable_loadmore'] ) ? 'block' : 'none'; ?>">
|
1927 |
-
<?php
|
1928 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1929 |
</div>
|
1930 |
</div>
|
1931 |
</div>
|
63 |
}
|
64 |
|
65 |
// HTML generated by the core APIs.
|
66 |
+
$html = wp_get_attachment_image
|
67 |
+
(
|
68 |
+
$post_thumbnail_id,
|
69 |
+
$thumbSize,
|
70 |
+
false,
|
71 |
+
array
|
72 |
+
(
|
73 |
+
"data-cat-posts-width" => $this->instance['thumb_w'],
|
74 |
+
"data-cat-posts-height" => $this->instance['thumb_h']
|
75 |
+
)
|
76 |
+
);
|
77 |
if ( ! $html ) {
|
78 |
return '';
|
79 |
}
|
405 |
* @since 4.9
|
406 |
*/
|
407 |
public function loadMoreHTML( $instance ) {
|
408 |
+
global $post_count;
|
409 |
|
410 |
+
if ( ! $instance['enable_loadmore'] || $post_count <= $instance['num'] ) {
|
411 |
return '';
|
412 |
}
|
413 |
|
429 |
$id = str_replace( WIDGET_BASE_ID . '-', '', $this->number );
|
430 |
}
|
431 |
|
432 |
+
// Placeholder
|
433 |
+
$placeholder_text = $instance['loadmore_text'] !== '' ? $instance['loadmore_text'] : sprintf( esc_attr__( 'Load More (%s/%s)', 'category-posts' ), '%step%', '%all%');
|
434 |
+
$pattern = '/%step%/';
|
435 |
+
$loadmore_text = preg_replace( $pattern, $instance['num'], $placeholder_text );
|
436 |
+
$pattern = '/%all%/';
|
437 |
+
$loadmore_text = preg_replace( $pattern, $post_count, $loadmore_text );
|
438 |
+
|
439 |
+
// Load more
|
440 |
+
$number = $instance['num'];
|
441 |
+
$start = $instance['offset'] + $number;
|
442 |
+
$loading = $instance['loading_text'] !== '' ? $instance['loading_text'] : esc_attr__( 'Loading...', 'category-posts' );
|
443 |
|
444 |
+
$ret .= '<button type="button" data-loading="' . esc_attr( $loading ) . '" data-id="' . esc_attr( $id ) .
|
445 |
+
'" data-start="' . esc_attr( $start ) . '" data-context="' . esc_attr( $context ) . '" data-number="' .
|
446 |
+
esc_attr( $number ) . '" data-post-count="' . esc_attr( $post_count ) . '" data-placeholder="' . esc_attr( $placeholder_text ) . '">' .
|
447 |
+
esc_html( $loadmore_text ) .
|
448 |
+
'</button>';
|
449 |
$ret .= '</div>';
|
450 |
return $ret;
|
451 |
}
|
1092 |
* are no applicable items.
|
1093 |
*/
|
1094 |
public function get_elements_HTML( $instance, $singular_id, $start, $number ) {
|
1095 |
+
global $post_count;
|
1096 |
+
|
1097 |
$ret = array();
|
1098 |
|
1099 |
if ( 0 === count( $instance ) ) {
|
1112 |
}
|
1113 |
$args = $this->queryArgs( $instance );
|
1114 |
$cat_posts = new \WP_Query( $args );
|
1115 |
+
|
1116 |
+
if( isset( $instance['enable_loadmore'] ) && $instance['enable_loadmore'] ) {
|
1117 |
+
$args['showposts'] = 0;
|
1118 |
+
$post_count = ( new \WP_Query( $args ) )->post_count; // May there is a better workflow to count the loadable items
|
1119 |
+
}
|
1120 |
+
|
1121 |
$current_post_id = null;
|
1122 |
if ( '' !== $singular_id ) {
|
1123 |
$current_post_id = (int) $singular_id;
|
1768 |
<p><?php esc_html_e( 'More Link settings', 'category-posts' ); ?></p>
|
1769 |
<div class="cpwp_ident">
|
1770 |
<?php
|
1771 |
+
echo $this->get_text_input_block_html
|
1772 |
+
(
|
1773 |
+
$instance, 'excerpt_more_text',
|
1774 |
+
esc_html__( '\'Read more\' text', 'category-posts' ) .
|
1775 |
+
' <a href="#" class="dashicons toggle-more-link-help dashicons-editor-help">' .
|
1776 |
+
'<span class="screen-reader-text">' . esc_html__( 'Show More Link help', 'category-posts' ) . '</span>' .
|
1777 |
+
'</a>', esc_attr__( '[…]', 'category-posts' ),
|
1778 |
+
true
|
1779 |
+
);
|
1780 |
?>
|
1781 |
<div class="cat-post-more-link-help" style="display:none;">
|
1782 |
<p><?php echo sprintf( __( 'Text in the \'more\' link. Can be text, HTML and <a target="_blank" href="%s">Dashicons</a>.', 'category-posts' ),
|
1959 |
<div class="cpwp_ident">
|
1960 |
<?php echo $this->get_checkbox_block_html( $instance, 'enable_loadmore', esc_html__( 'Enable Load More', 'category-posts' ), true ); ?>
|
1961 |
<div class="loadmore-settings" style="display:<?php echo ( $instance['enable_loadmore'] ) ? 'block' : 'none'; ?>">
|
1962 |
+
<?php
|
1963 |
+
echo $this->get_text_input_block_html( $instance, 'loadmore_text',
|
1964 |
+
esc_html__( 'Button text', 'category-posts' ) .
|
1965 |
+
' <a href="#" class="dashicons toggle-button-text-help dashicons-editor-help">' .
|
1966 |
+
'<span class="screen-reader-text">' . esc_html__( 'Show button text help', 'category-posts' ) . '</span>' .
|
1967 |
+
'</a>', sprintf( esc_attr__( 'Load More (%s/%s)', 'category-posts' ), '%step%', '%all%'), true );
|
1968 |
+
?>
|
1969 |
+
<div class="cat-post-button-text-help" style="display:none;">
|
1970 |
+
<p><?php echo esc_html__( 'The following placeholders will be replaced with the relevant information.', 'category-posts' ); ?>
|
1971 |
+
</p>
|
1972 |
+
<table>
|
1973 |
+
<tr>
|
1974 |
+
<th><?php esc_html_e( '%step%', 'category-posts' ); ?></th>
|
1975 |
+
<td><?php esc_html_e( 'Loaded items', 'category-posts' ); ?></td>
|
1976 |
+
</tr>
|
1977 |
+
<tr>
|
1978 |
+
<th><?php esc_html_e( '%all%', 'category-posts' ); ?></th>
|
1979 |
+
<td><?php esc_html_e( 'All possible items for the set filter query', 'category-posts' ); ?></td>
|
1980 |
+
</tr>
|
1981 |
+
</table>
|
1982 |
+
</div>
|
1983 |
+
<?php echo $this->get_text_input_block_html( $instance, 'loading_text', esc_html__( 'Loading text', 'category-posts' ), esc_attr__( 'Loading...', 'category-posts' ), true ); ?>
|
1984 |
</div>
|
1985 |
</div>
|
1986 |
</div>
|
js/admin/category-posts-widget.js
CHANGED
@@ -123,6 +123,13 @@ var cwp_namespace = {
|
|
123 |
jQuery(panel).find('.cat-post-more-link-help').toggle('slow');
|
124 |
},
|
125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
toggleHideTitle: function(item) {
|
127 |
var panel = item.parentElement.parentElement.parentElement;
|
128 |
if (item.checked) {
|
@@ -494,6 +501,10 @@ jQuery(document).ready(function() {
|
|
494 |
cwp_namespace.toggleMoreLinkHelp(this, event);
|
495 |
});
|
496 |
|
|
|
|
|
|
|
|
|
497 |
jQuery(class_namespace + ' .cpwp-open-placholder-dropdown-menu').off('click').on('click', function() { // open drop down and add placeholder
|
498 |
cwp_namespace.openAddPlaceholder(this);
|
499 |
});
|
@@ -526,4 +537,4 @@ jQuery(document).ready(function() {
|
|
526 |
}
|
527 |
|
528 |
setChangeHandlers();
|
529 |
-
});
|
123 |
jQuery(panel).find('.cat-post-more-link-help').toggle('slow');
|
124 |
},
|
125 |
|
126 |
+
// Show Load More button text help
|
127 |
+
toggleButtonTextHelp: function(item, event) {
|
128 |
+
event.preventDefault();
|
129 |
+
var panel = item.parentElement.parentElement.parentElement.parentElement;
|
130 |
+
jQuery(panel).find('.cat-post-button-text-help').toggle('slow');
|
131 |
+
},
|
132 |
+
|
133 |
toggleHideTitle: function(item) {
|
134 |
var panel = item.parentElement.parentElement.parentElement;
|
135 |
if (item.checked) {
|
501 |
cwp_namespace.toggleMoreLinkHelp(this, event);
|
502 |
});
|
503 |
|
504 |
+
jQuery(class_namespace + ' a.toggle-button-text-help').off('click').on('click', function(event) { // show load more button text help
|
505 |
+
cwp_namespace.toggleButtonTextHelp(this, event);
|
506 |
+
});
|
507 |
+
|
508 |
jQuery(class_namespace + ' .cpwp-open-placholder-dropdown-menu').off('click').on('click', function() { // open drop down and add placeholder
|
509 |
cwp_namespace.openAddPlaceholder(this);
|
510 |
});
|
537 |
}
|
538 |
|
539 |
setChangeHandlers();
|
540 |
+
});
|
js/admin/category-posts-widget.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
var cwp_namespace={php_settings_var:"categoryPosts",widget_class:".category-widget-cont",template_panel_prefix:".categoryposts-data-panel-",open_panels:{},template_change_timer:null,clickHandler:function(element){jQuery(element).toggleClass("open").next().stop().slideToggle();var panel=jQuery(element).data("panel"),id=jQuery(element).parent().parent().parent().parent().parent().attr("id"),o={};this.open_panels.hasOwnProperty(id)&&(o=this.open_panels[id]),o.hasOwnProperty(panel)?delete o[panel]:o[panel]=!0,this.open_panels[id]=o},toggleCatSelection:function(item){var cat=jQuery(item).find("option:selected").attr("value"),panel=item.parentElement.parentElement.parentElement.parentElement;"0"==cat?(jQuery(panel).find(".categoryPosts-title_link").hide(),jQuery(panel).find(".categoryPosts-title_link_url").show(),jQuery(panel).find(".categoryPosts-no_cat_childs").hide()):(jQuery(panel).find(".categoryPosts-title_link").show(),jQuery(panel).find(".categoryPosts-title_link_url").hide(),jQuery(panel).find(".categoryPosts-no_cat_childs").show())},toggleDisableFontStyles:function(item){var panel=item.parentElement.parentElement.parentElement;item.checked?jQuery(panel).find(".categoryPosts-disable_font_styles").hide():jQuery(panel).find(".categoryPosts-disable_font_styles").show()},toggleDateFormat:function(item){var value=jQuery(item).val(),panel=item.parentElement.parentElement;"other"!=value?jQuery(panel).find(".categoryPosts-date_format").hide():jQuery(panel).find(".categoryPosts-date_format").show()},toggleDateRange:function(item){var value=jQuery(item).val(),panel=item.parentElement.parentElement;switch(jQuery(panel).find(".categoryPosts-date-range p").hide(),jQuery(panel).find(".categoryPosts-date-range").show(),value){case"off":jQuery(panel).find(".categoryPosts-date-range").hide();break;case"days_ago":jQuery(panel).find(".categoryPosts-days_ago").show();break;case"between_dates":jQuery(panel).find(".categoryPosts-start_date").show(),jQuery(panel).find(".categoryPosts-end_date").show()}},toggleNoMatch:function(item){var value=jQuery(item).val(),panel=item.parentElement.parentElement;"text"==value?jQuery(panel).find(".categoryPosts-no-match-text").show():jQuery(panel).find(".categoryPosts-no-match-text").hide()},toggleTemplateHelp:function(item,event){event.preventDefault();var panel=item.parentElement.parentElement.parentElement.parentElement;jQuery(panel).find(".cat-post-template-help").toggle("slow")},toggleImageDimensionsHelp:function(item,event){event.preventDefault();var panel=item.parentElement.parentElement.parentElement.parentElement;jQuery(panel).find(".cat-post-image-dimensions-help").toggle("slow")},toggleMoreLinkHelp:function(item,event){event.preventDefault();var panel=item.parentElement.parentElement.parentElement.parentElement;jQuery(panel).find(".cat-post-more-link-help").toggle("slow")},toggleHideTitle:function(item){var panel=item.parentElement.parentElement.parentElement;item.checked?jQuery(panel).find(".categoryposts-data-panel-title-settings").hide():jQuery(panel).find(".categoryposts-data-panel-title-settings").show()},toggleLoadMore:function(item){var panel=item.parentElement.parentElement.parentElement;item.checked?jQuery(panel).find(".loadmore-settings").show():jQuery(panel).find(".loadmore-settings").hide()},selectPremadeTemplate:function(item){var panel=item.parentElement.parentElement.parentElement,div=item.parentElement.parentElement,select=jQuery(div).find("select"),template="%title%";switch(value=select.val(),value){case"title":template="%title%";break;case"title_excerpt":template="%title%\n\n%excerpt%\n\n%more-link%";break;case"title_thumb":template="%title%\n\n%thumb%";break;case"title_thum_excerpt":template="%title%\n\n%thumb%\n%excerpt%\n\n%more-link%";break;case"everything":template="%title%\n\n",template+="%date%\n\n",template+="%thumb%\n",template+='<span class="dashicons dashicons-admin-comments"></span> %commentnum% ',template+='<span class="dashicons dashicons-admin-users"></span> %author%\n',template+="%excerpt%\n\n",template+="%more-link%\n\n",template+="Categories: %category% ",template+='<span class="dashicons dashicons-tag"></span> %post_tag%'}var textarea=jQuery(panel).find("textarea");textarea.val(template),textarea.trigger("input","change")},autoCloseOpenPanels:function(_this){if(tiptoppress[this.php_settings_var].accordion&&!jQuery(_this).hasClass("open")){var jCloseElement=jQuery(_this).parent().find(".open");this.clickHandler(jCloseElement)}},defaultThumbnailSelection:function(elem,title,button_title){var frame=wp.media({title:title,multiple:!1,library:{type:"image"},button:{text:button_title}});return frame.on("close",(function(){var attachments=frame.state().get("selection").toJSON();if(1==attachments.length){var attachment=attachments[0],img_html='<img src="'+attachment.url+'" ';img_html+='width="60" ',img_html+='height="60" ',img_html+="/>",jQuery(elem).parent().prev().find(".default_thumb_img").html(img_html),jQuery(elem).parent().find(".cwp_default_thumb_remove").show(),jQuery(elem).parent().prev().find(".default_thumb_id").val(attachment.id).change()}})),frame.open(),!1},removeDefaultThumbnailSelection:function(elem){return jQuery(elem).parent().prev().find(".default_thumb_img").html(cwp_default_thumb_selection.none),jQuery(elem).hide(),jQuery(elem).parent().prev().find(".default_thumb_id").val(0).change(),!1},templateChange:function(elem){function adjustUiToTemplate(){var template=jQuery(elem).val(),tags=tiptoppress[this.php_settings_var].template_tags,widget_cont=jQuery(elem.parentElement.parentElement.parentElement.parentElement);for(var key in tags)-1!==template.indexOf(tags[key])?widget_cont.find(this.template_panel_prefix+tags[key]).show():widget_cont.find(this.template_panel_prefix+tags[key]).hide()}null!=this.template_change_timer&&clearTimeout(this.template_change_timer),this.template_change_timer=setTimeout(adjustUiToTemplate.bind(this),250)},thumbnailSizeChange:function(elem){var _that=jQuery(elem),thumb_h,thumb_w,_input_thumb_h=_that.closest(".categoryposts-data-panel-thumb").find(".thumb_h"),_input_thumb_w=_that.closest(".categoryposts-data-panel-thumb").find(".thumb_w");return _that.hasClass("smaller")?(thumb_w=_input_thumb_w.val()/1.015,thumb_h=_input_thumb_h.val()/1.015):_that.hasClass("quarter")?(thumb_w=_input_thumb_w.val()/4,thumb_h=_input_thumb_h.val()/4):_that.hasClass("half")?(thumb_h=_input_thumb_h.val()/2,thumb_w=_input_thumb_w.val()/2):_that.hasClass("double")?(thumb_h=2*_input_thumb_h.val(),thumb_w=2*_input_thumb_w.val()):_that.hasClass("bigger")?(thumb_w=1.02*_input_thumb_w.val(),thumb_h=1.02*_input_thumb_h.val()):_that.hasClass("square")?parseInt(_input_thumb_w.val())>=parseInt(_input_thumb_h.val())?(thumb_h=_input_thumb_w.val(),thumb_w=_input_thumb_w.val()):(thumb_h=_input_thumb_h.val(),thumb_w=_input_thumb_h.val()):_that.hasClass("standard")?parseInt(_input_thumb_w.val())>=parseInt(_input_thumb_h.val())?(thumb_h=_input_thumb_w.val()/4*3,thumb_w=_input_thumb_w.val()):(thumb_h=4*_input_thumb_w.val()/3,thumb_w=_input_thumb_w.val()):_that.hasClass("wide")?parseInt(_input_thumb_w.val())>=parseInt(_input_thumb_h.val())?(thumb_h=_input_thumb_w.val()/16*9,thumb_w=_input_thumb_w.val()):(thumb_h=16*_input_thumb_w.val()/9,thumb_w=_input_thumb_w.val()):_that.hasClass("switch")?(thumb_h=_input_thumb_w.val(),thumb_w=_input_thumb_h.val()):_that.hasClass("width")?(thumb_w=0==_input_thumb_w.val()?300:_input_thumb_w.val(),thumb_h=0):_that.hasClass("height")?(thumb_h=0==_input_thumb_h.val()?300:_input_thumb_h.val(),thumb_w=0):_that.hasClass("both")?(thumb_h=0,thumb_w=0):(thumb_w=_that.data("thumb-w"),thumb_h=_that.data("thumb-h")),_input_thumb_w.val(Math.floor(thumb_w)),_input_thumb_h.val(Math.floor(thumb_h)),_input_thumb_w.trigger("input","change"),_input_thumb_h.trigger("input","change"),!1},thumbnailFluidWidthChange:function(elem){var _that=jQuery(elem),_input_thumb_h=_that.closest(".categoryposts-data-panel-thumb").find(".thumb_h");return _that.closest("label").find("span").html(_that.val()+"%"),_input_thumb_h.trigger("input","change"),!1},openAddPlaceholder:function(elem){var _that=jQuery(elem);return _that.closest(".cat-post-add_premade_templates").find(".cpwp-placeholder-dropdown-menu").toggle(),_that.closest(".cat-post-add_premade_templates").find(".cpwp-placeholder-dropdown-menu span").off("click").on("click",(function(){var text=jQuery(this).data("value");switch(text){case"NewLine":text="\n";break;case"EmptyLine":text="\n\n";break;default:text="%"+text+"%"}var _div=this.parentElement.parentElement.parentElement,textarea=jQuery(_div).find("textarea"),textareaPos=textarea[0].selectionStart,textareaTxt=textarea.val();textarea.val(textareaTxt.substring(0,textareaPos)+text+textareaTxt.substring(textareaPos)),textarea[0].selectionStart=textareaPos+text.length,textarea[0].selectionEnd=textareaPos+text.length,textarea.focus(),textarea.trigger("input","change")})),_that.closest(".cat-post-add_premade_templates").find(".cpwp-placeholder-dropdown-menu").on("mouseenter",(function(){jQuery(this).addClass("cpw-doNotClose")})),_that.closest(".cat-post-add_premade_templates").find(".cpwp-placeholder-dropdown-menu").on("mouseleave",(function(){jQuery(this).removeClass("cpw-doNotClose")})),_that.closest(".cat-post-add_premade_templates").find(".cpwp-close-placeholder-dropdown-menu").off("click").on("click",(function(){_that.closest(".cat-post-add_premade_templates").find(".cpwp-placeholder-dropdown-menu").toggle()})),!1},selectPlaceholderHelper:function(elem){var textarea=jQuery(elem),textareaPos=textarea[0].selectionStart,textareaTxt=textarea.val(),nStartSel=textareaTxt.substring(0,textareaPos).lastIndexOf("%"),nEndSel=textareaPos+textareaTxt.substring(textareaPos).indexOf("%")+1,strSelTxt=textareaTxt.substring(nStartSel,nEndSel);return!(strSelTxt.indexOf("\n")>=0||strSelTxt.indexOf(" ")>=0||strSelTxt.length<=2)&&(textarea[0].selectionStart=nStartSel,textarea[0].selectionEnd=nEndSel,!1)}};jQuery(document).ready((function(){var class_namespace=".category-widget-cont";function setChangeHandlers(){jQuery(document).on("click",class_namespace+" .categoryPosts-hide_title input[type=checkbox]",(function(){cwp_namespace.toggleHideTitle(this)})),jQuery(document).on("change",class_namespace+" .categoryposts-data-panel-filter-cat",(function(){cwp_namespace.toggleCatSelection(this)})),jQuery(document).on("change",class_namespace+" .categoryPosts-date_range select",(function(){cwp_namespace.toggleDateRange(this)})),jQuery(".cwp_default_thumb_select").off("click").on("click",(function(){cwp_namespace.defaultThumbnailSelection(this,cwp_default_thumb_selection.frame_title,cwp_default_thumb_selection.button_title)})),jQuery(document).on("click",class_namespace+" .cat-post-premade_templates button",(function(){cwp_namespace.selectPremadeTemplate(this)})),jQuery(document).on("change",class_namespace+" .cat-post-premade_templates select",(function(event){event.preventDefault(),event.stopPropagation()})),jQuery(document).on("input",class_namespace+" .categoryPosts-template textarea",(function(){cwp_namespace.templateChange(this)})),jQuery(document).on("change",class_namespace+" .categoryPosts-preset_date_format select",(function(){cwp_namespace.toggleDateFormat(this)})),jQuery(class_namespace+" .cat-post-thumb-change-size button").off("click").on("click",(function(){cwp_namespace.thumbnailSizeChange(this)})),jQuery(document).on("input",class_namespace+" .thumb_fluid_width",(function(){cwp_namespace.thumbnailFluidWidthChange(this)})),jQuery(".cwp_default_thumb_remove").off("click").on("click",(function(){cwp_namespace.removeDefaultThumbnailSelection(this)})),jQuery(class_namespace+" a.toggle-template-help").off("click").on("click",(function(event){cwp_namespace.toggleTemplateHelp(this,event)})),jQuery(class_namespace+" a.toggle-image-dimensions-help").off("click").on("click",(function(event){cwp_namespace.toggleImageDimensionsHelp(this,event)})),jQuery(class_namespace+" a.toggle-more-link-help").off("click").on("click",(function(event){cwp_namespace.toggleMoreLinkHelp(this,event)})),jQuery(class_namespace+" .cpwp-open-placholder-dropdown-menu").off("click").on("click",(function(){cwp_namespace.openAddPlaceholder(this)})),jQuery(document).on("onfocusout, blur",class_namespace+" .cpwp-open-placholder-dropdown-menu,"+class_namespace+" .categoryPosts-template textarea",(function(){jQuery(this).closest(class_namespace+" .categoryPosts-template").parent().find(".cpwp-placeholder-dropdown-menu").not(".cpw-doNotClose").hide()})),jQuery(document).on("click",class_namespace+" .categoryPosts-template textarea",(function(){jQuery(this).closest(class_namespace+" .categoryPosts-template").parent().find(".cpwp-placeholder-dropdown-menu").not(".cpw-doNotClose").hide()})),jQuery(document).on("mousedown",class_namespace+" .categoryPosts-template textarea",(function(){var _that=this;setTimeout((function(){cwp_namespace.selectPlaceholderHelper(_that)}),0)})),jQuery(document).on("click",class_namespace+" .categoryPosts-disable_css input[type=checkbox]",(function(){cwp_namespace.toggleDisableFontStyles(this)})),jQuery(document).on("change",class_namespace+" .categoryPosts-no_match_handling select",(function(){cwp_namespace.toggleNoMatch(this)})),jQuery(document).on("click",class_namespace+" .categoryPosts-enable_loadmore input[type=checkbox]",(function(){cwp_namespace.toggleLoadMore(this)}))}jQuery(".category-widget-cont h4").click((function(){cwp_namespace.autoCloseOpenPanels(this),cwp_namespace.clickHandler(this)})),jQuery(document).on("widget-added widget-updated panelsopen",(function(root,element){jQuery(".category-widget-cont h4").off("click").on("click",(function(){cwp_namespace.autoCloseOpenPanels(this),cwp_namespace.clickHandler(this)})),jQuery(".cwp_default_thumb_select").off("click").on("click",(function(){cwp_namespace.defaultThumbnailSelection(this,cwp_default_thumb_selection.frame_title,cwp_default_thumb_selection.button_title)})),jQuery(".cwp_default_thumb_remove").off("click").on("click",(function(){cwp_namespace.removeDefaultThumbnailSelection(this)}));var id=jQuery(element).attr("id");if(cwp_namespace.open_panels.hasOwnProperty(id)){var o=cwp_namespace.open_panels[id];for(var panel in o)jQuery(element).find("[data-panel="+panel+"]").toggleClass("open").next().stop().show()}setChangeHandlers()})),setChangeHandlers()}));
|
1 |
+
var cwp_namespace={php_settings_var:"categoryPosts",widget_class:".category-widget-cont",template_panel_prefix:".categoryposts-data-panel-",open_panels:{},template_change_timer:null,clickHandler:function(element){jQuery(element).toggleClass("open").next().stop().slideToggle();var panel=jQuery(element).data("panel"),id=jQuery(element).parent().parent().parent().parent().parent().attr("id"),o={};this.open_panels.hasOwnProperty(id)&&(o=this.open_panels[id]),o.hasOwnProperty(panel)?delete o[panel]:o[panel]=!0,this.open_panels[id]=o},toggleCatSelection:function(item){var cat=jQuery(item).find("option:selected").attr("value"),panel=item.parentElement.parentElement.parentElement.parentElement;"0"==cat?(jQuery(panel).find(".categoryPosts-title_link").hide(),jQuery(panel).find(".categoryPosts-title_link_url").show(),jQuery(panel).find(".categoryPosts-no_cat_childs").hide()):(jQuery(panel).find(".categoryPosts-title_link").show(),jQuery(panel).find(".categoryPosts-title_link_url").hide(),jQuery(panel).find(".categoryPosts-no_cat_childs").show())},toggleDisableFontStyles:function(item){var panel=item.parentElement.parentElement.parentElement;item.checked?jQuery(panel).find(".categoryPosts-disable_font_styles").hide():jQuery(panel).find(".categoryPosts-disable_font_styles").show()},toggleDateFormat:function(item){var value=jQuery(item).val(),panel=item.parentElement.parentElement;"other"!=value?jQuery(panel).find(".categoryPosts-date_format").hide():jQuery(panel).find(".categoryPosts-date_format").show()},toggleDateRange:function(item){var value=jQuery(item).val(),panel=item.parentElement.parentElement;switch(jQuery(panel).find(".categoryPosts-date-range p").hide(),jQuery(panel).find(".categoryPosts-date-range").show(),value){case"off":jQuery(panel).find(".categoryPosts-date-range").hide();break;case"days_ago":jQuery(panel).find(".categoryPosts-days_ago").show();break;case"between_dates":jQuery(panel).find(".categoryPosts-start_date").show(),jQuery(panel).find(".categoryPosts-end_date").show()}},toggleNoMatch:function(item){var value=jQuery(item).val(),panel=item.parentElement.parentElement;"text"==value?jQuery(panel).find(".categoryPosts-no-match-text").show():jQuery(panel).find(".categoryPosts-no-match-text").hide()},toggleTemplateHelp:function(item,event){event.preventDefault();var panel=item.parentElement.parentElement.parentElement.parentElement;jQuery(panel).find(".cat-post-template-help").toggle("slow")},toggleImageDimensionsHelp:function(item,event){event.preventDefault();var panel=item.parentElement.parentElement.parentElement.parentElement;jQuery(panel).find(".cat-post-image-dimensions-help").toggle("slow")},toggleMoreLinkHelp:function(item,event){event.preventDefault();var panel=item.parentElement.parentElement.parentElement.parentElement;jQuery(panel).find(".cat-post-more-link-help").toggle("slow")},toggleButtonTextHelp:function(item,event){event.preventDefault();var panel=item.parentElement.parentElement.parentElement.parentElement;jQuery(panel).find(".cat-post-button-text-help").toggle("slow")},toggleHideTitle:function(item){var panel=item.parentElement.parentElement.parentElement;item.checked?jQuery(panel).find(".categoryposts-data-panel-title-settings").hide():jQuery(panel).find(".categoryposts-data-panel-title-settings").show()},toggleLoadMore:function(item){var panel=item.parentElement.parentElement.parentElement;item.checked?jQuery(panel).find(".loadmore-settings").show():jQuery(panel).find(".loadmore-settings").hide()},selectPremadeTemplate:function(item){var panel=item.parentElement.parentElement.parentElement,div=item.parentElement.parentElement,select=jQuery(div).find("select"),template="%title%";switch(value=select.val(),value){case"title":template="%title%";break;case"title_excerpt":template="%title%\n\n%excerpt%\n\n%more-link%";break;case"title_thumb":template="%title%\n\n%thumb%";break;case"title_thum_excerpt":template="%title%\n\n%thumb%\n%excerpt%\n\n%more-link%";break;case"everything":template="%title%\n\n",template+="%date%\n\n",template+="%thumb%\n",template+='<span class="dashicons dashicons-admin-comments"></span> %commentnum% ',template+='<span class="dashicons dashicons-admin-users"></span> %author%\n',template+="%excerpt%\n\n",template+="%more-link%\n\n",template+="Categories: %category% ",template+='<span class="dashicons dashicons-tag"></span> %post_tag%'}var textarea=jQuery(panel).find("textarea");textarea.val(template),textarea.trigger("input","change")},autoCloseOpenPanels:function(_this){if(tiptoppress[this.php_settings_var].accordion&&!jQuery(_this).hasClass("open")){var jCloseElement=jQuery(_this).parent().find(".open");this.clickHandler(jCloseElement)}},defaultThumbnailSelection:function(elem,title,button_title){var frame=wp.media({title:title,multiple:!1,library:{type:"image"},button:{text:button_title}});return frame.on("close",(function(){var attachments=frame.state().get("selection").toJSON();if(1==attachments.length){var attachment=attachments[0],img_html='<img src="'+attachment.url+'" ';img_html+='width="60" ',img_html+='height="60" ',img_html+="/>",jQuery(elem).parent().prev().find(".default_thumb_img").html(img_html),jQuery(elem).parent().find(".cwp_default_thumb_remove").show(),jQuery(elem).parent().prev().find(".default_thumb_id").val(attachment.id).change()}})),frame.open(),!1},removeDefaultThumbnailSelection:function(elem){return jQuery(elem).parent().prev().find(".default_thumb_img").html(cwp_default_thumb_selection.none),jQuery(elem).hide(),jQuery(elem).parent().prev().find(".default_thumb_id").val(0).change(),!1},templateChange:function(elem){function adjustUiToTemplate(){var template=jQuery(elem).val(),tags=tiptoppress[this.php_settings_var].template_tags,widget_cont=jQuery(elem.parentElement.parentElement.parentElement.parentElement);for(var key in tags)-1!==template.indexOf(tags[key])?widget_cont.find(this.template_panel_prefix+tags[key]).show():widget_cont.find(this.template_panel_prefix+tags[key]).hide()}null!=this.template_change_timer&&clearTimeout(this.template_change_timer),this.template_change_timer=setTimeout(adjustUiToTemplate.bind(this),250)},thumbnailSizeChange:function(elem){var _that=jQuery(elem),thumb_h,thumb_w,_input_thumb_h=_that.closest(".categoryposts-data-panel-thumb").find(".thumb_h"),_input_thumb_w=_that.closest(".categoryposts-data-panel-thumb").find(".thumb_w");return _that.hasClass("smaller")?(thumb_w=_input_thumb_w.val()/1.015,thumb_h=_input_thumb_h.val()/1.015):_that.hasClass("quarter")?(thumb_w=_input_thumb_w.val()/4,thumb_h=_input_thumb_h.val()/4):_that.hasClass("half")?(thumb_h=_input_thumb_h.val()/2,thumb_w=_input_thumb_w.val()/2):_that.hasClass("double")?(thumb_h=2*_input_thumb_h.val(),thumb_w=2*_input_thumb_w.val()):_that.hasClass("bigger")?(thumb_w=1.02*_input_thumb_w.val(),thumb_h=1.02*_input_thumb_h.val()):_that.hasClass("square")?parseInt(_input_thumb_w.val())>=parseInt(_input_thumb_h.val())?(thumb_h=_input_thumb_w.val(),thumb_w=_input_thumb_w.val()):(thumb_h=_input_thumb_h.val(),thumb_w=_input_thumb_h.val()):_that.hasClass("standard")?parseInt(_input_thumb_w.val())>=parseInt(_input_thumb_h.val())?(thumb_h=_input_thumb_w.val()/4*3,thumb_w=_input_thumb_w.val()):(thumb_h=4*_input_thumb_w.val()/3,thumb_w=_input_thumb_w.val()):_that.hasClass("wide")?parseInt(_input_thumb_w.val())>=parseInt(_input_thumb_h.val())?(thumb_h=_input_thumb_w.val()/16*9,thumb_w=_input_thumb_w.val()):(thumb_h=16*_input_thumb_w.val()/9,thumb_w=_input_thumb_w.val()):_that.hasClass("switch")?(thumb_h=_input_thumb_w.val(),thumb_w=_input_thumb_h.val()):_that.hasClass("width")?(thumb_w=0==_input_thumb_w.val()?300:_input_thumb_w.val(),thumb_h=0):_that.hasClass("height")?(thumb_h=0==_input_thumb_h.val()?300:_input_thumb_h.val(),thumb_w=0):_that.hasClass("both")?(thumb_h=0,thumb_w=0):(thumb_w=_that.data("thumb-w"),thumb_h=_that.data("thumb-h")),_input_thumb_w.val(Math.floor(thumb_w)),_input_thumb_h.val(Math.floor(thumb_h)),_input_thumb_w.trigger("input","change"),_input_thumb_h.trigger("input","change"),!1},thumbnailFluidWidthChange:function(elem){var _that=jQuery(elem),_input_thumb_h=_that.closest(".categoryposts-data-panel-thumb").find(".thumb_h");return _that.closest("label").find("span").html(_that.val()+"%"),_input_thumb_h.trigger("input","change"),!1},openAddPlaceholder:function(elem){var _that=jQuery(elem);return _that.closest(".cat-post-add_premade_templates").find(".cpwp-placeholder-dropdown-menu").toggle(),_that.closest(".cat-post-add_premade_templates").find(".cpwp-placeholder-dropdown-menu span").off("click").on("click",(function(){var text=jQuery(this).data("value");switch(text){case"NewLine":text="\n";break;case"EmptyLine":text="\n\n";break;default:text="%"+text+"%"}var _div=this.parentElement.parentElement.parentElement,textarea=jQuery(_div).find("textarea"),textareaPos=textarea[0].selectionStart,textareaTxt=textarea.val();textarea.val(textareaTxt.substring(0,textareaPos)+text+textareaTxt.substring(textareaPos)),textarea[0].selectionStart=textareaPos+text.length,textarea[0].selectionEnd=textareaPos+text.length,textarea.focus(),textarea.trigger("input","change")})),_that.closest(".cat-post-add_premade_templates").find(".cpwp-placeholder-dropdown-menu").on("mouseenter",(function(){jQuery(this).addClass("cpw-doNotClose")})),_that.closest(".cat-post-add_premade_templates").find(".cpwp-placeholder-dropdown-menu").on("mouseleave",(function(){jQuery(this).removeClass("cpw-doNotClose")})),_that.closest(".cat-post-add_premade_templates").find(".cpwp-close-placeholder-dropdown-menu").off("click").on("click",(function(){_that.closest(".cat-post-add_premade_templates").find(".cpwp-placeholder-dropdown-menu").toggle()})),!1},selectPlaceholderHelper:function(elem){var textarea=jQuery(elem),textareaPos=textarea[0].selectionStart,textareaTxt=textarea.val(),nStartSel=textareaTxt.substring(0,textareaPos).lastIndexOf("%"),nEndSel=textareaPos+textareaTxt.substring(textareaPos).indexOf("%")+1,strSelTxt=textareaTxt.substring(nStartSel,nEndSel);return!(strSelTxt.indexOf("\n")>=0||strSelTxt.indexOf(" ")>=0||strSelTxt.length<=2)&&(textarea[0].selectionStart=nStartSel,textarea[0].selectionEnd=nEndSel,!1)}};jQuery(document).ready((function(){var class_namespace=".category-widget-cont";function setChangeHandlers(){jQuery(document).on("click",class_namespace+" .categoryPosts-hide_title input[type=checkbox]",(function(){cwp_namespace.toggleHideTitle(this)})),jQuery(document).on("change",class_namespace+" .categoryposts-data-panel-filter-cat",(function(){cwp_namespace.toggleCatSelection(this)})),jQuery(document).on("change",class_namespace+" .categoryPosts-date_range select",(function(){cwp_namespace.toggleDateRange(this)})),jQuery(".cwp_default_thumb_select").off("click").on("click",(function(){cwp_namespace.defaultThumbnailSelection(this,cwp_default_thumb_selection.frame_title,cwp_default_thumb_selection.button_title)})),jQuery(document).on("click",class_namespace+" .cat-post-premade_templates button",(function(){cwp_namespace.selectPremadeTemplate(this)})),jQuery(document).on("change",class_namespace+" .cat-post-premade_templates select",(function(event){event.preventDefault(),event.stopPropagation()})),jQuery(document).on("input",class_namespace+" .categoryPosts-template textarea",(function(){cwp_namespace.templateChange(this)})),jQuery(document).on("change",class_namespace+" .categoryPosts-preset_date_format select",(function(){cwp_namespace.toggleDateFormat(this)})),jQuery(class_namespace+" .cat-post-thumb-change-size button").off("click").on("click",(function(){cwp_namespace.thumbnailSizeChange(this)})),jQuery(document).on("input",class_namespace+" .thumb_fluid_width",(function(){cwp_namespace.thumbnailFluidWidthChange(this)})),jQuery(".cwp_default_thumb_remove").off("click").on("click",(function(){cwp_namespace.removeDefaultThumbnailSelection(this)})),jQuery(class_namespace+" a.toggle-template-help").off("click").on("click",(function(event){cwp_namespace.toggleTemplateHelp(this,event)})),jQuery(class_namespace+" a.toggle-image-dimensions-help").off("click").on("click",(function(event){cwp_namespace.toggleImageDimensionsHelp(this,event)})),jQuery(class_namespace+" a.toggle-more-link-help").off("click").on("click",(function(event){cwp_namespace.toggleMoreLinkHelp(this,event)})),jQuery(class_namespace+" a.toggle-button-text-help").off("click").on("click",(function(event){cwp_namespace.toggleButtonTextHelp(this,event)})),jQuery(class_namespace+" .cpwp-open-placholder-dropdown-menu").off("click").on("click",(function(){cwp_namespace.openAddPlaceholder(this)})),jQuery(document).on("onfocusout, blur",class_namespace+" .cpwp-open-placholder-dropdown-menu,"+class_namespace+" .categoryPosts-template textarea",(function(){jQuery(this).closest(class_namespace+" .categoryPosts-template").parent().find(".cpwp-placeholder-dropdown-menu").not(".cpw-doNotClose").hide()})),jQuery(document).on("click",class_namespace+" .categoryPosts-template textarea",(function(){jQuery(this).closest(class_namespace+" .categoryPosts-template").parent().find(".cpwp-placeholder-dropdown-menu").not(".cpw-doNotClose").hide()})),jQuery(document).on("mousedown",class_namespace+" .categoryPosts-template textarea",(function(){var _that=this;setTimeout((function(){cwp_namespace.selectPlaceholderHelper(_that)}),0)})),jQuery(document).on("click",class_namespace+" .categoryPosts-disable_css input[type=checkbox]",(function(){cwp_namespace.toggleDisableFontStyles(this)})),jQuery(document).on("change",class_namespace+" .categoryPosts-no_match_handling select",(function(){cwp_namespace.toggleNoMatch(this)})),jQuery(document).on("click",class_namespace+" .categoryPosts-enable_loadmore input[type=checkbox]",(function(){cwp_namespace.toggleLoadMore(this)}))}jQuery(".category-widget-cont h4").click((function(){cwp_namespace.autoCloseOpenPanels(this),cwp_namespace.clickHandler(this)})),jQuery(document).on("widget-added widget-updated panelsopen",(function(root,element){jQuery(".category-widget-cont h4").off("click").on("click",(function(){cwp_namespace.autoCloseOpenPanels(this),cwp_namespace.clickHandler(this)})),jQuery(".cwp_default_thumb_select").off("click").on("click",(function(){cwp_namespace.defaultThumbnailSelection(this,cwp_default_thumb_selection.frame_title,cwp_default_thumb_selection.button_title)})),jQuery(".cwp_default_thumb_remove").off("click").on("click",(function(){cwp_namespace.removeDefaultThumbnailSelection(this)}));var id=jQuery(element).attr("id");if(cwp_namespace.open_panels.hasOwnProperty(id)){var o=cwp_namespace.open_panels[id];for(var panel in o)jQuery(element).find("[data-panel="+panel+"]").toggleClass("open").next().stop().show()}setChangeHandlers()})),setChangeHandlers()}));
|
js/frontend/loadmore.js
CHANGED
@@ -7,44 +7,60 @@
|
|
7 |
* Released under the GPLv2 license or later - http://www.gnu.org/licenses/gpl-2.0.html
|
8 |
*/
|
9 |
|
10 |
-
if (typeof jQuery !== 'undefined')
|
11 |
|
12 |
-
|
13 |
|
14 |
-
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
* Released under the GPLv2 license or later - http://www.gnu.org/licenses/gpl-2.0.html
|
8 |
*/
|
9 |
|
10 |
+
if (typeof jQuery !== 'undefined') {
|
11 |
|
12 |
+
var php_settings_var = 'categoryPosts'; // should be identical to namespace.
|
13 |
|
14 |
+
jQuery(document).ready(function() {
|
15 |
|
16 |
+
// Handle the click of load more.
|
17 |
+
jQuery(document).on('click', '.' + php_settings_var + '-loadmore button', function() {
|
18 |
+
var _this = jQuery(this),
|
19 |
+
id = _this.data('id'),
|
20 |
+
number = _this.data('number'),
|
21 |
+
start = _this.data('start'),
|
22 |
+
context = _this.data('context'),
|
23 |
+
url = tiptoppress[php_settings_var].json_root_url,
|
24 |
+
_ul = jQuery(this.parentElement.parentElement).find('ul'), // The UL of the widget.
|
25 |
+
origText = _this.text(),
|
26 |
+
postCount = _this.data('post-count'),
|
27 |
+
loadingText = _this.data('loading'),
|
28 |
+
loadmoreText = _this.data('placeholder'),
|
29 |
+
widgetNumber = jQuery(this).closest("[id*='" + id + "']").attr('id');
|
30 |
|
31 |
+
// Change the button text to indicate loading.
|
32 |
+
_this.text(loadingText);
|
33 |
+
// Get the data from the server
|
34 |
+
jQuery.getJSON(url + '/' + id + '/' + start + '/' + number + '/' + context + '/', function(data) {
|
35 |
+
// appened the returned data to the UL in the returned order.
|
36 |
+
jQuery.each(data, function(key, li) {
|
37 |
+
_ul.append(li);
|
38 |
+
// apend returns the _ul, therefor we need to actualy find
|
39 |
+
// the newly added item.
|
40 |
+
_ul.children().last().trigger('catposts.load_more');
|
41 |
+
});
|
42 |
+
if (postCount < start + number) {
|
43 |
+
_this.hide();
|
44 |
+
} else {
|
45 |
+
loadmoreText = loadmoreText.replace("%step%", start + number - 1);
|
46 |
+
loadmoreText = loadmoreText.replace("%all%", postCount);
|
47 |
+
_this.text(loadmoreText);
|
48 |
+
_this.data('start', start + number);
|
49 |
+
}
|
50 |
+
}).done(function() {
|
51 |
+
var widget = jQuery('#' + widgetNumber);
|
52 |
+
var widgetImage = jQuery(widget).find('.cat-post-item img').first();
|
53 |
+
|
54 |
+
// do each time new items are added
|
55 |
+
cat_posts_namespace.layout_wrap_text.preWrap(widget);
|
56 |
+
cat_posts_namespace.layout_wrap_text.setClass(widget);
|
57 |
+
if (0 !== parseInt(widgetImage.data('cat-posts-height')) && 0 !== parseInt(widgetImage.data('cat-posts-width'))) {
|
58 |
+
cat_posts_namespace.layout_img_size.setHeight(widget);
|
59 |
+
}
|
60 |
+
}).fail(function() {
|
61 |
+
// Revert to original text.
|
62 |
+
_this.text(origText);
|
63 |
+
});
|
64 |
+
});
|
65 |
+
});
|
66 |
+
}
|
js/frontend/loadmore.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
if("undefined"!=typeof jQuery){var php_settings_var="categoryPosts";jQuery(document).ready(function(){jQuery(document).on("click","."+php_settings_var+"-loadmore button",function(){var
|
1 |
+
if("undefined"!=typeof jQuery){var php_settings_var="categoryPosts";jQuery(document).ready((function(){jQuery(document).on("click","."+php_settings_var+"-loadmore button",(function(){var _this=jQuery(this),id=_this.data("id"),number=_this.data("number"),start=_this.data("start"),context=_this.data("context"),url=tiptoppress[php_settings_var].json_root_url,_ul=jQuery(this.parentElement.parentElement).find("ul"),origText=_this.text(),postCount=_this.data("post-count"),loadingText=_this.data("loading"),loadmoreText=_this.data("placeholder"),widgetNumber=jQuery(this).closest("[id*='"+id+"']").attr("id");_this.text(loadingText),jQuery.getJSON(url+"/"+id+"/"+start+"/"+number+"/"+context+"/",(function(data){jQuery.each(data,(function(key,li){_ul.append(li),_ul.children().last().trigger("catposts.load_more")})),postCount<start+number?_this.hide():(loadmoreText=(loadmoreText=loadmoreText.replace("%step%",start+number-1)).replace("%all%",postCount),_this.text(loadmoreText),_this.data("start",start+number))})).done((function(){var widget=jQuery("#"+widgetNumber),widgetImage=jQuery(widget).find(".cat-post-item img").first();cat_posts_namespace.layout_wrap_text.preWrap(widget),cat_posts_namespace.layout_wrap_text.setClass(widget),0!==parseInt(widgetImage.data("cat-posts-height"))&&0!==parseInt(widgetImage.data("cat-posts-width"))&&cat_posts_namespace.layout_img_size.setHeight(widget)})).fail((function(){_this.text(origText)}))}))}))}
|
loadmore.php
CHANGED
@@ -49,9 +49,9 @@ function get_next_elements( \WP_REST_Request $request ) {
|
|
49 |
if ( 2 <= count( $id_components ) ) {
|
50 |
switch ( $id_components[0] ) {
|
51 |
case 'shortcode':
|
52 |
-
if ( 3 === count( $id_components ) ) {
|
53 |
$pid = $id_components[1]; // The ID of the relevant post.
|
54 |
-
$name = $id_components[2]; // The shortcode "name".
|
55 |
$settings = shortcode_settings( $pid, $name );
|
56 |
if ( ! empty( $settings ) ) {
|
57 |
$virtual_widget = new Virtual_Widget( '', '', $settings );
|
49 |
if ( 2 <= count( $id_components ) ) {
|
50 |
switch ( $id_components[0] ) {
|
51 |
case 'shortcode':
|
52 |
+
if ( 2 === count( $id_components ) || 3 === count( $id_components ) ) {
|
53 |
$pid = $id_components[1]; // The ID of the relevant post.
|
54 |
+
$name = isset( $id_components[2] ) ? $id_components[2] : ''; // The shortcode "name".
|
55 |
$settings = shortcode_settings( $pid, $name );
|
56 |
if ( ! empty( $settings ) ) {
|
57 |
$virtual_widget = new Virtual_Widget( '', '', $settings );
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://wordpress.org/support/plugin/category-posts/reviews/
|
|
4 |
Tags: category, categories, posts, widget, posts widget, recent posts, category recent posts, shortcode, sidebar, excerpt, multiple widgets
|
5 |
Requires at least: 2.8
|
6 |
Tested up to: 5.6
|
7 |
-
Stable tag: 4.9.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -130,6 +130,9 @@ Check also the .htaccess file, if there is an entry for an older PHP version.
|
|
130 |
== Changelog ==
|
131 |
[Read more on our blog ...](http://tiptoppress.com/category/category-posts-widget)
|
132 |
|
|
|
|
|
|
|
133 |
= 4.9.8 - November 30th 2020 =
|
134 |
* Date since published for n-days
|
135 |
|
4 |
Tags: category, categories, posts, widget, posts widget, recent posts, category recent posts, shortcode, sidebar, excerpt, multiple widgets
|
5 |
Requires at least: 2.8
|
6 |
Tested up to: 5.6
|
7 |
+
Stable tag: 4.9.9
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
130 |
== Changelog ==
|
131 |
[Read more on our blog ...](http://tiptoppress.com/category/category-posts-widget)
|
132 |
|
133 |
+
= 4.9.9 - December 9th 2020 =
|
134 |
+
* Load more placeholders
|
135 |
+
|
136 |
= 4.9.8 - November 30th 2020 =
|
137 |
* Date since published for n-days
|
138 |
|
styles/admin/category-posts-widget.css
CHANGED
@@ -13,7 +13,8 @@
|
|
13 |
}
|
14 |
|
15 |
.cpwp_ident>p,
|
16 |
-
.cpwp_ident>div
|
|
|
17 |
display: flow-root;
|
18 |
}
|
19 |
|
@@ -70,7 +71,6 @@
|
|
70 |
|
71 |
.category-widget-cont input[type="text"] {
|
72 |
text-align: center;
|
73 |
-
float: right;
|
74 |
clear: both;
|
75 |
width: 100%;
|
76 |
}
|
13 |
}
|
14 |
|
15 |
.cpwp_ident>p,
|
16 |
+
.cpwp_ident>div,
|
17 |
+
.cpwp_ident>div>p {
|
18 |
display: flow-root;
|
19 |
}
|
20 |
|
71 |
|
72 |
.category-widget-cont input[type="text"] {
|
73 |
text-align: center;
|
|
|
74 |
clear: both;
|
75 |
width: 100%;
|
76 |
}
|