-
core
WordPress 5.2.2
https://www.wp-plugin-api.com/version/wordpress-5-2-2/ -
admin_init
Disable Comments
https://gist.github.com/mattclements/eab5ef656b2f946c4bfb -
Edit oembedded contents
Change excerpt length function wpa_oembed_excerpt_length() { return 20; } add_filter( ‘rest_oembed_output_excerpt_length’, ‘wpa_oembed_excerpt_length’, 9 ); Change oembedded content style function wpa_oembed_output() { ?> <style> .wp-embed { font-family: serif !important; } </style> <?php } add_action( ‘rest_oembed_output’, ‘wpa_oembed_output’, 11 ); -
core
WordPress 5.2.1 hooks
https://www.wp-plugin-api.com/version/wordpress-5-2-1/ -
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