Override Block Editor Palette Colors

add_filter( ‘wp_theme_json_data_theme’, function ( $theme_json ) { $new_data = array( ‘settings’ => array( ‘color’ => array( ‘palette’ => array( // Replace with your desired colors. array( ‘slug’ => ‘white’, ‘color’ => ‘#ffffff’, ‘name’ => ‘White’, ), array( ‘slug’ => ‘black’,…Continue reading

Reorder Admin Menu Items

add_filter( ‘custom_menu_order’, ‘__return_true’ ); // This will move the WPCode menu under the Dashboard menu item. // Uncomment and add more items as needed. add_filter( ‘menu_order’, function () { return array( ‘index.php’, ‘wpcode’, // ‘edit.php’, // Posts // ‘upload.php’, //…Continue reading

Disable Specific Blocks

add_filter( ‘allowed_block_types_all’, function ( $allowed_block_types, $block_editor_context ) { // List here the blocks you want to disallow. https://developer.wordpress.org/block-editor/reference-guides/core-blocks/ $disallowed_blocks = array( ‘core/navigation’, ‘core/query’, ); if ( ! is_array( $allowed_block_types ) || empty( $allowed_block_types ) ) { $registered_blocks = WP_Block_Type_Registry::get_instance()->get_all_registered(); $allowed_block_types…Continue reading

Maintenance Mode

add_action( ‘init’, function() { if ( ! current_user_can( ‘manage_options’ ) && ! is_admin() && ! is_login() ) { wp_die( ‘This website is currently undergoing scheduled maintenance. Please try again later.’ ); } } );Continue reading

Add ID column in admin tables

add_action( ‘admin_init’, function () { // Get all public post types $post_types = get_post_types( array(), ‘names’ ); function wpcode_add_post_id_column( $columns ) { $columns[‘wpcode_post_id’] = ‘ID’; // ‘ID’ is the column title return $columns; } function wpcode_show_post_id_column_data( $column, $post_id ) {…Continue reading

Post Meta Debugger

add_action( ‘add_meta_boxes’, function () { if ( ! current_user_can( ‘manage_options’ ) ) { // Don’t display the metabox to users who can’t manage options return; } add_meta_box( ‘wpcode-view-post-meta’, ‘Post Meta’, function () { $custom_fields = get_post_meta( get_the_ID() ); ?> Meta…Continue reading