New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin still not working with Genesis child themes #5

Open
paaljoachim opened this Issue Aug 24, 2015 · 18 comments

Comments

Projects
None yet
7 participants
@paaljoachim

paaljoachim commented Aug 24, 2015

I posted the following at the studiopress forum (some time ago):

Hey

I was trying to get the Featured Video Plus plugin https://wordpress.org/plugins/featured-video-plus/
to work with my child theme but it did not function. I e-mailed the author and he told me the following:

The automatic featured image replacement does not work for all themes – the Genesis Framework being one of them (there are many requests for this in the forum). I already was in touch with the developer but they do not intend to change their propitiatory API (they do not use WordPress’ native API).

How would we get the plugin to work with Genesis themes?

The developer is also working on the next version of Featured Video Plus which is located on Github:
https://github.com/ahoereth/featured-video-plus/tree/2.0.0


Any ideas as to what we can do about it?
What work around can be done?

Thanks.

@ahoereth

This comment has been minimized.

Show comment
Hide comment
@ahoereth

ahoereth Aug 24, 2015

Owner

I was in contact with StudioPress as well. At this point there is no way for me to hook into their framework's functionality for featured images. They do not make use of the native WordPress functions but implement their own: WordPress' functions provide ways to hook into, their's do not.
I am sorry, but it looks like this is not gonna change anytime soon.

Owner

ahoereth commented Aug 24, 2015

I was in contact with StudioPress as well. At this point there is no way for me to hook into their framework's functionality for featured images. They do not make use of the native WordPress functions but implement their own: WordPress' functions provide ways to hook into, their's do not.
I am sorry, but it looks like this is not gonna change anytime soon.

@nciske

This comment has been minimized.

Show comment
Hide comment
@nciske

nciske Aug 25, 2015

To add the featured video above the entry content (perhaps as an option if Genesis is detected?):

add_action( 'genesis_before_entry', 'prefix_add_featured_video_plus' );

function prefix_add_featured_video_plus(){
    echo do_shortcode('[featured-video-plus]');
}

What you get in the Sample theme:
https://cloudup.com/cixQ33WYZNb

If you want to replace the built in "Featured Image on Content Archives" functionality (and the child theme hasn't overridden that):

add_filter( 'genesis_pre_get_image', 'featured_video_plus_genesis_override', 10, 2 );

function featured_video_plus_genesis_override( $output, $args, $post ){

    // only act on archive featured images
    if( $args['context'] == 'archive' && has_post_video( $post->ID ) ){
        return do_shortcode('[featured-video-plus]');
    }else{
        return $output;
    }

}

YMMV with other Genesis child themes, but this covers the Genesis core functions.

Hope it helps ;-)

nciske commented Aug 25, 2015

To add the featured video above the entry content (perhaps as an option if Genesis is detected?):

add_action( 'genesis_before_entry', 'prefix_add_featured_video_plus' );

function prefix_add_featured_video_plus(){
    echo do_shortcode('[featured-video-plus]');
}

What you get in the Sample theme:
https://cloudup.com/cixQ33WYZNb

If you want to replace the built in "Featured Image on Content Archives" functionality (and the child theme hasn't overridden that):

add_filter( 'genesis_pre_get_image', 'featured_video_plus_genesis_override', 10, 2 );

function featured_video_plus_genesis_override( $output, $args, $post ){

    // only act on archive featured images
    if( $args['context'] == 'archive' && has_post_video( $post->ID ) ){
        return do_shortcode('[featured-video-plus]');
    }else{
        return $output;
    }

}

YMMV with other Genesis child themes, but this covers the Genesis core functions.

Hope it helps ;-)

@paaljoachim

This comment has been minimized.

Show comment
Hide comment
@paaljoachim

paaljoachim Sep 5, 2015

Hey Nick

I got the first code snippet to work awesome!
The second code gave a few errors when I tested in a local site with DeskTop Server and the Genesis Sample theme.

