diff --git a/accordion-blocks.php b/accordion-blocks.php index 3ceb7e4..262d9ea 100644 --- a/accordion-blocks.php +++ b/accordion-blocks.php @@ -4,7 +4,7 @@ * Plugin Name: Accordion Blocks * Plugin URI: https://github.com/philbuchanan/Accordion-Blocks * Description: Gutenberg blocks for creating responsive accordion drop-downs. - * Version: 1.3.4 + * Version: 1.3.5 * Requires at least: 5.5 * Author: Phil Buchanan * Author URI: https://philbuchanan.com @@ -112,9 +112,9 @@ public function enqueue_editor_assets() { * Enqueue the block's assets for the frontend */ public function enqueue_frontend_assets() { - $load_scripts_globablly = get_option('accordion_blocks_load_scripts_globablly'); + $load_scripts_globally = $this->should_load_scripts_globally(); - if ($load_scripts_globablly || has_block('pb/accordion-item', get_the_ID())) { + if ($load_scripts_globally || has_block('pb/accordion-item', get_the_ID())) { $min = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; wp_enqueue_script( @@ -188,10 +188,10 @@ public function register_settings() { register_setting( 'accordion_blocks_settings', - 'accordion_blocks_load_scripts_globablly', + 'accordion_blocks_load_scripts_globally', array( 'type' => 'boolean', - 'default' => true, + 'default' => 'on', ) ); } @@ -283,6 +283,27 @@ public function add_documentation_link($links) { + /** + * Get the load_scripts_globally option and return true or false. + */ + private function should_load_scripts_globally() { + /** + * This removes the old option (the option name had a typo), but ensures + * the new option gets updated with the same setting. + */ + if (get_option('accordion_blocks_load_scripts_globablly') == 'on') { + update_option('accordion_blocks_load_scripts_globally', 'on'); + } + + delete_option('accordion_blocks_load_scripts_globablly'); + + $load_scripts_globally = get_option('accordion_blocks_load_scripts_globally', 'on'); + + return !!$load_scripts_globally; + } + + + /** * Add the admin menu settings page */ @@ -332,13 +353,13 @@ public function settings_api_init() { ); add_settings_field( - 'accordion_blocks_load_scripts_globablly', + 'accordion_blocks_load_scripts_globally', __('Scripts and Styles', 'accordion-blocks'), - array($this, 'load_scripts_globablly_setting_callback'), + array($this, 'load_scripts_globally_setting_callback'), 'accordion_blocks_settings', 'accordion_blocks_global_settings_section', array( - 'label_for' => 'accordion_blocks_load_scripts_globablly', + 'label_for' => 'accordion_blocks_load_scripts_globally', ) ); } @@ -356,28 +377,28 @@ public function accordion_blocks_global_settings_section_callback() {} /** * Callback function for load scripts globally setting */ - public function load_scripts_globablly_setting_callback() { - $load_scripts_globablly = get_option('accordion_blocks_load_scripts_globablly'); ?> + public function load_scripts_globally_setting_callback() { + $load_scripts_globally = $this->should_load_scripts_globally(); ?>
-
diff --git a/languages/default.pot b/languages/default.pot index 0e07bb4..81e9ebb 100755 --- a/languages/default.pot +++ b/languages/default.pot @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: Accordion Blocks\n" -"POT-Creation-Date: 2021-04-08 09:52-0400\n" +"POT-Creation-Date: 2021-05-27 12:31-0400\n" "PO-Revision-Date: 2020-04-06 18:05-0400\n" "Last-Translator: Phil Buchanan \n" "Language-Team: Phil Buchanan\n" @@ -25,60 +25,36 @@ msgstr "" msgid "Donate" msgstr "" -#: ../accordion-blocks.php:291 ../accordion-blocks.php:310 +#: ../accordion-blocks.php:312 ../accordion-blocks.php:331 msgid "Accordion Blocks Settings" msgstr "" -#: ../accordion-blocks.php:292 +#: ../accordion-blocks.php:313 msgid "Accordion Blocks" msgstr "" -#: ../accordion-blocks.php:306 ../inc/admin-page.php:24 +#: ../accordion-blocks.php:327 msgid "You do not have sufficient permissions to access this page." msgstr "" -#: ../accordion-blocks.php:329 +#: ../accordion-blocks.php:350 msgid "Global Settings" msgstr "" -#: ../accordion-blocks.php:336 ../accordion-blocks.php:363 +#: ../accordion-blocks.php:357 ../accordion-blocks.php:384 msgid "Scripts and Styles" msgstr "" -#: ../accordion-blocks.php:373 -msgid "Load scripts and styles globablly" +#: ../accordion-blocks.php:394 +msgid "Load scripts and styles globally" msgstr "" -#: ../accordion-blocks.php:377 +#: ../accordion-blocks.php:398 msgid "Turning this off may cause accordions to stop working in some instances." msgstr "" -#: ../accordion-blocks.php:380 -msgid "Leave this on if you use accordions outside of the main content editor, or are adding accordions programatically." -msgstr "" - -#: ../inc/admin-page.php:8 ../inc/admin-page.php:9 ../inc/admin-page.php:28 -msgid "Theme Settings" -msgstr "" - -#: ../inc/admin-page.php:47 -msgid "Google Maps Settings" -msgstr "" - -#: ../inc/admin-page.php:54 -msgid "Google Maps API Key" -msgstr "" - -#: ../inc/admin-page.php:65 -msgid "Google Maps Pin Color" -msgstr "" - -#: ../inc/admin-page.php:110 -msgid "Learn how to get a Google Maps API key" -msgstr "" - -#: ../inc/admin-page.php:137 -msgid "A hex color value (e.g. #acd123) to use as the default Google Maps marker pin color." +#: ../accordion-blocks.php:401 +msgid "Turn this on if you use accordions outside of the main content editor, or are adding accordions programatically." msgstr "" #: ../src/block/edit.js:161 ../src/block/edit.js:171 diff --git a/package.json b/package.json index 05e6fdd..3d8c067 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "accordion-blocks", - "version": "1.3.4", + "version": "1.3.5", "description": "Gutenberg blocks for creating responsive accordion drop-downs.", "main": "src/index.js", "scripts": { diff --git a/readme.txt b/readme.txt index c00db61..bfa23e3 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Donate Link: https://philbuchanan.com/donate/ Tags: accordion, accordions, gutenberg, block, responsive Requires at least: 5.5 Tested up to: 5.7 -Stable tag: 1.3.4 +Stable tag: 1.3.5 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -89,6 +89,9 @@ For bug reports or feature requests or if you'd like to contribute to the plugin 2. Accordion block in the editor == Changelog == += 1.3.5 = +* Fixed: An issue where the global loading of scripts and styles checkbox was checked when the setting was actually off. + = 1.3.4 = * Fixed: Made turning off global loading of scripts and styles an explicit setting. You can turn off this off in Settings > Accordion Blocks. @@ -172,6 +175,9 @@ For bug reports or feature requests or if you'd like to contribute to the plugin * All new plugin to support the new WordPress Gutenberg editor. == Upgrade Notice == += 1.3.5 = +Fixed an issue where the global loading of scripts and styles checkbox was checked when the setting was actually off. + = 1.3.4 = Made turning off global loading of scripts and styles an explicit setting. You can turn off this off in Settings > Accordion Blocks.