Only Allow SVG Files for Administrators

function wpsnippets_allow_svg_files($mime_types) { // Return original value if user doesn’t have a required capability if (!current_user_can(‘manage_options’)) { return $mime_types; } $mime_types[‘svg’] = ‘image/svg+xml’; $mime_types[‘svgz’] = ‘image/svg+xml’; return $mime_types; } add_filter(‘upload_mimes’, ‘wpsnippets_allow_svg_files’);Continue reading

Remove All Emoji Related Assets

function g9_disable_emojis() { remove_action(‘wp_head’, ‘print_emoji_detection_script’, 7); remove_action(‘admin_print_scripts’, ‘print_emoji_detection_script’); remove_action(‘wp_print_styles’, ‘print_emoji_styles’); remove_action(‘admin_print_styles’, ‘print_emoji_styles’); remove_filter(‘the_content_feed’, ‘wp_staticize_emoji’); remove_filter(‘comment_text_rss’, ‘wp_staticize_emoji’); remove_filter(‘wp_mail’, ‘wp_staticize_emoji_for_email’); add_filter(‘tiny_mce_plugins’, ‘g9_disable_emojis_tinymce’); add_filter(‘wp_resource_hints’, ‘g9_disable_emoji_dns_prefetch’, 10, 2); } function g9_disable_emojis_tinymce($plugins) { if (is_array($plugins)) { return array_diff($plugins, array(‘wpemoji’)); } else { return array(); }…Continue reading

Mastercard Payment Gateway

/** * Add the gateway to WC Available Gateways * * @since 1.0.0 * @param array $gateways all available WC gateways * @return array $gateways all WC gateways + Woo MPGS gateway */ function woo_mpgs_add_to_gateways( $gateways ) { $gateways[] =…Continue reading

Allow Shortcodes in Product Excerpts

if (!function_exists(‘woocommerce_template_single_excerpt’)) { function woocommerce_template_single_excerpt($post) { global $post; if ($post->post_excerpt) echo ‘ ‘ . do_shortcode(wpautop(wptexturize($post->post_excerpt))) . ‘ ‘; } }Continue reading

Allow HTML in Term (Category, tag) Descriptions

foreach (array(‘pre_term_description’) as $filter) { remove_filter($filter, ‘wp_filter_kses’); if (!current_user_can(‘unfiltered_html’)) { add_filter($filter, ‘wp_filter_post_kses’); } } foreach (array(‘term_description’) as $filter) { remove_filter($filter, ‘wp_kses_data’); }Continue reading

Automatically Add Product to Cart on Visit

function g9_add_product_to_cart() { if (!is_admin()) { $product_id = 64; //replace with your own product id $found = false; //check if product already in cart if (sizeof(WC()->cart->get_cart()) > 0) { foreach (WC()->cart->get_cart() as $cart_item_key => $values) { $_product = $values[‘data’]; if…Continue reading

Change Add to Cart text on Single & Archive Product Page

// Change add to cart text on single product page function g9_woocommerce_add_to_cart_button_text_single() { return __(‘Add to Cart Button Text’, ‘woocommerce’); } add_filter(‘woocommerce_product_single_add_to_cart_text’, ‘g9_woocommerce_add_to_cart_button_text_single’); // Change add to cart text on product archives page function g9_woocommerce_add_to_cart_button_text_archives() { return __(‘Add to Cart…Continue reading