Here is a shortcode that I developed for WordPress to enable AJAX searching of the post title without relying on AJAX. There is a big push to move away from using iQuery and just use native functions of the browser to achieve the same objectives. My solution will detect when the shortcode is used and […]
Tag: PHP
How To Change Facebook Link Thumbnail and Description
To change the Facebook link thumbnail and description in WordPress we need to utilise a coding technology called “OpenGraph”. This allows a website to tell Facebook what information to display when someone shares a link. Facebook for Developers has a tool known as Debugger that allows a user to see what a Facebook link will […]
Disable WooCommerce Payment Gateways Based On Cart Amount
Disable WooCommerce payment gateways is fairly straight forward once you know what the name of the gateway is. The following code will disable paypal and stripe payment gateways on the WooCommerce checkout page when the cart amount is greater than $1000. You can adjust the code to disable payment gateways based on certain products that […]
Remove WooThemes IgniteWoo Updater Plugin Notice WordPress
To remove WooThemes and IgniteWoo update plugin notices, add the following code to your theme’s functions.php file.
1 2 3 4 |
//Remove WooThemes Updater remove_action('admin_notices', 'woothemes_updater_notice'); //Remove IgniteWoo Updater remove_action('admin_notices', 'ignitewoo_updater_notice'); |
[…]
WordPress PHP Check Plugin Active
This was taken from the WordPress Codex reference for is_plugin_active In the Admin Area:
1 |
is_plugin_active($plugin); |
In the front end of a theme you need to include a reference to the following library
1 2 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); is_plugin_active($plugin); |
In this case $plugin is the directory of the plugin followed by the main php file. In this example below the event […]
WooCommerce BCC Completed Orders Email
Adding an audit trail to WooCommerce completed orders emails is a fairly easy task. We can achieve this by employing the filter woocommerce_email_headers and adding in a check for the object name customer_completed_order. ** This will work for WooCommerce version less than or equal to 2.2 **
1 2 3 4 5 6 7 8 9 10 11 12 13 |
/** * BCC Email for orders completed for WooCommerce version 2.2 and below */ add_filter( 'woocommerce_email_headers', 'mycustom_headers_filter_function', 10, 2); function mycustom_headers_filter_function( $headers, $object ) { if ($object == 'customer_completed_order') { $headers .= 'BCC: Sales <contact@eversionsystems.com>' . "\r\n"; } return $headers; } |
** For WooCommerce version 2.3 and above […]
WooCommerce Duplicate Billing to Shipping Address For Virtual Products
With WooCommerce if a customer orders a virtual product there is no shipping address displayed on the checkout page. This makes sense as there is no physical item being posted to your customer. However, a few of my clients like to have the WooCommerce billing address match the shipping address. Subsequently, I wrote this piece […]
Add Custom Fields WordPress User Registration Page
To add custom fields WordPress user registration page we need to utilize the hook user_new_form because since WordPress 3.7 the hook register_form no longer works. Here is an example of adding a checkbox to the end of the user registration form.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<?php //Add a new form element... add_action( 'user_new_form', 'es_plugin_register_form' ); function es_plugin_register_form() { ?> <table class="form-table"> <tbody> <tr> <th scope="row"><label for="parent_account"><?php _e( 'Parent Account', 'eversion' ) ?></label></th> <td><label for="parent_account"><input name="parent_account" id="parent_account" value="1" type="checkbox">Create a parent account?</label></td> </tr> </tbody> </table> <?php } //Save our extra registration user meta. add_action( 'user_register', 'es_myplugin_user_register' ); function es_myplugin_user_register( $user_id ) { if ( isset( $_POST['parent_account'] ) ) { update_user_meta( $user_id, 'parent_account', 1 ); } } ?> |
Here is the result of us adding custom fields to WordPress user […]
Override WooCommerce Template Within Plugin
You might want to override a WooCommerce core template file in your plugin rather than in the theme directory to future proof theme switching. WooCommerce searches the following locations in this order until a match is found. Let’s alter this slightly so that it searches out plugin folder in order to override the WooCommerce template. […]
Sending WordPress Emails Using SMTP
Sending WordPress emails using SMTP is pretty straight forward so rather than using a plugin we can insert a small snippet to do the same thing. All you need for sending WordPress emails via SMTP are your mail server credentials such as username, password and server address. The WordPress email function wp_mail is essentially a […]