Support » Plugin: All-in-One Event Calendar » Fatal error: Can’t use function return value in write context in

  • hi there!

    after updating the plugin today i get this error:

    Fatal error: Can’t use function return value in write context in /home1/naamasha/public_html/wp-content/plugins/all-in-one-event-calendar/app/view/event/content.php on line 152

    what should i do?
    thanks!
    orit

Viewing 14 replies - 1 through 14 (of 14 total)
  • I am getting the same error – Fatal error: Can’t use function return value in write context in /home/iwapragu/public_html/wp-content/plugins/all-in-one-event-calendar/app/view/event/content.php on line 152.

    Need to know how to fix.

    Thanks.

    I am getting the same error after installing the update: Fatal error: Can’t use function return value in write context in /home/scoutnw/public_html/wp-content/plugins/all-in-one-event-calendar/app/view/event/content.php on line 152

    To fix this error, in the file wp-content/plugins/all-in-one-event-calendar/app/view/event/content.php
    Just after the line
    public function get_content_img_url( Ai1ec_Event $event, &$size = null ) {
    add :
    $attachment_url = wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) );
    and replace the line just after :
    $url_featured_image = ( ! empty ( wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ) ) ? wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ) : null );

    by
    $url_featured_image = ( ! empty ( $attachment_url ) ? wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ) : null );

    Nelero, thanks for this! Works great. I hope they incorporate this into future updates…!

    worked! thanks!

    This worked for me as well. THANK YOU Nelero!!!!

    Thank you, nelero.
    It has worked.

    Hi can someone explain to me part 2 of this fix?

    and replace the line just after :
    $url_featured_image = ( ! empty ( wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ) ) ? wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ) : null );

    by
    $url_featured_image = ( ! empty ( $attachment_url ) ? wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ) : null );

    I’m confused, the next line is empty space, after the empty space I have

    if ( ! empty( $url_featured_image ) ) {
    			return $url_featured_image;

    so what the heck do I replace?
    or can someone send me the modified file.
    My whole site now is down because of this plugin and I tried pasting replacing lines and things and still having this issue

    • This reply was modified 2 years, 3 months ago by  Kommy.

    This is my complete file “wp-content/plugins/all-in-one-event-calendar/app/view/event/content.php” after I made the changes.

    <?php

    /**
    * This class process event content.
    *
    * @author Time.ly Network Inc.
    * @since 2.0
    *
    * @package AI1EC
    * @subpackage AI1EC.View.Event
    */
    class Ai1ec_View_Event_Content extends Ai1ec_Base {

    /**
    * Render event excerpt header.
    *
    * @param Ai1ec_Event $event Event to render excerpt for.
    *
    * @return void Content is not returned, just rendered.
    */
    public function excerpt_view( Ai1ec_Event $event ) {
    $location = $this->_registry->get( ‘view.event.location’ );
    $location = esc_html(
    str_replace(
    “\n”,
    ‘, ‘,
    rtrim( $location->get_location( $event ) )
    )
    );
    $args = array(
    ‘event’ => $event,
    ‘location’ => $location,
    ‘text_when’ => __( ‘When:’, AI1EC_PLUGIN_NAME ),
    ‘text_where’ => __( ‘Where:’, AI1EC_PLUGIN_NAME ),
    );
    $loader = $this->_registry->get( ‘theme.loader’ );
    echo $loader->get_file(
    ‘event-excerpt.twig’,
    $args,
    true
    )->get_content();
    }

    /**
    * Format events excerpt view.
    *
    * @param string $text Content to excerpt.
    *
    * @return string Formatted event excerpt.
    */
    public function event_excerpt( $text ) {
    if ( ! $this->_registry->get( ‘acl.aco’ )->is_our_post_type() ) {
    return $text;
    }
    $event = $this->_registry->get( ‘model.event’, get_the_ID() );
    $post = $this->_registry->get( ‘view.event.post’ );
    $ob = $this->_registry->get( ‘compatibility.ob’ );
    $ob->start();
    $this->excerpt_view( $event );
    // Re-apply any filters to the post content that normally would have
    // been applied if it weren’t for our interference (below).
    echo shortcode_unautop( wpautop( $post->trim_excerpt( $event ) ) );
    return $ob->get_clean();
    }

    /**
    * Avoid re-adding wpautop for Ai1EC instances.
    *
    * @param string $content Processed content.
    *
    * @return string Paragraphs enclosed text.
    */
    public function event_excerpt_noautop( $content ) {
    if ( ! $this->_registry->get( ‘acl.aco’ )->is_our_post_type() ) {
    return wpautop( $content );
    }
    return $content;
    }

    public function get_post_excerpt( Ai1ec_Event $event ) {
    $content = strip_tags(
    strip_shortcodes(
    preg_replace(
    ‘#<\s*script[^>]*>.+<\s*/\s*script\s*>#x’,
    ”,
    apply_filters(
    ‘ai1ec_the_content’,
    apply_filters(
    ‘the_content’,
    $event->get( ‘post’ )->post_content
    )
    )
    )
    )
    );
    $content = preg_replace( ‘/\s+/’, ‘ ‘, $content );
    $words = explode( ‘ ‘, $content );
    if ( count( $words ) > 25 ) {
    return implode(
    ‘ ‘,
    array_slice( $words, 0, 25 )
    ) . ‘ […]’;
    }
    return $content;
    }

    /**
    * Generate the html for the “Calendar” button for this event.
    *
    * @return string
    */
    public function get_back_to_calendar_button_html() {
    $class = ”;
    $data_type = ”;
    $href = ”;
    if ( isset( $_COOKIE[‘ai1ec_calendar_url’] ) ) {
    $href = json_decode(
    stripslashes( $_COOKIE[‘ai1ec_calendar_url’] )
    );
    setcookie( ‘ai1ec_calendar_url’, ”, time() – 3600 );
    } else {
    $href = $this->_registry->get( ‘html.element.href’, array() );
    $href = $href->generate_href();
    }
    $text = esc_attr( Ai1ec_I18n::__( ‘Calendar’ ) );
    $tooltip = esc_attr( Ai1ec_I18n::__( ‘View all events’ ) );
    $html = <<<HTML
    <a class=”ai1ec-calendar-link ai1ec-btn ai1ec-btn-default ai1ec-btn-sm
    ai1ec-tooltip-trigger $class”
    href=”$href”
    $data_type
    data-placement=”left”
    title=”$tooltip”>
    <i class=”ai1ec-fa ai1ec-fa-calendar ai1ec-fa-fw”></i>
    <span class=”ai1ec-hidden-xs”>$text</span>

    HTML;
    return apply_filters( ‘ai1ec_get_back_to_calendar_html’, $html, $href );
    }

    /**
    * Simple regex-parse of post_content for matches of ; if
    * one is found, return its URL.
    *
    * @param null $size (width, height) array of returned image
    *
    * @return string|null
    */

    public function get_content_img_url( Ai1ec_Event $event, &$size = null ) {

    $attachment_url = wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) );

    // Try to find a featured image

    $url_featured_image = ( ! empty ( $attachment_url ) ? wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ) : null );

    if ( ! empty( $url_featured_image ) ) {
    return $url_featured_image;
    }

    preg_match(
    ‘/<img([^>]+)src=[“\’]?([^”\’\ >]+)([^>]*)>/i’,
    $event->get( ‘post’ )->post_content,
    $matches
    );
    // Check if we have a result
    if ( empty( $matches ) ) {
    return null;
    }

    // Mark found image.
    $event->get( ‘post’ )->post_content = str_replace(
    ‘<img’ . $matches[1],
    ‘<img’ . $matches[1] . ‘ data-ai1ec-hidden ‘,
    $event->get( ‘post’ )->post_content
    );

    $url = $matches[2];
    $size = array( 0, 0 );

    // Try to detect width and height.
    $attrs = $matches[1] . $matches[3];
    $matches = null;
    preg_match_all(
    ‘/(width|height)=[“\’]?(\d+)/i’,
    $attrs,
    $matches,
    PREG_SET_ORDER
    );
    // Check if we have a result, otherwise a notice is issued.
    if ( ! empty( $matches ) ) {
    foreach ( $matches as $match ) {
    $size[ $match[1] === ‘width’ ? 0 : 1 ] = $match[2];
    }
    }

    return $url;
    }

    }

    Awesome, that worked, thank you very much

    Hi @nelero,

    Thanks for posting the fix. The Development Team will address this issue as soon as possible. I apologize to all for the problems.

    Hello everyone,

    Calvin from our Development Team has fixed this issue and released it again. The problem was about an incompatibility with PHP 5.

    If anyone else has a problem please update your calendar again.

    Apologies again for the inconvenience.

    • This reply was modified 2 years, 3 months ago by  Sunny Lal.

    Can confirm that the update fixes the problem. Thanks for the quick work, Team Time.ly!

    yes, this fix has solved the problem, thank you for responding so quickly

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Fatal error: Can’t use function return value in write context in’ is closed to new replies.