Some PHP help needed in the wordpress theme

I want to add a filter. Currently the sortcode is:
[legbet_bettings]

I want to make it like this → [legbet_bettings time=today]
time = today filter will ensure that the events fetched are those that is happening today. can someone help me to achieve this?

<?php

//don't allow direct access via url
if ( ! defined('ABSPATH') ) {
    exit();
}

function legbet_bettings_front_controller ($atts) {

    //set default attributes
    $attributes = shortcode_atts(
        array(
            'sport' => legbet_VALUE_ALL,
            'toggle' => 1,
            'time' => '',
        ), $atts
    );

    ob_start();

    $active_events = false;

    $data = array();

    if (legbet_VALUE_ALL == $attributes['sport']) {

        $sports = legbet_get_sports();
        foreach ($sports as $sport) {

            $data [$sport['sport_id']] = legbet_get_sport_data($sport, get_option('bp_close_bets'));

            if ($data [$sport['sport_id']] ['count_active_events'] > 0) {
                $active_events = true;
            }

        }

    } else {

        $sport = legbet_get_sport_by_name($attributes['sport']);
        $data [$sport['sport_id']] = legbet_get_sport_data($sport, get_option('bp_close_bets'));

        if ($data [$sport['sport_id']] ['count_active_events'] > 0) {
            $active_events = true;
        }

    }


    $pass['sports'] = $data;
    $pass['sport_title_bg'] = get_option('bp_sport_title_bg_color');
    $pass['sport_title_text'] = get_option('bp_sport_title_text_color');
    $pass['sport_container_bg'] = get_option('bp_sport_container_bg_color');
    $pass['event_title_bg'] = get_option('bp_event_title_bg_color');
    $pass['event_title_text'] = get_option('bp_event_title_text_color');
    $pass['event_container_bg'] = get_option('bp_event_container_bg_color');
    $pass['bet_event_title_bg'] = get_option('bp_bet_event_title_bg_color');
    $pass['bet_event_title_text'] = get_option('bp_bet_event_title_text_color');
    $pass['cat_title_bg'] = get_option('bp_cat_title_bg_color');
    $pass['cat_title_text'] = get_option('bp_cat_title_text_color');
    $pass['cat_container_bg'] = get_option('bp_cat_container_bg_color');
    $pass['button_bg'] = get_option('bp_button_bg_color');
    $pass['button_text'] = get_option('bp_button_text_color');
    $pass['min_children_to_show_toggle'] = (int) $attributes['toggle'];
    $pass['active_bettings'] = $active_events;
    legbet_get_view('bettings', 'shortcodes', $pass);

    return ob_get_clean();
}

add_shortcode('legbet_bettings', 'legbet_bettings_front_controller');

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.