Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 49 additions & 35 deletions includes/Framework/Plugin/Dependencies.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
// phpcs:ignoreFile
/**
* Facebook for WooCommerce.
*/
Expand All @@ -8,7 +7,7 @@

use WooCommerce\Facebook\Framework\Plugin;

defined( 'ABSPATH' ) or exit;
defined( 'ABSPATH' ) || exit;

/**
* Plugin dependencies handler.
Expand All @@ -34,7 +33,7 @@ class Dependencies {
* @since 5.2.0
*
* @param Plugin $plugin plugin instance
* @param array $args {
* @param array $args {
* PHP extension, function, and settings dependencies
*
* @type array $php_extensions PHP extension dependencies
Expand Down Expand Up @@ -62,11 +61,14 @@ public function __construct( Plugin $plugin, $args = array() ) {
* @return array
*/
private function parse_dependencies( $args ) {
$dependencies = wp_parse_args( $args, array(
'php_extensions' => array(),
'php_functions' => array(),
'php_settings' => array(),
) );
$dependencies = wp_parse_args(
$args,
array(
'php_extensions' => array(),
'php_functions' => array(),
'php_settings' => array(),
)
);
$default_settings = array(
'suhosin.post.max_array_index_length' => 256,
'suhosin.post.max_totalname_length' => 65535,
Expand Down Expand Up @@ -166,21 +168,21 @@ public function add_php_settings_notices() {
if ( count( $bad_settings ) > 0 ) {
$message = sprintf(
/* translators: Placeholders: %s - plugin name */
__( '%s may behave unexpectedly because the following PHP configuration settings are required:' ),
__( '%s may behave unexpectedly because the following PHP configuration settings are required:', 'facebook-for-woocommerce' ),
'<strong>' . esc_html( $this->get_plugin()->get_plugin_name() ) . '</strong>'
);
$message .= '<ul>';
foreach ( $bad_settings as $setting => $values ) {
$setting_message = '<code>' . $setting . ' = ' . $values['expected'] . '</code>';
if ( ! empty( $values['type'] ) && 'min' === $values['type'] ) {
$setting_message = sprintf(
/* translators: Placeholders: %s - a PHP setting value */
__( '%s or higher', 'facebook-for-woocommerce' ),
$setting_message
);
}
$message .= '<li>' . $setting_message . '</li>';
foreach ( $bad_settings as $setting => $values ) {
$setting_message = '<code>' . $setting . ' = ' . $values['expected'] . '</code>';
if ( ! empty( $values['type'] ) && 'min' === $values['type'] ) {
$setting_message = sprintf(
/* translators: Placeholders: %s - a PHP setting value */
__( '%s or higher', 'facebook-for-woocommerce' ),
$setting_message
);
}
$message .= '<li>' . $setting_message . '</li>';
}
$message .= '</ul>';
$message .= __( 'Please contact your hosting provider or server administrator to configure these settings.', 'facebook-for-woocommerce' );
$this->add_admin_notice( 'wc-' . $this->get_plugin()->get_id_dasherized() . '-incompatibile-php-settings', $message, 'warning' );
Expand All @@ -200,13 +202,18 @@ protected function add_deprecated_notices() {
$message = '<p>';
$message .= sprintf(
/* translators: Placeholders: %1$s - <strong>, %2$s - </strong> */
__( 'Hey there! We\'ve noticed that your server is running %1$san outdated version of PHP%2$s, which is the programming language that WooCommerce and its extensions are built on.
__(
'Hey there! We\'ve noticed that your server is running %1$san outdated version of PHP%2$s, which is the programming language that WooCommerce and its extensions are built on.
The PHP version that is currently used for your site is no longer maintained, nor %1$sreceives security updates%2$s; newer versions are faster and more secure.
As a result, %3$s no longer supports this version and you should upgrade PHP as soon as possible.
Your hosting provider can do this for you. %4$sHere are some resources to help you upgrade%5$s and to explain PHP versions further.', 'facebook-for-woocommerce' ),
'<strong>', '</strong>',
Your hosting provider can do this for you. %4$sHere are some resources to help you upgrade%5$s and to explain PHP versions further.',
'facebook-for-woocommerce'
),
'<strong>',
'</strong>',
esc_html( $this->get_plugin()->get_plugin_name() ),
'<a href="http://skyver.ge/upgradephp">', '</a>'
'<a href="http://skyver.ge/upgradephp">',
'</a>'
);
$message .= '</p>';
$this->add_admin_notice( 'sv-wc-deprecated-php-version', $message, 'error' );
Expand All @@ -225,9 +232,13 @@ protected function add_deprecated_notices() {
*/
protected function add_admin_notice( $id, $message, $type = 'info' ) {
$notice_class = 'notice-' . $type;
$this->get_plugin()->get_admin_notice_handler()->add_admin_notice( $message, $id, array(
'notice_class' => $notice_class,
) );
$this->get_plugin()->get_admin_notice_handler()->add_admin_notice(
$message,
$id,
array(
'notice_class' => $notice_class,
)
);
}


Expand All @@ -248,15 +259,18 @@ public function get_active_scripts_optimization_plugins() {
*
* @param array $plugins an array of file identifiers (keys) and plugin names (values)
*/
$plugins = (array) apply_filters( 'wc_' . $this->get_plugin()->get_id() . '_scripts_optimization_plugins', [
'async-javascript.php' => 'Async JavaScript',
'autoptimize.php' => 'Autoptimize',
'wp-hummingbird.php' => 'Hummingbird',
'sg-optimizer.php' => 'SG Optimizer',
'w3-total-cache.php' => 'W3 Total Cache',
'wpFastestCache.php' => 'WP Fastest Cache',
'wp-rocket.php' => 'WP Rocket',
] );
$plugins = (array) apply_filters(
'wc_' . $this->get_plugin()->get_id() . '_scripts_optimization_plugins',
[
'async-javascript.php' => 'Async JavaScript',
'autoptimize.php' => 'Autoptimize',
'wp-hummingbird.php' => 'Hummingbird',
'sg-optimizer.php' => 'SG Optimizer',
'w3-total-cache.php' => 'W3 Total Cache',
'wpFastestCache.php' => 'WP Fastest Cache',
'wp-rocket.php' => 'WP Rocket',
]
);
$active_plugins = [];
foreach ( $plugins as $filename => $plugin_name ) {
if ( $this->get_plugin()->is_plugin_active( $filename ) ) {
Expand Down