Skip to content

Commit 4e39c6f

Browse files
committed
fix to coderabbit's qa
1 parent df79ec5 commit 4e39c6f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/lazy-components/cimo/index.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,19 @@ public function enqueue_script() {
7575
return;
7676
}
7777

78+
$is_installed = self::is_plugin_installed();
79+
80+
// Prevent exposing Cimo plugin status and action URLs to users lacking the necessary install or activate plugin capabilities.
81+
if ( ( ! $is_installed && ! current_user_can( 'install_plugins' ) ) ||
82+
( $is_installed && ! current_user_can( 'activate_plugins' ) )
83+
) {
84+
return;
85+
}
86+
7887
$cimo_status = 'activated';
7988
$cimo_action = '';
8089

81-
if ( ! self::is_plugin_installed() ) {
90+
if ( ! $is_installed ) {
8291
$cimo_status = 'not_installed';
8392
$cimo_action = wp_nonce_url(
8493
add_query_arg(
@@ -104,6 +113,11 @@ public function enqueue_script() {
104113
);
105114
}
106115

116+
// No need to expose plugin status and action URL if it's activated.
117+
if ( $cimo_status === 'activated' ) {
118+
return;
119+
}
120+
107121
$data = array(
108122
'status' => $cimo_status,
109123
'action' => html_entity_decode( $cimo_action ),

0 commit comments

Comments
 (0)