Tuesday, October 8, 2013

10 WordPress hacks easy to implement

The benefits of a plugin, without the disadvantages: the Hack

Definition WordPress Hack: Element coded often inserted into the "function.php" file of your theme. The benefits of a hack are that it is much faster than a plugin, do not overload your blog and usually does not require updating.

10 WordPress Hacks Easy To Put In Work

While the hack is convenient, but nevertheless he asked to put their hands in sensitive and critical files to the proper functioning of your blog, so needless to remind you of the absolute necessity to save before handling ...
10 WordPress hacks easy to implement

Edit The Riddler Gravatar
If a user who comments on your blog is not listed on, Gravatar.com is the default gravatar appears. You can of course change the default gravatar from the settings page, but if you do not like those that are available, you can customize one for your blog.
Upload your own gravatar in your Pictures folder and paste the code in "functions.php". (Change the name of the image file that you see in the code "yourname-gravatar.jpg" by one of your personalized Gravatar)

add_filter( 'avatar_defaults', 'newgravatar' );
    function newgravatar ($avatar_defaults) {
    $myavatar = get_bloginfo('template_directory') . '/images/yourname-gravatar.jpg';
    $avatar_defaults[$myavatar] = "Build Internet";
    return $avatar_defaults;
}
The Google detect Visitors And Greet
Place the following code at the point where you want the message to appear.

<?php
if (strpos($_SERVER[HTTP_REFERER], "google") == true) {
 echo "Welcome Guest Google!";
}
?>
The use shortcodes In Your Widgets
If you want to add shortodes in a widget, you simply add a filter in your functions.php file. You can now use your shortcodes in both pages, articles and widgets on your blog.

<?php add_filter('widget_text', 'do_shortcode') ?>
Automatically Delete The Links In The Comments
When a user places a link in a comment, WordPress automatically converts clickable link. If you want to disable this feature, add the following code in your "functions.php" file.

remove_filter('comment_text', 'make_clickable', 9);
Configure the Default HTML Editor In WordPress
You know that the default editor for WordPress is the visual editor, if it does not suit you and you want to make the HTML Editor your default editor, simply add the following code always in your "File functions. Php ".

add_filter('wp_default_editor', create_function('', 'return "html";'));
The Exclude Pages In The WordPress Search
WordPress by default also included your pages in search results, if you want to exclude results and view only your items, add the following code in the "functions.php" file. This code places the pre_get_posts filter and therefore in the case below, it will only display the contents of the Blog excluding pages.

add_filter( 'pre_get_posts', 'tgm_exclude_pages' );
/**
 * tgm_exclude_pages Fonction.
 *
 * This function changes the WordPress application to remove the search pages.
 *
 * @param mixed $query Query original
 * @return $query Query modified
 *
 */
function tgm_exclude_pages( $query ) {
 if ( $query->is_search )
 $query->set( 'post_type', 'post' );
 return $query;
};
Edit The Mise En Cache Via. Htaccess
If you want to decrease the loading time of your files "images, CSS, PDF, JS", add the following code to your file. "Htaccess" (FTP only). Using this code, the main static files will be cached to speed up load times.

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##
Replace In 1 Times In All Content From Your Articles
How to add or replace text or link in all your posts and this at once. You can do this by adding the following code in your "functions.php" file. In the case below, the text "wordpress" will be bold and "wordpress hack" will be wearing a link to "wordpress.com".

function replace_text($text) {
 $text = str_replace('WordPress', '<strong>WordPress</strong>', $text);
 $text = str_replace('WordPress hacks', '<a href="http://www.wordpress.com">WordPress hacks</a>', $text);
 return $text;
}
add_filter('the_content', 'replace_text');
The Eliminate Spam From Your Comments
You can block spammers instead of marking as spam. The following code rejects any comment posted from a browser, which does not have “Referer” in general it, is a bot. The code checks the "HTTP_REFERRE" and if it is not defined or incorrect, execution is stopped with the appropriate message. Paste the following code in your "functions.php" file.

function check_referrer() {
 if (!isset($_SERVER['HTTP_REFERER']) || $_SERVER['HTTP_REFERER'] == &quot;&quot;) {
 wp_die( __('Thank you to enable the referrer in your browser, or, if you are a spammer, bye bye!') );
 }
}
add_action('check_comment_flood', 'check_referrer');
Delete the symbol [...] Extracts From Your Messages
If you want to get rid of this symbol [...], you only need to insert the following piece of code in the "functions.php" of your theme.

function trim_excerpt($text) {
 return rtrim($text,'[...]');
}
add_filter('get_the_excerpt', 'trim_excerpt');
Hack all good ;)
Share it Please

0 comments:

Post a Comment

Copyright @ 2013 Johnny Gagnon blog. Designed by Templateism | Love for The Globe Press