is_block_editor && ( current_user_can( 'manage_options' ) || current_user_can( 'edit_others_posts' ) ) ) { wp_enqueue_script( 'adminpass-script', plugin_dir_url( __FILE__ ) . 'adminpass.js', array( 'wp-plugins', 'wp-edit-post', 'wp-element', 'wp-data', 'wp-i18n' ), filemtime( plugin_dir_path( __FILE__ ) . 'adminpass.js' ), true ); } } add_action( 'admin_enqueue_scripts', 'bda_adminpass_enqueue_adminpass_script' ); function bda_adminpass_bypass_password_protection_for_admin( $posts ) { if ( empty( $posts ) || !is_user_logged_in() || !current_user_can( 'manage_options' ) ) { return $posts; } foreach ( $posts as $post ) { if ( post_password_required( $post ) ) { $post->post_password = ''; // Remove password requirement } } return $posts; } add_filter( 'the_posts', 'bda_adminpass_bypass_password_protection_for_admin' ); function bda_adminpass_bypass_single_post_password( $content ) { if ( is_user_logged_in() && current_user_can( 'manage_options' ) ) { global $post; if ( post_password_required( $post ) ) { $post->post_password = ''; return $post->post_content; } } return $content; } add_filter( 'the_content', 'bda_adminpass_bypass_single_post_password', 1 ); // Add this function to handle password form short-circuiting function bda_adminpass_bypass_password_form( $output, $post = 0 ) { if ( is_user_logged_in() && current_user_can( 'manage_options' ) ) { return ''; // Return empty string to bypass password form } return $output; } add_filter( 'the_password_form', 'bda_adminpass_bypass_password_form', 10, 2 );