This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Display a custom taxonomy dropdown in admin | |
* @author Mike Hemberger | |
* @link http://thestizmedia.com/custom-post-type-filter-admin-custom-taxonomy/ | |
*/ | |
add_action('restrict_manage_posts', 'tsm_filter_post_type_by_taxonomy'); | |
function tsm_filter_post_type_by_taxonomy() { | |
global $typenow; | |
$post_type = 'team'; // change to your post type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Checkout Form | |
* | |
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-checkout.php. | |
* | |
* HOWEVER, on occasion WooCommerce will need to update template files and you | |
* (the theme developer) will need to copy the new files to your theme to | |
* maintain compatibility. We try to do this as little as possible, but it does | |
* happen. When this occurs the version of the template file will be bumped and |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'template_include', 'portfolio_page_template', 99 ); | |
function portfolio_page_template( $template ) { | |
if ( is_front_page() ) { | |
$new_template = locate_template( array( 'tpl-duplicate-homepage.php' ) ); | |
if ( '' != $new_template ) { | |
return $new_template ; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// this is a hack | |
// assumption is the uploaded image will be 2x size of actual image used | |
// for example image will be displayed as 225 * 90 px so upload image needs to be 500 * 180 | |
// so image size added using image size would be add_image_size( 'site-logo', '225', '90', true ); | |
$custom_logo_id = get_theme_mod( 'custom_logo' ); | |
$logo = wp_get_attachment_image( $custom_logo_id , 'site-logo'); | |
if ( has_custom_logo() ) { | |
//the_custom_logo(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gzip compression | |
<IfModule mod_deflate.c> | |
# Active compression | |
SetOutputFilter DEFLATE | |
# Force deflate for mangled headers | |
<IfModule mod_setenvif.c> | |
<IfModule mod_headers.c> | |
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding | |
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding | |
# Don’t compress images and other uncompressible content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load the scripts conditionally | |
add_action( 'load-' . $menu_page, array($this, 'enqueue_scripts') ); | |
/* This function is only called when our plugin's page loads! */ | |
public function enqueue_scripts(){ | |
add_action('admin_enqueue_scripts', array($this, 'load_admin_scripts') ); | |
} | |
/* Load Scripts only if necessary */ | |
public function load_admin_scripts(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class myClass{ | |
protected static $instance = null; | |
public function __construct(){ | |
add_filter('the_content', array($this, 'add_text')); | |
} | |
public static function get_instance(){ | |
// If the single instance hasn't been set, set it now. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Attaching to Init because plugin files and theme files all have been loaded by this point and no output has been generated */ | |
/* using anonymous function */ | |
add_action('init', function(){ | |
/* replace wp_head with any filter or action hook */ | |
$hooks = digthis_see_hooked_actions('wp_head'); | |
var_dump($hooks); | |
}); | |
function digthis_see_hooked_actions($hook = NULL){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Auto Complete all WooCommerce orders. | |
*/ | |
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' ); | |
function custom_woocommerce_auto_complete_order( $order_id ) { | |
if ( ! $order_id ) { | |
return; | |
} | |
$order = wc_get_order( $order_id ); |
NewerOlder