/** * Get Navigation Skin by ID from Database */ public static function get_essential_navigation_skin_by_handle($handle = '') { global $wpdb; if ($handle == '') { return false; } $table_name = $wpdb->prefix . Essential_Grid::TABLE_NAVIGATION_SKINS; $skin = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$table_name} WHERE handle = %s", $handle), ARRAY_A); if (!empty($skin)) { $skin['css'] = Essential_Grid_Base::stripslashes_deep($skin['css']); } return $skin; }
/** * add search shortcode functionality * @since: 2.0 */ public static function register_shortcode_search($args, $mid_content = null) { extract(shortcode_atts(array('handle' => ''), $args, 'ess_grid_search')); if (trim($handle) === '') { return false; } $settings = get_option('esg-search-settings', array('settings' => array(), 'global' => array(), 'shortcode' => array())); $settings = Essential_Grid_Base::stripslashes_deep($settings); if (!isset($settings['shortcode']['sc-handle'])) { return false; } $use_key = false; foreach ($settings['shortcode']['sc-handle'] as $key => $sc_handle) { if ($sc_handle === $handle) { $use_key = $key; } } if ($key === false) { return false; } //we have found it, now proceed if correct handle and a text was set it $class = 'eg-' . sanitize_html_class($settings['shortcode']['sc-handle'][$use_key]); if ($class === '') { return false; } $text = trim($settings['shortcode']['sc-html'][$use_key]); if ($text === '') { return false; } //modify text so that we add 1. the class to existing if there is a tag element in it (add only to first wrap). 2. the class as new if there is a tag element inside. 3. wrap text around it if there is not tag element $search = new Essential_Grid_Search(true); //true will enqueue scripts to page preg_match_all('/<(.*?)>/', $text, $matches); if (!empty($matches[0])) { //check if first tag has class, if not add it $string = $matches[0][0]; if (strpos($string, 'class="') !== false) { $new_text = str_replace('class="', 'class="' . $class . ' ', $string); } elseif (strpos($string, "class='") !== false) { $new_text = str_replace("class='", "class='" . $class . ' ', $string); } else { $use_string = $matches[1][0]; $new_text = '<' . $use_string . ' class="' . $class . '">'; } $text = str_replace($string, $new_text, $text); } else { $text = '<a href="javascript:void(0);" class="' . $class . '">' . $text . '</a>'; } return $text; }
/** * Get $_POST/$_GET Parameter */ public static function getVar($arr, $key, $default = "", $type = "") { $val = $default; if (isset($arr[$key])) { $val = $arr[$key]; } switch ($type) { case 'i': //int $val = intval($val); break; case 'f': //float $val = floatval($val); break; case 'r': //raw meaning, do nothing break; default: $val = Essential_Grid_Base::stripslashes_deep($val); break; } return $val; }
/** * Get Array of Text Elements */ public static function getTextElementsArray() { global $wpdb; $custom = array(); $elements = self::get_essential_item_elements(); if (!empty($elements)) { foreach ($elements as $element) { $custom[$element['handle']] = array('id' => $element['id'], 'name' => $element['name'], 'settings' => json_decode($element['settings'], true)); } } Essential_Grid_Base::stripslashes_deep($custom); return $custom; }
/** * Get Item Skin by ID from Database */ public static function get_essential_item_skin_by_id($id = 0) { global $wpdb; $id = intval($id); if ($id == 0) { return false; } $table_name = $wpdb->prefix . Essential_Grid::TABLE_ITEM_SKIN; $skin = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$table_name} WHERE id = %d", $id), ARRAY_A); if (!empty($skin)) { $skin['params'] = Essential_Grid_Base::stripslashes_deep(@json_decode($skin['params'], true)); $layers = @json_decode($skin['layers'], true); if (!empty($layers) && is_array($layers)) { //prevent overhead foreach ($layers as $lkey => $layer) { $layers[$lkey] = Essential_Grid_Base::stripslashes_deep($layer); } } $skin['layers'] = $layers; //$skin['layers'] = Essential_Grid_Base::stripslashes_deep(@json_decode($skin['layers'], true)); $skin['settings'] = Essential_Grid_Base::stripslashes_deep(@json_decode($skin['settings'], true)); } return $skin; }
<?php /** * Panel to the search options. * * @package Essential_Grid * @author ThemePunch <*****@*****.**> * @link http://www.themepunch.com/essential/ * @copyright 2014 ThemePunch * @since: 2.0 */ $settings = get_option('esg-search-settings', array('settings' => array(), 'global' => array(), 'shortcode' => array())); $settings = Essential_Grid_Base::stripslashes_deep($settings); $base = new Essential_Grid_Base(); $grids = Essential_Grid::get_grids_short(); $my_skins = array('light' => __('Light', EG_TEXTDOMAIN), 'dark' => __('Dark', EG_TEXTDOMAIN)); $my_skins = apply_filters('essgrid_modify_search_skins', $my_skins); ?> <h2 class="topheader"><?php _e('Search Settings', EG_TEXTDOMAIN); ?> </h2> <div id="eg-grid-search-wrapper"> <ul class="es-grid-search-tabs"> <li><a href="#eg-search-settings-wrap"><?php _e('Global Settings', EG_TEXTDOMAIN); ?> </a></li> <li><a href="#eg-shortcode-search-wrap"><?php _e('ShortCode Search', EG_TEXTDOMAIN);