Category Posts Widget - Version 4.9.12

Version Description

  • July 20 2021 =
  • Deprecated jQuery warnings
Download this release

Release Info

Developer Kometschuh
Plugin Icon 128x128 Category Posts Widget
Version 4.9.12
Comparing to
See all releases

Code changes from version 4.9.11 to 4.9.12

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.11
16
  Author URI: https://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.11';
29
  const DOC_URL = 'https://tiptoppress.com/category-posts-widget/documentation-4-9/';
30
  const PRO_URL = 'https://tiptoppress.com/term-and-category-based-posts-widget/';
31
  const SUPPORT_URL = 'https://wordpress.org/support/plugin/category-posts/';
@@ -540,22 +540,27 @@ function equal_cover_content_height( $number, $widgetsettings ) {
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"; ?>
547
  cat_posts_namespace.layout_wrap_text.preWrap(widget);
 
 
 
 
 
 
 
548
 
549
- <?php /* do on page load or on resize the browser window */ echo "\r\n"; ?>
550
- jQuery(window).on('load resize', function() {
551
- cat_posts_namespace.layout_wrap_text.setClass(widget);
552
- <?php /* No ratio calculation if one or more dimensions is set to 0 */ echo "\r\n"; ?>
553
- <?php if ( isset( $widgetsettings['thumb_w'] ) && 0 !== intval( $widgetsettings['thumb_w'] ) &&
554
- isset( $widgetsettings['thumb_h'] ) && 0 !== intval( $widgetsettings['thumb_h'] ) ) : echo "\r\n"; ?>
555
- cat_posts_namespace.layout_img_size.setHeight(widget);
556
- <?php endif; echo "\r\n"; ?>
557
- });
558
  });
 
559
  }
560
  </script>
561
  <?php
@@ -719,6 +724,7 @@ function default_settings() {
719
  'template' => "%title%\n\n%thumb%",
720
  'text_do_not_wrap_thumb' => false,
721
  'enable_loadmore' => false,
 
722
  'loadmore_text' => sprintf( __( 'Load More (%s/%s)', 'category-posts' ), '%step%', '%all%'),
723
  'loading_text' => __( 'Loading...', 'category-posts' ),
724
  'date_range' => 'off',
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.12
16
  Author URI: https://tiptoppress.com
17
  Text Domain: category-posts
18
  Domain Path: /languages
25
  exit;
26
  }
27
 
28
+ const VERSION = '4.9.12';
29
  const DOC_URL = 'https://tiptoppress.com/category-posts-widget/documentation-4-9/';
30
  const PRO_URL = 'https://tiptoppress.com/term-and-category-based-posts-widget/';
31
  const SUPPORT_URL = 'https://wordpress.org/support/plugin/category-posts/';
540
  }
541
  }
542
 
543
+ var widget = jQuery('#<?php echo esc_attr( $number ); ?>');
 
544
 
545
+ jQuery( document ).ready(function () {
546
  cat_posts_namespace.layout_wrap_text.preWrap(widget);
547
+ cat_posts_namespace.layout_wrap_text.setClass(widget);
548
+ <?php /* No ratio calculation if one or more dimensions is set to 0 */ echo "\r\n"; ?>
549
+ <?php if ( isset( $widgetsettings['thumb_w'] ) && 0 !== intval( $widgetsettings['thumb_w'] ) &&
550
+ isset( $widgetsettings['thumb_h'] ) && 0 !== intval( $widgetsettings['thumb_h'] ) ) : echo "\r\n"; ?>
551
+ cat_posts_namespace.layout_img_size.setHeight(widget);
552
+ <?php endif; echo "\r\n"; ?>
553
+ });
554
 
555
+ jQuery(window).on('load resize', function() {
556
+ cat_posts_namespace.layout_wrap_text.setClass(widget);
557
+ <?php /* No ratio calculation if one or more dimensions is set to 0 */ echo "\r\n"; ?>
558
+ <?php if ( isset( $widgetsettings['thumb_w'] ) && 0 !== intval( $widgetsettings['thumb_w'] ) &&
559
+ isset( $widgetsettings['thumb_h'] ) && 0 !== intval( $widgetsettings['thumb_h'] ) ) : echo "\r\n"; ?>
560
+ cat_posts_namespace.layout_img_size.setHeight(widget);
561
+ <?php endif; echo "\r\n"; ?>
 
 
562
  });
563
+
564
  }
565
  </script>
566
  <?php
724
  'template' => "%title%\n\n%thumb%",
725
  'text_do_not_wrap_thumb' => false,
726
  'enable_loadmore' => false,
727
+ 'loadmore_scrollTo' => false,
728
  'loadmore_text' => sprintf( __( 'Load More (%s/%s)', 'category-posts' ), '%step%', '%all%'),
729
  'loading_text' => __( 'Loading...', 'category-posts' ),
730
  'date_range' => 'off',
