WordPress – Reset password in database

How to reset a WordPress password directly in the database (using PHPMyAdmin)?

METHOD 1

Go to
https://www.md5hashgenerator.com/
and calculate the MD5 hash for the password you want to use.

Open the WordPress users table (in PHPMyAdmin) wp-users and paste the MD5 hash into your user_pass field.

 

METHOD 2 (SNEAKY ONE!)

  • Open the WordPress users table (in PHPMyAdmin) wp-users.
  • Select a user with Administrator rights.
  • Back up the (encrypted) password and email address of that user in a text file.
  • Change the email address to your own email address.
  • Go to the WP login page and click the ‘Lost your password?’ link.
  • Enter your own email address (the one you entered in the database).
  • Click the ‘reset password’ link in the email that you receive from WordPress.
  • Enter a new password and you are in!
  • Create a new user for yourself, with Administrator rights.
  • In PHPMyAdmin, restore the password and email for the user you abused.
  • DONE 😉

Resource:
http://www.wpbeginner.com/beginners-guide/how-to-reset-a-wordpress-password-from-phpmyadmin/


WordPress – How to override javascript files in a child theme?

How to override javascript files in a child theme?

Add to your functions.php  file the following code:

<?php
 // hook in late to make sure the parent theme's registration
 // has fired so you can undo it. Otherwise the parent will simply
 // enqueue its script anyway.
 add_action('wp_enqueue_scripts', 'wpse26822_script_fix', 100);
 function wpse26822_script_fix()
 {   wp_dequeue_script('parent_theme_script_handle');
     wp_enqueue_script('child_theme_script_handle',
        get_stylesheet_directory_uri().'/scripts/yourjs.js', array('jquery'));
 }
 ?>

Resource:
http://wordpress.stackexchange.com/questions/26822/how-to-override-javascript-files-in-child-theme


WordPress – Briefly unavailable for scheduled maintenance

When you get an empty page with an error message saying:

"Briefly unavailable for scheduled maintenance. Check back in a minute."

Go to the root of your website and delete a file called .maintenance.

Note: it’s a HIDDEN file, so make sure your FTP client shows hidden files too!



WordPress – How to create a Widget

How to create a basic Widget?

<?php
/*
 * Plugin Name: Test Widget
 * Version: 0.1
 * Description: This is a Test Widget
 * Author: Me
 * Author URI: http://me.com
 */
?>
<?php
class TestWidget extends WP_Widget
{
    /*********************************************************************
     *    CONSTRUCTOR
     *********************************************************************/
    public function __construct()
    {
        parent::__construct(false, $name = 'This is a Test Widget');    
    } // __construct()
    

    /*********************************************************************
     *    DISPLAYS THE WIDGET
     *********************************************************************/
    function widget($args, $instance)
    {    
        extract($args);

        $html = 'Hey, this is a Test Widget!';

        echo $html;
    } // widget()
    
} // TestWidget

/*********************************************************************
 *    REGISTER THE WIDGET
 *********************************************************************/    
add_action('widgets_init', create_function('', 'return register_widget("TestWidget");'));
?>

WordPress – Disabling all Plugins using the Database

If you need to disable all plugins because one of the plugins is causing a problem and therefore you cannot get to the plugins page via the Dashboard (so-called “White Screen of Death”), you can disable all plugins directly in the database.

Locate the option name “active_plugins” (in the wp_options table)
Copy the value and paste it into some text editor (as a backup).
Change the value to:

a:0:{}

 


WordPress – Highlight search results

How to highlight search results?

Put the following code into your content loop:

$keys    = explode(" ", $s);
$content = get_the_content( '<span>'.__( 'Read more', 'mytextdomain' ).'</span>' );
$content = preg_replace('/('.implode('|', $keys) .')/iu', '<span class="search-excerpt">\0</span>', $content);
echo $content;

Add to your style.css file:

.search-excerpt {
    background-color: yellow;
    color: black;
}

Resource:
http://www.wpbeginner.com/wp-tutorials/how-to-highlight-the-search-terms-in-results-in-wordpress/