Пример #1
0
 /**
  * Apply Custom Settings to the Grid, so users can change everything in the settings they want to
  * This allows to modify grid_params and grid_post_params
  * @since: 1.2.0
  */
 private function apply_custom_settings($has_handle = false)
 {
     if (empty($this->custom_settings) || !is_array($this->custom_settings)) {
         return false;
     }
     $base = new Essential_Grid_Base();
     $translate_variables = array('grid-layout' => 'layout');
     foreach ($this->custom_settings as $handle => $new_setting) {
         if (isset($translate_variables[$handle])) {
             $handle = $translate_variables[$handle];
         }
         if ($has_handle) {
             //p- is in front of postparameters
             if (strpos($handle, 'p-') === 0) {
                 $this->grid_postparams[substr($handle, 2)] = $new_setting;
             } else {
                 $this->grid_params[$handle] = $new_setting;
             }
         } else {
             if (isset($this->grid_params[$handle])) {
                 $this->grid_params[$handle] = $new_setting;
             } elseif (isset($this->grid_postparams[$handle])) {
                 $this->grid_postparams[$handle] = $new_setting;
             } else {
                 $this->grid_params[$handle] = $new_setting;
             }
         }
     }
     if (isset($this->grid_params['columns'])) {
         //change columns
         $columns = $base->set_basic_colums_custom($this->grid_params['columns']);
         $this->grid_params['columns'] = $columns;
     }
     if (isset($this->grid_params['rows-unlimited']) && $this->grid_params['rows-unlimited'] == 'off') {
         //add pagination
         $this->grid_params['navigation-layout']['pagination']['bottom-1'] = '0';
         $this->grid_params['bottom-1-margin-top'] = '10';
     }
     return true;
 }