@@ -3,108 +3,108 @@ |
||
3 | 3 | namespace Wordlift\Features; |
4 | 4 | |
5 | 5 | class Response_Adapter { |
6 | - const WL_FEATURES = '_wl_features'; |
|
7 | - const WL_1 = 'wl1'; |
|
8 | - |
|
9 | - public function __construct() { |
|
10 | - |
|
11 | - // Filter responses from the API calls to update the enabled features. |
|
12 | - add_filter( 'wl_api_service__response', array( $this, 'response' ), 10, 1 ); |
|
13 | - |
|
14 | - // Initialize from `$_ENV`: this is currently required for Unit Tests, since `tests/bootstrap.php` loads WordLift |
|
15 | - // before it can actually query the enabled features via HTTP (mock), which would prevent files from being included. |
|
16 | - // $this->init_from_env(); |
|
17 | - |
|
18 | - // Register the `wl_features__enable__{feature-name}` filters. |
|
19 | - $this->register_filters(); |
|
20 | - |
|
21 | - // Hook to the updates to the features setting to refresh the features' filters. |
|
22 | - add_action( 'update_option_' . self::WL_FEATURES, array( $this, 'register_filters' ), 10, 0 ); |
|
23 | - |
|
24 | - } |
|
25 | - |
|
26 | - public function response( $response ) { |
|
27 | - |
|
28 | - $headers = wp_remote_retrieve_headers( $response ); |
|
29 | - |
|
30 | - // Bail out if the `wl1` header isn't defined. |
|
31 | - if ( ! isset( $headers[ self::WL_1 ] ) ) { |
|
32 | - return $response; |
|
33 | - } |
|
34 | - $wl1_as_base64_string = $headers[ self::WL_1 ]; |
|
35 | - // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode |
|
36 | - $wl1 = json_decode( base64_decode( $wl1_as_base64_string ), true ); |
|
37 | - |
|
38 | - $updated_features = $wl1['features']; |
|
39 | - |
|
40 | - $existing_features = get_option( self::WL_FEATURES, array() ); |
|
41 | - |
|
42 | - // Loop through updated features. |
|
43 | - foreach ( $updated_features as $feature_slug => $new_value ) { |
|
44 | - |
|
45 | - // We cant pass false because that indicates if the feature is active or not, null is used to represent the features which are |
|
46 | - // not set before. |
|
47 | - $old_value = array_key_exists( $feature_slug, $existing_features ) ? $existing_features[ $feature_slug ] : null; |
|
48 | - |
|
49 | - if ( $old_value !== $new_value ) { |
|
50 | - /** |
|
51 | - * @param $feature_slug string The feature slug. |
|
52 | - * @param $old_value null | boolean Null represents the feature flag was not set before. |
|
53 | - * @param $new_value boolean True or false. |
|
54 | - * |
|
55 | - * @since 3.32.1 |
|
56 | - * Hook : `wl_feature__change__{feature_slug}` |
|
57 | - * Action hook to be fired when there is a change in feature state. |
|
58 | - */ |
|
59 | - do_action( "wl_feature__change__$feature_slug", $new_value, $old_value, $feature_slug ); |
|
60 | - } |
|
61 | - } |
|
62 | - |
|
63 | - if ( isset( $updated_features ) ) { |
|
64 | - |
|
65 | - if ( update_option( self::WL_FEATURES, (array) $updated_features, true ) ) { |
|
66 | - $this->register_filters(); |
|
67 | - } |
|
68 | - } |
|
69 | - |
|
70 | - return $response; |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * Registers the feature filters. |
|
75 | - */ |
|
76 | - public function register_filters() { |
|
77 | - |
|
78 | - foreach ( (array) get_option( self::WL_FEATURES, array() ) as $name => $enabled ) { |
|
79 | - // Remove previous filters. |
|
80 | - remove_filter( "wl_feature__enable__${name}", '__return_true' ); |
|
81 | - remove_filter( "wl_feature__enable__${name}", '__return_false' ); |
|
82 | - |
|
83 | - $callback = ( $enabled ? '__return_true' : '__return_false' ); |
|
84 | - add_filter( "wl_feature__enable__${name}", $callback ); |
|
85 | - } |
|
86 | - |
|
87 | - } |
|
88 | - |
|
89 | - private function init_from_env() { |
|
90 | - $features = array_reduce( |
|
91 | - array_filter( |
|
92 | - array_keys( $_ENV ), |
|
93 | - function ( $key ) { |
|
94 | - return preg_match( '~^WL_FEATURES__.*~', $key ); |
|
95 | - } |
|
96 | - ), |
|
97 | - function ( $features, $env ) { |
|
98 | - $name = strtolower( str_replace( '_', '-', substr( $env, strlen( 'WL_FEATURES__' ) ) ) ); |
|
99 | - $value = wp_validate_boolean( getenv( $env ) ); |
|
100 | - $features[ $name ] = $value; |
|
101 | - |
|
102 | - return $features; |
|
103 | - }, |
|
104 | - array() |
|
105 | - ); |
|
106 | - |
|
107 | - update_option( self::WL_FEATURES, (array) $features, true ); |
|
108 | - } |
|
6 | + const WL_FEATURES = '_wl_features'; |
|
7 | + const WL_1 = 'wl1'; |
|
8 | + |
|
9 | + public function __construct() { |
|
10 | + |
|
11 | + // Filter responses from the API calls to update the enabled features. |
|
12 | + add_filter( 'wl_api_service__response', array( $this, 'response' ), 10, 1 ); |
|
13 | + |
|
14 | + // Initialize from `$_ENV`: this is currently required for Unit Tests, since `tests/bootstrap.php` loads WordLift |
|
15 | + // before it can actually query the enabled features via HTTP (mock), which would prevent files from being included. |
|
16 | + // $this->init_from_env(); |
|
17 | + |
|
18 | + // Register the `wl_features__enable__{feature-name}` filters. |
|
19 | + $this->register_filters(); |
|
20 | + |
|
21 | + // Hook to the updates to the features setting to refresh the features' filters. |
|
22 | + add_action( 'update_option_' . self::WL_FEATURES, array( $this, 'register_filters' ), 10, 0 ); |
|
23 | + |
|
24 | + } |
|
25 | + |
|
26 | + public function response( $response ) { |
|
27 | + |
|
28 | + $headers = wp_remote_retrieve_headers( $response ); |
|
29 | + |
|
30 | + // Bail out if the `wl1` header isn't defined. |
|
31 | + if ( ! isset( $headers[ self::WL_1 ] ) ) { |
|
32 | + return $response; |
|
33 | + } |
|
34 | + $wl1_as_base64_string = $headers[ self::WL_1 ]; |
|
35 | + // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode |
|
36 | + $wl1 = json_decode( base64_decode( $wl1_as_base64_string ), true ); |
|
37 | + |
|
38 | + $updated_features = $wl1['features']; |
|
39 | + |
|
40 | + $existing_features = get_option( self::WL_FEATURES, array() ); |
|
41 | + |
|
42 | + // Loop through updated features. |
|
43 | + foreach ( $updated_features as $feature_slug => $new_value ) { |
|
44 | + |
|
45 | + // We cant pass false because that indicates if the feature is active or not, null is used to represent the features which are |
|
46 | + // not set before. |
|
47 | + $old_value = array_key_exists( $feature_slug, $existing_features ) ? $existing_features[ $feature_slug ] : null; |
|
48 | + |
|
49 | + if ( $old_value !== $new_value ) { |
|
50 | + /** |
|
51 | + * @param $feature_slug string The feature slug. |
|
52 | + * @param $old_value null | boolean Null represents the feature flag was not set before. |
|
53 | + * @param $new_value boolean True or false. |
|
54 | + * |
|
55 | + * @since 3.32.1 |
|
56 | + * Hook : `wl_feature__change__{feature_slug}` |
|
57 | + * Action hook to be fired when there is a change in feature state. |
|
58 | + */ |
|
59 | + do_action( "wl_feature__change__$feature_slug", $new_value, $old_value, $feature_slug ); |
|
60 | + } |
|
61 | + } |
|
62 | + |
|
63 | + if ( isset( $updated_features ) ) { |
|
64 | + |
|
65 | + if ( update_option( self::WL_FEATURES, (array) $updated_features, true ) ) { |
|
66 | + $this->register_filters(); |
|
67 | + } |
|
68 | + } |
|
69 | + |
|
70 | + return $response; |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Registers the feature filters. |
|
75 | + */ |
|
76 | + public function register_filters() { |
|
77 | + |
|
78 | + foreach ( (array) get_option( self::WL_FEATURES, array() ) as $name => $enabled ) { |
|
79 | + // Remove previous filters. |
|
80 | + remove_filter( "wl_feature__enable__${name}", '__return_true' ); |
|
81 | + remove_filter( "wl_feature__enable__${name}", '__return_false' ); |
|
82 | + |
|
83 | + $callback = ( $enabled ? '__return_true' : '__return_false' ); |
|
84 | + add_filter( "wl_feature__enable__${name}", $callback ); |
|
85 | + } |
|
86 | + |
|
87 | + } |
|
88 | + |
|
89 | + private function init_from_env() { |
|
90 | + $features = array_reduce( |
|
91 | + array_filter( |
|
92 | + array_keys( $_ENV ), |
|
93 | + function ( $key ) { |
|
94 | + return preg_match( '~^WL_FEATURES__.*~', $key ); |
|
95 | + } |
|
96 | + ), |
|
97 | + function ( $features, $env ) { |
|
98 | + $name = strtolower( str_replace( '_', '-', substr( $env, strlen( 'WL_FEATURES__' ) ) ) ); |
|
99 | + $value = wp_validate_boolean( getenv( $env ) ); |
|
100 | + $features[ $name ] = $value; |
|
101 | + |
|
102 | + return $features; |
|
103 | + }, |
|
104 | + array() |
|
105 | + ); |
|
106 | + |
|
107 | + update_option( self::WL_FEATURES, (array) $features, true ); |
|
108 | + } |
|
109 | 109 | |
110 | 110 | } |
@@ -6,44 +6,44 @@ |
||
6 | 6 | |
7 | 7 | class Api_Headers_Service { |
8 | 8 | |
9 | - private static $instance = null; |
|
10 | - |
|
11 | - protected function __construct() { |
|
12 | - |
|
13 | - } |
|
14 | - |
|
15 | - /** |
|
16 | - * This function is used to append WordPress endpoint data to every request made. |
|
17 | - * |
|
18 | - * @return array |
|
19 | - */ |
|
20 | - public function get_wp_headers() { |
|
21 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
22 | - $is_plugin_subscription = apply_filters( 'wl_feature__enable__entity-types-professional', false ) || |
|
23 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
24 | - apply_filters( 'wl_feature__enable__entity-types-business', false ) || |
|
25 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
26 | - apply_filters( 'wl_feature__enable__entity-types-starter', false ); |
|
27 | - |
|
28 | - try { |
|
29 | - return $is_plugin_subscription ? array( |
|
30 | - 'X-Wordlift-Plugin-Wp-Admin' => untrailingslashit( get_admin_url() ), |
|
31 | - 'X-Wordlift-Plugin-Wp-Json' => untrailingslashit( get_rest_url() ), |
|
32 | - ) : array(); |
|
33 | - } catch ( Exception $e ) { |
|
34 | - return array(); |
|
35 | - } |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * @return Api_Headers_Service |
|
40 | - */ |
|
41 | - public static function get_instance() { |
|
42 | - if ( null === self::$instance ) { |
|
43 | - self::$instance = new Api_Headers_Service(); |
|
44 | - } |
|
45 | - |
|
46 | - return self::$instance; |
|
47 | - } |
|
9 | + private static $instance = null; |
|
10 | + |
|
11 | + protected function __construct() { |
|
12 | + |
|
13 | + } |
|
14 | + |
|
15 | + /** |
|
16 | + * This function is used to append WordPress endpoint data to every request made. |
|
17 | + * |
|
18 | + * @return array |
|
19 | + */ |
|
20 | + public function get_wp_headers() { |
|
21 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
22 | + $is_plugin_subscription = apply_filters( 'wl_feature__enable__entity-types-professional', false ) || |
|
23 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
24 | + apply_filters( 'wl_feature__enable__entity-types-business', false ) || |
|
25 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
26 | + apply_filters( 'wl_feature__enable__entity-types-starter', false ); |
|
27 | + |
|
28 | + try { |
|
29 | + return $is_plugin_subscription ? array( |
|
30 | + 'X-Wordlift-Plugin-Wp-Admin' => untrailingslashit( get_admin_url() ), |
|
31 | + 'X-Wordlift-Plugin-Wp-Json' => untrailingslashit( get_rest_url() ), |
|
32 | + ) : array(); |
|
33 | + } catch ( Exception $e ) { |
|
34 | + return array(); |
|
35 | + } |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * @return Api_Headers_Service |
|
40 | + */ |
|
41 | + public static function get_instance() { |
|
42 | + if ( null === self::$instance ) { |
|
43 | + self::$instance = new Api_Headers_Service(); |
|
44 | + } |
|
45 | + |
|
46 | + return self::$instance; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | } |
@@ -6,29 +6,29 @@ |
||
6 | 6 | |
7 | 7 | class Plugin_Diagnostics_API { |
8 | 8 | |
9 | - /** |
|
10 | - * @var Api_Service |
|
11 | - */ |
|
12 | - private $api_service; |
|
9 | + /** |
|
10 | + * @var Api_Service |
|
11 | + */ |
|
12 | + private $api_service; |
|
13 | 13 | |
14 | - /** |
|
15 | - * @param Api_Service $api_service |
|
16 | - */ |
|
17 | - public function __construct( Api_Service $api_service ) { |
|
18 | - $this->api_service = $api_service; |
|
19 | - } |
|
14 | + /** |
|
15 | + * @param Api_Service $api_service |
|
16 | + */ |
|
17 | + public function __construct( Api_Service $api_service ) { |
|
18 | + $this->api_service = $api_service; |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * Update. |
|
23 | - * |
|
24 | - * @param $payload |
|
25 | - */ |
|
26 | - public function update( $payload ) { |
|
27 | - $this->api_service->request( |
|
28 | - 'PUT', |
|
29 | - '/accounts/me/plugin/diagnostics/plugins-collection', |
|
30 | - array( 'content-type' => 'application/json' ), |
|
31 | - wp_json_encode( $payload ) |
|
32 | - ); |
|
33 | - } |
|
21 | + /** |
|
22 | + * Update. |
|
23 | + * |
|
24 | + * @param $payload |
|
25 | + */ |
|
26 | + public function update( $payload ) { |
|
27 | + $this->api_service->request( |
|
28 | + 'PUT', |
|
29 | + '/accounts/me/plugin/diagnostics/plugins-collection', |
|
30 | + array( 'content-type' => 'application/json' ), |
|
31 | + wp_json_encode( $payload ) |
|
32 | + ); |
|
33 | + } |
|
34 | 34 | } |
@@ -6,53 +6,53 @@ |
||
6 | 6 | use Wordlift\Modules\Plugin_Diagnostics\Plugin_Diagnostics_API; |
7 | 7 | |
8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
9 | - exit; |
|
9 | + exit; |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | // Bail out if the feature isn't enabled. |
13 | 13 | if ( ! apply_filters( 'wl_feature__enable__wordpress-plugin-diagnostics', false ) ) { // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
14 | - return; |
|
14 | + return; |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | // Autoloader for dependencies. |
18 | 18 | if ( file_exists( __DIR__ . '/third-party/vendor/scoper-autoload.php' ) ) { |
19 | - require __DIR__ . '/third-party/vendor/scoper-autoload.php'; |
|
19 | + require __DIR__ . '/third-party/vendor/scoper-autoload.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | // Autoloader for plugin itself. |
23 | 23 | if ( file_exists( __DIR__ . '/includes/vendor/autoload.php' ) ) { |
24 | - require __DIR__ . '/includes/vendor/autoload.php'; |
|
24 | + require __DIR__ . '/includes/vendor/autoload.php'; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | function __wl_plugin_diagnostics_push_config() { |
28 | 28 | |
29 | - // Get all plugins |
|
30 | - $all_plugins = get_plugins(); |
|
31 | - |
|
32 | - // Get active plugins |
|
33 | - $active_plugins = get_option( 'active_plugins' ); |
|
34 | - |
|
35 | - $payload = array_map( |
|
36 | - function ( $path, $item ) use ( $active_plugins ) { |
|
37 | - return array( |
|
38 | - 'name' => $item['Name'], |
|
39 | - 'version' => $item['Version'], |
|
40 | - 'active' => in_array( $path, $active_plugins, true ), |
|
41 | - ); |
|
42 | - }, |
|
43 | - array_keys( $all_plugins ), |
|
44 | - $all_plugins |
|
45 | - ); |
|
46 | - |
|
47 | - // Load the service. |
|
48 | - $container_builder = new ContainerBuilder(); |
|
49 | - $loader = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) ); |
|
50 | - $loader->load( 'services.yml' ); |
|
51 | - $container_builder->compile(); |
|
52 | - |
|
53 | - /** @var Plugin_Diagnostics_API $api */ |
|
54 | - $api = $container_builder->get( 'Wordlift\Modules\Plugin_Diagnostics\Plugin_Diagnostics_API' ); |
|
55 | - $api->update( $payload ); |
|
29 | + // Get all plugins |
|
30 | + $all_plugins = get_plugins(); |
|
31 | + |
|
32 | + // Get active plugins |
|
33 | + $active_plugins = get_option( 'active_plugins' ); |
|
34 | + |
|
35 | + $payload = array_map( |
|
36 | + function ( $path, $item ) use ( $active_plugins ) { |
|
37 | + return array( |
|
38 | + 'name' => $item['Name'], |
|
39 | + 'version' => $item['Version'], |
|
40 | + 'active' => in_array( $path, $active_plugins, true ), |
|
41 | + ); |
|
42 | + }, |
|
43 | + array_keys( $all_plugins ), |
|
44 | + $all_plugins |
|
45 | + ); |
|
46 | + |
|
47 | + // Load the service. |
|
48 | + $container_builder = new ContainerBuilder(); |
|
49 | + $loader = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) ); |
|
50 | + $loader->load( 'services.yml' ); |
|
51 | + $container_builder->compile(); |
|
52 | + |
|
53 | + /** @var Plugin_Diagnostics_API $api */ |
|
54 | + $api = $container_builder->get( 'Wordlift\Modules\Plugin_Diagnostics\Plugin_Diagnostics_API' ); |
|
55 | + $api->update( $payload ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -16,97 +16,97 @@ |
||
16 | 16 | $wp_constants = json_decode( file_get_contents( 'vendor/sniccowp/php-scoper-wordpress-excludes/generated/exclude-wordpress-constants.json' ), true ); |
17 | 17 | |
18 | 18 | return array( |
19 | - // The prefix configuration. If a non null value is be used, a random prefix |
|
20 | - // will be generated instead. |
|
21 | - // |
|
22 | - // For more see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#prefix |
|
23 | - 'prefix' => 'Wordlift\Modules\Plugin_Diagnostics', |
|
19 | + // The prefix configuration. If a non null value is be used, a random prefix |
|
20 | + // will be generated instead. |
|
21 | + // |
|
22 | + // For more see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#prefix |
|
23 | + 'prefix' => 'Wordlift\Modules\Plugin_Diagnostics', |
|
24 | 24 | |
25 | - // By default when running php-scoper add-prefix, it will prefix all relevant code found in the current working |
|
26 | - // directory. You can however define which files should be scoped by defining a collection of Finders in the |
|
27 | - // following configuration key. |
|
28 | - // |
|
29 | - // This configuration entry is completely ignored when using Box. |
|
30 | - // |
|
31 | - // For more see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#finders-and-paths |
|
32 | - 'finders' => array( |
|
33 | - Finder::create() |
|
34 | - ->files() |
|
35 | - ->ignoreVCS( true ) |
|
36 | - ->notName( '/LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.json|composer\\.lock/' ) |
|
37 | - ->exclude( |
|
38 | - array( |
|
39 | - 'doc', |
|
40 | - 'test', |
|
41 | - 'test_old', |
|
42 | - 'tests', |
|
43 | - 'Tests', |
|
44 | - 'vendor-bin', |
|
45 | - ) |
|
46 | - ) |
|
47 | - ->in( |
|
48 | - array( |
|
49 | - 'vendor/cweagans/composer-patches', |
|
50 | - 'vendor/mcaskill/composer-exclude-files', |
|
51 | - 'vendor/psr/container', |
|
52 | - 'vendor/symfony/config', |
|
53 | - 'vendor/symfony/dependency-injection', |
|
54 | - 'vendor/symfony/filesystem', |
|
55 | - 'vendor/symfony/polyfill-ctype', |
|
56 | - 'vendor/symfony/polyfill-php73', |
|
57 | - 'vendor/symfony/polyfill-php80', |
|
58 | - 'vendor/symfony/yaml', |
|
59 | - ) |
|
60 | - ), |
|
25 | + // By default when running php-scoper add-prefix, it will prefix all relevant code found in the current working |
|
26 | + // directory. You can however define which files should be scoped by defining a collection of Finders in the |
|
27 | + // following configuration key. |
|
28 | + // |
|
29 | + // This configuration entry is completely ignored when using Box. |
|
30 | + // |
|
31 | + // For more see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#finders-and-paths |
|
32 | + 'finders' => array( |
|
33 | + Finder::create() |
|
34 | + ->files() |
|
35 | + ->ignoreVCS( true ) |
|
36 | + ->notName( '/LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.json|composer\\.lock/' ) |
|
37 | + ->exclude( |
|
38 | + array( |
|
39 | + 'doc', |
|
40 | + 'test', |
|
41 | + 'test_old', |
|
42 | + 'tests', |
|
43 | + 'Tests', |
|
44 | + 'vendor-bin', |
|
45 | + ) |
|
46 | + ) |
|
47 | + ->in( |
|
48 | + array( |
|
49 | + 'vendor/cweagans/composer-patches', |
|
50 | + 'vendor/mcaskill/composer-exclude-files', |
|
51 | + 'vendor/psr/container', |
|
52 | + 'vendor/symfony/config', |
|
53 | + 'vendor/symfony/dependency-injection', |
|
54 | + 'vendor/symfony/filesystem', |
|
55 | + 'vendor/symfony/polyfill-ctype', |
|
56 | + 'vendor/symfony/polyfill-php73', |
|
57 | + 'vendor/symfony/polyfill-php80', |
|
58 | + 'vendor/symfony/yaml', |
|
59 | + ) |
|
60 | + ), |
|
61 | 61 | |
62 | - // Symfony mbstring polyfill. |
|
63 | - Finder::create() |
|
64 | - ->files() |
|
65 | - ->ignoreVCS( true ) |
|
66 | - ->ignoreDotFiles( true ) |
|
67 | - ->name( '/\.*.php8?/' ) |
|
68 | - ->in( 'vendor/symfony/polyfill-mbstring/Resources' ) |
|
69 | - ->append( |
|
70 | - array( |
|
71 | - 'vendor/symfony/polyfill-mbstring/Mbstring.php', |
|
72 | - 'vendor/symfony/polyfill-mbstring/composer.json', |
|
73 | - ) |
|
74 | - ), |
|
62 | + // Symfony mbstring polyfill. |
|
63 | + Finder::create() |
|
64 | + ->files() |
|
65 | + ->ignoreVCS( true ) |
|
66 | + ->ignoreDotFiles( true ) |
|
67 | + ->name( '/\.*.php8?/' ) |
|
68 | + ->in( 'vendor/symfony/polyfill-mbstring/Resources' ) |
|
69 | + ->append( |
|
70 | + array( |
|
71 | + 'vendor/symfony/polyfill-mbstring/Mbstring.php', |
|
72 | + 'vendor/symfony/polyfill-mbstring/composer.json', |
|
73 | + ) |
|
74 | + ), |
|
75 | 75 | |
76 | - Finder::create()->append( |
|
77 | - array( |
|
78 | - 'composer.json', |
|
79 | - ) |
|
80 | - ), |
|
81 | - ), |
|
76 | + Finder::create()->append( |
|
77 | + array( |
|
78 | + 'composer.json', |
|
79 | + ) |
|
80 | + ), |
|
81 | + ), |
|
82 | 82 | |
83 | - // List of excluded files, i.e. files for which the content will be left untouched. |
|
84 | - // Paths are relative to the configuration file unless if they are already absolute |
|
85 | - // |
|
86 | - // For more see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#patchers |
|
87 | - 'exclude-files' => array(), |
|
83 | + // List of excluded files, i.e. files for which the content will be left untouched. |
|
84 | + // Paths are relative to the configuration file unless if they are already absolute |
|
85 | + // |
|
86 | + // For more see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#patchers |
|
87 | + 'exclude-files' => array(), |
|
88 | 88 | |
89 | - // When scoping PHP files, there will be scenarios where some of the code being scoped indirectly references the |
|
90 | - // original namespace. These will include, for example, strings or string manipulations. PHP-Scoper has limited |
|
91 | - // support for prefixing such strings. To circumvent that, you can define patchers to manipulate the file to your |
|
92 | - // heart contents. |
|
93 | - // |
|
94 | - // For more see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#patchers |
|
95 | - 'patchers' => array(), |
|
89 | + // When scoping PHP files, there will be scenarios where some of the code being scoped indirectly references the |
|
90 | + // original namespace. These will include, for example, strings or string manipulations. PHP-Scoper has limited |
|
91 | + // support for prefixing such strings. To circumvent that, you can define patchers to manipulate the file to your |
|
92 | + // heart contents. |
|
93 | + // |
|
94 | + // For more see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#patchers |
|
95 | + 'patchers' => array(), |
|
96 | 96 | |
97 | - // List of symbols to consider internal i.e. to leave untouched. |
|
98 | - // |
|
99 | - // For more information see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#excluded-symbols |
|
100 | - 'exclude-namespaces' => array( |
|
101 | - // 'Acme\Foo' // The Acme\Foo namespace (and sub-namespaces) |
|
102 | - // '~^PHPUnit\\\\Framework$~', // The whole namespace PHPUnit\Framework (but not sub-namespaces) |
|
103 | - // '~^$~', // The root namespace only |
|
104 | - // '', // Any namespace |
|
105 | - ), |
|
106 | - 'exclude-classes' => $wp_classes, |
|
97 | + // List of symbols to consider internal i.e. to leave untouched. |
|
98 | + // |
|
99 | + // For more information see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#excluded-symbols |
|
100 | + 'exclude-namespaces' => array( |
|
101 | + // 'Acme\Foo' // The Acme\Foo namespace (and sub-namespaces) |
|
102 | + // '~^PHPUnit\\\\Framework$~', // The whole namespace PHPUnit\Framework (but not sub-namespaces) |
|
103 | + // '~^$~', // The root namespace only |
|
104 | + // '', // Any namespace |
|
105 | + ), |
|
106 | + 'exclude-classes' => $wp_classes, |
|
107 | 107 | |
108 | - 'exclude-functions' => $wp_functions, |
|
108 | + 'exclude-functions' => $wp_functions, |
|
109 | 109 | |
110 | - 'exclude-constants' => $wp_constants, |
|
110 | + 'exclude-constants' => $wp_constants, |
|
111 | 111 | |
112 | 112 | ); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @since 3.33.6 |
48 | 48 | */ |
49 | 49 | if ( ! apply_filters( 'wl_is_enabled', true ) ) { |
50 | - return; |
|
50 | + return; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; |
@@ -76,33 +76,33 @@ discard block |
||
76 | 76 | */ |
77 | 77 | function activate_wordlift() { |
78 | 78 | |
79 | - $log = Wordlift_Log_Service::get_logger( 'activate_wordlift' ); |
|
79 | + $log = Wordlift_Log_Service::get_logger( 'activate_wordlift' ); |
|
80 | 80 | |
81 | - $log->info( 'Activating WordLift...' ); |
|
81 | + $log->info( 'Activating WordLift...' ); |
|
82 | 82 | |
83 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
84 | - Wordlift_Activator::activate(); |
|
83 | + require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
84 | + Wordlift_Activator::activate(); |
|
85 | 85 | |
86 | - /** |
|
87 | - * Tell the {@link Wordlift_Http_Api} class that we're activating, to let it run activation tasks. |
|
88 | - * |
|
89 | - * @see https://github.com/insideout10/wordlift-plugin/issues/820 related issue. |
|
90 | - * @since 3.19.2 |
|
91 | - */ |
|
92 | - Wordlift_Http_Api::activate(); |
|
86 | + /** |
|
87 | + * Tell the {@link Wordlift_Http_Api} class that we're activating, to let it run activation tasks. |
|
88 | + * |
|
89 | + * @see https://github.com/insideout10/wordlift-plugin/issues/820 related issue. |
|
90 | + * @since 3.19.2 |
|
91 | + */ |
|
92 | + Wordlift_Http_Api::activate(); |
|
93 | 93 | |
94 | - // Ensure the post type is registered before flushing the rewrite rules. |
|
95 | - Wordlift_Entity_Post_Type_Service::get_instance()->register(); |
|
96 | - flush_rewrite_rules(); |
|
97 | - /** |
|
98 | - * @since 3.27.7 |
|
99 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
100 | - */ |
|
101 | - Top_Entities::activate(); |
|
94 | + // Ensure the post type is registered before flushing the rewrite rules. |
|
95 | + Wordlift_Entity_Post_Type_Service::get_instance()->register(); |
|
96 | + flush_rewrite_rules(); |
|
97 | + /** |
|
98 | + * @since 3.27.7 |
|
99 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
100 | + */ |
|
101 | + Top_Entities::activate(); |
|
102 | 102 | |
103 | - if ( ! wp_next_scheduled( 'wl_daily_cron' ) ) { |
|
104 | - wp_schedule_event( time(), 'daily', 'wl_daily_cron' ); |
|
105 | - } |
|
103 | + if ( ! wp_next_scheduled( 'wl_daily_cron' ) ) { |
|
104 | + wp_schedule_event( time(), 'daily', 'wl_daily_cron' ); |
|
105 | + } |
|
106 | 106 | |
107 | 107 | } |
108 | 108 | |
@@ -112,23 +112,23 @@ discard block |
||
112 | 112 | */ |
113 | 113 | function deactivate_wordlift() { |
114 | 114 | |
115 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
116 | - Wordlift_Deactivator::deactivate(); |
|
117 | - Wordlift_Http_Api::deactivate(); |
|
118 | - Ttl_Cache_Cleaner::deactivate(); |
|
119 | - /** |
|
120 | - * @since 3.27.7 |
|
121 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
122 | - */ |
|
123 | - Top_Entities::deactivate(); |
|
124 | - /** |
|
125 | - * @since 3.27.8 |
|
126 | - * Remove notification flag on deactivation. |
|
127 | - */ |
|
128 | - Key_Validation_Notice::remove_notification_flag(); |
|
129 | - flush_rewrite_rules(); |
|
130 | - |
|
131 | - wp_clear_scheduled_hook( 'wl_daily_cron' ); |
|
115 | + require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
116 | + Wordlift_Deactivator::deactivate(); |
|
117 | + Wordlift_Http_Api::deactivate(); |
|
118 | + Ttl_Cache_Cleaner::deactivate(); |
|
119 | + /** |
|
120 | + * @since 3.27.7 |
|
121 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
122 | + */ |
|
123 | + Top_Entities::deactivate(); |
|
124 | + /** |
|
125 | + * @since 3.27.8 |
|
126 | + * Remove notification flag on deactivation. |
|
127 | + */ |
|
128 | + Key_Validation_Notice::remove_notification_flag(); |
|
129 | + flush_rewrite_rules(); |
|
130 | + |
|
131 | + wp_clear_scheduled_hook( 'wl_daily_cron' ); |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
@@ -151,84 +151,84 @@ discard block |
||
151 | 151 | * @since 1.0.0 |
152 | 152 | */ |
153 | 153 | function run_wordlift() { |
154 | - /** |
|
155 | - * Filter: wl_feature__enable__widgets. |
|
156 | - * |
|
157 | - * @param bool whether the widgets needed to be registered, defaults to true. |
|
158 | - * |
|
159 | - * @return bool |
|
160 | - * @since 3.27.6 |
|
161 | - */ |
|
162 | - if ( apply_filters( 'wl_feature__enable__widgets', true ) ) { |
|
163 | - add_action( 'widgets_init', 'wl_register_chord_widget' ); |
|
164 | - add_action( 'widgets_init', 'wl_register_geo_widget' ); |
|
165 | - add_action( 'widgets_init', 'wl_register_timeline_widget' ); |
|
166 | - } |
|
167 | - add_filter( 'widget_text', 'do_shortcode' ); |
|
168 | - |
|
169 | - /** |
|
170 | - * Filter: wl_feature__enable__analysis |
|
171 | - * |
|
172 | - * @param bool Whether to send api request to analysis or not |
|
173 | - * |
|
174 | - * @return bool |
|
175 | - * @since 3.27.6 |
|
176 | - */ |
|
177 | - if ( apply_filters( 'wl_feature__enable__analysis', true ) ) { |
|
178 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' ); |
|
179 | - } else { |
|
180 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' ); |
|
181 | - } |
|
182 | - |
|
183 | - $plugin = new Wordlift(); |
|
184 | - $plugin->run(); |
|
185 | - |
|
186 | - // Initialize the TTL Cache Cleaner. |
|
187 | - new Ttl_Cache_Cleaner(); |
|
188 | - |
|
189 | - // Load the new Post Adapter. |
|
190 | - new Post_Adapter(); |
|
191 | - |
|
192 | - // Load the API Data Hooks. |
|
193 | - new Api_Data_Hooks(); |
|
194 | - |
|
195 | - add_action( |
|
196 | - 'plugins_loaded', |
|
197 | - function () { |
|
198 | - // All features from registry should be initialized here. |
|
199 | - $features_registry = Features_Registry::get_instance(); |
|
200 | - $features_registry->initialize_all_features(); |
|
201 | - }, |
|
202 | - 5 |
|
203 | - ); |
|
204 | - |
|
205 | - add_action( |
|
206 | - 'plugins_loaded', |
|
207 | - // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
208 | - function () use ( $plugin ) { |
|
209 | - |
|
210 | - new Wordlift_Products_Navigator_Shortcode_REST(); |
|
211 | - |
|
212 | - // Register the Dataset module, requires `$api_service`. |
|
213 | - require_once plugin_dir_path( __FILE__ ) . 'classes/dataset/index.php'; |
|
214 | - require_once plugin_dir_path( __FILE__ ) . 'classes/shipping-data/index.php'; |
|
215 | - |
|
216 | - /* |
|
154 | + /** |
|
155 | + * Filter: wl_feature__enable__widgets. |
|
156 | + * |
|
157 | + * @param bool whether the widgets needed to be registered, defaults to true. |
|
158 | + * |
|
159 | + * @return bool |
|
160 | + * @since 3.27.6 |
|
161 | + */ |
|
162 | + if ( apply_filters( 'wl_feature__enable__widgets', true ) ) { |
|
163 | + add_action( 'widgets_init', 'wl_register_chord_widget' ); |
|
164 | + add_action( 'widgets_init', 'wl_register_geo_widget' ); |
|
165 | + add_action( 'widgets_init', 'wl_register_timeline_widget' ); |
|
166 | + } |
|
167 | + add_filter( 'widget_text', 'do_shortcode' ); |
|
168 | + |
|
169 | + /** |
|
170 | + * Filter: wl_feature__enable__analysis |
|
171 | + * |
|
172 | + * @param bool Whether to send api request to analysis or not |
|
173 | + * |
|
174 | + * @return bool |
|
175 | + * @since 3.27.6 |
|
176 | + */ |
|
177 | + if ( apply_filters( 'wl_feature__enable__analysis', true ) ) { |
|
178 | + add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' ); |
|
179 | + } else { |
|
180 | + add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' ); |
|
181 | + } |
|
182 | + |
|
183 | + $plugin = new Wordlift(); |
|
184 | + $plugin->run(); |
|
185 | + |
|
186 | + // Initialize the TTL Cache Cleaner. |
|
187 | + new Ttl_Cache_Cleaner(); |
|
188 | + |
|
189 | + // Load the new Post Adapter. |
|
190 | + new Post_Adapter(); |
|
191 | + |
|
192 | + // Load the API Data Hooks. |
|
193 | + new Api_Data_Hooks(); |
|
194 | + |
|
195 | + add_action( |
|
196 | + 'plugins_loaded', |
|
197 | + function () { |
|
198 | + // All features from registry should be initialized here. |
|
199 | + $features_registry = Features_Registry::get_instance(); |
|
200 | + $features_registry->initialize_all_features(); |
|
201 | + }, |
|
202 | + 5 |
|
203 | + ); |
|
204 | + |
|
205 | + add_action( |
|
206 | + 'plugins_loaded', |
|
207 | + // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
208 | + function () use ( $plugin ) { |
|
209 | + |
|
210 | + new Wordlift_Products_Navigator_Shortcode_REST(); |
|
211 | + |
|
212 | + // Register the Dataset module, requires `$api_service`. |
|
213 | + require_once plugin_dir_path( __FILE__ ) . 'classes/dataset/index.php'; |
|
214 | + require_once plugin_dir_path( __FILE__ ) . 'classes/shipping-data/index.php'; |
|
215 | + |
|
216 | + /* |
|
217 | 217 | * Require the Entity annotation cleanup module. |
218 | 218 | * |
219 | 219 | * @since 3.34.6 |
220 | 220 | */ |
221 | - require_once plugin_dir_path( __FILE__ ) . 'classes/cleanup/index.php'; |
|
221 | + require_once plugin_dir_path( __FILE__ ) . 'classes/cleanup/index.php'; |
|
222 | 222 | |
223 | - /* |
|
223 | + /* |
|
224 | 224 | * Import LOD entities. |
225 | 225 | * |
226 | 226 | * @since 3.35.0 |
227 | 227 | */ |
228 | - require_once plugin_dir_path( __FILE__ ) . 'classes/lod-import/index.php'; |
|
228 | + require_once plugin_dir_path( __FILE__ ) . 'classes/lod-import/index.php'; |
|
229 | 229 | |
230 | - } |
|
231 | - ); |
|
230 | + } |
|
231 | + ); |
|
232 | 232 | |
233 | 233 | } |
234 | 234 | |
@@ -242,50 +242,50 @@ discard block |
||
242 | 242 | */ |
243 | 243 | function wordlift_plugin_autoload_register() { |
244 | 244 | |
245 | - spl_autoload_register( |
|
246 | - function ( $class_name ) { |
|
245 | + spl_autoload_register( |
|
246 | + function ( $class_name ) { |
|
247 | 247 | |
248 | - // Bail out if these are not our classes. |
|
249 | - if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) { |
|
250 | - return false; |
|
251 | - } |
|
248 | + // Bail out if these are not our classes. |
|
249 | + if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) { |
|
250 | + return false; |
|
251 | + } |
|
252 | 252 | |
253 | - $class_name_lc = strtolower( str_replace( '_', '-', $class_name ) ); |
|
253 | + $class_name_lc = strtolower( str_replace( '_', '-', $class_name ) ); |
|
254 | 254 | |
255 | - preg_match( '|^wordlift\\\\(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches ); |
|
255 | + preg_match( '|^wordlift\\\\(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches ); |
|
256 | 256 | |
257 | - $path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] ); |
|
258 | - $file = 'class-' . $matches[2] . '.php'; |
|
257 | + $path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] ); |
|
258 | + $file = 'class-' . $matches[2] . '.php'; |
|
259 | 259 | |
260 | - $full_path = plugin_dir_path( __FILE__ ) . 'classes' . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $file; |
|
260 | + $full_path = plugin_dir_path( __FILE__ ) . 'classes' . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $file; |
|
261 | 261 | |
262 | - if ( ! file_exists( $full_path ) ) { |
|
263 | - return false; |
|
264 | - } |
|
262 | + if ( ! file_exists( $full_path ) ) { |
|
263 | + return false; |
|
264 | + } |
|
265 | 265 | |
266 | - try { |
|
267 | - require_once $full_path; |
|
268 | - } catch ( Exception $e ) { |
|
269 | - // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log |
|
270 | - error_log( "[WordLift] $full_path not found, cannot include." ); |
|
271 | - } |
|
266 | + try { |
|
267 | + require_once $full_path; |
|
268 | + } catch ( Exception $e ) { |
|
269 | + // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log |
|
270 | + error_log( "[WordLift] $full_path not found, cannot include." ); |
|
271 | + } |
|
272 | 272 | |
273 | - return true; |
|
274 | - } |
|
275 | - ); |
|
273 | + return true; |
|
274 | + } |
|
275 | + ); |
|
276 | 276 | |
277 | 277 | } |
278 | 278 | |
279 | 279 | function wl_block_categories( $categories ) { |
280 | - return array_merge( |
|
281 | - $categories, |
|
282 | - array( |
|
283 | - array( |
|
284 | - 'slug' => 'wordlift', |
|
285 | - 'title' => __( 'WordLift', 'wordlift' ), |
|
286 | - ), |
|
287 | - ) |
|
288 | - ); |
|
280 | + return array_merge( |
|
281 | + $categories, |
|
282 | + array( |
|
283 | + array( |
|
284 | + 'slug' => 'wordlift', |
|
285 | + 'title' => __( 'WordLift', 'wordlift' ), |
|
286 | + ), |
|
287 | + ) |
|
288 | + ); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -293,19 +293,19 @@ discard block |
||
293 | 293 | * this has to be removed when removing the legacy fields from the ui. |
294 | 294 | */ |
295 | 295 | function wl_enqueue_leaflet( $in_footer = false ) { |
296 | - // Leaflet. |
|
297 | - wp_enqueue_style( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.css', array(), '1.6.0' ); |
|
298 | - wp_enqueue_script( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer ); |
|
296 | + // Leaflet. |
|
297 | + wp_enqueue_style( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.css', array(), '1.6.0' ); |
|
298 | + wp_enqueue_script( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer ); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | add_filter( 'block_categories', 'wl_block_categories', 10 ); |
302 | 302 | |
303 | 303 | // Temporary fix for a typo in WooCommerce Extension. |
304 | 304 | add_filter( |
305 | - 'wl_feature__enable__dataset', |
|
306 | - function ( $value ) { |
|
307 | - return apply_filters( 'wl_features__enable__dataset', $value ); |
|
308 | - } |
|
305 | + 'wl_feature__enable__dataset', |
|
306 | + function ( $value ) { |
|
307 | + return apply_filters( 'wl_features__enable__dataset', $value ); |
|
308 | + } |
|
309 | 309 | ); |
310 | 310 | |
311 | 311 | require_once __DIR__ . '/modules/food-kg/load.php'; |
@@ -321,35 +321,35 @@ discard block |
||
321 | 321 | require_once __DIR__ . '/modules/plugin-diagnostics/load.php'; |
322 | 322 | |
323 | 323 | function _wl_update_plugins_raptive_domain( $update, $plugin_data, $plugin_file ) { |
324 | - // Bail out if it's not our plugin. |
|
325 | - $update_uri = $plugin_data['UpdateURI']; |
|
326 | - if ( 'wordlift/wordlift.php' !== $plugin_file || ! isset( $update_uri ) ) { |
|
327 | - return $update; |
|
328 | - } |
|
329 | - |
|
330 | - $response = wp_remote_get( "$update_uri?nocache=" . time() ); |
|
331 | - |
|
332 | - if ( is_wp_error( $response ) ) { |
|
333 | - return $update; |
|
334 | - } |
|
335 | - |
|
336 | - try { |
|
337 | - return json_decode( wp_remote_retrieve_body( $response ) ); |
|
338 | - } catch ( Exception $e ) { |
|
339 | - return $update; |
|
340 | - } |
|
324 | + // Bail out if it's not our plugin. |
|
325 | + $update_uri = $plugin_data['UpdateURI']; |
|
326 | + if ( 'wordlift/wordlift.php' !== $plugin_file || ! isset( $update_uri ) ) { |
|
327 | + return $update; |
|
328 | + } |
|
329 | + |
|
330 | + $response = wp_remote_get( "$update_uri?nocache=" . time() ); |
|
331 | + |
|
332 | + if ( is_wp_error( $response ) ) { |
|
333 | + return $update; |
|
334 | + } |
|
335 | + |
|
336 | + try { |
|
337 | + return json_decode( wp_remote_retrieve_body( $response ) ); |
|
338 | + } catch ( Exception $e ) { |
|
339 | + return $update; |
|
340 | + } |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | add_action( |
344 | - 'update_plugins_adthrive.wordlift.io', |
|
345 | - '_wl_update_plugins_raptive_domain', |
|
346 | - 10, |
|
347 | - 3 |
|
344 | + 'update_plugins_adthrive.wordlift.io', |
|
345 | + '_wl_update_plugins_raptive_domain', |
|
346 | + 10, |
|
347 | + 3 |
|
348 | 348 | ); |
349 | 349 | |
350 | 350 | add_action( |
351 | - 'update_plugins_raptive.wordlift.io', |
|
352 | - '_wl_update_plugins_raptive_domain', |
|
353 | - 10, |
|
354 | - 3 |
|
351 | + 'update_plugins_raptive.wordlift.io', |
|
352 | + '_wl_update_plugins_raptive_domain', |
|
353 | + 10, |
|
354 | + 3 |
|
355 | 355 | ); |