Skip to content

Instantly share code, notes, and snippets.

@vijujohns
vijujohns / add-honeypot-wordpress-comment-form.php
Last active February 4, 2022 07:28
Install honeypot spam prevention to your wordpress to reduce spam comments http://www.wppicker.com/how-to-install-honeypot-spam-blocking-for-wordpress/
/*
This code adds a hidden text field to the comment form to trap spam bots.
Add these code snippet at the end of functions.php.
No other setting needed.
*/
//Add an invisible field to comment form box
add_action('comment_form', 'wpp_add_honeypot');
function wpp_add_honeypot($postID) {
To block readme.html add this to .htaccess file:
<files readme.html>
order allow,deny
deny from all
</files>
Repeat it for other files as needed.
@vijujohns
vijujohns / remove-version.php
Last active August 29, 2015 14:27
code to remove wordpress version from head tags of pages, rss feeds etc http://www.wppicker.com/wordpress-security-remove-version-number-from-meta-generator-rss/
/*remove wordpress version number from front-end pages*/
function remove_version_from_mysite() {
return '';
}
add_filter('the_generator','remove_version_from_mysite');
//* Remove Comment Form Website URL Field
add_filter('comment_form_default_fields','wpp_remove_comment_url');
function wpp_remove_comment_url($fields) {
unset($fields['url']);
return $fields;
}
//* Remove comment form allowed tags
add_filter( 'comment_form_defaults', 'wpp_remove_comment_form_allowed_tags' );
function wpp_remove_comment_form_allowed_tags( $defaults ) {
/*Include a file from Child Theme Directory*/
<?php require_once( get_stylesheet_directory(). '/functions/child_theme_include_file.php' ); ?>
/*Include a file from Parent Theme Directory*/
<?php require_once( get_template_directory(). '/functions/parent_theme_include_file.php' ); ?>
/*Include a image from Child Theme Directory*/
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/my_picture.png" alt="" />
/*
Theme Name: Twenty Fifteen Child
Theme URI: http://example.com/
Description: Child theme for the Twenty Fifteen theme
Author: Your name here
Author URI: http://example.com/about/
Template: twentyfifteen
Version: 0.1.0
*/
@vijujohns
vijujohns / site-plugin.php
Last active August 29, 2015 14:26
Create a site specific plugin to host your local functions that can be enabled or disabled any time. http://www.wppicker.com/why-and-how-should-i-use-a-site-specific-plugin-for-wordpress/
<?php
/*
Plugin Name: Site Plugin for mysite.com
Version: 1.0
Author: Your Name
Description: Custom functions for mysite.com
*/
/* Start Adding Functions Below this Line */
//Automatically Insert Google Adsense ads to the top left or right of each post content.
add_filter( 'the_content', 'wpp_insert_ads_to_content' );
function wpp_insert_ads_to_content( $content ) {
$ad_code_wrapper_start = '<div style=”display:block;float:right;margin: 0px 0px 0px 10px;”>';
$ad_code = ' Copy and Paste Ad sense code here. Do not remove the starting and ending single quotes ';
$ad_code_wrapper_end = '</div>';
@vijujohns
vijujohns / 125x125 Ads.html
Last active August 29, 2015 14:26
Include responsive 125x125 Ad space in your WordPress blog sidebar without any plugin - http://www.wppicker.com/create-125x125-ad-space-site-sidebar-using-text-widgets/
<div style="float:right;position:relative;left:-50%;text-align:center;">
<div style="position:relative;left:50%;">
<!--125x125 Ad Banner Block#1-->
<a href="http://www.google.com" target=_blank>
<img src="http://localhost/wp-content/uploads/2015/07/a.png" alt="Google Banner" width="125" height="125" rel="nofollow" />
</a>
<!--125x125 Ad Banner Block#2-->
<a href="http://yahoo.com" target=_blank>
<div style="float:right;position:relative;left:-50%;text-align:center;">
<div style="position:relative;left:50%;">
<!--125x125 Ad Banner#1-->
<a href="target link here" target=_blank>
<img src="File URL of ad banner image here" alt="alt txt for ad 1" width="125" height="125" rel="nofollow" />
</a>
<!--125x125 Ad Banner#2-->
<a href="target link here" target=_blank>