← All changes
|
src/actions/importing/deactivate-conflicting-plugins-action.php
+41
-15
18.0
→
trunk
View file →
| @@ -1,20 +1,22 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Yoast\WP\SEO\Actions\Importing; |
| 4 | 4 | |
| 5 | -use wpdb; | |
| 6 | -use Yoast\WP\SEO\Conditionals\AIOSEO_V4_Importer_Conditional; | |
| 5 | +use Yoast\WP\SEO\Conditionals\Updated_Importer_Framework_Conditional; | |
| 7 | 6 | use Yoast\WP\SEO\Config\Conflicting_Plugins; |
| 7 | +use Yoast\WP\SEO\Helpers\Import_Cursor_Helper; | |
| 8 | 8 | use Yoast\WP\SEO\Helpers\Options_Helper; |
| 9 | +use Yoast\WP\SEO\Helpers\Sanitization_Helper; | |
| 10 | +use Yoast\WP\SEO\Services\Importing\Aioseo\Aioseo_Replacevar_Service; | |
| 11 | +use Yoast\WP\SEO\Services\Importing\Aioseo\Aioseo_Robots_Provider_Service; | |
| 12 | +use Yoast\WP\SEO\Services\Importing\Aioseo\Aioseo_Robots_Transformer_Service; | |
| 9 | 13 | use Yoast\WP\SEO\Services\Importing\Conflicting_Plugins_Service; |
| 10 | 14 | |
| 11 | 15 | /** |
| 12 | 16 | * Deactivates plug-ins that cause conflicts with Yoast SEO. |
| 13 | - * | |
| 14 | - * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded | |
| 15 | 17 | */ |
| 16 | -class Deactivate_Conflicting_Plugins_Action extends Abstract_Importing_Action { | |
| 18 | +class Deactivate_Conflicting_Plugins_Action extends Abstract_Aioseo_Importing_Action { | |
| 17 | 19 | |
| 18 | 20 | /** |
| 19 | 21 | * The plugin the class deals with. |
| 20 | 22 | * |
| @@ -19,9 +21,9 @@ | ||
| 19 | 21 | * The plugin the class deals with. |
| 20 | 22 | * |
| 21 | 23 | * @var string |
| 22 | 24 | */ |
| 23 | - const PLUGIN = 'conflicting-plugins'; | |
| 25 | + public const PLUGIN = 'conflicting-plugins'; | |
| 24 | 26 | |
| 25 | 27 | /** |
| 26 | 28 | * The type the class deals with. |
| 27 | 29 | * |
| @@ -26,11 +28,18 @@ | ||
| 26 | 28 | * The type the class deals with. |
| 27 | 29 | * |
| 28 | 30 | * @var string |
| 29 | 31 | */ |
| 30 | - const TYPE = 'deactivation'; | |
| 32 | + public const TYPE = 'deactivation'; | |
| 31 | 33 | |
| 32 | 34 | /** |
| 35 | + * The replacevar handler. | |
| 36 | + * | |
| 37 | + * @var Aioseo_Replacevar_Service | |
| 38 | + */ | |
| 39 | + protected $replacevar_handler; | |
| 40 | + | |
| 41 | + /** | |
| 33 | 42 | * Knows all plugins that might possibly conflict. |
| 34 | 43 | * |
| 35 | 44 | * @var Conflicting_Plugins_Service |
| 36 | 45 | */ |
| @@ -45,13 +54,26 @@ | ||
| 45 | 54 | |
| 46 | 55 | /** |
| 47 | 56 | * Class constructor. |
| 48 | 57 | * |
| 49 | - * @param Options_Helper $options The options helper. | |
| 50 | - * @param Conflicting_Plugins_Service $conflicting_plugins_service The Conflicting plugins Service. | |
| 58 | + * @param Import_Cursor_Helper $import_cursor The import cursor helper. | |
| 59 | + * @param Options_Helper $options The options helper. | |
| 60 | + * @param Sanitization_Helper $sanitization The sanitization helper. | |
| 61 | + * @param Aioseo_Replacevar_Service $replacevar_handler The replacevar handler. | |
| 62 | + * @param Aioseo_Robots_Provider_Service $robots_provider The robots provider service. | |
| 63 | + * @param Aioseo_Robots_Transformer_Service $robots_transformer The robots transfomer service. | |
| 64 | + * @param Conflicting_Plugins_Service $conflicting_plugins_service The Conflicting plugins Service. | |
| 51 | 65 | */ |
| 52 | - public function __construct( Options_Helper $options, Conflicting_Plugins_Service $conflicting_plugins_service ) { | |
| 53 | - parent::__construct( $options ); | |
| 66 | + public function __construct( | |
| 67 | + Import_Cursor_Helper $import_cursor, | |
| 68 | + Options_Helper $options, | |
| 69 | + Sanitization_Helper $sanitization, | |
| 70 | + Aioseo_Replacevar_Service $replacevar_handler, | |
| 71 | + Aioseo_Robots_Provider_Service $robots_provider, | |
| 72 | + Aioseo_Robots_Transformer_Service $robots_transformer, | |
| 73 | + Conflicting_Plugins_Service $conflicting_plugins_service | |
| 74 | + ) { | |
| 75 | + parent::__construct( $import_cursor, $options, $sanitization, $replacevar_handler, $robots_provider, $robots_transformer ); | |
| 54 | 76 | |
| 55 | 77 | $this->conflicting_plugins = $conflicting_plugins_service; |
| 56 | 78 | $this->detected_plugins = []; |
| 57 | 79 | } |
| @@ -57,8 +79,10 @@ | ||
| 57 | 79 | } |
| 58 | 80 | |
| 59 | 81 | /** |
| 60 | 82 | * Get the total number of conflicting plugins. |
| 83 | + * | |
| 84 | + * @return int | |
| 61 | 85 | */ |
| 62 | 86 | public function get_total_unindexed() { |
| 63 | 87 | return \count( $this->get_detected_plugins() ); |
| 64 | 88 | } |
| @@ -63,20 +87,22 @@ | ||
| 63 | 87 | return \count( $this->get_detected_plugins() ); |
| 64 | 88 | } |
| 65 | 89 | |
| 66 | 90 | /** |
| 67 | - * Returns whether the AISOEO post importing action is enabled. | |
| 91 | + * Returns whether the updated importer framework is enabled. | |
| 68 | 92 | * |
| 69 | - * @return bool True if the AISOEO post importing action is enabled. | |
| 93 | + * @return bool True if the updated importer framework is enabled. | |
| 70 | 94 | */ |
| 71 | 95 | public function is_enabled() { |
| 72 | - $aioseo_importer_conditional = \YoastSEO()->classes->get( AIOSEO_V4_Importer_Conditional::class ); | |
| 96 | + $updated_importer_framework_conditional = \YoastSEO()->classes->get( Updated_Importer_Framework_Conditional::class ); | |
| 73 | 97 | |
| 74 | - return $aioseo_importer_conditional->is_met(); | |
| 98 | + return $updated_importer_framework_conditional->is_met(); | |
| 75 | 99 | } |
| 76 | 100 | |
| 77 | 101 | /** |
| 78 | 102 | * Deactivate conflicting plugins. |
| 103 | + * | |
| 104 | + * @return array | |
| 79 | 105 | */ |
| 80 | 106 | public function index() { |
| 81 | 107 | $detected_plugins = $this->get_detected_plugins(); |
| 82 | 108 | $this->conflicting_plugins->deactivate_conflicting_plugins( $detected_plugins ); |