Created
May 8, 2018 19:37
-
-
Save badabingbreda/8bc2aeaa54d18fdd58871bd860bf0b2e to your computer and use it in GitHub Desktop.
Toolbox Action - toolbox_add_conditional_options
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 | |
add_action( 'toolbox_add_conditional_options' , 'add_some_new_conditional_feature', 10, 1 ); | |
function add_some_new_conditional_feature() { | |
toolboxExtender::add_conditional_option( | |
// filter name | |
'conditional_filter_check_parameter', | |
// option key and title | |
array('key'=> 'check_parameter' , 'title' => __('Check URL Parameter', 'textdomain') ), | |
// fields that are part of this options settings. | |
// No toggling of subfields or forms | |
array( | |
'query_parameter' => array( | |
'type' => 'text', | |
'label' => __( 'query parameter to check for', 'textdomain' ), | |
), | |
'query_value' => array( | |
'type' => 'text', | |
'label' => __( 'if equal to', 'textdomain' ), | |
), | |
) | |
); | |
add_filter( 'conditional_filter_check_parameter' , 'check_query_parameter' , 10, 3 ); | |
function check_query_parameter ( $is_visible, $param , $node ) { | |
if ( !isset( $_GET[$param['query_parameter']]) || $_GET[$param['query_parameter']] !== $param['query_value'] ) return false; | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment