Skip to content

Commit

Permalink
Ensure loading of legacy widget based on any saved data and fixed leg…
Browse files Browse the repository at this point in the history
…acy JS
  • Loading branch information
bainternet committed Jan 20, 2025
1 parent a27a2dc commit f56a966
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
5 changes: 3 additions & 2 deletions modules/legacy/components/frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ public function get_toolbar_button_title( $button_type ) {
}

public function enqueue_scripts() {
$assets_url = EA11Y_URL . 'modules/legacy/assets/';
wp_register_script(
'pojo-a11y',
EA11Y_URL . 'modules/legacy/js/app.min.js',
$assets_url . 'js/app.min.js',
[ 'jquery' ],
'1.0.0',
true
);

wp_register_style(
'pojo-a11y',
EA11Y_URL . 'modules/legacy/assets/css/style.min.css',
$assets_url . 'css/style.min.css',
[],
'1.0.0'
);
Expand Down
45 changes: 45 additions & 0 deletions modules/legacy/components/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,51 @@ public static function upgrade() : void {
update_option( self::UPGRADED_OPTION, true );
}

/**
* has_legacy_data
* used to check if the user has any legacy data stored
* @return bool
*/
public static function has_legacy_data() : bool {
$options = [
'pojo_a11y_focusable',
'pojo_a11y_skip_to_content_link',
'pojo_a11y_skip_to_content_link_element_id',
'pojo_a11y_remove_link_target',
'pojo_a11y_add_role_links',
'pojo_a11y_save',
'pojo_a11y_save_expiration',
'pojo_a11y_toolbar_title',
'pojo_a11y_toolbar_button_resize_font',
'pojo_a11y_toolbar_button_resize_font_add_title',
'pojo_a11y_toolbar_button_resize_font_less_title',
'pojo_a11y_toolbar_button_grayscale',
'pojo_a11y_toolbar_button_grayscale_title',
'pojo_a11y_toolbar_button_high_contrast',
'pojo_a11y_toolbar_button_high_contrast_title',
'pojo_a11y_toolbar_button_negative_contrast',
'pojo_a11y_toolbar_button_negative_contrast_title',
'pojo_a11y_toolbar_button_light_bg',
'pojo_a11y_toolbar_button_light_bg_title',
'pojo_a11y_toolbar_button_links_underline',
'pojo_a11y_toolbar_button_links_underline_title',
'pojo_a11y_toolbar_button_readable_font',
'pojo_a11y_toolbar_button_readable_font_title',
'pojo_a11y_toolbar_button_sitemap_title',
'pojo_a11y_toolbar_button_sitemap_link',
'pojo_a11y_toolbar_button_help_title',
'pojo_a11y_toolbar_button_help_link',
'pojo_a11y_toolbar_button_feedback_title',
'pojo_a11y_toolbar_button_feedback_link',
];
foreach ( $options as $option ) {
if ( get_option( $option, false ) ) {
return true;
}
}
return false;
}

/**
* is_upgraded
* @return bool
Expand Down
2 changes: 1 addition & 1 deletion modules/legacy/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static function get_settings() {
}

public static function is_active(): bool {
if ( get_option( 'pojo_a11y_toolbar', false ) && ! Upgrade::is_upgraded() ) {
if ( Upgrade::has_legacy_data() && ! Upgrade::is_upgraded() ) {
return true;
}
return false;
Expand Down

0 comments on commit f56a966

Please sign in to comment.