| @@ -1,63 +1,66 @@ | ||
| 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 | - /** | |
| 13 | - * Developer friendly hooks. | |
| 14 | - */ | |
| 15 | - class PXLBSAdminify_Developer_Hooks { | |
| 8 | + /** | |
| 9 | + * Developer friendly hooks. | |
| 10 | + */ | |
| 11 | + class WP_Adminify_Developer_Hooks | |
| 12 | + { | |
| 16 | 13 | |
| 14 | + /* * * * * * * * * * | |
| 15 | + * Class constructor | |
| 16 | + * * * * * * * * * */ | |
| 17 | + public function __construct() | |
| 18 | + { | |
| 19 | + $this->_hooks(); | |
| 20 | + } | |
| 17 | 21 | |
| 18 | - /* | |
| 19 | - * * * * * * * * * | |
| 20 | - * Class constructor | |
| 21 | - * * * * * * * * * */ | |
| 22 | - public function __construct() { | |
| 23 | - $this->_hooks(); | |
| 24 | - } | |
| 22 | + public function _hooks() | |
| 23 | + { | |
| 24 | + add_filter('wp_adminify_remember_me', [$this, 'wp_adminify_remember_me_callback'], 10, 1); | |
| 25 | + } | |
| 25 | 26 | |
| 26 | - public function _hooks() { | |
| 27 | - add_filter( 'pxlbsadminify_remember_me', [ $this, 'remember_me_callback' ], 10, 1 ); | |
| 28 | - } | |
| 27 | + /** | |
| 28 | + * wp_adminify_remember_me_callback [turn off the remember me option from WordPress login form.] | |
| 29 | + * @param bolean $activate | |
| 30 | + * @since 1.0.0 | |
| 31 | + */ | |
| 32 | + public function wp_adminify_remember_me_callback($activate) | |
| 33 | + { | |
| 29 | 34 | |
| 30 | - /** | |
| 31 | - * remember_me_callback [turn off the remember me option from WordPress login form.] | |
| 32 | - * | |
| 33 | - * @param bolean $activate | |
| 34 | - * @since 1.0.0 | |
| 35 | - */ | |
| 36 | - public function remember_me_callback( $activate ) { | |
| 37 | - if ( ! $activate ) { | |
| 38 | - return; | |
| 39 | - } | |
| 35 | + if (!$activate) | |
| 36 | + return; | |
| 40 | 37 | |
| 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 ); | |
| 46 | - // Reset any attempt to set the remember option | |
| 47 | - add_action( 'login_head', [ $this, 'unset_remember_me_option' ], 99 ); | |
| 48 | - } | |
| 38 | + // Add the hook into the login_form | |
| 39 | + add_action('login_form', [$this, 'wp_adminify_login_form'], 99); | |
| 40 | + // Reset any attempt to set the remember option | |
| 41 | + add_action('login_head', [$this, 'unset_remember_me_option'], 99); | |
| 42 | + } | |
| 49 | 43 | |
| 50 | - function unset_remember_me_option() { | |
| 44 | + function unset_remember_me_option() | |
| 45 | + { | |
| 51 | 46 | |
| 52 | - // Remove the rememberme post value | |
| 53 | - // phpcs:ignore WordPress.Security.NonceVerification.Missing -- read-only check, no state change. | |
| 54 | - if ( isset( $_POST['rememberme'] ) ) { | |
| 55 | - unset( $_POST['rememberme'] ); | |
| 56 | - } | |
| 57 | - } | |
| 47 | + // Remove the rememberme post value | |
| 48 | + if (isset($_POST['rememberme'])) { | |
| 49 | + unset($_POST['rememberme']); | |
| 50 | + } | |
| 51 | + } | |
| 58 | 52 | |
| 59 | - function hide_remember_me_style() { | |
| 60 | - echo '<style id="wp-adminify-hide-rememberme">.forgetmenot{display:none !important;}</style>'; | |
| 61 | - } | |
| 62 | - } | |
| 53 | + function wp_adminify_login_form() | |
| 54 | + { | |
| 55 | + | |
| 56 | + ob_start(array($this, 'remove_forgetmenot_class')); | |
| 57 | + } | |
| 58 | + | |
| 59 | + function remove_forgetmenot_class($content) | |
| 60 | + { | |
| 61 | + | |
| 62 | + $content = preg_replace('/<p class="forgetmenot">(.*)<\/p>/', '', $content); | |
| 63 | + return $content; | |
| 64 | + } | |
| 65 | + } | |
| 63 | 66 | } |