Skip to content

Instantly share code, notes, and snippets.

@Willem-Siebe
Willem-Siebe / functions.php
Created Mar 20, 2016
Salonized scripts and styles.
View functions.php
// WSIS: Salonized scripts and styles
function wsis_salonized_scripts() {
wp_register_style( 'salonized', '//cdn.salonized.com/assets/booking/v2/booking.css', false, false, 'screen, projection' );
wp_enqueue_style( 'salonized' );
wp_register_script( 'salonized-v2-js', '//cdn.salonized.com/assets/booking/v2.js', false, false, true );
wp_register_script( 'salonized-init', get_stylesheet_directory_uri() . '/js/salonized/wsis-salonized.js', array( 'salonized-v2-js' ), false, true );
wp_enqueue_script( 'salonized-init' );
View wp-config.php
/** Disable file editing in WordPress, see https://gist.github.com/Willem-Siebe/cf166ec36b3f2e145903. */
define('DISALLOW_FILE_EDIT', true);
@Willem-Siebe
Willem-Siebe / functions.php
Last active Aug 29, 2015
Check WP User role
View functions.php
// function current user roles http://docs.appthemes.com/tutorials/wordpress-check-user-role-function/
/**
* Checks if a particular user has a role.
* Returns true if a match was found.
*
* @param string $role Role name.
* @param int $user_id (Optional) The ID of a user. Defaults to the current user.
* @return bool
*/
@Willem-Siebe
Willem-Siebe / functions.php
Created Jul 20, 2015
Create unique Cred Frontend Editor url's after form submission so this can be tracked in Google Analytics. See https://wp-types.com/forums/topic/different-thank-you-pages-in-cred-depending-on-the-url-parameter/#post-263521, because you need to add more code to your CRED form!
View functions.php
// Add parent page ID's to the thank you pages after form submission through CRED forms. More code needs to be added in CRED form itself, see https://gist.github.com/Willem-Siebe/a30f4ba5ff3607923ebc.
add_shortcode('wsis-sc-get-url-param', 'wsis_get_url_param');
function wsis_get_url_param ($atts) {
$var = $atts["var"];
return $_GET[$var];
}
function wsis_add_parent_page_id_to_redirect_page($url, $post_id, $form_data)
@Willem-Siebe
Willem-Siebe / functions.php
Last active Aug 29, 2015
Remove Purchase Order field from Wholesale checkout page, see plugin https://stephensherrardplugins.com/plugins/woocommerce-wholesale-ordering/. Why is it there, plugin developer: At least here is the USA most companies that order wholesale from their vendors, have their own internal Purchase Order numbers that they assign to each order they mak…
View functions.php
// Remove Purchase Order field from Wholesale checkout page, see https://gist.github.com/Willem-Siebe/f23e348d1165d7934868.
function wsis_remove_purchase_order_field($fields) {
if (isset($fields['order']['purchase_order'])) {
unset($fields['order']['purchase_order']);
}
return $fields;
}
add_filter( 'woocommerce_checkout_fields', 'wsis_remove_purchase_order_field', 15, 1);
View gist:d0a2ba73cc3b980f1165
Changing heading element level from TablePress tables, see https://gist.github.com/Willem-Siebe/d0a2ba73cc3b980f1165.
add_filter( 'tablepress_print_name_html_tag', 'wsis_tablepress_change_table_name_h2_to_h4', 10, 2 );
function wsis_tablepress_change_table_name_h2_to_h4( $tag, $table_id ) {
$tag = 'h4';
return $tag;
}
@Willem-Siebe
Willem-Siebe / functions.php
Created Mar 18, 2015
Inline styling for own email templates WooCommerce before version 2.3.x, after version 2.3.x just use the new email template for styles email-styles.php, see Github issue https://github.com/woothemes/woocommerce/issues/5512 and must have gotten some help from a developer per e-mail.
View functions.php
function kill_defaults($tags) {
return array();
}
add_filter( 'woocommerce_email_style_inline_tags', 'kill_defaults', 20 );
add_filter( 'woocommerce_email_style_inline_h1_tag', 'kill_defaults', 20 );
add_filter( 'woocommerce_email_style_inline_h2_tag', 'kill_defaults', 20 );
add_filter( 'woocommerce_email_style_inline_h3_tag', 'kill_defaults', 20 );
add_filter( 'woocommerce_email_style_inline_a_tag', 'kill_defaults', 20 );
add_filter( 'woocommerce_email_style_inline_img_tag', 'kill_defaults', 20 );
View gist:c6d798ccba249d5bf080
// Remove CSS and/or JS for Select2 used by WooCommerce, see https://gist.github.com/Willem-Siebe/c6d798ccba249d5bf080.
add_action( 'wp_enqueue_scripts', 'wsis_dequeue_stylesandscripts_select2', 100 );
function wsis_dequeue_stylesandscripts_select2() {
if ( class_exists( 'woocommerce' ) ) {
wp_dequeue_style( 'select2' );
wp_deregister_style( 'select2' );
wp_dequeue_script( 'select2');
@Willem-Siebe
Willem-Siebe / functions.php
Created Feb 12, 2015
Disable e-mail subject encoding by Formidable, API Mandrill (if used) is taking care of this. See https://formidablepro.com/help-desk/email-subject/.
View functions.php
// Disable e-mail subject encoding by Formidable, API Mandrill (if used) is taking care of this, see https://gist.github.com/Willem-Siebe/cbd36caca079859b2918
add_filter('frm_encode_subject', 'wsis_frm_encode_subject');
function wsis_frm_encode_subject(){
return false;
}
View gist:9dfe4aaaaa24e1294da6
// Change WooCommerce username to emailaddress, see https://gist.github.com/Willem-Siebe/9dfe4aaaaa24e1294da6.
add_filter('woocommerce_new_customer_data','wsis_change_wc_username');
function wsis_change_wc_username($user_data) {
return array(
'user_login' => $user_data['user_email'],
'user_pass' => $user_data['user_pass'],
'user_email' => $user_data['user_email'],
'role' => 'customer');