Skip to content

Commit

Permalink
Merge pull request #2 from jmau111/master
Browse files Browse the repository at this point in the history
fix notices
  • Loading branch information
petitphp authored Jul 20, 2018
2 parents b73dd6c + 222794b commit 5b9f24b
Showing 1 changed file with 78 additions and 78 deletions.
156 changes: 78 additions & 78 deletions classes/monthly.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ function load_values( $params ) {

// Orderby
$orderby = 'f.facet_display_value DESC';
if ( 'asc' === $facet['orderby'] ) {
if ( ! empty( $facet['orderby'] ) && 'asc' === $facet['orderby'] ) {
$orderby = 'f.facet_display_value ASC';
}

// Limit
$limit = 10;
if ( absint( $facet['count'] ) > 0 ) {
if ( ! empty( $facet['count'] ) && absint( $facet['count'] ) > 0 ) {
$limit = absint( $facet['count'] );
}

Expand Down Expand Up @@ -95,7 +95,7 @@ function filter_posts( $params ) {
$dates = explode( '-', reset( $selected_values ) );

if ( count( $dates ) < 2 ) {
$dates = array( date( 'Y' ), date( 'm' ) );
$dates = array( date( 'Y' ), date( 'm' ) );
}

$sql = $wpdb->prepare( "SELECT DISTINCT post_id
Expand All @@ -118,95 +118,95 @@ function filter_posts( $params ) {
* Output admin settings HTML
*/
function settings_html() { ?>
<tr class="facetwp-conditional type-monthly">
<td>
<tr class="facetwp-conditional type-monthly">
<td>
<?php _e( 'Default label', 'fwp' ); ?>:
<div class="facetwp-tooltip">
<span class="icon-question">?</span>
<div class="facetwp-tooltip-content">
Customize the first option label (default: "Any")
</div>
</div>
</td>
<td>
<input type="text" class="facet-label-any" value="<?php _e( 'Any', 'fwp' ); ?>"/>
</td>
</tr>
<tr class="facetwp-conditional type-monthly">
<td>
<div class="facetwp-tooltip">
<span class="icon-question">?</span>
<div class="facetwp-tooltip-content">
Customize the first option label (default: "Any")
</div>
</div>
</td>
<td>
<input type="text" class="facet-label-any" value="<?php _e( 'Any', 'fwp' ); ?>"/>
</td>
</tr>
<tr class="facetwp-conditional type-monthly">
<td>
<?php _e( 'Archive order', 'fwp' ); ?>:
<div class="facetwp-tooltip">
<span class="icon-question">?</span>
<div class="facetwp-tooltip-content">
Customize the archives order (default: "Newest to Oldest")
</div>
</div>
</td>
<td>
<select class="facet-orderby">
<option value="desc" selected><?php _e( 'Newest to Oldest', 'fwp' ); ?></option>
<option value="asc"><?php _e( 'Oldest to newest', 'fwp' ); ?></option>
</select>
</td>
</tr>
<tr class="facetwp-conditional type-monthly">
<td>
<div class="facetwp-tooltip">
<span class="icon-question">?</span>
<div class="facetwp-tooltip-content">
Customize the archives order (default: "Newest to Oldest")
</div>
</div>
</td>
<td>
<select class="facet-orderby">
<option value="desc" selected><?php _e( 'Newest to Oldest', 'fwp' ); ?></option>
<option value="asc"><?php _e( 'Oldest to newest', 'fwp' ); ?></option>
</select>
</td>
</tr>
<tr class="facetwp-conditional type-monthly">
<td>
<?php _e( 'Count', 'fwp' ); ?>:
<div class="facetwp-tooltip">
<span class="icon-question">?</span>
<div class="facetwp-tooltip-content"><?php _e( 'The maximum number of facet choices to show',
<div class="facetwp-tooltip">
<span class="icon-question">?</span>
<div class="facetwp-tooltip-content"><?php _e( 'The maximum number of facet choices to show',
'fwp' ); ?></div>
</div>
</td>
<td><input type="text" class="facet-count" value="10"/></td>
</tr>
</div>
</td>
<td><input type="text" class="facet-count" value="10"/></td>
</tr>
<?php }

/**
* Output any admin scripts
*/
function admin_scripts() { ?>
<script>
(function ($) {
wp.hooks.addAction('facetwp/load/monthly', function ($this, obj) {
$this.find('.facet-source').val(obj['source']);
$this.find('.type-monthly .facet-label-any').val(obj['label_any']);
$this.find('.type-monthly .facet-orderby').val(obj['orderby']);
$this.find('.type-monthly .facet-count').val(obj['count']);
});

wp.hooks.addFilter('facetwp/save/monthly', function ($this, obj) {
obj['source'] = $this.find('.facet-source').val();
obj['label_any'] = $this.find('.type-monthly .facet-label-any').val();
obj['orderby'] = $this.find('.type-monthly .facet-orderby').val();
obj['count'] = $this.find('.type-monthly .facet-count').val();
return obj;
});
})(jQuery);
</script>
<script>
(function ($) {
wp.hooks.addAction('facetwp/load/monthly', function ($this, obj) {
$this.find('.facet-source').val(obj['source']);
$this.find('.type-monthly .facet-label-any').val(obj['label_any']);
$this.find('.type-monthly .facet-orderby').val(obj['orderby']);
$this.find('.type-monthly .facet-count').val(obj['count']);
});

wp.hooks.addFilter('facetwp/save/monthly', function ($this, obj) {
obj['source'] = $this.find('.facet-source').val();
obj['label_any'] = $this.find('.type-monthly .facet-label-any').val();
obj['orderby'] = $this.find('.type-monthly .facet-orderby').val();
obj['count'] = $this.find('.type-monthly .facet-count').val();
return obj;
});
})(jQuery);
</script>
<?php }

/**
* Output any front-end scripts
*/
function front_scripts() { ?>
<script>
(function ($) {
wp.hooks.addAction('facetwp/refresh/monthly', function ($this, facet_name) {
var val = $this.find('.facetwp-monthly').val();
FWP.facets[facet_name] = val ? [val] : [];
});

wp.hooks.addAction('facetwp/ready', function () {
$(document).on('change', '.facetwp-facet .facetwp-monthly', function () {
var $facet = $(this).closest('.facetwp-facet');
if ('' != $facet.find(':selected').val()) {
FWP.static_facet = $facet.attr('data-name');
}
FWP.autoload();
});
});
})(jQuery);
</script>
<script>
(function ($) {
wp.hooks.addAction('facetwp/refresh/monthly', function ($this, facet_name) {
var val = $this.find('.facetwp-monthly').val();
FWP.facets[facet_name] = val ? [val] : [];
});

wp.hooks.addAction('facetwp/ready', function () {
$(document).on('change', '.facetwp-facet .facetwp-monthly', function () {
var $facet = $(this).closest('.facetwp-facet');
if ('' != $facet.find(':selected').val()) {
FWP.static_facet = $facet.attr('data-name');
}
FWP.autoload();
});
});
})(jQuery);
</script>
<?php }
}
}

0 comments on commit 5b9f24b

Please sign in to comment.