/** * If the passed orderby value is allowed, convert the alias to a * properly-prefixed orderby value. * * @access protected * * @param string $orderby Alias for the field to order by. * @return string|false Field to use in the sort clause. False otherwise. */ protected function parse_orderby($orderby) { // Meta values get special treatment $meta_keys = array(); $meta_clauses = $this->meta_query->queries; if (!empty($meta_clauses)) { if ('meta_value' == $orderby) { return $this->parse_orderby_for_meta(reset($meta_clauses)); } elseif ('meta_value_num' == $orderby) { return $this->parse_orderby_for_meta(reset($meta_clauses), 'double'); } elseif (array_key_exists($orderby, $meta_clauses)) { return $this->parse_orderby_for_meta($meta_clauses[$orderby]); } } if ('rand' == $orderby) { // @todo: implement `random_score` return false; } $field = parent::parse_orderby($orderby); // We don't actually want the mysql column here, so we'll remove it $field = preg_replace('/^.*\\./', '', $field); if ('ID' == $field) { return $this->es_map('post_id'); } elseif (!preg_match('/[^a-z_]/i', $field)) { // Return it if the field only contains letters and underscores return $this->es_map($field); } return false; }