- 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)) { |
| <?php | |
| /** | |
| * Prevent top level permalink slugs that will cause conflicts. | |
| * | |
| * New rewrite slugs are introduced when CPTs or Custom Taxonomies are created. | |
| * This code adds a check when Pages or Posts are created, that their Permalink | |
| * does not conflict with one of the reserved top level slugs you define. | |
| * | |
| * In the case of a bad (i.e conflicting slug), WordPress appends a "-2" to | |
| * the permalink. |