--- a/ehive-search/EHiveSearch.php
+++ b/ehive-search/EHiveSearch.php
@@ -4,7 +4,7 @@
Plugin URI: http://developers.ehive.com/wordpress-plugins/
Author: Vernon Systems limited
Description: Search and display results from eHive. The <a href="http://developers.ehive.com/wordpress-plugins#ehiveaccess" target="_blank">eHiveAccess plugin</a> must be installed.
- Version: 2.5.0
+ Version: 2.5.1
Author URI: http://vernonsystems.com
License: GPL2+
*/
@@ -34,8 +34,8 @@
const CURRENT_VERSION = 4; // Increment each time an upgrade is required / options added or deleted.
const EHIVE_SEARCH_OPTIONS = "ehive_search_options";
- function __construct() {
-
+ function __construct() {
+ add_action("init", array(&$this, "ehive_search_init"));
add_action("admin_init", array(&$this, "ehive_search_admin_options_init"));
add_action("admin_menu", array(&$this, "ehive_search_admin_menu"));
@@ -43,6 +43,22 @@
add_shortcode('ehive_search', array(&$this, 'ehive_search_shortcode'));
}
+ function ehive_search_init() {
+ add_action('pre_get_posts', array(&$this, 'alter_post_query_var'));
+ }
+
+ function alter_post_query_var($query) {
+ if (!is_admin() && $query->is_main_query()) {
+ $options = get_option('ehive_search_options');
+ if (isset($options['query_var'])) {
+ $query->set($options['query_var'], sanitize_text_field( $query->get($options['query_var'])));
+ }
+ if (isset($options['page_var'])) {
+ $query->set($options['page_var'], sanitize_text_field( $query->get($options['page_var'])));
+ }
+ }
+ }
+
function ehive_search_admin_options_init(){
$this->ehive_plugin_update();
@@ -79,6 +95,84 @@
}
function ehive_search_options_validate($input) {
+
+ if(isset($input['limit'])) { $input['limit'] = sanitize_text_field($input['limit']); }
+ if(!isset($input['limit']) || $input['limit'] == "" ) {
+ $input['limit'] = "12";
+ }
+
+ // Lightbox view
+ if(isset($input['lightbox_object_number_enabled_label'])) { $input['lightbox_object_number_enabled_label'] = sanitize_text_field($input['lightbox_object_number_enabled_label']); }
+ if(isset($input['lightbox_name_enabled_label'])) { $input['lightbox_name_enabled_label'] = sanitize_text_field($input['lightbox_name_enabled_label']); }
+ if(isset($input['lightbox_primary_creator_maker_enabled_label'])) { $input['lightbox_primary_creator_maker_enabled_label'] = sanitize_text_field($input['lightbox_primary_creator_maker_enabled_label']); }
+ if(isset($input['lightbox_primary_creator_maker_role_enabled_label'])) { $input['lightbox_primary_creator_maker_role_enabled_label'] = sanitize_text_field($input['lightbox_primary_creator_maker_role_enabled_label']); }
+ if(isset($input['lightbox_taxonomic_classification_enabled'])) { $input['lightbox_taxonomic_classification_enabled'] = sanitize_text_field($input['lightbox_taxonomic_classification_enabled']); }
+ if(isset($input['lightbox_taxonomic_type_indicator_enabled'])) { $input['lightbox_taxonomic_type_indicator_enabled'] = sanitize_text_field($input['lightbox_taxonomic_type_indicator_enabled']); }
+ if(isset($input['lightbox_field_collector_enabled'])) { $input['lightbox_field_collector_enabled'] = sanitize_text_field($input['lightbox_field_collector_enabled']); }
+ if(isset($input['lightbox_web_public_description_enabled'])) { $input['lightbox_web_public_description_enabled'] = sanitize_text_field($input['lightbox_web_public_description_enabled']); }
+ if(isset($input['lightbox_date_made_enabled'])) { $input['lightbox_date_made_enabled'] = sanitize_text_field($input['lightbox_date_made_enabled']); }
+ if(isset($input['lightbox_place_made_enabled'])) { $input['lightbox_place_made_enabled'] = sanitize_text_field($input['lightbox_place_made_enabled']); }
+ if(isset($input['lightbox_object_type_enabled'])) { $input['lightbox_object_type_enabled'] = sanitize_text_field($input['lightbox_object_type_enabled']); }
+ if(isset($input['lightbox_medium_description_enabled'])) { $input['lightbox_medium_description_enabled'] = sanitize_text_field($input['lightbox_medium_description_enabled']); }
+ if(isset($input['lightbox_measurement_description_enabled'])) { $input['lightbox_measurement_description_enabled'] = sanitize_text_field($input['lightbox_measurement_description_enabled']); }
+ if(isset($input['lightbox_named_collection_enabled'])) { $input['lightbox_named_collection_enabled'] = sanitize_text_field($input['lightbox_named_collection_enabled']); }
+ if(isset($input['lightbox_credit_line_enabled'])) { $input['lightbox_credit_line_enabled'] = sanitize_text_field($input['lightbox_credit_line_enabled']); }
+
+ if(isset($input['lightbox_columns'])) { $input['lightbox_columns'] = sanitize_text_field($input['lightbox_columns']); }
+ if(!isset($input['lightbox_columns']) || $input['lightbox_columns'] == "" ) {
+ $input['lightbox_columns'] = "1";
+ }
+
+ if(isset($input['lightbox_more_link_text'])) { $input['lightbox_more_link_text'] = sanitize_text_field($input['lightbox_more_link_text']); }
+
+ if(isset($input['query_var'])) { $input['query_var'] = sanitize_text_field($input['query_var']); }
+ if(!isset($input['query_var']) || $input['query_var'] == "" ) {
+ $input['query_var'] = "eHive_query";
+ }
+
+ if(isset($input['page_var'])) { $input['page_var'] = sanitize_text_field($input['page_var']); }
+ if(!isset($input['page_var']) || $input['page_var'] == "" ) {
+ $input['page_var'] = "eHive_page";
+ }
+
+ if(isset($input['css_class'])) { $input['css_class'] = sanitize_text_field($input['css_class']); }
+
+ if(isset($input['item_background_colour'])) { $input['item_background_colour'] = sanitize_text_field($input['item_background_colour']); }
+ if(!isset($input['item_background_colour']) || $input['item_background_colour'] == "" ) {
+ $input['item_background_colour'] = "#f3f3f3";
+ }
+
+ if(isset($input['item_border_colour'])) { $input['item_border_colour'] = sanitize_text_field($input['item_border_colour']); }
+ if(!isset($input['item_border_colour']) || $input['item_border_colour'] == "" ) {
+ $input['item_border_colour'] = "#666666";
+ }
+
+ if(isset($input['item_border_width'])) { $input['item_border_width'] = sanitize_text_field($input['item_border_width']); }
+ if(!isset($input['item_border_width']) || $input['item_border_width'] == "" ) {
+ $input['item_border_width'] = "2";
+ }
+
+ if(isset($input['image_background_colour'])) { $input['image_background_colour'] = sanitize_text_field($input['image_background_colour']); }
+ if(!isset($input['image_background_colour']) || $input['image_background_colour'] == "" ) {
+ $input['image_background_colour'] = "#ffffff";
+ }
+
+ if(isset($input['image_padding'])) { $input['image_padding'] = sanitize_text_field($input['image_padding']); }
+ if(!isset($input['image_padding']) || $input['image_padding'] == "" ) {
+ $input['image_padding'] = "1";
+ }
+
+ if(isset($input['image_border_colour'])) { $input['image_border_colour'] = sanitize_text_field($input['image_border_colour']); }
+ if(!isset($input['image_border_colour']) || $input['image_border_colour'] == "" ) {
+ $input['image_border_colour'] = "#666666";
+ }
+
+ if(isset($input['image_border_width'])) { $input['image_border_width'] = sanitize_text_field($input['image_border_width']); }
+ if(!isset($input['image_border_width']) || $input['image_border_width'] == "" ) {
+ $input['image_border_width'] = "2";
+ }
+
+
add_settings_error('ehive_search_options', 'updated', 'eHive Search settings saved.', 'updated');
$input["update_version"] = self::CURRENT_VERSION; // Retain the plugin version on save of opotions.
@@ -193,9 +287,6 @@
add_settings_field('image_border_width', 'Image border width', array(&$this, 'image_border_width_fn'), __FILE__, 'css_inline_section');
}
- //
- // GENERAL OPTIONS SECTION
- //
function limit_fn() {
$options = get_option('ehive_search_options');
echo "<input class='small-text' id='limit' name='ehive_search_options[limit]' type='number' value='{$options['limit']}' />";
@@ -272,9 +363,6 @@
}
}
- //
- // RESULTS VIEW SECTION
- //
function result_views_options_fn($keyValuePair) {
$options = get_option('ehive_search_options');
@@ -304,9 +392,6 @@
echo "<input ".$checked." id='show_powered_by_ehive' name='ehive_search_options[show_powered_by_ehive]' type='checkbox' />";
}
- //
- // LIST VIEW SECTION
- //
function list_view_options_fn($key) {
$options = get_option('ehive_search_options');
@@ -335,11 +420,7 @@
}
echo "</select>";
}
-
-
- //
- // LIGHTBOX VIEW SECTION
- //
+
function lightbox_columns_fn() {
$options = get_option('ehive_search_options');
echo "<input class='small-text' id='lightbox_columns' name='ehive_search_options[lightbox_columns]' type='number' value='{$options['lightbox_columns']}' />";
@@ -365,7 +446,8 @@
}
if(isset($options[$key.'_label'])){
- echo "<input id='{$key}_label' name='ehive_search_options[{$key}_label]' size='40' type='text' value='{$options[$key.'_label']}' />";
+ $labelValue = sanitize_text_field($options[$key.'_label']);
+ echo "<input id='{$key}_label' name='ehive_search_options[{$key}_label]' size='40' type='text' value='{$labelValue}' />";
} else {
echo "<input id='{$key}_label' name='ehive_search_options[{$key}_label]' size='40' type='text' value='' />";
}
@@ -390,11 +472,7 @@
}
echo "</select>";
}
-
-
- //
- // ADVANCED OPTIONS SECTION
- //
+
function query_var_fn() {
$options = get_option('ehive_search_options');
echo "<input class='medium-text' id='query_var' name='ehive_search_options[query_var]' type='text' value='{$options['query_var']}' />";
@@ -405,9 +483,6 @@
echo "<input class='medium-text' id='page_var' name='ehive_search_options[page_var]' type='text' value='{$options['page_var']}' />";
}
- //
- // CSS OPTIONS SECTION
- //
function css_class_fn() {
$options = get_option('ehive_search_options');
echo "<input class='medium-text' id='css_class' name='ehive_search_options[css_class]' type='text' value='{$options['css_class']}' />";
@@ -423,9 +498,6 @@
echo "<input {$checked} id='plugin_css_enabled' name='ehive_search_options[plugin_css_enabled]' type='checkbox' />";
}
- //
- // INLINE CSS OPTIONS SECTION
- //
function item_background_colour_fn() {
$options = get_option('ehive_search_options');
$checked = '';
@@ -640,31 +712,47 @@
return get_option('ehive_search_options');
}
- public function ehive_search_shortcode($atts) {
- global $eHiveAccess;
+ public function ehive_search_shortcode($atts=[]) {
- $options = get_option('ehive_search_options');
+ $options = get_option('ehive_search_options');
+
+ $attsMerged = shortcode_atts(['css_class' => array_key_exists('css_class', $options) ? sanitize_text_field($options['css_class']) : '',
+ 'item_background_colour' => array_key_exists('item_background_colour', $options) ? sanitize_text_field($options['item_background_colour']) : '#f3f3f3',
+ 'item_background_colour_enabled' => array_key_exists('item_background_colour_enabled', $options) ? sanitize_text_field($options['item_background_colour_enabled']) : 'on',
+ 'item_border_colour' => array_key_exists('item_border_colour', $options) ? sanitize_text_field($options['item_border_colour']) : '#666666',
+ 'item_border_colour_enabled' => array_key_exists('item_border_colour_enabled', $options) ? sanitize_text_field($options['item_border_colour_enabled']) : '',
+ 'item_border_width' => array_key_exists('item_border_width', $options) ? sanitize_text_field($options['item_border_width']) : '2',
+ 'image_background_colour' => array_key_exists('image_background_colour', $options) ? sanitize_text_field($options['image_background_colour']) : '#ffffff',
+ 'image_background_colour_enabled' => array_key_exists('image_background_colour_enabled', $options) ? sanitize_text_field($options['image_background_colour_enabled']) : 'on',
+ 'image_padding' => array_key_exists('image_padding', $options) ? sanitize_text_field($options['image_padding']) : '1',
+ 'image_padding_enabled' => array_key_exists('image_padding_enabled', $options) ? sanitize_text_field($options['image_padding_enabled']) : 'on',
+ 'image_border_colour' => array_key_exists('image_border_colour', $options) ? sanitize_text_field($options['image_border_colour']) : '#666666',
+ 'image_border_colour_enabled' => array_key_exists('image_border_colour_enabled', $options) ? sanitize_text_field($options['image_border_colour_enabled']) : 'on',
+ 'image_border_width' => array_key_exists('image_border_width', $options) ? sanitize_text_field($options['image_border_width']) : '2',
+ 'sort_name' => array_key_exists('sort_name', $options) ? sanitize_text_field($options['sort_name']) : 'search_relevance',
+ 'sort_order' => array_key_exists('sort_order', $options) ? sanitize_text_field($options['sort_order']) : 'asc',
+ 'image_size_list' => array_key_exists('image_size_list', $options) ? sanitize_text_field($options['image_size_list']) : 'TS',
+ 'image_size_lightbox' => array_key_exists('image_size_lightbox', $options) ? sanitize_text_field($options['image_size_lightbox']) : 'S'
+ ],$atts, "ehive_search");
+
+ $css_class = sanitize_text_field($attsMerged['css_class']);
+ $item_background_colour = sanitize_text_field($attsMerged['item_background_colour']);
+ $item_background_colour_enabled = sanitize_text_field($attsMerged['item_background_colour_enabled']);
+ $item_border_colour = sanitize_text_field($attsMerged['item_border_colour']);
+ $item_border_colour_enabled = sanitize_text_field($attsMerged['item_border_colour_enabled']);
+ $item_border_width = sanitize_text_field($attsMerged['item_border_width']);
+ $image_background_colour = sanitize_text_field($attsMerged['image_background_colour']);
+ $image_background_colour_enabled = sanitize_text_field($attsMerged['image_background_colour_enabled']);
+ $image_padding = sanitize_text_field($attsMerged['image_padding']);
+ $image_padding_enabled = sanitize_text_field($attsMerged['image_padding_enabled']);
+ $image_border_colour = sanitize_text_field($attsMerged['image_border_colour']);
+ $image_border_colour_enabled = sanitize_text_field($attsMerged['image_border_colour_enabled']);
+ $image_border_width = sanitize_text_field($attsMerged['image_border_width']);
+ $sort_name = sanitize_text_field($attsMerged['sort_name']);
+ $sort_order = sanitize_text_field($attsMerged['sort_order']);
+ $image_size_list = sanitize_text_field($attsMerged['image_size_list']);
+ $image_size_lightbox = sanitize_text_field($attsMerged['image_size_lightbox']);
- extract(shortcode_atts(array('css_class' => array_key_exists('css_class', $options) ? $options['css_class'] : '',
- 'item_background_colour' => array_key_exists('item_background_colour', $options) ? $options['item_background_colour'] : '#f3f3f3',
- 'item_background_colour_enabled' => array_key_exists('item_background_colour_enabled', $options) ? $options['item_background_colour_enabled'] : 'on',
- 'item_border_colour' => array_key_exists('item_border_colour', $options) ? $options['item_border_colour'] : '#666666',
- 'item_border_colour_enabled' => array_key_exists('item_border_colour_enabled', $options) ? $options['item_border_colour_enabled'] : '',
- 'item_border_width' => array_key_exists('item_border_width', $options) ? $options['item_border_width'] : '2',
- 'image_background_colour' => array_key_exists('image_background_colour', $options) ? $options['image_background_colour'] : '#ffffff',
- 'image_background_colour_enabled' => array_key_exists('image_background_colour_enabled', $options) ? $options['image_background_colour_enabled'] : 'on',
- 'image_padding' => array_key_exists('image_padding', $options) ? $options['image_padding'] : '1',
- 'image_padding_enabled' => array_key_exists('image_padding_enabled', $options) ? $options['image_padding_enabled'] : 'on',
- 'image_border_colour' => array_key_exists('image_border_colour', $options) ? $options['image_border_colour'] : '#666666',
- 'image_border_colour_enabled' => array_key_exists('image_border_colour_enabled', $options) ? $options['image_border_colour_enabled'] : 'on',
- 'image_border_width' => array_key_exists('image_border_width', $options) ? $options['image_border_width'] : '2',
-
- 'sort_name' => array_key_exists('sort_name', $options) ? $options['sort_name'] : 'search_relevance',
- 'sort_order' => array_key_exists('sort_order', $options) ? $options['sort_order'] : 'asc',
- 'image_size_list' => array_key_exists('image_size_list', $options) ? $options['image_size_list'] : 'TS',
- 'image_size_lightbox' => array_key_exists('image_size_lightbox', $options) ? $options['image_size_lightbox'] : 'S'
- ),$atts));
-
$resultsViewLightboxEnabled = (isset( $options['results_view_lightbox_enabled']) && $options['results_view_lightbox_enabled'] == 'on') ? true : false;
$resultsViewListEnabled = (isset ($options['results_view_list_enabled']) && $options['results_view_list_enabled'] == 'on') ? true : false;
$resultsViewPosterboardEnabled = (isset($options['results_view_posterboard_enabled']) && $options['results_view_posterboard_enabled'] == 'on') ? true : false;
@@ -674,16 +762,25 @@
$queryAll = ehive_search_get_var('all', false);
- $query = ehive_search_get_var( $options['query_var'], false);
-
+ $query = ehive_search_get_var( $options['query_var'], false);
+
$query = rawurldecode($query);
$query = stripslashes_deep( $query );
- $page = ehive_search_get_var($options['page_var'], 1) - 1;
+ if (ehive_search_get_var($options['page_var'], false)) {
+ $page = ehive_search_get_var($options['page_var']);
+ $page = intVal($page);
+ $page = $page -1;
+ } else {
+ $page = 0;
+ }
+
$offset = $page * $options['limit'];
$a = ehive_search_get_var('a' ,false);
+ global $eHiveAccess;
+
try {
if (!$query == false || $queryAll == true) {
@@ -755,8 +852,21 @@
}
function query_vars($vars) {
- $vars[] = (isset($this->options['query_var']) && $this->options['query_var'] ) ? $this->options['query_var'] : '';
- $vars[] = (isset($this->options['page_var']) && $this->options['page_var'] ) ? $this->options['page_var'] : '';
+
+ $options = get_option(self::EHIVE_SEARCH_OPTIONS);
+
+ if (isset($options['query_var']) && $options['query_var'] !== "" ){
+ $vars[] = $options['query_var'];
+ } else {
+ $vars[] = "eHive_query";
+ }
+
+ if (isset($options['page_var']) && $options['page_var'] !== "" ){
+ $vars[] = $options['page_var'];
+ } else {
+ $vars[] = "eHive_page";
+ }
+
return $vars;
}
@@ -925,12 +1035,13 @@
return get_permalink($pageId);
}
+
$eHiveSearch = new EHiveSearch();
add_filter('query_vars', array(&$eHiveSearch, 'query_vars'));
// add_filter('rewrite_rules_array', array(&$eHiveSearch, 'add_rewrite_rules'));
-
+
add_action('activate_ehive-search/EHiveSearch.php', array(&$eHiveSearch, 'activate'));
add_action('deactivate_ehive-search/EHiveSearch.php', array(&$eHiveSearch, 'deactivate'));
}
--- a/ehive-search/templates/eHiveSearch.php
+++ b/ehive-search/templates/eHiveSearch.php
@@ -19,31 +19,27 @@
if ($css_class == "") {
echo '<div class="ehive-search">';
} else {
- echo '<div class="ehive-search '.$css_class.'">';
+ echo '<div class="ehive-search '.esc_attr($css_class).'">';
}
if ( isset( $options['hide_search_form_enabled']) && $options['hide_search_form_enabled'] == 'on') {
} else {
-//if ( $options['hide_search_form_enabled'] != 'on') {
- echo '<form class="ehive-search" name="ehive-search-form" action="'. $eHiveAccess->getSearchPageLink() .'" method="get">';
-
- echo "<input class='ehive-query' type='text' name='". $options['query_var'] ."' value='".$query."'/>";
-
+ echo '<form class="ehive-search" name="ehive-search-form" action="'. esc_url($eHiveAccess->getSearchPageLink()) .'" method="get">';
+ echo "<input class='ehive-query' type='text' name='". esc_attr($options['query_var']) ."' value='".esc_html($query)."'/>";
echo '<input class="ehive-submit" type="submit" value="Search"/>';
echo '</form>';
}
if (isset($eHiveBadRequestErrorMessage)) {
- echo "<p class='ehive-error-message ehive-account-details-error'>$eHiveBadRequestErrorMessage</p>";
+ echo "<p class='ehive-error-message ehive-account-details-error'>".esc_html($eHiveBadRequestErrorMessage)."</p>";
} else {
if (isset($eHiveApiErrorMessage)) {
- echo "<p class='ehive-error-message ehive-account-details-error'>$eHiveApiErrorMessage</p>";
+ echo "<p class='ehive-error-message ehive-account-details-error'>".esc_html($eHiveApiErrorMessage)."</p>";
} else {
- if (isset($objectRecordsCollection)) {
-
+ if (isset($objectRecordsCollection)) {
if ($objectRecordsCollection->totalObjects > 0) {
echo '<div class="ehive-search-results">';
$view = ehive_search_get_var('view', $resultsViewDefault);
@@ -57,7 +53,13 @@
$pBase = ehive_search_link() . '?a='.$a.$all.'&view='.$view.'&%_%';
$pFormat = $options['page_var'] . '=%#%';
$pTotal = ceil($objectRecordsCollection->totalObjects / $options['limit']);
- $pCurrent = ehive_search_get_var($options['page_var'], 1);
+
+ //$pCurrent = ehive_search_get_var($options['page_var'], 1);
+ if ( ehive_search_get_var($options['page_var'])){
+ $pCurrent = ehive_search_get_var($options['page_var']);
+ } else {
+ $pCurrent = 1;
+ }
echo paginate_links( array('base' => $pBase, 'format' => $pFormat, 'total' => $pTotal, 'current' => $pCurrent) );
@@ -67,7 +69,12 @@
$pBase = ehive_search_link() . '?' . $options['query_var'] . '=' .rawurlencode( $query ).$all.'&view='.$view.'&%_%';
$pFormat = $options['page_var'] . '=%#%';
$pTotal = ceil($objectRecordsCollection->totalObjects / $options['limit']);
- $pCurrent = ehive_search_get_var($options['page_var'], 1);
+
+ if ( ehive_search_get_var($options['page_var'])){
+ $pCurrent = ehive_search_get_var($options['page_var']);
+ } else {
+ $pCurrent = 1;
+ }
echo paginate_links( array('base' => $pBase, 'format' => $pFormat, 'total' => $pTotal, 'current' => $pCurrent) );
}
@@ -77,7 +84,6 @@
echo '</div>';
}
- //$imageSize = "";
$itemInlineStyleEnabled = false;
$imageInlineStyleEnabled = false;
$itemInlineStyle = '';
@@ -113,7 +119,7 @@
$imageInlineStyle .= "background:$image_background_colour; ";
$imageInlineStyleEnabled = true;
}
- if (isset($options['image_padding_enabled']) && $options['image_padding_enabled'] == 'on') {
+ if (isset($options['image_padding_enabled']) && $options['image_padding_enabled'] == 'on'&& $image_padding > 0) {
$imageInlineStyle .= "padding:{$image_padding}px; ";
$imageInlineStyleEnabled = true;
}
@@ -124,10 +130,10 @@
}
if($itemInlineStyleEnabled) {
- $itemInlineStyle = " style='$itemInlineStyle'";
+ $itemInlineStyle = " style='".esc_attr($itemInlineStyle)."'";
}
if($imageInlineStyleEnabled) {
- $imageInlineStyle = " style='$imageInlineStyle'";
+ $imageInlineStyle = " style='".esc_attr($imageInlineStyle)."'";
}
echo "<div class='ehive-view ehive-$view'>";
@@ -135,7 +141,7 @@
echo "<div class='ehive-item' $itemInlineStyle>";
echo '<div class="ehive-item-image-wrap">';
- echo '<a class="ehive-image-link" href="'.$eHiveAccess->getObjectDetailsPageLink($objectRecord->objectRecordId).'">';
+ echo '<a class="ehive-image-link" href="'.esc_url($eHiveAccess->getObjectDetailsPageLink($objectRecord->objectRecordId)).'">';
$name = '';
if (isset($objectRecord->name)) {
@@ -147,7 +153,7 @@
if (isset($imageMediaSet)) {
$mediaRow = $imageMediaSet->mediaRows[0];
$imageMedia = $mediaRow->getMediaByIdentifier("image_$imageSize");
- $imageLink = '<img class="ehive-image" src="'.$imageMedia->getMediaAttribute('url').'"' . $imageInlineStyle . ' alt="'.esc_attr($imageMedia->getMediaAttribute('title')).'" title="'.esc_attr($imageMedia->getMediaAttribute('title')).'">';
+ $imageLink = '<img class="ehive-image" src="'.esc_url($imageMedia->getMediaAttribute('url')).'"' . $imageInlineStyle . ' alt="'.esc_attr($imageMedia->getMediaAttribute('title')).'" title="'.esc_attr($imageMedia->getMediaAttribute('title')).'">';
}
echo $imageLink;
@@ -174,7 +180,13 @@
$pBase = ehive_search_link() . '?a='.$a.$all.'&view='.$view.'&%_%';
$pFormat = $options['page_var'] . '=%#%';
$pTotal = ceil($objectRecordsCollection->totalObjects / $options['limit']);
- $pCurrent = ehive_search_get_var($options['page_var'], 1);
+ //$pCurrent = ehive_search_get_var($options['page_var'], 1);
+ if ( ehive_search_get_var($options['page_var'])){
+ $pCurrent = ehive_search_get_var($options['page_var']);
+ } else {
+ $pCurrent = 1;
+ }
+
echo paginate_links( array('base' => $pBase, 'format' => $pFormat, 'total' => $pTotal, 'current' => $pCurrent) );
@@ -184,8 +196,13 @@
$pBase = ehive_search_link() . '?' . $options['query_var'] . '=' .rawurlencode( $query ).$all.'&view='.$view.'&%_%';
$pFormat = $options['page_var'] . '=%#%';
$pTotal = ceil($objectRecordsCollection->totalObjects / $options['limit']);
- $pCurrent = ehive_search_get_var($options['page_var'], 1);
-
+ //$pCurrent = ehive_search_get_var($options['page_var'], 1);
+ if ( ehive_search_get_var($options['page_var'])){
+ $pCurrent = ehive_search_get_var($options['page_var']);
+ } else {
+ $pCurrent = 1;
+ }
+
echo paginate_links( array('base' => $pBase, 'format' => $pFormat, 'total' => $pTotal, 'current' => $pCurrent) );
}
@@ -232,7 +249,7 @@
if ($view == 'lightbox') {
echo '<li>lightbox</li>';
} else {
- echo '<li><a href="'.$link.'&view=lightbox'.'">lightbox</a></li>';
+ echo '<li><a href="'.esc_url($link).'&view=lightbox'.'">lightbox</a></li>';
}
}
@@ -240,7 +257,7 @@
if ($view == 'list') {
echo '<li>list</li>';
} else {
- echo '<li><a href="'.$link.'&view=list'.'">list</a></li>';
+ echo '<li><a href="'.esc_url($link).'&view=list'.'">list</a></li>';
}
}
@@ -288,30 +305,30 @@
$fieldLabel = $options["lightbox_{$key}_enabled_label"];
}
if ( isset($fieldValue) && $fieldValue !='' ) {
- echo '<p class="ehive-field ehive-identifier-'.$key.'">';
+ echo '<p class="ehive-field ehive-identifier-'.esc_attr($key).'">';
if (isset($fieldLabel) && $fieldLabel !='') {
- echo '<span class="ehive-field-label">'.$fieldLabel.'</span>';
+ echo '<span class="ehive-field-label">'.esc_html($fieldLabel).'</span>';
}
if (isset($fieldValue) && $fieldValue !='') {
- echo $fieldValue;
+ echo esc_html($fieldValue);
}
echo '</p>';
}
}
if (isset($options['lightbox_more_link_enabled']) && $options['lightbox_more_link_enabled'] == "on") {
- echo '<a class="ehive-more-link" href="'.$eHiveAccess->getObjectDetailsPageLink($objectRecord->objectRecordId).'">'.$options['lightbox_more_link_text'].'</a>';
+ echo '<a class="ehive-more-link" href="'.esc_url($eHiveAccess->getObjectDetailsPageLink($objectRecord->objectRecordId)).'">'.esc_html($options['lightbox_more_link_text']).'</a>';
}
}
function listMetadata($options, $objectRecord, $eHiveAccess, $eHiveApi) {
$showPublicProfileName = (isset($options['show_public_profile_name']) && $options['show_public_profile_name'] == 'on') ? true : false;
$showCatalogueTypeIcon = (isset($options['show_catalogue_type_icon']) && $options['show_catalogue_type_icon'] == 'on') ? true : false;
- echo '<a href="'.$eHiveAccess->getObjectDetailsPageLink($objectRecord->objectRecordId).'"><span class="ehive-item-summary">'.listFields($options, $objectRecord).'</span></a>';
+ echo '<a href="'.esc_url($eHiveAccess->getObjectDetailsPageLink($objectRecord->objectRecordId)).'"><span class="ehive-item-summary">'.esc_html(listFields($options, $objectRecord)).'</span></a>';
if ( $showPublicProfileName ) {
echo '<p class="ehive-field ehive-identifier-public_profile_name">';
echo '<span class="ehive-field-label">From: </span>';
- echo '<a href="'.$eHiveAccess->getAccountDetailsPageLink($objectRecord->account->accountId).'">'.$objectRecord->account->publicProfileName.'</a>';
+ echo '<a href="'.esc_url($eHiveAccess->getAccountDetailsPageLink($objectRecord->account->accountId)).'">'.esc_html($objectRecord->account->publicProfileName).'</a>';
echo '</p>';
}
@@ -340,7 +357,6 @@
break;
}
}
-
}
function listFields($options, $objectRecord) {