Passing array of variables to plugins’ add_filter

Question

In a plugin I have this filter

// Let the extensions add any menu before action buttons.
            $extended_tab_listings = apply_filters('rm_after_front_tabtitle_listing',array()); 
            foreach($extended_tab_listings as $tab){ ?>
                <div class="rmtabs_head <?php echo $tab['class']; ?> rmtabs_head" title="<?php echo $tab['label'] ?>" data-rmt-tabcontent="#<?php echo $tab['id'] ?>"><?php echo $tab['icon'].' '.$tab['label'] ?></a></div>
            <?php }
            ?>

I have tried passing the array to the filter as follows, by amalgamating; Using multi-dimensional array with filter and https://pippinsplugins.com/a-quick-introduction-to-using-filters/. However, it is not working correctly.

function nj_add_rm_after_front_tabtitle_listing() {
    // Add the titles of tabs we want

    $array = 
    array( 
        'label' => "TEST",       
        'class' => "my-class",    
        'icon' => 'my-icon',   
        'id'  => '123',  
    );

    return $array;
}
add_filter('rm_after_front_tabtitle_listing', 'nj_add_rm_after_front_tabtitle_listing');

What is the correct method to pass the variables?

0
, Nick Jones 3 years 2020-04-05T08:50:59-05:00 0 Answers 68 views 0

Leave an answer

Browse
Browse