Skip to content

Commit

Permalink
Don't enqueue remove url script for non-editor users
Browse files Browse the repository at this point in the history
  • Loading branch information
jdevalk committed Jan 17, 2025
1 parent e108b45 commit cbfd7de
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions inc/hacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,17 @@ public function remove_comment_url() {
* @return void
*/
public function enqueue_comment_block_scripts() {
\wp_enqueue_script( 'ch-comment-block-edit', \plugin_dir_url( \EMILIA_COMMENT_HACKS_FILE ) . 'admin/assets/js/remove-url.js', [ 'jquery' ], '1.0.0', true );
\wp_localize_script(
'ch-comment-block-edit',
'chCommentBlockEdit',
[
'ajax_url' => \admin_url( 'admin-ajax.php' ),
'nonce' => \wp_create_nonce( 'ch_remove_comment_url_nonce' ),
]
);
if ( \current_user_can( 'edit_posts' ) ) {
\wp_enqueue_script( 'ch-comment-block-edit', \plugin_dir_url( \EMILIA_COMMENT_HACKS_FILE ) . 'admin/assets/js/remove-url.js', [ 'jquery' ], '1.0.0', true );
\wp_localize_script(
'ch-comment-block-edit',
'chCommentBlockEdit',
[
'ajax_url' => \admin_url( 'admin-ajax.php' ),
'nonce' => \wp_create_nonce( 'ch_remove_comment_url_nonce' ),
]
);
}
}

/**
Expand Down

0 comments on commit cbfd7de

Please sign in to comment.