major_untested_plugins ) ? array_diff_key( $this->minor_untested_plugins, $this->major_untested_plugins ) : $this->minor_untested_plugins; $version_parts = explode( '.', $this->new_version ); $new_version = $version_parts[0] . '.' . $version_parts[1]; if ( empty( $plugins ) ) { return; } /* translators: %s: version number */ $message = sprintf( __( 'The installed versions of the following plugin(s) are not tested with WooCommerce %s. If possible, update these plugins before updating WooCommerce:', 'woocommerce' ), $new_version ); ob_start(); include( 'views/html-notice-untested-extensions-inline.php' ); return ob_get_clean(); } /** * Get the inline warning notice for major version updates. * * @return string */ protected function get_extensions_inline_warning_major() { $upgrade_type = 'major'; $plugins = $this->major_untested_plugins; $version_parts = explode( '.', $this->new_version ); $new_version = $version_parts[0] . '.0'; if ( empty( $plugins ) ) { return; } /* translators: %s: version number */ $message = sprintf( __( 'Heads up! The installed versions of the following plugin(s) are not tested with WooCommerce %s and may not be fully-compatible. Please update these extensions or confirm they are compatible first, or you may experience issues:', 'woocommerce' ), $new_version ); ob_start(); include( 'views/html-notice-untested-extensions-inline.php' ); return ob_get_clean(); } /** * Get the warning notice for the modal window. * * @return string */ protected function get_extensions_modal_warning() { $version_parts = explode( '.', $this->new_version ); $new_version = $version_parts[0] . '.0'; $plugins = $this->major_untested_plugins; ob_start(); include( 'views/html-notice-untested-extensions-modal.php' ); return ob_get_clean(); } /* |-------------------------------------------------------------------------- | Data Helpers |-------------------------------------------------------------------------- | | Methods for getting & manipulating data. */ /** * Get active plugins that have a tested version lower than the input version. * * @param string $version * @param string $release 'major' or 'minor'. * @return array of plugin info arrays */ public function get_untested_plugins( $version, $release ) { $extensions = $this->get_plugins_with_header( self::VERSION_TESTED_HEADER ); $untested = array(); $version_parts = explode( '.', $version ); $version = $version_parts[0]; if ( 'minor' === $release ) { $version .= '.' . $version_parts[1]; } foreach ( $extensions as $file => $plugin ) { $plugin_version_parts = explode( '.', $plugin[ self::VERSION_TESTED_HEADER ] ); if ( ! is_numeric( $plugin_version_parts[0] ) || ( 'minor' === $release && ! isset( $plugin_version_parts[1] ) ) || ( 'minor' === $release && ! is_numeric( $plugin_version_parts[1] ) ) ) { continue; } $plugin_version = $plugin_version_parts[0]; if ( 'minor' === $release ) { $plugin_version .= '.' . $plugin_version_parts[1]; } if ( version_compare( $plugin_version, $version, '<' ) && is_plugin_active( $file ) ) { $untested[ $file ] = $plugin; } } return $untested; } /** * Get plugins that have a valid value for a specific header. * * @param string $header * @return array of plugin info arrays */ protected function get_plugins_with_header( $header ) { $plugins = get_plugins(); $matches = array(); foreach ( $plugins as $file => $plugin ) { if ( ! empty( $plugin[ $header ] ) ) { $matches[ $file ] = $plugin; } } return apply_filters( 'woocommerce_get_plugins_with_header', $matches, $header, $plugins ); } }