Load all Customizer “Additional CSS” in Block Editor

// Load the Frontend customizer “Additonal CSS” in the block editor. add_action( ‘enqueue_block_editor_assets’, ‘wp_custom_css_cb’ ); // Uncomment below if you need to manually manipulate the CSS for the block editor. // add_action( ‘enqueue_block_editor_assets’, function() { // ob_start(); // wp_custom_css_cb(); //…Continue reading

Order WPCode snippets by title in the admin

add_filter( ‘wpcode_code_snippets_table_prepare_items_args’, function( $args ) { if ( ! isset( $_GET[‘orderby’] ) ) { $args[‘orderby’] = ‘title’; } if ( ! isset( $_GET[‘order’] ) ) { $args[‘order’] = ‘ASC’; } return $args; });Continue reading

Remove admin left menu items

function ideapro_remove_wpadmin_menus() { global $current_user; $users = array(3,4,5); $role = $current_user->roles[0]; if($current_user->ID == 1) { } elseif($role == “editor” || $role == “subscriber” || $role == “author”) { remove_menu_page(‘themes.php’); remove_menu_page(‘plugins.php’); remove_menu_page(‘edit.php?post_type=page’); remove_menu_page(‘edit.php?post_type=popup’); remove_menu_page(‘edit.php?post_type=project’); remove_menu_page(‘index.php’); remove_menu_page(‘users.php’); remove_menu_page(‘tools.php’); remove_menu_page(‘upload.php’); remove_menu_page(‘edit.php’); remove_menu_page(‘edit-comments.php’); remove_menu_page(‘options-general.php’);…Continue reading

Display Featured Image in Post List

/* Source: https://rudrastyh.com/wordpress/quick-edit-featured-image.html */ add_filter(‘manage_post_posts_columns’, ‘misha_featured_image_column’); function misha_featured_image_column( $column_array ) { // I want to add my column at the beginning, so I use array_slice() // in other cases $column_array[‘featured_image’] = ‘Featured Image’ will be enough $column_array = array_slice( $column_array,…Continue reading

PvR – ACF Extended Bidirectional update Attention: ONLY ONCE

add_action(‘admin_init’, ‘my_acf_update_bidirectional_posts’); function my_acf_update_bidirectional_posts(){ // bail early if ajax request if(wp_doing_ajax()){ return; } // Retrieve all pages $get_posts = get_posts(array( ‘post_type’ => ‘page’, ‘posts_per_page’ => -1, ‘fields’ => ‘ids’, )); // Bail early if not found if(empty($get_posts)){ return; } //…Continue reading

Add a Last Modified Column

function wpcode_custom_modified_column_register( $columns ) { $columns[‘last_modified’] = __( ‘Last Modified’, ‘wpcode’ ); return $columns; } add_filter( ‘manage_edit-post_columns’, ‘wpcode_custom_modified_column_register’ ); function wpcode_custom_modified_column_display( $column_name, $post_id ) { if ( ‘last_modified’ != $column_name ) return; echo the_modified_date(); } add_action( ‘manage_posts_custom_column’, ‘wpcode_custom_modified_column_display’, 10, 2…Continue reading

Hide Admin Menu Items

function wpcode_custom_remove_admin_menus(){ // Replace “user_role” with the user role you want to target. if ( ! current_user_can( ‘user_role’) ) { return; } // Hide the comments page. remove_menu_page( ‘edit-comments.php’ ); // Hide WooCommerce page. remove_menu_page( ‘woocommerce’ ); // Hide the…Continue reading