Ejemplo n.º 1
0
 /**
  * return all custom element fields
  */
 public function get_custom_elements_for_javascript()
 {
     $meta = new Essential_Grid_Meta();
     $item_elements = new Essential_Grid_Item_Element();
     $elements = array(array('name' => 'custom-soundcloud', 'type' => 'input'), array('name' => 'custom-vimeo', 'type' => 'input'), array('name' => 'custom-youtube', 'type' => 'input'), array('name' => 'custom-html5-mp4', 'type' => 'input'), array('name' => 'custom-html5-ogv', 'type' => 'input'), array('name' => 'custom-html5-webm', 'type' => 'input'), array('name' => 'custom-image', 'type' => 'image'), array('name' => 'custom-text', 'type' => 'textarea'), array('name' => 'custom-ratio', 'type' => 'select'), array('name' => 'post-link', 'type' => 'input'), array('name' => 'custom-filter', 'type' => 'input'));
     $custom_meta = $meta->get_all_meta(false);
     if (!empty($custom_meta)) {
         foreach ($custom_meta as $cmeta) {
             if ($cmeta['type'] == 'text') {
                 $cmeta['type'] = 'input';
             }
             $elements[] = array('name' => 'eg-cm-' . $cmeta['handle'], 'type' => $cmeta['type'], 'default' => @$cmeta['default']);
         }
     }
     $def_ele = $item_elements->getElementsForDropdown();
     foreach ($def_ele as $type => $element) {
         foreach ($element as $handle => $name) {
             $elements[] = array('name' => $handle, 'type' => 'input');
         }
     }
     return $elements;
 }
Ejemplo n.º 2
0
 public function set_sorting_text($san_text)
 {
     if (strpos($san_text, 'eg-') === 0) {
         $meta = new Essential_Grid_Meta();
         $m = $meta->get_all_meta(false);
         if (!empty($m)) {
             foreach ($m as $me) {
                 if ('eg-' . $me['handle'] == $san_text) {
                     return $me['name'];
                 }
             }
         }
     } elseif (strpos($san_text, 'egl-') === 0) {
         $meta = new Essential_Grid_Meta_Linking();
         $m = $meta->get_all_link_meta(false);
         if (!empty($m)) {
             foreach ($m as $me) {
                 if ('egl-' . $me['handle'] == $san_text) {
                     return $me['name'];
                 }
             }
         }
     } else {
         switch ($san_text) {
             case 'date':
                 $san_text = __('Date', EG_TEXTDOMAIN);
                 break;
             case 'title':
                 $san_text = __('Title', EG_TEXTDOMAIN);
                 break;
             case 'excerpt':
                 $san_text = __('Excerpt', EG_TEXTDOMAIN);
                 break;
             case 'id':
                 $san_text = __('ID', EG_TEXTDOMAIN);
                 break;
             case 'slug':
                 $san_text = __('Slug', EG_TEXTDOMAIN);
                 break;
             case 'author':
                 $san_text = __('Author', EG_TEXTDOMAIN);
                 break;
             case 'last-modified':
                 $san_text = __('Last Modified', EG_TEXTDOMAIN);
                 break;
             case 'number-of-comments':
                 $san_text = __('Comments', EG_TEXTDOMAIN);
                 break;
             case 'meta_num_total_sales':
                 $san_text = __('Total Sales', EG_TEXTDOMAIN);
                 break;
             case 'meta_num__regular_price':
                 $san_text = __('Regular Price', EG_TEXTDOMAIN);
                 break;
             case 'meta_num__sale_price':
                 $san_text = __('Sale Price', EG_TEXTDOMAIN);
                 break;
             case 'meta__featured':
                 $san_text = __('Featured', EG_TEXTDOMAIN);
                 break;
             case 'meta__sku':
                 $san_text = __('SKU', EG_TEXTDOMAIN);
                 break;
             case 'meta_num_stock':
                 $san_text = __('In Stock', EG_TEXTDOMAIN);
                 break;
             default:
                 $san_text = ucfirst($san_text);
                 break;
         }
     }
     return $san_text;
 }
Ejemplo n.º 3
0
<?php

