Returns a submit button, with provided text and appropriate class, copied from WP Core for use on the frontend
public static submit_button ( string $text = null, string $type = 'primary large', string $name = 'submit', boolean $wrap = true, array | string $other_attributes = null ) | ||
$text | string | The text of the button (defaults to 'Save Changes') |
$type | string | The type of button. One of: primary, secondary, delete |
$name | string | The HTML name of the submit button. Defaults to "submit". If no id attribute is given in $other_attributes below, $name will be used as the button's id. |
$wrap | boolean | True if the output button should be wrapped in a paragraph tag, false otherwise. Defaults to true |
$other_attributes | array | string | Other attributes that should be output with the button, mapping attributes to their values, such as array( 'tabindex' => '1' ). These attributes will be output as attribute="value", such as tabindex="1". Defaults to no other attributes. Other attributes can also be provided as a string such as 'tabindex="1"', though the array format is typically cleaner. |
public function filters() { include_once ABSPATH . 'wp-admin/includes/template.php'; wp_enqueue_script('thickbox'); wp_enqueue_style('pods-ui-list-table', PODS_URL . 'ui/css/pods-ui-list-table.css', array('thickbox'), PODS_VERSION); $filters = $this->filters; foreach ($filters as $k => $filter) { if (isset($this->pod->fields[$filter])) { $filter_field = $this->pod->fields[$filter]; } elseif (isset($this->fields['manage'][$filter])) { $filter_field = $this->fields['manage'][$filter]; } else { continue; } if (isset($filter_field) && in_array($filter_field['type'], array('date', 'datetime', 'time'))) { if ('' == pods_var_raw('filter_' . $filter . '_start', 'get', '', null, true) && '' == pods_var_raw('filter_' . $filter . '_end', 'get', '', null, true)) { unset($filters[$k]); } } elseif ('' === pods_var_raw('filter_' . $filter, 'get', '')) { unset($filters[$k]); } } $filtered = false; if (!empty($filters)) { $filtered = true; } ?> <div class="pods-ui-filter-bar"> <div class="pods-ui-filter-bar-primary"> <?php if (!empty($this->views)) { ?> <ul class="subsubsub"> <li class="pods-ui-filter-view-label"><strong><?php echo $this->heading['views']; ?> </strong></li> <?php foreach ($this->views as $view => $label) { if (false === strpos($label, '<a')) { $link = pods_query_arg(array('view' . $this->num => $view, 'pg' . $this->num => ''), self::$allowed, $this->exclusion()); if ($this->view == $view) { $label = '<a href="' . esc_url($link) . '" class="current">' . $label . '</a>'; } else { $label = '<a href="' . esc_url($link) . '">' . $label . '</a>'; } } ?> <li class="<?php echo esc_attr($view); ?> "><?php echo $label; ?> </li> <?php } ?> </ul> <?php } ?> <?php if (false !== $this->search && false !== $this->searchable) { ?> <p class="search-box"> <?php if ($filtered || '' != pods_var_raw('search' . $this->num, 'get', '', null, true)) { $clear_filters = array('search' . $this->num => false); foreach ($this->filters as $filter) { $clear_filters['filter_' . $filter . '_start'] = false; $clear_filters['filter_' . $filter . '_end'] = false; $clear_filters['filter_' . $filter] = false; } ?> <a href="<?php echo esc_url(pods_query_arg($clear_filters, array('orderby' . $this->num, 'orderby_dir' . $this->num, 'limit' . $this->num, 'page'), $this->exclusion())); ?> " class="pods-ui-filter-reset">[<?php _e('Reset', 'pods'); ?> ]</a> <?php } if (false !== $this->do_hook('filters_show_search', true)) { ?> <label class="screen-reader-text" for="page-search<?php echo esc_attr($this->num); ?> -input"><?php _e('Search', 'pods'); ?> :</label> <?php echo PodsForm::field('search' . $this->num, $this->search, 'text', array('attributes' => array('id' => 'page-search' . $this->num . '-input'))); ?> <?php } else { echo PodsForm::field('search' . $this->num, '', 'hidden'); } ?> <?php echo PodsForm::submit_button($this->header['search'], 'button', false, false, array('id' => 'search' . $this->num . '-submit')); ?> </p> <?php } ?> </div> <?php if (!empty($this->filters)) { ?> <div class="pods-ui-filter-bar-secondary"> <ul class="subsubsub"> <?php if (!$filtered) { ?> <li class="pods-ui-filter-bar-add-filter"> <a href="#TB_inline?width=640&inlineId=pods-ui-posts-filter-popup" class="thickbox" title="<?php esc_attr_e('Advanced Filters', 'pods'); ?> "> <?php _e('Advanced Filters', 'pods'); ?> </a> </li> <?php } else { ?> <li class="pods-ui-filter-bar-add-filter"> <a href="#TB_inline?width=640&inlineId=pods-ui-posts-filter-popup" class="thickbox" title="<?php esc_attr_e('Advanced Filters', 'pods'); ?> "> + <?php _e('Add Filter', 'pods'); ?> </a> </li> <?php } foreach ($filters as $filter) { $value = pods_var_raw('filter_' . $filter, 'get'); if (isset($this->pod->fields[$filter])) { $filter_field = $this->pod->fields[$filter]; } elseif (isset($this->fields['manage'][$filter])) { $filter_field = $this->fields['manage'][$filter]; } else { continue; } $data_filter = 'filter_' . $filter; $start = $end = $value_label = ''; if (in_array($filter_field['type'], array('date', 'datetime', 'time'))) { $start = pods_var_raw('filter_' . $filter . '_start', 'get', '', null, true); $end = pods_var_raw('filter_' . $filter . '_end', 'get', '', null, true); if (!empty($start) && !in_array($start, array('0000-00-00', '0000-00-00 00:00:00', '00:00:00'))) { $start = PodsForm::field_method($filter_field['type'], 'convert_date', $start, 'n/j/Y'); } if (!empty($end) && !in_array($end, array('0000-00-00', '0000-00-00 00:00:00', '00:00:00'))) { $end = PodsForm::field_method($filter_field['type'], 'convert_date', $end, 'n/j/Y'); } $value = trim($start . ' - ' . $end, ' -'); $data_filter = 'filter_' . $filter . '_start'; } elseif ('pick' == $filter_field['type']) { $value_label = trim(PodsForm::field_method('pick', 'value_to_label', $filter, $value, $filter_field, $this->pod->pod_data, null)); } elseif ('boolean' == $filter_field['type']) { $yesno_options = array('1' => pods_var_raw('boolean_yes_label', $filter_field['options'], __('Yes', 'pods'), null, true), '0' => pods_var_raw('boolean_no_label', $filter_field['options'], __('No', 'pods'), null, true)); if (isset($yesno_options[(string) $value])) { $value_label = $yesno_options[(string) $value]; } } if (strlen($value_label) < 1) { $value_label = $value; } ?> <li class="pods-ui-filter-bar-filter" data-filter="<?php echo esc_attr($data_filter); ?> "> <a href="#TB_inline?width=640&inlineId=pods-ui-posts-filter-popup" class="thickbox" title="<?php esc_attr_e('Advanced Filters', 'pods'); ?> "> <strong><?php echo $filter_field['label']; ?> :</strong> <?php echo esc_html($value_label); ?> </a> <a href="#remove-filter" class="remove-filter" title="<?php esc_attr_e('Remove Filter', 'pods'); ?> ">x</a> <?php if (in_array($filter_field['type'], array('date', 'datetime', 'time'))) { echo PodsForm::field('filter_' . $filter . '_start', $start, 'hidden'); echo PodsForm::field('filter_' . $filter . '_end', $end, 'hidden'); } else { echo PodsForm::field($data_filter, $value, 'hidden'); } ?> </li> <?php } ?> </ul> </div> <?php } ?> </div> <script type="text/javascript"> jQuery( function() { jQuery( '.pods-ui-filter-bar-secondary' ).on( 'click', '.remove-filter', function ( e ) { jQuery( '.pods-ui-filter-popup #' + jQuery( this ).parent().data( 'filter' ) ).remove(); jQuery( this ).parent().find( 'input' ).each( function () { jQuery( this ).remove(); } ); jQuery( 'form#posts-filter [name="pg<?php echo esc_attr($this->num); ?> "]' ).prop( 'disabled', true ); jQuery( 'form#posts-filter [name="action<?php echo esc_attr($this->num); ?> "]' ).prop( 'disabled', true ); jQuery( 'form#posts-filter [name="action_bulk<?php echo esc_attr($this->num); ?> "]' ).prop( 'disabled', true ); jQuery( 'form#posts-filter [name="_wpnonce<?php echo esc_attr($this->num); ?> "]' ).prop( 'disabled', true ); jQuery( 'form#posts-filter' ).submit(); e.preventDefault(); } ); } ); </script> <?php }