From b45b4fc140da1d30daaf3b1702babb4fa5170dc9 Mon Sep 17 00:00:00 2001 From: nikitasinelnikov Date: Wed, 30 Sep 2020 12:03:06 +0300 Subject: [PATCH] - fixed admin menu PHP notice; --- includes/admin/core/class-admin-menu.php | 6 ++-- includes/core/class-plugin-updater.php | 37 ++++++++++++++++++++++++ readme.txt | 1 + ultimate-member.php | 2 +- 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/includes/admin/core/class-admin-menu.php b/includes/admin/core/class-admin-menu.php index 302a9adb..ad3366f9 100644 --- a/includes/admin/core/class-admin-menu.php +++ b/includes/admin/core/class-admin-menu.php @@ -125,15 +125,15 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) { if ( is_array( $menu ) ) { foreach ( $menu as $key => $menu_item ) { if ( 0 === strpos( $menu_item[0], _x( 'Users', 'Admin menu name' ) ) ) { - $menu[ $key ][0] .= ' '.$count.''; + $menu[ $key ][0] .= ' ' . $count . ''; } } } - if ( is_array( $submenu ) ) { + if ( is_array( $submenu ) && isset( $submenu['users.php'] ) ) { foreach ( $submenu['users.php'] as $key => $menu_item ) { if ( 0 === strpos( $menu_item[0], _x( 'All Users', 'Admin menu name' ) ) ) { - $submenu['users.php'][ $key ][0] .= ' '.$count.''; + $submenu['users.php'][ $key ][0] .= ' ' . $count . ''; } } } diff --git a/includes/core/class-plugin-updater.php b/includes/core/class-plugin-updater.php index 51bfd9f1..99089867 100644 --- a/includes/core/class-plugin-updater.php +++ b/includes/core/class-plugin-updater.php @@ -37,6 +37,30 @@ if ( ! class_exists( 'um\core\Plugin_Updater' ) ) { //plugin information info add_filter( 'plugins_api', array( &$this, 'plugin_information' ), 9999, 3 ); + + // make this only for version which have the update packages + //add_filter( 'auto_update_plugin', array( &$this, 'prevent_dangerous_auto_updates' ), 99, 2 ); + } + + + /** + * Prevent auto-updating the WooCommerce plugin on major releases if there are untested extensions active. + * + * @since 3.2.0 + * @param bool $should_update If should update. + * @param object $plugin Plugin data. + * @return bool + */ + function prevent_dangerous_auto_updates( $should_update, $plugin ) { + if ( ! isset( $plugin->plugin, $plugin->new_version ) ) { + return $should_update; + } + + if ( 'ultimate-member/ultimate-member.php' !== $plugin->plugin ) { + return $should_update; + } + + return $should_update; } @@ -367,6 +391,10 @@ if ( ! class_exists( 'um\core\Plugin_Updater' ) ) { continue; } + /*if ( ! empty( $_transient_data->no_update ) && ! empty( $_transient_data->no_update[ $slug ] ) && $_transient_data->last_checked > time() - DAY_IN_SECONDS ) { + continue; + }*/ + $path = wp_normalize_path( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $slug ); if ( ! file_exists( $path ) ) { continue; @@ -390,11 +418,20 @@ if ( ! class_exists( 'um\core\Plugin_Updater' ) ) { if ( version_compare( $plugin_data['Version'], $version_info->new_version, '<' ) ) { $_transient_data->response[ $slug ] = $version_info; $_transient_data->response[ $slug ]->plugin = $slug; + } else { + $_transient_data->no_update[ $slug ] = $version_info; + $_transient_data->no_update[ $slug ]->plugin = $slug; } $_transient_data->last_checked = time(); $_transient_data->checked[ $slug ] = $plugin_data['Version']; + } elseif ( false !== $version_info && is_object( $version_info ) && ! isset( $version_info->new_version ) ) { + $_transient_data->no_update[ $slug ] = $version_info; + $_transient_data->no_update[ $slug ]->plugin = $slug; + + $_transient_data->last_checked = time(); + $_transient_data->checked[ $slug ] = $plugin_data['Version']; } } diff --git a/readme.txt b/readme.txt index c79e8d6a..88feebd9 100644 --- a/readme.txt +++ b/readme.txt @@ -162,6 +162,7 @@ The plugin works with popular caching plugins by automatically excluding Ultimat - Fixed can_view_profile function - Fixed security patch for role change via profile form + - Fixed admin-menu PHP notice = 2.1.10: September 23, 2020 = diff --git a/ultimate-member.php b/ultimate-member.php index 5540be2e..54d254b6 100644 --- a/ultimate-member.php +++ b/ultimate-member.php @@ -3,7 +3,7 @@ Plugin Name: Ultimate Member Plugin URI: http://ultimatemember.com/ Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress -Version: 2.1.11-rc.1 +Version: 2.1.11-rc.2 Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member