Tagged: 

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #189994

    adding code to my enfold child theme functions.php file breaks my site.
    after installing the child theme, activating it, and adding code to the functions.php file, I get a whitescreen that can only be corrected by deleting the code that was added.

    The added php code works fine with no problems in the parent theme. When I activate the child theme with the same code added to the child theme’s functions.php file – the whole site breaks.

    #190284

    Hey rmatene!

    What is the actual code you are adding in?

    Best regards,
    Devin

    #190443

    The code that i’m adding is as follows, and is used to control the display of some elements from the “The Events Calendar PRO” and “Wootickets” plugin from Modern Tribe. I have followed the Enfold child theme video tutorial (yours Devin), as well as the tutorials and documentation from the Modern Tribe website with no success in getting this code to work in my child theme functions.php file.

    Latest Enfold installed, no plugins activated. As stated earlier, the added php code works fine with no problems in the parent theme fuctions.php file.

    /*
    * Move the Wootickets form to Below the Event Description
    */
    remove_action(‘tribe_events_single_event_after_the_meta’, array(TribeWooTickets::get_instance(), ‘front_end_tickets_form’));
    add_action(‘tribe_events_single_event_after_the_content’, array(TribeWooTickets::get_instance(), ‘front_end_tickets_form’));

    /*
    * Filter Modern Tribe’s The Events Calendar / Events Calendar PRO plugins to show ticket prices from the WooCommerce Tickets add-on
    */
    function my_wootickets_tribe_get_cost( $cost, $postId, $withCurrencySymbol ) {
    if ( empty($cost) && class_exists(‘TribeWooTickets’) ) {
    // see if the event has tickets associated with it
    $wootickets = TribeWooTickets::get_instance();
    $ticket_ids = $wootickets->get_Tickets_ids( $postId );
    if ( empty($ticket_ids) ) {
    return ”;
    }

    // see if any tickets remain, and what price range they have
    $max_price = 0;
    $min_price = 0;
    $sold_out = TRUE;
    foreach ( $ticket_ids as $ticket_id ) {
    $ticket = $wootickets->get_ticket($postId, $ticket_id);
    if ( $ticket->stock ) {
    $sold_out = FALSE;
    $price = $ticket->price;
    if ( $price > $max_price ) {
    $max_price = $price;
    }
    if ( empty($min_price) || $price < $min_price ) {
    $min_price = $price;
    }
    }
    }
    if ( $sold_out ) { // all of the tickets are sold out
    return __(‘Sold Out’);
    }
    if ( empty($max_price) ) { // none of the tickets costs anything
    return __(‘Free’);
    }

    // make a string showing the price (or range, if applicable)
    $currency = tribe_get_option( ‘defaultCurrencySymbol’, ‘$’ );
    if ( empty($min_price) || $min_price == $max_price ) {
    return $currency . $max_price;
    }
    return $currency . $min_price . ‘ – ‘ . $currency . $max_price;
    }
    return $cost; // return the default, if nothing above returned
    }
    add_filter( ‘tribe_get_cost’, ‘my_wootickets_tribe_get_cost’, 10, 3 );

    /*
    * Remove the iCal Import button except from Single-Event view
    */
    add_action(‘tribe_events_before_template’, ‘remove_ical_from_list_view’);

    function remove_ical_from_list_view() {
    if (tribe_is_event_query() && tribe_is_list_view())
    remove_filter(‘tribe_events_after_footer’, array(‘TribeiCal’, ‘maybe_add_link’), 10, 1);
    }

    add_action(‘tribe_events_before_template’, ‘remove_ical_from_month_view’);

    function remove_ical_from_month_view() {
    if (tribe_is_event_query() && tribe_is_month())
    remove_filter(‘tribe_events_after_footer’, array(‘TribeiCal’, ‘maybe_add_link’), 10, 1);
    }

    add_action(‘tribe_events_before_view’, ‘remove_ical_from_org_venue_views’);

    function remove_ical_from_org_venue_views() {
    if ( tribe_is_event_query() && (tribe_is_organizer() || tribe_is_venue()) )
    remove_filter(‘tribe_events_after_footer’, array(‘TribeiCal’, ‘maybe_add_link’), 10, 1);
    }

    #190994

    I think this might be the culprit:

    remove_action(‘tribe_events_single_event_after_the_meta’, array(TribeWooTickets::get_instance(), ‘front_end_tickets_form’));
    add_action(‘tribe_events_single_event_after_the_content’, array(TribeWooTickets::get_instance(), ‘front_end_tickets_form’));

    I don’t know if there needs to be a check on when that happens or if it needs to be different when in a child theme but checking with Tribe would be the best route from here.

    #191003

    If the same code works fine in the parents function.php this might help:
    1: search for empty lines on the beginning / end of your php
    2: make sure that you save as UTF-8 without BOM and upload again
    axel

    • This reply was modified 11 years, 1 month ago by kaMai.
    #191861

    I tried cleaning it up and removing spaces but everything works without the action remove/add.

    #192440

    Thank you all for your assistance and I have finally got it working with the aid from the guys at Modern Tribe.

    The action remove/add code was incorrect and should have read:

    
    remove_action('tribe_events_single_event_after_the_meta', array(TribeWooTickets::get_instance(), 'front_end_tickets_form'), 5);
    add_action('tribe_events_single_event_after_the_content', array(TribeWooTickets::get_instance(), 'front_end_tickets_form'), 5);
    

    I’m not php savvy and i’m unsure of what the number 5 represents at the end of the code, but I can state that it works without any problems.

    Devin, i’m all good for you to close this ticket.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘child theme – adding code to the functions.php breaks my site’ is closed to new replies.