Skip to content
Snippets Groups Projects
Commit b5d30c6a authored by Krzysiek's avatar Krzysiek
Browse files

Break down for prepare_requirement_notices method

parent 5ba9d1d5
Branches
Tags
1 merge request!1Devel 1.10 - Wymagana wersja PHP i Wordpress
...@@ -187,13 +187,19 @@ if ( ! class_exists( 'WPDesk_Requirement_Checker_1_10' ) ) { ...@@ -187,13 +187,19 @@ if ( ! class_exists( 'WPDesk_Requirement_Checker_1_10' ) ) {
if ( ! is_null( $this->min_wc_version ) && ! $this->is_wc_at_least( $this->min_wc_version ) ) { if ( ! is_null( $this->min_wc_version ) && ! $this->is_wc_at_least( $this->min_wc_version ) ) {
$notices[] = $this->prepare_notice_message( sprintf( __( 'The “%s” plugin cannot run on WooCommerce versions older than %s. Please update WooCommerce.' ), esc_html( $this->plugin_name ), $this->min_wc_version ) ); $notices[] = $this->prepare_notice_message( sprintf( __( 'The “%s” plugin cannot run on WooCommerce versions older than %s. Please update WooCommerce.' ), esc_html( $this->plugin_name ), $this->min_wc_version ) );
} }
if ( count( $this->plugin_require ) > 0 ) { $notices = $this->append_plugin_require_notices( $notices );
foreach ( $this->plugin_require as $plugin_name => $nice_plugin_name ) { $notices = $this->append_module_require_notices( $notices );
if ( ! $this->is_wp_plugin_active( $plugin_name ) ) { $notices = $this->append_settings_require_notices( $notices );
$notices[] = $this->prepare_notice_message( sprintf( __( 'The “%s” plugin cannot run without %s active. Please install and activate %s plugin.' ), esc_html( $this->plugin_name ), esc_html( basename( $nice_plugin_name ) ), esc_html( basename( $nice_plugin_name ) ) ) );
} return $notices;
}
} }
/**
* @param array $notices
*
* @return array
*/
private function append_module_require_notices( $notices ) {
if ( count( $this->module_require ) > 0 ) { if ( count( $this->module_require ) > 0 ) {
foreach ( $this->module_require as $module_name => $nice_module_name ) { foreach ( $this->module_require as $module_name => $nice_module_name ) {
if ( ! $this->is_module_active( $module_name ) ) { if ( ! $this->is_module_active( $module_name ) ) {
...@@ -201,6 +207,16 @@ if ( ! class_exists( 'WPDesk_Requirement_Checker_1_10' ) ) { ...@@ -201,6 +207,16 @@ if ( ! class_exists( 'WPDesk_Requirement_Checker_1_10' ) ) {
} }
} }
} }
return $notices;
}
/**
* @param array $notices
*
* @return array
*/
private function append_settings_require_notices( $notices ) {
if ( count( $this->setting_require ) > 0 ) { if ( count( $this->setting_require ) > 0 ) {
foreach ( $this->setting_require as $setting => $value ) { foreach ( $this->setting_require as $setting => $value ) {
if ( ! $this->is_setting_set( $setting, $value ) ) { if ( ! $this->is_setting_set( $setting, $value ) ) {
...@@ -212,6 +228,23 @@ if ( ! class_exists( 'WPDesk_Requirement_Checker_1_10' ) ) { ...@@ -212,6 +228,23 @@ if ( ! class_exists( 'WPDesk_Requirement_Checker_1_10' ) ) {
return $notices; return $notices;
} }
/**
* @param array $notices
*
* @return array
*/
private function append_plugin_require_notices( $notices ) {
if ( count( $this->plugin_require ) > 0 ) {
foreach ( $this->plugin_require as $plugin_name => $nice_plugin_name ) {
if ( ! $this->is_wp_plugin_active( $plugin_name ) ) {
$notices[] = $this->prepare_notice_message( sprintf( __( 'The “%s” plugin cannot run without %s active. Please install and activate %s plugin.' ), esc_html( $this->plugin_name ), esc_html( basename( $nice_plugin_name ) ), esc_html( basename( $nice_plugin_name ) ) ) );
}
}
}
return $notices;
}
/** /**
* @param string $name * @param string $name
* @param mixed $value * @param mixed $value
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment