Skip to content

Instantly share code, notes, and snippets.

View disable-access-to-files.txt
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.
View remove-version.php
/*remove wordpress version number from front-end pages*/
function remove_version_from_mysite() {
return '';
}
add_filter('the_generator','remove_version_from_mysite');
View add-honeypot-wordpress-comment-form.php
/*
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) {
View remove-comment-form-url.php
//* 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 ) {
View include-files-child-theme.php
/*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="" />
View child-theme-style.css
/*
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 Aug 29, 2015
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/
View site-plugin.php
<?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 */
View auto-insert-adsense-ad-to-top-left-or-right-of-post-content.php
//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>';
View include-125x125-ad.html
<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>
@vijujohns
vijujohns / 125x125 Ads.html
Last active Aug 29, 2015
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/
View 125x125 Ads.html
<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>