js/admin/category-posts-widget.js CHANGED
@@ -412,7 +412,7 @@ jQuery(document).ready(function() {
412
 
413
  var class_namespace = '.category-widget-cont';
414
 
415
- jQuery('.category-widget-cont h4').click(function() { // for widgets page
416
  cwp_namespace.autoCloseOpenPanels(this);
417
  // toggle panel open/close
418
  cwp_namespace.clickHandler(this);
@@ -548,4 +548,4 @@ jQuery(document).ready(function() {
548
  }
549
 
550
  setChangeHandlers();
551
- });
412
 
413
  var class_namespace = '.category-widget-cont';
414
 
415
+ jQuery('.category-widget-cont h4').on('click', function() { // for widgets page
416
  cwp_namespace.autoCloseOpenPanels(this);
417
  // toggle panel open/close
418
  cwp_namespace.clickHandler(this);
548
  }
549
 
550
  setChangeHandlers();
551
+ });
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")},toggleTitleLevelHelp:function(item,event){event.preventDefault();var panel=item.parentElement.parentElement.parentElement.parentElement;jQuery(panel).find(".cat-post-title-level-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-title-level-help").off("click").on("click",(function(event){cwp_namespace.toggleTitleLevelHelp(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()}));
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")},toggleTitleLevelHelp:function(item,event){event.preventDefault();var panel=item.parentElement.parentElement.parentElement.parentElement;jQuery(panel).find(".cat-post-title-level-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-title-level-help").off("click").on("click",(function(event){cwp_namespace.toggleTitleLevelHelp(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").on("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
@@ -13,6 +13,16 @@ if (typeof jQuery !== 'undefined') {
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),
@@ -26,7 +36,9 @@ if (typeof jQuery !== 'undefined') {
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);
@@ -48,6 +60,14 @@ if (typeof jQuery !== 'undefined') {
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
 
@@ -63,4 +83,4 @@ if (typeof jQuery !== 'undefined') {
63
  });
64
  });
65
  });
66
- }
13
 
14
  jQuery(document).ready(function() {
15
 
16
+ // scrollbar
17
+ jQuery('.' + php_settings_var + '-loadmore button').each(function() {
18
+ if ( jQuery(this).data('scrollto') ) {
19
+ var _ul = jQuery(this.parentElement.parentElement).find('ul'); // The UL of the widget.
20
+ _ul.css({
21
+ "height":_ul.prop('scrollHeight'),
22
+ });
23
+ }
24
+ });
25
+
26
  // Handle the click of load more.
27
  jQuery(document).on('click', '.' + php_settings_var + '-loadmore button', function() {
28
  var _this = jQuery(this),
36
  postCount = _this.data('post-count'),
37
  loadingText = _this.data('loading'),
38
  loadmoreText = _this.data('placeholder'),
39
+ widgetNumber = jQuery(this).closest("[id*='" + id + "']").attr('id'),
40
+ scrollHeight = _ul.prop('scrollHeight'), // Scrollbar
41
+ useScrollTo = _this.data('scrollto'); // Scrollbar
42
 
43
  // Change the button text to indicate loading.
44
  _this.text(loadingText);
60
  _this.data('start', start + number);
61
  }
62
  }).done(function() {
63
+
64
+ // Scrollbar
65
+ if (useScrollTo) {
66
+ _ul.stop().animate({
67
+ scrollTop:scrollHeight,
68
+ }, 1000, 'swing');
69
+ }
70
+
71
  var widget = jQuery('#' + widgetNumber);
72
  var widgetImage = jQuery(widget).find('.cat-post-item img').first();
73
 
83
  });
84
  });
85
  });
86
+ }
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 _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)}))}))}))}
1
+ if("undefined"!=typeof jQuery){var php_settings_var="categoryPosts";jQuery(document).ready((function(){jQuery("."+php_settings_var+"-loadmore button").each((function(){if(jQuery(this).data("scrollto")){var _ul=jQuery(this.parentElement.parentElement).find("ul");_ul.css({height:_ul.prop("scrollHeight")})}})),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"),scrollHeight=_ul.prop("scrollHeight"),useScrollTo=_this.data("scrollto");_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(){useScrollTo&&_ul.stop().animate({scrollTop:scrollHeight},1e3,"swing");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)}))}))}))}
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.8
7
- Stable tag: 4.9.11
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 ...](https://tiptoppress.com/category/category-posts-widget)
132
 
 
 
 
133
  = 4.9.11 - April 15th 2021 =
134
  * Wiget title heading level buttons
135
  * Add sticky posts at start
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.8
7
+ Stable tag: 4.9.12
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 ...](https://tiptoppress.com/category/category-posts-widget)
132
 
133
+ = 4.9.12 - July 20 2021 =
134
+ * Deprecated jQuery warnings
135
+
136
  = 4.9.11 - April 15th 2021 =
137
  * Wiget title heading level buttons
138
  * Add sticky posts at start