Snippets frequently used with Sage
This file contains hidden or 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
JOSEPH: Did I hear a dog? What's your dog's name? | |
+ CONWAY: His name is Homer. | |
~ dog_name = "Homer" | |
JOSEPH: Bit of a shuffle or a drag in Homer's step — kind of an old one isn't he? | |
+ CONWAY: Her name is Blue. | |
~ dog_name = "Blue" | |
JOSEPH: Blue sounds like a sweet old hound. I used to know a dog like that. |
This file contains hidden or 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 | |
/** | |
* Check if the cart contains virtual product | |
* | |
* @return bool | |
*/ | |
function woo_cart_has_virtual_product(){ | |
global $woocommerce; | |
// By default, no virtual product |
This file contains hidden or 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 if ( get_the_content() ) { ?> | |
// do or output something | |
<?php } ?> // break php tag for HTML block |
This file contains hidden or 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 | |
$args = array( | |
'post_type' => 'product', | |
'meta_key' => '_featured', | |
'meta_value' => 'yes', | |
'posts_per_page' => 6 | |
); | |
$featured_query = new WP_Query( $args ); | |
if ($featured_query->have_posts()) : | |
?> |
This file contains hidden or 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 | |
/** | |
* Related Posts. | |
* | |
* Usage: | |
* To show related by categories: | |
* Add in single.php <?php dfw_related_posts(); ?>. | |
* To show related by tags: | |
* Add in single.php <?php dfw_related_posts('tag'); ?>. |
This file contains hidden or 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 | |
/* | |
Plugin Name: Editors Add Users | |
Description: Allow editors to add user roles | |
Author: Christopher Davis | |
Author URI: http://www.christopherguitar.me | |
License: GPL2 | |
*/ | |
register_activation_hook( __FILE__, 'wpse42003_activation' ); |
This file contains hidden or 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 | |
/** | |
* Add the custom field on checkout page | |
*/ | |
add_action( 'woocommerce_after_checkout_billing_form', 'display_extra_fields_after_billing_address' , 10, 1 ); | |
function display_extra_fields_after_billing_address () { | |
_e( "Delivery Date: ", "add_extra_fields"); | |
?> |
This file contains hidden or 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 adds an option to send order notes email manually via order actions drop-down. | |
*/ | |
/** | |
* Filter to add a new menu to the dropdown | |
* | |
* @param array $actions | |
* @return array |
NewerOlder