//needs: $base (instance of Essential_Grid_Base), $grid (Instance of Essential_Grid::get_essential_grid_by_id() || false [creation of new])
if (!isset($base)) {
    $base = new Essential_Grid_Base();
}
$eg_meta = new Essential_Grid_Meta();
// INIT POSTER IMAGE SOURCE ORDERS
if (intval($isCreate) > 0) {
    //currently editing, so default can be empty
    $poster_source_order = $base->getVar($grid['params'], 'poster-source-order', '');
} else {
    $poster_source_order = $base->getVar($grid['params'], 'poster-source-order', array('featured-image'));
}
$poster_source_list = $base->get_poster_source_order();
// INIT LIGHTBOX SOURCE ORDERS
if (intval($isCreate) > 0) {
    //currently editing, so default can be empty
    $lb_source_order = $base->getVar($grid['params'], 'lb-source-order', '');
} else {
    $lb_source_order = $base->getVar($grid['params'], 'lb-source-order', array('featured-image'));
}
$lb_source_list = $base->get_lb_source_order();
// INIT AJAX SOURCE ORDERS
if (intval($isCreate) > 0) {
    //currently editing, so default can be empty
    $aj_source_order = $base->getVar($grid['params'], 'aj-source-order', '');
} else {
    $aj_source_order = $base->getVar($grid['params'], 'aj-source-order', array('post-content'));
}
$aj_source_list = $base->get_aj_source_order();
Ejemplo n.º 4
0
 public function export_custom_meta($export_custom_meta)
 {
     $return_metas = array();
     if ($export_custom_meta !== false && !empty($export_custom_meta)) {
         $metas = new Essential_Grid_Meta();
         $custom_metas = $metas->get_all_meta();
         if (!empty($export_custom_meta)) {
             foreach ($custom_metas as $c_meta) {
                 foreach ($export_custom_meta as $meta) {
                     if ($c_meta['handle'] == $meta) {
                         $return_metas[] = $c_meta;
                         break;
                     }
                 }
             }
         }
     }
     return $return_metas;
 }
 /**
  * Handle Ajax Requests
  */
 public static function on_ajax_action()
 {
     try {
         $token = self::getPostVar('token', false);
         //verify the token
         $isVerified = wp_verify_nonce($token, 'Essential_Grid_actions');
         $error = false;
         if ($isVerified) {
             $data = self::getPostVar("data", false);
             switch (self::getPostVar("client_action", false)) {
                 case 'add_google_fonts':
                     $f = new ThemePunch_Fonts();
                     $result = $f->add_new_font($data);
                     if ($result === true) {
                         Essential_Grid::ajaxResponseSuccess(__("Font successfully created!", EG_TEXTDOMAIN), array('data' => $result, 'is_redirect' => true, 'redirect_url' => self::getFontsUrl()));
                     } else {
                         Essential_Grid::ajaxResponseError($result, false);
                     }
                     break;
                 case 'remove_google_fonts':
                     if (!isset($data['handle'])) {
                         Essential_Grid::ajaxResponseError(__('Font not found', EG_TEXTDOMAIN), false);
                     }
                     $f = new ThemePunch_Fonts();
                     $result = $f->remove_font_by_handle($data['handle']);
                     if ($result === true) {
                         Essential_Grid::ajaxResponseSuccess(__("Font successfully removed!", EG_TEXTDOMAIN), array('data' => $result));
                     } else {
                         Essential_Grid::ajaxResponseError($result, false);
                     }
                     break;
                 case 'edit_google_fonts':
                     if (!isset($data['handle'])) {
                         Essential_Grid::ajaxResponseError(__('No handle given', EG_TEXTDOMAIN), false);
                     }
                     if (!isset($data['url'])) {
                         Essential_Grid::ajaxResponseError(__('No parameters given', EG_TEXTDOMAIN), false);
                     }
                     $f = new ThemePunch_Fonts();
                     $result = $f->edit_font_by_handle($data);
                     if ($result === true) {
                         Essential_Grid::ajaxResponseSuccess(__("Font successfully changed!", EG_TEXTDOMAIN), array('data' => $result));
                     } else {
                         Essential_Grid::ajaxResponseError($result, false);
                     }
                     break;
                 case 'add_custom_meta':
                     $m = new Essential_Grid_Meta();
                     $result = $m->add_new_meta($data);
                     if ($result === true) {
                         Essential_Grid::ajaxResponseSuccess(__("Meta successfully created!", EG_TEXTDOMAIN), array('data' => $result, 'is_redirect' => true, 'redirect_url' => self::getSubViewUrl(Essential_Grid_Admin::VIEW_SUB_CUSTOM_META_AJAX)));
                     } else {
                         Essential_Grid::ajaxResponseError($result, false);
                     }
                     break;
                 case 'remove_custom_meta':
                     if (!isset($data['handle'])) {
                         Essential_Grid::ajaxResponseError(__('Meta not found', EG_TEXTDOMAIN), false);
                     }
                     $m = new Essential_Grid_Meta();
                     $result = $m->remove_meta_by_handle($data['handle']);
                     if ($result === true) {
                         Essential_Grid::ajaxResponseSuccess(__("Meta successfully removed!", EG_TEXTDOMAIN), array('data' => $result));
                     } else {
                         Essential_Grid::ajaxResponseError($result, false);
                     }
                     break;
                 case 'edit_custom_meta':
                     if (!isset($data['handle'])) {
                         Essential_Grid::ajaxResponseError(__('No handle given', EG_TEXTDOMAIN), false);
                     }
                     if (!isset($data['name'])) {
                         Essential_Grid::ajaxResponseError(__('No name given', EG_TEXTDOMAIN), false);
                     }
                     $m = new Essential_Grid_Meta();
                     $result = $m->edit_meta_by_handle($data);
                     if ($result === true) {
                         Essential_Grid::ajaxResponseSuccess(__("Meta successfully changed!", EG_TEXTDOMAIN), array('data' => $result));
                     } else {
                         Essential_Grid::ajaxResponseError($result, false);
                     }
                     break;
                 case 'add_link_meta':
                     $m = new Essential_Grid_Meta_Linking();
                     $result = $m->add_new_link_meta($data);
                     if ($result === true) {
                         Essential_Grid::ajaxResponseSuccess(__("Meta successfully created!", EG_TEXTDOMAIN), array('data' => $result, 'is_redirect' => true, 'redirect_url' => self::getSubViewUrl(Essential_Grid_Admin::VIEW_SUB_CUSTOM_META_AJAX)));
                     } else {
                         Essential_Grid::ajaxResponseError($result, false);
                     }
                     break;
                 case 'remove_link_meta':
                     if (!isset($data['handle'])) {
                         Essential_Grid::ajaxResponseError(__('Meta not found', EG_TEXTDOMAIN), false);
                     }
                     $m = new Essential_Grid_Meta_Linking();
                     $result = $m->remove_link_meta_by_handle($data['handle']);
                     if ($result === true) {
                         Essential_Grid::ajaxResponseSuccess(__("Meta successfully removed!", EG_TEXTDOMAIN), array('data' => $result));
                     } else {
                         Essential_Grid::ajaxResponseError($result, false);
                     }
                     break;
                 case 'edit_link_meta':
                     if (!isset($data['handle'])) {
                         Essential_Grid::ajaxResponseError(__('No handle given', EG_TEXTDOMAIN), false);
                     }
                     if (!isset($data['name'])) {
                         Essential_Grid::ajaxResponseError(__('No name given', EG_TEXTDOMAIN), false);
                     }
                     if (!isset($data['original'])) {
                         Essential_Grid::ajaxResponseError(__('No original given', EG_TEXTDOMAIN), false);
                     }
                     $m = new Essential_Grid_Meta_Linking();
                     $result = $m->edit_link_meta_by_handle($data);
                     if ($result === true) {
                         Essential_Grid::ajaxResponseSuccess(__("Meta successfully changed!", EG_TEXTDOMAIN), array('data' => $result));
                     } else {
                         Essential_Grid::ajaxResponseError($result, false);
                     }
                     break;
                 case 'add_widget_area':
                     $wa = new Essential_Grid_Widget_Areas();
                     $result = $wa->add_new_sidebar($data);
                     if ($result === true) {
                         Essential_Grid::ajaxResponseSuccess(__("Widget Area successfully created!", EG_TEXTDOMAIN), array('data' => $result, 'is_redirect' => true, 'redirect_url' => self::getSubViewUrl(Essential_Grid_Admin::VIEW_SUB_WIDGET_AREA_AJAX)));
                     } else {
                         Essential_Grid::ajaxResponseError($result, false);
                     }
                     break;
                 case 'edit_widget_area':
                     if (!isset($data['handle'])) {
                         Essential_Grid::ajaxResponseError(__('No handle given', EG_TEXTDOMAIN), false);
                     }
                     if (!isset($data['name'])) {
                         Essential_Grid::ajaxResponseError(__('No name given', EG_TEXTDOMAIN), false);
                     }
                     $wa = new Essential_Grid_Widget_Areas();
                     $result = $wa->edit_widget_area_by_handle($data);
                     if ($result === true) {
                         Essential_Grid::ajaxResponseSuccess(__("Widget Area successfully changed!", EG_TEXTDOMAIN), array('data' => $result));
                     } else {
                         Essential_Grid::ajaxResponseError($result, false);
                     }
                     break;
                 case 'remove_widget_area':
                     if (!isset($data['handle'])) {
                         Essential_Grid::ajaxResponseError(__('Widget Area not found', EG_TEXTDOMAIN), false);
                     }
                     $wa = new Essential_Grid_Widget_Areas();
                     $result = $wa->remove_widget_area_by_handle($data['handle']);
                     if ($result === true) {
                         Essential_Grid::ajaxResponseSuccess(__("Widget Area successfully removed!", EG_TEXTDOMAIN), array('data' => $result));
                     } else {
                         Essential_Grid::ajaxResponseError($result, false);
                     }
                     break;
                 case 'get_preview_html_markup':
                     //add wpml transient
                     $lang_code = '';
                     if (Essential_Grid_Wpml::is_wpml_exists()) {
                         $lang_code = Essential_Grid_Wpml::get_current_lang_code();
                     }
                     if (isset($data['id'])) {
                         delete_transient('ess_grid_trans_query_' . $data['id'] . $lang_code);
                         //delete cache
                     }
                     $result = Essential_Grid_Base::output_demo_skin_html($data);
                     if (isset($result['error'])) {
                         Essential_Grid::ajaxResponseData($result);
                     } else {
                         Essential_Grid::ajaxResponseData(array("data" => array('html' => $result['html'], 'preview' => @$result['preview'])));
                     }
                     break;
                     /* //TP: CHUNK
                     			case 'get_preview_html_markup_chunk': //only for custom grid
                     				$grid = new Essential_Grid();
                     				$grid->init_by_data($data);
                     				
                     				$html = '';
                     				
                     				if($grid->is_custom_grid()){
                     					ob_start();
                     					$grid->output_by_custom('custom', true);
                     					$html = ob_get_contents();
                     					ob_clean();
                     					ob_end_clean();
                     				}
                     				$order_id = self::getPostVar("order_id", false);
                     				
                     				Essential_Grid::ajaxResponseData(array("data"=>array('preview' => $html, 'order_id' => $order_id)));
                     				
                     			break; */
                 /* //TP: CHUNK
                 			case 'get_preview_html_markup_chunk': //only for custom grid
                 				$grid = new Essential_Grid();
                 				$grid->init_by_data($data);
                 				
                 				$html = '';
                 				
                 				if($grid->is_custom_grid()){
                 					ob_start();
                 					$grid->output_by_custom('custom', true);
                 					$html = ob_get_contents();
                 					ob_clean();
                 					ob_end_clean();
                 				}
                 				$order_id = self::getPostVar("order_id", false);
                 				
                 				Essential_Grid::ajaxResponseData(array("data"=>array('preview' => $html, 'order_id' => $order_id)));
                 				
                 			break; */
                 case 'save_search_settings':
                     if (!empty($data)) {
                         update_option('esg-search-settings', $data);
                     }
                     Essential_Grid::ajaxResponseSuccess(__("Search Settings succesfully saved!", EG_TEXTDOMAIN));
                     break;
                 case 'update_general_settings':
                     $result = self::savePluginPermission($data['permission']);
                     $cur_query = get_option('tp_eg_query_type', 'wp_query');
                     update_option('tp_eg_output_protection', @$data['protection']);
                     update_option('tp_eg_tooltips', @$data['tooltips']);
                     update_option('tp_eg_wait_for_fonts', @$data['wait_for_fonts']);
                     update_option('tp_eg_js_to_footer', @$data['js_to_footer']);
                     update_option('tp_eg_use_cache', @$data['use_cache']);
                     update_option('tp_eg_query_type', @$data['query_type']);
                     update_option('tp_eg_enable_log', @$data['enable_log']);
                     update_option('tp_eg_use_lightbox', @$data['use_lightbox']);
                     if (@$data['use_lightbox'] === 'jackbox') {
                         Essential_Grid_Jackbox::enable_jackbox();
                     } else {
                         Essential_Grid_Jackbox::disable_jackbox();
                     }
                     if ($cur_query !== $data['query_type']) {
                         //delete cache
                         $lang = array();
                         if (Essential_Grid_Wpml::is_wpml_exists()) {
                             $lang = icl_get_languages();
                         }
                         $grids = Essential_Grid::get_essential_grids();
                         if (!empty($grids)) {
                             foreach ($grids as $grid) {
                                 if (!empty($lang)) {
                                     foreach ($lang as $code => $val) {
                                         delete_transient('ess_grid_trans_query_' . $grid->id . $val['language_code']);
                                         delete_transient('ess_grid_trans_full_grid_' . $grid->id . $val['language_code']);
                                     }
                                 } else {
                                     delete_transient('ess_grid_trans_query_' . $grid->id);
                                     delete_transient('ess_grid_trans_full_grid_' . $grid->id);
                                 }
                             }
                         }
                     }
                     if ($result !== true) {
                         $error = __("Global Settings did not change!", EG_TEXTDOMAIN);
                     } else {
                         Essential_Grid::ajaxResponseSuccess(__("Global Settings succesfully saved!", EG_TEXTDOMAIN), $result);
                     }
                     break;
                 case 'update_create_grid':
                     $result = self::update_create_grid($data);
                     if ($result !== true) {
                         $error = $result;
                     } else {
                         $lang = array();
                         if (Essential_Grid_Wpml::is_wpml_exists()) {
                             $lang = icl_get_languages();
                         }
                         if (isset($data['id']) && intval($data['id']) > 0) {
                             if (!empty($lang)) {
                                 foreach ($lang as $code => $val) {
                                     delete_transient('ess_grid_trans_query_' . $data['id'] . $val['language_code']);
                                     //delete cache
                                     delete_transient('ess_grid_trans_full_grid_' . $data['id'] . $val['language_code']);
                                     //delete cache
                                 }
                             } else {
                                 delete_transient('ess_grid_trans_query_' . $data['id']);
                                 //delete cache
                                 delete_transient('ess_grid_trans_full_grid_' . $data['id']);
                                 //delete cache
                             }
                             Essential_Grid::ajaxResponseSuccess(__("Grid successfully saved/changed!", EG_TEXTDOMAIN), $result);
                         } else {
                             Essential_Grid::ajaxResponseSuccess(__("Grid successfully saved/changed!", EG_TEXTDOMAIN), array('data' => $result, 'is_redirect' => true, 'redirect_url' => self::getViewUrl(Essential_Grid_Admin::VIEW_OVERVIEW)));
                         }
                     }
                     break;
                 case 'delete_grid':
                     $result = self::delete_grid_by_id($data);
                     if ($result !== true) {
                         $error = $result;
                     } else {
                         Essential_Grid::ajaxResponseSuccess(__("Grid deleted", EG_TEXTDOMAIN), array('data' => $result, 'is_redirect' => true, 'redirect_url' => self::getViewUrl(Essential_Grid_Admin::VIEW_OVERVIEW)));
                     }
                     break;
                 case 'duplicate_grid':
                     $result = self::duplicate_grid_by_id($data);
                     if ($result !== true) {
                         $error = $result;
                     } else {
                         Essential_Grid::ajaxResponseSuccess(__("Grid duplicated", EG_TEXTDOMAIN), array('data' => $result, 'is_redirect' => true, 'redirect_url' => self::getViewUrl(Essential_Grid_Admin::VIEW_OVERVIEW)));
                     }
                     break;
                 case 'update_create_item_skin':
                     $result = Essential_Grid_Item_Skin::update_save_item_skin($data);
                     if ($result !== true) {
                         $error = $result;
                     } else {
                         if (isset($data['id']) && intval($data['id']) > 0) {
                             Essential_Grid::ajaxResponseSuccess(__("Item Skin changed", EG_TEXTDOMAIN), array('data' => $result));
                         } else {
                             Essential_Grid::ajaxResponseSuccess(__("Item Skin created/changed", EG_TEXTDOMAIN), array('data' => $result, 'is_redirect' => true, 'redirect_url' => self::getViewUrl("", "", 'essential-' . Essential_Grid_Admin::VIEW_SUB_ITEM_SKIN_OVERVIEW)));
                         }
                     }
                     break;
                 case 'update_custom_css':
                     if (isset($data['global_css'])) {
                         Essential_Grid_Global_Css::set_global_css_styles($data['global_css']);
                         Essential_Grid::ajaxResponseSuccess(__("CSS saved!", EG_TEXTDOMAIN), '');
                     } else {
                         $error = __("No CSS Received", EG_TEXTDOMAIN);
                     }
                     break;
                 case 'delete_item_skin':
                     $result = Essential_Grid_Item_Skin::delete_item_skin_by_id($data);
                     if ($result !== true) {
                         $error = $result;
                     } else {
                         Essential_Grid::ajaxResponseSuccess(__("Item Skin deleted", EG_TEXTDOMAIN), array('data' => $result));
                     }
                     break;
                 case 'duplicate_item_skin':
                     $result = Essential_Grid_Item_Skin::duplicate_item_skin_by_id($data);
                     if ($result !== true) {
                         $error = $result;
                     } else {
                         Essential_Grid::ajaxResponseSuccess(__("Item Skin duplicated", EG_TEXTDOMAIN), array('data' => $result, 'is_redirect' => true, 'redirect_url' => self::getViewUrl("", "", 'essential-' . Essential_Grid_Admin::VIEW_SUB_ITEM_SKIN_OVERVIEW)));
                     }
                     break;
                 case 'star_item_skin':
                     $result = Essential_Grid_Item_Skin::star_item_skin_by_id($data);
                     if ($result !== true) {
                         $error = $result;
                     } else {
                         Essential_Grid::ajaxResponseSuccess(__("Favorite Changed", EG_TEXTDOMAIN), array('data' => $result));
                     }
                     break;
                 case 'update_create_item_element':
                     $result = Essential_Grid_Item_Element::update_create_essential_item_element($data);
                     if ($result !== true) {
                         $error = $result;
                     } else {
                         Essential_Grid::ajaxResponseSuccess(__("Item Element created/changed", EG_TEXTDOMAIN), array('data' => $result));
                     }
                     break;
                 case 'check_item_element_existence':
                     $result = Essential_Grid_Item_Element::check_existence_by_handle(@$data['name']);
                     if ($result === false) {
                         Essential_Grid::ajaxResponseData(array("data" => array('existence' => 'false')));
                     } elseif ($result === true) {
                         Essential_Grid::ajaxResponseData(array("data" => array('existence' => 'true')));
                     } else {
                         Essential_Grid::ajaxResponseData(array("data" => array('existence' => $result)));
                     }
                     break;
                 case 'get_predefined_elements':
                     $elements = Essential_Grid_Item_Element::getElementsForJavascript();
                     $html_elements = Essential_Grid_Item_Element::prepareDefaultElementsForEditor();
                     $html_elements .= Essential_Grid_Item_Element::prepareTextElementsForEditor();
                     Essential_Grid::ajaxResponseData(array("data" => array('elements' => $elements, 'html' => $html_elements)));
                     break;
                 case 'delete_predefined_elements':
                     $result = Essential_Grid_Item_Element::delete_element_by_handle($data);
                     if ($result !== true) {
                         $error = $result;
                     } else {
                         Essential_Grid::ajaxResponseSuccess(__("Item Element successfully deleted", EG_TEXTDOMAIN), array('data' => $result));
                     }
                     break;
                 case 'update_create_navigation_skin_css':
                     $nav = new Essential_Grid_Navigation();
                     $result = $nav->update_create_navigation_skin_css($data);
                     if ($result !== true) {
                         $error = $result;
                     } else {
                         $base = new Essential_Grid_Base();
                         $skin_css = Essential_Grid_Navigation::output_navigation_skins();
                         $skins = Essential_Grid_Navigation::get_essential_navigation_skins();
                         $select = '';
                         foreach ($skins as $skin) {
                             $select .= '<option value="' . $skin['handle'] . '">' . $skin['name'] . '</option>' . "\n";
                         }
                         if (isset($data['sid']) && intval($data['sid']) > 0) {
                             Essential_Grid::ajaxResponseSuccess(__("Navigation Skin successfully changed!", EG_TEXTDOMAIN), array('css' => $skin_css, 'select' => $select, 'default_skins' => $skins));
                         } else {
                             Essential_Grid::ajaxResponseSuccess(__("Navigation Skin successfully created", EG_TEXTDOMAIN), array('css' => $skin_css, 'select' => $select, 'default_skins' => $skins));
                         }
                     }
                     break;
                 case 'delete_navigation_skin_css':
                     $nav = new Essential_Grid_Navigation();
                     $result = $nav->delete_navigation_skin_css($data);
                     if ($result !== true) {
                         $error = $result;
                     } else {
                         $base = new Essential_Grid_Base();
                         $skin_css = Essential_Grid_Navigation::output_navigation_skins();
                         $skins = Essential_Grid_Navigation::get_essential_navigation_skins();
                         $select = '';
                         foreach ($skins as $skin) {
                             $select .= '<option value="' . $skin['handle'] . '">' . $skin['name'] . '</option>' . "\n";
                         }
                         Essential_Grid::ajaxResponseSuccess(__("Navigation Skin successfully deleted!", EG_TEXTDOMAIN), array('css' => $skin_css, 'select' => $select, 'default_skins' => $skins));
                     }
                     break;
                 case 'get_post_meta_html_for_editor':
                     if (!isset($data['post_id']) || intval($data['post_id']) == 0) {
                         Essential_Grid::ajaxResponseError(__('No Post ID/Wrong Post ID!', EG_TEXTDOMAIN), false);
                         exit;
                     }
                     if (!isset($data['grid_id']) || intval($data['grid_id']) == 0) {
                         Essential_Grid::ajaxResponseError(__('Please save the grid first to use this feature!', EG_TEXTDOMAIN), false);
                         exit;
                     }
                     $post = get_post($data['post_id']);
                     $disable_advanced = true;
                     //nessecary, so that only normal things can be changed in preview mode
                     if (!empty($post)) {
                         $grid_id = $data['grid_id'];
                         ob_start();
                         require 'views/elements/grid-meta-box.php';
                         $content = ob_get_contents();
                         ob_clean();
                         ob_end_clean();
                         Essential_Grid::ajaxResponseData(array("data" => array('html' => $content)));
                     } else {
                         Essential_Grid::ajaxResponseError(__('Post not found!', EG_TEXTDOMAIN), false);
                         exit;
                     }
                     break;
                 case 'update_post_meta_through_editor':
                     if (!isset($data['metas']) || !isset($data['metas']['post_id']) || intval($data['metas']['post_id']) == 0) {
                         Essential_Grid::ajaxResponseError(__('No Post ID/Wrong Post ID!', EG_TEXTDOMAIN), false);
                         exit;
                     }
                     if (!isset($data['metas']) || !isset($data['metas']['grid_id']) || intval($data['metas']['grid_id']) == 0) {
                         Essential_Grid::ajaxResponseError(__('Please save the grid first to use this feature!', EG_TEXTDOMAIN), false);
                         exit;
                     }
                     //set the cobbles setting to the post
                     $cobbles = json_decode(get_post_meta($data['metas']['post_id'], 'eg_cobbles', true), true);
                     $cobbles[$data['metas']['grid_id']]['cobbles'] = $data['metas']['eg_cobbles_size'];
                     $cobbles = json_encode($cobbles);
                     update_post_meta($data['metas']['post_id'], 'eg_cobbles', $cobbles);
                     //set the use_skin setting to the post
                     $use_skin = json_decode(get_post_meta($data['metas']['post_id'], 'eg_use_skin', true), true);
                     $use_skin[$data['metas']['grid_id']]['use-skin'] = $data['metas']['eg_use_skin'];
                     $use_skin = json_encode($use_skin);
                     update_post_meta($data['metas']['post_id'], 'eg_use_skin', $use_skin);
                     $result = self::custom_meta_box_save($data['metas']['post_id'], $data['metas'], true);
                     self::check_for_transient_deletion($data['metas']['post_id']);
                     if ($result === true) {
                         Essential_Grid::ajaxResponseSuccess(__("Post Meta saved!", EG_TEXTDOMAIN), array());
                     } else {
                         Essential_Grid::ajaxResponseError(__('Post not found!', EG_TEXTDOMAIN), false);
                         exit;
                     }
                     break;
                 case 'trigger_post_meta_visibility':
                     if (!isset($data['post_id']) || intval($data['post_id']) == 0) {
                         Essential_Grid::ajaxResponseError(__('No Post ID/Wrong Post ID!', EG_TEXTDOMAIN), false);
                         exit;
                     }
                     if (!isset($data['grid_id']) || intval($data['grid_id']) == 0) {
                         Essential_Grid::ajaxResponseError(__('Please save the grid first to use this feature!', EG_TEXTDOMAIN), false);
                         exit;
                     }
                     $visibility = json_decode(get_post_meta($data['post_id'], 'eg_visibility', true), true);
                     $found = false;
                     if (!empty($visibility) && is_array($visibility)) {
                         foreach ($visibility as $grid => $setting) {
                             if ($grid == $data['grid_id']) {
                                 if ($setting == false) {
                                     $visibility[$grid] = true;
                                 } else {
                                     $visibility[$grid] = false;
                                 }
                                 $found = true;
                                 break;
                             }
                         }
                     }
                     if (!$found) {
                         $visibility[$data['grid_id']] = false;
                     }
                     $visibility = json_encode($visibility);
                     update_post_meta($data['post_id'], 'eg_visibility', $visibility);
                     self::check_for_transient_deletion($data['post_id']);
                     Essential_Grid::ajaxResponseSuccess(__("Visibility of Post for this Grid changed!", EG_TEXTDOMAIN), array());
                     break;
                 case 'get_image_by_id':
                     if (!isset($data['img_id']) || intval($data['img_id']) == 0) {
                         $error = __('Wrong Image ID given', EG_TEXTDOMAIN);
                     } else {
                         $img = wp_get_attachment_image_src($data['img_id'], 'full');
                         if ($img !== false) {
                             Essential_Grid::ajaxResponseSuccess('', array('url' => $img[0]));
                         } else {
                             $error = __('Image with given ID does not exist', EG_TEXTDOMAIN);
                         }
                     }
                     break;
                 case 'activate_purchase_code':
                     $result = false;
                     if (!empty($data['username']) && !empty($data['api_key']) && !empty($data['code'])) {
                         $result = Essential_Grid_Admin::check_purchase_verification($data);
                     } else {
                         $error = __('The API key, the Purchase Code and the Username need to be set!', EG_TEXTDOMAIN);
                     }
                     if ($result === true) {
                         Essential_Grid::ajaxResponseSuccess(__('Purchase Code Successfully Activated', EG_TEXTDOMAIN), array('data' => $result, 'is_redirect' => true, 'redirect_url' => self::getViewUrl("", "", 'essential-' . Essential_Grid_Admin::VIEW_START)));
                     } else {
                         if ($result !== false) {
                             $error = $result;
                         } else {
                             $error = __('Purchase Code is invalid', EG_TEXTDOMAIN);
                         }
                         Essential_Grid::ajaxResponseError($error, false);
                         exit;
                     }
                     break;
                 case 'deactivate_purchase_code':
                     $result = Essential_Grid_Admin::do_purchase_deactivation($data);
                     if ($result === true) {
                         Essential_Grid::ajaxResponseSuccess(__('Successfully removed validation', EG_TEXTDOMAIN), array('data' => $result, 'is_redirect' => true, 'redirect_url' => self::getViewUrl("", "", 'essential-' . Essential_Grid_Admin::VIEW_START)));
                     } else {
                         if ($result !== false) {
                             $error = $result;
                         } else {
                             $error = __('Could not remove Validation!', EG_TEXTDOMAIN);
                         }
                         Essential_Grid::ajaxResponseError($error, false);
                         exit;
                     }
                     break;
                 case 'dismiss_notice':
                     update_option('tp_eg_valid-notice', 'false');
                     Essential_Grid::ajaxResponseSuccess('.');
                     break;
                 case 'import_default_post_data':
                     try {
                         require EG_PLUGIN_PATH . 'includes/assets/default-posts.php';
                         require EG_PLUGIN_PATH . 'includes/assets/default-grids-meta-fonts.php';
                         if (isset($json_tax)) {
                             $import_tax = new PunchPost();
                             $import_tax->import_taxonomies($json_tax);
                         }
                         //insert meta, grids & punchfonts
                         $im = new Essential_Grid_Import();
                         if (isset($tp_grid_meta_fonts)) {
                             $tp_grid_meta_fonts = json_decode($tp_grid_meta_fonts, true);
                             $grids = @$tp_grid_meta_fonts['grids'];
                             if (!empty($grids) && is_array($grids)) {
                                 $grids_imported = $im->import_grids($grids);
                             }
                             $custom_metas = @$tp_grid_meta_fonts['custom-meta'];
                             if (!empty($custom_metas) && is_array($custom_metas)) {
                                 $custom_metas_imported = $im->import_custom_meta($custom_metas);
                             }
                             $custom_fonts = @$tp_grid_meta_fonts['punch-fonts'];
                             if (!empty($custom_fonts) && is_array($custom_fonts)) {
                                 $custom_fonts_imported = $im->import_punch_fonts($custom_fonts);
                             }
                         }
                         if (isset($json_posts)) {
                             $import = new PunchPort();
                             $import->set_tp_import_posts($json_posts);
                             $import->import_custom_posts();
                         }
                         Essential_Grid::ajaxResponseSuccess(__('Demo data successfully imported', EG_TEXTDOMAIN), array());
                     } catch (Exception $d) {
                         $error = __('Something went wrong, please contact the developer', EG_TEXTDOMAIN);
                     }
                     break;
                 case 'export_data':
                     $export_grids = self::getPostVar('export-grids-id', false);
                     $export_skins = self::getPostVar('export-skins-id', false);
                     $export_elements = self::getPostVar('export-elements-id', false);
                     $export_navigation_skins = self::getPostVar('export-navigation-skins-id', false);
                     $export_global_styles = self::getPostVar('export-global-styles', false);
                     $export_custom_meta = self::getPostVar('export-custom-meta-handle', false);
                     $export_punch_fonts = self::getPostVar('export-punch-fonts-handle', false);
                     header('Content-Type: text/json');
                     header('Content-Disposition: attachment;filename=ess_grid.json');
                     ob_start();
                     $export = array();
                     $ex = new Essential_Grid_Export();
                     //export Grids
                     if (!empty($export_grids)) {
                         $export['grids'] = $ex->export_grids($export_grids);
                     }
                     //export Skins
                     if (!empty($export_skins)) {
                         $export['skins'] = $ex->export_skins($export_skins);
                     }
                     //export Elements
                     if (!empty($export_elements)) {
                         $export['elements'] = $ex->export_elements($export_elements);
                     }
                     //export Navigation Skins
                     if (!empty($export_navigation_skins)) {
                         $export['navigation-skins'] = $ex->export_navigation_skins($export_navigation_skins);
                     }
                     //export Custom Meta
                     if (!empty($export_custom_meta)) {
                         $export['custom-meta'] = $ex->export_custom_meta($export_custom_meta);
                     }
                     //export Punch Fonts
                     if (!empty($export_punch_fonts)) {
                         $export['punch-fonts'] = $ex->export_punch_fonts($export_punch_fonts);
                     }
                     //export Global Styles
                     if ($export_global_styles == 'on') {
                         $export['global-css'] = $ex->export_global_styles($export_global_styles);
                     }
                     echo json_encode($export);
                     $content = ob_get_contents();
                     ob_clean();
                     ob_end_clean();
                     echo $content;
                     exit;
                     break;
                 case 'import_data':
                     if (!isset($data['imports']) || empty($data['imports'])) {
                         Essential_Grid::ajaxResponseError(__('No data for import selected', EG_TEXTDOMAIN), false);
                         exit;
                     }
                     try {
                         $im = new Essential_Grid_Import();
                         $temp_d = @$data['imports'];
                         unset($temp_d['data-grids']);
                         unset($temp_d['data-skins']);
                         unset($temp_d['data-elements']);
                         unset($temp_d['data-navigation-skins']);
                         unset($temp_d['data-global-css']);
                         $im->set_overwrite_data($temp_d);
                         //set overwrite data global to class
                         $skins = @$data['imports']['data-skins'];
                         if (!empty($skins) && is_array($skins)) {
                             foreach ($skins as $key => $skin) {
                                 $tskin = json_decode(stripslashes($skin), true);
                                 if (empty($tskin)) {
                                     $tskin = json_decode($skin, true);
                                 }
                                 $skins[$key] = $tskin;
                             }
                             if (!empty($skins)) {
                                 $skins_ids = @$data['imports']['import-skins-id'];
                                 $skins_imported = $im->import_skins($skins, $skins_ids);
                             }
                         }
                         $navigation_skins = @$data['imports']['data-navigation-skins'];
                         if (!empty($navigation_skins) && is_array($navigation_skins)) {
                             foreach ($navigation_skins as $key => $navigation_skin) {
                                 $tnavigation_skin = json_decode(stripslashes($navigation_skin), true);
                                 if (empty($tnavigation_skin)) {
                                     $tnavigation_skin = json_decode($navigation_skin, true);
                                 }
                                 $navigation_skins[$key] = $tnavigation_skin;
                             }
                             if (!empty($navigation_skins)) {
                                 $navigation_skins_ids = @$data['imports']['import-navigation-skins-id'];
                                 $navigation_skins_imported = $im->import_navigation_skins(@$navigation_skins, $navigation_skins_ids);
                             }
                         }
                         $grids = @$data['imports']['data-grids'];
                         if (!empty($grids) && is_array($grids)) {
                             foreach ($grids as $key => $grid) {
                                 $tgrid = json_decode(stripslashes($grid), true);
                                 if (empty($tgrid)) {
                                     $tgrid = json_decode($grid, true);
                                 }
                                 $grids[$key] = $tgrid;
                             }
                             if (!empty($grids)) {
                                 $grids_ids = @$data['imports']['import-grids-id'];
                                 $grids_imported = $im->import_grids($grids, $grids_ids);
                             }
                         }
                         $elements = @$data['imports']['data-elements'];
                         if (!empty($elements) && is_array($elements)) {
                             foreach ($elements as $key => $element) {
                                 $telement = json_decode(stripslashes($element), true);
                                 if (empty($telement)) {
                                     $telement = json_decode($element, true);
                                 }
                                 $elements[$key] = $telement;
                             }
                             if (!empty($elements)) {
                                 $elements_ids = @$data['imports']['import-elements-id'];
                                 $elements_imported = $im->import_elements(@$elements, $elements_ids);
                             }
                         }
                         $custom_metas = @$data['imports']['data-custom-meta'];
                         if (!empty($custom_metas) && is_array($custom_metas)) {
                             foreach ($custom_metas as $key => $custom_meta) {
                                 $tcustom_meta = json_decode(stripslashes($custom_meta), true);
                                 if (empty($tcustom_meta)) {
                                     $tcustom_meta = json_decode($custom_meta, true);
                                 }
                                 $custom_metas[$key] = $tcustom_meta;
                             }
                             if (!empty($custom_metas)) {
                                 $custom_metas_handle = @$data['imports']['import-custom-meta-handle'];
                                 $custom_metas_imported = $im->import_custom_meta($custom_metas, $custom_metas_handle);
                             }
                         }
                         $custom_fonts = @$data['imports']['data-punch-fonts'];
                         if (!empty($custom_fonts) && is_array($custom_fonts)) {
                             foreach ($custom_fonts as $key => $custom_font) {
                                 $tcustom_font = json_decode(stripslashes($custom_font), true);
                                 if (empty($tcustom_font)) {
                                     $tcustom_font = json_decode($custom_font, true);
                                 }
                                 $custom_fonts[$key] = $tcustom_font;
                             }
                             if (!empty($custom_fonts)) {
                                 $custom_fonts_handle = @$data['imports']['import-punch-fonts-handle'];
                                 $custom_fonts_imported = $im->import_punch_fonts($custom_fonts, $custom_fonts_handle);
                             }
                         }
                         if (@$data['imports']['import-global-styles'] == 'on') {
                             $global_css = @$data['imports']['data-global-css'];
                             $tglobal_css = stripslashes($global_css);
                             if (empty($tglobal_css)) {
                                 $tglobal_css = $global_css;
                             }
                             $global_styles_imported = $im->import_global_styles($tglobal_css);
                         }
                         Essential_Grid::ajaxResponseSuccess(__('Successfully imported data', EG_TEXTDOMAIN), array('is_redirect' => true, 'redirect_url' => self::getViewUrl("", "", 'essential-' . Essential_Grid_Admin::VIEW_START)));
                     } catch (Exception $d) {
                         $error = __('Something went wrong, please contact the developer', EG_TEXTDOMAIN);
                     }
                     break;
                 case 'delete_full_cache':
                     $lang = array();
                     if (Essential_Grid_Wpml::is_wpml_exists()) {
                         $lang = icl_get_languages();
                     }
                     $grids = Essential_Grid::get_essential_grids();
                     if (!empty($grids)) {
                         foreach ($grids as $grid) {
                             if (!empty($lang)) {
                                 foreach ($lang as $code => $val) {
                                     delete_transient('ess_grid_trans_query_' . $grid->id . $val['language_code']);
                                     delete_transient('ess_grid_trans_full_grid_' . $grid->id . $val['language_code']);
                                 }
                             } else {
                                 delete_transient('ess_grid_trans_query_' . $grid->id);
                                 delete_transient('ess_grid_trans_full_grid_' . $grid->id);
                             }
                         }
                     }
                     Essential_Grid::ajaxResponseSuccess(__('Successfully deleted all cache', EG_TEXTDOMAIN), array());
                     break;
                 case "get_image_url":
                     if (isset($data['imageid']) && intval($data['imageid']) > 0) {
                         $img_atts = wp_get_attachment_image_src($data['imageid']);
                         if ($img_atts !== false) {
                             $img_src = $img_atts[0];
                             Essential_Grid::ajaxResponseSuccess(__("Image URL found", EG_TEXTDOMAIN), array('url' => $img_src, 'imageid' => $data['imageid']));
                         }
                     }
                     $error = __('No correct image ID given', EG_TEXTDOMAIN);
                     break;
                 case "toggle_grid_favorite":
                     if (isset($data['id']) && intval($data['id']) > 0) {
                         $return = self::toggle_favorite_by_id($data['id']);
                         if ($return === true) {
                             Essential_Grid::ajaxResponseSuccess(__("Favorite Set", EG_TEXTDOMAIN));
                         } else {
                             $error = $return;
                         }
                     } else {
                         $error = __('No ID given', EG_TEXTDOMAIN);
                     }
                     break;
                 case "subscribe_to_newsletter":
                     if (isset($data['email']) && !empty($data['email'])) {
                         $return = ThemePunch_Newsletter::subscribe($data['email']);
                         if ($return !== false) {
                             if (!isset($return['status']) || $return['status'] === 'error') {
                                 $error = isset($return['message']) && !empty($return['message']) ? $return['message'] : __('Invalid Email', EG_TEXTDOMAIN);
                             } else {
                                 Essential_Grid::ajaxResponseSuccess(__("Success! Please check your Emails to finish the subscribtion", EG_TEXTDOMAIN), $return);
                             }
                         } else {
                             $error = __('Invalid Email/Could not connect to the Newsletter server', EG_TEXTDOMAIN);
                         }
                     } else {
                         $error = __('No Email given', EG_TEXTDOMAIN);
                     }
                     break;
                 case "unsubscribe_to_newsletter":
                     if (isset($data['email']) && !empty($data['email'])) {
                         $return = ThemePunch_Newsletter::unsubscribe($data['email']);
                         if ($return !== false) {
                             if (!isset($return['status']) || $return['status'] === 'error') {
                                 $error = isset($return['message']) && !empty($return['message']) ? $return['message'] : __('Invalid Email', EG_TEXTDOMAIN);
                             } else {
                                 Essential_Grid::ajaxResponseSuccess(__("Success! Please check your Emails to finish the process", EG_TEXTDOMAIN), $return);
                             }
                         } else {
                             $error = __('Invalid Email/Could not connect to the Newsletter server', EG_TEXTDOMAIN);
                         }
                     } else {
                         $error = __('No Email given', EG_TEXTDOMAIN);
                     }
                     break;
                 default:
                     $error = true;
                     break;
             }
         } else {
             $error = true;
         }
         if ($error !== false) {
             $showError = __("Wrong Request!", EG_TEXTDOMAIN);
             if ($error !== true) {
                 $showError = __("Ajax Error: ", EG_TEXTDOMAIN) . $error;
             }
             Essential_Grid::ajaxResponseError($showError, false);
         }
         exit;
     } catch (Exception $e) {
         exit;
     }
 }
