From 4cacab889259a66a59cd78a2507fce1d72a54152 Mon Sep 17 00:00:00 2001 From: Md Obidullah Date: Tue, 12 Mar 2024 16:06:02 +0600 Subject: [PATCH] PHP 8.2 and nonce validation issue fix (#1713) * add changelog * build files * Fixed capability issue * Fixed php undefined array key issue * Updated version and changelog * Removed duplicate log --------- Co-authored-by: vairafiq --- config.php | 2 +- directorist-base.php | 6 +++--- includes/classes/class-upgrade.php | 33 +++++++++++++++++------------ includes/model/ListingDashboard.php | 2 +- readme.txt | 11 +++++++--- 5 files changed, 33 insertions(+), 21 deletions(-) diff --git a/config.php b/config.php index 06c0797c45..b4b1a2883c 100644 --- a/config.php +++ b/config.php @@ -1,6 +1,6 @@ load_template( 'admin-templates/admin-promo-banner' ); } } - public function bfcm_notice() { - if ( !current_user_can( 'manage_options' ) ) { - return; - } + protected static function can_manage_plugins() { + return ( current_user_can( 'install_plugins' ) || current_user_can( 'manage_options' ) ); + } - if( self::is_pro_user() ) { + public function bfcm_notice() { + if ( ! self::can_manage_plugins() || self::is_pro_user() ) { return; } @@ -118,13 +118,18 @@ public static function promo_remote_get() { return $response_body; } - public function upgrade_notice() - { - if (!current_user_can('administrator')) return; + public function upgrade_notice() { + if ( ! self::can_manage_plugins() ) { + return; + } - if( '7.0' !== ATBDP_VERSION ) return; + if ( '7.0' !== ATBDP_VERSION ) { + return; + } - if ( get_user_meta( get_current_user_id(), $this->upgrade_notice_id, true ) || ! empty( $this->directorist_migration[ $this->upgrade_notice_id ] ) ) return; + if ( get_user_meta( get_current_user_id(), $this->upgrade_notice_id, true ) || ! empty( $this->directorist_migration[ $this->upgrade_notice_id ] ) ) { + return; + } $text = ''; @@ -143,7 +148,10 @@ public function upgrade_notice() } - public function configure_notices(){ + public function configure_notices() { + if ( ! self::can_manage_plugins() ) { + return; + } $this->directorist_notices = get_option( 'directorist_notices' ); @@ -157,7 +165,6 @@ public function configure_notices(){ if ( isset( $_GET['directorist-depricated-notice'] ) ) { $this->directorist_notices[ $this->legacy_notice_id ] = 1; update_option( 'directorist_notices', $this->directorist_notices ); - } if ( isset( $_GET['close-directorist-promo-version'], $_GET['directorist_promo_nonce'] ) && wp_verify_nonce( $_GET['directorist_promo_nonce'], 'close-directorist-promo-version' ) ) { diff --git a/includes/model/ListingDashboard.php b/includes/model/ListingDashboard.php index 78e376dbd0..e4f529dab8 100644 --- a/includes/model/ListingDashboard.php +++ b/includes/model/ListingDashboard.php @@ -188,7 +188,7 @@ public function get_listing_thumbnail() { $listing_prv_img = get_post_meta($id, '_listing_prv_img', true); $listing_img = get_post_meta($id, '_listing_img', true); - if ( is_array( $listing_img ) && ! empty( $listing_img ) ) { + if ( is_array( $listing_img ) && ! empty( $listing_img[0] ) ) { $thumbnail_img = atbdp_get_image_source( $listing_img[0], $image_quality ); $thumbnail_id = $listing_img[0]; } diff --git a/readme.txt b/readme.txt index 3b40da493d..34be34342a 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: member directory, listing, classifieds, directory plugin, business directo Requires at least: 4.6 Tested up to: 6.4 Requires PHP: 7.0 -Stable tag: 7.8.5 +Stable tag: 7.8.6 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html @@ -410,6 +410,11 @@ Directorist is a complete directory solution and in combination with its advance == Changelog == +7.8.6 - Mar 12, 2024 + +* Fix - Undefined array index issue +* Fix - Promo banner nonce validation issue + 7.8.5 - Feb 12, 2024 * Fix - Setup wizard user permission issue (#1702) @@ -515,10 +520,10 @@ Directorist is a complete directory solution and in combination with its advance * Fix - Column Issue in All Categories & Locations Page * Fix - Publish Date Issue when Importing Listings * Fix - Typo Issue in Users REST API -* Fix - Image Size Issue in Single Listing Slider +* Fix - Image Size Issue in Single Listing Slider * Fix - Listing Count Issue in All Categories & Locations Page * Fix - PHP 8 Deprecated Notices -* Fix - inlineEditPost JS Console Error +* Fix - inlineEditPost JS Console Error 7.5.5 - Jun 01, 2023