call_user_func_array:{/Users/joachim/Documents/Websites/newsite.dev/wp-includes/plugin.php:503} ( )

call_user_func_array:{/Users/joachim/Documents/Websites/newsite.dev/wp-includes/widgets.php:1319} ( )

call_user_func_array:{/Users/joachim/Documents/Websites/newsite.dev/wp-includes/plugin.php:213} ( )

But the main thing is that the first code snippet works great!
Thank you very much for the code Nick!

paaljoachim commented Sep 5, 2015

Hey Nick

I got the first code snippet to work awesome!
The second code gave a few errors when I tested in a local site with DeskTop Server and the Genesis Sample theme.

call_user_func_array:{/Users/joachim/Documents/Websites/newsite.dev/wp-includes/plugin.php:503} ( )

call_user_func_array:{/Users/joachim/Documents/Websites/newsite.dev/wp-includes/widgets.php:1319} ( )

call_user_func_array:{/Users/joachim/Documents/Websites/newsite.dev/wp-includes/plugin.php:213} ( )

But the main thing is that the first code snippet works great!
Thank you very much for the code Nick!

@braddalton

This comment has been minimized.

Show comment
Hide comment
@braddalton
Contributor

braddalton commented Sep 6, 2015

@braddalton

This comment has been minimized.

Show comment
Hide comment
@braddalton

braddalton Sep 6, 2015

Contributor

@nciske Comes from Automatic so i assume its spot on.
@paaljoachim Tested this and it works when the plugin is activate and deactivated.

add_filter( 'genesis_pre_get_image', 'featured_video_plus_genesis_override', 10, 2 );
function featured_video_plus_genesis_override( $output, $args ){
    // only act on archive featured images
    if( $args['context'] == 'archive' && function_exists('has_post_video') && has_post_video() ) {
        return the_post_video();
    } else {
        return $output;
    }
}
Contributor

braddalton commented Sep 6, 2015

@nciske Comes from Automatic so i assume its spot on.
@paaljoachim Tested this and it works when the plugin is activate and deactivated.

add_filter( 'genesis_pre_get_image', 'featured_video_plus_genesis_override', 10, 2 );
function featured_video_plus_genesis_override( $output, $args ){
    // only act on archive featured images
    if( $args['context'] == 'archive' && function_exists('has_post_video') && has_post_video() ) {
        return the_post_video();
    } else {
        return $output;
    }
}
@nciske

This comment has been minimized.

Show comment
Hide comment
@nciske

nciske Sep 6, 2015

I stand corrected, thanks for pointing that out @braddalton.

Here's a way to have your shortcode, without the overhead: https://gist.github.com/nciske/3b186cbc91b48d685679

nciske commented Sep 6, 2015

I stand corrected, thanks for pointing that out @braddalton.

Here's a way to have your shortcode, without the overhead: https://gist.github.com/nciske/3b186cbc91b48d685679

@braddalton

This comment has been minimized.

Show comment
Hide comment
@braddalton

braddalton Sep 6, 2015

Contributor

Good stuff @nciske. Are you going to add that to the plugin? Looks like it didn't make it into core.

So we use something like this via the child themes functions file:

add_filter( 'genesis_pre_get_image', 'featured_video_plus_genesis_override', 10, 2 );
function featured_video_plus_genesis_override( $output, $args ){
    if( $args['context'] == 'archive' && function_exists('has_post_video') && has_post_video()) {
        return run_shortcode( 'featured-video-plus' );
    } else {
        return $output;
    }
}
Contributor

braddalton commented Sep 6, 2015

Good stuff @nciske. Are you going to add that to the plugin? Looks like it didn't make it into core.

So we use something like this via the child themes functions file:

add_filter( 'genesis_pre_get_image', 'featured_video_plus_genesis_override', 10, 2 );
function featured_video_plus_genesis_override( $output, $args ){
    if( $args['context'] == 'archive' && function_exists('has_post_video') && has_post_video()) {
        return run_shortcode( 'featured-video-plus' );
    } else {
        return $output;
    }
}
@ahoereth

