public
Last active

Removing the Forgetmenot-checkbox on the WordPress login screen.

  • Download Gist
functions-php.part.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
<?php
 
/**
* Remove forgetmenot-checkbox on login screen
* Uses the hook 'after_theme_setup' instead of 'plugins_loaded' because
* first the theme have to be setup for get_template_directory_uri()
*
* @uses add_action()
* @hook after_setup_theme
*/
add_action(
'after_setup_theme',
'WPSE77581_remove_forgetmenot',
10,
0
);
 
/**
* Hook up all actions and filters
*
* @uses add_action()
* @hook login_enqueue_scripts
* @hook login_head
* @hook login_footer
*/
function WPSE77581_remove_forgetmenot() {
 
// add JavaScript
add_action( 'login_enqueue_scripts', 'WPSE77581_enqueue_script', 10, 0 );
 
// plain PHP with outputbuffering
add_action( 'login_head', 'WPSE77581_start_outputbuffer', 1, 0 );
add_action( 'login_footer', 'WPSE77581_end_outputbuffer', 1, 0 );
 
}
 
/**
* Enqueueing needed JavaScripts
* JS is stored in the folder 'js' inside the theme folder
*
* @uses wp_enqueue_script
* @uses get_template_directory_uri()
*/
function WPSE77581_enqueue_script() {
 
wp_enqueue_script(
'WPSE77581-remove-forgetmenot',
get_template_directory_uri() . '/js/wpse77581.js',
array( 'jquery' ),
false,
true
);
 
}
 
/**
* Start outputbuffering
* Buffers the DOM for later manipulation
*/
function WPSE77581_start_outputbuffer() {
 
ob_start();
 
}
 
/**
* End outputbuffering
* Get the content from outputbuffer and remove the paragraph with checkbox
*/
function WPSE77581_end_outputbuffer() {
 
$html = ob_get_clean();
 
$search = '#<p class="forgetmenot">.+</p>#Uuis';
 
$html = preg_replace( $search, '', $html );
 
echo $html;
 
}
index.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
<?php
/**
* WordPress-Plugin Remove Forgetmenot
*
* PHP version 5.3
*
* @category PHP
* @package WordPress
* @subpackage Remove Forgetmenot
* @author Ralf Albert <me@neun12.de>
* @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.txt
* @version 0.1
* @date 20112-12-29
* @link http://wordpress.com
*/
 
/**
* Plugin Name: Remove Forgetmenot
* Plugin URI: http://yoda.neun12.de
* Description: Removes the 'forgetmenot' checkbox from the login screen
* Version: 0.1
* Author: Ralf Albert
* Author URI: http://yoda.neun12.de
* Text Domain:
* Domain Path:
* Network:
* License: GPLv3
*/
 
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
 
 
namespace WPSE77581;
 
/**
* Start the plugin when plugins was loaded
*/
add_action(
'plugins_loaded',
'WPSE77581\remove_forgetmenot',
10,
0
);
 
/**
* Initialize the plugin. Hook up all actions and filters
*/
function remove_forgetmenot() {
 
// add JavaScript
add_action( 'login_enqueue_scripts', 'WPSE77581\enqueue_script', 10, 0 );
 
// plain PHP with outputbuffering
add_action( 'login_head', 'WPSE77581\start_outputbuffer', 1, 0 );
add_action( 'login_footer', 'WPSE77581\end_outputbuffer', 1, 0 );
 
}
 
/**
* Enqueueing needed JavaScripts
*/
function enqueue_script() {
 
wp_enqueue_script(
'WPSE77581-remove-forgetmenot',
plugins_url( 'wpse77581.js', __FILE__ ),
array( 'jquery' ),
false,
true
);
 
}
 
/**
* Start outputbuffering
* Buffers the DOM for later manipulation
*/
function start_outputbuffer() {
 
ob_start();
 
}
 
/**
* End outputbuffering
* Get the content from outputbuffer and remove the paragraph with checkbox
*/
function end_outputbuffer() {
 
$html = ob_get_clean();
 
$search = '#<p class="forgetmenot">.+</p>#Uuis';
 
$html = preg_replace( $search, '', $html );
 
echo $html;
 
}
index_php52.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
<?php
/**
* WordPress-Plugin Remove Forgetmenot
*
* PHP version 5.2
*
* @category PHP
* @package WordPress
* @subpackage Remove Forgetmenot
* @author Ralf Albert <me@neun12.de>
* @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.txt
* @version 0.1
* @date 20112-12-29
* @link http://wordpress.com
*/
 
/**
* Plugin Name: Remove Forgetmenot
* Plugin URI: http://yoda.neun12.de
* Description: Removes the 'forgetmenot' checkbox from the login screen
* Version: 0.1
* Author: Ralf Albert
* Author URI: http://yoda.neun12.de
* Text Domain:
* Domain Path:
* Network:
* License: GPLv3
*/
 
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
 
 
/**
* Start the plugin when plugins was loaded
*/
add_action(
'plugins_loaded',
'WPSE77581_remove_forgetmenot',
10,
0
);
 
/**
* Initialize the plugin. Hook up all actions and filters
*/
function WPSE77581_remove_forgetmenot() {
 
// add JavaScript
add_action( 'login_enqueue_scripts', 'WPSE77581_enqueue_script', 10, 0 );
 
// plain PHP with outputbuffering
add_action( 'login_head', 'WPSE77581_start_outputbuffer', 1, 0 );
add_action( 'login_footer', 'WPSE77581_end_outputbuffer', 1, 0 );
 
}
 
/**
* Enqueueing needed JavaScripts
*/
function WPSE77581_enqueue_script() {
 
wp_enqueue_script(
'WPSE77581-remove-forgetmenot',
plugins_url( 'wpse77581.js', __FILE__ ),
array( 'jquery' ),
false,
true
);
 
}
 
/**
* Start outputbuffering
* Buffers the DOM for later manipulation
*/
function WPSE77581_start_outputbuffer() {
 
ob_start();
 
}
 
/**
* End outputbuffering
* Get the content from outputbuffer and remove the paragraph with checkbox
*/
function WPSE77581_end_outputbuffer() {
 
$html = ob_get_clean();
 
$search = '#<p class="forgetmenot">.+</p>#Uuis';
 
$html = preg_replace( $search, '', $html );
 
echo $html;
 
}
readme.txt
1 2 3 4 5 6 7
README
 
Install
Donwload the zip-archive, uncompress it into a folder, upload the folder to your WordPress plugin-folder. Activate the plugin on the plugin screen.
 
!!!ATTENTION!!!
If you are using PHP5.2, delete or rename the file 'index.php' BEFORE upload/activate the plugin. Then rename the file 'index_php52.php' into 'index.php'
wpse77581.js
JavaScript
1 2 3 4 5 6 7 8 9
/**
* JavaScript (jQuery)
* Removes all paragraphs with class '.forgetmenot'
*/
jQuery( document ).ready(
function ( $ ) {
$( '.forgetmenot' ).remove();
}
);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.