| @@ -1,19 +1,15 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 4 | - exit; // Exit if accessed directly. | |
| 5 | -} | |
| 6 | - | |
| 7 | 3 | /** |
| 8 | 4 | * WP Adminify has some hooks for developers. |
| 9 | 5 | */ |
| 10 | -if ( ! class_exists( 'PXLBSAdminify_Developer_Hooks' ) ) { | |
| 6 | +if ( ! class_exists( 'WP_Adminify_Developer_Hooks' ) ) { | |
| 11 | 7 | |
| 12 | 8 | /** |
| 13 | 9 | * Developer friendly hooks. |
| 14 | 10 | */ |
| 15 | - class PXLBSAdminify_Developer_Hooks { | |
| 11 | + class WP_Adminify_Developer_Hooks { | |
| 16 | 12 | |
| 17 | 13 | |
| 18 | 14 | /* |
| 19 | 15 | * * * * * * * * * |
| @@ -23,27 +19,24 @@ | ||
| 23 | 19 | $this->_hooks(); |
| 24 | 20 | } |
| 25 | 21 | |
| 26 | 22 | public function _hooks() { |
| 27 | - add_filter( 'pxlbsadminify_remember_me', [ $this, 'remember_me_callback' ], 10, 1 ); | |
| 23 | + add_filter( 'wp_adminify_remember_me', [ $this, 'wp_adminify_remember_me_callback' ], 10, 1 ); | |
| 28 | 24 | } |
| 29 | 25 | |
| 30 | 26 | /** |
| 31 | - * remember_me_callback [turn off the remember me option from WordPress login form.] | |
| 27 | + * wp_adminify_remember_me_callback [turn off the remember me option from WordPress login form.] | |
| 32 | 28 | * |
| 33 | 29 | * @param bolean $activate |
| 34 | 30 | * @since 1.0.0 |
| 35 | 31 | */ |
| 36 | - public function remember_me_callback( $activate ) { | |
| 32 | + public function wp_adminify_remember_me_callback( $activate ) { | |
| 37 | 33 | if ( ! $activate ) { |
| 38 | 34 | return; |
| 39 | 35 | } |
| 40 | 36 | |
| 41 | - // Hide the "Remember Me" checkbox via CSS instead of opening | |
| 42 | - // an output buffer in login_form. Output buffers that are not | |
| 43 | - // closed in the same logical flow can desync the buffer stack | |
| 44 | - // when other plugins/themes also buffer output. | |
| 45 | - add_action( 'login_head', [ $this, 'hide_remember_me_style' ], 99 ); | |
| 37 | + // Add the hook into the login_form | |
| 38 | + add_action( 'login_form', [ $this, 'wp_adminify_login_form' ], 99 ); | |
| 46 | 39 | // Reset any attempt to set the remember option |
| 47 | 40 | add_action( 'login_head', [ $this, 'unset_remember_me_option' ], 99 ); |
| 48 | 41 | } |
| 49 | 42 | |
| @@ -49,15 +42,19 @@ | ||
| 49 | 42 | |
| 50 | 43 | function unset_remember_me_option() { |
| 51 | 44 | |
| 52 | 45 | // Remove the rememberme post value |
| 53 | - // phpcs:ignore WordPress.Security.NonceVerification.Missing -- read-only check, no state change. | |
| 54 | 46 | if ( isset( $_POST['rememberme'] ) ) { |
| 55 | 47 | unset( $_POST['rememberme'] ); |
| 56 | 48 | } |
| 57 | 49 | } |
| 58 | 50 | |
| 59 | - function hide_remember_me_style() { | |
| 60 | - echo '<style id="wp-adminify-hide-rememberme">.forgetmenot{display:none !important;}</style>'; | |
| 51 | + function wp_adminify_login_form() { | |
| 52 | + ob_start( [ $this, 'remove_forgetmenot_class' ] ); | |
| 53 | + } | |
| 54 | + | |
| 55 | + function remove_forgetmenot_class( $content ) { | |
| 56 | + $content = preg_replace( '/<p class="forgetmenot">(.*)<\/p>/', '', $content ); | |
| 57 | + return $content; | |
| 61 | 58 | } |
| 62 | 59 | } |
| 63 | 60 | } |