Skip to content

Instantly share code, notes, and snippets.

@ajithrn
ajithrn / wp-custom-admin-columns.php
Last active August 29, 2015 13:57
Wordpress: custom admin columns sorting
<?php
/**
* custom admin columns for custom-post-type , and sorting
*
* custom_post_type: enter cutom post type as function name
* custom-post-type: enter your custom post here
* custom_column: enter your custom colum id
* custom_column1: enter your custom colum id
* CustomColumnName: enter your custom column name
* custom_meta: enter custom meta
@ajithrn
ajithrn / bmq.css
Created March 31, 2014 19:08
CSS: Bootstrap 3 Media Queries
/*==================================================
= Bootstrap 3 Media Queries =
==================================================*/
/*========== Mobile First Method ==========*/
/* Custom, iPhone Retina */
@media only screen and (min-width : 320px) {
@ajithrn
ajithrn / media-custom-images.php
Last active August 29, 2015 14:00
Wordpress: custom media image sizes
<?php
// Add new image sizes to media editor
function media_custom_image_sizes( $image_sizes ) {
// get the custom image sizes
global $_wp_additional_image_sizes;
// if there are none, just return the built-in sizes
if ( empty( $_wp_additional_image_sizes ) )
return $image_sizes;
@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
@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 / 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 / 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 / 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
*
/**
* 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' ) );
<?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