Global Setting Filter & Extenable to other posts
-
This plugin is great but as many have requested it would be great to have it globally enabled. Also in our use case we’d like video resume to also work on some other post types. We made some slight edits to the plugin for you to consider.
edit: ld-video-resume/public/class-video_resume.php
Edit #1:
replace:add_action ( 'learndash-lesson-after', array( $this ,'enqueue_js' ) );
add_action ( 'learndash-topic-after', array( $this ,'enqueue_js' ) );with:
add_action( 'wp_footer', array( $this ,'enqueue_js' ) );
NOTE: this way the code could fire on more post types. Perhaps there is a better way to do this.
Edit #2:
replace:if ( ! isset( $post->post_type ) || ! in_array($post->post_type, array( 'sfwd-lessons', 'sfwd-topic' ) ) ) {
return;
}
with:$video_post_types = array( 'sfwd-lessons', 'sfwd-topic' );
$video_post_types = apply_filters( 'video_resume_post_types', $video_post_types );
if ( ! isset( $post->post_type ) || ! in_array($post->post_type, $video_post_types ) ) {
return;
}NOTE: This allows the post types to be filtered like this:
add_filter('video_resume_post_types','custom_video_resume_post_types',10);
function custom_video_resume_post_types($post_types){
$post_types[] = 'project';
$post_types[] = 'page';
return $post_types;
}Edit #3:
below line:$video_provider = get_post_meta( $post->ID, 'video_resume_provider', true );
add line:$video_provider = apply_filters( 'video_resume_provider', $video_provider, $post->ID, $post );
NOTE: This allows the provider to be globally or conditionally set like this:
add_filter('video_resume_provider','custom_video_resume_provider',10,3);
function custom_video_resume_provider($provider, $postID, $post){
if( ($postID == '20433') && ($post->post_type == 'page')){
$provider = 'vimeo';
} elseif( $post->post_type != 'page' ){
$provider = 'vimeo';
}
return $provider;
}
- The topic ‘Global Setting Filter & Extenable to other posts’ is closed to new replies.