WPSEO_Import_Hooks

Abstract object for handling the importing and deactivating of the plugin.

Defined (1)

The class is defined in the following location(s).

/admin/import/class-import-hooks.php  
  1. abstract class WPSEO_Import_Hooks { 
  2.  
  3. /** 
  4. * @var string The main plugin file. 
  5. */ 
  6. protected $plugin_file; 
  7.  
  8. /** 
  9. * @var string The GET parameter for running the import. 
  10. */ 
  11. protected $import_listener; 
  12.  
  13. /** 
  14. * @var string The GET parameter for deactivating the plugin. 
  15. */ 
  16. protected $deactivation_listener; 
  17.  
  18. /** 
  19. * Throw a notice to import settings. 
  20. * @since 3.0 
  21. */ 
  22. abstract public function show_import_settings_notice(); 
  23.  
  24. /** 
  25. * Throw a notice to inform the user that the plugin has been deactivated 
  26. * @since 3.0 
  27. */ 
  28. abstract public function show_deactivate_notice(); 
  29.  
  30. /** 
  31. * Adding the hooks to show import/deactivate message when needed. 
  32. */ 
  33. public function __construct() { 
  34. if ( $this->is_active() ) { 
  35. $this->show_import_message(); 
  36. $this->show_deactivate_message(); 
  37.  
  38. /** 
  39. * Handle deactivation & import of the data data 
  40. * @since 3.0 
  41. */ 
  42. public function show_import_message() { 
  43. if ( filter_input( INPUT_GET, 'tool' ) !== 'import-export' ) { 
  44. add_action( 'admin_notices', array( $this, 'show_import_settings_notice' ) ); 
  45.  
  46. /** 
  47. * Handle deactivation of the plugin 
  48. * @since 3.0 
  49. */ 
  50. public function show_deactivate_message() { 
  51. if ( filter_input( INPUT_GET, $this->deactivation_listener ) === '1' ) { 
  52. // Deactivate AIO. 
  53. deactivate_plugins( $this->plugin_file ); 
  54.  
  55. // Show notice that aioseo has been deactivated. 
  56. add_action( 'admin_notices', array( $this, 'show_deactivate_notice' ) ); 
  57.  
  58. // Clean up the referrer url for later use. 
  59. if ( isset( $_SERVER['REQUEST_URI'] ) ) { 
  60. $_SERVER['REQUEST_URI'] = remove_query_arg( array( $this->deactivation_listener ), sanitize_text_field( $_SERVER['REQUEST_URI'] ) ); 
  61.  
  62. /** 
  63. * Check if the plugin is active. 
  64. * @return bool 
  65. */ 
  66. protected function is_active() { 
  67. return is_plugin_active( $this->plugin_file );