</tr>
				</thead>
				<tbody>
				<?php 
    foreach ($grids as $grid) {
        $total++;
        $cur_offset++;
        if ($cur_offset <= $offset) {
            continue;
        }
        //if we are lower then the offset, continue;
        if ($cur_offset > $limit + $offset) {
            continue;
        }
        // if we are higher then the limit + offset, continue
        $cur_grid = Essential_Grid::get_essential_grid_by_id($grid->id);
        $skin_id = @$cur_grid['params']['entry-skin'];
        ?>
					<tr>
						<td><a href="javascript:void(0);" class="eg-toggle-favorite" id="eg-star-id-<?php 
        echo $grid->id;
        ?>
"><i class="eg-icon-star<?php 
        echo isset($cur_grid['settings']['favorite']) && $cur_grid['settings']['favorite'] == 'true' ? '' : '-empty';
        ?>
"></i></a></td>
						<td><?php 
        echo $grid->id;
        ?>
</td>
						<td><?php 
 /**
  * Update/Create Grid
  * @return    boolean	true
  */
 private static function update_create_grid($data)
 {
     global $wpdb;
     if (!isset($data['name']) || strlen($data['name']) < 2) {
         return __('Title needs to have at least 2 characters', EG_TEXTDOMAIN);
     }
     if (!isset($data['handle']) || strlen($data['handle']) < 2) {
         return __('Alias needs to have at least 2 characters', EG_TEXTDOMAIN);
     }
     if (!isset($data['params']) || empty($data['params'])) {
         return __('No setting informations received!', EG_TEXTDOMAIN);
     }
     if ($data['postparams']['source-type'] == 'custom') {
         if (!isset($data['layers']) || empty($data['layers'])) {
             return __('Please add at least one element in Custom Grid mode', EG_TEXTDOMAIN);
         }
     } elseif ($data['postparams']['source-type'] == 'post') {
         if (!isset($data['postparams']['post_types']) || empty($data['postparams']['post_types'])) {
             return __('Please select a Post Type', EG_TEXTDOMAIN);
         }
     } elseif (!isset($data['postparams']['source-type'])) {
         return __('Invalid data received, this could be the cause of server limitations. If you use a custom grid, please lower the number of entries.', EG_TEXTDOMAIN);
     }
     if (!isset($data['layers']) || empty($data['layers'])) {
         $data['layers'] = array();
     }
     //this is only set if we are source-type custom
     if ($data['postparams']['source-type'] == 'post') {
         if (isset($data['postparams']['post_types'])) {
             $types = explode(',', $data['postparams']['post_types']);
             if (!in_array('page', (array) $types)) {
                 if (!isset($data['postparams']['post_category']) || empty($data['postparams']['post_category'])) {
                     return __('Please select a Post Categorie', EG_TEXTDOMAIN);
                 }
             }
         }
     }
     $table_name = $wpdb->prefix . Essential_Grid::TABLE_GRID;
     if (isset($data['id']) && intval($data['id']) > 0) {
         //update
         //check if entry with handle exists, because this is unique
         $grid = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$table_name} WHERE handle = %s AND id != %s ", $data['handle'], $data['id']), ARRAY_A);
         if (!empty($grid)) {
             return __('Ess. Grid with chosen alias already exists, please choose a different alias', EG_TEXTDOMAIN);
         }
         //check if exists, if yes, update
         $entry = Essential_Grid::get_essential_grid_by_id($data['id']);
         if ($entry !== false) {
             $response = $wpdb->update($table_name, array('name' => $data['name'], 'handle' => $data['handle'], 'postparams' => json_encode($data['postparams']), 'params' => json_encode($data['params']), 'layers' => json_encode($data['layers']), 'last_modified' => date('Y-m-d H:i:s')), array('id' => $data['id']));
             if ($response === false) {
                 return __('Ess. Grid could not be changed', EG_TEXTDOMAIN);
             }
             return true;
         }
     }
     //check if entry with handle exists, because this is unique
     $grid = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$table_name} WHERE handle = %s", $data['handle']), ARRAY_A);
     if (!empty($grid)) {
         return __('Ess. Grid with chosen alias already exists, please choose a different alias', EG_TEXTDOMAIN);
     }
     //insert if function did not return yet
     $response = $wpdb->insert($table_name, array('name' => $data['name'], 'handle' => $data['handle'], 'postparams' => json_encode($data['postparams']), 'params' => json_encode($data['params']), 'layers' => json_encode($data['layers']), 'last_modified' => date('Y-m-d H:i:s')));
     if ($response === false) {
         return false;
     }
     return true;
 }
Exemplo n.º 3
0
 */
if (!defined('ABSPATH')) {
    exit;
}
$grid = false;
$base = new Essential_Grid_Base();
$nav_skin = new Essential_Grid_Navigation();
$wa = new Essential_Grid_Widget_Areas();
$meta = new Essential_Grid_Meta();
$isCreate = $base->getGetVar('create', 'true');
$title = __('Create New Ess. Grid', EG_TEXTDOMAIN);
$save = __('Save Grid', EG_TEXTDOMAIN);
$layers = false;
if (intval($isCreate) > 0) {
    //currently editing
    $grid = Essential_Grid::get_essential_grid_by_id(intval($isCreate));
    if (!empty($grid)) {
        $title = __('Settings', EG_TEXTDOMAIN);
        $layers = $grid['layers'];
    }
}
$postTypesWithCats = $base->getPostTypesWithCatsForClient();
$jsonTaxWithCats = $base->jsonEncodeForClientSide($postTypesWithCats);
$base = new Essential_Grid_Base();
$pages = get_pages(array('sort_column' => 'post_name'));
$post_elements = $base->getPostTypesAssoc();
$postTypes = $base->getVar($grid['postparams'], 'post_category', 'post');
$categories = $base->setCategoryByPostTypes($postTypes, $postTypesWithCats);
$selected_pages = explode(',', $base->getVar($grid['postparams'], 'selected_pages', '-1', 's'));
$columns = $base->getVar($grid['params'], 'columns', '');
$columns = $base->set_basic_colums($columns);