php_ver = $php_ver; $this->wp_ver = $wp_ver; $this->name = $name; $this->plugins = $plugins; } /** * Checking the compatibility of the plugin with the version of PHP * In case of incompatibility still fully loaded plugin (return) * * @return boolean Check PHP compatibility */ public function is_compatible_php() { if ( version_compare( phpversion(), $this->php_ver, '<' ) ) { return false; } return true; } /** * Checking the compatibility of the plugin with the version of Wordpress * In case of incompatibility still fully loaded plugin (return) * * @return boolean Check WordPress compatibility */ public function is_compatible_wordpress() { if ( version_compare( $GLOBALS['wp_version'], $this->wp_ver, '<' ) ) { return false; } return true; } /** * Check if the required plugin is active * * @return bool Return true if plugin is active */ public function are_required_plugins_active() { if ( empty( $this->plugins ) ) { return true; } $result = true; $_active_plugins = wp_get_active_and_valid_plugins(); $active_plugins = array_filter( array_map( array( $this, 'get_plugin_name' ), $_active_plugins ) ); foreach ( $this->plugins as $plugin ) { if ( ! in_array( $plugin, $active_plugins, true ) ) { $result = false; $this->not_found[] = $plugin; } } return $result; } /** * Checking compatibility with installed versions of the plugin * In case of incompatibility still fully loaded plugin (return) * * @return boolean Check if plugin is compatible */ public function is_compatible_version() { if ( $this->is_compatible_php() && $this->is_compatible_wordpress() && $this->are_required_plugins_active() ) { return true; } return false; } /** * Get the admin notice PHP * * @param bolean $wrap Is wrappable or not. * * @return string Return the admin notice for PHP */ public function get_admin_notices_php( $wrap ) { return $this->get_admin_notices_text( $wrap, 'PHP', phpversion(), $this->php_ver ); } /** * Get the admin notice WordPress * * @param bolean $wrap Is wrappable or not. * * @return string Return the admin notice for WordPress */ public function get_admin_notices_wordpress( $wrap ) { return $this->get_admin_notices_text( $wrap, 'WordPress', $GLOBALS['wp_version'], $this->wp_ver ); } /** * Get the admin notice for required plugin if is not activated * * @param bolean $wrap Is wrappable or not. * * @return string Return the admin notice */ public function get_admin_notices_required_plugins( $wrap ) { $html = __( 'requires %s plugins to work', 'minimum_requirements' ); if ( false === $wrap ) { $html = '
' . $this->name . ' - ' . $html . '
' . $this->name . ' - ' . $html . '