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 | |
/*** | |
Actions after purchase status is changed - useful for check payments | |
***/ | |
function drw_edd_after_check_purchase( $payment_id, $new_status, $old_status ) { | |
//bail if the order isn't approved | |
if ( !in_array($new_status, array('publish', 'complete')) ) { |
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 | |
/*** | |
Allow a product to be added only once to cart | |
***/ | |
function drw_edd_one_item_checkout( $download_id, $options ) { | |
if ( edd_item_in_cart($download_id) ) { | |
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 | |
/*** | |
Stores persisent data as post meta instead of using Transient API | |
@param $post_id int post ID to store post meta for | |
@parm $meta_key str "transient" name | |
@param $update_func str function to update the meta key with a new value | |
@param $expiration time when value should expire |
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 | |
function yournamespace_delete_transient( $post_id, $post, $update ) { | |
delete_transient('yournamespace_data_example'); | |
} | |
//{your_post_type} with a custom post type | |
add_action('save_post_{your_post_type}', 'yournamespace_delete_transient', 10, 3); |
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 | |
/*** | |
Register custom field for existing endpoint with callback function | |
Endpoint: /wp/v2/your_post_type | |
Note: Could also be a custom endpoint using register_rest_route | |
***/ | |
register_rest_field('your_post_type', 'custom_field_name', 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 | |
function yournamespace_rest_transient_example() { | |
//check for transient first | |
$data = get_transient( 'yournamespace_data_example' ); | |
if ( !empty( $data ) ) { | |
$data = $terms_transient; |
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_filter( 'woocommerce_thankyou_order_received_text', 'my_custom_order_received_text' ); | |
function my_custom_order_received_text() { ?> | |
<div class="order-received-text"> | |
<h5>Your Order Was Successful!</h5> | |
<p>Congratulations and a huge thank you for registering with us!</p> | |
<p>You will receive a confirmation email shortly. If you have questions, please do not hesitate to <a href="/contact">contact us</a></p> | |
<p>Thanks again!</p> |
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 | |
function hck_filter_taxonomy_archives( $url, $sfid) { | |
if (is_tax('topics')) { | |
$slug = get_queried_object()->slug; | |
$url = site_url() .'/'. get_post_type() .'/'. $slug; | |
} | |
return $url; |
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 | |
function hck_filter_taxonomy_archives( $query_args, $sfid ) { | |
if( $sfid == 509 ) { | |
$query_args = array( | |
'post_type' => 'articles', | |
); | |