-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[APP-721] Render widget and global settings #124
Changes from all commits
7d2c821
3b29e7b
95b4ee1
d5d84e5
41172de
770ee52
ef59dc9
b7afde2
ac56f0f
e4030dd
1969be2
008de11
b87ad0d
445a9cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace EA11y\Modules\Widget; | ||
|
||
use EA11y\Classes\Module_Base; | ||
use EA11y\Modules\Connect\Module as Connect; | ||
use EA11y\Modules\Settings\Classes\Settings; | ||
use Exception; | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; // Exit if accessed directly. | ||
} | ||
|
||
class Module extends Module_Base { | ||
|
||
public function get_name(): string { | ||
return 'widget'; | ||
} | ||
|
||
/** | ||
* Enqueue scripts | ||
* | ||
* @return void | ||
* @throws Exception | ||
*/ | ||
public function enqueue_accessibility_widget () : void { | ||
|
||
if ( ! Connect::is_connected() ) { | ||
return; | ||
} | ||
|
||
$plan_data = Settings::get( Settings::PLAN_DATA ); | ||
|
||
if ( ! isset( $plan_data->public_api_key ) ) { | ||
return; | ||
} | ||
|
||
wp_enqueue_script( | ||
'ea11y-widget', | ||
$this->get_widget_url() .'?api_key=' . $plan_data->public_api_key, | ||
[], | ||
EA11Y_VERSION, | ||
true | ||
); | ||
|
||
wp_localize_script( | ||
'ea11y-widget', | ||
'ea11yWidget', | ||
[ | ||
'iconSettings' => get_option( 'ea11y_widget_icon_settings' ), | ||
'menuSettings' => get_option( 'ea11y_widget_menu_settings' ), | ||
] | ||
); | ||
} | ||
|
||
private function get_widget_url() : string { | ||
return apply_filters( 'ea11y_widget_url', '' ); // TODO: add public url | ||
} | ||
|
||
/** | ||
* Module constructor. | ||
*/ | ||
public function __construct() { | ||
add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_accessibility_widget' ] ); | ||
} | ||
Comment on lines
+63
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be enqueue only if connected There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bainternet Should there be a check for plan data as well? If the pan data is not available, then the widget should not load. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes also the pr is not fixed in both comments |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this should probably be above it