Skip to content

Instantly share code, notes, and snippets.

@ajithrn
ajithrn / remove_wp_font.php
Created March 26, 2015 14:15
WordPress: Remove WP Fonts
/**
* Remove Open Sans that WP adds from frontend
*/
if (!function_exists('remove_wp_open_sans')) :
function remove_wp_open_sans() {
wp_deregister_style( 'open-sans' );
wp_register_style( 'open-sans', false );
}
add_action('wp_enqueue_scripts', 'remove_wp_open_sans');
// Uncomment below to remove from admin
@ajithrn
ajithrn / box-shadow.html
Last active August 29, 2015 14:16 — forked from ocean90/box-shadow.html
CSS: box-shadows
<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;
@ajithrn
ajithrn / is_child.php
Last active August 29, 2015 14:16
WordPress: Check if a page is child of another
/**
* Check if a page is child of another
* Ref: http://bavotasan.com/2011/is_child-conditional-function-for-wordpress/
*
* @param mixed $page_id_or_slug Provide the parent ID or Slug
* @return bool Whether the page is child or not of the given parent
*/
function is_child( $page_id_or_slug )
{
global $post;
<?php
/*-----------------------------------------------------------------------------------*/
/* Conditional Logic to Detect Various Event Related Views/Pages
/*-----------------------------------------------------------------------------------*/
if( tribe_is_month() && !is_tax() ) { // Month View Page
echo 'were on the month view page';
} elseif( tribe_is_month() && is_tax() ) { // Month View Category Page
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
@ajithrn
ajithrn / cpt-active-menu-clas-fix.php
Last active August 29, 2015 14:06
Wordpress: CPT active menu class fix
<?php
/**
* cusom post type active menu item fix
* not 100% working, it does remove the class,
* but if you are using custom page template to display post type, the active class insertion might not work
*
* @autor : ajith
* @url : http://trytoinnovate.com
* @referance : https://gist.github.com/AlphaBlossom/ae2f676d4763d1f1b3a2
*
@ajithrn
ajithrn / php.ini
Last active August 29, 2015 14:06
Wordpress: php.ini
## php.ini hack for increase memory allocation and maximun file upload size
## upload this file to wp-admin folder
##
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
file_uploads = On
max_execution_time = 300
##
##
@ajithrn
ajithrn / gravity_embed.php
Last active August 29, 2015 14:05
Wordpress: Gravity Form PHP embed
<?php
/**
* ref : http://www.gravityhelp.com/documentation/page/Embedding_A_Form
* Gravity forms embedding in php files
* @var boolean
*/
gravity_form($id_or_title, $display_title=true, $display_description=true, $display_inactive=false, $field_values=null, $ajax=false, $tabindex);
//Usage
@ajithrn
ajithrn / acf_flexible.php
Created July 7, 2014 00:09
Wordpress: ACF Flexible
<?php
// check if the flexible content field has rows of data
if( have_rows('sb_blocks') ):
// loop through the rows of data
while ( have_rows('sb_blocks') ) : the_row();
if( get_row_layout() == 'sbb_image_tile' ): ?>
@ajithrn
ajithrn / favicon.php
Last active August 29, 2015 14:03
Wordpress: custom favicon
/**
** Function to add custom favicon in wordpress blog
**/
function add_favicon() {
$favicon_path = get_template_directory_uri() . '/assets/img/favicon.ico';
echo '<link rel="shortcut icon" href="' . $favicon_path . '" />';
}
add_action( 'wp_head', 'add_favicon' ); //front end
add_action( 'admin_head', 'add_favicon' ); //admin end