Ejemplo n.º 1
0
 /**
  * Output Sorting from custom grid
  * @since 1.0.6
  */
 public function output_sorting_by_all_types()
 {
     $base = new Essential_Grid_Base();
     $nav = new Essential_Grid_Navigation();
     $m = new Essential_Grid_Meta();
     $order_by = explode(',', $base->getVar($this->grid_params, 'sorting-order-by', 'date'));
     if (!is_array($order_by)) {
         $order_by = array($order_by);
     }
     $order_by_start = $base->getVar($this->grid_params, 'sorting-order-by-start', 'none');
     if (strpos($order_by_start, 'eg-') === 0 || strpos($order_by_start, 'egl-') === 0) {
         //add meta at the end for meta sorting
         //if essential Meta, replace to meta name. Else -> replace - and _ with space, set each word uppercase
         $metas = $m->get_all_meta();
         $f = false;
         if (!empty($metas)) {
             foreach ($metas as $meta) {
                 if ('eg-' . $meta['handle'] == $order_by_start || 'egl-' . $meta['handle'] == $order_by_start) {
                     $f = true;
                     $order_by_start = $meta['name'];
                     break;
                 }
             }
         }
         if ($f === false) {
             $order_by_start = ucwords(str_replace(array('-', '_'), array(' ', ' '), $order_by_start));
         }
     }
     $nav->set_orders($order_by);
     //set order of filter
     $nav->set_orders_start($order_by_start);
     //set order of filter
     $nav->output_sorting();
 }