Snippets frequently used with Sage
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 | |
/** | |
* 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 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 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 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 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 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 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 |
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 adds back an option to resend the admin new order email from the order edit screen that was removed in WooCommerce 3.2 | |
*/ | |
/** | |
* Filter to add a new menu to the dropdown | |
* | |
* @param array $actions | |
* @return array |
NewerOlder