This comment has been minimized.

Show comment
Hide comment
@ahoereth

ahoereth Sep 6, 2015

Owner

Thanks for investigating! I will probably include this in the next update.

Instead of do_shortcode or run_shortcode you can use the following:

return get_the_post_video();
Owner

ahoereth commented Sep 6, 2015

Thanks for investigating! I will probably include this in the next update.

Instead of do_shortcode or run_shortcode you can use the following:

return get_the_post_video();
@ahoereth

This comment has been minimized.

Show comment
Hide comment
@ahoereth

ahoereth Sep 7, 2015

Owner

So I just looked into this and am not so sure if I will actually implement this. The problem I see is that the genesis_pre_get_image filter does a lot more than just filter post thumbnails / featured images - it actually filters all images. You bypassed this by checking the context, but people might choose to show a lot more than a single picture in their post archives.

Owner

ahoereth commented Sep 7, 2015

So I just looked into this and am not so sure if I will actually implement this. The problem I see is that the genesis_pre_get_image filter does a lot more than just filter post thumbnails / featured images - it actually filters all images. You bypassed this by checking the context, but people might choose to show a lot more than a single picture in their post archives.

ahoereth added a commit that referenced this issue Sep 7, 2015

ahoereth added a commit that referenced this issue Sep 7, 2015

ahoereth added a commit that referenced this issue Sep 7, 2015

@braddalton

This comment has been minimized.

Show comment
Hide comment
@braddalton

braddalton Sep 8, 2015

Contributor

Agree. I wouldn't add a genesis filter as it's not a genesis specific plugin and you're going to find it won't work in all cases. If you wanted to make a genesis specific plugin for featured videos, you could check out the genesis featured posts widget included in genesis as a starting point.

Contributor

braddalton commented Sep 8, 2015

Agree. I wouldn't add a genesis filter as it's not a genesis specific plugin and you're going to find it won't work in all cases. If you wanted to make a genesis specific plugin for featured videos, you could check out the genesis featured posts widget included in genesis as a starting point.

@electricbrick

This comment has been minimized.

Show comment
Hide comment
@electricbrick

electricbrick Sep 18, 2015

I got a featured image conditional working for single entries as well.

https://gist.github.com/electricbrick/0489819352c8fe04830e

electricbrick commented Sep 18, 2015

I got a featured image conditional working for single entries as well.

https://gist.github.com/electricbrick/0489819352c8fe04830e

@braddalton

This comment has been minimized.

Show comment
Hide comment
@braddalton

braddalton Sep 19, 2015

Contributor

Hello Tom

Wouldn't you use

add_action('genesis_before_entry','your_function');

rather than

add_filter
Contributor

braddalton commented Sep 19, 2015

Hello Tom

Wouldn't you use

add_action('genesis_before_entry','your_function');

rather than

add_filter
@electricbrick

This comment has been minimized.

Show comment
Hide comment
@electricbrick

electricbrick Sep 21, 2015

Thanks, Brad. Both work, actually, but I'm inferring that it's a best-practice to use add_action?

electricbrick commented Sep 21, 2015

Thanks, Brad. Both work, actually, but I'm inferring that it's a best-practice to use add_action?

@braddalton

This comment has been minimized.

Show comment
Hide comment
@braddalton

braddalton Sep 21, 2015

Contributor

I think so unless you're using a filter to modify an existing function.

Contributor

braddalton commented Sep 21, 2015

I think so unless you're using a filter to modify an existing function.

@pseudomac

This comment has been minimized.

Show comment
Hide comment
@pseudomac

pseudomac Oct 2, 2015

