Tuesday, November 8, 2022
HomeWordPress Developmentfilters - add_filter('the_content', 'technique') doesn't set off my customized technique

filters – add_filter(‘the_content’, ‘technique’) doesn’t set off my customized technique


I am utilizing the parse_request hook to set off the the_content filter once you’re at /sportivity-roster within the url. Once I do a var_dump within the if assertion the place I test the fixed it is worth, it really works, however for some not figuring out cause it’s not reaching my technique which ought to get triggered within the the_content hook.

add_action('parse_request', 'sportivity_roster_custom_url_handler');
perform sportivity_roster_custom_url_handler() {
    world $wp;
    $path = $wp->request;
    if($path === sup::ROSTER_URL) { 
        add_filter('the_content', 'generateView', 1);
    }
}

perform generateView($content material){
    $weeks = sportivity_roster_get_lessons(array_values(Location::loadAll())[0]->getSportivityApi());
    $index = 0;
    $contents = array();
    foreach($weeks as $week => $classes) {
        foreach($classes as $locationId => $lessonsForWeek) {
            $weekSelector = sprintf('.location.%s .week_percents', $locationId, $index);
            $content material = sportivity_roster_makeWeek($lessonsForWeek, array(), $weekSelector);
            $contents[$weekSelector] = $content material;
            $index++;
        }
    }

    $knowledge = array(
        'classes' => $weeks,
        'contents' => $contents,
        'lessons_bookable' => false,
    );
    return sup::includeView('roster', $knowledge);
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments