-
core
WordPress 5.2 hooks
https://www.wp-plugin-api.com/version/wordpress-5-2/ -
wpcf7_init
Add customized fields in Contact Form 7
Add a field in Contact Form 7. In the form, insert [favorite_posts post_titles] In the email content, use [post_titles] In functions.php, add_action( ‘wpcf7_init’, ‘custom_add_form_tag_form_seminars’ ); function custom_add_form_tag_form_seminars() { wpcf7_add_form_tag( ‘favorite_posts’, ‘your_form_shortcode’, array(‘name-attr’ => true) ); // “form_seminars” is the type of the form-tag } function your_form_shortcode( $tag ) { if (!is_object($tag)) return ”; $name = $tag->{‘name’}; if (empty($name)) return ”; ob_start(); $args = array(‘post_type’ => ‘post’, ‘numberposts’ => -1 ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) { ?> <table class=”table table-bordered”> <?php while ( $the_query->have_posts() ) { $the_query->the_post(); ?> <tr> <td style=”width:40px;”> <input type=”checkbox” id=”hoge_<?php the_ID(); ?>” name=”<?php echo $name; ?>[]” class=”wpcf7-form-control” value=”<?php echo esc_attr( get_the_title() […] -
pre_get_posts
Show Custom Post Types in archive page
Change ‘your-custom-post-type’ to your desired custom post type. You should use $query->is_main_query() to only show these in your archive page (if you don’t, your custom post type posts may show up in your sidebar widget, etc.). function hoge_show_cpt_archives( $query ) { if( is_tag() && $query->is_main_query() ) { $query->set( ‘post_type’, array( ‘post’, ‘your-custom-post-type’ )); return $query; } } add_filter( ‘pre_get_posts’, ‘hoge_show_cpt_archives’ ); -
woocommerce_email_headers
WooCommerce BCC emails to specific email address
function add_bcc_all_emails( $headers, $object ) { $headers = array( $headers, ‘Bcc: Me <my@mail.net>’ .”\r\n”, ); return $headers; } add_filter( ‘woocommerce_email_headers’, ‘add_bcc_all_emails’, 10, 2 ); https://stackoverflow.com/questions/52924180/woocommerce-bcc-all-mails -
woocommerce_shipping_calculator_enable_city
Remove WooCommerce shipping calculator fields
When calculating the shipping fees, usually the City / Post Code / State fields are not necessary; Country is sufficient. To remove these fields, use the following snippet: add_filter( ‘woocommerce_shipping_calculator_enable_city’, ‘__return_false’ ); add_filter( ‘woocommerce_shipping_calculator_enable_postcode’, ‘__return_false’ ); add_filter( ‘woocommerce_shipping_calculator_enable_state’, ‘__return_false’ ); -
wp_unique_post_slug
Automatically generate random Post Slug for specific post type
add_filter( ‘wp_unique_post_slug’, ‘custom_unique_post_slug’, 10, 4 ); function custom_unique_post_slug( $slug, $post_ID, $post_status, $post_type ) { if ( $custom_post_type == $post_type ) { $post = get_post($post_ID); if ( empty($post->post_name) || $slug != $post->post_name ) { $slug = md5( time() ); } } return $slug; } Specify $custom_post_type to make it work for a specific post type. https://stackoverflow.com/questions/4518527/customize-the-auto-generation-of-post-slug-in-wordpress -
woocommerce_checkout_process
Add Privacy Policy Acceptance Checkbox @ WooCommerce Checkout
/** * @snippet Add privacy policy tick box at checkout * @how-to Watch tutorial @ https://businessbloomer.com/?p=19055 * @sourcecode https://businessbloomer.com/?p=19854 * @author Rodolfo Melogli * @testedwith WooCommerce 3.3.4 */ add_action( ‘woocommerce_review_order_before_submit’, ‘bbloomer_add_checkout_privacy_policy’, 9 ); function bbloomer_add_checkout_privacy_policy() { woocommerce_form_field( ‘privacy_policy’, array( ‘type’ => ‘checkbox’, ‘class’ => array(‘form-row privacy’), ‘label_class’ => array(‘woocommerce-form__label woocommerce-form__label-for-checkbox checkbox’), ‘input_class’ => array(‘woocommerce-form__input woocommerce-form__input-checkbox input-checkbox’), ‘required’ => true, ‘label’ => ‘I\’ve read and accept the <a href=”/privacy-policy”>Privacy Policy</a>’, )); } // Show notice if customer does not tick add_action( ‘woocommerce_checkout_process’, ‘bbloomer_not_approved_privacy’ ); function bbloomer_not_approved_privacy() { if ( ! (int) isset( $_POST[‘privacy_policy’] ) ) { wc_add_notice( __( ‘Please acknowledge the Privacy Policy’ ), ‘error’ ); } } https://businessbloomer.com/woocommerce-additional-acceptance-checkbox-checkout/ -
core
WordPress 5.1 hooks
https://www.wp-plugin-api.com/version/wordpress-5-1/ -
core
WordPress 5.0.3 hooks
https://www.wp-plugin-api.com/version/wordpress-5-0-3/ -
tiny_mce_before_init
Adding Custom Font Sizes to TinyMCE editor
// Enable font size & font family selects in the editor if ( ! function_exists( ‘wpex_mce_buttons’ ) ) { function wpex_mce_buttons( $buttons ) { array_unshift( $buttons, ‘fontselect’ ); // Add Font Select array_unshift( $buttons, ‘fontsizeselect’ ); // Add Font Size Select return $buttons; } } add_filter( ‘mce_buttons_2’, ‘wpex_mce_buttons’ ); https://www.wpexplorer.com/wordpress-tinymce-tweaks/