Changeset 3438021
- Timestamp:
- 01/12/2026 05:27:19 PM (3 months ago)
- Location:
- notifier-to-slack
- Files:
-
- 2 edited
-
tags/3.11.0/inc/AdminDashboard.php (modified) (9 diffs)
-
trunk/inc/AdminDashboard.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
notifier-to-slack/tags/3.11.0/inc/AdminDashboard.php
r3434442 r3438021 234 234 $pro_version = $this->get_pro_plugin_version(); 235 235 if ( ! $pro_version ) { 236 return; 237 } 238 239 // Check if Pro version is compatible (2.2.0 or higher) 240 if ( version_compare( $pro_version, '2.2.0', '>=' ) ) { 241 // Pro version is compatible - clear any existing upgrade flags 242 $this->clear_pro_upgrade_flags(); 236 243 return; 237 244 } … … 256 263 echo '</p></div>'; 257 264 }); 265 } 266 } 267 268 /** 269 * Clear Pro upgrade flags when compatible version is detected. 270 * 271 * @since 3.11.0 272 */ 273 private function clear_pro_upgrade_flags() { 274 // Clear upgrade flags if they exist 275 if ( get_option( 'wpnts_pro_upgrade_required' ) ) { 276 delete_option( 'wpnts_pro_upgrade_required' ); 277 } 278 279 if ( get_option( 'wpnts_pro_upgrade_notice_dismissed' ) ) { 280 delete_option( 'wpnts_pro_upgrade_notice_dismissed' ); 281 } 282 283 if ( get_option( 'wpnts_pro_old_version' ) ) { 284 delete_option( 'wpnts_pro_old_version' ); 258 285 } 259 286 } … … 334 361 nonce: '<?php echo wp_create_nonce( 'wpnts_dismiss_notice' ); ?>' 335 362 }, function(response) { 363 if (response.success) { 364 jQuery('#wpnts-pro-upgrade-notice').fadeOut(); 365 } else { 366 console.error('Failed to dismiss notice:', response.data ? response.data.message : 'Unknown error'); 367 // Still hide the notice on client side to prevent user frustration 368 jQuery('#wpnts-pro-upgrade-notice').fadeOut(); 369 } 370 }).fail(function(xhr, status, error) { 371 console.error('AJAX request failed:', error); 372 // Still hide the notice on client side to prevent user frustration 336 373 jQuery('#wpnts-pro-upgrade-notice').fadeOut(); 337 374 }); … … 355 392 */ 356 393 public function dismiss_pro_upgrade_notice() { 357 // Verify nonce 358 if ( ! wp_verify_nonce( $_POST['nonce'], 'wpnts_dismiss_notice' ) ) { 359 wp_die( 'Security check failed' ); 394 // Check if user has proper capabilities 395 if ( ! current_user_can( 'manage_options' ) ) { 396 wp_die( 'Insufficient permissions' ); 397 } 398 399 // Verify nonce with proper sanitization 400 $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : ''; 401 402 if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'wpnts_dismiss_notice' ) ) { 403 wp_send_json_error( array( 'message' => 'Security check failed' ) ); 404 return; 360 405 } 361 406 … … 363 408 update_option( 'wpnts_pro_upgrade_notice_dismissed', true ); 364 409 365 wp_send_json_success( );410 wp_send_json_success( array( 'message' => 'Notice dismissed successfully' ) ); 366 411 } 367 412 … … 384 429 // Deactivate the Pro plugin immediately 385 430 deactivate_plugins( 'notifier-to-slack-pro/notifier-to-slack-pro.php' ); 431 432 // Set upgrade flags 433 update_option( 'wpnts_pro_upgrade_required', true ); 434 update_option( 'wpnts_pro_old_version', $pro_version ); 386 435 387 436 // Show error message … … 396 445 array( 'back_link' => true ) 397 446 ); 447 } else if ( version_compare( $free_version, '3.11.0', '>=' ) && version_compare( $pro_version, '2.2.0', '>=' ) ) { 448 // Compatible Pro version activated - clear any existing upgrade flags 449 $this->clear_pro_upgrade_flags(); 398 450 } 399 451 } … … 405 457 */ 406 458 public function reset_pro_upgrade_notice() { 407 // Verify nonce 408 if ( ! wp_verify_nonce( $_POST['nonce'], 'wpnts_reset_notice' ) ) { 409 wp_die( 'Security check failed' ); 459 // Check if user has proper capabilities 460 if ( ! current_user_can( 'manage_options' ) ) { 461 wp_die( 'Insufficient permissions' ); 462 } 463 464 // Verify nonce with proper sanitization 465 $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : ''; 466 467 if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'wpnts_reset_notice' ) ) { 468 wp_send_json_error( array( 'message' => 'Security check failed' ) ); 469 return; 410 470 } 411 471 … … 415 475 delete_option( 'wpnts_pro_old_version' ); 416 476 417 wp_send_json_success( 'Pro upgrade notice reset successfully');477 wp_send_json_success( array( 'message' => 'Pro upgrade notice reset successfully' ) ); 418 478 } 419 479 } -
notifier-to-slack/trunk/inc/AdminDashboard.php
r3434442 r3438021 234 234 $pro_version = $this->get_pro_plugin_version(); 235 235 if ( ! $pro_version ) { 236 return; 237 } 238 239 // Check if Pro version is compatible (2.2.0 or higher) 240 if ( version_compare( $pro_version, '2.2.0', '>=' ) ) { 241 // Pro version is compatible - clear any existing upgrade flags 242 $this->clear_pro_upgrade_flags(); 236 243 return; 237 244 } … … 256 263 echo '</p></div>'; 257 264 }); 265 } 266 } 267 268 /** 269 * Clear Pro upgrade flags when compatible version is detected. 270 * 271 * @since 3.11.0 272 */ 273 private function clear_pro_upgrade_flags() { 274 // Clear upgrade flags if they exist 275 if ( get_option( 'wpnts_pro_upgrade_required' ) ) { 276 delete_option( 'wpnts_pro_upgrade_required' ); 277 } 278 279 if ( get_option( 'wpnts_pro_upgrade_notice_dismissed' ) ) { 280 delete_option( 'wpnts_pro_upgrade_notice_dismissed' ); 281 } 282 283 if ( get_option( 'wpnts_pro_old_version' ) ) { 284 delete_option( 'wpnts_pro_old_version' ); 258 285 } 259 286 } … … 334 361 nonce: '<?php echo wp_create_nonce( 'wpnts_dismiss_notice' ); ?>' 335 362 }, function(response) { 363 if (response.success) { 364 jQuery('#wpnts-pro-upgrade-notice').fadeOut(); 365 } else { 366 console.error('Failed to dismiss notice:', response.data ? response.data.message : 'Unknown error'); 367 // Still hide the notice on client side to prevent user frustration 368 jQuery('#wpnts-pro-upgrade-notice').fadeOut(); 369 } 370 }).fail(function(xhr, status, error) { 371 console.error('AJAX request failed:', error); 372 // Still hide the notice on client side to prevent user frustration 336 373 jQuery('#wpnts-pro-upgrade-notice').fadeOut(); 337 374 }); … … 355 392 */ 356 393 public function dismiss_pro_upgrade_notice() { 357 // Verify nonce 358 if ( ! wp_verify_nonce( $_POST['nonce'], 'wpnts_dismiss_notice' ) ) { 359 wp_die( 'Security check failed' ); 394 // Check if user has proper capabilities 395 if ( ! current_user_can( 'manage_options' ) ) { 396 wp_die( 'Insufficient permissions' ); 397 } 398 399 // Verify nonce with proper sanitization 400 $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : ''; 401 402 if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'wpnts_dismiss_notice' ) ) { 403 wp_send_json_error( array( 'message' => 'Security check failed' ) ); 404 return; 360 405 } 361 406 … … 363 408 update_option( 'wpnts_pro_upgrade_notice_dismissed', true ); 364 409 365 wp_send_json_success( );410 wp_send_json_success( array( 'message' => 'Notice dismissed successfully' ) ); 366 411 } 367 412 … … 384 429 // Deactivate the Pro plugin immediately 385 430 deactivate_plugins( 'notifier-to-slack-pro/notifier-to-slack-pro.php' ); 431 432 // Set upgrade flags 433 update_option( 'wpnts_pro_upgrade_required', true ); 434 update_option( 'wpnts_pro_old_version', $pro_version ); 386 435 387 436 // Show error message … … 396 445 array( 'back_link' => true ) 397 446 ); 447 } else if ( version_compare( $free_version, '3.11.0', '>=' ) && version_compare( $pro_version, '2.2.0', '>=' ) ) { 448 // Compatible Pro version activated - clear any existing upgrade flags 449 $this->clear_pro_upgrade_flags(); 398 450 } 399 451 } … … 405 457 */ 406 458 public function reset_pro_upgrade_notice() { 407 // Verify nonce 408 if ( ! wp_verify_nonce( $_POST['nonce'], 'wpnts_reset_notice' ) ) { 409 wp_die( 'Security check failed' ); 459 // Check if user has proper capabilities 460 if ( ! current_user_can( 'manage_options' ) ) { 461 wp_die( 'Insufficient permissions' ); 462 } 463 464 // Verify nonce with proper sanitization 465 $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : ''; 466 467 if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'wpnts_reset_notice' ) ) { 468 wp_send_json_error( array( 'message' => 'Security check failed' ) ); 469 return; 410 470 } 411 471 … … 415 475 delete_option( 'wpnts_pro_old_version' ); 416 476 417 wp_send_json_success( 'Pro upgrade notice reset successfully');477 wp_send_json_success( array( 'message' => 'Pro upgrade notice reset successfully' ) ); 418 478 } 419 479 }
Note: See TracChangeset
for help on using the changeset viewer.