Student Post Existence Check

// Check if the current user already has a “student” post $args = array( ‘author’ => get_current_user_id(), ‘post_type’ => ‘student’, ‘posts_per_page’ => -1, // Retrieve all posts ‘order’ => ‘DESC’, // Order by most recent post first ); $student_posts =…Continue reading

Allow ICO files upload

add_filter( ‘upload_mimes’, function ( $mimes ) { // By default, only administrator users are allowed to add ICO files. // To enable more user types edit or comment the lines below but beware of // the security risks if you…Continue reading

Pin Headline Analyzer

add_action( ‘admin_enqueue_scripts’, ‘aioseo_editor_pin_styles’ ); function aioseo_editor_pin_styles() { $custom_css = ‘@media (min-width: 782px){.interface-complementary-area-header .components-button.has-icon { display: flex !important; }}’; wp_add_inline_style( ‘wp-edit-post’, $custom_css ); }Continue reading

Make Product Non Purchasable for Wholesale Customer if Product Stock is Less Than Certain Amount

/* Make Product Non Purchasable for Wholesale Customer Iif Product Stock is Less Than X Amount */ add_filter( ‘woocommerce_is_purchasable’, ‘wwpp_limit_purchase_based_on_stock’, 10, 2 ); function wwpp_limit_purchase_based_on_stock( $is_purchasable, $product ) { //Get Product Stock Quantity $product_quantity = $product->get_stock_quantity(); //Get current user’s wholesale…Continue reading

Setting default template for post type

/** * Setting default template for post type as a pattern php file * */ function awesome_register_podcast_template() { $post_type_object = get_post_type_object( ‘podcast’ ); $post_type_object->template = array( array( ‘core/pattern’, array( ‘slug’ => ‘vivek/podcast-audio’, ) ), ); } add_action( ‘init’, ‘awesome_register_podcast_template’ );Continue reading

Loading ACF Blocks from theme

/** * Load Blocks */ function load_blocks() { $theme = wp_get_theme(); $blocks = get_blocks(); foreach( $blocks as $block ) { if ( file_exists( get_template_directory() . ‘/blocks/’ . $block . ‘/block.json’ ) ) { register_block_type( get_template_directory() . ‘/blocks/’ . $block .…Continue reading

Force nwwp Colour Scheme

add_action( ‘admin_init’, function() { // remove the color scheme picker remove_action( ‘admin_color_scheme_picker’, ‘admin_color_scheme_picker’ ); // force all users to use the “Ectoplasm” color scheme add_filter( ‘get_user_option_admin_color’, function() { return ‘nwwp’; }); });Continue reading