function facets($wp_query, $args)
 {
     if (!is_search() || !Config::option('enable')) {
         return;
     }
     return $args;
 }
 /**
  * A convenient method that aggregates the results of all the other methods in the class. Example of output:
  *
  * <code>
  *    array(
  *        // the keys are names of fields and/or taxonomies
  *        'taxonomy' => array(
  *            'available' => array(
  *                'taxonomy1'    => array(
  *                    'count'    => 10,
  *                    'slug'    => 'taxonomy1',
  *                    'name'    => 'Taxonomy One',
  *                    'font'    => 24
  *                )
  *            ),
  *            'selected' => array(
  *                'taxonomy2'    => array(
  *                    'slug'    => 'taxonomy2',
  *                    'name'    => 'Taxonomy Two'
  *                )
  *            ),
  *            'total' => 10
  *        ),
  *        'rating' => array(
  *            'available' => array(
  *                '10-20' => array(
  *                    'count'    => 4,
  *                    'slug'    => '10-20',
  *                    'to'    => 20,
  *                    'from'    => 10
  *                )
  *            ),
  *            'total' => 4
  *        )
  *    )
  * </code>
  *
  * @param string $minFont The minimum font size to use for display in a tag cloud (defaults to : 12)
  * @param string $maxFont The maximum font size to use for display in a tag cloud (defaults to : 24)
  *
  * @return array An associative array where the keys represent the data point with a list of selected and/or available options.
  **/
 static function all($minFont = 12, $maxFont = 24)
 {
     $options = array();
     foreach (Config::taxonomies() as $tax) {
         $options[$tax] = self::taxonomy($tax);
     }
     $numeric = Config::option('numeric');
     $fields = array_merge(Config::fields(), Config::meta_fields());
     foreach ($fields as $field) {
         if (isset($numeric[$field])) {
             $options[$field] = self::range($field);
         }
         if ($field == 'post_type') {
             $options['post_type'] = self::types(Config::types());
         }
     }
     foreach (Config::customFacets() as $field) {
         $options[$field] = self::custom($field);
     }
     foreach ($options as $name => &$field) {
         if (isset($field['available'])) {
             foreach ($field['available'] as &$available) {
                 $available['font'] = self::cloud($field['available'], $available, $minFont, $maxFont);
             }
         }
     }
     return $options;
 }
 function facets($wp_query, $args)
 {
     $enabled = Config::option('enable_all_tags', false);
     if (!$enabled || !is_tag()) {
         return;
     }
     if (!isset($wp_query->query_vars['tag'])) {
         return;
     }
     $args['post_tag']['and'][] = $wp_query->query_vars['tag'];
     return $args;
 }
 function facets($wp_query, $args)
 {
     $enabled = Config::option('enable_all_posts', false);
     if (!$enabled || !is_post_type_archive() || !isset($wp_query->query_vars['post_type'])) {
         return;
     }
     $fields = Config::fields();
     // should handle this better, good for now
     if (!in_array('post_type', $fields)) {
         die('You must re-index your data with the post_type field enabled to use this ElasticSearch on this post type.');
     }
     $args['post_type'] = $wp_query->query_vars['post_type'];
     return $args;
 }
 function swap()
 {
     try {
         $primary = Config::option('server_index');
         $secondary = Config::option('secondary_index');
         if ($secondary) {
             Config::set('server_index', $secondary);
             Config::set('secondary_index', $primary);
         }
         echo 1;
     } catch (\Exception $ex) {
         header("HTTP/1.0 500 Internal Server Error");
         echo $ex->getMessage();
     }
     die;
 }
 function facets($wp_query, $args)
 {
     if (!is_category()) {
         return;
     }
     $enabled = Config::option('enable_categories', array());
     $all = Config::option('enable_all_categories', false);
     $cats = array();
     if (!$wp_query->is_main_query() || is_admin()) {
         return;
     }
     if (isset($wp_query->query_vars['category_name']) && !empty($wp_query->query_vars['category_name'])) {
         $cat = get_category_by_slug($wp_query->query_vars['category_name']);
         if (!$all && !in_array($cat->term_id, $enabled)) {
             return;
         }
         $cats[] = $cat;
     } else {
         if (isset($wp_query->query_vars['cat']) && !empty($wp_query->query_vars['cat'])) {
             $catids = explode(',', $wp_query->query_vars['cat']);
             foreach ($catids as $id) {
                 if (!$all && !in_array($id, $enabled)) {
                     return;
                 }
                 $cats[] = get_category($id);
             }
         }
     }
     if (empty($cats)) {
         return;
     }
     if (!isset($args['category'])) {
         if (count($cats) > 1) {
             foreach ($cats as $cat) {
                 $args['category']['or'][] = $cat->slug;
             }
         } else {
             $args['category']['and'][] = $cats[0]->slug;
         }
     }
     return $args;
 }
 /**
  * The Elastica\Index object used by F.E.S
  *
  * @param boolean $write Specifiy whether you are making read-only or write transactions (currently just adjusts timeout values)
  *
  * @return Elastica\Index
  * @internal
  **/
 static function _index($write = false)
 {
     return self::_client($write)->getIndex(Config::option('server_index'));
 }
  
  <div class="grid col-9">
  <div class="row">
	<form action="" method="post" enctype="multipart/form-data" >
    <p><?php 
