This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<div id="primary"> | |
<div id="content"> | |
<?php | |
$pp404 = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This code snippet forces login with email address and eliminates login with user name | |
// Remove the default authentication function and replace it by a custom function | |
remove_filter( 'authenticate', 'wp_authenticate_username_password', 20, 3 ); | |
add_filter( 'authenticate', 'force_email_login', 20, 3 ); | |
// Custom function to force email login | |
function force_email_login( $user, $username, $password ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This code snippet removes the wrong password login screen shake | |
// Add a custom function to the login head | |
add_action( 'login_head', 'remove_login_shake' ); | |
function remove_login_shake() { | |
// remove the wp_shake JavaScript | |
remove_action( 'login_head', 'wp_shake_js', 12 ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This code snippet automatically deletes the thumbnail if a post is deleted | |
// Add a custom function that runs before a post is deleted | |
add_action( 'before_delete_post', 'remove_post_thumbnail', 10 ); | |
// This function deletes the image assigned as thumbnail from the media library | |
function remove_post_thumbnail( $post_id ) { | |
// First we have to check, of there's a thumbnail assigned to the post |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This code snippet forces a new created user to change his password on first login | |
// To identify if a user changed his password we'll add an user meta key named password-changed when a user changes his password | |
// A new created user does not have this meta - so we know, he has to changed his password yet | |
// To force an user again to change his password we'd only have to delete the meta key | |
// Add a custom function to current_screen which is an admin hook triggered after the necessary elements to identify a screen are set up | |
add_action( 'current_screen', 'check_password_changed' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This code snippet adds a meta box in the right sidebar of the post screen that lists all available shortcodes | |
// As we use a default WordPress admin meta box the box can be closed to save space and opened when needed | |
// Add a custom function to create the meta box | |
add_action( 'add_meta_boxes', 'add_shortcodes_metabox' ); | |
// This function adds the meta box | |
function add_shortcodes_metabox() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This code snippet replaces the link to the locally hosted jQuery core with the link to the jQuery core hosted on jQuery CDN | |
// This reduces server load and page load time | |
// We do not use wp_deregister_script and wp_register_script but we directly access the global variable $wp_scripts | |
// because we want to replace the script with the correct version number | |
add_action( 'wp_print_scripts', 'replace_jquery' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This code snippet allows you to use shortcodes inside text widgets | |
// Some themes enable this feature, so maybe there's no need to do this yourself | |
// If your theme does not, this tiny code can do it | |
add_filter( 'widget_text', 'do_shortcode' ); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This code snippet completely removes the admin bar from the front end | |
add_filter( 'show_admin_bar', '__return_false' ); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This code snippet hides exclusive content if the user is not logged in | |
// To hide content you have to create a category with the slug 'only-for-members' | |
// All posts assigned to this category will be hidden from not logged in users | |
// Add a custom function to filter the content | |
add_filter( 'the_content', 'exclusive_content', 99 ); | |
// If the user is not logged in, the excerpt will be displayed plus a message that the content is avialable only for registered users |
OlderNewer