Remove remote API call in "Grow your business" task (#50479)
* Remove call to remote API in marketing task * Add changelog * Deprecate unused class methods
This commit is contained in:
parent
201f165600
commit
a337cfcab9
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: update
|
||||
|
||||
Remove remote API call from marketing task
|
|
@ -56,79 +56,40 @@ class Marketing extends Task {
|
|||
return __( '2 minutes', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Task completion.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_complete() {
|
||||
if ( null === $this->is_complete_result ) {
|
||||
$this->is_complete_result = self::has_installed_extensions();
|
||||
}
|
||||
|
||||
return $this->is_complete_result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Task visibility.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function can_view() {
|
||||
return Features::is_enabled( 'remote-free-extensions' ) && count( self::get_plugins() ) > 0;
|
||||
return Features::is_enabled( 'remote-free-extensions' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the marketing plugins.
|
||||
*
|
||||
* @deprecated 9.3.0 Removed to improve performance.
|
||||
* @return array
|
||||
*/
|
||||
public static function get_plugins() {
|
||||
$bundles = RemoteFreeExtensions::get_extensions(
|
||||
array(
|
||||
'task-list/reach',
|
||||
'task-list/grow',
|
||||
)
|
||||
);
|
||||
|
||||
return array_reduce(
|
||||
$bundles,
|
||||
function( $plugins, $bundle ) {
|
||||
$visible = array();
|
||||
foreach ( $bundle['plugins'] as $plugin ) {
|
||||
if ( $plugin->is_visible ) {
|
||||
$visible[] = $plugin;
|
||||
}
|
||||
}
|
||||
return array_merge( $plugins, $visible );
|
||||
},
|
||||
array()
|
||||
wc_deprecated_function(
|
||||
__METHOD__,
|
||||
'9.3.0'
|
||||
);
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the store has installed marketing extensions.
|
||||
*
|
||||
* @deprecated 9.3.0 Removed to improve performance.
|
||||
* @return bool
|
||||
*/
|
||||
public static function has_installed_extensions() {
|
||||
$plugins = self::get_plugins();
|
||||
$remaining = array();
|
||||
$installed = array();
|
||||
|
||||
foreach ( $plugins as $plugin ) {
|
||||
if ( ! $plugin->is_installed ) {
|
||||
$remaining[] = $plugin;
|
||||
} else {
|
||||
$installed[] = $plugin;
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure the task has been actioned and a marketing extension has been installed.
|
||||
if ( count( $installed ) > 0 && Task::is_task_actioned( 'marketing' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
wc_deprecated_function(
|
||||
__METHOD__,
|
||||
'9.3.0'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue