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
44 changes: 24 additions & 20 deletions includes/Framework/Plugin.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
// phpcs:ignoreFile
/**
* Facebook for WooCommerce.
*/
Expand All @@ -10,7 +9,7 @@
use WooCommerce\Facebook\Framework\Plugin\Compatibility;
use WooCommerce\Facebook\Framework\Plugin\Dependencies;

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

/**
* # WooCommerce Plugin Framework
Expand Down Expand Up @@ -81,7 +80,7 @@ abstract class Plugin {
*
* @param string $id plugin id
* @param string $version plugin version number
* @param array $args {
* @param array $args {
* optional plugin arguments
*
* @type int|float $latest_wc_versions the last supported versions of WooCommerce, as a major.minor float relative to the latest available version
Expand All @@ -100,11 +99,14 @@ public function __construct( $id, $version, $args = [] ) {
$this->id = $id;
$this->version = $version;

$args = wp_parse_args( $args, [
'min_wc_semver' => 0.2, // by default, 2 minor versions behind the latest published are supported
'text_domain' => '',
'dependencies' => [],
] );
$args = wp_parse_args(
$args,
[
'min_wc_semver' => 0.2, // by default, 2 minor versions behind the latest published are supported
'text_domain' => '',
'dependencies' => [],
]
);

$this->min_wc_semver = is_numeric( $args['min_wc_semver'] ) ? abs( $args['min_wc_semver'] ) : null;
$this->text_domain = $args['text_domain'];
Expand Down Expand Up @@ -195,7 +197,7 @@ protected function init_lifecycle_handler() {
protected function init_batch_log_handler() {
$this->batch_log_handler = new BatchLogHandler();
}

/**
* Builds the error log handler instance.
*
Expand Down Expand Up @@ -338,14 +340,15 @@ public function add_admin_notices() {
}

// grab latest published version
$supported_wc_version = $latest_wc_version = current( $latest_wc_versions );
$latest_wc_version = current( $latest_wc_versions );
$supported_wc_version = $latest_wc_version;

// grab semver parts
$latest_semver = explode( '.', $latest_wc_version );
$supported_semver = explode( '.', (string) $this->min_wc_semver );
$supported_major = max( 0, (int) $latest_semver[0] - (int) $supported_semver[0] );
$supported_minor = isset( $supported_semver[1] ) ? (int) $supported_semver[1] : 0;
$previous_minor = null;
$latest_semver = explode( '.', $latest_wc_version );
$supported_semver = explode( '.', (string) $this->min_wc_semver );
$supported_major = max( 0, (int) $latest_semver[0] - (int) $supported_semver[0] );
$supported_minor = isset( $supported_semver[1] ) ? (int) $supported_semver[1] : 0;
$previous_minor = null;

// loop known WooCommerce versions from the most recent until we get the oldest supported one
foreach ( $latest_wc_versions as $older_wc_version ) {
Expand Down Expand Up @@ -387,7 +390,8 @@ public function add_admin_notices() {
__( 'Heads up! %1$s will soon discontinue support for WooCommerce %2$s. Please %3$supdate WooCommerce%4$s to take advantage of the latest updates and features.', 'facebook-for-woocommerce' ),
$this->get_plugin_name(),
$current_wc_version,
'<a href="' . esc_url( admin_url( 'update-core.php' ) ) .'">', '</a>'
'<a href="' . esc_url( admin_url( 'update-core.php' ) ) . '">',
'</a>'
),
$this->get_id_dasherized() . '-deprecated-wc-version-as-of-' . str_replace( '.', '-', $supported_wc_version ),
[ 'notice_class' => 'notice-info' ]
Expand Down Expand Up @@ -450,8 +454,8 @@ public function add_api_request_logging() {
* Log API requests/responses
*
* @since 2.2.0
* @param array $request request data, see SV_WC_API_Base::broadcast_request() for format
* @param array $response response data
* @param array $request request data, see SV_WC_API_Base::broadcast_request() for format
* @param array $response response data
* @param string|null $log_id log to write data to
*/
public function log_api_request( $request, $response, $log_id = null ) {
Expand Down Expand Up @@ -569,7 +573,7 @@ public function get_plugin_file() {
/**
* The implementation for this abstract method should simply be:
*
* return __FILE__;
* Return __FILE__;
*
* @since 2.0.0
* @return string the full path and filename of the plugin file
Expand Down Expand Up @@ -777,7 +781,7 @@ public function get_reviews_url() {
/**
* Gets the plugin's path without a trailing slash.
*
* e.g. /path/to/wp-content/plugins/plugin-directory
* E.g. /path/to/wp-content/plugins/plugin-directory
*
* @since 2.0.0
*
Expand Down