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(); ?>