Skip to content

Commit

Permalink
Plugin updates (#15)
Browse files Browse the repository at this point in the history
* Update environment checks for the plugin

* Separate css & js code from the plugin file

* Update POT file

* Updates tests

* Increase tests coverage to 100%

* CSS fix for mobile and re-genrated POT file

* Added back assets to index.php and minute changes

* Add support for litespeed

* Update readme.txt file
  • Loading branch information
akshitsethi authored Jul 20, 2020
1 parent e4ac16a commit 4e80cbc
Show file tree
Hide file tree
Showing 8 changed files with 991 additions and 481 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION := 1.2.0
VERSION := 1.2.5
PLUGINSLUG := spiderblocker
SRCPATH := $(shell pwd)/src

Expand Down Expand Up @@ -64,7 +64,7 @@ i18n:
wp i18n make-pot src src/i18n/spiderblocker.pot

cover: vendor
bin/coverage-check clover.xml 85
bin/coverage-check clover.xml 100

clean:
rm -rf vendor/ bin
3 changes: 3 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
<exclude processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/inc/templates</directory>
</exclude>
</whitelist>
</filter>
<php>
Expand Down
127 changes: 73 additions & 54 deletions src/i18n/spiderblocker.pot
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2020-01-13T09:39:59+05:30\n"
"POT-Creation-Date: 2020-07-20T15:38:48+05:30\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.3.0\n"
"X-Generator: WP-CLI 2.4.0\n"
"X-Domain: spiderblocker\n"

#. Plugin Name of the plugin
#: index.php:752
#: inc/templates/settings.php:14
msgid "Spider Blocker"
msgstr ""

Expand All @@ -31,97 +31,116 @@ msgstr ""
msgid "www.easyblognetworks.com"
msgstr ""

#: index.php:41
msgid ""
"This plugin requires PHP 5.6.0 or higher. Please contact your hosting provider about upgrading your\n"
"\t\t\tserver software. Your PHP version is"
#: inc/templates/settings.php:29
msgid "Add New Bot"
msgstr ""

#: index.php:374
msgid "SpiderBlocker plugin has enabled blocking of some bots, please review settings by visiting"
#: inc/templates/settings.php:35
#: inc/templates/settings.php:69
#: inc/templates/settings.php:90
msgid "User Agent"
msgstr ""

#: index.php:374
msgid "Setting page"
#: inc/templates/settings.php:39
msgid "Bot Name"
msgstr ""

#: index.php:399
msgid "This plugin requires Apache2 server with mod_rewrite support. Please contact your hosting provider about upgrading your server software. Your Apache version is"
#: inc/templates/settings.php:44
msgid "Bot Description URL"
msgstr ""

#: index.php:413
msgid "%1$s %2$s %3$s"
#: inc/templates/settings.php:52
msgid "Add Bot"
msgstr ""

#: index.php:414
msgid "This plugin requires"
#: inc/templates/settings.php:57
msgid "List of bots"
msgstr ""

#: index.php:416
msgid "file that is writable by the server. Please enable write access for file"
#: inc/templates/settings.php:60
msgid "Filter..."
msgstr ""

#: index.php:574
msgid "Failed parsing JSON"
#: inc/templates/settings.php:73
#: inc/templates/settings.php:94
msgid "Name"
msgstr ""

#: index.php:588
msgid "Unable to process the request as no data has been received."
#: inc/templates/settings.php:77
#: inc/templates/settings.php:98
msgid "State"
msgstr ""

#: index.php:766
msgid "Add New Bot"
#: inc/templates/settings.php:81
#: inc/templates/settings.php:102
msgid "Action"
msgstr ""

#: index.php:772
#: index.php:800
#: index.php:812
msgid "User Agent"
#: inc/templates/settings.php:115
msgid "Block"
msgstr ""

#: index.php:776
msgid "Bot Name"
#: inc/templates/settings.php:116
msgid "Allow"
msgstr ""

#: index.php:781
msgid "Bot Description URL"
#: inc/templates/settings.php:117
msgid "Remove"
msgstr ""

#: index.php:788
msgid "Add Bot"
#: inc/templates/settings.php:128
msgid "Save"
msgstr ""

#: index.php:791
msgid "List of bots"
#: inc/templates/settings.php:129
msgid "Reset to Defaults"
msgstr ""

#: index.php:793
msgid "Filter..."
#: inc/templates/settings.php:130
msgid "Import/Export Definitions"
msgstr ""

#: index.php:802
#: index.php:813
msgid "Name"
#: index.php:352
msgid "%s requires Apache2 server with mod_rewrite support. Please contact your hosting provider about upgrading your server software."
msgstr ""

#: index.php:804
#: index.php:814
msgid "State"
#: index.php:365
msgid "%s requires .htaccess file that is writable by the server. Please enable write access for the file."
msgstr ""

#: index.php:806
#: index.php:816
msgid "Action"
#: index.php:382
msgid "%1$s requires WordPress version %2$s or higher. Please %3$supdate WordPress &raquo;%4$s"
msgstr ""

#: index.php:841
msgid "Save"
#: index.php:397
msgid "%1$s plugin has enabled blocking of some bots, please review settings by visiting %2$sSettings page%3$s!"
msgstr ""

#: index.php:842
msgid "Reset to Defaults"
#: index.php:599
#: index.php:604
msgid "Unable to process the request as no data has been received."
msgstr ""

#: index.php:843
msgid "Import/Export Definitions"
#: index.php:611
msgid "Failed parsing JSON data."
msgstr ""

#: index.php:678
msgid "List of bots was saved and new blocklist applied!"
msgstr ""

#: index.php:679
msgid "List of bots was reset to defaults!"
msgstr ""

#: index.php:680
msgid "Bot"
msgstr ""

#: index.php:681
msgid "was added!"
msgstr ""

#: index.php:682
msgid "Bot was removed!"
msgstr ""
134 changes: 134 additions & 0 deletions src/inc/templates/settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?php

/**
* View for plugin settings panel.
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

?>

<div class="spiderblocker-root">
<h1><?php esc_html_e( 'Spider Blocker', 'spiderblocker' ); ?></h1>
<hr/>

<div ng-app="spiderBlockApp">
<div ng-controller="NotificationsCtrl">
<div class="notice notice-{{ n.state }} fixed" ng-repeat="n in notifications" style="top: {{3.5*($index+1)}}em">
<p>{{n.msg}}
<a ng-click="removeNotification(notification)">
<span class="dashicons dashicons-no-alt"></span>
</a>
</p>
</div>
</div>

<div ng-controller="BotListCtrl">
<h2><?php esc_html_e( 'Add New Bot', 'spiderblocker' ); ?></h2>

<form name="add_form" ng-submit="add()">
<table class="form-table">
<tbody>
<tr>
<th scope="row"><label><?php esc_html_e( 'User Agent', 'spiderblocker' ); ?></label></th>
<td><input type="text" bots="bots" ng-model='bot.re' class="regular-text" required/></td>
</tr>
<tr>
<th scope="row"><label><?php esc_html_e( 'Bot Name', 'spiderblocker' ); ?></label></th>
<td><input type="text" ng-model='bot.name' class="regular-text" required/></td>
</tr>
<tr>
<tr>
<th scope="row"><label><?php esc_html_e( 'Bot Description URL', 'spiderblocker' ); ?></label></th>
<td><input type="url" ng-model='bot.desc' class="regular-text" placeholder="http://"/>
</td>
</tr>
</tbody>
</table>

<p class="submit">
<input ng-disabled="add_form.$invalid" type="submit" class="button button-primary" value="<?php esc_attr_e( 'Add Bot', 'spiderblocker' ); ?>">
</p>
</form>

<div class="sb-table-top">
<h2><?php esc_html_e( 'List of bots', 'spiderblocker' ); ?></h2>

<ng-form class="search-box">
<input size="35" type="search" id="ua-search-input" ng-model="query" placeholder="<?php esc_attr_e( 'Filter...', 'spiderblocker' ); ?>">
</ng-form>
</div><!-- .sb-table-top -->

<table class="wp-list-table widefat bots">
<thead>
<tr>
<th scope="col" class="manage-column column-description">
<a href="" ng-click="predicate = 're'; reverse=false">
<?php esc_html_e( 'User Agent', 'spiderblocker' ); ?> <span class="dashicons dashicons-sort"></span>
</a>
</th>
<th scope="col" class="manage-column column-name">
<?php esc_html_e( 'Name', 'spiderblocker' ); ?>
</th>
<th scope="col" class="manage-column column-state">
<a href="" ng-click="predicate = 'state'; reverse=false">
<?php esc_html_e( 'State', 'spiderblocker' ); ?> <span class="dashicons dashicons-sort"></span>
</a>
</th>
<th scope="col" id="action" class="manage-column column-action">
<?php esc_html_e( 'Action', 'spiderblocker' ); ?>
</th>
</tr>
</thead>

<tfoot>
<tr>
<th scope="col" class="manage-column column-description">
<a href="" ng-click="predicate = 're'; reverse=false">
<?php esc_html_e( 'User Agent', 'spiderblocker' ); ?>
</a>
</th>
<th scope="col" class="manage-column column-name">
<?php esc_html_e( 'Name', 'spiderblocker' ); ?>
</th>
<th scope="col" class="manage-column column-state">
<a href="" ng-click="predicate = 'state'; reverse=false">
<?php esc_html_e( 'State', 'spiderblocker' ); ?>
</a>
</th>
<th scope="col" id="action" class="manage-column column-action">
<?php esc_html_e( 'Action', 'spiderblocker' ); ?>
</th>
</tr>
</tfoot>

<tbody id="the-list">
<tr id="spider-blocker" ng-repeat="bot in bots | filter:query | orderBy:predicate:reverse"
ng-class="{'active': bot.state}">

<th class="bot-re"> {{ bot.re }}</th>
<td class="bot-title"><strong>{{ bot.name }}</strong> <a target="_blank" ng-href="{{bot.desc}}">{{ bot.desc }}</a></td>
<th class="expression" ng-class="{'blocked':bot.state}"> {{ bot.state?"Blocked":"Allowed" }}</th>
<td class="actions">
<input ng-hide="bot.state" type="button" ng-click="bot.state=true" class="button button-primary" value="<?php esc_attr_e( 'Block', 'spiderblocker' ); ?>">
<input ng-show="bot.state" type="button" ng-click="bot.state=false" class="button button-secondary" value="<?php esc_attr_e( 'Allow', 'spiderblocker' ); ?>">
<input type="button" ng-click="remove(bot.re)" class="button button-secondary" value="<?php esc_attr_e( 'Remove', 'spiderblocker' ); ?>">
</td>
</tr>
</tbody>
</table>

<div id="rules-export-import" style="display:none;">
<textarea style="-webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;width: 100%;height: 99%;" json-text ng-model="bots"></textarea>
</div>

<p class="submit">
<input type="button" class="button button-primary" ng-click="save()" value="<?php esc_attr_e( 'Save', 'spiderblocker' ); ?>">
<input type="button" class="button button-primary" ng-click="reset()" value="<?php esc_attr_e( 'Reset to Defaults', 'spiderblocker' ); ?>">
<a href="#TB_inline?width=540&height=360&inlineId=rules-export-import" class="thickbox button button-secondary"><?php esc_html_e( 'Import/Export Definitions', 'spiderblocker' ); ?></a>
</p>
</div>
</div>
</div><!-- .spiderblocker-root -->
Loading

0 comments on commit 4e80cbc

Please sign in to comment.