if (isset($confirm) && $confirm > 0) {
    echo "Modificación exitosa";
}
?>
   </p>
		<h3>Ingrese la imagen de fondo</h3>
		<input type="file" name="background" accept="image/*">
		<br>
		<br>
		<input type="submit" value="Enviar" class="btn">
		<input type="hidden" name="add" val="">
	</form>
    <h3>Preview</h3>
    <img src="<?php 
echo File::url(Config::option('bgtestimonios'));
?>
" alt="Preview imagen testimonios">
    
  </div>
  
  </div>
  </div>
</div>

<?php 
require "template/footer.php";
<?php

namespace elasticsearch;

$fields = array('numeric' => array('id' => 'numeric', 'type' => 'multi_checkbox', 'title' => 'Numeric Fields', 'desc' => 'Any field marked as "numeric" will enabled support for range faceting.', 'options' => array()), 'not_analyzed' => array('id' => 'not_analyzed', 'type' => 'multi_checkbox', 'title' => 'Non Analyzed Fields', 'options' => array(), 'desc' => 'Any string field marked as "non analyzed" will require search terms to match the entire value instead of any words in the value.'));
foreach (array_merge(Config::fields(), Config::meta_fields()) as $field) {
    if ($field != 'post_date' && $field != 'post_type') {
        $fields['numeric']['options'][$field] = $field;
        $fields['not_analyzed']['options'][$field] = $field;
    }
}
$numeric_option = Config::option('numeric');
if ($numeric_option) {
    foreach (array_keys($numeric_option) as $numeric) {
        $fields[$numeric . '_range'] = array('id' => $numeric . '_range', 'type' => 'text', 'title' => $numeric . ' Range', 'desc' => 'Comma delimited list of ranges for this field using the format of FROM-TO. Currently ranges are always inclusive., ie: "-10,10-50,50-" or "-5,6-,7-,8-,9-"');
    }
}
$sections['field'] = array('icon' => NHP_OPTIONS_URL . 'img/glyphicons/glyphicons_097_vector_path_line.png', 'title' => 'Field Mapping', 'desc' => 'Finer grain control over how data is interpreted inside of ElasticSearch. Any changes made in this tab will require you to clear then re-index your data.', 'fields' => $fields);
 public static function _searchField($fields, $type, $exclude, $search, $facets, &$musts, &$filters, &$scored, $numeric)
 {
     foreach ($fields as $field) {
         if (in_array($field, $exclude)) {
             continue;
         }
         if ($search) {
             $score = Config::score($type, $field);
             $notanalyzed = Config::option('not_analyzed');
             if ($score > 0) {
                 if (strpos($search, "~") > -1 || isset($notanalyzed[$field])) {
                     // TODO: fuzzy doesn't work with english analyzer
                     $scored[] = "{$field}^{$score}";
                 } else {
                     $scored[] = "{$field}.english^{$score}";
                 }
             }
         }
         if (isset($numeric[$field]) && $numeric[$field]) {
             $ranges = Config::ranges($field);
             if (count($ranges) > 0) {
                 self::_filterBySelectedFacets($field, $facets, 'range', $musts, $filters, $ranges);
             }
         }
     }
 }
 public static function _searchField($fields, $type, $exclude, $search, $facets, &$musts, &$filters, &$scored, $numeric)
 {
     foreach ($fields as $field) {
         if (in_array($field, $exclude)) {
             continue;
         }
         if ($search) {
             $score = Config::score($type, $field);
             $notanalyzed = Config::option('not_analyzed');
             if ($score > 0) {
                 if (strpos($search, "~") > -1 || isset($notanalyzed[$field])) {
                     // TODO: fuzzy doesn't work with english analyzer
                     $scored[] = "{$field}^{$score}";
                 } else {
                     $scored[] = sprintf("{$field}.%s^{$score}", Config::apply_filters('string_language', 'english'));
                 }
             }
         }
         if (isset($numeric[$field]) && $numeric[$field]) {
             $ranges = Config::ranges($field);
             if (count($ranges) > 0) {
                 $transformed = array();
                 foreach ($ranges as $key => $range) {
                     $transformed[$key] = array();
                     if (isset($range['to'])) {
                         $transformed[$key]['lt'] = $range['to'];
                     }
                     if (isset($range['from'])) {
                         $transformed[$key]['gte'] = $range['from'];
                     }
                 }
                 self::_filterBySelectedFacets($field, $facets, 'range', $musts, $filters, $transformed);
             }
         } else {
             if ($type == 'custom') {
                 self::_filterBySelectedFacets($field, $facets, 'term', $musts, $filters);
             }
         }
     }
 }
 public function testOptionNotDefined()
 {
     $this->assertNull(Config::option('baz'));
 }