-
Notifications
You must be signed in to change notification settings - Fork 19
Integration branch: Sidebar Metabox #1332
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
Changes from 125 commits
0251fcc
dd1392f
67e92d8
1d93cea
1d8e558
8c4cd1c
7668fd2
90b4ae2
fb9db34
ffc4dd6
900e882
b77dee3
7817b40
a2794a3
a8c78cc
f930e50
57bffd6
8abb52c
2620171
2fc1454
c7c39e0
a47dbe8
6e0567a
913672f
9613324
775df9e
2f9ddf6
777c1a7
ee17ec0
cf707ff
b8168e6
ccc6410
3b9cefc
b82799c
e5a6128
3b0a198
2c2f729
2122c4e
dfcb6ff
719d58c
b773509
eebeac8
d6f7b44
7d46dc7
2a9621b
a155912
de7ddb4
91df4ff
1aada59
30734be
3e3ee98
dd4c35f
ccc011a
9340134
6090da0
f4e1c3a
627e4d6
4814709
1ed4412
3d5b5b2
0e1e751
60e4e91
7ff8b53
b15b919
04ae21e
0fca6e7
2d45195
396d699
2e5232a
99a51e1
091a658
c760dd8
32f82f4
fb89e6f
872fbb9
b48b482
87aee09
79e0e19
7c7ff1a
325497e
762ee96
3eb22d0
2464b63
8dcbcef
8126f73
50892a9
2d737d0
0eec8a6
42e75df
2f09a85
f107fa1
853e7d7
b6cfdd4
00773d0
3932c69
e3ed1ce
af212eb
56f52bb
7d35769
3d8231d
5e3e32b
d99ed26
a41c6d1
e623aab
eaa9b54
56c66c1
4b867f7
f6fcc2c
3dbca12
1f558f7
1cb1078
c6abe5c
8f9194b
538e397
6e3dd1d
3394747
2d0603b
cc030e8
0ba5849
b05f240
25d1cf5
bb04b29
97541e6
79d3239
e53d9c4
27a9a15
b357636
742bae0
3e93eb7
ab74aeb
22da85b
c448773
78297e6
94f4983
c57e304
3598cba
5e3f57e
0cfedf4
fb3cf58
893f014
223c161
bf6b5f6
d45d70c
8cc8e1c
2a1a478
d97c0e5
52d6ebb
08c337a
6f5e460
f464a92
f617c14
d13ba3b
3355a3f
72ddff2
bc17adc
9dd19ae
5e4fd73
476132b
18c2449
6465af8
ee25828
b690bd7
2b779de
7f52e0b
0d0725a
ab79fdb
2ff7da5
bc1d434
1131feb
f550a42
57d2c52
1aac068
6cad30e
7c9afba
95b5822
b7e1437
386e525
ca02b4b
059c3f3
e23016d
bd9a654
25885cb
7b16bf5
f752c3c
578b1fe
261d9df
a9141d4
3eadb5b
7446b0e
4e0196d
f176039
2ebe9fa
96ff297
850857a
43fb777
569993c
b4d7b98
d58f17b
865c7cc
5de0870
0efd13a
b6d6b10
987487b
a1a5851
6eb1ff5
ff03831
7e878a4
f3dda57
4319781
f3a4afb
102f8e9
be9860a
f4fcfde
df5e7b1
99ade24
bb31a14
92bee8c
54211cb
95322ba
997a194
414a55c
1a48608
1cf3fb5
8b7f140
71b9ab4
8fdd5b6
8b2954f
322d2b5
d83e00a
21b2fbe
395d57f
f8508a4
bbc21e1
1c6ef4b
0a88b7e
0fb86a3
1338972
93553e0
9f3a412
7a65cee
e521eab
7ec6158
f590a14
cc0b17c
30d3241
54f6c93
614ec89
0069a71
e3f11f8
4726454
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,11 @@ | ||
| { | ||
| "presets": [ | ||
| "@babel/preset-env", | ||
| [ | ||
| "@babel/preset-react", | ||
| { | ||
| "runtime": "automatic" | ||
| } | ||
| ] | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ public function __construct() { | |
| public static function enqueue() { | ||
| self::enqueue_styles(); | ||
| self::maybe_enqueue_admin_and_editor_app_scripts(); | ||
| self::maybe_enqueue_sidebar_script(); | ||
| self::maybe_enqueue_email_opt_in_script(); | ||
| } | ||
|
|
||
|
|
@@ -49,7 +50,8 @@ public static function maybe_enqueue_admin_and_editor_app_scripts() { | |
|
|
||
| global $pagenow; | ||
| $post_types = Settings::get_scannable_post_types(); | ||
| $current_post_type = get_post_type(); | ||
| $has_post_types = is_array( $post_types ) && count( $post_types ); | ||
| $is_scannable_post = Helpers::is_current_post_type_scannable( $post_types ); | ||
| $page = self::get_current_page_slug(); | ||
| $enabled_pages = apply_filters( | ||
| 'edac_filter_admin_scripts_slugs', | ||
|
|
@@ -63,10 +65,9 @@ public static function maybe_enqueue_admin_and_editor_app_scripts() { | |
|
|
||
| if ( | ||
| ( | ||
| is_array( $post_types ) && | ||
| count( $post_types ) && | ||
| $has_post_types && | ||
| ( | ||
| in_array( $current_post_type, $post_types, true ) || | ||
| $is_scannable_post || | ||
| in_array( $page, $enabled_pages, true ) | ||
| ) | ||
| ) || | ||
|
|
@@ -93,9 +94,7 @@ public static function maybe_enqueue_admin_and_editor_app_scripts() { | |
| if ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) { | ||
|
|
||
| // Is this posttype setup to be checked? | ||
| $post_types = Settings::get_scannable_post_types(); | ||
| $current_post_type = get_post_type(); | ||
| $active = ( is_array( $post_types ) && in_array( $current_post_type, $post_types, true ) ); | ||
| $active = $is_scannable_post; | ||
|
|
||
| $pro = defined( 'EDACP_VERSION' ) && EDAC_KEY_VALID; | ||
|
|
||
|
|
@@ -149,6 +148,75 @@ public static function maybe_enqueue_admin_and_editor_app_scripts() { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Enqueue the Gutenberg sidebar script. | ||
| * | ||
| * @return void | ||
| */ | ||
| public static function maybe_enqueue_sidebar_script() { | ||
| global $pagenow; | ||
|
|
||
| // Only load on post edit screens. | ||
| if ( 'post.php' !== $pagenow && 'post-new.php' !== $pagenow ) { | ||
| return; | ||
| } | ||
|
|
||
| if ( ! Helpers::is_block_editor() ) { | ||
| return; | ||
| } | ||
|
|
||
| // Check if this post type is scannable. | ||
| $post_types = Settings::get_scannable_post_types(); | ||
| if ( ! Helpers::is_current_post_type_scannable( $post_types ) ) { | ||
| return; | ||
| } | ||
|
|
||
| // Enqueue the sidebar script with WordPress dependencies. | ||
| wp_enqueue_script( | ||
| 'edac-sidebar', | ||
| plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/sidebar.bundle.js', | ||
| [ | ||
| 'wp-plugins', | ||
| 'wp-edit-post', | ||
| 'wp-editor', | ||
| 'wp-element', | ||
| 'wp-data', | ||
| 'wp-i18n', | ||
| 'wp-api-fetch', | ||
| 'wp-components', | ||
| ], | ||
| EDAC_VERSION, | ||
| false | ||
| ); | ||
|
|
||
| // Set translations for the sidebar. | ||
| wp_set_script_translations( 'edac-sidebar', 'accessibility-checker', plugin_dir_path( EDAC_PLUGIN_FILE ) . 'languages' ); | ||
|
|
||
| // Localize script with necessary data. | ||
| wp_localize_script( | ||
| 'edac-sidebar', | ||
| 'edac_sidebar_app', | ||
| [ | ||
| 'gutenbergEnabled' => true, | ||
| 'postID' => get_the_ID(), | ||
| 'edacApiUrl' => esc_url_raw( rest_url() . 'accessibility-checker/v1' ), | ||
| 'nonce' => wp_create_nonce( 'wp_rest' ), | ||
| 'settingsUrl' => esc_url_raw( admin_url( 'admin.php?page=accessibility_checker_settings' ) ), | ||
| 'readabilityHelpUrl' => esc_url_raw( edac_link_wrapper( 'https://a11ychecker.com/help3265', 'wordpress-general', 'content-analysis-sidebar', false ) ), | ||
| 'manuallyTestHelpUrl' => esc_url_raw( edac_link_wrapper( 'https://a11ychecker.com/help4280', 'wordpress-general', 'content-analysis-sidebar', false ) ), | ||
| ] | ||
| ); | ||
|
Comment on lines
+198
to
+214
Contributor
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. 🧩 Analysis chain🏁 Script executed: # Check client-side code for nonce key usage
rg -n "edac_sidebar_app\.(nonce|restNonce)" -t js
# Also check broader patterns in JS/sidebar code
rg -n "\.nonce\b|\.restNonce\b" -t js | head -30Repository: equalizedigital/accessibility-checker Length of output: 1530 🏁 Script executed: # Verify the nonce key usage in the PHP file itself at the mentioned lines
sed -n '85,95p; 139,149p; 200,215p' admin/class-enqueue-admin.phpRepository: equalizedigital/accessibility-checker Length of output: 1681 🏁 Script executed: # Find all localize_script calls in the file to see naming patterns
rg -A 15 "wp_localize_script" admin/class-enqueue-admin.phpRepository: equalizedigital/accessibility-checker Length of output: 2192 Nonce key naming inconsistency in The REST API nonce is named Rename to align with the established convention: 🔧 Suggested fix wp_localize_script(
'edac-sidebar',
'edac_sidebar_app',
[
'gutenbergEnabled' => true,
'postID' => get_the_ID(),
'highlightNonce' => wp_create_nonce( 'edac_highlight' ),
'ajaxNonce' => wp_create_nonce( 'ajax-nonce' ),
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'edacApiUrl' => esc_url_raw( rest_url() . 'accessibility-checker/v1' ),
- 'nonce' => wp_create_nonce( 'wp_rest' ),
+ 'restNonce' => wp_create_nonce( 'wp_rest' ),
'settingsUrl' => esc_url_raw( admin_url( 'admin.php?page=accessibility_checker_settings' ) ),
'readabilityHelpUrl' => esc_url_raw( edac_link_wrapper( 'https://a11ychecker.com/help3265', 'wordpress-general', 'content-analysis-sidebar', false ) ),
'manuallyTestHelpUrl' => esc_url_raw( edac_link_wrapper( 'https://a11ychecker.com/help4280', 'wordpress-general', 'content-analysis-sidebar', false ) ),
]
);🤖 Prompt for AI Agents |
||
|
|
||
| // Enqueue sidebar styles. | ||
| wp_enqueue_style( | ||
| 'edac-sidebar', | ||
| plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/css/sidebar.css', | ||
| [], | ||
| EDAC_VERSION, | ||
| 'all' | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Enqueue the email opt-in script on the welcome page. | ||
| * | ||
|
|
@@ -170,6 +238,7 @@ public static function maybe_enqueue_email_opt_in_script() { | |
| $email_opt_in->enqueue_scripts(); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Gets the current admin page slug. | ||
| * | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Missing
restNoncefor authenticated REST API calls.The localized data for the sidebar script does not include
restNonce, which is required for authenticated REST API requests. Other scripts in this file (e.g.,edac_script_varsat line 89,edac_editor_appat line 145) include this nonce. Without it, the sidebar's API calls to thesidebar-dataendpoint may fail authentication.🔧 Proposed fix
wp_localize_script( 'edac-sidebar', 'edac_sidebar_app', [ 'gutenbergEnabled' => true, 'postID' => get_the_ID(), 'edacApiUrl' => esc_url_raw( rest_url() . 'accessibility-checker/v1' ), + 'restNonce' => wp_create_nonce( 'wp_rest' ), ] );🤖 Prompt for AI Agents
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.
I will be tackling this later when I add buttons for actions like rescan and clear issues.
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.
@pattonwebz, sounds good! Since this will be addressed in a future change when you add the action buttons, would you like me to create an issue to track adding therestNonceto the sidebar's localized data? That way it won't be forgotten when implementing the rescan and clear issues functionality.