WordPress.org

Ready to get started?Download WordPress

Forums

Featured Video Plus
[resolved] Hook into admin area? (4 posts)

  1. jleo2255
    Member
    Posted 1 year ago #

    It seems I can only use the has_post_video function in the loop. Is there a way I can use this in the admin area as well? That way I can check if a post has a video and update info on an admin page accordingly?

    This is a fantastic and well thought out plugin btw.

    http://wordpress.org/extend/plugins/featured-video-plus/

  2. jleo2255
    Member
    Posted 1 year ago #

    Nevermind. It's late and I wasn't thinking about what my functions.php file could/couldn't reference. For anyone with the same prob, just add this to your functions.php file:

    function has_post_video($post_id = null){

    global $post;

    if($post_id == null)
    $post_id = $GLOBALS['post']->ID;

    $meta = unserialize( get_post_meta( $post_id, '_fvp_video', true ) );

    if( !isset($meta) || empty($meta['id']) )
    return false;

    return true;

    }

    It seems the other functions should work similarly well.

    Thank you very much for this plugin, sir. 5 stars!

  3. jleo2255
    Member
    Posted 1 year ago #

    Sorry, one last thing. In the above code you will want to suffix any function re-used on the admin side so it isn't re-declared. Ex.

    function has_post_video_admin($post_id = null){

    global $post;

    if($post_id == null)
    $post_id = $GLOBALS['post']->ID;

    $meta = unserialize( get_post_meta( $post_id, '_fvp_video', true ) );

    if( !isset($meta) || empty($meta['id']) )
    return false;

    return true;

    }

  4. Alexander Hoereth
    Member
    Plugin Author

    Posted 1 year ago #

    You did the right thing, the has_post_video-function is just available on the front end. Did not think about someone wanting to embed the plugin more deeply into the WordPress Admin interface. But you are right, maybe I should open it up for front- & backend. I will consider this for the next version, thanks!

    If someone uses the approach described above, please use a suffix or prefix as described in #3. This way the function won't get in conflict with a feature release.

    PS: Thanks for the rating!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic