Same Issue as: code deprecated in Functions.php

Home Forums Calendar Products Events Calendar PRO Same Issue as: code deprecated in Functions.php

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1296972
    Robert Safran
    Participant

    I updated to release 4.5.4 of the The Events Calendar and version 4.4.10 of The Events Calendar Pro in preparation for the WordPress 4.8 version that flywheel is forcing on me by June 22nd. I’m getting errors:

    Notice: Undefined variable: event in /www/wp-content/themes/sharewisdom/functions.php on line 1388 Notice: /www/wp-content/plugins/the-events-calendar/src/deprecated/TribeEvents.php is deprecated since version 3.10! Use Tribe__Events__Main instead. in /www/wp-includes/functions.php on line 3959

    Any help appreciated.
    Thanks…

    #1297199
    Robert Safran
    Participant

    I updated all occurrences of TribeEvents in my custom functions.php file with Tribe__Events__Main and it didn’t make any difference. Not sure what else I can do.

    Here’s the function that includes line 1388 which is the if ($event ) {

    function episode_cat_sb() {
    ob_start();
    $event_cat_ids = array();
    if ( $event ) {
    $event_cats = wp_get_object_terms( $event->ID, Tribe__Events__Main::TAXONOMY );
    foreach ( $event_cats as $event_cat ) {
    $event_cat_ids[] = $event_cat->term_id;
    }
    } else {
    $event_cats = array();
    }
    $args = array(
    ‘hide_empty’ => false,
    ‘orderby’ => ‘name’,
    ‘order’ => ‘ASC’,
    ‘exclude’ => $event_cat_ids,
    );

    $cats = get_terms( TribeEvents::TAXONOMY, $args );
    $cats = array_merge( $event_cats, $cats );
    $cats = apply_filters( ‘tribe_community_events_event_categories’, $cats );

    echo ‘<div class=”sidebar_episode_categories_list”>’;

    foreach ($cats as $cat) {
    echo ‘<div class=”sidebar_episode”><a href=”‘;
    echo home_url();
    echo ‘/episodes/category/’.esc_attr($cat->slug).’/?tribe_paged=1&tribe_event_display=past”‘;
    echo ‘>’.esc_attr($cat->slug).’</div>’; }

    echo ‘</div>’;

    return ob_get_clean();

    }

    #1297640
    Robert Safran
    Participant

    My wonderful web developer resolved all the issues in our functions.php file. All is working now on WordPress 4.8.

    #1298126
    Andras
    Keymaster

    Robert, that is great to hear! Sounds like you have an awesome developer at hand, congrats!

    Could you share what was the solution he implemented? It might be useful for others searching the forum.

    Thanks and cheers,
    Andras

    #1298159
    Robert Safran
    Participant

    This second functions snippet contains the modifications from my developer.

    /*Original function*/
    function episode_cat_sb() {
    ob_start();
    $event_cat_ids = array();
    if ( $event ) {
    $event_cats = wp_get_object_terms( $event->ID, TribeEvents::TAXONOMY );
    foreach ( $event_cats as $event_cat ) {
    $event_cat_ids[] = $event_cat->term_id;
    }
    } else {
    $event_cats = array();
    }
    $args = array(
    ‘hide_empty’ => false,
    ‘orderby’ => ‘name’,
    ‘order’ => ‘ASC’,
    ‘exclude’ => $event_cat_ids,
    );

    $cats = get_terms( TribeEvents::TAXONOMY, $args );
    $cats = array_merge( $event_cats, $cats );
    $cats = apply_filters( ‘tribe_community_events_event_categories’, $cats );

    echo ‘<div class=”sidebar_episode_categories_list”>’;

    foreach ($cats as $cat) {
    echo ‘<div class=”sidebar_episode”><a href=”‘;
    echo home_url();
    echo ‘/episodes/category/’.esc_attr($cat->slug).’/?tribe_paged=1&tribe_event_display=past”‘;
    echo ‘>’.esc_attr($cat->slug).’</div>’; }

    echo ‘</div>’;

    return ob_get_clean();

    }

    /*The new working function*/
    function episode_cat_sb() {
    ob_start();
    $event_cat_ids = array();
    $event = array();
    if ( $event ) {
    $event_cats = wp_get_object_terms( $event->ID, Tribe__Events__Main::TAXONOMY );
    foreach ( $event_cats as $event_cat ) {
    $event_cat_ids[] = $event_cat->term_id;
    }
    } else {
    $event_cats = array();
    }
    $args = array(
    ‘hide_empty’ => false,
    ‘orderby’ => ‘name’,
    ‘order’ => ‘ASC’,
    ‘exclude’ => $event_cat_ids,
    );

    $cats = get_terms( Tribe__Events__Main::TAXONOMY, $args );
    $cats = array_merge( $event_cats, $cats );
    $cats = apply_filters( ‘tribe_community_events_event_categories’, $cats );

    echo ‘<div class=”sidebar_episode_categories_list”>’;

    foreach ($cats as $cat) {
    echo ‘<div class=”sidebar_episode”><a href=”‘;
    echo home_url();
    echo ‘/episodes/category/’.esc_attr($cat->slug).’/?tribe_paged=1&tribe_event_display=past”‘;
    echo ‘>’.esc_attr($cat->slug).’</div>’; }

    echo ‘</div>’;

    return ob_get_clean();

    }

    #1298828
    Andras
    Keymaster

    Awesome Robert, thanks a lot for sharing!

    Since the issue is resolved I am going to close this ticket, but if you need anything else related to this topic or another please post a new one in the forum and we will be happy to help you out.

    Cheers,
    Andras

    PS: If you like our plugins, and you didn’t yet do so 🙂 we would be happy to receive a review in the wordpress.org repository. Thanks!
    https://wordpress.org/support/plugin/the-events-calendar/reviews/

    PS2: We’d be also grateful if you would give us feedback on your satisfaction with support. Just click on one of the classy looking emojis below. 🙂 If you can spare a few words, that’s even better. Doublethanks!

     

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Same Issue as: code deprecated in Functions.php’ is closed to new replies.