WordPress.org

Forums

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

  1. paer
    Member
    Posted 2 years 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 2 years 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 1 year 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 1 year ago #

    Did u comment this out yet?

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

  6. thatwastaxing
    Member
    Posted 1 year 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 1 year 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 1 year 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 1 year 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 1 year 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

  • Image Credits
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic