*/ class Latest_Updates extends Notice { public $type = 'notice'; public $color = 'info'; /** * Check if we're on the WP Adminify settings page * * @return bool */ private function is_adminify_settings_page() { global $pagenow; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check, no state change. return is_admin() && $pagenow === 'admin.php' && isset( $_GET['page'] ) && $_GET['page'] === 'wp-adminify-settings'; } /** * Latest Updates Notice * * @return void */ public function __construct() { parent::__construct(); if(is_admin()){ // TODO: Need to check about conflicts with other plugins // add_action( 'admin_footer', array( $this, 'pxlbsadminify_handle_plugin_update_notice_dismiss' ),99999 ); add_action( 'wp_ajax_pxlbsadminify_plugin_update_info', array( $this, 'pxlbsadminify_plugin_update_info' ) ); } } /** * Handles the AJAX request for the plugin update info notice dismissal. * * Triggered when the user clicks the Dismiss button in the notice. * * @since 1.0 * * @return void */ public function pxlbsadminify_plugin_update_info() { if (!current_user_can('install_plugins')) { return; } // Verify nonce for security. check_ajax_referer( 'dismiss_notice_nonce', 'nonce' ); $action_type = isset( $_POST['action_type'] ) ? sanitize_text_field( wp_unslash( $_POST['action_type'] ) ) : 'dismiss'; $option_value = ( 'forever' === $action_type ) ? 'forever' : 'dismissed'; wp_send_json_success( array( 'message' => 'Notice dismissed.', 'data' => update_option('pxlbsadminify_plugin_update_info_notice', $option_value ) ) ); } /** * Notice Content * * @author Jewel Theme */ public function notice_content() { if ( ! $this->is_adminify_settings_page() ) { return; } $forever_notice = get_option('pxlbsadminify_plugin_update_info_notice', true ); if( 'forever' === $forever_notice ){ return; } if("dismissed" !== $forever_notice){ $pxlbsadminify_changelog_items = __(' Security: Security Update.
', 'adminify'); $pxlbsadminify_changelog_message = sprintf( /* translators: %1$s: changelogs page URL. %2$s: link anchor text. %3$s: plugin update heading HTML. %4$s: changelog list items HTML. */ __('%3$s %4$s
Check Changelogs for %2$s', 'adminify'), esc_url_raw('https://wpadminify.com/changelogs'), __('More about Updates ', 'adminify'), /** Changelog Items * Starts from: %3$s */ '

' . PXLBSADMINIFY . ' v' . esc_html(PXLBSADMINIFY_VER) . '' . __(' has some updates..', 'adminify') . '


', // %3$s // changelogs $pxlbsadminify_changelog_items ); printf(wp_kses_post($pxlbsadminify_changelog_message)); } $this->pxlbsadminify_handle_plugin_update_notice_dismiss(); } /** * Notice Header * * @author Jewel Theme */ public function notice_header() { if ( ! $this->is_adminify_settings_page() ) { echo '