Ejemplo n.º 6
0
<?php

if (!defined('ABSPATH')) {
    exit;
}
//force the js file to be included
wp_enqueue_script('essential-grid-item-editor-script', plugins_url('../../assets/js/grid-editor.js', __FILE__), array('jquery'), Essential_Grid::VERSION);
$base = new Essential_Grid_Base();
$item_elements = new Essential_Grid_Item_Element();
$meta = new Essential_Grid_Meta();
$meta_link = new Essential_Grid_Meta_Linking();
$fonts = new ThemePunch_Fonts();
//check if id exists and get data from database if so.
$skin = false;
$skin_id = false;
$isCreate = $base->getGetVar('create', 'true');
$title = __('Create New Item Skin', EG_TEXTDOMAIN);
$save = __('Save Item Skin', EG_TEXTDOMAIN);
if (intval($isCreate) > 0) {
    //currently editing
    $skin = Essential_Grid_Item_Skin::get_essential_item_skin_by_id(intval($isCreate));
    if (!empty($skin)) {
        $title = __('Change Item Skin', EG_TEXTDOMAIN);
        $save = __('Change Item Skin', EG_TEXTDOMAIN);
        $skin_id = intval($isCreate);
    }
}
$elements = $item_elements->getElementsForJavascript();
$style_attributes = $item_elements->get_existing_elements(true);
$all_attributes = $item_elements->get_existing_elements();
$element_type = $item_elements->getElementsForDropdown();
Ejemplo n.º 7
0
    /**
     * Edit Custom Element Dialog
     * @since    1.0.0
     */
    public static function edit_custom_element_dialog()
    {
        $meta = new Essential_Grid_Meta();
        $item_elements = new Essential_Grid_Item_Element();
        ?>
		<div id="edit-custom-element-dialog-wrap" class="essential-dialog-wrap" title="<?php 
        _e('Element Settings', EG_TEXTDOMAIN);
        ?>
"  style="display: none; padding:15px 0px;">
			<form id="edit-custom-element-form">
				<input type="hidden" name="custom-type" value="" />
				<div class="eg-elset-title esg-item-skin-media-title">
					<?php 
        _e('Media:', EG_TEXTDOMAIN);
        ?>
				</div>
				<div id="esg-item-skin-elements-media">
					<div class="eg-elset-row esg-item-skin-elements" id="esg-item-skin-elements-media-sound">
						<div class="eg-elset-label"  for="custom-soundcloud"><?php 
        _e('SoundCloud Track ID', EG_TEXTDOMAIN);
        ?>
</div><input name="custom-soundcloud" type="input" value="" />
					</div>
					<div class="eg-elset-row esg-item-skin-elements" id="esg-item-skin-elements-media-youtube">
						<div class="eg-elset-label"  for="custom-soundcloud"><?php 
        _e('YouTube ID', EG_TEXTDOMAIN);
        ?>
</div><input name="custom-youtube" type="input" value="" />
					</div>
					<div class="eg-elset-row esg-item-skin-elements" id="esg-item-skin-elements-media-vimeo">
						<div class="eg-elset-label"  for="custom-soundcloud"><?php 
        _e('Vimeo ID', EG_TEXTDOMAIN);
        ?>
</div><input name="custom-vimeo" type="input" value="" />
					</div>
					<div class="esg-item-skin-elements" id="esg-item-skin-elements-media-html5">
						<div class="eg-elset-row"><div class="eg-elset-label"  for="custom-html5-mp4"><?php 
        _e('MP4', EG_TEXTDOMAIN);
        ?>
</div><input name="custom-html5-mp4" type="input" value="" /></div>
						<div class="eg-elset-row"><div class="eg-elset-label"  for="custom-html5-ogv"><?php 
        _e('OGV', EG_TEXTDOMAIN);
        ?>
</div><input name="custom-html5-ogv" type="input" value="" /></div>
						<div class="eg-elset-row"><div class="eg-elset-label"  for="custom-html5-webm"><?php 
        _e('WEBM', EG_TEXTDOMAIN);
        ?>
</div><input name="custom-html5-webm" type="input" value="" /></div>
					</div>
					<div class="eg-elset-row esg-item-skin-elements" id="esg-item-skin-elements-media-image">
						<div class="eg-elset-label" for="custom-image"><?php 
        _e('Image', EG_TEXTDOMAIN);
        ?>
</div>
						<input type="hidden" value="" id="esg-custom-image" name="custom-image">
						<a id="eg-custom-choose-from-image-library" class="button-primary revblue" href="javascript:void(0);" data-setto="esg-custom-image"><?php 
        _e('Choose Image', EG_TEXTDOMAIN);
        ?>
</a>
						<a id="eg-custom-clear-from-image-library" class="button-primary revred eg-custom-remove-custom-meta-field" href="javascript:void(0);"><?php 
        _e('Remove Image', EG_TEXTDOMAIN);
        ?>
</a>
						
						<div id="custom-image-wrapper" style="width:100%;">
							<img id="esg-custom-image-img" src="" style="max-width:200px; display: none;margin:20px 0px 0px 250px;">
						</div>
					</div>
					<div class="eg-elset-row esg-item-skin-elements" id="esg-item-skin-elements-media-ratio">
						<div class="eg-elset-label"  for="custom-ratio"><?php 
        _e('Video Ratio', EG_TEXTDOMAIN);
        ?>
</div>
						<select name="custom-ratio">
							<option value="0"><?php 
        _e('4:3', EG_TEXTDOMAIN);
        ?>
</option>
							<option value="1"><?php 
        _e('16:9', EG_TEXTDOMAIN);
        ?>
</option>
						</select>
					</div>
				</div>
				<div id="">
					
					<?php 
        $custom_meta = $meta->get_all_meta(false);
        if (!empty($custom_meta)) {
            echo '<div class="eg-elset-title">';
            _e('Custom Meta:', EG_TEXTDOMAIN);
            echo '</div>';
            foreach ($custom_meta as $cmeta) {
                ?>
							<div class="eg-elset-row"><div class="eg-elset-label"  class="eg-mb-label"><?php 
                echo $cmeta['name'];
                ?>
:</div>
								<?php 
                switch ($cmeta['type']) {
                    case 'text':
                        echo '<input type="text" name="eg-' . $cmeta['handle'] . '" value="" />';
                        break;
                    case 'select':
                    case 'multi-select':
                        $do_array = $cmeta['type'] == 'multi-select' ? '[]' : '';
                        $el = $meta->prepare_select_by_string($cmeta['select']);
                        echo '<select name="eg-' . $cmeta['handle'] . $do_array . '"';
                        if ($cmeta['type'] == 'multi-select') {
                            echo ' multiple="multiple" size="5"';
                        }
                        echo '>';
                        if (!empty($el) && is_array($el)) {
                            if ($cmeta['type'] == 'multi-select') {
                                echo '<option value="">' . __('---', EG_TEXTDOMAIN) . '</option>';
                            }
                            foreach ($el as $ele) {
                                echo '<option value="' . $ele . '">' . $ele . '</option>';
                            }
                        }
                        echo '</select>';
                        break;
                    case 'image':
                        $var_src = '';
                        ?>
										<input type="hidden" value="" name="eg-<?php 
                        echo $cmeta['handle'];
                        ?>
" id="eg-<?php 
                        echo $cmeta['handle'] . '-cm';
                        ?>
" />
										<a class="button-primary revblue eg-image-add" href="javascript:void(0);" data-setto="eg-<?php 
                        echo $cmeta['handle'] . '-cm';
                        ?>
"><?php 
                        _e('Choose Image', EG_TEXTDOMAIN);
                        ?>
</a>
										<a class="button-primary revred eg-image-clear" href="javascript:void(0);" data-setto="eg-<?php 
                        echo $cmeta['handle'] . '-cm';
                        ?>
"><?php 
                        _e('Remove Image', EG_TEXTDOMAIN);
                        ?>
</a>
										<div>
											<img id="eg-<?php 
                        echo $cmeta['handle'] . '-cm';
                        ?>
-img" src="<?php 
                        echo $var_src;
                        ?>
" <?php 
                        echo $var_src == '' ? 'style="max-width:200px; display: none;margin:20px 0px 0px 250px;"' : '';
                        ?>
>
										</div>
										<?php 
                        break;
                }
                ?>
							</div>
							<?php 
            }
        } else {
            _e('No metas available yet. Add some through the Custom Meta menu of Essential Grid.', EG_TEXTDOMAIN);
            ?>
<div style="clear:both; height:20px"></div><?php 
        }
        $elements = $item_elements->getElementsForDropdown();
        $p_lang = array('post' => __('Post', EG_TEXTDOMAIN), 'woocommerce' => __('WooCommerce', EG_TEXTDOMAIN));
        foreach ($elements as $type => $element) {
            ?>
						<div class="eg-elset-title">
							<?php 
            echo $p_lang[$type];
            ?>
						</div>
						<?php 
            foreach ($element as $handle => $name) {
                echo '<div class="eg-elset-row"><div class="eg-elset-label"  for="' . $handle . '">' . $name['name'] . ':</div><input name="' . $handle . '" value="" /></div>';
            }
        }
        echo '<div class="eg-elset-title">';
        _e('Link To:', EG_TEXTDOMAIN);
        echo '</div>';
        echo '<div class="eg-elset-row"><div class="eg-elset-label"  for="post-link">' . __('Post Link', EG_TEXTDOMAIN) . ':</div><input name="post-link" value="" /></div>';
        echo '<div class="eg-elset-title">';
        _e('Other:', EG_TEXTDOMAIN);
        echo '</div>';
        echo '<div class="eg-elset-row"><div class="eg-elset-label"  for="custom-filter">' . __('Filter (comma seperated)', EG_TEXTDOMAIN) . ':</div><input name="custom-filter" value="" /></div>';
        ?>
					<div class="eg-elset-row">
						<div class="eg-elset-label" for="cobbles">
							<?php 
        _e('Cobbles Element Size:', EG_TEXTDOMAIN);
        ?>
						</div>
						<select name="cobbles-size">
							<option value="1:1"><?php 
        _e('width 1, height 1', EG_TEXTDOMAIN);
        ?>
</option>
							<option value="1:2"><?php 
        _e('width 1, height 2', EG_TEXTDOMAIN);
        ?>
</option>
							<option value="1:3"><?php 
        _e('width 1, height 3', EG_TEXTDOMAIN);
        ?>
</option>
							<option value="2:1"><?php 
        _e('width 2, height 1', EG_TEXTDOMAIN);
        ?>
</option>
							<option value="2:2"><?php 
        _e('width 2, height 2', EG_TEXTDOMAIN);
        ?>
</option>
							<option value="2:3"><?php 
        _e('width 2, height 3', EG_TEXTDOMAIN);
        ?>
</option>
							<option value="3:1"><?php 
        _e('width 3, height 1', EG_TEXTDOMAIN);
        ?>
</option>
							<option value="3:2"><?php 
        _e('width 3, height 2', EG_TEXTDOMAIN);
        ?>
</option>
							<option value="3:3"><?php 
        _e('width 3, height 3', EG_TEXTDOMAIN);
        ?>
</option>
						</select>
					</div>
					<div class="eg-elset-row">
						<?php 
        $skins = Essential_Grid_Item_Skin::get_essential_item_skins('all', false);
        ?>
						<div class="eg-elset-label" for="use-skin">
							<?php 
        _e('Choose Specific Skin:', EG_TEXTDOMAIN);
        ?>
						</div>
						<select name="use-skin">
							<option value="-1"><?php 
        _e('-- Default Skin --', EG_TEXTDOMAIN);
        ?>
</option>
							<?php 
        if (!empty($skins)) {
            foreach ($skins as $skin) {
                echo '<option value="' . $skin['id'] . '">' . $skin['name'] . '</option>' . "\n";
            }
        }
        ?>
						</select>
					</div>
				</div>
			</form>
			<script type="text/javascript">
				jQuery('.eg-image-add').click(function(e) {
					e.preventDefault();
					AdminEssentials.upload_image_img(jQuery(this).data('setto'));
					
					return false; 
				});
				
				jQuery('.eg-image-clear').click(function(e) {
					e.preventDefault();
					var setto = jQuery(this).data('setto');
					jQuery('#'+setto).val('');
					jQuery('#'+setto+'-img').attr("src","");
					jQuery('#'+setto+'-img').hide();
					return false; 
				});
				
				jQuery('#eg-custom-choose-from-image-library').click(function(e) {
					e.preventDefault();
					AdminEssentials.upload_image_img(jQuery(this).data('setto'));
					
					return false; 
				});
				
				jQuery('#eg-custom-clear-from-image-library').click(function(e) {
					e.preventDefault();
					jQuery('#esg-custom-image-src').val('');
					jQuery('#custom-image-img').attr("src","");
					jQuery('#custom-image-img').hide();
					return false; 
				});
			</script>
		</div>
		<?php 
    }
