Skip to content

Commit

Permalink
Merge pull request #8 from Decicus/master
Browse files Browse the repository at this point in the history
Add option for deleting based on number of clicks
  • Loading branch information
ozh authored Mar 31, 2022
2 parents d510809 + 6948bd7 commit bc6393b
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Mass Remove Links
Plugin URI: https://github.com/YOURLS/mass-remove-links/
Description: Remove several (or all) links.
Version: 1.1
Version: 1.2
Author: Ozh
Author URI: http://ozh.org/
*/
Expand Down Expand Up @@ -59,6 +59,17 @@ function ozh_yourls_linkmr_form() {
<input type="text" name="url" /> (case sensitive)
</p>
<p><label for="radio_clicks">
<input type="radio" name="what" id="radio_clicks" value="clicks"/>All links with the specified amount of clicks
</label>
<select name="clicks_filter">
<option value="equals">Equals (=)</option>
<option value="greaterThan">Greater than (>)</option>
<option value="lessThan">Less than (<)</option>
</select>
<input type="number" name="clicks" min="0" value="0" />
</p>
<p><label for="radio_all">
<input type="radio" name="what" id="radio_all" value="all"/>All links. All.
</label>
Expand All @@ -73,7 +84,7 @@ function ozh_yourls_linkmr_form() {
function select_radio(el){
$(el).parent().find(':radio').click();
}
$('input:text')
$('input:text, input[type="number"]')
.click(function(){select_radio($(this))})
.focus(function(){select_radio($(this))})
.change(function(){select_radio($(this))});
Expand All @@ -88,11 +99,24 @@ function ozh_yourls_linkmr_process() {
$where = '';
$binds = array();

$validClicksFilters = array(
'equals' => '=',
'greaterThan' => '>',
'lessThan' => '<',
);

switch( $_POST['what'] ) {
case 'all':
$where = '1=1';
break;

case 'clicks':
$clicksFilter = $validClicksFilters[$_POST['clicks_filter']] ?? '=';

$binds['clicks'] = (int) $_POST['clicks'];
$where = "`clicks` $clicksFilter :clicks";
break;

case 'date':
$where = "`timestamp` BETWEEN :date1 and :date2";
$binds['date1'] = $_POST['date'] . ' 00:00:00';
Expand Down

0 comments on commit bc6393b

Please sign in to comment.