How to create a option plugin for rules of conditional logic?

The background

Creates a settings page conditional logic display contents of files from a given folder.

At the moment the script works like this:
is the specified directory "forms" is scanned for php files.
Each file contains a form with a set of all the different list boxes and so on
- For each file the script needs to specify conditional logic to show\load, which is formed from the list of terms in two taxonomies: estate_operation and estate_type.
Thus it turns out that I need a loop to generate the array:
[path to the file id of the first taxonomy, the second taxonomy id]
The number of files is not known beforehand and may vary.
Question 1: How best to form array of options to further as quickly as possible to search for matches on the id of the taxonomies. How can I avoid heavily nested, not the fruit of a lot of entities ?
Question 2: How not ajax+jQuery to get selected terms from the list?
PHP code
$ae_conditional_logic_page = basename(__FILE__);

ae_conditional_logic_options function() {
 global $ae_conditional_logic_page;
 add_options_page( 'Conditional logic forms', 'Conditional logic forms ', 'manage_options', $ae_conditional_logic_page, 'ae_conditional_logic_option_page'); 
add_action('admin_menu', 'ae_conditional_logic_options');

// Return a function
ae_conditional_logic_option_page function(){

 global $ae_conditional_logic_page;
 ?><div class="wrap">
 <h2>Conditional logic Forms of object parameters</h2><small>For each form in the directory "forms" indicate the logic of the show. Each form should be in a separate file.</small>
 <?php scan_forms();?>
 <form method="post" enctype="multipart/form-data" action="options.php">
 <p class="submit"> 
 <input type="submit" class="button-primary" value="<?php _e('Save changes') ?>" /> 

scan_forms function(){ ?>
 <div class="container mt-2"><div class="row mb-1"><div class="col"><b>file Name\shapes</b></div><div class="col"><b>Surgery</b></div><div class="col"><b>property Type</b></div></div>
 foreach ( glob( plugin_dir_path( __FILE__ )."../forms/*.php" ) as $file ){ ?> 
 <div class="row mb-1"><div class="col"><?php echo basename($file); ?></div><div class="col"><?php estate_operation_select(); ?></div><div class="col"><?php estate_type_select(); ?></div></div>
 <?php } ?> 

/* Output functions types and taxonomies */
estate_operation_select function(){
 echo'<select id="estate_operation_select" needed="true" class="form-control">';
 $terms = get_terms("estate_operation", 'orderby=count&hide_empty=0'); $count = count($terms); 
 if ($count > 0) { foreach ($terms as $term) {if ($term->parent != '0' ){$parent=";}else{$parent ='disabled';} echo '<option '.$parent.' value="' . $term->term_taxonomy_id . '">' . $term->name .' </option>'; } } 

estate_type_select function(){
 echo'<select id="estate_type_select" needed="true" class="form-control">'; 
 $terms = get_terms("estate_type", 'orderby=count&hide_empty=0'); $count = count($terms);
 if ($count > 0) { foreach ($terms as $term) { echo '<option value="' . $term->term_taxonomy_id .' '.selected(get_option('demo-select').'">' . $term->name . '</option>'; } }
/* -------------------------------- */
//save_conditional_logic_option function(){}

March 12th 20 at 08:40
0 answer

Find more questions by tags WordPress