Last active
August 9, 2019 16:59
-
-
Save petertwise/b036dc65f3496636b534ad9021a876ab to your computer and use it in GitHub Desktop.
test squarecandy ACF events filtering system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Test Event Filter | |
Plugin URI: https://squarecandy.net | |
Description: | |
Version: 1.0.0 | |
Author: Square Candy Design | |
Author URI: http://squarecandydesign.com | |
Text Domain: squarecandy | |
*/ | |
// Example - remove fields | |
add_filter( 'squarecandy_filter_events_fields', 'custom_squarecandy_filter_events_fields', 10, 1 ); | |
function custom_squarecandy_filter_events_fields( $eventfields ) { | |
// remove unwanted fields | |
unset( $eventfields['address'] ); | |
unset( $eventfields['city'] ); | |
unset( $eventfields['state'] ); | |
unset( $eventfields['zip'] ); | |
unset( $eventfields['venue_location'] ); | |
unset( $eventfields['zoom_level'] ); | |
return $eventfields; | |
} | |
// Example - add fields | |
add_filter( 'squarecandy_filter_events_fields', 'addnew_squarecandy_filter_events_fields', 10, 1 ); | |
function addnew_squarecandy_filter_events_fields( $eventfields ) { | |
// add to end | |
$eventfields['test_new_field_end'] = array( | |
'key' => 'field_h8f9hwafhdsioahfdso', | |
'label' => 'Test New Field End', | |
'name' => 'test_new_field_end', | |
'type' => 'true_false', | |
); | |
// add to middle | |
$temp_array = array(); | |
$insert_after = 'end_time'; | |
foreach ($eventfields as $key => $value) { | |
$temp_array[$key] = $value; | |
if ( $insert_after === $key ) { | |
$temp_array['test_new_field_middle'] = array( | |
'key' => 'field_middleh8f9hwaf67234897o', | |
'label' => 'Test New Field Middle', | |
'name' => 'test_new_field_middle', | |
'type' => 'true_false', | |
); | |
} | |
} | |
$eventfields = $temp_array; | |
return $eventfields; | |
} | |
// Example - change field label | |
add_filter( 'squarecandy_filter_events_fields', 'relabel_squarecandy_filter_events_fields', 10, 1 ); | |
function relabel_squarecandy_filter_events_fields( $eventfields ) { | |
// change labels | |
$eventfields['venue']['label'] = 'Location'; | |
$eventfields['venue_link']['label'] = 'Location Link'; | |
return $eventfields; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment