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

Format USD Currency

function pw_edd_custom_currency_format( $formatted, $currency, $price ) { return $price . ‘ USD’; } add_filter( ‘edd_usd_currency_filter_before’, ‘pw_edd_custom_currency_format’, 10, 3 ); add_filter( ‘edd_usd_currency_filter_after’, ‘pw_edd_custom_currency_format’, 10, 3 );Continue reading

Change user role for buyers

function ao_edd_set_customer_role( $payment_id ) { $email = edd_get_payment_user_email( $payment_id ); $downloads = edd_get_payment_meta_downloads( $payment_id ); $user_id = edd_get_payment_user_id( $payment_id ); if( $user_id ) { $user = new WP_User( $user_id ); // Add role $user->add_role( ‘buyer’ ); } } add_action( ‘edd_complete_purchase’,…Continue reading

Allow SVG Files Upload (copy)

/** * Allow SVG uploads for administrator users. * * @param array $upload_mimes Allowed mime types. * * @return mixed */ add_filter( ‘upload_mimes’, function ( $upload_mimes ) { // By default, only administrator users are allowed to add SVGs. //…Continue reading

Admin Bar – Updates (copy)

function add_updates_admin_bar_menu() { global $wp_admin_bar; $wp_admin_bar->add_menu( array( ‘id’ => ‘updates’, ‘title’ => ‘Updates’, ‘href’ => admin_url( ‘update-core.php’ ), ‘parent’ => ‘top-secondary’, ) ); } add_action( ‘wp_before_admin_bar_render’, ‘add_updates_admin_bar_menu’ );Continue reading