Ejemplo n.º 8
0
 /**
  * replace all metas with corresponding text
  */
 public function replace_all_meta_in_text($post_id, $text)
 {
     if (trim($text) === '' || intval($post_id) === 0) {
         return '';
     }
     $base = new Essential_Grid_Base();
     $meta_link = new Essential_Grid_Meta_Linking();
     $cmeta = $this->get_all_meta();
     //process meta tags:
     $arr_matches = array();
     preg_match_all("/%[^%]*%/", $text, $arr_matches);
     if (!empty($arr_matches)) {
         $my_post = get_post($post_id, ARRAY_A);
         foreach ($arr_matches as $matches) {
             if (is_array($matches)) {
                 foreach ($matches as $match) {
                     $meta = trim(str_replace('%', '', $match));
                     $meta_value = get_post_meta($post_id, $meta, true);
                     if (!empty($cmeta)) {
                         foreach ($cmeta as $me) {
                             if ('eg-' . $me['handle'] == $meta) {
                                 if ($me['type'] == 'image') {
                                     if (intval($meta_value) > 0) {
                                         //get URL to Image
                                         $img = wp_get_attachment_image_src($meta_value, 'full');
                                         if ($img !== false) {
                                             $meta_value = $img[0];
                                         } else {
                                             $meta_value = '';
                                         }
                                     } else {
                                         $meta_value = '';
                                     }
                                 }
                                 if ($meta_value == '' && isset($me['default'])) {
                                     $meta_value = $me['default'];
                                 }
                                 break;
                             }
                         }
                     }
                     //check woocommerce
                     if (Essential_Grid_Woocommerce::is_woo_exists()) {
                         $wc_text = Essential_Grid_Woocommerce::get_value_by_meta($post_id, $meta);
                         if ($wc_text !== '') {
                             $meta_value = $wc_text;
                         }
                     }
                     if (empty($meta_value) && !empty($my_post)) {
                         //try to get from post
                         switch ($meta) {
                             //Post elements
                             case 'post_url':
                                 $post_id = $base->getVar($my_post, 'ID', '');
                                 $meta_value = get_permalink($post_id);
                                 break;
                             case 'post_id':
                                 $meta_value = $base->getVar($my_post, 'ID', '');
                                 break;
                             case 'title':
                                 $meta_value = $base->getVar($my_post, 'post_title', '');
                                 break;
                             case 'excerpt':
                                 $meta_value = trim($base->getVar($my_post, 'post_excerpt'));
                                 if (empty($meta_value)) {
                                     $meta_value = trim($base->getVar($my_post, 'post_content'));
                                 }
                                 $meta_value = strip_tags($meta_value);
                                 //,"<b><br><br/><i><strong><small>"
                                 break;
                             case 'meta':
                                 $m = new Essential_Grid_Meta();
                                 $meta_value = $m->get_meta_value_by_handle($my_post['ID'], $meta);
                                 break;
                             case 'alias':
                                 $meta_value = $base->getVar($my_post, 'post_name');
                                 break;
                             case 'content':
                                 $meta_value = $base->getVar($my_post, 'post_content');
                                 break;
                             case 'link':
                                 $meta_value = get_permalink($my_post['ID']);
                                 break;
                             case 'date':
                                 $postDate = $base->getVar($my_post, "post_date_gmt");
                                 $meta_value = $base->convert_post_date($postDate);
                                 break;
                             case 'date_modified':
                                 $dateModified = $base->getVar($my_post, "post_modified");
                                 $meta_value = $base->convert_post_date($dateModified);
                                 break;
                             case 'author_name':
                                 $authorID = $base->getVar($my_post, 'post_author');
                                 $meta_value = get_the_author_meta('display_name', $authorID);
                                 break;
                             case 'num_comments':
                                 $meta_value = $base->getVar($my_post, 'comment_count');
                                 break;
                             case 'cat_list':
                                 $use_taxonomies = false;
                                 $postCatsIDs = $base->getVar($my_post, 'post_category');
                                 if (empty($postCatsIDs) && isset($my_post['post_type'])) {
                                     $postCatsIDs = array();
                                     $obj = get_object_taxonomies($my_post['post_type']);
                                     if (!empty($obj) && is_array($obj)) {
                                         foreach ($obj as $tax) {
                                             $use_taxonomies[] = $tax;
                                             $new_terms = get_the_terms($my_post['ID'], $tax);
                                             if (is_array($new_terms) && !empty($new_terms)) {
                                                 foreach ($new_terms as $term) {
                                                     $postCatsIDs[$term->term_id] = $term->term_id;
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 $meta_value = $base->get_categories_html_list($postCatsIDs, true, ',', $use_taxonomies);
                                 break;
                             case 'tag_list':
                                 $meta_value = $base->get_tags_html_list($my_post['ID']);
                                 break;
                             default:
                                 $meta_value = apply_filters('essgrid_post_meta_content', $meta_value, $meta, $my_post['ID'], $my_post);
                                 break;
                                 break;
                         }
                         if (empty($meta_value)) {
                             //check if its linking
                             $meta_value = $meta_link->get_link_meta_value_by_handle($my_post['ID'], $meta);
                         }
                     }
                     $text = str_replace($match, $meta_value, $text);
                 }
             }
         }
     }
     return $text;
 }
Ejemplo n.º 9
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();
 }
Ejemplo n.º 10
0
<?php

/**
 * @package   Essential_Grid
 * @author    ThemePunch <*****@*****.**>
 * @link      http://www.themepunch.com/essential/
 * @copyright 2014 ThemePunch
 */
//force the js file to be included
//wp_enqueue_script('essential-grid-item-editor-script', EG_PLUGIN_URL.'admin/assets/js/grid-editor.js', array('jquery'), Essential_Grid::VERSION );
$metas = new Essential_Grid_Meta();
$meta_links = new Essential_Grid_Meta_Linking();
?>
	<h2 class="topheader"><?php 
echo esc_html(get_admin_page_title());
?>
</h2>
	
	<div id="eg-grid-custom-meta-wrapper">
		<ul class="es-grid-meta-tabs">
			<li><a href="#eg-custom-meta-wrap"><?php 
_e('Custom Meta', EG_TEXTDOMAIN);
?>
</a></li>
			<li><a href="#eg-meta-links-wrap"><?php 
_e('Meta References / Aliases', EG_TEXTDOMAIN);
?>
</a></li>
		</ul>
		<div id="eg-custom-meta-wrap">
			<div class="eg-custom-meta-info-box" style="padding:10px 15px; margin-bottom:15px;background:#3498db; color:#fff;">
Ejemplo n.º 11
0
 /**
  * Retrieve the value of post elements
  */
 public function get_custom_element_value($handle, $separator, $meta = '')
 {
     $base = new Essential_Grid_Base();
     $m = new Essential_Grid_Meta();
     $text = '';
     $text = $base->getVar($this->layer_values, $handle, '');
     if ($text == '' && $meta != '') {
         $text = $base->getVar($this->layer_values, $meta, '');
     }
     if (intval($text) > 0) {
         //we may be an image from the metas
         $custom_meta = $m->get_all_meta(false);
         if (!empty($custom_meta)) {
             foreach ($custom_meta as $cmeta) {
                 if ($cmeta['handle'] == $handle) {
                     if ($cmeta['type'] == 'image') {
                         $img = wp_get_attachment_image_src($text, $this->media_sources_type);
                         if ($img !== false) {
                             $text = $img[0];
                             //replace with URL
                         }
                     }
                     break;
                 }
             }
         }
     }
     return $text;
 }
Ejemplo n.º 12
0
 * @package   Essential_Grid
 * @author    ThemePunch <*****@*****.**>
 * @link      http://www.themepunch.com/essential/
 * @copyright 2014 ThemePunch
 */
if (!defined('ABSPATH')) {
    exit;
}
if (!isset($post)) {
    return false;
}
//not called as it should be
$base = new Essential_Grid_Base();
$item_skin = new Essential_Grid_Item_Skin();
$item_elements = new Essential_Grid_Item_Element();
$meta = new Essential_Grid_Meta();
$values = get_post_custom($post->ID);
$eg_sources_html5_mp4 = isset($values['eg_sources_html5_mp4']) ? esc_attr($values['eg_sources_html5_mp4'][0]) : "";
$eg_sources_html5_ogv = isset($values['eg_sources_html5_ogv']) ? esc_attr($values['eg_sources_html5_ogv'][0]) : "";
$eg_sources_html5_webm = isset($values['eg_sources_html5_webm']) ? esc_attr($values['eg_sources_html5_webm'][0]) : "";
$eg_vimeo_ratio = isset($values['eg_vimeo_ratio']) ? esc_attr($values['eg_vimeo_ratio'][0]) : "0";
$eg_youtube_ratio = isset($values['eg_youtube_ratio']) ? esc_attr($values['eg_youtube_ratio'][0]) : "0";
$eg_wistia_ratio = isset($values['eg_wistia_ratio']) ? esc_attr($values['eg_wistia_ratio'][0]) : "0";
$eg_html5_ratio = isset($values['eg_html5_ratio']) ? esc_attr($values['eg_html5_ratio'][0]) : "0";
$eg_soundcloud_ratio = isset($values['eg_soundcloud_ratio']) ? esc_attr($values['eg_soundcloud_ratio'][0]) : "0";
$eg_sources_youtube = isset($values['eg_sources_youtube']) ? esc_attr($values['eg_sources_youtube'][0]) : "";
$eg_sources_wistia = isset($values['eg_sources_wistia']) ? esc_attr($values['eg_sources_wistia'][0]) : "";
$eg_sources_vimeo = isset($values['eg_sources_vimeo']) ? esc_attr($values['eg_sources_vimeo'][0]) : "";
$eg_sources_image = isset($values['eg_sources_image']) ? esc_attr($values['eg_sources_image'][0]) : "";
$eg_sources_iframe = isset($values['eg_sources_iframe']) ? esc_attr($values['eg_sources_iframe'][0]) : "";
$eg_sources_soundcloud = isset($values['eg_sources_soundcloud']) ? esc_attr($values['eg_sources_soundcloud'][0]) : "";
Ejemplo n.º 13
0
<?php

/**
 * @package   Essential_Grid
 * @author    ThemePunch <*****@*****.**>
 * @link      http://www.themepunch.com/essential/
 * @copyright 2014 ThemePunch
 */
if (!defined('ABSPATH')) {
    exit;
}
$c_grids = new Essential_Grid();
$item_skin = new Essential_Grid_Item_Skin();
$item_ele = new Essential_Grid_Item_Element();
$nav_skin = new Essential_Grid_Navigation();
$metas = new Essential_Grid_Meta();
$fonts = new ThemePunch_Fonts();
$grids = $c_grids->get_essential_grids();
$skins = $item_skin->get_essential_item_skins();
$elements = $item_ele->get_essential_item_elements();
$navigation_skins = $nav_skin->get_essential_navigation_skins();
$custom_metas = $metas->get_all_meta();
$custom_fonts = $fonts->get_all_fonts();
$token = wp_create_nonce("Essential_Grid_actions");
$import_data = false;
if (isset($_FILES['import_file'])) {
    if ($_FILES['import_file']['error'] > 0) {
        echo '<div class="error"><p>' . __('Invalid file or file size too big.', EG_TEXTDOMAIN) . '</p></div>';
    } else {
        $file_name = $_FILES['import_file']['name'];
        $ext = explode(".", $file_name);
Ejemplo n.º 14
0
 public function import_custom_meta($import_custom_meta, $import_handles = true, $check_append = true)
 {
     $base = new Essential_Grid_Base();
     $metas = new Essential_Grid_Meta();
     $link_metas = new Essential_Grid_Meta_Linking();
     $custom_metas = $metas->get_all_meta();
     foreach ($import_custom_meta as $i_custom_meta) {
         $type = isset($i_custom_meta['m_type']) && $i_custom_meta['m_type'] == 'link' ? 'link' : 'meta';
         if (!empty($import_handles) && is_array($import_handles)) {
             $found = false;
             foreach ($import_handles as $handle) {
                 if ($i_custom_meta['handle'] == $handle) {
                     $found = true;
                     break;
                 }
             }
             if (!$found) {
                 continue;
             }
         } else {
             if ($import_handles !== true) {
                 break;
             }
         }
         $exist = false;
         if (!empty($custom_metas)) {
             foreach ($custom_metas as $meta) {
                 if ($meta['handle'] == $i_custom_meta['handle']) {
                     if ($type == $meta['m_type']) {
                         $exist = true;
                         break;
                     }
                 }
             }
         }
         if ($import_handles == true) {
             //do not insert if handle exists. This is for the import demo data process
             if ($exist) {
                 continue;
             }
         }
         $append = true;
         if ($exist) {
             //skin exists - append or overwrite
             if ($check_append) {
                 //check in $_POST if append or overwrite
                 $do = $base->getVar($this->overwrite_data, 'custom-meta-overwrite-' . $i_custom_meta['handle'], 'append');
                 $append = $do == 'append' ? true : false;
             }
         }
         if ($import_handles !== true) {
             if ($append) {
                 //append
                 if ($exist) {
                     $orig_handle = $i_custom_meta['handle'];
                     $i_custom_meta['handle'] = $i_custom_meta['handle'] . '-' . date('His');
                     $i_custom_meta['name'] = $i_custom_meta['name'] . '-' . date('His');
                 }
                 if ($type == 'meta') {
                     $metas->add_new_meta($i_custom_meta);
                 } elseif ($type == 'link') {
                     $link_metas->add_new_link_meta($i_custom_meta);
                 }
             } else {
                 //overwrite
                 if ($type == 'meta') {
                     $metas->edit_meta_by_handle($i_custom_meta);
                 } elseif ($type == 'link') {
                     $link_metas->edit_link_meta_by_handle($i_custom_meta);
                 }
             }
         } else {
             //create or overwrite
             if ($exist) {
                 if ($type == 'meta') {
                     $metas->edit_meta_by_handle($i_custom_meta);
                 } elseif ($type == 'link') {
                     $link_metas->edit_link_meta_by_handle($i_custom_meta);
                 }
             } else {
                 if ($type == 'meta') {
                     $metas->add_new_meta($i_custom_meta);
                 } elseif ($type == 'link') {
                     $link_metas->add_new_link_meta($i_custom_meta);
                 }
             }
         }
     }
 }
Ejemplo n.º 15
0
 public function export_essential_grid()
 {
     require_once ABSPATH . 'wp-content/plugins/essential-grid/essential-grid.php';
     $c_grid = new Essential_Grid();
     $export_grids = array();
     $grids = $c_grid->get_essential_grids();
     foreach ($grids as $grid) {
         $export_grids[] = $grid->id;
     }
     $export_skins = array();
     $item_skin = new Essential_Grid_Item_Skin();
     $skins = $item_skin->get_essential_item_skins('all', false);
     foreach ($skins as $skin) {
         $export_grids[] = $skin['id'];
     }
     $export_elements = array();
     $c_elements = new Essential_Grid_Item_Element();
     $elements = $c_elements->get_essential_item_elements();
     foreach ($elements as $element) {
         $export_elements[] = $element['id'];
     }
     $export_navigation_skins = array();
     $c_nav_skins = new Essential_Grid_Navigation();
     $nav_skins = $c_nav_skins->get_essential_navigation_skins();
     foreach ($nav_skins as $nav_skin) {
         $export_navigation_skins[] = $nav_skin['id'];
     }
     $export_custom_meta = array();
     $metas = new Essential_Grid_Meta();
     $custom_metas = $metas->get_all_meta();
     foreach ($custom_metas as $custom_meta) {
         $export_custom_meta[] = $custom_meta['handle'];
     }
     $export_punch_fonts = array();
     $fonts = new ThemePunch_Fonts();
     $custom_fonts = $fonts->get_all_fonts();
     foreach ($custom_fonts as $custom_font) {
         $export_punch_fonts[] = $custom_font['handle'];
     }
     $export = array();
     $ex = new Essential_Grid_Export();
     //export Grids
     if (!empty($export_grids)) {
         $export['grids'] = $ex->export_grids($export_grids);
     }
     //export Skins
     if (!empty($export_skins)) {
         $export['skins'] = $ex->export_skins($export_skins);
     }
     //export Elements
     if (!empty($export_elements)) {
         $export['elements'] = $ex->export_elements($export_elements);
     }
     //export Navigation Skins
     if (!empty($export_navigation_skins)) {
         $export['navigation-skins'] = $ex->export_navigation_skins($export_navigation_skins);
     }
     //export Custom Meta
     if (!empty($export_custom_meta)) {
         $export['custom-meta'] = $ex->export_custom_meta($export_custom_meta);
     }
     //export Punch Fonts
     if (!empty($export_punch_fonts)) {
         $export['punch-fonts'] = $ex->export_punch_fonts($export_punch_fonts);
     }
     //export Global Styles
     $export['global-css'] = $ex->export_global_styles('on');
     $this->save_as_txt_file('essential_grid.txt', json_encode($export));
 }