- Table of contents
- General information
- Terms
- General structure of a test
- WordPress-specific assertions and test functions
- enqueues
- creating posts
- creating terms
- attaching images
- ?
<?php | |
// Put this in wp-config.php and replace https://example.com/ with the URL of the production site. | |
define( 'BC_USE_REMOTE_MEDIA_URL', 'https://example.com' ); | |
// Put the rest of this in functions.php or a custom plugin or somewhere else. | |
if ( defined( 'BC_USE_REMOTE_MEDIA_URL' ) && ! empty( BC_USE_REMOTE_MEDIA_URL ) ) { | |
add_filter( 'wp_get_attachment_image_src', 'bc_filter_wp_get_attachment_image_src' ); | |
add_filter( 'wp_calculate_image_srcset', 'bc_filter_wp_calculate_image_srcset' ); | |
add_filter( 'wp_get_attachment_url', 'bc_filter_wp_get_attachment_url' ); | |
} |
<?php | |
add_filter( 'woocommerce_payment_complete_order_status', 'wmg_auto_complete_virtual_orders', 10, 3 ); | |
/** | |
* Automatically complete orders with only virtual products | |
* | |
* @param string $payment_complete_status Order status used after an order payment is received | |
* @param int $order_id ID of the order being processed | |
* @param WC_Order $order Order object being processed |
/** | |
* Get All orders IDs for a given product ID. | |
* | |
* @param integer $product_id (required) | |
* @param array $order_status (optional) Default is 'wc-completed' | |
* | |
* @return array | |
*/ | |
function get_orders_ids_by_product_id( $product_id, $order_status = array( 'wc-completed' ) ){ | |
global $wpdb; |
<?php | |
/** | |
* Plugin Name: Convert ACF PHP to JSON | |
* Description: Convert Advanced Custom Fields Pro configuration from PHP to JSON. | |
*/ | |
namespace ConvertAcfPhpToJson; | |
/** | |
* Add submenu item under 'Custom Fields' |
<?php | |
/** | |
* Adds a Base64 encoded version of the Featured Image thumbnail | |
* to post meta | |
* | |
* @param int $post_id ID of the post that's being updated. | |
*/ | |
function dp_add_base64_featured_image_thumb($post_id) { | |
// If this is just a revision, don't do anything. | |
if (wp_is_post_revision($post_id)) { |