Skip to content

Instantly share code, notes, and snippets.

@RalfAlbert
Created December 31, 2012 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RalfAlbert/4419131 to your computer and use it in GitHub Desktop.
Save RalfAlbert/4419131 to your computer and use it in GitHub Desktop.
themes_functions-php.part.php
<?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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment