cdn
7 years ago
buttons.html
11 years ago
cloudflare_warning.html
6 years ago
disable_wp_cron.php
7 years ago
download.html
10 years ago
exclude.php
7 years ago
htaccess.html
9 years ago
lazy_load.php
6 years ago
newpost.php
6 years ago
nginx_gzip.php
9 years ago
permission_error.html
10 years ago
preload.php
6 years ago
sample_img_list.html
7 years ago
timeout.php
7 years ago
update_error.html
10 years ago
update_now.php
9 years ago
update_success.html
10 years ago
update_success.php
10 years ago
updatepost.php
6 years ago
exclude.php
573 lines
| 1 | <style type="text/css"> |
| 2 | .wpfc-exclude-item:hover{ |
| 3 | background-color: #E5E5E5; |
| 4 | } |
| 5 | .wpfc-exclude-item{ |
| 6 | float: left; |
| 7 | width: 330.5px; |
| 8 | margin-right: 7px; |
| 9 | -moz-border-radius:5px 5px 5px 5px; |
| 10 | -webkit-border-radius:5px 5px 5px 5px; |
| 11 | border-radius:5px 5px 5px 5px; |
| 12 | border:1px solid transparent; |
| 13 | cursor:pointer; |
| 14 | padding:9px; |
| 15 | outline:none !important; |
| 16 | list-style: outside none none; |
| 17 | } |
| 18 | .star{ |
| 19 | float:left; |
| 20 | height:28px; |
| 21 | width:32px; |
| 22 | display: none; |
| 23 | } |
| 24 | .star img{ |
| 25 | margin:9px 4px 4px; |
| 26 | } |
| 27 | |
| 28 | .wpfc-exclude-item-form-title{ |
| 29 | max-width:380px; |
| 30 | font-weight:bold; |
| 31 | white-space:nowrap; |
| 32 | max-width:615px; |
| 33 | margin-bottom:3px; |
| 34 | text-overflow:ellipsis; |
| 35 | -o-text-overflow:ellipsis; |
| 36 | -moz-text-overflow:ellipsis; |
| 37 | -webkit-text-overflow:ellipsis; |
| 38 | line-height:1em; |
| 39 | font-family: Verdana,Geneva,Arial,Helvetica,sans-serif; |
| 40 | } |
| 41 | .wpfc-exclude-item-details{ |
| 42 | font-size:11px; |
| 43 | color:#888; |
| 44 | display:block; |
| 45 | white-space:nowrap; |
| 46 | font-family: Verdana,Geneva,Arial,Helvetica,sans-serif; |
| 47 | line-height:1.5em; |
| 48 | } |
| 49 | .wpfc-exclude-item-details b { |
| 50 | display:inline; |
| 51 | margin-left: 1px; |
| 52 | |
| 53 | } |
| 54 | .wpfc-exclude-item-right{ |
| 55 | margin-right: 0; |
| 56 | } |
| 57 | </style> |
| 58 | <div id="wpfc-modal-exclude" style="display:none;top: 10.5px; left: 226px; position: absolute; padding: 6px; height: auto; width: 560px; z-index: 10001;"> |
| 59 | <div style="height: 100%; width: 100%; background: none repeat scroll 0% 0% rgb(0, 0, 0); position: absolute; top: 0px; left: 0px; z-index: -1; opacity: 0.5; border-radius: 8px;"> |
| 60 | </div> |
| 61 | <div style="z-index: 600; border-radius: 3px;"> |
| 62 | <div style="font-family:Verdana,Geneva,Arial,Helvetica,sans-serif;font-size:12px;background: none repeat scroll 0px 0px rgb(255, 161, 0); z-index: 1000; position: relative; padding: 2px; border-bottom: 1px solid rgb(194, 122, 0); height: 35px; border-radius: 3px 3px 0px 0px;"> |
| 63 | <table width="100%" height="100%"> |
| 64 | <tbody> |
| 65 | <tr> |
| 66 | <td valign="middle" style="vertical-align: middle; font-weight: bold; color: rgb(255, 255, 255); text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.5); padding-left: 10px; font-size: 13px; cursor: move;">Exclude Page Wizard</td> |
| 67 | <td width="20" align="center" style="vertical-align: middle;"></td> |
| 68 | <td width="20" align="center" style="vertical-align: middle; font-family: Arial,Helvetica,sans-serif; color: rgb(170, 170, 170); cursor: default;"> |
| 69 | <div title="Close Window" class="close-wiz"></div> |
| 70 | </td> |
| 71 | </tr> |
| 72 | </tbody> |
| 73 | </table> |
| 74 | </div> |
| 75 | <div class="window-content-wrapper" style="padding: 8px;"> |
| 76 | <div style="z-index: 1000; height: auto; position: relative; display: inline-block; width: 100%;" class="window-content"> |
| 77 | |
| 78 | |
| 79 | <div id="wpfc-wizard-exclude" class="wpfc-cdn-pages-container"> |
| 80 | <div wpfc-cdn-page="1" class="wiz-cont" style="padding:0 0;min-height:37px;"> |
| 81 | |
| 82 | <table width="100%" cellspacing="0" cellpadding="0" border="0" height="100%" style="background-color:#FFFFFF;border:1px solid #ccc !important;border-radius:10px;"> |
| 83 | <tbody> |
| 84 | <tr> |
| 85 | <td valign="top" id="cond-list"> |
| 86 | <table width="100%" cellspacing="0" cellpadding="5" border="0" class="cond-line active-line"> |
| 87 | <tbody> |
| 88 | <tr> |
| 89 | <td width="100" height="35" class="wpfc-condition-text" style="padding-left:10px;font-family: Verdana,Geneva,Arial,Helvetica,sans-serif;font-size: 12px;">If REQUEST_URI</td> |
| 90 | <td class="" width="95"> |
| 91 | <select name="wpfc-exclude-rule-prefix" style="width: 98px !important;"> |
| 92 | <option selected="" value=""></option> |
| 93 | <option value="homepage">Home Page</option> |
| 94 | <option value="category">Categories</option> |
| 95 | <option value="tag">Tags</option> |
| 96 | <option value="post">Posts</option> |
| 97 | <option value="page">Pages</option> |
| 98 | |
| 99 | <option value="archive">Archives</option> |
| 100 | |
| 101 | <option value="attachment">Attachments</option> |
| 102 | <option value="startwith">Starts With</option> |
| 103 | <option value="contain">Contains</option> |
| 104 | <option value="exact">Is Equal To</option> |
| 105 | <option value="googleanalytics">has Google Analytics Parameters</option> |
| 106 | <option value="woocommerce_items_in_cart">has Woocommerce Items in Cart</option> |
| 107 | </select> |
| 108 | </td> |
| 109 | <td width="300"> |
| 110 | <div class="wpfc-exclude-rule-line-middle"> |
| 111 | <input type="text" name="wpfc-exclude-rule-content" style="width:300px;"> |
| 112 | <input type="hidden" name="wpfc-exclude-rule-type" style="width:300px;"> |
| 113 | </div> |
| 114 | </td> |
| 115 | </tr> |
| 116 | </tbody> |
| 117 | </table> |
| 118 | </td> |
| 119 | </tr> |
| 120 | </tbody> |
| 121 | </table> |
| 122 | </div> |
| 123 | </div> |
| 124 | </div> |
| 125 | </div> |
| 126 | <div class="window-buttons-wrapper" style="padding: 0px; display: inline-block; width: 100%; border-top: 1px solid rgb(255, 255, 255); background: none repeat scroll 0px 0px rgb(222, 222, 222); z-index: 999; position: relative; text-align: right; border-radius: 0px 0px 3px 3px;"> |
| 127 | <div style="padding: 12px; height: 23px;"> |
| 128 | <button class="wpfc-dialog-buttons buttons-blood" type="button" action="remove"> |
| 129 | <span>Remove Rule</span> |
| 130 | </button> |
| 131 | <button class="wpfc-dialog-buttons" type="button" action="back"> |
| 132 | <span>Back</span> |
| 133 | </button> |
| 134 | <button class="wpfc-dialog-buttons" type="button" action="next"> |
| 135 | <span>Next</span> |
| 136 | </button> |
| 137 | <button class="wpfc-dialog-buttons" type="button" action="close"> |
| 138 | <span>Close</span> |
| 139 | </button> |
| 140 | <button class="wpfc-dialog-buttons buttons-green" type="button" action="finish"> |
| 141 | <span>Save</span> |
| 142 | </button> |
| 143 | </div> |
| 144 | </div> |
| 145 | </div> |
| 146 | </div> |
| 147 | <script type="text/javascript"> |
| 148 | var WpFcExcludePages = { |
| 149 | rules: [], |
| 150 | init: function(rules){ |
| 151 | this.rules = rules; |
| 152 | this.insert_existing_rules(); |
| 153 | this.click_event_for_add_button(); |
| 154 | this.reorder(); |
| 155 | }, |
| 156 | remove_rule: function(clone_modal_id, number){ |
| 157 | jQuery("div.wpfc-exclude-item[wpfc-exclude-item-number='" + number + "']").remove(); |
| 158 | jQuery("div.wpfc-exclude-rule-line[wpfc-exclude-rule-number='" + number + "']").remove(); |
| 159 | Wpfc_Dialog.remove(clone_modal_id, number); |
| 160 | |
| 161 | this.save(function(){}); |
| 162 | }, |
| 163 | add_item: function(number, e){ |
| 164 | var self = this; |
| 165 | var item = jQuery(".wpfc-exclude-item").first().clone(); |
| 166 | |
| 167 | if(jQuery(".wpfc-exclude-item").length%2 == 0){ |
| 168 | console.log(item, jQuery(".wpfc-exclude-item").length) |
| 169 | item.addClass("wpfc-exclude-item-right"); |
| 170 | } |
| 171 | |
| 172 | |
| 173 | item.attr("wpfc-exclude-item-number", number); |
| 174 | item.attr("prefix", e.prefix); |
| 175 | item.attr("content", e.content); |
| 176 | item.attr("type", e.type); |
| 177 | |
| 178 | item.find(".wpfc-exclude-item-url").html(self.create_url_description(e.prefix, e.content, e.type)); |
| 179 | |
| 180 | item.find(".wpfc-exclude-item-form-title").html(self.create_title(e.prefix, e.content)); |
| 181 | |
| 182 | item.click(function(){ |
| 183 | var clone_modal = jQuery("#wpfc-modal-exclude").clone(); |
| 184 | var clone_modal_id = "wpfc-modal-exclude-" + new Date().getTime(); |
| 185 | |
| 186 | clone_modal.find("select").change(function(e){ |
| 187 | if(jQuery(this).val().match(/^(homepage|category|tag|archive|post|page|attachment|googleanalytics|woocommerce_items_in_cart)$/)){ |
| 188 | clone_modal.find("input[name='wpfc-exclude-rule-content']").closest("td").hide(); |
| 189 | clone_modal.find("input[name='wpfc-exclude-rule-content']").val(jQuery(this).val()); |
| 190 | |
| 191 | jQuery(this).closest("td").width(395); |
| 192 | jQuery(this).width(395); |
| 193 | }else{ |
| 194 | clone_modal.find("input[name='wpfc-exclude-rule-content']").closest("td").show(); |
| 195 | clone_modal.find("input[name='wpfc-exclude-rule-content']").val(""); |
| 196 | |
| 197 | jQuery(this).closest("td").width(95); |
| 198 | jQuery(this).width(95); |
| 199 | } |
| 200 | }); |
| 201 | |
| 202 | |
| 203 | if(e.prefix.match(/^(homepage|category|tag|archive|post|page|attachment|googleanalytics|woocommerce_items_in_cart)$/)){ |
| 204 | clone_modal.find("input[name='wpfc-exclude-rule-content']").closest("td").hide(); |
| 205 | |
| 206 | clone_modal.find("select").closest("td").width(395); |
| 207 | clone_modal.find("select").width(395); |
| 208 | } |
| 209 | |
| 210 | clone_modal.attr("id", clone_modal_id); |
| 211 | clone_modal.find("select[name='wpfc-exclude-rule-prefix']").val(jQuery(this).attr("prefix")); |
| 212 | clone_modal.find("input[name='wpfc-exclude-rule-content']").val(jQuery(this).attr("content")); |
| 213 | clone_modal.find("input[name='wpfc-exclude-rule-type']").val(jQuery(this).attr("type")); |
| 214 | |
| 215 | |
| 216 | clone_modal.find("select[name='wpfc-exclude-rule-prefix'] option").each(function(){ |
| 217 | if(this.value == "woocommerce_items_in_cart"){ |
| 218 | if(e.type == "cookie"){ |
| 219 | return; |
| 220 | }else{ |
| 221 | jQuery(this).remove(); |
| 222 | } |
| 223 | }else{ |
| 224 | if(e.type != "page"){ |
| 225 | if(this.value != "contain"){ |
| 226 | jQuery(this).remove(); |
| 227 | |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | } |
| 232 | |
| 233 | |
| 234 | }); |
| 235 | |
| 236 | |
| 237 | if(e.type != "page"){ |
| 238 | if(e.type == "useragent"){ |
| 239 | clone_modal.find(".wpfc-condition-text").text("If User-Agent"); |
| 240 | }else if(e.type == "css"){ |
| 241 | clone_modal.find(".wpfc-condition-text").text("If CSS Url"); |
| 242 | }else if(e.type == "js"){ |
| 243 | clone_modal.find(".wpfc-condition-text").text("If JS Url"); |
| 244 | }else if(e.type == "cookie"){ |
| 245 | clone_modal.find(".wpfc-condition-text").text("If Cookie"); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | |
| 250 | |
| 251 | jQuery("#wpfc-modal-exclude").after(clone_modal); |
| 252 | |
| 253 | if(typeof e.editable == "undefined"){ |
| 254 | Wpfc_Dialog.dialog(clone_modal_id, {"close" : |
| 255 | function(){ |
| 256 | }, |
| 257 | "remove" : |
| 258 | function(){ |
| 259 | self.remove_rule(clone_modal_id, number); |
| 260 | }, |
| 261 | "finish" : |
| 262 | function(){ |
| 263 | var prefix = clone_modal.find("select[name='wpfc-exclude-rule-prefix']").val(); |
| 264 | var content = clone_modal.find("input[name='wpfc-exclude-rule-content']").val(); |
| 265 | var type = clone_modal.find("input[name='wpfc-exclude-rule-type']").val(); |
| 266 | |
| 267 | jQuery("div.wpfc-exclude-rule-line[wpfc-exclude-rule-number='" + number + "']").find("select[name='wpfc-exclude-rule-prefix-" + number + "']").val(prefix); |
| 268 | jQuery("div.wpfc-exclude-rule-line[wpfc-exclude-rule-number='" + number + "']").find("input[name='wpfc-exclude-rule-content-" + number + "']").val(content); |
| 269 | |
| 270 | if(self.is_empty_values(prefix, content)){ |
| 271 | Wpfc_Dialog.remove(clone_modal_id); |
| 272 | |
| 273 | self.save(function(){ |
| 274 | jQuery("div.wpfc-exclude-item[wpfc-exclude-item-number='" + number + "']").attr("prefix", prefix); |
| 275 | jQuery("div.wpfc-exclude-item[wpfc-exclude-item-number='" + number + "']").attr("content", content); |
| 276 | |
| 277 | jQuery("div.wpfc-exclude-item[wpfc-exclude-item-number='" + number + "']").find(".wpfc-exclude-item-url").html(self.create_url_description(prefix, content, type)); |
| 278 | |
| 279 | jQuery("div.wpfc-exclude-item[wpfc-exclude-item-number='" + number + "']").find(".wpfc-exclude-item-form-title").html(self.create_title(prefix, content)); |
| 280 | }); |
| 281 | } |
| 282 | } |
| 283 | }); |
| 284 | }else if(e.editable == false){ |
| 285 | Wpfc_Dialog.dialog(clone_modal_id, {"close" : function(){}}); |
| 286 | } |
| 287 | }); |
| 288 | |
| 289 | item.show(); |
| 290 | |
| 291 | jQuery(".wpfc-exclude-" + e.type + "-list").append(item); |
| 292 | |
| 293 | this.reorder(); |
| 294 | }, |
| 295 | create_title: function(prefix, content){ |
| 296 | var title = ""; |
| 297 | |
| 298 | if(prefix == "exact"){ |
| 299 | title = "Is Equal To: " + content; |
| 300 | }else if(prefix == "startwith"){ |
| 301 | title = "Start With: " + content; |
| 302 | }else if(prefix == "contain"){ |
| 303 | title = "Contains: " + content; |
| 304 | }else if(prefix == "homepage"){ |
| 305 | title = "Home Page"; |
| 306 | }else if(prefix == "tag"){ |
| 307 | title = "Tags"; |
| 308 | }else if(prefix == "archive"){ |
| 309 | title = "Archives"; |
| 310 | }else if(prefix == "category"){ |
| 311 | title = "Categories"; |
| 312 | }else if(prefix == "post"){ |
| 313 | title = "Posts"; |
| 314 | }else if(prefix == "page"){ |
| 315 | title = "Pages"; |
| 316 | }else if(prefix == "attachment"){ |
| 317 | title = "Attachments"; |
| 318 | }else if(prefix == "googleanalytics"){ |
| 319 | title = "Google Analytics Parameters"; |
| 320 | }else if(prefix == "woocommerce_items_in_cart"){ |
| 321 | title = "Woocommerce Items in Cart"; |
| 322 | } |
| 323 | |
| 324 | return title; |
| 325 | }, |
| 326 | create_url_description: function(prefix, content, type){ |
| 327 | var request_uri = content; |
| 328 | var b_start = "<b style='font-size:11px;color:#FFA100;'>"; |
| 329 | var b_end = "</b>" |
| 330 | |
| 331 | if(prefix == "exact"){ |
| 332 | request_uri = b_start + content + b_end; |
| 333 | }else if(prefix == "startwith"){ |
| 334 | request_uri = b_start + content + b_end + '(.*)'; |
| 335 | }else if(prefix == "contain"){ |
| 336 | request_uri = '(.*)' + b_start + content + b_end + '(.*)'; |
| 337 | }else if(prefix == "homepage"){ |
| 338 | request_uri = ""; |
| 339 | } |
| 340 | |
| 341 | if(type == "page" || type == "css" || type == "js"){ |
| 342 | if(prefix.match(/^(homepage|category|tag|archive|post|page|attachment|googleanalytics|woocommerce_items_in_cart)$/)){ |
| 343 | if(prefix == "homepage"){ |
| 344 | return "The " + b_start + "homepage" + b_end + " has been excluded"; |
| 345 | }else{ |
| 346 | return "All" + " " + b_start + this.create_title(prefix).toLowerCase() + b_end + " " + "have been excluded"; |
| 347 | } |
| 348 | }else{ |
| 349 | return "<?php echo preg_replace("/(https?\:\/\/[^\/]+).*/", "$1", site_url());?>" + "/" + request_uri; |
| 350 | } |
| 351 | }else if(type == "useragent"){ |
| 352 | return "User-Agent: " + request_uri; |
| 353 | }else if(type == "cookie"){ |
| 354 | if(content == "Admin"){ |
| 355 | return "Caching has been disabled for " + b_start + "Admin" + b_end + " users"; |
| 356 | }else{ |
| 357 | return "Cookie: " + request_uri; |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | }, |
| 362 | add_line: function(number, e){ |
| 363 | var line = jQuery(".wpfc-exclude-rule-line").first().closest(".wpfc-exclude-rule-line").clone(); |
| 364 | |
| 365 | line.attr("wpfc-exclude-rule-number", number); |
| 366 | |
| 367 | line.find(".wpfc-exclude-rule-line-add").remove(); |
| 368 | line.find(".wpfc-exclude-rule-line-delete").show(); |
| 369 | line.find("select[name^='wpfc-exclude-rule-prefix']").attr("name", "wpfc-exclude-rule-prefix-" + number).val(e.prefix); |
| 370 | line.find("input[name^='wpfc-exclude-rule-content']").attr("name", "wpfc-exclude-rule-content-" + number).val(e.content); |
| 371 | line.find("input[name^='wpfc-exclude-rule-type']").attr("name", "wpfc-exclude-rule-type-" + number).val(e.type); |
| 372 | |
| 373 | jQuery(".wpfc-exclude-rule-container").append(line); |
| 374 | }, |
| 375 | click_event_for_add_button: function(){ |
| 376 | var self = this; |
| 377 | |
| 378 | jQuery(".wpfc-add-new-exclude-button").click(function(e){ |
| 379 | var clone_modal = jQuery("#wpfc-modal-exclude").clone(); |
| 380 | //var number = jQuery("div.wpfc-exclude-rule-line[wpfc-exclude-rule-number]").length; |
| 381 | var number = new Date().getTime(); |
| 382 | var clone_modal_id = "wpfc-modal-exclude-" + new Date().getTime(); |
| 383 | var clone_modal_type = jQuery(e.currentTarget).attr("data-type"); |
| 384 | |
| 385 | clone_modal.attr("id", clone_modal_id); |
| 386 | clone_modal.find("input[name='wpfc-exclude-rule-type']").val(clone_modal_type); |
| 387 | |
| 388 | clone_modal.find("select[name='wpfc-exclude-rule-prefix'] option").each(function(){ |
| 389 | if(this.value == "woocommerce_items_in_cart"){ |
| 390 | if(clone_modal_type == "cookie"){ |
| 391 | return; |
| 392 | }else{ |
| 393 | jQuery(this).remove(); |
| 394 | } |
| 395 | }else{ |
| 396 | if(clone_modal_type != "page"){ |
| 397 | if(this.value != "contain"){ |
| 398 | jQuery(this).remove(); |
| 399 | |
| 400 | } |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | |
| 405 | }); |
| 406 | |
| 407 | if(clone_modal_type != "page"){ |
| 408 | if(clone_modal_type == "useragent"){ |
| 409 | clone_modal.find(".wpfc-condition-text").text("If User-Agent"); |
| 410 | }else if(clone_modal_type == "css"){ |
| 411 | clone_modal.find(".wpfc-condition-text").text("If CSS Url"); |
| 412 | }else if(clone_modal_type == "js"){ |
| 413 | clone_modal.find(".wpfc-condition-text").text("If JS Url"); |
| 414 | }else if(clone_modal_type == "cookie"){ |
| 415 | clone_modal.find(".wpfc-condition-text").text("If Cookie"); |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | |
| 420 | |
| 421 | |
| 422 | clone_modal.find("select").change(function(){ |
| 423 | if(jQuery(this).val().match(/^(homepage|category|tag|archive|post|page|attachment|googleanalytics|woocommerce_items_in_cart)$/)){ |
| 424 | clone_modal.find("input[name='wpfc-exclude-rule-content']").closest("td").hide(); |
| 425 | clone_modal.find("input[name='wpfc-exclude-rule-content']").val(jQuery(this).val()); |
| 426 | |
| 427 | jQuery(this).closest("td").width(395); |
| 428 | jQuery(this).width(395); |
| 429 | }else{ |
| 430 | clone_modal.find("input[name='wpfc-exclude-rule-content']").closest("td").show(); |
| 431 | clone_modal.find("input[name='wpfc-exclude-rule-content']").val(""); |
| 432 | |
| 433 | jQuery(this).closest("td").width(95); |
| 434 | jQuery(this).width(95); |
| 435 | } |
| 436 | }); |
| 437 | |
| 438 | jQuery("#wpfc-modal-exclude").after(clone_modal); |
| 439 | |
| 440 | Wpfc_Dialog.dialog(clone_modal_id, {"finish" : |
| 441 | function(){ |
| 442 | var prefix = clone_modal.find("select[name='wpfc-exclude-rule-prefix']").val(); |
| 443 | var content = clone_modal.find("input[name='wpfc-exclude-rule-content']").val(); |
| 444 | var type = clone_modal.find("input[name='wpfc-exclude-rule-type']").val(); |
| 445 | |
| 446 | content = self.remove_host_name(content); |
| 447 | |
| 448 | content = content.replace(/^\/|\/$/g, ''); |
| 449 | |
| 450 | if(self.is_empty_values(prefix, content)){ |
| 451 | self.add_line(number + 1, {"prefix" : prefix, "content" : content, "type" : type}); |
| 452 | |
| 453 | Wpfc_Dialog.remove(clone_modal_id); |
| 454 | |
| 455 | self.save(function(){ |
| 456 | self.add_item(number + 1, {"prefix" : prefix, "content" : content, "type" : type}); |
| 457 | }); |
| 458 | } |
| 459 | }, |
| 460 | "close" : |
| 461 | function(){ |
| 462 | } |
| 463 | }); |
| 464 | }); |
| 465 | }, |
| 466 | save: function(callback){ |
| 467 | var self = this, rule_number, prefix, content, rule, rules = []; |
| 468 | |
| 469 | jQuery("form div.wpfc-exclude-rule-line").each(function(i, e){ |
| 470 | rule_number = jQuery(e).attr("wpfc-exclude-rule-number"); |
| 471 | prefix = jQuery(e).find("select[name^='wpfc-exclude-rule-prefix']").val(); |
| 472 | type = jQuery(e).find("input[name^='wpfc-exclude-rule-type']").val(); |
| 473 | content = jQuery(e).find("input[name^='wpfc-exclude-rule-content']").val(); |
| 474 | |
| 475 | content = self.remove_host_name(content); |
| 476 | |
| 477 | rules.push({"prefix" : prefix, "content" : content, "type" : type}); |
| 478 | }); |
| 479 | |
| 480 | jQuery("#revert-loader-toolbar").show(); |
| 481 | |
| 482 | jQuery.ajax({ |
| 483 | type: 'POST', |
| 484 | dataType: "json", |
| 485 | url: ajaxurl, |
| 486 | data : {"action": "wpfc_save_exclude_pages", "rules" : rules, security: '<?php echo wp_create_nonce( "wpfc-save-exclude-ajax-nonce" ); ?>'}, |
| 487 | success: function(res){ |
| 488 | if(res.success){ |
| 489 | jQuery("#revert-loader-toolbar").hide(); |
| 490 | callback(); |
| 491 | self.reorder(); |
| 492 | }else{ |
| 493 | alert("The rule cannot be added..."); |
| 494 | } |
| 495 | }, |
| 496 | error: function(e) { |
| 497 | alert("unknown error"); |
| 498 | } |
| 499 | }); |
| 500 | }, |
| 501 | insert_existing_rules: function(){ |
| 502 | var self = this; |
| 503 | |
| 504 | self.add_item(new Date().getTime(), {"type" : "page", "prefix" : "exact", "content" : "wp-login.php", "editable" : false}); |
| 505 | //self.add_item(new Date().getTime(), {"prefix" : "startwith", "content" : "wp-content", "editable" : false}); |
| 506 | self.add_item(new Date().getTime(), {"type" : "page", "prefix" : "startwith", "content" : "wp-admin", "editable" : false}); |
| 507 | |
| 508 | self.add_item(new Date().getTime(), {"type" : "useragent", "prefix" : "contain", "content" : "facebookexternalhit", "editable" : false}); |
| 509 | self.add_item(new Date().getTime(), {"type" : "useragent", "prefix" : "contain", "content" : "LinkedInBot", "editable" : false}); |
| 510 | self.add_item(new Date().getTime(), {"type" : "useragent", "prefix" : "contain", "content" : "WhatsApp", "editable" : false}); |
| 511 | self.add_item(new Date().getTime(), {"type" : "useragent", "prefix" : "contain", "content" : "Twitterbot", "editable" : false}); |
| 512 | |
| 513 | self.add_item(new Date().getTime(), {"type" : "cookie", "prefix" : "contain", "content" : "Admin", "editable" : false}); |
| 514 | |
| 515 | |
| 516 | if(typeof this.rules != "undefined" && this.rules && this.rules.length > 0){ |
| 517 | jQuery.each(self.rules, function(i, e){ |
| 518 | if(i > 0){ |
| 519 | } |
| 520 | e.type = e.type ? e.type : "page"; |
| 521 | |
| 522 | self.add_line(i + 1, e); |
| 523 | self.add_item(i + 1, e); |
| 524 | }); |
| 525 | } |
| 526 | }, |
| 527 | is_empty_values: function(prefix, content){ |
| 528 | if(prefix){ |
| 529 | jQuery("#wpfc-wizard-exclude select[name='wpfc-exclude-rule-prefix']").css({'border-color': '#ddd'}); |
| 530 | }else{ |
| 531 | jQuery("#wpfc-wizard-exclude select[name='wpfc-exclude-rule-prefix']").css({'border-color': 'red'}); |
| 532 | } |
| 533 | |
| 534 | if(content){ |
| 535 | jQuery("#wpfc-wizard-exclude input[name='wpfc-exclude-rule-content']").css({'border-color': '#ddd'}); |
| 536 | }else{ |
| 537 | jQuery("#wpfc-wizard-exclude input[name='wpfc-exclude-rule-content']").css({'border-color': 'red'}); |
| 538 | } |
| 539 | |
| 540 | if(prefix && content){ |
| 541 | return true; |
| 542 | } |
| 543 | |
| 544 | return false; |
| 545 | }, |
| 546 | remove_host_name: function(content){ |
| 547 | //to replace the urls which start with http:// or www. or with Host_Name |
| 548 | content = content.replace(new RegExp('.*' + location.hostname.replace(/www\./, "") + "\/", "gi"), ""); |
| 549 | content = content.replace(/\/$/, ""); |
| 550 | |
| 551 | return content; |
| 552 | }, |
| 553 | reorder: function(type){ |
| 554 | jQuery("div.tab6 div[class^='wpfc-exclude'][class$='-list']").each(function(i,e){ |
| 555 | var type = jQuery(e).attr("class").match(/wpfc-exclude-([^-]+)-list/); |
| 556 | |
| 557 | if(typeof type[1] != "undefined"){ |
| 558 | jQuery("div.wpfc-exclude-" + type[1] + "-list div.wpfc-exclude-item").each(function(i, e){ |
| 559 | jQuery(e).removeClass("wpfc-exclude-item-right"); |
| 560 | |
| 561 | if(i%2 != 0){ |
| 562 | jQuery(e).addClass("wpfc-exclude-item-right"); |
| 563 | } |
| 564 | }); |
| 565 | } |
| 566 | }); |
| 567 | } |
| 568 | }; |
| 569 | </script> |
| 570 | |
| 571 | |
| 572 | |
| 573 |