Skip to content

Commit

Permalink
Merge pull request #7712 from Automattic/remove/obsolete-workaround
Browse files Browse the repository at this point in the history
Remove obsolete code
  • Loading branch information
donnapep authored Dec 2, 2024
2 parents e6bf3b1 + ce8cf09 commit 523486d
Showing 1 changed file with 0 additions and 41 deletions.
41 changes: 0 additions & 41 deletions includes/class-sensei-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ public function __construct() {
// remove a course from course order when trashed
add_action( 'transition_post_status', array( $this, 'remove_trashed_course_from_course_order' ) );

// Add workaround for block editor bug on CPT pages. See the function doc for more information.
add_action( 'admin_footer', array( $this, 'output_cpt_block_editor_workaround' ) );

// Add AJAX endpoint for event logging.
add_action( 'wp_ajax_sensei_log_event', array( $this, 'ajax_log_event' ) );

Expand Down Expand Up @@ -1749,44 +1746,6 @@ public function notify_if_admin_email_not_real_admin_user() {
}
}

/**
* Adds a workaround for fixing an issue with CPT's in the block editor.
*
* See https://github.com/WordPress/gutenberg/pull/15375
*
* Once that PR makes its way into WP Core, this function (and its
* attachment to the action in `__construct`) can be removed.
*
* @access private
*
* @since 2.1.0
*/
public function output_cpt_block_editor_workaround() {
$screen = get_current_screen();

if ( ! ( method_exists( $screen, 'is_block_editor' ) && $screen->is_block_editor() ) ) {
return;
}

?>
<script type="text/javascript">
jQuery( document ).ready( function() {
if ( wp.apiFetch ) {
wp.apiFetch.use( function( options, next ) {
let url = options.path || options.url;
if ( 'POST' === options.method && wp.url.getQueryArg( url, 'meta-box-loader' ) ) {
if ( options.body instanceof FormData && 'undefined' === options.body.get( 'post_author' ) ) {
options.body.delete( 'post_author' );
}
}
return next( options );
} );
}
} );
</script>
<?php
}

/**
* Attempt to log a Sensei event.
*
Expand Down

0 comments on commit 523486d

Please sign in to comment.