Plugin Directory

Changeset 3438021


Ignore:
Timestamp:
01/12/2026 05:27:19 PM (3 months ago)
Author:
wpazleen
Message:

missing file updated

Location:
notifier-to-slack
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • notifier-to-slack/tags/3.11.0/inc/AdminDashboard.php

    r3434442 r3438021  
    234234        $pro_version = $this->get_pro_plugin_version();
    235235        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();
    236243            return;
    237244        }
     
    256263                echo '</p></div>';
    257264            });
     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' );
    258285        }
    259286    }
     
    334361                nonce: '<?php echo wp_create_nonce( 'wpnts_dismiss_notice' ); ?>'
    335362            }, 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
    336373                jQuery('#wpnts-pro-upgrade-notice').fadeOut();
    337374            });
     
    355392     */
    356393    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;
    360405        }
    361406
     
    363408        update_option( 'wpnts_pro_upgrade_notice_dismissed', true );
    364409       
    365         wp_send_json_success();
     410        wp_send_json_success( array( 'message' => 'Notice dismissed successfully' ) );
    366411    }
    367412
     
    384429            // Deactivate the Pro plugin immediately
    385430            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 );
    386435           
    387436            // Show error message
     
    396445                array( 'back_link' => true )
    397446            );
     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();
    398450        }
    399451    }
     
    405457     */
    406458    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;
    410470        }
    411471
     
    415475        delete_option( 'wpnts_pro_old_version' );
    416476       
    417         wp_send_json_success( 'Pro upgrade notice reset successfully' );
     477        wp_send_json_success( array( 'message' => 'Pro upgrade notice reset successfully' ) );
    418478    }
    419479}
  • notifier-to-slack/trunk/inc/AdminDashboard.php

    r3434442 r3438021  
    234234        $pro_version = $this->get_pro_plugin_version();
    235235        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();
    236243            return;
    237244        }
     
    256263                echo '</p></div>';
    257264            });
     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' );
    258285        }
    259286    }
     
    334361                nonce: '<?php echo wp_create_nonce( 'wpnts_dismiss_notice' ); ?>'
    335362            }, 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
    336373                jQuery('#wpnts-pro-upgrade-notice').fadeOut();
    337374            });
     
    355392     */
    356393    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;
    360405        }
    361406
     
    363408        update_option( 'wpnts_pro_upgrade_notice_dismissed', true );
    364409       
    365         wp_send_json_success();
     410        wp_send_json_success( array( 'message' => 'Notice dismissed successfully' ) );
    366411    }
    367412
     
    384429            // Deactivate the Pro plugin immediately
    385430            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 );
    386435           
    387436            // Show error message
     
    396445                array( 'back_link' => true )
    397446            );
     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();
    398450        }
    399451    }
     
    405457     */
    406458    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;
    410470        }
    411471
     
    415475        delete_option( 'wpnts_pro_old_version' );
    416476       
    417         wp_send_json_success( 'Pro upgrade notice reset successfully' );
     477        wp_send_json_success( array( 'message' => 'Pro upgrade notice reset successfully' ) );
    418478    }
    419479}
Note: See TracChangeset for help on using the changeset viewer.