I have a Wordpress plugin that I need to modify.
Basically, I have an arbitrary string that I want to pass into a specific array value that is then passed to a filter ( 'gmw_main_shortcode_form_args', $form ). The code is below and I need to filter the form array and pass the string to the "page_load_results" value of the array:
$this->form = apply_filters( 'gmw_main_shortcode_form_args', $form );
public function page_load_results() {`
$page_load_options = $this->form['page_load_results'];
$this->form['org_address'] = '';
$this->form['get_per_page'] = ( !empty( $_GET[$this->form['url_px'].'per_page'] ) ) ? $_GET[$this->form['url_px'].'per_page'] : current( explode( ",", $page_load_options['per_page'] ) );
$this->form['radius'] = ( !empty( $page_load_options['radius'] ) ) ? $page_load_options['radius'] : 200;
$this->form['search_results']['display_map'] = $page_load_options['display_map'];
$this->form['units_array'] = gmw_get_units_array( $this->form['page_load_results']['units'] );
Can anyone share what is the correct way to do this?
Here is an example of using array_filter
array_filter($form, function($k) {
return $k == 'gmw_main_shortcode_form_args';
}, ARRAY_FILTER_USE_KEY);