First create global variables (in functions.php or as a mu-plugin):
<?php
/*
 * CUSTOM GLOBAL VARIABLES
 */
function wtnerd_global_vars() {| <?php | |
| // In a class constructor | |
| $this->size_tax = wc_attribute_taxonomy_name( 'Size' ); | |
| $this->color_tax = wc_attribute_taxonomy_name( 'Color' ); | |
| // Insert the main product first | |
| // It will be used as a parent for other variations (think of it as a container) | |
| $product_id = wp_insert_post( array( | 
| /* | |
| * Add our Custom Fields to simple products | |
| */ | |
| function mytheme_woo_add_custom_fields() { | |
| global $woocommerce, $post; | |
| echo '<div class="options_group">'; | |
| // Text Field | 
| /** | |
| * You often need to get the content or title from a specific post. | |
| * Sometimes, using a custom loop is the better option, but when you only need | |
| * to get information from a specific post, there’s a better option | |
| */ | |
| echo get_post_field('post_content', $post_id); | 
| <?php | |
| add_filter( 'acf/load_field/name=flex_layout', __CLASS__ . '::craft_content_layouts' ); | |
| static function craft_content_layouts( $field ) { | |
| // Remove the layouts | |
| // that are named in this list | |
| $remove_list = [ | |
| 'paragraph', | |
| 'banner', | 
| <?php | |
| // There are three options (that I know of) for automatically enabling a plugin | |
| // in new sites. | |
| // 1. Move the plugin from wp-content/plugins/ to wp-content/mu-plugins/ (MU = | |
| // Must Use). But then it cannot be deactivated for any site. | |
| // 2. Click "Network Activate" instead of "Activate" to enable it for all sites. | |
| // I didn't want to use this though because I didn't want to affect existing | 
| <?php | |
| /*========================================= | |
| Custom Submit Box | |
| ==========================================*/ | |
| /** | |
| * Loop throught custom post types and | |
| * replace default submit box | |
| * | |
| * @since 1.0 | |
| * | 
First create global variables (in functions.php or as a mu-plugin):
<?php
/*
 * CUSTOM GLOBAL VARIABLES
 */
function wtnerd_global_vars() {