public function admin_list_fields($fields, $post_data) { $list_type = $post_data['list_type']; if (!in_array($list_type, array('posts', 'terms.posts', 'users.posts'))) { return $fields; } $html = '<div id="w4pl_field_group_date_query" class="w4pl_field_group"> <div class="w4pl_group_title">Posts: Date Query</div> <div class="w4pl_group_fields">'; $html .= '<div class="wffw wff_clone_wrap">'; $html .= '<table id="w4pl_date_query_table" class="widefat wff_clone_table"> <thead> <tr> <th class="column">' . __('Column', 'w4pl') . '</th> <th class="key">' . __('Key', 'w4pl') . '</th> <th class="compare">' . __('Compare', 'w4pl') . '</th> <th class="value">' . __('Value', 'w4pl') . '</th> <th class="action">' . __('Action', 'w4pl') . '</th> </tr> </thead> <tbody class="wff_clone_to">'; if (!empty($post_data['date_query'])) { foreach ($post_data['date_query'] as $date_query) { $html .= $this->get_date_query_form($date_query); } } $html .= '</tbody> </table>'; $html .= ' <div id="w4pl_date_query_value_clone" style="display:none;"> <div class="item"> <input type="text" class="wff wfft_text wffi_w4pl_date_query_value"> <a class="w4pl_date_query_value_add button" href="#">+</a> <a class="w4pl_date_query_value_del button" href="#">-</a> </div> </div>'; $html .= ' <p style="text-align:right;"><a href="#" class="button wff_clone_btn">' . __('+ Add', 'w4pl') . '</a></p> <table class="csshide"><tbody class="wff_clone_from">' . $this->get_date_query_form() . '</table>'; $html .= w4pl_form_field_html(array('field_wrap' => false, 'name' => 'w4pl[date_query_relation]', 'label' => __('Relation', 'w4pl'), 'type' => 'radio', 'option' => array('OR' => __('OR', 'w4pl'), 'AND' => __('AND', 'w4pl')), 'value' => $post_data['date_query_relation'])); $html .= '<p class="wffdw2">'; $html .= '<br />For the value field, you can also use following shortcodes to apply dynamic value:'; $html .= '<br /><code>[w4pl_date day=+6 hour=-1 format="Y-m-d H:i:s"]</code> - for displaying datetime based on current time'; $html .= '<br /><code>[w4pl_time day=+6 hour=-1]</code> - for displaying timestamp based on current time'; $html .= '<br /><br />Note: Above Shortcodes generates times in GMT timezone. To compare time saved in another timezone, use hour attribute. for example: [w4pl_date hour=+6] will generate the time what is identical to GMT+6 timestamp.'; $html .= '</p>'; $html .= '</div><!--.wffw-->'; $html .= '</div><!--.w4pl_group_fields--></div><!--#w4pl_field_group_date_query-->'; $fields['date_query'] = array('position' => '140', 'type' => 'html', 'html' => $html); /* ========================================= */ return $fields; }
public function admin_list_fields($fields, $post_data) { $list_type = $post_data['list_type']; if (!in_array($list_type, array('posts'))) { return $fields; } $post_type = $post_data['post_type']; $taxonomies = self::post_type_taxonomies_options($post_type); if (empty($taxonomies)) { return $fields; } $html = '<div id="w4pl_field_group_tax_query" class="w4pl_field_group"><div class="w4pl_group_title">Posts: Tax Query</div><div class="w4pl_group_fields">'; $tax_query_relation = isset($post_data['tax_query']['relation']) && !empty($post_data['tax_query']['relation']) ? $post_data['tax_query']['relation'] : 'OR'; $html .= '<div class="wffw">'; $html .= '<table id="w4pl_tax_query_table" class="widefat"> <thead> <tr> <th id="w4pl_tax_query_taxonomy_cell_head">Taxonomy</th> <th id="w4pl_tax_query_operator_cell_head">Operator</th> <th id="w4pl_tax_query_field_cell_head">Field</th> <th id="w4pl_tax_query_terms_cell_head">Terms</th> <th id="w4pl_tax_query_action_cell_head">Action</th> </tr> </thead> <tbody>'; if (isset($post_data['tax_query']) && !empty($post_data['tax_query'])) { $index = 0; foreach ($post_data['tax_query']['taxonomy'] as $i => $taxonomy) { $field = isset($post_data['tax_query']['field'][$i]) ? $post_data['tax_query']['field'][$i] : ''; $operator = isset($post_data['tax_query']['operator'][$i]) ? $post_data['tax_query']['operator'][$i] : ''; $terms = isset($post_data['tax_query']['terms'][$i]) ? $post_data['tax_query']['terms'][$i] : ''; if (empty($terms) || empty($operator)) { continue; } $html .= ' <tr><td class="w4pl_tax_query_taxonomy_cell"> ' . w4pl_form_child_field_html(array('id' => 'w4pl_tax_query_taxonomy_' . $index, 'name' => 'w4pl[tax_query][taxonomy][' . $index . ']', 'input_class' => 'w4pl_tax_query_taxonomy', 'type' => 'select', 'option' => self::post_type_taxonomies_options($post_type), 'value' => $taxonomy)) . '</td><td class="w4pl_tax_query_operator_cell">' . w4pl_form_child_field_html(array('id' => 'w4pl_tax_query_operator_' . $index, 'name' => 'w4pl[tax_query][operator][' . $index . ']', 'input_class' => 'w4pl_tax_query_operator', 'type' => 'select', 'option' => self::tax_query_operator_options(), 'value' => $operator)) . '</td><td class="w4pl_tax_query_field_cell">' . w4pl_form_child_field_html(array('id' => 'w4pl_tax_query_field_' . $index, 'name' => 'w4pl[tax_query][field][' . $index . ']', 'input_class' => 'w4pl_tax_query_field', 'type' => 'select', 'option' => self::tax_query_field_options(), 'value' => $field)) . '</td><td class="w4pl_tax_query_terms_cell terms" data-pos="' . $index . '">'; if (!is_array($terms)) { $terms = array($terms); } $btn_class = ''; if (in_array($operator, array('IN', 'NOT IN'))) { $btn_class = 'csshide'; } $cindex = 0; foreach ($terms as $val) { $html .= ' <div class="item"> <input type="text" value="' . esc_attr($val) . '" name="w4pl[tax_query][terms][' . $index . '][]" class="wff wffi_w4pl_tax_query_terms_' . $index . ' wfft_text "> <a class="w4pl_tax_query_value_add button" href="#">+</a> <a class="w4pl_tax_query_value_del button" href="#">-</a> </div>'; ++$cindex; } $html .= '</td><td class="w4pl_tax_query_action_cell"><a class="w4pl_tax_query_remove_btn" href="#" class="button">Remove</a></td> </tr>'; ++$index; } } $html .= '</tbody> </table>'; $html .= ' <div id="w4pl_tax_query_value_clone" style="display:none;"> <div class="item"> <input type="text" class="wff wfft_text wffi_w4pl_tax_query_value"> <a class="w4pl_tax_query_value_add button" href="#">+</a> <a class="w4pl_tax_query_value_del button" href="#">-</a> </div> </div>'; $html .= ' <p style="text-align:right;"><a id="w4pl_tax_query_add_btn" href="#" class="button">+ Add</a></p> <table id="w4pl_tax_query_clone" style="display:none;"> <tr><td class="w4pl_tax_query_taxonomy_cell">' . w4pl_form_child_field_html(array('name' => 'w4pl[tax_query][taxonomy][]', 'input_class' => 'w4pl_tax_query_taxonomy', 'type' => 'select', 'option' => self::post_type_taxonomies_options($post_type))) . '</td><td class="w4pl_tax_query_operator_cell">' . w4pl_form_child_field_html(array('name' => 'w4pl[tax_query][operator][]', 'input_class' => 'w4pl_tax_query_operator', 'type' => 'select', 'option' => self::tax_query_operator_options())) . '</td><td class="w4pl_tax_query_field_cell">' . w4pl_form_child_field_html(array('name' => 'w4pl[tax_query][field][]', 'input_class' => 'w4pl_tax_query_field', 'type' => 'select', 'option' => self::tax_query_field_options())) . '</td><td class="w4pl_tax_query_terms_cell terms">' . '<div class="item"> <input type="text" class="wff wfft_text wffi_w4pl_tax_query_terms"> <a class="w4pl_tax_query_value_add button" href="#">+</a> <a class="w4pl_tax_query_value_del button" href="#">-</a> </div>' . '</td><td class="w4pl_tax_query_action_cell terms"><a class="w4pl_tax_query_remove_btn" href="#" class="button">Remove</a></td>' . ' </tr></table>'; $html .= w4pl_form_field_html(array('field_wrap' => false, 'name' => 'w4pl[tax_query][relation]', 'label' => 'Relation', 'type' => 'radio', 'option' => array('OR' => 'OR', 'AND' => 'AND'), 'value' => $tax_query_relation)); $html .= '</div><!--.wffw-->'; $html .= '</div><!--.w4pl_group_fields--></div><!--#w4pl_field_group_tax_query-->'; $fields['tax_query'] = array('position' => '110', 'type' => 'html', 'html' => $html); /* ========================================= */ return $fields; }
function w4pl_form_child_field_html($args = array()) { $args['label'] = ''; $args['field_wrap'] = false; $args['label_wrap'] = false; $args['input_wrap'] = false; return w4pl_form_field_html($args); }
public function admin_list_fields($fields, $post_data) { $list_type = $post_data['list_type']; if (!in_array($list_type, array('posts', 'terms.posts'))) { return $fields; } /* Meta Query */ $html = '<div id="w4pl_field_group_meta_query" class="w4pl_field_group"> <div class="w4pl_group_title">' . __('Posts: Meta Query', W4PL_TD) . '</div> <div class="w4pl_group_fields">'; $meta_query_relation = isset($post_data['meta_query']['relation']) && !empty($post_data['meta_query']['relation']) ? $post_data['meta_query']['relation'] : 'OR'; $html .= '<div class="wffw">'; $html .= '<table id="w4pl_meta_query_table" class="widefat"> <thead> <tr> <th id="w4pl_meta_query_key_cell_head">' . __('Key', W4PL_TD) . '</th> <th id="w4pl_meta_query_compare_cell_head">' . __('Compare', W4PL_TD) . '</th> <th id="w4pl_meta_query_value_cell_head">' . __('Value', W4PL_TD) . '</th> <th id="w4pl_meta_query_action_cell_head">' . __('Action', W4PL_TD) . '</th> </tr> </thead> <tbody>'; if (isset($post_data['meta_query']) && isset($post_data['meta_query']['key']) && is_array($post_data['meta_query']['key']) && !empty($post_data['meta_query']['key'])) { $index = 0; foreach ($post_data['meta_query']['key'] as $i => $key) { $compare = isset($post_data['meta_query']['compare'][$i]) ? $post_data['meta_query']['compare'][$i] : ''; $value = isset($post_data['meta_query']['value'][$i]) ? $post_data['meta_query']['value'][$i] : ''; if (empty($key) || empty($compare)) { continue; } $html .= ' <tr><td class="w4pl_meta_query_key_cell"> ' . w4pl_form_child_field_html(array('id' => 'w4pl_meta_query_key_' . $index, 'name' => 'w4pl[meta_query][key][' . $index . ']', 'input_class' => 'w4pl_meta_query_key', 'type' => 'text', 'value' => $key)) . '</td><td class="w4pl_meta_query_compare_cell">' . w4pl_form_child_field_html(array('id' => 'w4pl_meta_query_compare_' . $index, 'name' => 'w4pl[meta_query][compare][' . $index . ']', 'input_class' => 'w4pl_meta_query_compare', 'type' => 'select', 'option' => self::meta_query_compare_options(), 'value' => $compare)) . '</td><td class="w4pl_meta_query_value_cell values" data-pos="' . $index . '">'; if (!is_array($value)) { $value = array($value); } $cindex = 0; foreach ($value as $val) { $html .= ' <div class="item"> <input type="text" value="' . esc_attr($val) . '" name="w4pl[meta_query][value][' . $index . '][]" class="wff wffi_w4pl_meta_query_value_' . $index . ' wfft_text "> <a class="w4pl_meta_query_value_add button" href="#">+</a> <a class="w4pl_meta_query_value_del button" href="#">-</a> </div>'; ++$cindex; } $html .= '</td><td class="w4pl_meta_query_action_cell"><a class="w4pl_meta_query_remove_btn" href="#" class="button">' . __('Remove', W4PL_TD) . '</a></td> </tr>'; ++$index; } } $html .= '</tbody> </table>'; $html .= ' <div id="w4pl_meta_query_value_clone" style="display:none;"> <div class="item"> <input type="text" class="wff wfft_text wffi_w4pl_meta_query_value"> <a class="w4pl_meta_query_value_add button" href="#">+</a> <a class="w4pl_meta_query_value_del button" href="#">-</a> </div> </div>'; $html .= ' <p style="text-align:right;"><a id="w4pl_meta_query_add_btn" href="#" class="button">' . __('+ Add', W4PL_TD) . '</a></p> <table id="w4pl_meta_query_clone" style="display:none;"> <tr><td class="w4pl_meta_query_key_cell"> <input type="text" class="wff wffi_w4pl_meta_query_key wfft_text"> </td><td class="w4pl_meta_query_compare_cell">' . w4pl_form_child_field_html(array('name' => 'w4pl[meta_query][compare][]', 'input_class' => 'w4pl_meta_query_compare', 'type' => 'select', 'option' => self::meta_query_compare_options())) . '</td><td class="w4pl_meta_query_value_cell values">' . '<div class="item"> <input type="text" class="wff wfft_text wffi_w4pl_meta_query_value"> <a class="w4pl_meta_query_value_add button" href="#">+</a> <a class="w4pl_meta_query_value_del button" href="#">-</a> </div>' . '</td><td class="w4pl_meta_query_action_cell"><a class="w4pl_meta_query_remove_btn" href="#" class="button">' . __('Remove', W4PL_TD) . '</a></td>' . ' </tr></table>'; $html .= w4pl_form_field_html(array('field_wrap' => false, 'name' => 'w4pl[meta_query][relation]', 'label' => __('Relation', W4PL_TD), 'type' => 'radio', 'option' => array('OR' => __('OR', W4PL_TD), 'AND' => __('AND', W4PL_TD)), 'value' => $meta_query_relation)); $html .= '<p class="wffdw2">'; $html .= '<br />For the value field, you can also use following shortcodes to apply dynamic value:'; $html .= '<br /><code>[w4pl_date day=+6 hour=-1 format="Y-m-d H:i:s"]</code> - for displaying datetime based on current time'; $html .= '<br /><code>[w4pl_time day=+6 hour=-1]</code> - for displaying timestamp based on current time'; $html .= '<br /><br />Note: Above Shortcodes generates times in GMT timezone. To compare time saved in another timezone, use hour attribute. for example: [w4pl_date hour=+6] will generate the time what is identical to GMT+6 timestamp.'; $html .= '</p>'; $html .= '</div><!--.wffw-->'; $html .= '</div><!--.w4pl_group_fields--></div><!--#w4pl_field_group_meta_query-->'; $fields['meta_query'] = array('position' => '120', 'type' => 'html', 'html' => $html); /* ========================================= */ return $fields; }
public function admin_list_fields($fields, $post_data) { $list_type = $post_data['list_type']; if (!in_array($list_type, array('posts', 'terms.posts'))) { return $fields; } /* Meta Query */ $html = '<div id="w4pl_field_group_meta_query" class="w4pl_field_group"><div class="w4pl_group_title">Posts: Meta Query</div><div class="w4pl_group_fields">'; $meta_query_relation = isset($post_data['meta_query']['relation']) && !empty($post_data['meta_query']['relation']) ? $post_data['meta_query']['relation'] : 'OR'; $html .= '<div class="wffw">'; $html .= '<table id="w4pl_meta_query_table" class="widefat"> <thead> <tr> <th id="w4pl_meta_query_key_cell_head">Key</th> <th id="w4pl_meta_query_compare_cell_head">Compare</th> <th id="w4pl_meta_query_value_cell_head">Value</th> <th id="w4pl_meta_query_action_cell_head">Action</th> </tr> </thead> <tbody>'; if (isset($post_data['meta_query']) && isset($post_data['meta_query']['key']) && is_array($post_data['meta_query']['key']) && !empty($post_data['meta_query']['key'])) { $index = 0; foreach ($post_data['meta_query']['key'] as $i => $key) { $compare = isset($post_data['meta_query']['compare'][$i]) ? $post_data['meta_query']['compare'][$i] : ''; $value = isset($post_data['meta_query']['value'][$i]) ? $post_data['meta_query']['value'][$i] : ''; if (empty($key) || empty($compare)) { continue; } $html .= ' <tr><td class="w4pl_meta_query_key_cell"> ' . w4pl_form_child_field_html(array('id' => 'w4pl_meta_query_key_' . $index, 'name' => 'w4pl[meta_query][key][' . $index . ']', 'input_class' => 'w4pl_meta_query_key', 'type' => 'text', 'value' => $key)) . '</td><td class="w4pl_meta_query_compare_cell">' . w4pl_form_child_field_html(array('id' => 'w4pl_meta_query_compare_' . $index, 'name' => 'w4pl[meta_query][compare][' . $index . ']', 'input_class' => 'w4pl_meta_query_compare', 'type' => 'select', 'option' => self::meta_query_compare_options(), 'value' => $compare)) . '</td><td class="w4pl_meta_query_value_cell values" data-pos="' . $index . '">'; if (!is_array($value)) { $value = array($value); } $cindex = 0; foreach ($value as $val) { $html .= ' <div class="item"> <input type="text" value="' . esc_attr($val) . '" name="w4pl[meta_query][value][' . $index . '][]" class="wff wffi_w4pl_meta_query_value_' . $index . ' wfft_text "> <a class="w4pl_meta_query_value_add button" href="#">+</a> <a class="w4pl_meta_query_value_del button" href="#">-</a> </div>'; ++$cindex; } $html .= '</td><td class="w4pl_meta_query_action_cell"><a class="w4pl_meta_query_remove_btn" href="#" class="button">Remove</a></td> </tr>'; ++$index; } } $html .= '</tbody> </table>'; $html .= ' <div id="w4pl_meta_query_value_clone" style="display:none;"> <div class="item"> <input type="text" class="wff wfft_text wffi_w4pl_meta_query_value"> <a class="w4pl_meta_query_value_add button" href="#">+</a> <a class="w4pl_meta_query_value_del button" href="#">-</a> </div> </div>'; $html .= ' <p style="text-align:right;"><a id="w4pl_meta_query_add_btn" href="#" class="button">+ Add</a></p> <table id="w4pl_meta_query_clone" style="display:none;"> <tr><td class="w4pl_meta_query_key_cell"> <input type="text" class="wff wffi_w4pl_meta_query_key wfft_text"> </td><td class="w4pl_meta_query_compare_cell">' . w4pl_form_child_field_html(array('name' => 'w4pl[meta_query][compare][]', 'input_class' => 'w4pl_meta_query_compare', 'type' => 'select', 'option' => self::meta_query_compare_options())) . '</td><td class="w4pl_meta_query_value_cell values">' . '<div class="item"> <input type="text" class="wff wfft_text wffi_w4pl_meta_query_value"> <a class="w4pl_meta_query_value_add button" href="#">+</a> <a class="w4pl_meta_query_value_del button" href="#">-</a> </div>' . '</td><td class="w4pl_meta_query_action_cell"><a class="w4pl_meta_query_remove_btn" href="#" class="button">Remove</a></td>' . ' </tr></table>'; $html .= w4pl_form_field_html(array('field_wrap' => false, 'name' => 'w4pl[meta_query][relation]', 'label' => 'Relation', 'type' => 'radio', 'option' => array('OR' => 'OR', 'AND' => 'AND'), 'value' => $meta_query_relation)); $html .= '</div><!--.wffw-->'; $html .= '</div><!--.w4pl_group_fields--></div><!--#w4pl_field_group_meta_query-->'; $fields['meta_query'] = array('position' => '120', 'type' => 'html', 'html' => $html); /* ========================================= */ return $fields; }