WordPress.org

Ready to get started?Download WordPress

Forums

Image Credits
[resolved] Error on function or do_shortcode (10 posts)

  1. paer
    Member
    Posted 1 year ago #

    I tried to add a the function get_image_credits(); on a post, but I got this message:

    Fatal error: Call to undefined function get_image_credits() in /.../wp-content/themes/.../content-meta.php on line 9

    Later I tried do_shortcode('[image-credits]') and it worked, but I got this error message as well:

    Warning: Wrong parameter count for in_array() in /.../wp-content/plugins/image-credits/plugin.php on line 137

    Does anyone have an idea to fix this?

    http://wordpress.org/extend/plugins/image-credits/

  2. paer
    Member
    Posted 1 year ago #

    I'm still lost with this problem. Does anyone else experience the same problems?

  3. paer
    Member
    Posted 1 year ago #

    I found a simple solution, but only works by using do_shortcode:
    <?php echo do_shortcode('[image-credits]') ?>

    Just exclude "in_array" On line 137 of file plugin.php. See example:

    if ( !empty( $source_name ) && !empty( $source_url ) /*&& !in_array( $source_url, $source_urls )*/ ) {

    Until now, I haven't discovered any bugs yet. Fingers crossed ;-)

  4. thatwastaxing
    Member
    Posted 12 months ago #

    I have this problem too:

    Warning: in_array() expects parameter 2 to be array, null given in C:\xampp\htdocs\testsite\wp-content\plugins\image-credits\plugin.php on line 137

  5. paer
    Member
    Posted 12 months ago #

    Did u comment this out yet?

    /*&& !in_array( $source_url, $source_urls )*/

  6. thatwastaxing
    Member
    Posted 12 months ago #

    No because I needed the shortcode and not put inside the theme. But I just tried it (deleted, not commented out) and it works with the shortcode too! Thanks!

  7. jeremy9856
    Member
    Posted 10 months ago #

    This warning is very simple to fix

    Warning: in_array() expects parameter 2 to be array, null given in C:\xampp\htdocs\testsite\wp-content\plugins\image-credits\plugin.php on line 137

    At the line 137 add just this :
    $source_urls = array();

    Before that :

    if ( !empty( $source_name ) && !empty( $source_url ) && !in_array( $source_url, $source_urls ) ) {

  8. paer
    Member
    Posted 10 months ago #

    Thank you, this fix did it.

    But after fixing the issue on line 137, I had the same issue on line 117, too.

    So I added this:
    $attachment_ids = array();

    Before that:
    if ( in_array( $id, $attachment_ids ) )

  9. thatwastaxing
    Member
    Posted 10 months ago #

    I applied your code but now only one image credit shows up in a post where there is more than one image that has credits.

  10. Adam Capriola
    Member
    Plugin Author

    Posted 10 months ago #

    This array error will be fixed in an update to the plugin I'm uploading later today.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic