Skip to content

Commit

Permalink
Deprecations for init functions calling add_action or add_filter
Browse files Browse the repository at this point in the history
  • Loading branch information
joshcanhelp committed Apr 2, 2019
1 parent 2a8bd34 commit 924e6ed
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 22 deletions.
15 changes: 6 additions & 9 deletions WP_Auth0.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,17 @@ class WP_Auth0 {
public function __construct( $options = null ) {
spl_autoload_register( array( $this, 'autoloader' ) );
$this->a0_options = $options instanceof WP_Auth0_Options ? $options : WP_Auth0_Options::Instance();
$this->basename = plugin_basename( __FILE__ );
}

/**
* Initialize the plugin and its modules setting all the hooks
* Initialize the plugin and its modules setting all the hooks.
*
* @deprecated - 3.10.0, will move add_action calls out of this class in the next major.
*
* @codeCoverageIgnore - Deprecated.
*/
public function init() {
$this->basename = plugin_basename( __FILE__ );

$ip_checker = new WP_Auth0_Ip_Check();
$ip_checker->init();

$this->db_manager = new WP_Auth0_DBManager( $this->a0_options );
$this->db_manager->init();
Expand Down Expand Up @@ -119,10 +120,6 @@ public function init() {

add_filter( 'plugin_action_links_' . $this->basename, array( $this, 'wp_add_plugin_settings_link' ) );

if ( isset( $_GET['message'] ) ) {
add_action( 'wp_footer', array( $this, 'a0_render_message' ) );
}

$initial_setup = new WP_Auth0_InitialSetup( $this->a0_options );
$initial_setup->init();

Expand Down
4 changes: 3 additions & 1 deletion lib/WP_Auth0_DBManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ public function __construct( WP_Auth0_Options $a0_options ) {
}

/**
* TODO: Deprecate init()
* @deprecated - 3.10.0, will move add_action calls out of this class in the next major.
*
* @codeCoverageIgnore - Deprecated.
*/
public function init() {
$this->current_db_version = (int) get_option( 'auth0_db_version', 0 );
Expand Down
5 changes: 4 additions & 1 deletion lib/WP_Auth0_EditProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ public function __construct(

/**
* Add actions and filters for the profile page.
* TODO: Deprecate init()
*
* @deprecated - 3.10.0, will move add_action calls out of this class in the next major.
*
* @codeCoverageIgnore - Deprecated.
*/
public function init() {
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
Expand Down
5 changes: 3 additions & 2 deletions lib/WP_Auth0_Email_Verification.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ public function __construct( WP_Auth0_Api_Jobs_Verification $api_jobs_resend ) {

/**
* Set up hooks tied to functions that can be dequeued.
* TODO: Deprecate init()
*
* @codeCoverageIgnore - Called at startup, tested in TestEmailVerification::testHooks()
* @deprecated - 3.10.0, will move add_action calls out of this class in the next major.
*
* @codeCoverageIgnore - Deprecated.
*/
public static function init() {
add_action( 'wp_ajax_nopriv_resend_verification_email', 'wp_auth0_ajax_resend_verification_email' );
Expand Down
5 changes: 3 additions & 2 deletions lib/WP_Auth0_ErrorLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ class WP_Auth0_ErrorLog {

/**
* Add actions and filters for the error log settings section.
* TODO: Deprecate init()
*
* @link https://developer.wordpress.org/reference/hooks/admin_action__requestaction/
* @deprecated - 3.10.0, will move add_action calls out of this class in the next major.
*
* @codeCoverageIgnore - Deprecated.
*/
public function init() {
add_action( 'admin_action_wpauth0_clear_error_log', 'wp_auth0_errorlog_clear_error_log' );
Expand Down
4 changes: 3 additions & 1 deletion lib/WP_Auth0_Export_Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ public function __construct( WP_Auth0_DBManager $db_manager ) {
}

/**
* TODO: Deprecate init()
* @deprecated - 3.10.0, will move add_action calls out of this class in the next major.
*
* @codeCoverageIgnore - Deprecated.
*/
public function init() {
add_action( 'admin_footer', array( $this, 'a0_add_users_export' ) );
Expand Down
4 changes: 3 additions & 1 deletion lib/WP_Auth0_Import_Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ public function __construct( WP_Auth0_Options $a0_options ) {
}

/**
* TODO: Deprecate init()
* @deprecated - 3.10.0, will move add_action calls out of this class in the next major.
*
* @codeCoverageIgnore - Deprecated.
*/
public function init() {
add_action( 'admin_action_wpauth0_export_settings', array( $this, 'export_settings' ) );
Expand Down
4 changes: 3 additions & 1 deletion lib/WP_Auth0_Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public function __construct( WP_Auth0_Options $a0_options, WP_Auth0_Ip_Check $ip
}

/**
* TODO: Deprecate init()
* @deprecated - 3.10.0, will move add_action calls out of this class in the next major.
*
* @codeCoverageIgnore - Deprecated.
*/
public function init() {
add_action( 'parse_request', array( $this, 'custom_requests' ) );
Expand Down
4 changes: 3 additions & 1 deletion lib/WP_Auth0_Settings_Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public function __construct( WP_Auth0_Options $a0_options, WP_Auth0_InitialSetup
}

/**
* TODO: Deprecate init()
* @deprecated - 3.10.0, will move add_action calls out of this class in the next major.
*
* @codeCoverageIgnore - Deprecated.
*/
public function init() {
add_action( 'admin_menu', array( $this, 'init_menu' ), 95.55, 0 );
Expand Down
5 changes: 5 additions & 0 deletions lib/WP_Auth0_WooCommerceOverrides.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public function __construct( WP_Auth0 $plugin, $options = null ) {
}
}

/**
* @deprecated - 3.10.0, will move add_action calls out of this class in the next major.
*
* @codeCoverageIgnore - Deprecated.
*/
public function init() {
add_filter( 'woocommerce_checkout_login_message', array( $this, 'override_woocommerce_checkout_login_form' ) );
add_filter( 'woocommerce_before_customer_login_form', array( $this, 'override_woocommerce_login_form' ) );
Expand Down
5 changes: 5 additions & 0 deletions lib/admin/WP_Auth0_Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public function __construct( WP_Auth0_Options $a0_options, WP_Auth0_Routes $rout
$this->router = $router;
}

/**
* @deprecated - 3.10.0, will move add_action calls out of this class in the next major.
*
* @codeCoverageIgnore - Deprecated.
*/
public function init() {
add_action( 'admin_init', array( $this, 'init_admin' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue' ), 1 );
Expand Down
5 changes: 5 additions & 0 deletions lib/initial-setup/WP_Auth0_InitialSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public function __construct( WP_Auth0_Options $a0_options ) {
$this->end_step = new WP_Auth0_InitialSetup_End( $this->a0_options );
}

/**
* @deprecated - 3.10.0, will move add_action calls out of this class in the next major.
*
* @codeCoverageIgnore - Deprecated.
*/
public function init() {

add_action( 'init', array( $this, 'init_setup' ), 1 );
Expand Down
4 changes: 3 additions & 1 deletion lib/profile/WP_Auth0_Profile_Change_Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public function __construct( WP_Auth0_Api_Change_Email $api_change_email ) {
/**
* Add actions for the update user process.
*
* @codeCoverageIgnore - Tested in TestProfileChangeEmail::testInitHooks()
* @deprecated - 3.10.0, will move add_action calls out of this class in the next major.
*
* @codeCoverageIgnore - Deprecated.
*/
public function init() {

Expand Down
4 changes: 3 additions & 1 deletion lib/profile/WP_Auth0_Profile_Change_Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public function __construct( WP_Auth0_Api_Change_Password $api_change_password )
/**
* Add actions and filters for the profile page.
*
* @codeCoverageIgnore - Tested in TestProfileChangePassword::testInitHooks()
* @deprecated - 3.10.0, will move add_action calls out of this class in the next major.
*
* @codeCoverageIgnore - Deprecated.
*/
public function init() {

Expand Down
4 changes: 3 additions & 1 deletion lib/profile/WP_Auth0_Profile_Delete_Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public function __construct( WP_Auth0_UsersRepo $users_repo ) {
/**
* Add actions and filters for the profile page.
*
* @codeCoverageIgnore - Tested in TestProfileDeleteData::testInitHooks()
* @deprecated - 3.10.0, will move add_action calls out of this class in the next major.
*
* @codeCoverageIgnore - Deprecated.
*/
public function init() {
add_action( 'edit_user_profile', array( $this, 'show_delete_identity' ) );
Expand Down

0 comments on commit 924e6ed

Please sign in to comment.