This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.
This documentation has moved here: https://github.com/johnbillion/wp_mail
| "use strict"; | |
| // based on unutbu's stackoverflow answer | |
| // https://stackoverflow.com/a/40958702/54829 | |
| // which is based on Evan Miller's blog post | |
| // http://www.evanmiller.org/ranking-items-with-star-ratings.html | |
| function starsort(ratings) { | |
| function sum(array) { return array.reduce((x, y) => x + y, 0) }; |
| function wc_bypass_logout_confirmation() { | |
| global $wp; | |
| if ( isset( $wp->query_vars['customer-logout'] ) ) { | |
| wp_redirect( str_replace( '&', '&', wp_logout_url( wc_get_page_permalink( 'myaccount' ) ) ) ); | |
| exit; | |
| } | |
| } | |
| add_action( 'template_redirect', 'wc_bypass_logout_confirmation' ); |
| <?php | |
| /** | |
| * Send "New User Registration" email to admins when new customer is created on WooCommerce. | |
| * | |
| * @param int $id New customer ID. | |
| */ | |
| function my_wc_customer_created_notification( $id ) { | |
| wp_new_user_notification( $id, null, 'admin' ); | |
| } |
| <?php | |
| /** | |
| * Make sure the function does not exist before defining it | |
| */ | |
| if( ! function_exists( 'remove_class_filter' ) ){ | |
| /** | |
| * Remove Class Filter Without Access to Class Object | |
| * | |
| * In order to use the core WordPress remove_filter() on a filter added with the callback |
This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.
This documentation has moved here: https://github.com/johnbillion/wp_mail
| <?php // only copy if needed! | |
| /** | |
| * Disables repeat purchase for the product | |
| * | |
| * @param bool $purchasable true if product can be purchased | |
| * @param \WC_Product $product the WooCommerce product | |
| * @return bool $purchasable the updated is_purchasable check | |
| */ | |
| function sv_disable_repeat_purchase( $purchasable, $product ) { |
| <?php | |
| /** | |
| * Insert an attachment from a URL address. | |
| * | |
| * @param string $url The URL address. | |
| * @param int|null $parent_post_id The parent post ID (Optional). | |
| * @return int|false The attachment ID on success. False on failure. | |
| */ | |
| function wp_insert_attachment_from_url( $url, $parent_post_id = null ) { |
| On Mac OS X (Leopard+), the Apache HTTP Server runs under the user account, _www which belongs to the group _www. To allow WordPress to configure wp-config.php during installation, update files during upgrades, and update the .htaccess file for pretty permalinks, give the server write permission on the files. | |
| One way to do this is to change the owner of the wordpress directory and its contents to _www. Keep the group as staff, a group to which your user account belongs and give write permissions to the group. | |
| $ cd /<wherever>/Sites/<thesite> | |
| $ sudo chown -R _www wordpress | |
| $ sudo chmod -R g+w wordpress | |
| This way, the WordPress directories have a permission level of 775 and files have a permission level of 664. No file nor directory is world-writeable. |
| <?php | |
| /** | |
| * This is free and unencumbered software released into the public domain. | |
| * | |
| * Anyone is free to copy, modify, publish, use, compile, sell, or | |
| * distribute this software, either in source code form or as a compiled | |
| * binary, for any purpose, commercial or non-commercial, and by any | |
| * means. | |
| * |