Hi,
About the problem size video with new version of Featured Video Plus 2.2.2 and Genesis Framework
Perhaps I have found a possible solution, a working demo at this link: http://demotest.pseudoclasse.com/
Genesis Framework + Child sample
Plugin: Feature Video Plus, version 2.2.2
In Media settings: "Apply display mode": when viewing single posts and pages.

  1. In the file functions.php I add the following code: https://gist.github.com/electricbrick/0489819352c8fe04830e
  2. In Feature Video Plus, I opened the file: frontend.min.js and I replaced, from line 225 to line 229 (preload images), the previous version (2.2.0) from line 213 to line 215.

In short, frontend.min.js (NOT minify for practical reasons)

    // preload images
//    [fvpdata.playicon, fvpdata.loadicon].forEach(function(val) {
//      $('body').append($('<img/>', {src: val, alt: 'preload image'}).hide());
//    });
//  });
//})(jQuery);

// replaced from old version
    initFeaturedVideoPlus();
  });
})(jQuery);

screenshot showing the problem: http://i.imgur.com/mcVRntA.jpg
a demo site, to verify: link removed

My question is: do you think I have done a foolish thing?
Do you think it is acceptable as a solution?
If you consider that my change is unacceptable, no problem telling me.
I have contacted the author of Featured Video Plus.

pseudomac commented Oct 2, 2015

Hi,
About the problem size video with new version of Featured Video Plus 2.2.2 and Genesis Framework
Perhaps I have found a possible solution, a working demo at this link: http://demotest.pseudoclasse.com/
Genesis Framework + Child sample
Plugin: Feature Video Plus, version 2.2.2
In Media settings: "Apply display mode": when viewing single posts and pages.

  1. In the file functions.php I add the following code: https://gist.github.com/electricbrick/0489819352c8fe04830e
  2. In Feature Video Plus, I opened the file: frontend.min.js and I replaced, from line 225 to line 229 (preload images), the previous version (2.2.0) from line 213 to line 215.

In short, frontend.min.js (NOT minify for practical reasons)

    // preload images
//    [fvpdata.playicon, fvpdata.loadicon].forEach(function(val) {
//      $('body').append($('<img/>', {src: val, alt: 'preload image'}).hide());
//    });
//  });
//})(jQuery);

// replaced from old version
    initFeaturedVideoPlus();
  });
})(jQuery);

screenshot showing the problem: http://i.imgur.com/mcVRntA.jpg
a demo site, to verify: link removed

My question is: do you think I have done a foolish thing?
Do you think it is acceptable as a solution?
If you consider that my change is unacceptable, no problem telling me.
I have contacted the author of Featured Video Plus.

@jdaviescoates

This comment has been minimized.

Show comment
Hide comment
@jdaviescoates

jdaviescoates Jun 16, 2016

I managed to get it working (i.e. featured video replaced featured image on single posts and archives) by adding this to my functions.php file and then unchecking 'Include the Featured Image?' in Genesis -> Theme Settings > Content Archives

//* Code to Display Featured Image (and therefore featured video embed) 
add_action( 'genesis_before_entry_content', 'featured_post_image', 8 );
function featured_post_image() {
  if ( is_singular( 'archive' ) )  return;
    the_post_thumbnail('post-image');
}

jdaviescoates commented Jun 16, 2016

I managed to get it working (i.e. featured video replaced featured image on single posts and archives) by adding this to my functions.php file and then unchecking 'Include the Featured Image?' in Genesis -> Theme Settings > Content Archives

//* Code to Display Featured Image (and therefore featured video embed) 
add_action( 'genesis_before_entry_content', 'featured_post_image', 8 );
function featured_post_image() {
  if ( is_singular( 'archive' ) )  return;
    the_post_thumbnail('post-image');
}
@electricbrick

This comment has been minimized.

Show comment
Hide comment
@electricbrick

electricbrick Jun 16, 2016

@pseudomac Is this still a problem? Somehow I missed your reply, and haven't encountered it myself.

electricbrick commented Jun 16, 2016

@pseudomac Is this still a problem? Somehow I missed your reply, and haven't encountered it myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment