-
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/
-
Customize WooCommerce Order Emails
add_action( ‘woocommerce_email_after_order_table’, ‘wdm_add_shipping_method_to_order_email’, 10, 2 ); function wdm_add_shipping_method_to_order_email( $order, $is_admin_email ) { echo ‘<p><h4>Shipping:</h4> ‘ . $order->get_shipping_method() . ‘</p>’; } https://wisdmlabs.com/blog/customize-woocommerce-order-emails/
-
WooCommerce: Add First & Last Name to My Account Register Form
https://businessbloomer.com/woocommerce-add-first-last-name-account-register-form/
-
Change My Account menu names
Change My Account menu names add_filter( ‘woocommerce_account_menu_items’, ‘tbs_woocommerce_account_menu_items’, 10, 2 ); function tbs_woocommerce_account_menu_items( $items, $endpoints ){ $items[‘orders’] = ‘Recent Orders’; $items[‘edit-address’] = ‘Manage Addresses’; unset( $items[‘payment-methods’]); return $items; }
-
Save Contact Form 7 submitted content to post
An example to save submitted content as a post add_action(‘wpcf7_mail_sent’, ‘hoge_wpcf7_insert_post’, 10, 1); function hoge_wpcf7_insert_post(){ $submission = WPCF7_Submission::get_instance(); if ( $submission ) { $formdata = $submission->get_posted_data(); $email = $formdata[‘your-email’]; $name = $formdata[‘your-name’]; $new_post = array( ‘post_type’ => ‘post’, ‘post_title’ => $formdata[‘your-email’] . ‘ ‘ . $formdata[‘your-name’] , ‘post_status’ => ‘draft’, ‘post_content’ => $formdata[‘your-message’] ); $post_id = wp_insert_post( $new_post ); // insert as post meta add_post_meta( $post_id, ‘some_meta’, $formdata[‘some_meta’]); } }
-
Remove the version number from pages and feeds
// remove version info from head and feeds add_filter(‘the_generator’, ‘digwp_complete_version_removal’); function digwp_complete_version_removal() { return ”; } Thanks digwp.com https://digwp.com/2012/10/customizing-wordpress-feeds/
-
Disable Gutenberg editor
add_filter(‘gutenberg_can_edit_post_type’, ‘__return_false’); https://coliss.com/articles/blog/wordpress/how-to-disable-gutenberg.html
-
Using admin-ajax in front end to dynamically retrieve data
https://hijiriworld.com/web/wordpress-ajax/ http://fwww.hateblo.jp/entry/2017/11/24/160719
-
Add select field to TinyMCE to change line height
function add_style_select_button($buttons) { array_unshift($buttons, ‘styleselect’); return $buttons; } add_filter(‘mce_buttons_2’, ‘add_style_select_button’); function my_mce_before_init_insert_formats( $init_array ) { $style_formats = array( // These are the custom styles array( ‘title’ => ‘line 2’, ‘block’ => ‘span’, ‘classes’ => ‘line20’, ‘wrapper’ => true, ), array( ‘title’ => ‘line 3’, ‘inline’ => ‘span’, ‘classes’ => ‘line30’, ‘wrapper’ => true, ), ); // Insert the array, JSON ENCODED, into ‘style_formats’ $init_array[‘style_formats’] = json_encode( $style_formats ); return $init_array; } // Attach callback to ‘tiny_mce_before_init’ add_filter( ‘tiny_mce_before_init’, ‘my_mce_before_init_insert_formats’ ); css /* custom css */ .line20 { line-height: 2em; } .line30 { line-height: 3em; }
-
Remove Version Number From CSS & JS
// Remove WP Version From Styles add_filter( ‘style_loader_src’, ‘sdt_remove_ver_css_js’, 9999 ); // Remove WP Version From Scripts add_filter( ‘script_loader_src’, ‘sdt_remove_ver_css_js’, 9999 ); // Function to remove version numbers function sdt_remove_ver_css_js( $src ) { if ( strpos( $src, ‘ver=’ ) ) $src = remove_query_arg( ‘ver’, $src ); return $src; }