From 2888527e41a497e63672244d0a40d851fc585553 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sun, 2 Jun 2024 22:43:08 +0200 Subject: [PATCH] v 2.80.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Settings v 0.21.0 - Handle « uncheck all » --- inc/WPUBaseSettings/WPUBaseSettings.php | 30 ++++++++++++++++++++----- wpubaseplugin.php | 6 ++--- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/inc/WPUBaseSettings/WPUBaseSettings.php b/inc/WPUBaseSettings/WPUBaseSettings.php index 178f09e..127e97c 100644 --- a/inc/WPUBaseSettings/WPUBaseSettings.php +++ b/inc/WPUBaseSettings/WPUBaseSettings.php @@ -1,10 +1,10 @@ ' . __('Check all', __NAMESPACE__) . ''; + $check_label = __('Check all', __NAMESPACE__); + $section['after_section'] .= ''; if (!$has_check_all) { $has_check_all = true; add_action('admin_footer', array(&$this, 'admin_footer_checkall')); @@ -582,9 +583,26 @@ function admin_footer_checkall() { echo << jQuery(document).ready(function() { - jQuery(".wpubasesettings-check-all").on("click", function(e) { - e.preventDefault(); - jQuery(this).prev(".form-table").find(":checkbox").prop("checked", true); + jQuery(".wpubasesettings-check-all").each(function() { + var _btn = jQuery(this), + _table = _btn.prev(".form-table"), + _checkboxes = _table.find(":checkbox"), + _check_all = true; + + _btn.on("click", function(e) { + e.preventDefault(); + _checkboxes.prop("checked", _check_all); + _checkboxes.trigger("change"); + }); + + function check_checkboxes_mode() { + var _checked = _checkboxes.filter(":checked").length; + _check_all = _checked < _checkboxes.length; + _btn.text(_check_all ? _btn.data("check-label") : _btn.data("uncheck-label")); + } + _checkboxes.on("change", check_checkboxes_mode); + check_checkboxes_mode(); + }); }); diff --git a/wpubaseplugin.php b/wpubaseplugin.php index 349e116..0d29397 100644 --- a/wpubaseplugin.php +++ b/wpubaseplugin.php @@ -5,7 +5,7 @@ Plugin URI: https://github.com/WordPressUtilities/wpubaseplugin Update URI: https://github.com/WordPressUtilities/wpubaseplugin Description: A framework for a WordPress plugin -Version: 2.79.0 +Version: 2.80.0 Author: Darklg Author URI: https://darklg.me/ Text Domain: wpubaseplugin @@ -20,7 +20,7 @@ class WPUBasePlugin { - public $version = '2.79.0'; + public $version = '2.80.0'; private $utilities_classes = array( 'messages' => array( @@ -36,7 +36,7 @@ class WPUBasePlugin { 'name' => 'WPUBaseAdminPage' ), 'settings' => array( - 'namespace' => 'wpubasesettings_0_20_0', + 'namespace' => 'wpubasesettings_0_21_0', 'name' => 'WPUBaseSettings' ), 'cron' => array(