Skip to content

Instantly share code, notes, and snippets.

@eri-trabiccolo
Created January 21, 2021 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eri-trabiccolo/f94fdc46b76a90629d7e5a84aa8dcd48 to your computer and use it in GitHub Desktop.
Save eri-trabiccolo/f94fdc46b76a90629d7e5a84aa8dcd48 to your computer and use it in GitHub Desktop.
<?php // <- do not copy this line.
/**
* This will prevent old lessons and lessons created with the course builder to have blocks added.
*/
add_filter(
'llms_blocks_should_migrate_post',
function( $ret, $post_id ) {
return $post_id && 'lesson' === get_post_type( $post_id ) ? false : $ret;
},
10,
2
);
/**
* It will, prevent lesson's template elements to be directly shown in front via hooks.
*/
add_filter(
'llms_blocks_is_post_migrated',
function( $ret, $post_id ) {
return $post_id && 'lesson' === get_post_type( $post_id ) ? true : $ret;
},
10,
2
);
/**
* This will unset the block editor template for the lessons created via wp admin Lessons -> Add New:
* block will not be added directly in the editor.
*/
add_filter(
'lifterlms_register_post_type_lesson',
function ( $lesson_type_array ) {
unset( $lesson_type_array['template'] );
return $lesson_type_array;
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment