Changeset 2221863
- Timestamp:
- 01/03/2020 08:55:52 PM (6 years ago)
- Location:
- easy-country-spam-blocker/trunk
- Files:
-
- 8 edited
-
README.txt (modified) (1 diff)
-
admin/css/mi-ecsb-admin.css (modified) (27 diffs)
-
admin/js/mi-ecsb-admin.js (modified) (3 diffs)
-
admin/partials/mi-ecsb-admin-display.php (modified) (3 diffs)
-
includes/class-mi-ecsb-form-actions.php (modified) (3 diffs)
-
includes/class-mi-ecsb-helper.php (modified) (1 diff)
-
includes/class-mi-ecsb-redirect.php (modified) (2 diffs)
-
mi-ecsb.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
easy-country-spam-blocker/trunk/README.txt
r2215383 r2221863 57 57 == Screenshots == 58 58 59 1. https://i.ibb.co/xGZV5gh/Capture.png60 2. https://i.ibb.co/yVSgXJF/mi-ecsb-flowchart.jpg59 1. Settings page. 60 2. How ECSB works. 61 61 62 62 == Changelog == 63 64 = 1.1.0 = 65 * Added ability to choose whitelisted countries 66 * Added small quickstart section 63 67 64 68 = 1.0.1 = -
easy-country-spam-blocker/trunk/admin/css/mi-ecsb-admin.css
r2215383 r2221863 3 3 * included in this file. 4 4 */ 5 #ecsb-admin-page 6 {5 6 .ecsb-admin-page { 7 7 margin-right: 20px; 8 8 } 9 9 10 #ecsb-admin-page .switch 11 { 10 .ecsb-admin-page .switch { 12 11 position: relative; 13 12 display: inline-block; … … 16 15 } 17 16 18 #ecsb-admin-page .switch input 19 { 17 .ecsb-admin-page .switch input { 20 18 opacity: 0; 21 19 width: 0; … … 23 21 } 24 22 25 #ecsb-admin-page .slider 26 { 23 .ecsb-admin-page .slider { 27 24 position: absolute; 28 25 cursor: pointer; … … 32 29 bottom: 0; 33 30 background-color: #cccccc; 34 35 31 -webkit-transition: 400ms; 36 32 -moz-transition: 400ms; … … 39 35 } 40 36 41 #ecsb-admin-page .slider:before 42 { 37 .ecsb-admin-page .slider:before { 43 38 position: absolute; 44 39 content: ""; … … 48 43 bottom: 2px; 49 44 background-color: white; 50 51 45 -webkit-transition: 400ms; 52 46 -moz-transition: 400ms; … … 55 49 } 56 50 57 #ecsb-admin-page input:checked + .slider 58 { 51 .ecsb-admin-page input:checked+.slider { 59 52 background-color: #2677d5; 60 53 } 61 54 62 #ecsb-admin-page input:focus + .slider 63 { 55 .ecsb-admin-page input:focus+.slider { 64 56 box-shadow: 0 0 1px #2677d5; 65 57 } 66 58 67 #ecsb-admin-page input:checked + .slider:before 68 { 59 .ecsb-admin-page input:checked+.slider:before { 69 60 -webkit-transform: translateX(20px); 70 61 -moz-transform: translateX(20px); … … 74 65 } 75 66 76 #ecsb-admin-page .slider.round 77 { 67 .ecsb-admin-page .slider.round { 78 68 border-radius: 20px; 79 69 } 80 70 81 #ecsb-admin-page .slider.round:before 82 { 71 .ecsb-admin-page .slider.round:before { 83 72 border-radius: 50%; 84 73 } … … 86 75 87 76 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 { 90 85 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 { 98 89 margin: 5px 0; 99 90 } 100 91 101 #ecsb-admin-page .ecsb-field-label 102 { 92 .ecsb-admin-page .ecsb-field-label { 103 93 font-size: 15px; 104 94 font-weight: 600; 105 95 } 106 96 107 #ecsb-admin-page .ecsb-field.marginless-bottom 108 { 97 .ecsb-admin-page .ecsb-field.marginless-bottom { 109 98 margin-bottom: 0; 110 99 } 111 100 112 #ecsb-admin-page .ecsb-field .ecsb-explanation 113 { 101 .ecsb-admin-page .ecsb-field .ecsb-explanation { 114 102 margin: 0; 115 103 padding: 5px; … … 118 106 } 119 107 120 #ecsb-admin-page .ecsb-field.url-select-container 121 { 108 .ecsb-admin-page .ecsb-field.url-select-container { 122 109 margin-top: 0; 123 110 } 124 111 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 { 127 113 height: 35px; 128 114 } 129 115 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 { 133 117 display: inline-block; 134 118 height: 100%; … … 138 122 outline: none; 139 123 box-sizing: border-box; 140 141 124 -webkit-box-shadow: none; 142 125 -moz-box-shadow: none; … … 144 127 } 145 128 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 { 148 130 position: relative; 149 131 z-index: 5; … … 153 135 background-color: #f5f5f5; 154 136 border-radius: 0; 155 156 137 -webkit-transition: background-color 250ms, color 250ms; 157 138 -moz-transition: background-color 250ms, color 250ms; … … 160 141 } 161 142 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 { 166 144 background-color: #0d3e70; 167 145 color: white; 168 146 } 169 147 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 { 172 149 position: relative; 173 150 } 174 151 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 { 177 153 position: absolute; 178 154 top: -40px; … … 182 158 opacity: 0; 183 159 background-color: white; 184 185 160 -webkit-box-shadow: 1px 1px 10px 1px rgba(0, 0, 0, 0.07); 186 161 -moz-box-shadow: 1px 1px 10px 1px rgba(0, 0, 0, 0.07); 187 162 -o-box-shadow: 1px 1px 10px 1px rgba(0, 0, 0, 0.07); 188 163 box-shadow: 1px 1px 10px 1px rgba(0, 0, 0, 0.07); 189 190 164 -webkit-transform: scaleY(0); 191 165 -moz-transform: scaleY(0); … … 193 167 -o-transform: scaleY(0); 194 168 transform: scaleY(0); 195 196 169 animation: optionsFadeOut 250ms ease-in; 197 170 } 198 171 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 { 201 173 visibility: hidden; 202 174 } 203 175 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 { 206 177 top: 25px; 207 178 z-index: 10; 208 179 opacity: 1; 209 210 180 -webkit-transform: scaleY(1); 211 181 -moz-transform: scaleY(1); … … 213 183 -o-transform: scaleY(1); 214 184 transform: scaleY(1); 215 216 185 animation: optionsFadeIn 500ms ease-out; 217 186 } 218 187 219 @keyframes optionsFadeIn 220 { 221 0% 222 { 188 @keyframes optionsFadeIn { 189 0% { 223 190 top: -40px; 224 191 z-index: 0; 225 192 opacity: 0; 226 227 193 -webkit-transform: scaleY(0); 228 194 -moz-transform: scaleY(0); … … 231 197 transform: scaleY(0); 232 198 } 233 234 65% 235 { 199 65% { 236 200 opacity: 1; 237 238 201 -webkit-transform: scaleY(1); 239 202 -moz-transform: scaleY(1); … … 242 205 transform: scaleY(1); 243 206 } 244 245 95% 246 { 207 95% { 247 208 z-index: 3; 248 209 } 249 250 100% 251 { 210 100% { 252 211 top: 25px; 253 212 z-index: 10; … … 255 214 } 256 215 257 @keyframes optionsFadeOut 258 { 259 0% 260 { 216 @keyframes optionsFadeOut { 217 0% { 261 218 top: 25px; 262 219 z-index: 10; 263 220 opacity: 1; 264 265 221 -webkit-transform: scaleY(1); 266 222 -moz-transform: scaleY(1); … … 269 225 transform: scaleY(1); 270 226 } 271 272 5% 273 { 227 5% { 274 228 z-index: 3; 275 229 } 276 277 95% 278 { 230 95% { 279 231 opacity: 0; 280 281 232 -webkit-transform: scaleY(0); 282 233 -moz-transform: scaleY(0); … … 285 236 transform: scaleY(0); 286 237 } 287 288 100% 289 { 238 100% { 290 239 top: -40px; 291 240 z-index: 0; … … 293 242 } 294 243 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 { 297 245 margin: 0; 298 246 padding: 5px; … … 300 248 cursor: pointer; 301 249 background-color: white; 302 303 250 -webkit-transition: background-color 250ms, color 250ms; 304 251 -moz-transition: background-color 250ms, color 250ms; … … 307 254 } 308 255 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 { 313 257 background-color: #2677d5; 314 258 color: white; 315 259 } 316 260 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 { 319 262 position: relative; 320 263 z-index: 5; … … 329 272 border: none; 330 273 cursor: pointer; 331 332 274 -webkit-box-shadow: none; 333 275 -moz-box-shadow: none; 334 276 box-shadow: none; 335 336 277 -webkit-transition: background-color 250ms, color 250ms; 337 278 -moz-transition: background-color 250ms, color 250ms; … … 340 281 } 341 282 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 { 346 284 background-color: #2677d5; 347 285 color: white; 348 286 } 349 287 350 #ecsb-admin-page .ecsb-notice 351 { 288 .ecsb-admin-page .ecsb-notice { 352 289 margin: 10px 0; 353 290 opacity: 1; 354 355 291 animation: noticeFadeIn 500ms ease-in; 356 292 } 357 293 358 #ecsb-admin-page .ecsb-notice.hide 359 { 294 .ecsb-admin-page .ecsb-notice.hide { 360 295 opacity: 0; 361 362 296 animation: noticeFadeOut 500ms ease-out; 363 297 } 364 298 365 @keyframes noticeFadeIn 366 { 367 from 368 { 299 @keyframes noticeFadeIn { 300 from { 369 301 opacity: 0; 370 302 } 371 372 to 373 { 303 to { 374 304 opacity: 1; 375 305 } 376 306 } 377 307 378 @keyframes noticeFadeOut 379 { 380 from 381 { 308 @keyframes noticeFadeOut { 309 from { 382 310 opacity: 1; 383 311 } 384 385 to 386 { 312 to { 387 313 opacity: 0; 388 314 } -
easy-country-spam-blocker/trunk/admin/js/mi-ecsb-admin.js
r2215383 r2221863 2 2 jQuery(document).ready(function() 3 3 { 4 // Create empty array of countries. 5 let countries = []; 6 4 7 // Try to find the settings form. 5 8 let form = document.getElementById('ecsb-settings-form'); … … 8 11 return; 9 12 } 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 }); 10 49 11 50 // Add an event to the submit event. … … 20 59 action: form.action.value, 21 60 isEnabled: jQuery(form.isEnabled).prop('checked'), 61 countries: countries, 22 62 redirectUrl: form.redirectUrl.value, 23 63 urlProtocol: form.url_protocol.value + '://' -
easy-country-spam-blocker/trunk/admin/partials/mi-ecsb-admin-display.php
r2215383 r2221863 15 15 // Try to get the redirect URL from the database. 16 16 $is_enabled = EasyCountrySpamBlocker_Helper::get_wp_option( 'mi-ecsb_is_enabled', false ); 17 $countries = EasyCountrySpamBlocker_Helper::get_wp_option( 'mi-ecsb_countries', [] ); 17 18 $redirect_url = EasyCountrySpamBlocker_Helper::get_url(); 18 19 $url_protocol = ''; … … 31 32 32 33 <!-- 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"> 35 35 <h2><?php _e( 'Easy Country Spam Blocker Settings', 'mi-ecsb' ); ?></h2> 36 36 <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> 37 37 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> 39 46 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> 41 75 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; ?> 43 79 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> 45 93 46 </label>94 <div id="ecsb-notices"></div> 47 95 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> 49 100 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> 52 106 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; ?> 55 112 </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 --> 113 116 <div style="background-color: white; padding: 10px; margin-top: 10px;"> 114 117 <h2><?php _e( 'Questions?', 'mi-ecsb' ); ?></h2> … … 116 119 <a class="button button-primary button-large" href="https://www.mediuminteractive.com/contact/" target="_blank" rel="nofollow"><?php _e( 'Contact Us', 'mi-ecsb' ); ?></a> 117 120 </div> 118 119 <div id="ecsb-notices"></div>120 121 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> 121 145 </div> -
easy-country-spam-blocker/trunk/includes/class-mi-ecsb-form-actions.php
r2215383 r2221863 109 109 $post_data = array(); 110 110 111 // Sanitize the 111 // Sanitize the is enabled. 112 112 $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' ]; 113 116 114 117 // Sanitize the redirect URL. … … 149 152 // Save enabled status in the WordPress database. 150 153 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' ] ); 151 157 152 158 // Save URL in the WordPress database. … … 155 161 // Set the return data. 156 162 $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' ], 159 165 'exit_code' => 0, 160 166 'is_error' => false -
easy-country-spam-blocker/trunk/includes/class-mi-ecsb-helper.php
r2215383 r2221863 397 397 return 'WordPress/' . $wp_version . '; ' . home_url(); 398 398 } 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 } 399 649 } -
easy-country-spam-blocker/trunk/includes/class-mi-ecsb-redirect.php
r2215383 r2221863 81 81 { 82 82 // 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'; 84 85 85 86 // Try to get information one more time. … … 106 107 107 108 // 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 ) ) { 110 116 return; 111 117 } 112 118 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 } 120 129 } 121 130 } -
easy-country-spam-blocker/trunk/mi-ecsb.php
r2215383 r2221863 16 16 * Plugin Name: Easy Country Spam Blocker 17 17 * Description: Easily block non-US visitors out of your site with a custom redirect URL. 18 * Version: 1. 0.018 * Version: 1.1.0 19 19 * Author: Medium Interactive, LLC 20 20 * Author URI: https://mediuminteractive.com/ … … 32 32 * Current plugin version. Use SemVer - https://semver.org 33 33 */ 34 define( 'EASYCOUNTRYSPAMBLOCKER_VERSION', '1. 0.0' );34 define( 'EASYCOUNTRYSPAMBLOCKER_VERSION', '1.1.0' ); 35 35 define( 'EASYCOUNTRYSPAMBLOCKER_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); 36 36 define( 'EASYCOUNTRYSPAMBLOCKER_BASE_PATH', plugin_dir_path( __FILE__ ) );
Note: See TracChangeset
for help on using the changeset viewer.