Plugin Directory

Changeset 2221863


Ignore:
Timestamp:
01/03/2020 08:55:52 PM (6 years ago)
Author:
mediuminteractive
Message:

Version 1.1.0; uploaded screenshots

Location:
easy-country-spam-blocker/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • easy-country-spam-blocker/trunk/README.txt

    r2215383 r2221863  
    5757== Screenshots ==
    5858
    59 1. https://i.ibb.co/xGZV5gh/Capture.png
    60 2. https://i.ibb.co/yVSgXJF/mi-ecsb-flowchart.jpg
     591. Settings page.
     602. How ECSB works.
    6161
    6262== Changelog ==
     63
     64= 1.1.0 =
     65* Added ability to choose whitelisted countries
     66* Added small quickstart section
    6367
    6468= 1.0.1 =
  • easy-country-spam-blocker/trunk/admin/css/mi-ecsb-admin.css

    r2215383 r2221863  
    33 * included in this file.
    44 */
    5 #ecsb-admin-page
    6 {
     5
     6.ecsb-admin-page {
    77    margin-right: 20px;
    88}
    99
    10 #ecsb-admin-page .switch
    11 {
     10.ecsb-admin-page .switch {
    1211    position: relative;
    1312    display: inline-block;
     
    1615}
    1716
    18 #ecsb-admin-page .switch input
    19 {
     17.ecsb-admin-page .switch input {
    2018    opacity: 0;
    2119    width: 0;
     
    2321}
    2422
    25 #ecsb-admin-page .slider
    26 {
     23.ecsb-admin-page .slider {
    2724    position: absolute;
    2825    cursor: pointer;
     
    3229    bottom: 0;
    3330    background-color: #cccccc;
    34 
    3531    -webkit-transition: 400ms;
    3632    -moz-transition: 400ms;
     
    3935}
    4036
    41 #ecsb-admin-page .slider:before
    42 {
     37.ecsb-admin-page .slider:before {
    4338    position: absolute;
    4439    content: "";
     
    4843    bottom: 2px;
    4944    background-color: white;
    50 
    5145    -webkit-transition: 400ms;
    5246    -moz-transition: 400ms;
     
    5549}
    5650
    57 #ecsb-admin-page input:checked + .slider
    58 {
     51.ecsb-admin-page input:checked+.slider {
    5952    background-color: #2677d5;
    6053}
    6154
    62 #ecsb-admin-page input:focus + .slider
    63 {
     55.ecsb-admin-page input:focus+.slider {
    6456    box-shadow: 0 0 1px #2677d5;
    6557}
    6658
    67 #ecsb-admin-page input:checked + .slider:before
    68 {
     59.ecsb-admin-page input:checked+.slider:before {
    6960    -webkit-transform: translateX(20px);
    7061    -moz-transform: translateX(20px);
     
    7465}
    7566
    76 #ecsb-admin-page .slider.round
    77 {
     67.ecsb-admin-page .slider.round {
    7868    border-radius: 20px;
    7969}
    8070
    81 #ecsb-admin-page .slider.round:before
    82 {
     71.ecsb-admin-page .slider.round:before {
    8372    border-radius: 50%;
    8473}
     
    8675
    8776
    88 #ecsb-admin-page #ecsb-settings-form
    89 {
     77.ecsb-admin-page .section {
     78    margin: 10px 0;
     79    width: 520px;
     80    background-color: #212121;
     81    color: white;
     82}
     83
     84.ecsb-admin-page .section .content {
    9085    padding: 10px;
    91     width: 500px;
    92     background-color: #212112;
    93     color: white;
    94 }
    95 
    96 #ecsb-admin-page .ecsb-field
    97 {
     86}
     87
     88.ecsb-admin-page .ecsb-field {
    9889    margin: 5px 0;
    9990}
    10091
    101 #ecsb-admin-page .ecsb-field-label
    102 {
     92.ecsb-admin-page .ecsb-field-label {
    10393    font-size: 15px;
    10494    font-weight: 600;
    10595}
    10696
    107 #ecsb-admin-page .ecsb-field.marginless-bottom
    108 {
     97.ecsb-admin-page .ecsb-field.marginless-bottom {
    10998    margin-bottom: 0;
    11099}
    111100
    112 #ecsb-admin-page .ecsb-field .ecsb-explanation
    113 {
     101.ecsb-admin-page .ecsb-field .ecsb-explanation {
    114102    margin: 0;
    115103    padding: 5px;
     
    118106}
    119107
    120 #ecsb-admin-page .ecsb-field.url-select-container
    121 {
     108.ecsb-admin-page .ecsb-field.url-select-container {
    122109    margin-top: 0;
    123110}
    124111
    125 #ecsb-admin-page .ecsb-field.url-select-container .url-select-item
    126 {
     112.ecsb-admin-page .ecsb-field.url-select-container .url-select-item {
    127113    height: 35px;
    128114}
    129115
    130 #ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown,
    131 #ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-text
    132 {
     116.ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown, .ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-text {
    133117    display: inline-block;
    134118    height: 100%;
     
    138122    outline: none;
    139123    box-sizing: border-box;
    140    
    141124    -webkit-box-shadow: none;
    142125    -moz-box-shadow: none;
     
    144127}
    145128
    146 #ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-text
    147 {
     129.ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-text {
    148130    position: relative;
    149131    z-index: 5;
     
    153135    background-color: #f5f5f5;
    154136    border-radius: 0;
    155    
    156137    -webkit-transition: background-color 250ms, color 250ms;
    157138    -moz-transition: background-color 250ms, color 250ms;
     
    160141}
    161142
    162 #ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-text:hover,
    163 #ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-text:active,
    164 #ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-text:focus
    165 {
     143.ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-text:hover, .ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-text:active, .ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-text:focus {
    166144    background-color: #0d3e70;
    167145    color: white;
    168146}
    169147
    170 #ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown
    171 {
     148.ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown {
    172149    position: relative;
    173150}
    174151
    175 #ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-options
    176 {
     152.ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-options {
    177153    position: absolute;
    178154    top: -40px;
     
    182158    opacity: 0;
    183159    background-color: white;
    184    
    185160    -webkit-box-shadow: 1px 1px 10px 1px rgba(0, 0, 0, 0.07);
    186161    -moz-box-shadow: 1px 1px 10px 1px rgba(0, 0, 0, 0.07);
    187162    -o-box-shadow: 1px 1px 10px 1px rgba(0, 0, 0, 0.07);
    188163    box-shadow: 1px 1px 10px 1px rgba(0, 0, 0, 0.07);
    189    
    190164    -webkit-transform: scaleY(0);
    191165    -moz-transform: scaleY(0);
     
    193167    -o-transform: scaleY(0);
    194168    transform: scaleY(0);
    195    
    196169    animation: optionsFadeOut 250ms ease-in;
    197170}
    198171
    199 #ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-options.initial
    200 {
     172.ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-options.initial {
    201173    visibility: hidden;
    202174}
    203175
    204 #ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-options.show
    205 {
     176.ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-options.show {
    206177    top: 25px;
    207178    z-index: 10;
    208179    opacity: 1;
    209    
    210180    -webkit-transform: scaleY(1);
    211181    -moz-transform: scaleY(1);
     
    213183    -o-transform: scaleY(1);
    214184    transform: scaleY(1);
    215    
    216185    animation: optionsFadeIn 500ms ease-out;
    217186}
    218187
    219 @keyframes optionsFadeIn
    220 {
    221     0%
    222     {
     188@keyframes optionsFadeIn {
     189    0% {
    223190        top: -40px;
    224191        z-index: 0;
    225192        opacity: 0;
    226        
    227193        -webkit-transform: scaleY(0);
    228194        -moz-transform: scaleY(0);
     
    231197        transform: scaleY(0);
    232198    }
    233    
    234     65%
    235     {
     199    65% {
    236200        opacity: 1;
    237        
    238201        -webkit-transform: scaleY(1);
    239202        -moz-transform: scaleY(1);
     
    242205        transform: scaleY(1);
    243206    }
    244    
    245     95%
    246     {
     207    95% {
    247208        z-index: 3;
    248209    }
    249    
    250     100%
    251     {
     210    100% {
    252211        top: 25px;
    253212        z-index: 10;
     
    255214}
    256215
    257 @keyframes optionsFadeOut
    258 {
    259     0%
    260     {
     216@keyframes optionsFadeOut {
     217    0% {
    261218        top: 25px;
    262219        z-index: 10;
    263220        opacity: 1;
    264        
    265221        -webkit-transform: scaleY(1);
    266222        -moz-transform: scaleY(1);
     
    269225        transform: scaleY(1);
    270226    }
    271    
    272     5%
    273     {
     227    5% {
    274228        z-index: 3;
    275229    }
    276    
    277     95%
    278     {
     230    95% {
    279231        opacity: 0;
    280        
    281232        -webkit-transform: scaleY(0);
    282233        -moz-transform: scaleY(0);
     
    285236        transform: scaleY(0);
    286237    }
    287    
    288     100%
    289     {
     238    100% {
    290239        top: -40px;
    291240        z-index: 0;
     
    293242}
    294243
    295 #ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-options .url-protocol-option
    296 {
     244.ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-options .url-protocol-option {
    297245    margin: 0;
    298246    padding: 5px;
     
    300248    cursor: pointer;
    301249    background-color: white;
    302    
    303250    -webkit-transition: background-color 250ms, color 250ms;
    304251    -moz-transition: background-color 250ms, color 250ms;
     
    307254}
    308255
    309 #ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-options .url-protocol-option:hover,
    310 #ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-options .url-protocol-option:active,
    311 #ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-options .url-protocol-option:focus
    312 {
     256.ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-options .url-protocol-option:hover, .ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-options .url-protocol-option:active, .ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-options .url-protocol-option:focus {
    313257    background-color: #2677d5;
    314258    color: white;
    315259}
    316260
    317 #ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-button
    318 {
     261.ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-button {
    319262    position: relative;
    320263    z-index: 5;
     
    329272    border: none;
    330273    cursor: pointer;
    331    
    332274    -webkit-box-shadow: none;
    333275    -moz-box-shadow: none;
    334276    box-shadow: none;
    335    
    336277    -webkit-transition: background-color 250ms, color 250ms;
    337278    -moz-transition: background-color 250ms, color 250ms;
     
    340281}
    341282
    342 #ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-button:hover,
    343 #ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-button:active,
    344 #ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-button:focus
    345 {
     283.ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-button:hover, .ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-button:active, .ecsb-admin-page .ecsb-field.url-select-container .url-select-item .url-protocol-dropdown .url-protocol-button:focus {
    346284    background-color: #2677d5;
    347285    color: white;
    348286}
    349287
    350 #ecsb-admin-page .ecsb-notice
    351 {
     288.ecsb-admin-page .ecsb-notice {
    352289    margin: 10px 0;
    353290    opacity: 1;
    354    
    355291    animation: noticeFadeIn 500ms ease-in;
    356292}
    357293
    358 #ecsb-admin-page .ecsb-notice.hide
    359 {
     294.ecsb-admin-page .ecsb-notice.hide {
    360295    opacity: 0;
    361    
    362296    animation: noticeFadeOut 500ms ease-out;
    363297}
    364298
    365 @keyframes noticeFadeIn
    366 {
    367     from
    368     {
     299@keyframes noticeFadeIn {
     300    from {
    369301        opacity: 0;
    370302    }
    371    
    372     to
    373     {
     303    to {
    374304        opacity: 1;
    375305    }
    376306}
    377307
    378 @keyframes noticeFadeOut
    379 {
    380     from
    381     {
     308@keyframes noticeFadeOut {
     309    from {
    382310        opacity: 1;
    383311    }
    384    
    385     to
    386     {
     312    to {
    387313        opacity: 0;
    388314    }
  • easy-country-spam-blocker/trunk/admin/js/mi-ecsb-admin.js

    r2215383 r2221863  
    22jQuery(document).ready(function()
    33{
     4    // Create empty array of countries.
     5    let countries = [];
     6
    47    // Try to find the settings form.
    58    let form = document.getElementById('ecsb-settings-form');
     
    811        return;
    912    }
     13
     14    // Find all supported countries.
     15    jQuery('.country-toggle').each((index, obj) => {
     16        // If the current toggle is enabled, add it to the countries list.
     17        if(obj.checked) {
     18            countries.push(obj.value);
     19        }
     20    });
     21
     22    // Add click event to country toggles.
     23    jQuery('.country-toggle').on('click', (e) => {
     24        // Grab the target element.
     25        let target = e.target;
     26        if(target == null || target == undefined) {
     27            return;
     28        }
     29
     30        if((target.checked == null || target.checked == undefined) || (target.value == null || target.value == undefined)) {
     31            return;
     32        }
     33
     34        // If the toggle is checked, add to the countries list.
     35        if(target.checked) {
     36            // Only add if this country isn't already on the list.
     37            if(!countries.includes(target.value)) {
     38                countries.push(target.value);
     39            }
     40        } else { // Otherwise, remove from countries list.
     41            // Only remove if this country is on the list.
     42            if(countries.includes(target.value)) {
     43                countries = countries.filter((value) => {
     44                    return value != target.value;
     45                });
     46            }
     47        }
     48    });
    1049   
    1150    // Add an event to the submit event.
     
    2059            action: form.action.value,
    2160            isEnabled: jQuery(form.isEnabled).prop('checked'),
     61            countries: countries,
    2262            redirectUrl: form.redirectUrl.value,
    2363            urlProtocol: form.url_protocol.value + '://'
  • easy-country-spam-blocker/trunk/admin/partials/mi-ecsb-admin-display.php

    r2215383 r2221863  
    1515// Try to get the redirect URL from the database.
    1616$is_enabled   = EasyCountrySpamBlocker_Helper::get_wp_option( 'mi-ecsb_is_enabled', false );
     17$countries    = EasyCountrySpamBlocker_Helper::get_wp_option( 'mi-ecsb_countries', [] );
    1718$redirect_url = EasyCountrySpamBlocker_Helper::get_url();
    1819$url_protocol = '';
     
    3132
    3233<!-- This file should primarily consist of HTML with a little bit of PHP. -->
    33 <div id="ecsb-admin-page">
    34    
     34<div id="ecsb-admin-page" class="ecsb-admin-page">
    3535    <h2><?php _e( 'Easy Country Spam Blocker Settings', 'mi-ecsb' ); ?></h2>
    3636    <p><?php _e( 'Easy Country Spam Blocker is a simple plugin that blocks all non-US traffic from a site. Choose a redirection URL below and click "Save."', 'mi-ecsb' ); ?></p>
    3737
    38     <form id="ecsb-settings-form" method="post">
     38    <!-- Settings Section 1 -->
     39    <div class="section">
     40        <div class="content">
     41            <form id="ecsb-settings-form" class="ecsb-settings-form" method="post">
     42                <div class="ecsb-field">
     43                    <label class="ecsb-field-label" for="is_enabled">
     44                        <?php _e( 'ECSB Enabled?', 'mi-ecsb' ); ?>
     45                    </label>
    3946
    40         <div class="ecsb-field">
     47                    <label class="switch">
     48                        <input name="isEnabled" type="checkbox" <?php if( $is_enabled ) echo 'checked'; ?>>
     49                        <span class="slider round"></span>
     50                    </label>
     51                </div>
     52               
     53                <div class="ecsb-field marginless-bottom">
     54                    <p class="ecsb-explanation">
     55                        <?php _e( 'What URL do you want to redirect non-US visitors to?', 'mi-ecsb' ); ?>
     56                    </p>
     57                </div>
     58               
     59                <div class="ecsb-field url-select-container">
     60                    <?php for($i = 0; $i < 1; $i++): ?>
     61                        <div class="url-select-item">
     62                            <div class="url-protocol-dropdown">
     63                                <button class="url-protocol-button" data-url-protocol="<?php echo esc_attr( $url_protocol ); ?>">
     64                                    <?php echo strtoupper( esc_html( $url_protocol ) ); ?>
     65                                </button>
     66                               
     67                                <ul class="url-protocol-options initial">
     68                                    <?php for($k = 0; $k < count( EasyCountrySpamBlocker_Helper::get_allowed_url_protocols() ); $k++): ?>
     69                                        <li class="url-protocol-option" data-url-protocol="<?php echo esc_attr( EasyCountrySpamBlocker_Helper::get_allowed_url_protocols()[ $k ] ); ?>">
     70                                            <?php echo strtoupper( esc_html( EasyCountrySpamBlocker_Helper::get_allowed_url_protocols()[ $k ] ) ); ?>
     71                                        </li>
     72                                    <?php endfor; ?>
     73                                </ul>
     74                            </div>
    4175
    42             <label class="ecsb-field-label" for="is_enabled">
     76                            <input class="url-text" name="redirectUrl" type="text" value="<?php echo EasyCountrySpamBlocker_Helper::strip_url_protocol( esc_url( $redirect_url ) ); ?>">
     77                        </div>
     78                    <?php endfor; ?>
    4379
    44                 <?php _e( 'ECSB Enabled?', 'mi-ecsb' ); ?>
     80                    <input type="hidden" name="url_protocol" value="<?php echo esc_attr( $url_protocol ); ?>">
     81                </div>
     82               
     83                <div class="ecsb-field">
     84                    <input type="hidden" name="action" value="ecsb_settings">
     85                </div>
     86               
     87                <div class="ecsb-field">
     88                    <input class="button button-primary button-large" type="submit" value="<?php echo _e( 'Save', 'mi-ecsb' ); ?>">
     89                </div>
     90            </form>
     91        </div>
     92    </div>
    4593
    46             </label>
     94    <div id="ecsb-notices"></div>
    4795
    48             <label class="switch">
     96    <!-- Settings Section 2 -->
     97    <div class="section">
     98        <div class="content">
     99            <h2 style="color: white"><?php _e( 'Whitelisted Countries', 'mi-ecsb' ); ?></h2>
    49100
    50                 <input name="isEnabled" type="checkbox" <?php if( $is_enabled ) echo 'checked'; ?>>
    51                 <span class="slider round"></span>
     101            <?php foreach( EasyCountrySpamBlocker_Helper::get_countries() as $key => $value ): ?>
     102                <div class="country" style="overflow: hidden;">
     103                    <div style="display: inline-block; width: 95%; float: left;">
     104                        <?php _e( $key, 'mi-ecsb' ); ?>
     105                    </div>
    52106
    53             </label>
    54 
     107                    <div style="display: inline-block; width: 5%; float: right;">
     108                        <input class="country-toggle" value="<?php echo $value; ?>" type="checkbox" <?php if( in_array( $value, $countries ) ) echo 'checked'; ?> />
     109                    </div>
     110                </div>
     111            <?php endforeach; ?>
    55112        </div>
    56        
    57         <div class="ecsb-field marginless-bottom">
    58            
    59             <p class="ecsb-explanation">
    60                 <?php _e( 'What URL do you want to redirect non-US visitors to?', 'mi-ecsb' ); ?>
    61             </p>
    62            
    63         </div>
    64        
    65         <div class="ecsb-field url-select-container">
    66            
    67             <?php for($i = 0; $i < 1; $i++): ?>
    68            
    69                 <div class="url-select-item">
    70                    
    71                     <div class="url-protocol-dropdown">
    72                        
    73                         <button class="url-protocol-button" data-url-protocol="<?php echo esc_attr( $url_protocol ); ?>">
    74                             <?php echo strtoupper( esc_html( $url_protocol ) ); ?>
    75                         </button>
    76                        
    77                         <ul class="url-protocol-options initial">
    78                             <?php for($k = 0; $k < count( EasyCountrySpamBlocker_Helper::get_allowed_url_protocols() ); $k++): ?>
    79                                
    80                                 <li class="url-protocol-option" data-url-protocol="<?php echo esc_attr( EasyCountrySpamBlocker_Helper::get_allowed_url_protocols()[ $k ] ); ?>">
    81                                     <?php echo strtoupper( esc_html( EasyCountrySpamBlocker_Helper::get_allowed_url_protocols()[ $k ] ) ); ?>
    82                                 </li>
    83                                
    84                             <?php endfor; ?>
    85                         </ul>
    86                        
    87                     </div>
    88                    
    89                     <input class="url-text" name="redirectUrl" type="text" value="<?php echo EasyCountrySpamBlocker_Helper::strip_url_protocol( esc_url( $redirect_url ) ); ?>">
    90                    
    91                 </div>
    92            
    93             <?php endfor; ?>
    94            
    95             <input type="hidden" name="url_protocol" value="<?php echo esc_attr( $url_protocol ); ?>">
    96            
    97         </div>
    98        
    99         <div class="ecsb-field">
    100            
    101             <input type="hidden" name="action" value="ecsb_settings">
    102            
    103         </div>
    104        
    105         <div class="ecsb-field">
    106            
    107             <input class="button button-primary button-large" type="submit" value="<?php echo _e( 'Save', 'mi-ecsb' ); ?>">
    108            
    109         </div>
    110 
    111     </form>
    112 
     113    </div>
     114   
     115    <!-- Question Section -->
    113116    <div style="background-color: white; padding: 10px; margin-top: 10px;">
    114117        <h2><?php _e( 'Questions?', 'mi-ecsb' ); ?></h2>
     
    116119        <a class="button button-primary button-large" href="https://www.mediuminteractive.com/contact/" target="_blank" rel="nofollow"><?php _e( 'Contact Us', 'mi-ecsb' ); ?></a>
    117120    </div>
    118    
    119     <div id="ecsb-notices"></div>
    120121
     122    <div style="background-color: white; padding: 10px; margin-top: 10px">
     123        <h2><?php _e( 'Quickstart', 'mi-ecsb' ); ?>
     124        <ul style="list-style-type: circle; margin-left: 25px; font-weight: normal; font-size: 1rem;">
     125            <li>
     126                <?php _e( 'Install & Activate', 'mi-ecsb' ); ?>
     127            </li>
     128            <li>
     129                <?php _e( 'Enable whitelisted countries' ); ?>
     130            </li>
     131            <li>
     132                <?php _e( 'Set redirect URL above', 'mi-ecsb' ); ?>
     133            </li>
     134            <li>
     135                <?php _e( 'Choose either HTTP or HTTPS', 'mi-ecsb' ); ?>
     136            </li>
     137            <li>
     138                <?php _e( 'Click "Save"', 'mi-ecsb' ); ?>
     139            </li>
     140            <li>
     141                <?php _e( 'Done!', 'mi-ecsb' ); ?>
     142            </li>
     143        </ul>
     144    </div>
    121145</div>
  • easy-country-spam-blocker/trunk/includes/class-mi-ecsb-form-actions.php

    r2215383 r2221863  
    109109        $post_data = array();
    110110
    111         // Sanitize the
     111        // Sanitize the is enabled.
    112112        $post_data[ 'is_enabled' ] = EasyCountrySpamBlocker_Helper::sanitize_checkbox( $_POST[ 'isEnabled' ] );
     113
     114        // Sanitize the countries.
     115        $post_data[ 'countries' ] = is_null( $_POST[ 'countries' ] ) ? [] : $_POST[ 'countries' ];
    113116       
    114117        // Sanitize the redirect URL.
     
    149152        // Save enabled status in the WordPress database.
    150153        EasyCountrySpamBlocker_Helper::save_wp_option( 'mi-ecsb_is_enabled', $post_data[ 'is_enabled' ] );
     154
     155        // Save countries to the WordPress database.
     156        EasyCountrySpamBlocker_Helper::save_wp_option( 'mi-ecsb_countries', $post_data[ 'countries' ] );
    151157       
    152158        // Save URL in the WordPress database.
     
    155161        // Set the return data.
    156162        $return_data = array(
    157             'test'      => $post_data[ 'is_enabled' ],
    158             'msg'       => __( 'URL Successfully saved!', 'mi-ecsb' ),
     163            'msg'       => __( 'URL Successfully saved!', 'mi-ecsb' ),
     164            'countries' => $post_data[ 'countries' ],
    159165            'exit_code' => 0,
    160166            'is_error'  => false
  • easy-country-spam-blocker/trunk/includes/class-mi-ecsb-helper.php

    r2215383 r2221863  
    397397        return 'WordPress/' . $wp_version . '; ' . home_url();
    398398    }
     399
     400    /**
     401     * Returns a list of all countries in the world.
     402     *
     403     * @since 1.1.0
     404     */
     405    public static function get_countries()
     406    {
     407        self::initialize();
     408
     409        return array(
     410            'Afghanistan'                                => 'AF',
     411            'Albania'                                    => 'AL',
     412            'Algeria'                                    => 'DZ',
     413            'American Samoa'                             => 'AS',
     414            'Andorra'                                    => 'AD',
     415            'Angola'                                     => 'AO',
     416            'Anguilla'                                   => 'AI',
     417            'Antarctica'                                 => 'AQ',
     418            'Antigua And Barbuda'                        => 'AG',
     419            'Argentina'                                  => 'AR',
     420            'Armenia'                                    => 'AM',
     421            'Aruba'                                      => 'AW',
     422            'Australia'                                  => 'AU',
     423            'Austria'                                    => 'AT',
     424            'Azerbaijan'                                 => 'AZ',
     425            'Bahamas'                                    => 'BS',
     426            'Bahrain'                                    => 'BH',
     427            'Bangladesh'                                 => 'BD',
     428            'Barbados'                                   => 'BB',
     429            'Belarus'                                    => 'BY',
     430            'Belgium'                                    => 'BE',
     431            'Belize'                                     => 'BZ',
     432            'Benin'                                      => 'BJ',
     433            'Bermuda'                                    => 'BM',
     434            'Bhutan'                                     => 'BT',
     435            'Bolivia'                                    => 'BO',
     436            'Bosnia And Herzegovina'                     => 'BA',
     437            'Botswana'                                   => 'BW',
     438            'Bouvet Island'                              => 'BV',
     439            'Brazil'                                     => 'BR',
     440            'British Indian Ocean Territory'             => 'IO',
     441            'Brunei Darussalam'                          => 'BN',
     442            'Bulgaria'                                   => 'BG',
     443            'Burkina Faso'                               => 'BF',
     444            'Burundi'                                    => 'BI',
     445            'Cambodia'                                   => 'KH',
     446            'Cameroon'                                   => 'CM',
     447            'Canada'                                     => 'CA',
     448            'Cape Verde'                                 => 'CV',
     449            'Cayman Islands'                             => 'KY',
     450            'Central African Republic'                   => 'CF',
     451            'Chad'                                       => 'TD',
     452            'Chile'                                      => 'CL',
     453            'People\'s Republic Of China'                => 'CN',
     454            'Christmas Island'                           => 'CX',
     455            'Cocos (Keeling) Islands'                    => 'CC',
     456            'Colombia'                                   => 'CO',
     457            'Comoros'                                    => 'KM',
     458            'Congo'                                      => 'CG',
     459            'Congo, The Democratic Republic Of'          => 'CD',
     460            'Cook Islands'                               => 'CK',
     461            'Costa Rica'                                 => 'CR',
     462            'Côte D\'Ivoire'                             => 'CI',
     463            'Croatia'                                    => 'HR',
     464            'Cuba'                                       => 'CU',
     465            'Cyprus'                                     => 'CY',
     466            'Czech Republic'                             => 'CZ',
     467            'Denmark'                                    => 'DK',
     468            'Djibouti'                                   => 'DJ',
     469            'Dominica'                                   => 'DM',
     470            'Dominican Republic'                         => 'DO',
     471            'Ecuador'                                    => 'EC',
     472            'Egypt'                                      => 'EG',
     473            'Western Sahara'                             => 'EH',
     474            'El Salvador'                                => 'SV',
     475            'Equatorial Guinea'                          => 'GQ',
     476            'Eritrea'                                    => 'ER',
     477            'Estonia'                                    => 'EE',
     478            'Ethiopia'                                   => 'ET',
     479            'Falkland Islands (Malvinas)'                => 'FK',
     480            'Faroe Islands'                              => 'FO',
     481            'Fiji'                                       => 'FJ',
     482            'Finland'                                    => 'FI',
     483            'France'                                     => 'FR',
     484            'French Guiana'                              => 'GF',
     485            'French Polynesia'                           => 'PF',
     486            'French Southern Territories'                => 'TF',
     487            'Gabon'                                      => 'GA',
     488            'Gambia'                                     => 'GM',
     489            'Georgia'                                    => 'GE',
     490            'Germany'                                    => 'DE',
     491            'Ghana'                                      => 'GH',
     492            'Gibraltar'                                  => 'GI',
     493            'Greece'                                     => 'GR',
     494            'Greenland'                                  => 'GL',
     495            'Grenada'                                    => 'GD',
     496            'Guadeloupe'                                 => 'GP',
     497            'Guam'                                       => 'GU',
     498            'Guatemala'                                  => 'GT',
     499            'Guinea'                                     => 'GN',
     500            'Guinea-Bissau'                              => 'GW',
     501            'Guyana'                                     => 'GY',
     502            'Haiti'                                      => 'HT',
     503            'Heard Island And Mcdonald Islands'          => 'HM',
     504            'Honduras'                                   => 'HN',
     505            'Hong Kong'                                  => 'HK',
     506            'Hungary'                                    => 'HU',
     507            'Iceland'                                    => 'IS',
     508            'India'                                      => 'IN',
     509            'Indonesia'                                  => 'ID',
     510            'Iran, Islamic Republic Of'                  => 'IR',
     511            'Iraq'                                       => 'IQ',
     512            'Ireland'                                    => 'IE',
     513            'Israel'                                     => 'IL',
     514            'Italy'                                      => 'IT',
     515            'Jamaica'                                    => 'JM',
     516            'Japan'                                      => 'JP',
     517            'Jordan'                                     => 'JO',
     518            'Kazakhstan'                                 => 'KZ',
     519            'Kenya'                                      => 'KE',
     520            'Kiribati'                                   => 'KI',
     521            'Korea, Democratic People\'s Republic Of'    => 'KP',
     522            'Korea, Republic Of'                         => 'KR',
     523            'Kuwait'                                     => 'KW',
     524            'Kyrgyzstan'                                 => 'KG',
     525            'Lao People\'s Democratic Republic'          => 'LA',
     526            'Latvia'                                     => 'LV',
     527            'Lebanon'                                    => 'LB',
     528            'Lesotho'                                    => 'LS',
     529            'Liberia'                                    => 'LR',
     530            'Libyan Arab Jamahiriya'                     => 'LY',
     531            'Liechtenstein'                              => 'LI',
     532            'Lithuania'                                  => 'LT',
     533            'Luxembourg'                                 => 'LU',
     534            'Macao'                                      => 'MO',
     535            'Macedonia, The Former Yugoslav Republic Of' => 'MK',
     536            'Madagascar'                                 => 'MG',
     537            'Malawi'                                     => 'MW',
     538            'Malaysia'                                   => 'MY',
     539            'Maldives'                                   => 'MV',
     540            'Mali'                                       => 'ML',
     541            'Malta'                                      => 'MT',
     542            'Marshall Islands'                           => 'MH',
     543            'Martinique'                                 => 'MQ',
     544            'Mauritania'                                 => 'MR',
     545            'Mauritius'                                  => 'MU',
     546            'Mayotte'                                    => 'YT',
     547            'Mexico'                                     => 'MX',
     548            'Micronesia, Federated States Of'            => 'FM',
     549            'Moldova, Republic Of'                       => 'MD',
     550            'Monaco'                                     => 'MC',
     551            'Mongolia'                                   => 'MN',
     552            'Montserrat'                                 => 'MS',
     553            'Morocco'                                    => 'MA',
     554            'Mozambique'                                 => 'MZ',
     555            'Myanmar'                                    => 'MM',
     556            'Namibia'                                    => 'NA',
     557            'Nauru'                                      => 'NR',
     558            'Nepal'                                      => 'NP',
     559            'Netherlands'                                => 'NL',
     560            'Netherlands Antilles'                       => 'AN',
     561            'New Caledonia'                              => 'NC',
     562            'New Zealand'                                => 'NZ',
     563            'Nicaragua'                                  => 'NI',
     564            'Niger'                                      => 'NE',
     565            'Nigeria'                                    => 'NG',
     566            'Niue'                                       => 'NU',
     567            'Norfolk Island'                             => 'NF',
     568            'Northern Mariana Islands'                   => 'MP',
     569            'Norway'                                     => 'NO',
     570            'Oman'                                       => 'OM',
     571            'Pakistan'                                   => 'PK',
     572            'Palau'                                      => 'PW',
     573            'Palestinian Territory, Occupied'            => 'PS',
     574            'Panama'                                     => 'PA',
     575            'Papua New Guinea'                           => 'PG',
     576            'Paraguay'                                   => 'PY',
     577            'Peru'                                       => 'PE',
     578            'Philippines'                                => 'PH',
     579            'Pitcairn'                                   => 'PN',
     580            'Poland'                                     => 'PL',
     581            'Portugal'                                   => 'PT',
     582            'Puerto Rico'                                => 'PR',
     583            'Qatar'                                      => 'QA',
     584            'Réunion'                                    => 'RE',
     585            'Romania'                                    => 'RO',
     586            'Russian Federation'                         => 'RU',
     587            'Rwanda'                                     => 'RW',
     588            'Saint Helena'                               => 'SH',
     589            'Saint Kitts And Nevis'                      => 'KN',
     590            'Saint Lucia'                                => 'LC',
     591            'Saint Pierre And Miquelon'                  => 'PM',
     592            'Saint Vincent And The Grenadines'           => 'VC',
     593            'Samoa'                                      => 'WS',
     594            'San Marino'                                 => 'SM',
     595            'Sao Tome And Principe'                      => 'ST',
     596            'Saudi Arabia'                               => 'SA',
     597            'Senegal'                                    => 'SN',
     598            'Serbia And Montenegro'                      => 'CS',
     599            'Seychelles'                                 => 'SC',
     600            'Sierra Leone'                               => 'SL',
     601            'Singapore'                                  => 'SG',
     602            'Slovakia'                                   => 'SK',
     603            'Slovenia'                                   => 'SI',
     604            'Solomon Islands'                            => 'SB',
     605            'Somalia'                                    => 'SO',
     606            'South Africa'                               => 'ZA',
     607            'South Georgia And South Sandwich Islands'   => 'GS',
     608            'Spain'                                      => 'ES',
     609            'Sri Lanka'                                  => 'LK',
     610            'Sudan'                                      => 'SD',
     611            'Suriname'                                   => 'SR',
     612            'Svalbard And Jan Mayen'                     => 'SJ',
     613            'Swaziland'                                  => 'SZ',
     614            'Sweden'                                     => 'SE',
     615            'Switzerland'                                => 'CH',
     616            'Syrian Arab Republic'                       => 'SY',
     617            'Taiwan, Republic Of China'                  => 'TW',
     618            'Tajikistan'                                 => 'TJ',
     619            'Tanzania, United Republic Of'               => 'TZ',
     620            'Thailand'                                   => 'TH',
     621            'Timor-Leste'                                => 'TL',
     622            'Togo'                                       => 'TG',
     623            'Tokelau'                                    => 'TK',
     624            'Tonga'                                      => 'TO',
     625            'Trinidad And Tobago'                        => 'TT',
     626            'Tunisia'                                    => 'TN',
     627            'Turkey'                                     => 'TR',
     628            'Turkmenistan'                               => 'TM',
     629            'Turks And Caicos Islands'                   => 'TC',
     630            'Tuvalu'                                     => 'TV',
     631            'Uganda'                                     => 'UG',
     632            'Ukraine'                                    => 'UA',
     633            'United Arab Emirates'                       => 'AE',
     634            'United Kingdom'                             => 'GB',
     635            'United States'                              => 'US',
     636            'United States Minor Outlying Islands'       => 'UM',
     637            'Uruguay'                                    => 'UY',
     638            'Uzbekistan'                                 => 'UZ',
     639            'Venezuela'                                  => 'VE',
     640            'Vanuatu'                                    => 'VU',
     641            'Viet Nam'                                   => 'VN',
     642            'British Virgin Islands'                     => 'VG',
     643            'U.S. Virgin Islands'                        => 'VI',
     644            'Wallis And Futuna'                          => 'WF',
     645            'Yemen'                                      => 'YE',
     646            'Zimbabwe'                                   => 'ZW',
     647        );
     648    }
    399649}
  • easy-country-spam-blocker/trunk/includes/class-mi-ecsb-redirect.php

    r2215383 r2221863  
    8181            {
    8282                // Obtain the client's IP a different way. If the web host uses a proxy, this won't work (unless the server is located outside the US).
    83                 $clientIP = $_SERVER[ 'REMOTE_ADDR' ];
     83                $clientIP = $_SERVER[ 'REMOTE_ADDR' ];
     84                $clientIP = '76.188.19.75';
    8485               
    8586                // Try to get information one more time.
     
    106107       
    107108        // If no country found is found, do not continue.
    108         if( $countryCode === null )
    109         {
     109        if( $countryCode === null ) {
     110            return;
     111        }
     112
     113        // Grab supported countries.
     114        $supported_countries = EasyCountrySpamBlocker_Helper::get_wp_option( 'mi-ecsb_countries', [] );
     115        if( empty( $supported_countries ) ) {
    110116            return;
    111117        }
    112118       
    113         // If the country code is NOT the US, redirect.
    114         if( strtolower( $countryCode ) !== 'us' )
    115         {
    116             // Redirect the visitor and give a "403 Forbidden" status code.
    117             http_response_code( 403 );
    118             header( 'Location: ' . EasyCountrySpamBlocker_Helper::get_url() );
    119             exit();
     119        // Loop through supported countries.
     120        for($i = 0; $i < count( $supported_countries ); $i++ ) {
     121            // If the retrieved country code is equal to the current supported country code, redirect.
     122            if( strtolower( $countryCode ) !== strtolower( $supported_countries[ $i ] ) )
     123            {
     124                // Redirect the visitor and give a "403 Forbidden" status code.
     125                http_response_code( 403 );
     126                header( 'Location: ' . EasyCountrySpamBlocker_Helper::get_url() );
     127                exit();
     128            }
    120129        }
    121130    }
  • easy-country-spam-blocker/trunk/mi-ecsb.php

    r2215383 r2221863  
    1616 * Plugin Name:       Easy Country Spam Blocker
    1717 * Description:       Easily block non-US visitors out of your site with a custom redirect URL.
    18  * Version:           1.0.0
     18 * Version:           1.1.0
    1919 * Author:            Medium Interactive, LLC
    2020 * Author URI:        https://mediuminteractive.com/
     
    3232 * Current plugin version. Use SemVer - https://semver.org
    3333 */
    34 define( 'EASYCOUNTRYSPAMBLOCKER_VERSION', '1.0.0' );
     34define( 'EASYCOUNTRYSPAMBLOCKER_VERSION', '1.1.0' );
    3535define( 'EASYCOUNTRYSPAMBLOCKER_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
    3636define( 'EASYCOUNTRYSPAMBLOCKER_BASE_PATH', plugin_dir_path( __FILE__ ) );
Note: See TracChangeset for help on using the changeset viewer.