Skip to content

Commit

Permalink
Fixed masonry layouts, sanitized search input, and misc PHP notices
Browse files Browse the repository at this point in the history
  • Loading branch information
Daro authored and Daro committed Jan 3, 2019
1 parent f154ddc commit 8ac8ceb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
14 changes: 9 additions & 5 deletions inc/class-layouts.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ public function before_content( $content ) {
global $post;
$post_id = $post->ID;


// show on single sell media pages
if ( is_singular( 'sell_media_item' ) || sell_media_attachment( $post_id ) || sell_media_is_search() ) {

Expand All @@ -236,7 +237,9 @@ public function before_content( $content ) {
}

$new_content .= sell_media_breadcrumbs();
$new_content .= sell_media_get_media();
if ( ! sell_media_is_search() ) {
$new_content .= sell_media_get_media();
}
$new_content .= $content;

// only wrap content if a single image/media is being viewed
Expand Down Expand Up @@ -347,12 +350,13 @@ function content_loop( $post_id, $i, $args = array() ) {
$image_height = $image_data[2];
$width = $image_width * 250 / $image_height;
$padding_bottom = $image_height / $image_width * 100;
error_log( 'img width ' . $image_width );
error_log( 'img height ' . $image_height );

$html = '<div id="sell-media-' . $original_id . '" class="' . $class . '" style="width:' . $width . 'px; flex-grow:' . $width . '; " >';
} else {

$html = '<div id="sell-media-' . $original_id . '" class="' . $class . '">';
}
$html = '<div id="sell-media-' . $original_id . '" class="' . $class . '" style="width:' . $width . 'px; flex-grow:' . $width . '; " >';


$html .= '<a href="' . esc_url( get_permalink( $original_id ) ) . '" ' . sell_media_link_attributes( $original_id ) . ' class="sell-media-item">';
if ( 'sell-media-horizontal-masonry' === $this->settings->thumbnail_layout ) {
$html .= '<i style="padding-bottom:' . $padding_bottom . '%;" ></i>';
Expand Down
4 changes: 2 additions & 2 deletions inc/class-search.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function form( $url = null, $used = null ) {
}

// Get the search term(s)
$search_term = get_query_var( 'search_query' );
$search_term = htmlspecialchars(trim(stripslashes(strip_tags(get_query_var( 'search_query' )))));

// Get the file type
$search_file_type = get_query_var( 'search_file_type' );
Expand Down Expand Up @@ -206,7 +206,7 @@ public function form( $url = null, $used = null ) {
// hook for related keywords, etc.
$html .= sell_media_format_related_search_results( $search_terms );

$html .= $this->search_help();
//$html .= $this->search_help();

$html .= '<div id="sell-media-search-results" class="sell-media">';
$html .= '<div class="' . apply_filters( 'sell_media_grid_item_container_class', 'sell-media-grid-item-container' ) . '">';
Expand Down
2 changes: 1 addition & 1 deletion inc/helpers.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -1489,4 +1489,4 @@ function sell_media_ecommerce_enabled( $post_id ) {
$status = false;
}
return $status;
}
}
9 changes: 4 additions & 5 deletions inc/scripts.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ function sell_media_scripts( $hook ) {
if ( is_customize_preview() || ( isset( $settings->thumbnail_layout ) && 'sell-media-masonry' === $settings->thumbnail_layout ) ) {
wp_enqueue_script( 'sell_media_masonry', SELL_MEDIA_PLUGIN_URL . 'js/macy.min.js', array( 'jquery' ), SELL_MEDIA_VERSION, true );
wp_add_inline_script( 'sell_media_masonry', '
setTimeout(function(){
jQuery(function() {
var macyGrid = Macy;
var galleries = document.querySelectorAll(".sell-media-grid-item-masonry-container");
var macyInstances = [];
var macyOptions = {
Expand All @@ -48,15 +49,13 @@ function sell_media_scripts( $hook ) {
520: 1
}
};
for (var i = 0; i < galleries.length; i++) {
var newId = "sell-media-instance-" + i;
galleries[i].id = newId;
macyOptions.container = "#" + newId;
macyInstances.push(Macy(macyOptions));
macyInstances.push(macyGrid(macyOptions));
}
window.dispatchEvent(new Event("resize"));
}, 100)'
});'
);
}

Expand Down
Loading

0 comments on commit 8ac8ceb

Please sign in to comment.