Version Description
- Fix plugin activation error
- Fix fatal error in table nav, props to spacedmonkey
Download this release
Release Info
| Developer | johnny5 |
| Plugin | |
| Version | 2.3.8 |
| Comparing to | |
| See all releases | |
Code changes from version 2.3.6 to 2.3.8
- README.md +16 -0
- admin.css +57 -381
- ajax.php +0 -377
- js/redirection.js +189 -295
- matches/user_agent.php +1 -1
- models/database.php +3 -3
- models/file_io.php +2 -2
- models/group.php +28 -20
- models/match.php +1 -1
- models/module.php +22 -1
- models/pager.php +368 -476
- models/redirect.php +39 -10
- modules/apache.php +13 -10
- modules/wordpress.php +4 -0
- readme.txt +19 -12
- redirection.php +196 -49
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- view/admin/add.php +44 -68
- view/admin/group_edit.php +30 -28
- view/admin/group_item.php +0 -17
- view/admin/group_list.php +14 -90
- view/admin/item.php +0 -31
- view/admin/item_edit.php +27 -26
- view/admin/item_list.php +11 -98
- view/admin/log.php +2 -9
- view/admin/module_edit.php +24 -34
- view/admin/module_item.php +0 -52
- view/admin/module_list.php +4 -22
- view/admin/support.php +1 -1
README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Redirection
|
| 2 |
+
===========
|
| 3 |
+
|
| 4 |
+
Redirection is a WordPress plugin to manage 301 redirections, keep track of 404 errors, and generally tidy up any loose ends your site may have. This is particularly useful if you are migrating pages from an old website, or are changing the directory of your WordPress installation.
|
| 5 |
+
|
| 6 |
+
Installation
|
| 7 |
+
============
|
| 8 |
+
Redirection can be installed by visiting the WordPress.org plugin page:
|
| 9 |
+
|
| 10 |
+
https://wordpress.org/plugins/redirection/
|
| 11 |
+
|
| 12 |
+
Support
|
| 13 |
+
=======
|
| 14 |
+
Please raise any bug reports or enhancement requests here. Pull requests are always welcome.
|
| 15 |
+
|
| 16 |
+
You can find a more detailed description of the plugin on the [Redirection home page](http://urbangiraffe.com/plugins/redirection/)
|
admin.css
CHANGED
|
@@ -1,12 +1,3 @@
|
|
| 1 |
-
#MB_window {
|
| 2 |
-
top: 200px;
|
| 3 |
-
}
|
| 4 |
-
|
| 5 |
-
#MB_header a
|
| 6 |
-
{
|
| 7 |
-
border: none;
|
| 8 |
-
}
|
| 9 |
-
|
| 10 |
.modules
|
| 11 |
{
|
| 12 |
width: 100%;
|
|
@@ -98,377 +89,102 @@ color: black;
|
|
| 98 |
color: white;
|
| 99 |
}
|
| 100 |
|
| 101 |
-
.left
|
| 102 |
-
{
|
| 103 |
-
text-align: left;
|
| 104 |
-
}
|
| 105 |
-
|
| 106 |
-
.center
|
| 107 |
-
{
|
| 108 |
-
text-align: center;
|
| 109 |
-
}
|
| 110 |
-
|
| 111 |
-
.edit
|
| 112 |
-
{
|
| 113 |
-
width: 100%;
|
| 114 |
-
}
|
| 115 |
-
|
| 116 |
-
.edit th
|
| 117 |
-
{
|
| 118 |
-
text-align: right;
|
| 119 |
-
}
|
| 120 |
-
|
| 121 |
-
.edit .center
|
| 122 |
-
{
|
| 123 |
-
text-align: center;
|
| 124 |
-
}
|
| 125 |
-
|
| 126 |
-
.edit .left
|
| 127 |
-
{
|
| 128 |
-
text-align: left;
|
| 129 |
-
}
|
| 130 |
-
|
| 131 |
-
.redirections h3
|
| 132 |
-
{
|
| 133 |
-
padding: 0px;
|
| 134 |
-
margin: 0.5em 0 0.5em 1em;
|
| 135 |
-
font-size: 1.1em;
|
| 136 |
-
}
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
.redirections img
|
| 140 |
-
{
|
| 141 |
-
vertical-align: middle;
|
| 142 |
-
}
|
| 143 |
-
|
| 144 |
-
.redirections, .redirections_header
|
| 145 |
-
{
|
| 146 |
-
padding: 0;
|
| 147 |
-
margin: 0;
|
| 148 |
-
|
| 149 |
-
}
|
| 150 |
-
|
| 151 |
-
.redirections li a
|
| 152 |
-
{
|
| 153 |
-
border: none;
|
| 154 |
-
}
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
.redirections li { background-color: #e6e6e6; }
|
| 159 |
-
.check { border: none; background-color: transparent;}
|
| 160 |
-
.redirections .count, .redirections .type { background-color: #d4d4d4;}
|
| 161 |
-
|
| 162 |
-
.redirections .type_url { background-color: #C9F2C9; }
|
| 163 |
-
.redirections .type_url .count { background-color: #A0D8A0; }
|
| 164 |
-
.redirections .type_url .type { background-color: #A0D8A0; }
|
| 165 |
-
.redirections .type_url .tools { background-color: #A0D8A0; }
|
| 166 |
-
|
| 167 |
-
.redirections .type_error { background-color: #F3C7EC; }
|
| 168 |
-
.redirections .type_error .count{ background-color: #D18EC6; }
|
| 169 |
-
.redirections .type_error .type { background-color: #D18EC6; }
|
| 170 |
-
.redirections .type_error .tools { background-color: #D18EC6; }
|
| 171 |
-
|
| 172 |
-
.redirections .type_random { background-color: #F3EBB1; }
|
| 173 |
-
.redirections .type_random .count { background-color: #D3CB8D; }
|
| 174 |
-
.redirections .type_random .type { background-color: #D3CB8D; }
|
| 175 |
-
.redirections .type_random .tools { background-color: #D3CB8D; }
|
| 176 |
-
|
| 177 |
-
.redirections .type_pass { background-color: #AEC5E7; }
|
| 178 |
-
.redirections .type_pass .count { background-color: #7E9BC5; }
|
| 179 |
-
.redirections .type_pass .type { background-color: #7E9BC5; }
|
| 180 |
-
.redirections .type_pass .tools { background-color: #7E9BC5; }
|
| 181 |
-
|
| 182 |
-
.redirections li.disabled
|
| 183 |
-
{
|
| 184 |
-
background-color: #f2f2f2;
|
| 185 |
-
color: #999;
|
| 186 |
-
}
|
| 187 |
-
|
| 188 |
-
.redirections li.disabled .tools, .redirections li.disabled .count, .redirections li.disabled .info, .redirections li.disabled .type
|
| 189 |
-
{
|
| 190 |
-
background-color: #d4d4d4;
|
| 191 |
-
}
|
| 192 |
-
|
| 193 |
-
.redirections li.disabled a
|
| 194 |
-
{
|
| 195 |
-
color: #999;
|
| 196 |
-
}
|
| 197 |
-
|
| 198 |
-
.redirections li, .redirections_header li
|
| 199 |
-
{
|
| 200 |
-
list-style-type: none;
|
| 201 |
-
overflow: hidden;
|
| 202 |
-
}
|
| 203 |
-
|
| 204 |
-
.redirections li a
|
| 205 |
-
{
|
| 206 |
-
text-decoration: underline;
|
| 207 |
-
}
|
| 208 |
-
|
| 209 |
-
.item
|
| 210 |
-
{
|
| 211 |
-
overflow: hidden;
|
| 212 |
-
}
|
| 213 |
-
|
| 214 |
-
.item, .date, .count, .tools, .type
|
| 215 |
-
{
|
| 216 |
-
padding: 5px 8px;
|
| 217 |
-
height: 100%;
|
| 218 |
-
}
|
| 219 |
-
|
| 220 |
-
.item-regex
|
| 221 |
-
{
|
| 222 |
-
font-style: italic;
|
| 223 |
-
}
|
| 224 |
-
|
| 225 |
-
.type, .item { float: left;}
|
| 226 |
-
|
| 227 |
-
.wrap h2
|
| 228 |
-
{
|
| 229 |
-
clear: none;
|
| 230 |
-
}
|
| 231 |
-
|
| 232 |
-
.date, .count, .tools, .options
|
| 233 |
-
{
|
| 234 |
-
float: right;
|
| 235 |
-
}
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
.type { width: 3em; text-align: center; color: #333;}
|
| 239 |
-
|
| 240 |
-
.date
|
| 241 |
-
{
|
| 242 |
-
text-align: center;
|
| 243 |
-
}
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
.count
|
| 247 |
-
{
|
| 248 |
-
width: 5em;
|
| 249 |
-
text-align: center;
|
| 250 |
-
}
|
| 251 |
-
|
| 252 |
-
.sortable
|
| 253 |
-
{
|
| 254 |
-
cursor: move;
|
| 255 |
-
}
|
| 256 |
-
|
| 257 |
-
.sort
|
| 258 |
-
{
|
| 259 |
-
width: 8em;
|
| 260 |
-
text-align: center;
|
| 261 |
-
padding: 4px 2px;
|
| 262 |
-
font-size: 0.8em;
|
| 263 |
-
background-color: #ccc;
|
| 264 |
-
}
|
| 265 |
-
|
| 266 |
-
.sort a
|
| 267 |
-
{
|
| 268 |
-
color: #555;
|
| 269 |
-
border: none;
|
| 270 |
-
}
|
| 271 |
-
|
| 272 |
-
.sort a:hover
|
| 273 |
-
{
|
| 274 |
-
color: white;
|
| 275 |
-
}
|
| 276 |
-
.sort img
|
| 277 |
-
{
|
| 278 |
-
vertical-align: middle;
|
| 279 |
-
}
|
| 280 |
-
|
| 281 |
-
.type
|
| 282 |
-
{
|
| 283 |
-
margin-right: 3px;
|
| 284 |
-
}
|
| 285 |
-
|
| 286 |
-
.tools
|
| 287 |
-
{
|
| 288 |
-
height: 1.4em;
|
| 289 |
-
}
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
.pager
|
| 293 |
-
{
|
| 294 |
-
font-size: 0.9em;
|
| 295 |
-
text-align: right;
|
| 296 |
-
}
|
| 297 |
-
|
| 298 |
-
.pagertools
|
| 299 |
-
{
|
| 300 |
-
float: right;
|
| 301 |
-
font-size: 0.9em;
|
| 302 |
-
margin-left: 10px;
|
| 303 |
-
margin-bottom: 2px;
|
| 304 |
-
}
|
| 305 |
-
|
| 306 |
-
.pager select, .pager input { font-size: 0.9em; }
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
.sub
|
| 310 |
-
{
|
| 311 |
-
font-weight: normal;
|
| 312 |
-
font-size: 0.8em;
|
| 313 |
-
color: #666;
|
| 314 |
-
}
|
| 315 |
|
| 316 |
-
.
|
| 317 |
-
{
|
| 318 |
-
margin: 0; padding: 0;
|
| 319 |
list-style-type: square;
|
| 320 |
-
}
|
| 321 |
-
|
| 322 |
-
.sub ul li
|
| 323 |
-
{
|
| 324 |
-
margin: 0; padding: 0;
|
| 325 |
-
margin-left: 20px;
|
| 326 |
-
}
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
.extra
|
| 330 |
-
{
|
| 331 |
-
width: 100%;
|
| 332 |
-
}
|
| 333 |
-
|
| 334 |
-
.extra td
|
| 335 |
-
{
|
| 336 |
-
font-size: 1em;
|
| 337 |
-
}
|
| 338 |
-
|
| 339 |
-
.extra th
|
| 340 |
-
{
|
| 341 |
-
background-color: #ccc;
|
| 342 |
-
text-align: right;
|
| 343 |
-
}
|
| 344 |
-
|
| 345 |
-
.extra ul
|
| 346 |
-
{
|
| 347 |
-
margin: 0; padding: 0;
|
| 348 |
-
}
|
| 349 |
-
|
| 350 |
-
.extra ul
|
| 351 |
-
{
|
| 352 |
-
list-style-type: none;
|
| 353 |
-
}
|
| 354 |
-
|
| 355 |
-
.extra ul li ul
|
| 356 |
-
{
|
| 357 |
margin-left: 20px;
|
| 358 |
-
list-style-type: square;
|
| 359 |
}
|
| 360 |
|
| 361 |
-
.
|
| 362 |
-
{
|
| 363 |
-
width: 100%;
|
| 364 |
-
font-size: 0.9em;
|
| 365 |
-
}
|
| 366 |
-
|
| 367 |
-
.urls td
|
| 368 |
{
|
| 369 |
-
|
| 370 |
-
|
|
|
|
|
|
|
| 371 |
}
|
| 372 |
|
| 373 |
-
.
|
| 374 |
{
|
| 375 |
-
|
| 376 |
-
|
|
|
|
| 377 |
}
|
| 378 |
|
| 379 |
-
.
|
| 380 |
{
|
| 381 |
-
|
| 382 |
-
text-decoration: none !important;
|
| 383 |
}
|
| 384 |
|
| 385 |
-
.
|
| 386 |
-
|
| 387 |
-
background-color: #efefef;
|
| 388 |
}
|
| 389 |
|
| 390 |
-
.
|
| 391 |
-
|
| 392 |
-
background-color: #FDD1D1;
|
| 393 |
}
|
| 394 |
|
| 395 |
-
.
|
| 396 |
-
|
| 397 |
-
width: 100%;
|
| 398 |
}
|
| 399 |
|
| 400 |
-
.
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
.searchargs .term
|
| 404 |
-
{
|
| 405 |
-
width: 90%;
|
| 406 |
-
}
|
| 407 |
-
.results li
|
| 408 |
-
{
|
| 409 |
-
margin-bottom: 10px;
|
| 410 |
}
|
| 411 |
|
| 412 |
-
.
|
| 413 |
-
|
| 414 |
-
color: #0F3D09;
|
| 415 |
-
padding-bottom: 10px;
|
| 416 |
-
font-size: 0.9em;
|
| 417 |
}
|
| 418 |
|
| 419 |
-
.
|
| 420 |
-
|
| 421 |
-
|
| 422 |
}
|
| 423 |
|
| 424 |
-
.
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
margin-top: 10px;
|
| 428 |
-
font-size: 0.9em;
|
| 429 |
}
|
| 430 |
|
| 431 |
-
.
|
| 432 |
-
|
| 433 |
-
|
| 434 |
}
|
| 435 |
|
| 436 |
-
.
|
| 437 |
-
|
| 438 |
-
|
| 439 |
}
|
| 440 |
|
| 441 |
-
table.
|
| 442 |
-
|
| 443 |
-
|
| 444 |
}
|
| 445 |
|
| 446 |
-
table.
|
| 447 |
-
|
| 448 |
-
text-align: right;
|
| 449 |
-
padding-right: 1em;
|
| 450 |
}
|
| 451 |
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
margin-bottom: 1em;
|
| 455 |
-
padding: 0.5em 1em 1em 1em;
|
| 456 |
-
border: 1px solid #ccc;
|
| 457 |
}
|
| 458 |
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
text-align: right;
|
| 462 |
}
|
| 463 |
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 468 |
}
|
| 469 |
|
| 470 |
-
.
|
| 471 |
-
|
| 472 |
border-width: 1px;
|
| 473 |
border-style: solid;
|
| 474 |
padding: 0 0.6em;
|
|
@@ -477,52 +193,12 @@ font-size: 1.2em;
|
|
| 477 |
border-color: #e6db55;
|
| 478 |
}
|
| 479 |
|
| 480 |
-
.updated-red p{
|
| 481 |
margin: 0.5em 0;
|
| 482 |
line-height: 1;
|
| 483 |
padding: 2px;
|
| 484 |
}
|
| 485 |
|
| 486 |
-
.
|
| 487 |
-
|
| 488 |
-
text-align: center;
|
| 489 |
}
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
.bulleted li {
|
| 493 |
-
list-style-type: square;
|
| 494 |
-
margin-left: 20px;
|
| 495 |
-
}
|
| 496 |
-
|
| 497 |
-
.donations li
|
| 498 |
-
{
|
| 499 |
-
list-style-type: none;
|
| 500 |
-
float: left;
|
| 501 |
-
text-align: center;
|
| 502 |
-
padding: 1em 2em;
|
| 503 |
-
}
|
| 504 |
-
|
| 505 |
-
.translators li
|
| 506 |
-
{
|
| 507 |
-
float: left;
|
| 508 |
-
width: 300px;
|
| 509 |
-
margin-left: 1.5em;
|
| 510 |
-
}
|
| 511 |
-
|
| 512 |
-
div .supporter strong
|
| 513 |
-
{
|
| 514 |
-
background-color: yellow;
|
| 515 |
-
}
|
| 516 |
-
|
| 517 |
-
#items, .item {
|
| 518 |
-
direction:ltr;
|
| 519 |
-
}
|
| 520 |
-
|
| 521 |
-
.wp-list-table .column-created {
|
| 522 |
-
width: 150px;
|
| 523 |
-
}
|
| 524 |
-
|
| 525 |
-
.wp-list-table .column-ip {
|
| 526 |
-
width: 120px;
|
| 527 |
-
}
|
| 528 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
.modules
|
| 2 |
{
|
| 3 |
width: 100%;
|
| 89 |
color: white;
|
| 90 |
}
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
+
.bulleted li {
|
|
|
|
|
|
|
| 94 |
list-style-type: square;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
margin-left: 20px;
|
|
|
|
| 96 |
}
|
| 97 |
|
| 98 |
+
.donations li
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
{
|
| 100 |
+
list-style-type: none;
|
| 101 |
+
float: left;
|
| 102 |
+
text-align: center;
|
| 103 |
+
padding: 1em 2em;
|
| 104 |
}
|
| 105 |
|
| 106 |
+
.translators li
|
| 107 |
{
|
| 108 |
+
float: left;
|
| 109 |
+
width: 300px;
|
| 110 |
+
margin-left: 1.5em;
|
| 111 |
}
|
| 112 |
|
| 113 |
+
div .supporter strong
|
| 114 |
{
|
| 115 |
+
background-color: yellow;
|
|
|
|
| 116 |
}
|
| 117 |
|
| 118 |
+
#items, .item {
|
| 119 |
+
direction:ltr;
|
|
|
|
| 120 |
}
|
| 121 |
|
| 122 |
+
.wp-list-table .column-moduletype {
|
| 123 |
+
width: 100px;
|
|
|
|
| 124 |
}
|
| 125 |
|
| 126 |
+
.wp-list-table .column-groups {
|
| 127 |
+
width: 50px;
|
|
|
|
| 128 |
}
|
| 129 |
|
| 130 |
+
.wp-list-table .column-created {
|
| 131 |
+
width: 150px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
}
|
| 133 |
|
| 134 |
+
.wp-list-table .column-ip {
|
| 135 |
+
width: 120px;
|
|
|
|
|
|
|
|
|
|
| 136 |
}
|
| 137 |
|
| 138 |
+
.wp-list-table .column-type {
|
| 139 |
+
width: 50px;
|
| 140 |
+
text-align: left;
|
| 141 |
}
|
| 142 |
|
| 143 |
+
.wp-list-table .column-hits {
|
| 144 |
+
width: 50px;
|
| 145 |
+
text-align: left;
|
|
|
|
|
|
|
| 146 |
}
|
| 147 |
|
| 148 |
+
.wp-list-table .column-redirects {
|
| 149 |
+
width: 100px;
|
| 150 |
+
text-align: left;
|
| 151 |
}
|
| 152 |
|
| 153 |
+
.wp-list-table .column-last_access {
|
| 154 |
+
width: 100px;
|
| 155 |
+
text-align: left;
|
| 156 |
}
|
| 157 |
|
| 158 |
+
table.edit.loading .table-loading .spinner {
|
| 159 |
+
float: left;
|
| 160 |
+
display: block;
|
| 161 |
}
|
| 162 |
|
| 163 |
+
table.edit.loading .table-actions {
|
| 164 |
+
display: none;
|
|
|
|
|
|
|
| 165 |
}
|
| 166 |
|
| 167 |
+
table.items .red-disabled {
|
| 168 |
+
text-decoration: line-through;
|
|
|
|
|
|
|
|
|
|
| 169 |
}
|
| 170 |
|
| 171 |
+
.red-added {
|
| 172 |
+
display: none;
|
|
|
|
| 173 |
}
|
| 174 |
|
| 175 |
+
.red-error {
|
| 176 |
+
display: none;
|
| 177 |
+
border-width: 1px;
|
| 178 |
+
border-style: solid;
|
| 179 |
+
padding: 1em 1em;
|
| 180 |
+
margin: 10px 0px;
|
| 181 |
+
background-color: #F55B7C;
|
| 182 |
+
border-color: red;
|
| 183 |
+
color: white;
|
| 184 |
}
|
| 185 |
|
| 186 |
+
.loaded .red-added {
|
| 187 |
+
display: block;
|
| 188 |
border-width: 1px;
|
| 189 |
border-style: solid;
|
| 190 |
padding: 0 0.6em;
|
| 193 |
border-color: #e6db55;
|
| 194 |
}
|
| 195 |
|
| 196 |
+
.loading .updated-red p {
|
| 197 |
margin: 0.5em 0;
|
| 198 |
line-height: 1;
|
| 199 |
padding: 2px;
|
| 200 |
}
|
| 201 |
|
| 202 |
+
.loaded-error .red-error {
|
| 203 |
+
display: block;
|
|
|
|
| 204 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ajax.php
DELETED
|
@@ -1,377 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* Redirection
|
| 4 |
-
*
|
| 5 |
-
* @package Redirection
|
| 6 |
-
* @author John Godley
|
| 7 |
-
* @copyright Copyright (C) John Godley
|
| 8 |
-
**/
|
| 9 |
-
|
| 10 |
-
/*
|
| 11 |
-
============================================================================================================
|
| 12 |
-
This software is provided "as is" and any express or implied warranties, including, but not limited to, the
|
| 13 |
-
implied warranties of merchantibility and fitness for a particular purpose are disclaimed. In no event shall
|
| 14 |
-
the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or
|
| 15 |
-
consequential damages (including, but not limited to, procurement of substitute goods or services; loss of
|
| 16 |
-
use, data, or profits; or business interruption) however caused and on any theory of liability, whether in
|
| 17 |
-
contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of
|
| 18 |
-
this software, even if advised of the possibility of such damage.
|
| 19 |
-
|
| 20 |
-
For full license details see license.txt
|
| 21 |
-
============================================================================================================ */
|
| 22 |
-
|
| 23 |
-
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
|
| 24 |
-
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
|
| 25 |
-
|
| 26 |
-
class RedirectionAjax extends Redirection_Plugin {
|
| 27 |
-
var $post;
|
| 28 |
-
|
| 29 |
-
function RedirectionAjax() {
|
| 30 |
-
$this->register_plugin( 'redirection', __FILE__ );
|
| 31 |
-
|
| 32 |
-
add_action( 'init', array( &$this, 'init' ) );
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
function init() {
|
| 36 |
-
if ( current_user_can( 'administrator' ) ) {
|
| 37 |
-
$this->post = stripslashes_deep( $_POST );
|
| 38 |
-
|
| 39 |
-
$this->register_ajax( 'red_log_show' );
|
| 40 |
-
$this->register_ajax( 'red_log_hide' );
|
| 41 |
-
$this->register_ajax( 'red_log_delete' );
|
| 42 |
-
|
| 43 |
-
$this->register_ajax( 'red_module_edit' );
|
| 44 |
-
$this->register_ajax( 'red_module_load' );
|
| 45 |
-
$this->register_ajax( 'red_module_save' );
|
| 46 |
-
$this->register_ajax( 'red_module_reset' );
|
| 47 |
-
$this->register_ajax( 'red_module_delete' );
|
| 48 |
-
|
| 49 |
-
$this->register_ajax( 'red_group_edit' );
|
| 50 |
-
$this->register_ajax( 'red_group_load' );
|
| 51 |
-
$this->register_ajax( 'red_group_save' );
|
| 52 |
-
$this->register_ajax( 'red_group_toggle' );
|
| 53 |
-
$this->register_ajax( 'red_group_delete' );
|
| 54 |
-
$this->register_ajax( 'red_group_reset' );
|
| 55 |
-
$this->register_ajax( 'red_group_move' );
|
| 56 |
-
$this->register_ajax( 'red_group_saveorder' );
|
| 57 |
-
|
| 58 |
-
$this->register_ajax( 'red_redirect_edit' );
|
| 59 |
-
$this->register_ajax( 'red_redirect_load' );
|
| 60 |
-
$this->register_ajax( 'red_redirect_save' );
|
| 61 |
-
$this->register_ajax( 'red_redirect_toggle' );
|
| 62 |
-
$this->register_ajax( 'red_redirect_delete' );
|
| 63 |
-
$this->register_ajax( 'red_redirect_reset' );
|
| 64 |
-
$this->register_ajax( 'red_redirect_move' );
|
| 65 |
-
$this->register_ajax( 'red_redirect_saveorder' );
|
| 66 |
-
$this->register_ajax( 'red_redirect_add' );
|
| 67 |
-
}
|
| 68 |
-
}
|
| 69 |
-
|
| 70 |
-
function red_log_show() {
|
| 71 |
-
$id = intval( $_GET['id'] );
|
| 72 |
-
|
| 73 |
-
if ( check_ajax_referer( 'redirection-log_'.$id ) ) {
|
| 74 |
-
$log = RE_Log::get_by_id( $id );
|
| 75 |
-
$redirect = Red_Item::get_by_id( $log->redirection_id );
|
| 76 |
-
|
| 77 |
-
$this->render_admin( 'log_item_details', array( 'log' => $log, 'redirect' => $redirect ) );
|
| 78 |
-
die();
|
| 79 |
-
}
|
| 80 |
-
}
|
| 81 |
-
|
| 82 |
-
function red_log_hide() {
|
| 83 |
-
$id = intval( $_GET['id'] );
|
| 84 |
-
|
| 85 |
-
if ( check_ajax_referer( 'redirection-log_'.$id ) ) {
|
| 86 |
-
$log = RE_Log::get_by_id( $id );
|
| 87 |
-
|
| 88 |
-
echo '<a class="details" href="'.$log->url.'">'.$log->show_url ($log->url).'</a>';
|
| 89 |
-
die();
|
| 90 |
-
}
|
| 91 |
-
}
|
| 92 |
-
|
| 93 |
-
function red_log_delete() {
|
| 94 |
-
if ( check_ajax_referer( 'redirection-items' ) ) {
|
| 95 |
-
if ( preg_match_all( '/=(\d*)/', $this->post['checked'], $items ) > 0) {
|
| 96 |
-
foreach ( $items[1] AS $item ) {
|
| 97 |
-
RE_Log::delete( intval( $item ) );
|
| 98 |
-
}
|
| 99 |
-
}
|
| 100 |
-
}
|
| 101 |
-
}
|
| 102 |
-
|
| 103 |
-
function red_module_edit() {
|
| 104 |
-
$id = intval( $_GET['id'] );
|
| 105 |
-
|
| 106 |
-
if ( check_ajax_referer( 'redirection-module_'.$id ) ) {
|
| 107 |
-
$module = Red_Module::get( $id );
|
| 108 |
-
|
| 109 |
-
if ( $module )
|
| 110 |
-
$this->render_admin( 'module_edit', array( 'module' => $module ) );
|
| 111 |
-
|
| 112 |
-
die();
|
| 113 |
-
}
|
| 114 |
-
}
|
| 115 |
-
|
| 116 |
-
function red_module_load() {
|
| 117 |
-
$id = intval( $_GET['id'] );
|
| 118 |
-
|
| 119 |
-
if ( check_ajax_referer( 'redirection-module_'.$id ) ) {
|
| 120 |
-
$module = Red_Module::get ($id);
|
| 121 |
-
if ($module) {
|
| 122 |
-
global $redirection;
|
| 123 |
-
$options = $redirection->get_options();
|
| 124 |
-
|
| 125 |
-
$this->render_admin( 'module_item', array( 'module' => $module, 'token' => $options['token'] ) );
|
| 126 |
-
}
|
| 127 |
-
|
| 128 |
-
die();
|
| 129 |
-
}
|
| 130 |
-
}
|
| 131 |
-
|
| 132 |
-
function red_module_save() {
|
| 133 |
-
$id = intval( $this->post['id'] );
|
| 134 |
-
|
| 135 |
-
if ( check_ajax_referer( 'redirection-module_save_'.$id ) ) {
|
| 136 |
-
$module = Red_Module::get( $id );
|
| 137 |
-
if ( $module ) {
|
| 138 |
-
global $redirection;
|
| 139 |
-
$options = $redirection->get_options();
|
| 140 |
-
$module->update( $this->post );
|
| 141 |
-
|
| 142 |
-
$this->render_admin( 'module_item', array( 'module' => $module, 'token' => $options['token'] ) );
|
| 143 |
-
die();
|
| 144 |
-
}
|
| 145 |
-
}
|
| 146 |
-
}
|
| 147 |
-
|
| 148 |
-
function red_module_reset() {
|
| 149 |
-
$id = intval( $_GET['id'] );
|
| 150 |
-
|
| 151 |
-
if ( check_ajax_referer( 'redirection-module_'.$id ) ) {
|
| 152 |
-
$module = Red_Module::get( $id );
|
| 153 |
-
|
| 154 |
-
if ( $module ) {
|
| 155 |
-
global $redirection;
|
| 156 |
-
$options = $redirection->get_options();
|
| 157 |
-
|
| 158 |
-
$module->reset ();
|
| 159 |
-
$this->render_admin( 'module_item', array( 'module' => $module, 'token' => $options['token'] ) );
|
| 160 |
-
}
|
| 161 |
-
|
| 162 |
-
die();
|
| 163 |
-
}
|
| 164 |
-
}
|
| 165 |
-
|
| 166 |
-
function red_module_delete() {
|
| 167 |
-
$id = intval( $_GET['id'] );
|
| 168 |
-
if ( check_ajax_referer( 'redirection-module_'.$id ) ) {
|
| 169 |
-
$module = Red_Module::get( $id );
|
| 170 |
-
$module->delete();
|
| 171 |
-
}
|
| 172 |
-
}
|
| 173 |
-
|
| 174 |
-
function red_group_edit() {
|
| 175 |
-
$id = intval( $_GET['id'] );
|
| 176 |
-
|
| 177 |
-
if ( check_ajax_referer( 'redirection-group_'.$id ) ) {
|
| 178 |
-
$group = Red_Group::get( $id );
|
| 179 |
-
if ( $group )
|
| 180 |
-
$this->render_admin( 'group_edit', array( 'group' => $group, 'modules' => Red_Module::get_for_select() ) );
|
| 181 |
-
|
| 182 |
-
die();
|
| 183 |
-
}
|
| 184 |
-
}
|
| 185 |
-
|
| 186 |
-
function red_group_load() {
|
| 187 |
-
$id = intval( $_GET['id'] );
|
| 188 |
-
|
| 189 |
-
if ( check_ajax_referer( 'redirection-group_'.$id ) ) {
|
| 190 |
-
$group = Red_Group::get( $id );
|
| 191 |
-
if ( $group )
|
| 192 |
-
$this->render_admin( 'group_item', array( 'group' => $group ) );
|
| 193 |
-
die();
|
| 194 |
-
}
|
| 195 |
-
}
|
| 196 |
-
|
| 197 |
-
function red_group_save() {
|
| 198 |
-
$id = intval( $this->post['id'] );
|
| 199 |
-
|
| 200 |
-
if ( check_ajax_referer( 'redirection-group_save_'.$id ) ) {
|
| 201 |
-
$group = Red_Group::get( $id );
|
| 202 |
-
if ( $group ) {
|
| 203 |
-
$original_module = $group->module_id;
|
| 204 |
-
$group->update( $this->post );
|
| 205 |
-
|
| 206 |
-
$this->render_admin( 'group_item', array( 'group' => $group ) );
|
| 207 |
-
}
|
| 208 |
-
|
| 209 |
-
die();
|
| 210 |
-
}
|
| 211 |
-
}
|
| 212 |
-
|
| 213 |
-
function red_group_toggle() {
|
| 214 |
-
if ( check_ajax_referer( 'redirection-items' ) ) {
|
| 215 |
-
if ( preg_match_all( '/=(\d*)/', $this->post['checked'], $items ) > 0) {
|
| 216 |
-
foreach ( $items[1] AS $group ) {
|
| 217 |
-
$group = Red_Group::get( $group );
|
| 218 |
-
$group->toggle_status();
|
| 219 |
-
}
|
| 220 |
-
|
| 221 |
-
Red_Module::flush( $group->module_id );
|
| 222 |
-
}
|
| 223 |
-
}
|
| 224 |
-
}
|
| 225 |
-
|
| 226 |
-
function red_group_delete() {
|
| 227 |
-
if ( check_ajax_referer( 'redirection-items' ) ) {
|
| 228 |
-
if ( preg_match_all( '/=(\d*)/', $this->post['checked'], $items ) > 0) {
|
| 229 |
-
foreach ( $items[1] AS $group ) {
|
| 230 |
-
Red_Group::delete( intval( $group ) );
|
| 231 |
-
}
|
| 232 |
-
}
|
| 233 |
-
}
|
| 234 |
-
}
|
| 235 |
-
|
| 236 |
-
function red_group_reset() {
|
| 237 |
-
if ( check_ajax_referer( 'redirection-items' ) ) {
|
| 238 |
-
if ( preg_match_all( '/=(\d*)/', $this->post['checked'], $items ) > 0) {
|
| 239 |
-
foreach ( $items[1] AS $group ) {
|
| 240 |
-
$redirect = Red_Group::get( intval( $group ) );
|
| 241 |
-
$redirect->reset();
|
| 242 |
-
}
|
| 243 |
-
}
|
| 244 |
-
}
|
| 245 |
-
}
|
| 246 |
-
|
| 247 |
-
function red_group_move() {
|
| 248 |
-
if ( check_ajax_referer( 'redirection-items' ) ) {
|
| 249 |
-
$target = intval( $this->post['target'] );
|
| 250 |
-
|
| 251 |
-
if ( preg_match_all( '/=(\d*)/', $this->post['checked'], $items ) > 0) {
|
| 252 |
-
foreach ( $items[1] AS $group ) {
|
| 253 |
-
$redirect = Red_Group::get( $group );
|
| 254 |
-
$redirect->move_to( $target );
|
| 255 |
-
}
|
| 256 |
-
}
|
| 257 |
-
}
|
| 258 |
-
}
|
| 259 |
-
|
| 260 |
-
function red_group_saveorder() {
|
| 261 |
-
if ( check_ajax_referer( 'redirection-items' ) ) {
|
| 262 |
-
if ( preg_match_all( '/=(\d*)/', $this->post['items'], $items ) > 0) {
|
| 263 |
-
Red_Group::save_order( $items[1], intval( $this->post['page'] ) );
|
| 264 |
-
}
|
| 265 |
-
}
|
| 266 |
-
}
|
| 267 |
-
|
| 268 |
-
function red_redirect_edit() {
|
| 269 |
-
if ( check_ajax_referer( 'redirection-items' ) ) {
|
| 270 |
-
$redirect = Red_Item::get_by_id( intval( $_GET['id'] ) );
|
| 271 |
-
if ( $redirect )
|
| 272 |
-
$this->render_admin( 'item_edit', array( 'redirect' => $redirect, 'groups' => Red_Group::get_for_select() ) );
|
| 273 |
-
|
| 274 |
-
die();
|
| 275 |
-
}
|
| 276 |
-
}
|
| 277 |
-
|
| 278 |
-
function red_redirect_load() {
|
| 279 |
-
if ( check_ajax_referer( 'redirection-items' ) ) {
|
| 280 |
-
$redirect = Red_Item::get_by_id( intval( $_GET['id'] ) );
|
| 281 |
-
if ( $redirect )
|
| 282 |
-
$this->render_admin( 'item', array( 'redirect' => $redirect, 'date_format' => get_option( 'date_format' ) ) );
|
| 283 |
-
|
| 284 |
-
die();
|
| 285 |
-
}
|
| 286 |
-
}
|
| 287 |
-
|
| 288 |
-
function red_redirect_save() {
|
| 289 |
-
$id = intval( $this->post['id'] );
|
| 290 |
-
|
| 291 |
-
if ( check_ajax_referer( 'redirection-redirect_save_'.$id ) ) {
|
| 292 |
-
$redirect = Red_Item::get_by_id( $id );
|
| 293 |
-
$redirect->update( $this->post );
|
| 294 |
-
|
| 295 |
-
$this->render_admin( 'item', array( 'redirect' => $redirect, 'date_format' => get_option( 'date_format' ) ) );
|
| 296 |
-
die();
|
| 297 |
-
}
|
| 298 |
-
}
|
| 299 |
-
|
| 300 |
-
function red_redirect_toggle() {
|
| 301 |
-
if ( check_ajax_referer( 'redirection-items' ) ) {
|
| 302 |
-
if ( preg_match_all( '/=(\d*)/', $this->post['checked'], $items ) > 0) {
|
| 303 |
-
foreach ( $items[1] AS $item ) {
|
| 304 |
-
$redirect = Red_Item::get_by_id( $item );
|
| 305 |
-
$redirect->toggle_status();
|
| 306 |
-
}
|
| 307 |
-
}
|
| 308 |
-
|
| 309 |
-
$group = Red_Group::get( $redirect->group_id );
|
| 310 |
-
Red_Module::flush( $group->module_id );
|
| 311 |
-
}
|
| 312 |
-
}
|
| 313 |
-
|
| 314 |
-
function red_redirect_delete() {
|
| 315 |
-
if ( check_ajax_referer( 'redirection-items' ) ) {
|
| 316 |
-
if ( preg_match_all( '/=(\d*)/', $this->post['checked'], $items ) > 0) {
|
| 317 |
-
$redirect = Red_Item::get_by_id( $items[0]);
|
| 318 |
-
|
| 319 |
-
foreach ( $items[1] AS $item ) {
|
| 320 |
-
Red_Item::delete( intval( $item ) );
|
| 321 |
-
}
|
| 322 |
-
|
| 323 |
-
$group = Red_Group::get( $redirect->group_id );
|
| 324 |
-
Red_Module::flush( $group->module_id );
|
| 325 |
-
}
|
| 326 |
-
}
|
| 327 |
-
}
|
| 328 |
-
|
| 329 |
-
function red_redirect_reset() {
|
| 330 |
-
if ( check_ajax_referer( 'redirection-items' ) ) {
|
| 331 |
-
if ( preg_match_all( '/=(\d*)/', $this->post['checked'], $items ) > 0) {
|
| 332 |
-
foreach ( $items[1] AS $item ) {
|
| 333 |
-
$redirect = Red_Item::get_by_id( intval( $item ) );
|
| 334 |
-
$redirect->reset();
|
| 335 |
-
}
|
| 336 |
-
}
|
| 337 |
-
}
|
| 338 |
-
}
|
| 339 |
-
|
| 340 |
-
function red_redirect_move() {
|
| 341 |
-
if ( check_ajax_referer( 'redirection-items' ) ) {
|
| 342 |
-
$target = intval( $this->post['target'] );
|
| 343 |
-
|
| 344 |
-
if ( preg_match_all( '/=(\d*)/', $this->post['checked'], $items ) > 0) {
|
| 345 |
-
foreach ( $items[1] AS $item ) {
|
| 346 |
-
$redirect = Red_Item::get_by_id( $item );
|
| 347 |
-
$redirect->move_to( $target );
|
| 348 |
-
}
|
| 349 |
-
}
|
| 350 |
-
}
|
| 351 |
-
}
|
| 352 |
-
|
| 353 |
-
function red_redirect_saveorder() {
|
| 354 |
-
if ( check_ajax_referer( 'redirection-items' ) ) {
|
| 355 |
-
if ( preg_match_all( '/=(\d*)/', $this->post['items'], $items ) > 0) {
|
| 356 |
-
Red_Item::save_order( $items[1], intval( $this->post['page'] ) );
|
| 357 |
-
}
|
| 358 |
-
}
|
| 359 |
-
}
|
| 360 |
-
|
| 361 |
-
function red_redirect_add() {
|
| 362 |
-
if ( check_ajax_referer( 'redirection-redirect_add' ) ) {
|
| 363 |
-
$item = Red_Item::create( $this->post );
|
| 364 |
-
if ( is_wp_error( $item ) )
|
| 365 |
-
$this->render_error( $item->get_error_message() );
|
| 366 |
-
elseif ( $item !== false ) {
|
| 367 |
-
echo '<li class="type_'.$item->action_type.'" id="item_'.$item->id.'">';
|
| 368 |
-
$this->render_admin( 'item', array( 'redirect' => $item, 'date_format' => get_option( 'date_format' ) ) );
|
| 369 |
-
echo '</li>';
|
| 370 |
-
}
|
| 371 |
-
else
|
| 372 |
-
$this->render_error( __( 'Sorry, but your redirection was not created', 'redirection' ) );
|
| 373 |
-
|
| 374 |
-
die();
|
| 375 |
-
}
|
| 376 |
-
}
|
| 377 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/redirection.js
CHANGED
|
@@ -1,298 +1,192 @@
|
|
| 1 |
var Redirection;
|
| 2 |
|
| 3 |
(function($) {
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
});
|
| 194 |
-
|
| 195 |
-
return false;
|
| 196 |
-
});
|
| 197 |
-
|
| 198 |
-
// Delete links
|
| 199 |
-
$( 'a.rdelete' ).unbind( 'click' ).click( function() {
|
| 200 |
-
var item = $( this ).parents( 'tr' )
|
| 201 |
-
|
| 202 |
-
$( item ).find( '.operations a' ).hide();
|
| 203 |
-
$( item ).find( '.loader' ).show();
|
| 204 |
-
$.get( this.href, function() {
|
| 205 |
-
$( item ).fadeOut();
|
| 206 |
-
});
|
| 207 |
-
|
| 208 |
-
return false;
|
| 209 |
-
});
|
| 210 |
-
}
|
| 211 |
-
|
| 212 |
-
function edit_items( type ) {
|
| 213 |
-
$( 'a.redirection-edit' ).unbind( 'click' ).click(function() { return form_loader( this, 'li', edit_items ) } );
|
| 214 |
-
|
| 215 |
-
$( 'a.select-all' ).unbind( 'click' ).click(function() { return select_all(); } );
|
| 216 |
-
$( 'a.toggle-all' ).unbind( 'click' ).click(function() { return do_items( type, 'toggle' ); });
|
| 217 |
-
$( 'a.reset-all' ).unbind( 'click' ).click(function() { return do_items( type, 'reset' ); });
|
| 218 |
-
$( 'a.delete-all' ).unbind( 'click' ).click(function() { return delete_all( type ); });
|
| 219 |
-
$( 'input.move-all' ).unbind( 'click' ).click(function() { return move_all( type ); });
|
| 220 |
-
|
| 221 |
-
$( 'a.sort-on' ).unbind( 'click' ).click(function() { return sort_order(); });
|
| 222 |
-
$( 'a.sort-save' ).unbind( 'click' ).click(function() { return sort_order_save( type ); });
|
| 223 |
-
}
|
| 224 |
-
|
| 225 |
-
function logs() {
|
| 226 |
-
$( '.show-log' ).unbind( 'click' ).click( function() {
|
| 227 |
-
var item = $( this ).parents( 'tr' )
|
| 228 |
-
var href = this.href;
|
| 229 |
-
|
| 230 |
-
// Set loading icon
|
| 231 |
-
$( item ).find( '.info' ).html( opts.progress );
|
| 232 |
-
|
| 233 |
-
// Load info
|
| 234 |
-
$( item ).find( '.info' ).load( this.href, function() {
|
| 235 |
-
// Setup cancel handler
|
| 236 |
-
$( item ).find( '.info input[name=cancel]').click( function() {
|
| 237 |
-
$( item ).find( '.info' ).load( href.replace( 'red_log_show', 'red_log_hide' ), function () {
|
| 238 |
-
logs();
|
| 239 |
-
});
|
| 240 |
-
|
| 241 |
-
return false;
|
| 242 |
-
});
|
| 243 |
-
} );
|
| 244 |
-
|
| 245 |
-
return false;
|
| 246 |
-
});
|
| 247 |
-
|
| 248 |
-
$( '#actionator' ).unbind( 'click' ).click( function() {
|
| 249 |
-
if ( $( '#action2_select' ).val() == 'delete' )
|
| 250 |
-
delete_all( 'log' );
|
| 251 |
-
return false;
|
| 252 |
-
});
|
| 253 |
-
|
| 254 |
-
$( '.add-log' ).unbind( 'click' ).click( function( item ) {
|
| 255 |
-
$( '#added' ).hide ();
|
| 256 |
-
$( '#add' ).show ();
|
| 257 |
-
|
| 258 |
-
// Copy details
|
| 259 |
-
$( '#old' ).val( $( this ).attr( 'href' ) );
|
| 260 |
-
return false;
|
| 261 |
-
});
|
| 262 |
-
|
| 263 |
-
$( '#cb input' ).unbind( 'click' ).click( function() {
|
| 264 |
-
var checked = $( this ).attr( 'checked' );
|
| 265 |
-
|
| 266 |
-
$( 'input.check' ).each( function( pos, item ) {
|
| 267 |
-
$( item ).attr( 'checked', checked );
|
| 268 |
-
});
|
| 269 |
-
});
|
| 270 |
-
}
|
| 271 |
-
|
| 272 |
-
var api = {
|
| 273 |
-
logs: logs,
|
| 274 |
-
edit_items: edit_items,
|
| 275 |
-
modules: modules
|
| 276 |
-
};
|
| 277 |
-
|
| 278 |
-
return api;
|
| 279 |
-
}
|
| 280 |
-
|
| 281 |
-
$( document ).ready( function() {
|
| 282 |
-
$( '#support-annoy' ).animate( { opacity: 0.2, backgroundColor: 'red' } ).animate( { opacity: 1, backgroundColor: 'yellow' } );
|
| 283 |
-
} );
|
| 284 |
-
|
| 285 |
-
})(jQuery);
|
| 286 |
-
|
| 287 |
-
function update_user_agent (item,box)
|
| 288 |
-
{
|
| 289 |
-
jQuery('#user_agent_' + box).attr ('value', jQuery(item).attr ('value'));
|
| 290 |
-
}
|
| 291 |
-
|
| 292 |
-
function change_add_redirect (item)
|
| 293 |
-
{
|
| 294 |
-
if (item.value == 'url' || item.value == 'pass')
|
| 295 |
-
jQuery('#target').show ();
|
| 296 |
-
else
|
| 297 |
-
jQuery('#target').hide ();
|
| 298 |
-
}
|
| 1 |
var Redirection;
|
| 2 |
|
| 3 |
(function($) {
|
| 4 |
+
Redirection_Items = function() {
|
| 5 |
+
function edit_items() {
|
| 6 |
+
$( 'table.items' ).on( 'click', '.row-actions a.red-auto', function( ev ) {
|
| 7 |
+
ev.preventDefault();
|
| 8 |
+
|
| 9 |
+
$( this ).closest( 'tr' ).find( 'input[type=checkbox]' ).prop( 'checked', true );
|
| 10 |
+
$( 'select[name=action]' ).find( 'option[value=' + $( this ).data( 'action' ) + ']' ).prop( 'selected', true );
|
| 11 |
+
$( '#doaction' ).click();
|
| 12 |
+
} );
|
| 13 |
+
|
| 14 |
+
$( 'table.items' ).on( 'click', '.row-actions a.red-ajax', function( ev ) {
|
| 15 |
+
var action = $( this ).data( 'action' );
|
| 16 |
+
var container = $( this ).closest( 'td' );
|
| 17 |
+
|
| 18 |
+
ev.preventDefault();
|
| 19 |
+
|
| 20 |
+
container.data( 'cancel', container.html() );
|
| 21 |
+
|
| 22 |
+
show_loading( container.find( '.row-actions' ) );
|
| 23 |
+
|
| 24 |
+
$.post( ajaxurl, {
|
| 25 |
+
action: $( this ).data( 'action' ),
|
| 26 |
+
nonce: $( this ).data( 'nonce' ),
|
| 27 |
+
id: $( this ).data( 'id' )
|
| 28 |
+
}, function( response ) {
|
| 29 |
+
if ( show_error( response ) )
|
| 30 |
+
return;
|
| 31 |
+
|
| 32 |
+
container.html( response.html );
|
| 33 |
+
connect_redirect_edit( container );
|
| 34 |
+
}, 'json' );
|
| 35 |
+
} );
|
| 36 |
+
|
| 37 |
+
$( document ).on( 'change', 'select.change-user-agent', function( ev ) {
|
| 38 |
+
$( this ).closest( 'td' ).find( 'input[type=text]' ).val( $( this ).val() );
|
| 39 |
+
} );
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
function show_loading( container ) {
|
| 43 |
+
container.replaceWith( '<div class="spinner" style="display: block"></div>' );
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
function show_error( response ) {
|
| 47 |
+
if (response == 0 || response == -1) {
|
| 48 |
+
alert( Redirectioni10n.error_msg );
|
| 49 |
+
return true;
|
| 50 |
+
}
|
| 51 |
+
else if (response.error) {
|
| 52 |
+
alert( response.error );
|
| 53 |
+
return true;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
return false;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
function connect_redirect_edit( container ) {
|
| 60 |
+
container.find( 'input[name=save]' ).on( 'click', function( ev ) {
|
| 61 |
+
var form = $( this ).closest( 'table.edit' );
|
| 62 |
+
|
| 63 |
+
ev.preventDefault();
|
| 64 |
+
|
| 65 |
+
form.addClass( 'loading' );
|
| 66 |
+
|
| 67 |
+
$.post( form.data( 'url' ), form.find( 'input, select' ).serialize(), function( response ) {
|
| 68 |
+
if ( show_error( response ) )
|
| 69 |
+
return;
|
| 70 |
+
|
| 71 |
+
container.html( response.html );
|
| 72 |
+
|
| 73 |
+
if ( response.code )
|
| 74 |
+
container.closest( 'tr' ).find( '.column-type' ).html( response.code );
|
| 75 |
+
}, 'json' );
|
| 76 |
+
} );
|
| 77 |
+
|
| 78 |
+
container.find( 'input[name=cancel]' ).on( 'click', function( ev ) {
|
| 79 |
+
ev.preventDefault();
|
| 80 |
+
|
| 81 |
+
container.html( container.data( 'cancel' ) );
|
| 82 |
+
container.data( 'cancel', null );
|
| 83 |
+
} );
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
edit_items();
|
| 87 |
+
};
|
| 88 |
+
|
| 89 |
+
Redirection_Modules = function() {
|
| 90 |
+
function modules() {
|
| 91 |
+
// Edit module
|
| 92 |
+
$( 'a.edit' ).unbind( 'click' ).click( function( ev ) {
|
| 93 |
+
var container = $( this ).closest( 'tr' );
|
| 94 |
+
ev.preventDefault();
|
| 95 |
+
|
| 96 |
+
$.get( $( this ).attr( 'href' ), function( response ) {
|
| 97 |
+
container.html( response );
|
| 98 |
+
} );
|
| 99 |
+
} );
|
| 100 |
+
|
| 101 |
+
// Reset links
|
| 102 |
+
$( 'a.reset' ).unbind( 'click' ).click( function() {
|
| 103 |
+
var item = $( this ).parents( 'tr' )
|
| 104 |
+
var href = this.href;
|
| 105 |
+
|
| 106 |
+
$( item ).find( '.operations div' ).hide();
|
| 107 |
+
$( item ).find( '.loader' ).show();
|
| 108 |
+
$( item ).load( this.href, function() {
|
| 109 |
+
modules();
|
| 110 |
+
});
|
| 111 |
+
|
| 112 |
+
return false;
|
| 113 |
+
});
|
| 114 |
+
|
| 115 |
+
// Delete links
|
| 116 |
+
$( 'a.rdelete' ).unbind( 'click' ).click( function() {
|
| 117 |
+
var item = $( this ).parents( 'tr' )
|
| 118 |
+
|
| 119 |
+
$( item ).find( '.operations a' ).hide();
|
| 120 |
+
$( item ).find( '.loader' ).show();
|
| 121 |
+
$.get( this.href, function() {
|
| 122 |
+
$( item ).fadeOut();
|
| 123 |
+
});
|
| 124 |
+
|
| 125 |
+
return false;
|
| 126 |
+
});
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
modules();
|
| 130 |
+
};
|
| 131 |
+
|
| 132 |
+
Redirection_Logs = function() {
|
| 133 |
+
function logs() {
|
| 134 |
+
$( '.add-log' ).unbind( 'click' ).click( function( item ) {
|
| 135 |
+
$( '#added' ).hide ();
|
| 136 |
+
$( '#add' ).show ();
|
| 137 |
+
|
| 138 |
+
// Copy details
|
| 139 |
+
$( '#old' ).val( $( this ).attr( 'href' ) );
|
| 140 |
+
return false;
|
| 141 |
+
} );
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
logs();
|
| 145 |
+
};
|
| 146 |
+
|
| 147 |
+
function get_redirect_error( response ) {
|
| 148 |
+
if ( parseInt( response, 10 ) === 0 || parseInt( response, 10 ) === -1 )
|
| 149 |
+
return Redirectioni10n.error_msg;
|
| 150 |
+
else if ( response.error )
|
| 151 |
+
return response.error;
|
| 152 |
+
return false;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
Redirection_Add = function( selector, target, add_form, add_to_screen ) {
|
| 156 |
+
$( selector ).on( 'change', function() {
|
| 157 |
+
if ( $( this ).val() == 'url' || $( this ).val() == 'pass' )
|
| 158 |
+
$( target ).show();
|
| 159 |
+
else
|
| 160 |
+
$( target ).hide();
|
| 161 |
+
} );
|
| 162 |
+
|
| 163 |
+
$( add_form ).find( 'form' ).ajaxForm( {
|
| 164 |
+
beforeSubmit: function () {
|
| 165 |
+
$( add_form ).removeClass( 'loaded-error' ).addClass( 'loading' );
|
| 166 |
+
},
|
| 167 |
+
success: function( response ) {
|
| 168 |
+
var error = get_redirect_error( response );
|
| 169 |
+
|
| 170 |
+
$( add_form ).removeClass( 'loading' );
|
| 171 |
+
|
| 172 |
+
if ( error ) {
|
| 173 |
+
$( add_form ).addClass( 'loaded-error' );
|
| 174 |
+
$( add_form ).find( '.red-error' ).html( error );
|
| 175 |
+
return;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
if ( add_to_screen === true ) {
|
| 179 |
+
$( add_form ).addClass( 'loaded' );
|
| 180 |
+
|
| 181 |
+
$( 'table.items' ).append( response.html );
|
| 182 |
+
$( 'table.items tr' ).each( function( pos, item ) {
|
| 183 |
+
$( item ).removeClass( 'alternate' );
|
| 184 |
+
if ( pos % 2 == 0 )
|
| 185 |
+
$( item ).addClass( 'alternate' );
|
| 186 |
+
} );
|
| 187 |
+
}
|
| 188 |
+
},
|
| 189 |
+
dataType: 'json'
|
| 190 |
+
});
|
| 191 |
+
};
|
| 192 |
+
} )( jQuery );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
matches/user_agent.php
CHANGED
|
@@ -45,7 +45,7 @@ class Agent_Match extends Red_Match {
|
|
| 45 |
<th width="100"><?php _e( 'User Agent', 'redirection' ); ?>:</th>
|
| 46 |
<td>
|
| 47 |
<input id="user_agent_<?php echo $this->id ?>" style="width: 65%" type="text" name="user_agent" value="<?php echo esc_attr( $this->user_agent ); ?>"/>
|
| 48 |
-
<select style="width: 30%"
|
| 49 |
<?php foreach ( $defined AS $key => $value ) : ?>
|
| 50 |
<option value="<?php echo $key ?>"<?php if ( $key == $this->user_agent ) echo ' selected="selected"' ?>><?php echo esc_html( $value ) ?></option>
|
| 51 |
<?php endforeach; ?>
|
| 45 |
<th width="100"><?php _e( 'User Agent', 'redirection' ); ?>:</th>
|
| 46 |
<td>
|
| 47 |
<input id="user_agent_<?php echo $this->id ?>" style="width: 65%" type="text" name="user_agent" value="<?php echo esc_attr( $this->user_agent ); ?>"/>
|
| 48 |
+
<select style="width: 30%" class="change-user-agent">
|
| 49 |
<?php foreach ( $defined AS $key => $value ) : ?>
|
| 50 |
<option value="<?php echo $key ?>"<?php if ( $key == $this->user_agent ) echo ' selected="selected"' ?>><?php echo esc_html( $value ) ?></option>
|
| 51 |
<?php endforeach; ?>
|
models/database.php
CHANGED
|
@@ -88,7 +88,7 @@ class RE_Database {
|
|
| 88 |
KEY `module_id` (`module_id`)
|
| 89 |
) $charset_collate",
|
| 90 |
|
| 91 |
-
"CREATE TABLE `{$wpdb->prefix}redirection_modules`(
|
| 92 |
`id` int(11) unsigned NOT NULL auto_increment,
|
| 93 |
`type` varchar(20) NOT NULL default '',
|
| 94 |
`name` varchar(50) NOT NULL default '',
|
|
@@ -98,7 +98,7 @@ class RE_Database {
|
|
| 98 |
KEY `type` (`type`)
|
| 99 |
) $charset_collate",
|
| 100 |
|
| 101 |
-
"CREATE TABLE `{$wpdb->prefix}redirection_404` (
|
| 102 |
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
| 103 |
`created` datetime NOT NULL,
|
| 104 |
`url` varchar(255) NOT NULL DEFAULT '',
|
|
@@ -181,7 +181,7 @@ class RE_Database {
|
|
| 181 |
$wpdb->query( "DELETE FROM {$wpdb->prefix}redirection_modules WHERE type='404'" );
|
| 182 |
$wpdb->query( "UPDATE {$wpdb->prefix}redirection_groups SET module_id=1 WHERE module_id=3" );
|
| 183 |
|
| 184 |
-
$wpdb->query( "CREATE TABLE `{$wpdb->prefix}redirection_404` (
|
| 185 |
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
| 186 |
`created` datetime NOT NULL,
|
| 187 |
`url` varchar(255) NOT NULL DEFAULT '',
|
| 88 |
KEY `module_id` (`module_id`)
|
| 89 |
) $charset_collate",
|
| 90 |
|
| 91 |
+
"CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}redirection_modules`(
|
| 92 |
`id` int(11) unsigned NOT NULL auto_increment,
|
| 93 |
`type` varchar(20) NOT NULL default '',
|
| 94 |
`name` varchar(50) NOT NULL default '',
|
| 98 |
KEY `type` (`type`)
|
| 99 |
) $charset_collate",
|
| 100 |
|
| 101 |
+
"CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}redirection_404` (
|
| 102 |
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
| 103 |
`created` datetime NOT NULL,
|
| 104 |
`url` varchar(255) NOT NULL DEFAULT '',
|
| 181 |
$wpdb->query( "DELETE FROM {$wpdb->prefix}redirection_modules WHERE type='404'" );
|
| 182 |
$wpdb->query( "UPDATE {$wpdb->prefix}redirection_groups SET module_id=1 WHERE module_id=3" );
|
| 183 |
|
| 184 |
+
$wpdb->query( "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}redirection_404` (
|
| 185 |
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
| 186 |
`created` datetime NOT NULL,
|
| 187 |
`url` varchar(255) NOT NULL DEFAULT '',
|
models/file_io.php
CHANGED
|
@@ -22,11 +22,11 @@ abstract class Red_FileIO {
|
|
| 22 |
return $exporter;
|
| 23 |
}
|
| 24 |
|
| 25 |
-
function import( $group, $file ) {
|
| 26 |
if ( is_uploaded_file( $file['tmp_name'] ) ) {
|
| 27 |
$parts = pathinfo( $file['name'] );
|
| 28 |
|
| 29 |
-
if ( $parts['extension'] == 'csv' ) {
|
| 30 |
include dirname( dirname( __FILE__ ) ).'/fileio/csv.php';
|
| 31 |
$importer = new Red_Csv_File();
|
| 32 |
$data = '';
|
| 22 |
return $exporter;
|
| 23 |
}
|
| 24 |
|
| 25 |
+
public static function import( $group, $file ) {
|
| 26 |
if ( is_uploaded_file( $file['tmp_name'] ) ) {
|
| 27 |
$parts = pathinfo( $file['name'] );
|
| 28 |
|
| 29 |
+
if ( isset( $parts['extension'] ) && $parts['extension'] == 'csv' ) {
|
| 30 |
include dirname( dirname( __FILE__ ) ).'/fileio/csv.php';
|
| 31 |
$importer = new Red_Csv_File();
|
| 32 |
$data = '';
|
models/group.php
CHANGED
|
@@ -1,7 +1,10 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
class Red_Group {
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
| 5 |
if ( is_object( $values ) ) {
|
| 6 |
foreach ( $values AS $key => $value ) {
|
| 7 |
$this->$key = $value;
|
|
@@ -9,6 +12,18 @@ class Red_Group {
|
|
| 9 |
}
|
| 10 |
}
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
/**
|
| 13 |
* Get list of groups
|
| 14 |
*/
|
|
@@ -83,7 +98,7 @@ class Red_Group {
|
|
| 83 |
static function get_first_id() {
|
| 84 |
global $wpdb;
|
| 85 |
|
| 86 |
-
return $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}redirection_groups ORDER BY id LIMIT 0,1" );
|
| 87 |
}
|
| 88 |
|
| 89 |
static function create( $data ) {
|
|
@@ -118,32 +133,25 @@ class Red_Group {
|
|
| 118 |
function update( $data ) {
|
| 119 |
global $wpdb;
|
| 120 |
|
|
|
|
|
|
|
| 121 |
$this->tracking = isset( $data['tracking'] ) ? true : false;
|
| 122 |
$this->status = isset( $data['status'] ) ? 'enabled' : 'disabled';
|
|
|
|
| 123 |
|
| 124 |
-
$wpdb->update( $wpdb->prefix.'redirection_groups', array( 'name' => $
|
| 125 |
|
| 126 |
Red_Module::flush( $this->module_id );
|
| 127 |
}
|
| 128 |
|
| 129 |
-
|
| 130 |
global $wpdb;
|
| 131 |
|
| 132 |
-
$obj = self::get( $group );
|
| 133 |
-
|
| 134 |
// Delete all items in this group
|
| 135 |
-
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_items WHERE group_id=%d", $
|
| 136 |
|
| 137 |
// Delete the group
|
| 138 |
-
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_groups WHERE id=%d", $
|
| 139 |
-
|
| 140 |
-
// Update positions
|
| 141 |
-
$rows = $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}redirection_groups ORDER BY position" );
|
| 142 |
-
if ( count( $rows ) > 0 ) {
|
| 143 |
-
foreach ( $rows AS $pos => $row ) {
|
| 144 |
-
$wpdb->update( $wpdb->prefix.'redirection_groups', array( 'position' => intval( $pos ) ), array( 'id' => intval( $row->id ) ) );
|
| 145 |
-
}
|
| 146 |
-
}
|
| 147 |
}
|
| 148 |
|
| 149 |
static function save_order( $items, $start ) {
|
|
@@ -177,10 +185,10 @@ class Red_Group {
|
|
| 177 |
RE_Log::delete_for_group( $this->id );
|
| 178 |
}
|
| 179 |
|
| 180 |
-
function
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
return
|
| 184 |
}
|
| 185 |
|
| 186 |
function type() {
|
| 1 |
<?php
|
| 2 |
|
| 3 |
class Red_Group {
|
| 4 |
+
private $items = 0;
|
| 5 |
+
private $name;
|
| 6 |
+
|
| 7 |
+
public function __construct( $values = '' ) {
|
| 8 |
if ( is_object( $values ) ) {
|
| 9 |
foreach ( $values AS $key => $value ) {
|
| 10 |
$this->$key = $value;
|
| 12 |
}
|
| 13 |
}
|
| 14 |
|
| 15 |
+
public function get_name() {
|
| 16 |
+
return $this->name;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
public function get_id() {
|
| 20 |
+
return $this->id;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
public function is_disabled() {
|
| 24 |
+
return $this->status == 'disabled' ? true : false;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
/**
|
| 28 |
* Get list of groups
|
| 29 |
*/
|
| 98 |
static function get_first_id() {
|
| 99 |
global $wpdb;
|
| 100 |
|
| 101 |
+
return intval( $wpdb->get_var( "SELECT id FROM {$wpdb->prefix}redirection_groups ORDER BY id LIMIT 0,1" ) );
|
| 102 |
}
|
| 103 |
|
| 104 |
static function create( $data ) {
|
| 133 |
function update( $data ) {
|
| 134 |
global $wpdb;
|
| 135 |
|
| 136 |
+
$data = array_map( 'stripslashes', $data );
|
| 137 |
+
|
| 138 |
$this->tracking = isset( $data['tracking'] ) ? true : false;
|
| 139 |
$this->status = isset( $data['status'] ) ? 'enabled' : 'disabled';
|
| 140 |
+
$this->name = trim( wp_kses( $data['name'], array() ) );
|
| 141 |
|
| 142 |
+
$wpdb->update( $wpdb->prefix.'redirection_groups', array( 'name' => $this->name, 'status' => $this->status, 'tracking' => intval( $this->tracking ) ), array( 'id' => intval( $this->id ) ) );
|
| 143 |
|
| 144 |
Red_Module::flush( $this->module_id );
|
| 145 |
}
|
| 146 |
|
| 147 |
+
function delete() {
|
| 148 |
global $wpdb;
|
| 149 |
|
|
|
|
|
|
|
| 150 |
// Delete all items in this group
|
| 151 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_items WHERE group_id=%d", $this->id ) );
|
| 152 |
|
| 153 |
// Delete the group
|
| 154 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_groups WHERE id=%d", $this->id ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
}
|
| 156 |
|
| 157 |
static function save_order( $items, $start ) {
|
| 185 |
RE_Log::delete_for_group( $this->id );
|
| 186 |
}
|
| 187 |
|
| 188 |
+
function get_item_count() {
|
| 189 |
+
global $wpdb;
|
| 190 |
+
|
| 191 |
+
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}redirection_items WHERE group_id=%d", $this->id ) );
|
| 192 |
}
|
| 193 |
|
| 194 |
function type() {
|
models/match.php
CHANGED
|
@@ -62,7 +62,7 @@ class Red_Match {
|
|
| 62 |
}
|
| 63 |
|
| 64 |
function get_target( $url, $matched_url, $regex ) {
|
| 65 |
-
return
|
| 66 |
}
|
| 67 |
|
| 68 |
static function create( $name, $data = '' ) {
|
| 62 |
}
|
| 63 |
|
| 64 |
function get_target( $url, $matched_url, $regex ) {
|
| 65 |
+
return false;
|
| 66 |
}
|
| 67 |
|
| 68 |
static function create( $name, $data = '' ) {
|
models/module.php
CHANGED
|
@@ -1,7 +1,10 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
class Red_Module {
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
function Red_Module( $values = '' ) {
|
| 7 |
if ( is_object( $values ) ) {
|
|
@@ -35,6 +38,8 @@ class Red_Module {
|
|
| 35 |
function update( $data ) {
|
| 36 |
global $wpdb;
|
| 37 |
|
|
|
|
|
|
|
| 38 |
$this->name = $data['name'];
|
| 39 |
$options = $this->save( $data );
|
| 40 |
$wpdb->update( $wpdb->prefix.'redirection_modules', array( 'name' => trim( $data['name'] ), 'options' => empty( $options ) ? '' : serialize( $options ) ), array( 'id' => intval( $this->id ) ) );
|
|
@@ -264,4 +269,20 @@ class Red_Module {
|
|
| 264 |
|
| 265 |
function config() {
|
| 266 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
}
|
| 1 |
<?php
|
| 2 |
|
| 3 |
class Red_Module {
|
| 4 |
+
private $id;
|
| 5 |
+
private $type;
|
| 6 |
+
private $name;
|
| 7 |
+
private $options;
|
| 8 |
|
| 9 |
function Red_Module( $values = '' ) {
|
| 10 |
if ( is_object( $values ) ) {
|
| 38 |
function update( $data ) {
|
| 39 |
global $wpdb;
|
| 40 |
|
| 41 |
+
$data = array_map( 'stripslashes', $data );
|
| 42 |
+
|
| 43 |
$this->name = $data['name'];
|
| 44 |
$options = $this->save( $data );
|
| 45 |
$wpdb->update( $wpdb->prefix.'redirection_modules', array( 'name' => trim( $data['name'] ), 'options' => empty( $options ) ? '' : serialize( $options ) ), array( 'id' => intval( $this->id ) ) );
|
| 269 |
|
| 270 |
function config() {
|
| 271 |
}
|
| 272 |
+
|
| 273 |
+
function get_id() {
|
| 274 |
+
return $this->id;
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
function get_type() {
|
| 278 |
+
return $this->type;
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
public function get_name() {
|
| 282 |
+
return $this->name;
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
public function get_type_string() {
|
| 286 |
+
return '';
|
| 287 |
+
}
|
| 288 |
}
|
models/pager.php
CHANGED
|
@@ -3,11 +3,13 @@
|
|
| 3 |
if ( !class_exists( 'WP_List_Table' ) )
|
| 4 |
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
| 5 |
|
| 6 |
-
class
|
| 7 |
-
private $
|
|
|
|
| 8 |
|
| 9 |
-
function __construct( $
|
| 10 |
-
$this->
|
|
|
|
| 11 |
|
| 12 |
//Set parent defaults
|
| 13 |
parent::__construct( array(
|
|
@@ -17,34 +19,48 @@ class Redirection_Log_Table extends WP_List_Table {
|
|
| 17 |
) );
|
| 18 |
}
|
| 19 |
|
| 20 |
-
function
|
| 21 |
-
$
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
return
|
| 28 |
}
|
| 29 |
|
| 30 |
-
function
|
| 31 |
-
return
|
| 32 |
}
|
| 33 |
|
| 34 |
-
function
|
| 35 |
-
$
|
| 36 |
-
'
|
| 37 |
-
);
|
|
|
|
| 38 |
|
| 39 |
-
|
|
|
|
| 40 |
}
|
| 41 |
|
| 42 |
-
function
|
| 43 |
$actions = array(
|
| 44 |
-
'
|
|
|
|
| 45 |
);
|
| 46 |
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
}
|
| 49 |
|
| 50 |
function column_cb($item){
|
|
@@ -55,42 +71,86 @@ class Redirection_Log_Table extends WP_List_Table {
|
|
| 55 |
);
|
| 56 |
}
|
| 57 |
|
| 58 |
-
function
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
return $
|
| 67 |
}
|
| 68 |
|
| 69 |
function get_sortable_columns() {
|
| 70 |
$sortable_columns = array(
|
| 71 |
-
'created' => array( 'id', true ),
|
| 72 |
'url' => array( 'url', false),
|
| 73 |
-
'referrer' => array( 'referrer', false ),
|
| 74 |
-
'ip' => array( 'item_id', false ),
|
| 75 |
);
|
| 76 |
return $sortable_columns;
|
| 77 |
}
|
| 78 |
|
| 79 |
function get_bulk_actions() {
|
| 80 |
$actions = array(
|
| 81 |
-
'delete'
|
|
|
|
|
|
|
|
|
|
| 82 |
);
|
|
|
|
| 83 |
return $actions;
|
| 84 |
}
|
| 85 |
|
| 86 |
function process_bulk_action() {
|
| 87 |
-
if ( '
|
| 88 |
-
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
}
|
| 92 |
}
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
function prepare_items( $type = '', $id = 0 ) {
|
| 95 |
global $wpdb, $current_user;
|
| 96 |
|
|
@@ -119,28 +179,191 @@ class Redirection_Log_Table extends WP_List_Table {
|
|
| 119 |
if ( isset( $_GET['s'] ) )
|
| 120 |
$where[] = $wpdb->prepare( 'url LIKE %s', '%'.like_escape( $_GET['s'] ).'%' );
|
| 121 |
|
|
|
|
|
|
|
|
|
|
| 122 |
$where_cond = "";
|
| 123 |
if ( count( $where ) > 0 )
|
| 124 |
$where_cond = " WHERE ".implode( ' AND ', $where );
|
| 125 |
|
| 126 |
-
$table = $wpdb->prefix.'
|
| 127 |
$rows = $wpdb->get_results( "SELECT * FROM {$table} ".$where_cond.$wpdb->prepare( " ORDER BY $orderby $order LIMIT %d,%d", ( $this->get_pagenum() - 1 ) * $per_page, $per_page ) );
|
| 128 |
-
$total_items = $wpdb->get_var( "SELECT COUNT(*) FROM {$table}".$where_cond );
|
| 129 |
|
| 130 |
$this->items = array();
|
| 131 |
foreach ( (array)$rows AS $row ) {
|
| 132 |
-
$this->items[] = new
|
| 133 |
}
|
| 134 |
|
| 135 |
$this->set_pagination_args( array(
|
| 136 |
-
'total_items' => $total_items,
|
| 137 |
'per_page' => $per_page,
|
| 138 |
-
'total_pages' => ceil( $total_items / $per_page )
|
| 139 |
) );
|
| 140 |
}
|
| 141 |
}
|
| 142 |
|
| 143 |
-
class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
private $lookup;
|
| 145 |
|
| 146 |
function __construct( $options ) {
|
|
@@ -155,19 +378,25 @@ class Redirection_404_Table extends WP_List_Table {
|
|
| 155 |
}
|
| 156 |
|
| 157 |
function column_created( $item ) {
|
| 158 |
-
$actions
|
| 159 |
|
| 160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
}
|
| 162 |
|
| 163 |
function column_ip( $item ) {
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
return sprintf( '%1$s %2$s', '<a href="'.esc_attr( $this->lookup ).esc_attr( long2ip( $item->ip ) ).'">'.long2ip( $item->ip ).'</a>', $this->row_actions( $actions ) );
|
| 167 |
}
|
| 168 |
|
| 169 |
function column_url( $item ) {
|
| 170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
}
|
| 172 |
|
| 173 |
function column_referrer( $item ) {
|
|
@@ -189,7 +418,7 @@ class Redirection_404_Table extends WP_List_Table {
|
|
| 189 |
function get_columns(){
|
| 190 |
$columns = array(
|
| 191 |
'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
|
| 192 |
-
'created'
|
| 193 |
'url' => __( 'Source URL', 'redirection' ),
|
| 194 |
'referrer' => __( 'Referrer', 'redirection' ),
|
| 195 |
'ip' => __( 'IP', 'redirection' ),
|
|
@@ -199,9 +428,10 @@ class Redirection_404_Table extends WP_List_Table {
|
|
| 199 |
|
| 200 |
function get_sortable_columns() {
|
| 201 |
$sortable_columns = array(
|
| 202 |
-
'created'
|
| 203 |
'url' => array( 'url', false),
|
| 204 |
'referrer' => array( 'referrer', false ),
|
|
|
|
| 205 |
);
|
| 206 |
return $sortable_columns;
|
| 207 |
}
|
|
@@ -216,12 +446,12 @@ class Redirection_404_Table extends WP_List_Table {
|
|
| 216 |
function process_bulk_action() {
|
| 217 |
if ( 'delete' === $this->current_action() ) {
|
| 218 |
foreach( $_POST['item'] AS $id ) {
|
| 219 |
-
|
| 220 |
}
|
| 221 |
}
|
| 222 |
}
|
| 223 |
|
| 224 |
-
function prepare_items( $
|
| 225 |
global $wpdb, $current_user;
|
| 226 |
|
| 227 |
$screen = get_current_screen();
|
|
@@ -249,14 +479,11 @@ class Redirection_404_Table extends WP_List_Table {
|
|
| 249 |
if ( isset( $_GET['s'] ) )
|
| 250 |
$where[] = $wpdb->prepare( 'url LIKE %s', '%'.like_escape( $_GET['s'] ).'%' );
|
| 251 |
|
| 252 |
-
if ( $restrict_by_ip !== false )
|
| 253 |
-
$where[] = $wpdb->prepare( 'ip=INET_ATON(%s)', $restrict_by_ip );
|
| 254 |
-
|
| 255 |
$where_cond = "";
|
| 256 |
if ( count( $where ) > 0 )
|
| 257 |
$where_cond = " WHERE ".implode( ' AND ', $where );
|
| 258 |
|
| 259 |
-
$table = $wpdb->prefix.'
|
| 260 |
$rows = $wpdb->get_results( "SELECT * FROM {$table} ".$where_cond.$wpdb->prepare( " ORDER BY $orderby $order LIMIT %d,%d", ( $this->get_pagenum() - 1 ) * $per_page, $per_page ) );
|
| 261 |
$total_items = $wpdb->get_var( "SELECT COUNT(*) FROM {$table}".$where_cond );
|
| 262 |
|
|
@@ -273,10 +500,12 @@ class Redirection_404_Table extends WP_List_Table {
|
|
| 273 |
}
|
| 274 |
}
|
| 275 |
|
| 276 |
-
class
|
| 277 |
private $lookup;
|
| 278 |
|
| 279 |
function __construct( $options ) {
|
|
|
|
|
|
|
| 280 |
//Set parent defaults
|
| 281 |
parent::__construct( array(
|
| 282 |
'singular' => 'item', //singular name of the listed records
|
|
@@ -285,16 +514,28 @@ class Redirection_Group_Table extends WP_List_Table {
|
|
| 285 |
) );
|
| 286 |
}
|
| 287 |
|
| 288 |
-
function
|
| 289 |
-
$actions['add'] = '<a href="'.esc_url( $item->url ).'" class="add-log">'.__( '
|
| 290 |
|
| 291 |
-
return '
|
| 292 |
}
|
| 293 |
|
| 294 |
-
function
|
| 295 |
$actions['add'] = '<a href="'.admin_url( 'tools.php?page=redirection.php&sub=404s&ip='.esc_attr( long2ip( $item->ip ) ) ).'">'.__( 'Show only this IP', 'redirection' ).'</a>';
|
| 296 |
|
| 297 |
-
return '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 298 |
}
|
| 299 |
|
| 300 |
function column_cb($item){
|
|
@@ -308,15 +549,19 @@ class Redirection_Group_Table extends WP_List_Table {
|
|
| 308 |
function get_columns(){
|
| 309 |
$columns = array(
|
| 310 |
'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
|
| 311 |
-
'
|
| 312 |
-
'
|
|
|
|
|
|
|
| 313 |
);
|
| 314 |
return $columns;
|
| 315 |
}
|
| 316 |
|
| 317 |
function get_sortable_columns() {
|
| 318 |
$sortable_columns = array(
|
| 319 |
-
'
|
|
|
|
|
|
|
| 320 |
);
|
| 321 |
return $sortable_columns;
|
| 322 |
}
|
|
@@ -331,7 +576,7 @@ class Redirection_Group_Table extends WP_List_Table {
|
|
| 331 |
function process_bulk_action() {
|
| 332 |
if ( 'delete' === $this->current_action() ) {
|
| 333 |
foreach( $_POST['item'] AS $id ) {
|
| 334 |
-
|
| 335 |
}
|
| 336 |
}
|
| 337 |
}
|
|
@@ -339,13 +584,12 @@ class Redirection_Group_Table extends WP_List_Table {
|
|
| 339 |
function prepare_items( $restrict_by_ip = false ) {
|
| 340 |
global $wpdb, $current_user;
|
| 341 |
|
| 342 |
-
$screen
|
| 343 |
$per_page = get_user_meta( $current_user->ID, $screen->get_option( 'per_page', 'option' ), true );
|
| 344 |
|
| 345 |
-
$per_page
|
| 346 |
-
$columns
|
| 347 |
-
$sortable
|
| 348 |
-
$current_page = $this->get_pagenum();
|
| 349 |
|
| 350 |
$this->_column_headers = array( $columns, array(), $sortable );
|
| 351 |
|
|
@@ -361,8 +605,18 @@ class Redirection_Group_Table extends WP_List_Table {
|
|
| 361 |
if ( !in_array( $order, array( 'asc', 'desc' ) ) )
|
| 362 |
$order = 'desc';
|
| 363 |
|
| 364 |
-
$
|
|
|
|
|
|
|
| 365 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 366 |
$rows = $wpdb->get_results( "SELECT * FROM {$table} ".$where_cond.$wpdb->prepare( " ORDER BY $orderby $order LIMIT %d,%d", ( $this->get_pagenum() - 1 ) * $per_page, $per_page ) );
|
| 367 |
$total_items = $wpdb->get_var( "SELECT COUNT(*) FROM {$table}".$where_cond );
|
| 368 |
|
|
@@ -379,428 +633,66 @@ class Redirection_Group_Table extends WP_List_Table {
|
|
| 379 |
}
|
| 380 |
}
|
| 381 |
|
| 382 |
-
class
|
| 383 |
-
{
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
var $order_direction = null;
|
| 391 |
-
var $order_tags = array ();
|
| 392 |
-
var $steps = array ();
|
| 393 |
-
var $search = null;
|
| 394 |
-
var $filters = array ();
|
| 395 |
-
var $id;
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
/**
|
| 399 |
-
* Construct a pager object using the $_GET data, the current URL, and default preferences
|
| 400 |
-
*
|
| 401 |
-
* @param array $data Array of values, typically from $_GET
|
| 402 |
-
* @param string $url The current URL
|
| 403 |
-
* @param string $orderby Default database column to order data by
|
| 404 |
-
* @param string $direction Default direction of ordering (DESC or ASC)
|
| 405 |
-
* @param string $id An ID for the pager to separate it from other pagers (typically the plugin name)
|
| 406 |
-
* @return void
|
| 407 |
-
**/
|
| 408 |
-
function RE_Pager ($data, $url, $orderby = '', $direction = 'DESC', $id = 'default', $tags = '')
|
| 409 |
-
{
|
| 410 |
-
// Remove all pager params from the url
|
| 411 |
-
$this->id = $id;
|
| 412 |
-
$this->url = $url;
|
| 413 |
-
|
| 414 |
-
if (isset ($data['curpage']) && $data['curpage'] > 0)
|
| 415 |
-
$this->current_page = intval ($data['curpage']);
|
| 416 |
-
|
| 417 |
-
global $user_ID;
|
| 418 |
-
|
| 419 |
-
if (isset ($data['perpage']))
|
| 420 |
-
{
|
| 421 |
-
$this->per_page = intval ($data['perpage']);
|
| 422 |
-
$per_page[get_class ($this)][$this->id] = $this->per_page;
|
| 423 |
-
}
|
| 424 |
-
else if (isset ($per_page[get_class ($this)]) && isset ($per_page[get_class ($this)][$this->id]))
|
| 425 |
-
$this->per_page = $per_page[get_class ($this)][$this->id];
|
| 426 |
-
|
| 427 |
-
if (!empty ($tags))
|
| 428 |
-
{
|
| 429 |
-
$this->order_tags = $tags;
|
| 430 |
-
if (isset ($this->order_tags[$this->order_by]))
|
| 431 |
-
$this->order_by = $this->order_tags[$this->order_by];
|
| 432 |
-
}
|
| 433 |
-
|
| 434 |
-
$this->order_direction = $direction;
|
| 435 |
-
$this->order_original = $orderby;
|
| 436 |
-
if (isset ($data['order']))
|
| 437 |
-
$this->order_direction = $data['order'];
|
| 438 |
-
|
| 439 |
-
$this->search = isset($data['search']) ? $data['search'] : '';
|
| 440 |
-
$this->steps = array (10, 25, 50, 100, 250);
|
| 441 |
-
$this->url = str_replace ('&', '&', $this->url);
|
| 442 |
-
$this->url = str_replace ('&&', '&', $this->url);
|
| 443 |
-
}
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
/**
|
| 447 |
-
* Set the total number of entries that match the conditions
|
| 448 |
-
*
|
| 449 |
-
* @param int $total Count
|
| 450 |
-
* @return void
|
| 451 |
-
**/
|
| 452 |
-
|
| 453 |
-
function set_total ($total)
|
| 454 |
-
{
|
| 455 |
-
$this->total = $total;
|
| 456 |
-
|
| 457 |
-
if ($this->current_page <= 0 || $this->current_page > $this->total_pages ())
|
| 458 |
-
$this->current_page = 1;
|
| 459 |
-
}
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
/**
|
| 463 |
-
* Return the current page offset
|
| 464 |
-
*
|
| 465 |
-
* @return int Current page offset
|
| 466 |
-
**/
|
| 467 |
-
|
| 468 |
-
function offset ()
|
| 469 |
-
{
|
| 470 |
-
return ($this->current_page - 1) * $this->per_page;
|
| 471 |
-
}
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
/**
|
| 475 |
-
* @todo explain
|
| 476 |
-
* @return void
|
| 477 |
-
**/
|
| 478 |
-
function is_secondary_sort ()
|
| 479 |
-
{
|
| 480 |
-
return substr ($this->order_by, 0, 1) == '_' ? true : false;
|
| 481 |
-
}
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
/**
|
| 485 |
-
* Returns a set of conditions without any limits. This is suitable for a COUNT SQL
|
| 486 |
-
*
|
| 487 |
-
* @param string $conditions WHERE conditions
|
| 488 |
-
* @param array $searches Array of columns to search on
|
| 489 |
-
* @param array $filters Array of columns to filter on
|
| 490 |
-
* @return string SQL
|
| 491 |
-
**/
|
| 492 |
-
|
| 493 |
-
function to_conditions ($conditions, $searches = '', $filters = '') {
|
| 494 |
-
global $wpdb;
|
| 495 |
-
|
| 496 |
-
$sql = '';
|
| 497 |
-
if ($conditions != '')
|
| 498 |
-
$sql .= ' WHERE '.$conditions;
|
| 499 |
-
|
| 500 |
-
// Add on search conditions
|
| 501 |
-
if (is_array ($searches) && $this->search != '')
|
| 502 |
-
{
|
| 503 |
-
if ($sql == '')
|
| 504 |
-
$sql .= ' WHERE (';
|
| 505 |
-
else
|
| 506 |
-
$sql .= ' AND (';
|
| 507 |
-
|
| 508 |
-
$searchbits = array ();
|
| 509 |
-
foreach ($searches AS $search)
|
| 510 |
-
$searchbits[] = $wpdb->prepare( $search.' LIKE %s', '%'.like_escape( $this->search ).'%' );
|
| 511 |
-
|
| 512 |
-
$sql .= implode (' OR ', $searchbits);
|
| 513 |
-
$sql .= ')';
|
| 514 |
-
}
|
| 515 |
-
|
| 516 |
-
// Add filters
|
| 517 |
-
if (is_array ($filters) && !empty ($this->filters))
|
| 518 |
-
{
|
| 519 |
-
$searchbits = array ();
|
| 520 |
-
foreach ($filters AS $filter)
|
| 521 |
-
{
|
| 522 |
-
if (isset ($this->filters[$filter]))
|
| 523 |
-
{
|
| 524 |
-
if ($this->filters[$filter] != '')
|
| 525 |
-
$searchbits[] = $wpdb->prepare( $filter." = %s", $this->filters[$filter] );
|
| 526 |
-
}
|
| 527 |
-
}
|
| 528 |
-
|
| 529 |
-
if (count ($searchbits) > 0)
|
| 530 |
-
{
|
| 531 |
-
if ($sql == '')
|
| 532 |
-
$sql .= ' WHERE (';
|
| 533 |
-
else
|
| 534 |
-
$sql .= ' AND (';
|
| 535 |
-
|
| 536 |
-
$sql .= implode (' AND ', $searchbits);
|
| 537 |
-
$sql .= ')';
|
| 538 |
-
}
|
| 539 |
-
}
|
| 540 |
-
|
| 541 |
-
return $sql;
|
| 542 |
}
|
| 543 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 544 |
|
| 545 |
-
|
| 546 |
-
* Returns a set of conditions with limits.
|
| 547 |
-
*
|
| 548 |
-
* @param string $conditions WHERE conditions
|
| 549 |
-
* @param array $searches Array of columns to search on
|
| 550 |
-
* @param array $filters Array of columns to filter on
|
| 551 |
-
* @return string SQL
|
| 552 |
-
**/
|
| 553 |
-
|
| 554 |
-
function to_limits ($conditions = '', $searches = '', $filters = '', $group_by = '') {
|
| 555 |
-
global $wpdb;
|
| 556 |
-
|
| 557 |
-
$sql = $this->to_conditions ($conditions, $searches, $filters);
|
| 558 |
-
|
| 559 |
-
if ($group_by)
|
| 560 |
-
$sql .= ' '.$group_by.' ';
|
| 561 |
-
|
| 562 |
-
if ($this->per_page > 0)
|
| 563 |
-
$sql .= $wpdb->prepare( ' LIMIT %d,%d', $this->offset(), $this->per_page );
|
| 564 |
-
return $sql;
|
| 565 |
-
}
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
/**
|
| 569 |
-
* Return the url with all the params added back
|
| 570 |
-
*
|
| 571 |
-
* @param int Page offset
|
| 572 |
-
* @param string $orderby Optional order
|
| 573 |
-
* @return string URL
|
| 574 |
-
**/
|
| 575 |
-
|
| 576 |
-
function url ($offset, $orderby = '')
|
| 577 |
-
{
|
| 578 |
-
// Position
|
| 579 |
-
if (strpos ($this->url, 'curpage=') !== false)
|
| 580 |
-
$url = preg_replace ('/curpage=\d*/', 'curpage='.$offset, $this->url);
|
| 581 |
-
else
|
| 582 |
-
$url = $this->url.'&curpage='.$offset;
|
| 583 |
-
|
| 584 |
-
// Order
|
| 585 |
-
if ($orderby != '')
|
| 586 |
-
{
|
| 587 |
-
if (strpos ($url, 'orderby=') !== false)
|
| 588 |
-
$url = preg_replace ('/orderby=\w*/', 'orderby='.$orderby, $url);
|
| 589 |
-
else
|
| 590 |
-
$url = $url.'&orderby='.$orderby;
|
| 591 |
-
|
| 592 |
-
if (!empty ($this->order_tags) && isset ($this->order_tags[$orderby]))
|
| 593 |
-
$dir = $this->order_direction == 'ASC' ? 'DESC' : 'ASC';
|
| 594 |
-
else if ($this->order_by == $orderby)
|
| 595 |
-
$dir = $this->order_direction == 'ASC' ? 'DESC' : 'ASC';
|
| 596 |
-
else
|
| 597 |
-
$dir = $this->order_direction;
|
| 598 |
-
|
| 599 |
-
if (strpos ($url, 'order=') !== false)
|
| 600 |
-
$url = preg_replace ('/order=\w*/', 'order='.$dir, $url);
|
| 601 |
-
else
|
| 602 |
-
$url = $url.'&order='.$dir;
|
| 603 |
-
}
|
| 604 |
-
|
| 605 |
-
if ( isset( $_GET['id'] ) )
|
| 606 |
-
$url .= '&id='.intval( $_GET['id'] );
|
| 607 |
-
|
| 608 |
-
if ( isset( $_GET['perpage'] ) )
|
| 609 |
-
$url .= '&perpage='.intval( $_GET['perpage'] );
|
| 610 |
-
|
| 611 |
-
if ( isset( $_GET['search'] ) )
|
| 612 |
-
$url .= '&search='.urlencode( $_GET['search'] );
|
| 613 |
-
|
| 614 |
-
return str_replace ('&go=go', '', $url);
|
| 615 |
}
|
| 616 |
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
* Return current page
|
| 620 |
-
*
|
| 621 |
-
* @return int
|
| 622 |
-
**/
|
| 623 |
-
|
| 624 |
-
function current_page () { return $this->current_page; }
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
/**
|
| 628 |
-
* Return total number of pages
|
| 629 |
-
*
|
| 630 |
-
* @return int
|
| 631 |
-
**/
|
| 632 |
-
|
| 633 |
-
function total_pages ()
|
| 634 |
-
{
|
| 635 |
-
if ($this->per_page == 0)
|
| 636 |
-
return 1;
|
| 637 |
-
return ceil ($this->total / $this->per_page);
|
| 638 |
}
|
| 639 |
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
* Determine if we have a next page
|
| 643 |
-
*
|
| 644 |
-
* @return boolean
|
| 645 |
-
**/
|
| 646 |
-
|
| 647 |
-
function have_next_page ()
|
| 648 |
-
{
|
| 649 |
-
if ($this->current_page < $this->total_pages ())
|
| 650 |
-
return true;
|
| 651 |
-
return false;
|
| 652 |
}
|
| 653 |
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
* Determine if we have a previous page
|
| 657 |
-
*
|
| 658 |
-
* @return boolean
|
| 659 |
-
**/
|
| 660 |
-
|
| 661 |
-
function have_previous_page ()
|
| 662 |
-
{
|
| 663 |
-
if ($this->current_page > 1)
|
| 664 |
-
return true;
|
| 665 |
-
return false;
|
| 666 |
}
|
| 667 |
|
|
|
|
|
|
|
| 668 |
|
| 669 |
-
|
| 670 |
-
{
|
| 671 |
-
if ($column == $this->order_by)
|
| 672 |
-
{
|
| 673 |
-
if ($class)
|
| 674 |
-
printf (' class="sortedd"');
|
| 675 |
-
else
|
| 676 |
-
echo ' sortedd';
|
| 677 |
-
}
|
| 678 |
}
|
| 679 |
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
*
|
| 683 |
-
* @param string $column Column to search upon
|
| 684 |
-
* @param string $text Text to display for the column
|
| 685 |
-
* @param boolean $image Whether to show a direction image
|
| 686 |
-
* @return string URL
|
| 687 |
-
**/
|
| 688 |
-
|
| 689 |
-
function sortable ($column, $text, $image = true)
|
| 690 |
-
{
|
| 691 |
-
return $text;
|
| 692 |
-
$url = admin_url( add_query_arg( array( 'orderby' => $column ), 'redirection.php' ) );
|
| 693 |
-
|
| 694 |
-
$img = '';
|
| 695 |
-
|
| 696 |
-
if (isset ($this->order_tags[$column]))
|
| 697 |
-
$column = $this->order_tags[$column];
|
| 698 |
-
|
| 699 |
-
if ($column == $this->order_by)
|
| 700 |
-
{
|
| 701 |
-
$dir = WP_PLUGIN_URL.'/'.basename (dirname (dirname (__FILE__)));
|
| 702 |
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
$img = '<img align="bottom" src="'.$dir.'/images/down.gif" alt="dir" width="16" height="7"/>';
|
| 707 |
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
}
|
| 711 |
|
| 712 |
-
|
| 713 |
-
}
|
| 714 |
-
|
| 715 |
-
|
| 716 |
-
/**
|
| 717 |
-
* Returns an array of page numbers => link, given the current page (next and previous etc)
|
| 718 |
-
*
|
| 719 |
-
* @return array Array of page links
|
| 720 |
-
**/
|
| 721 |
-
|
| 722 |
-
function area_pages ()
|
| 723 |
-
{
|
| 724 |
-
// First page
|
| 725 |
-
$allow_dot = true;
|
| 726 |
-
$pages = array ();
|
| 727 |
-
|
| 728 |
-
if ($this->total_pages () > 1)
|
| 729 |
-
{
|
| 730 |
-
$previous = __ ('Previous', 'redirection');
|
| 731 |
-
$next = __ ('Next', 'redirection');
|
| 732 |
-
|
| 733 |
-
if ($this->have_previous_page ())
|
| 734 |
-
$pages[] = '<a href="'.$this->url ($this->current_page - 1).'">'.$previous.'</a> |';
|
| 735 |
-
else
|
| 736 |
-
$pages[] = $previous.' |';
|
| 737 |
-
|
| 738 |
-
for ($pos = 1; $pos <= $this->total_pages (); $pos++)
|
| 739 |
-
{
|
| 740 |
-
if ($pos == $this->current_page)
|
| 741 |
-
{
|
| 742 |
-
$pages[] = '<span class="active">'.$pos.'</span>';
|
| 743 |
-
$allow_dot = true;
|
| 744 |
-
}
|
| 745 |
-
else if ($pos == 1 || abs ($this->current_page - $pos) <= 2 || $pos == $this->total_pages ())
|
| 746 |
-
$pages[] = '<a href="'.$this->url ($pos).'">'.$pos."</a>";
|
| 747 |
-
else if ($allow_dot)
|
| 748 |
-
{
|
| 749 |
-
$allow_dot = false;
|
| 750 |
-
$pages[] = '…';
|
| 751 |
-
}
|
| 752 |
-
}
|
| 753 |
|
| 754 |
-
|
| 755 |
-
|
| 756 |
-
|
| 757 |
-
$pages[] = '| '.$next;
|
| 758 |
}
|
| 759 |
|
| 760 |
-
|
| 761 |
-
|
| 762 |
-
|
| 763 |
-
|
| 764 |
-
|
| 765 |
-
* @todo
|
| 766 |
-
* @return boolean
|
| 767 |
-
**/
|
| 768 |
-
|
| 769 |
-
function filtered ($field, $value)
|
| 770 |
-
{
|
| 771 |
-
if (isset ($this->filters[$field]) && $this->filters[$field] == $value)
|
| 772 |
-
return true;
|
| 773 |
-
return false;
|
| 774 |
-
}
|
| 775 |
-
|
| 776 |
-
|
| 777 |
-
/**
|
| 778 |
-
* Display a SELECT box suitable for a per-page
|
| 779 |
-
*
|
| 780 |
-
* @return void
|
| 781 |
-
**/
|
| 782 |
-
|
| 783 |
-
function per_page ($plugin = '')
|
| 784 |
-
{
|
| 785 |
-
?>
|
| 786 |
-
<select name="perpage">
|
| 787 |
-
<?php foreach ($this->steps AS $step) : ?>
|
| 788 |
-
<option value="<?php echo $step ?>"<?php if ($this->per_page == $step) echo ' selected="selected"' ?>>
|
| 789 |
-
<?php printf (__ ('%d per-page', $plugin), $step) ?>
|
| 790 |
-
</option>
|
| 791 |
-
<?php endforeach; ?>
|
| 792 |
-
</select>
|
| 793 |
-
<?php
|
| 794 |
-
}
|
| 795 |
-
|
| 796 |
-
function page_links ()
|
| 797 |
-
{
|
| 798 |
-
$text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>',
|
| 799 |
-
number_format_i18n (($this->current_page () - 1) * $this->per_page + 1),
|
| 800 |
-
number_format_i18n ($this->current_page () * $this->per_page > $this->total ? $this->total : $this->current_page () * $this->per_page),
|
| 801 |
-
number_format_i18n ($this->total));
|
| 802 |
-
|
| 803 |
-
$links = paginate_links (array ('base' => str_replace ('99', '%#%', $this->url (99)), 'format' => '%#%', 'current' => $this->current_page (), 'total' => $this->total_pages (), 'end_size' => 3, 'mid_size' => 2, 'prev_next' => true));
|
| 804 |
-
return $text.$links;
|
| 805 |
}
|
| 806 |
}
|
| 3 |
if ( !class_exists( 'WP_List_Table' ) )
|
| 4 |
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
| 5 |
|
| 6 |
+
class Redirection_Table extends WP_List_Table {
|
| 7 |
+
private $groups;
|
| 8 |
+
private $total_items;
|
| 9 |
|
| 10 |
+
function __construct( array $groups, Red_Group $current_group = null ) {
|
| 11 |
+
$this->groups = $groups;
|
| 12 |
+
$this->current_group = $current_group;
|
| 13 |
|
| 14 |
//Set parent defaults
|
| 15 |
parent::__construct( array(
|
| 19 |
) );
|
| 20 |
}
|
| 21 |
|
| 22 |
+
function get_columns(){
|
| 23 |
+
$columns = array(
|
| 24 |
+
'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
|
| 25 |
+
'type' => __( 'Type', 'redirection' ),
|
| 26 |
+
'url' => __( 'URL', 'redirection' ),
|
| 27 |
+
'hits' => __( 'Hits', 'redirection' ),
|
| 28 |
+
'last_access' => __( 'Last Access', 'redirection' ),
|
| 29 |
+
);
|
| 30 |
|
| 31 |
+
return $columns;
|
| 32 |
}
|
| 33 |
|
| 34 |
+
function column_type( $item ) {
|
| 35 |
+
return esc_html( $item->type() );
|
| 36 |
}
|
| 37 |
|
| 38 |
+
function column_last_access( $item ) {
|
| 39 |
+
if ( $item->last_access == 0 )
|
| 40 |
+
return '—';
|
| 41 |
+
return date_i18n( get_option( 'date_format' ), $item->last_access );
|
| 42 |
+
}
|
| 43 |
|
| 44 |
+
function column_hits( $item ) {
|
| 45 |
+
return esc_html( $item->last_count );
|
| 46 |
}
|
| 47 |
|
| 48 |
+
function column_url( $item ) {
|
| 49 |
$actions = array(
|
| 50 |
+
'edit' => sprintf( '<a class="red-ajax" data-action="%s" data-nonce="%s" data-id="%s" href="#">'.__( 'Edit', 'redirection' ).'</a>', 'red_redirect_edit', wp_create_nonce( 'red-edit_'.$item->get_id() ), $item->get_id() ),
|
| 51 |
+
'delete' => sprintf( '<a class="red-auto" data-action="%s" href="#">'.__( 'Delete', 'redirection' ).'</a>', 'delete', $item->get_id() ),
|
| 52 |
);
|
| 53 |
|
| 54 |
+
$before = $after = '';
|
| 55 |
+
if ( $item->is_enabled() )
|
| 56 |
+
$actions['disable'] = sprintf( '<a class="red-auto" data-action="%s" href="#">'.__( 'Disable', 'redirection' ).'</a>', 'disable', $item->get_id() );
|
| 57 |
+
else {
|
| 58 |
+
$actions['enable'] = sprintf( '<a class="red-auto" data-action="%s" href="#">'.__( 'Enable', 'redirection' ).'</a>', 'enable', $item->get_id() );
|
| 59 |
+
$before = '<span class="red-disabled">';
|
| 60 |
+
$after = '</span>';
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
return sprintf( '%1$s %2$s', $before.'<a href="'.esc_url( $item->url ).'">'.esc_html( $item->url ).'</a>'.$after, $this->row_actions( $actions ) );
|
| 64 |
}
|
| 65 |
|
| 66 |
function column_cb($item){
|
| 71 |
);
|
| 72 |
}
|
| 73 |
|
| 74 |
+
function get_row( $item ) {
|
| 75 |
+
ob_start();
|
| 76 |
+
|
| 77 |
+
$this->single_row( $item );
|
| 78 |
+
$output = ob_get_contents();
|
| 79 |
+
|
| 80 |
+
ob_end_clean();
|
| 81 |
+
|
| 82 |
+
return $output;
|
| 83 |
}
|
| 84 |
|
| 85 |
function get_sortable_columns() {
|
| 86 |
$sortable_columns = array(
|
|
|
|
| 87 |
'url' => array( 'url', false),
|
|
|
|
|
|
|
| 88 |
);
|
| 89 |
return $sortable_columns;
|
| 90 |
}
|
| 91 |
|
| 92 |
function get_bulk_actions() {
|
| 93 |
$actions = array(
|
| 94 |
+
'delete' => __( 'Delete', 'redirection' ),
|
| 95 |
+
'enable' => __( 'Enable', 'redirection' ),
|
| 96 |
+
'disable' => __( 'Disable', 'redirection' ),
|
| 97 |
+
'reset' => __( 'Reset Hits', 'redirection' ),
|
| 98 |
);
|
| 99 |
+
|
| 100 |
return $actions;
|
| 101 |
}
|
| 102 |
|
| 103 |
function process_bulk_action() {
|
| 104 |
+
if ( !isset( $_POST['item'] ) )
|
| 105 |
+
return;
|
| 106 |
+
|
| 107 |
+
if ( in_array( $this->current_action(), array( 'reset', 'enable', 'disable', 'delete' ) ) ) {
|
| 108 |
+
$redirections = array();
|
| 109 |
+
|
| 110 |
+
foreach( (array)$_POST['item'] AS $id ) {
|
| 111 |
+
$redirect = Red_Item::get_by_id( intval( $id ) );
|
| 112 |
+
if ( $redirect )
|
| 113 |
+
$redirections[] = $redirect;
|
| 114 |
}
|
| 115 |
+
|
| 116 |
+
array_map( function( $item ) {
|
| 117 |
+
if ( $this->current_action() == 'reset' )
|
| 118 |
+
$item->reset();
|
| 119 |
+
elseif ( $this->current_action() == 'enable' )
|
| 120 |
+
$item->enable();
|
| 121 |
+
elseif ( $this->current_action() == 'disable' )
|
| 122 |
+
$item->disable();
|
| 123 |
+
elseif ( $this->current_action() == 'delete' )
|
| 124 |
+
$item->delete();
|
| 125 |
+
}, $redirections );
|
| 126 |
+
|
| 127 |
+
Red_Module::flush( $this->current_group->module_id );
|
| 128 |
}
|
| 129 |
}
|
| 130 |
|
| 131 |
+
function extra_tablenav( $which ) {
|
| 132 |
+
if ( $which == 'bottom' )
|
| 133 |
+
return;
|
| 134 |
+
|
| 135 |
+
?>
|
| 136 |
+
<div class="alignleft actions">
|
| 137 |
+
<select name="id">
|
| 138 |
+
<?php foreach ( $this->groups AS $module_name => $groups ) : ?>
|
| 139 |
+
<optgroup label="<?php echo esc_attr( $module_name ); ?>">
|
| 140 |
+
<?php foreach ( $groups AS $group_name => $group ) : ?>
|
| 141 |
+
<option value="<?php echo esc_attr( $group_name ); ?>"<?php selected( $group_name, $this->current_group->get_id() ); ?>>
|
| 142 |
+
<?php echo esc_html( $group ); ?>
|
| 143 |
+
</option>
|
| 144 |
+
<?php endforeach; ?>
|
| 145 |
+
</optgroup>
|
| 146 |
+
<?php endforeach; ?>
|
| 147 |
+
</select>
|
| 148 |
+
|
| 149 |
+
<?php submit_button( __( 'Filter' ), 'button', false, false, array( 'id' => 'post-query-submit' ) ); ?>
|
| 150 |
+
</div>
|
| 151 |
+
<?php
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
function prepare_items( $type = '', $id = 0 ) {
|
| 155 |
global $wpdb, $current_user;
|
| 156 |
|
| 179 |
if ( isset( $_GET['s'] ) )
|
| 180 |
$where[] = $wpdb->prepare( 'url LIKE %s', '%'.like_escape( $_GET['s'] ).'%' );
|
| 181 |
|
| 182 |
+
if ( isset( $_REQUEST['id'] ) )
|
| 183 |
+
$where[] = $wpdb->prepare( "group_id=%d", intval( $_REQUEST['id'] ) );
|
| 184 |
+
|
| 185 |
$where_cond = "";
|
| 186 |
if ( count( $where ) > 0 )
|
| 187 |
$where_cond = " WHERE ".implode( ' AND ', $where );
|
| 188 |
|
| 189 |
+
$table = $wpdb->prefix.'redirection_items';
|
| 190 |
$rows = $wpdb->get_results( "SELECT * FROM {$table} ".$where_cond.$wpdb->prepare( " ORDER BY $orderby $order LIMIT %d,%d", ( $this->get_pagenum() - 1 ) * $per_page, $per_page ) );
|
| 191 |
+
$this->total_items = $wpdb->get_var( "SELECT COUNT(*) FROM {$table}".$where_cond );
|
| 192 |
|
| 193 |
$this->items = array();
|
| 194 |
foreach ( (array)$rows AS $row ) {
|
| 195 |
+
$this->items[] = new Red_Item( $row );
|
| 196 |
}
|
| 197 |
|
| 198 |
$this->set_pagination_args( array(
|
| 199 |
+
'total_items' => $this->total_items,
|
| 200 |
'per_page' => $per_page,
|
| 201 |
+
'total_pages' => ceil( $this->total_items / $per_page )
|
| 202 |
) );
|
| 203 |
}
|
| 204 |
}
|
| 205 |
|
| 206 |
+
class Redirection_Group_Table extends WP_List_Table {
|
| 207 |
+
private $modules;
|
| 208 |
+
private $current_module;
|
| 209 |
+
|
| 210 |
+
function __construct( $modules, $current_module ) {
|
| 211 |
+
$this->modules = $modules;
|
| 212 |
+
$this->current_module = $current_module;
|
| 213 |
+
|
| 214 |
+
//Set parent defaults
|
| 215 |
+
parent::__construct( array(
|
| 216 |
+
'singular' => 'item', //singular name of the listed records
|
| 217 |
+
'plural' => 'items', //plural name of the listed records
|
| 218 |
+
'ajax' => false //does this table support ajax?
|
| 219 |
+
) );
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
function get_columns(){
|
| 223 |
+
$columns = array(
|
| 224 |
+
'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
|
| 225 |
+
'name' => __( 'Name', 'redirection' ),
|
| 226 |
+
'redirects' => __( 'Redirects', 'redirection' ),
|
| 227 |
+
);
|
| 228 |
+
|
| 229 |
+
return $columns;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
function column_name( $item ) {
|
| 233 |
+
$actions = array(
|
| 234 |
+
'edit' => sprintf( '<a class="red-ajax" data-action="%s" data-nonce="%s" data-id="%s" href="#">'.__( 'Edit', 'redirection' ).'</a>', 'red_group_edit', wp_create_nonce( 'red-edit_'.$item->get_id() ), $item->get_id() ),
|
| 235 |
+
'delete' => sprintf( '<a class="red-auto" data-action="%s" href="#">'.__( 'Delete', 'redirection' ).'</a>', 'delete', $item->get_id() ),
|
| 236 |
+
'view' => '<a href="tools.php?page=redirection.php&id='.$item->get_id().'">'.__( 'View Redirects', 'redirection' ).'</a>',
|
| 237 |
+
);
|
| 238 |
+
|
| 239 |
+
$after = $before = '';
|
| 240 |
+
if ( $item->is_disabled() ) {
|
| 241 |
+
$before = '<span class="red-disabled">';
|
| 242 |
+
$after = '</span>';
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
return sprintf( '%1$s %2$s', $before.esc_html( $item->get_name() ).$after, $this->row_actions( $actions ) );
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
function column_redirects( $item ) {
|
| 249 |
+
return esc_html( $item->get_item_count() );
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
function column_cb($item){
|
| 253 |
+
return sprintf(
|
| 254 |
+
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
|
| 255 |
+
/*$1%s*/ $this->_args['singular'], //Let's simply repurpose the table's singular label ("movie")
|
| 256 |
+
/*$2%s*/ $item->id //The value of the checkbox should be the record's id
|
| 257 |
+
);
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
function get_sortable_columns() {
|
| 261 |
+
$sortable_columns = array(
|
| 262 |
+
'name' => array( 'name', false ),
|
| 263 |
+
);
|
| 264 |
+
|
| 265 |
+
return $sortable_columns;
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
function get_bulk_actions() {
|
| 269 |
+
$actions = array(
|
| 270 |
+
'delete' => __( 'Delete', 'redirection' ),
|
| 271 |
+
);
|
| 272 |
+
|
| 273 |
+
return $actions;
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
function process_bulk_action() {
|
| 277 |
+
if ( !isset( $_POST['item'] ) )
|
| 278 |
+
return;
|
| 279 |
+
|
| 280 |
+
if ( in_array( $this->current_action(), array( 'delete' ) ) ) {
|
| 281 |
+
$groups = array();
|
| 282 |
+
|
| 283 |
+
foreach( (array)$_POST['item'] AS $id ) {
|
| 284 |
+
$redirect = Red_Group::get( intval( $id ) );
|
| 285 |
+
if ( $redirect )
|
| 286 |
+
$groups[] = $redirect;
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
array_map( function( $item ) {
|
| 290 |
+
$item->delete();
|
| 291 |
+
}, $groups );
|
| 292 |
+
}
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
protected function extra_tablenav( $which ) {
|
| 296 |
+
if ( $which == 'bottom' )
|
| 297 |
+
return;
|
| 298 |
+
|
| 299 |
+
?>
|
| 300 |
+
<div class="alignleft actions">
|
| 301 |
+
<select name="id">
|
| 302 |
+
<?php foreach ( $this->modules AS $module_name => $module ) : ?>
|
| 303 |
+
<option value="<?php echo esc_attr( $module_name ); ?>"<?php selected( $module_name, $this->current_module ); ?>>
|
| 304 |
+
<?php echo esc_html( $module ); ?>
|
| 305 |
+
</option>
|
| 306 |
+
<?php endforeach; ?>
|
| 307 |
+
</select>
|
| 308 |
+
|
| 309 |
+
<?php submit_button( __( 'Filter' ), 'button', false, false, array( 'id' => 'post-query-submit' ) ); ?>
|
| 310 |
+
</div>
|
| 311 |
+
<?php
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
function prepare_items( $type = '', $id = 0 ) {
|
| 315 |
+
global $wpdb, $current_user;
|
| 316 |
+
|
| 317 |
+
$screen = get_current_screen();
|
| 318 |
+
$per_page = get_user_meta( $current_user->ID, $screen->get_option( 'per_page', 'option' ), true );
|
| 319 |
+
|
| 320 |
+
$per_page = $per_page ? $per_page : 25;
|
| 321 |
+
$columns = $this->get_columns();
|
| 322 |
+
$sortable = $this->get_sortable_columns();
|
| 323 |
+
|
| 324 |
+
$this->_column_headers = array( $columns, array(), $sortable );
|
| 325 |
+
|
| 326 |
+
// Process any stuff
|
| 327 |
+
$this->process_bulk_action();
|
| 328 |
+
|
| 329 |
+
$orderby = ( ! empty( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id';
|
| 330 |
+
$order = ( ! empty( $_GET['order'] ) ) ? strtolower( $_GET['order'] ) : 'desc';
|
| 331 |
+
|
| 332 |
+
if ( !in_array( $orderby, array_keys( $sortable ) ) )
|
| 333 |
+
$orderby = $wpdb->prefix.'redirection_groups.name';
|
| 334 |
+
|
| 335 |
+
if ( !in_array( $order, array( 'asc', 'desc' ) ) )
|
| 336 |
+
$order = 'desc';
|
| 337 |
+
|
| 338 |
+
$where = array();
|
| 339 |
+
if ( isset( $_GET['s'] ) )
|
| 340 |
+
$where[] = $wpdb->prepare( 'name LIKE %s', '%'.like_escape( $_GET['s'] ).'%' );
|
| 341 |
+
|
| 342 |
+
if ( isset( $_REQUEST['id'] ) )
|
| 343 |
+
$where[] = $wpdb->prepare( "module_id=%d", intval( $_REQUEST['id'] ) );
|
| 344 |
+
|
| 345 |
+
$where_cond = "";
|
| 346 |
+
if ( count( $where ) > 0 )
|
| 347 |
+
$where_cond = " WHERE ".implode( ' AND ', $where );
|
| 348 |
+
|
| 349 |
+
$table = $wpdb->prefix.'redirection_groups';
|
| 350 |
+
$rows = $wpdb->get_results( "SELECT * FROM {$table} ".$where_cond.$wpdb->prepare( " ORDER BY $orderby $order LIMIT %d,%d", ( $this->get_pagenum() - 1 ) * $per_page, $per_page ) );
|
| 351 |
+
$this->total_items = $wpdb->get_var( "SELECT COUNT(*) FROM {$table}".$where_cond );
|
| 352 |
+
|
| 353 |
+
$this->items = array();
|
| 354 |
+
foreach ( (array)$rows AS $row ) {
|
| 355 |
+
$this->items[] = new Red_Group( $row );
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
$this->set_pagination_args( array(
|
| 359 |
+
'total_items' => $this->total_items,
|
| 360 |
+
'per_page' => $per_page,
|
| 361 |
+
'total_pages' => ceil( $this->total_items / $per_page )
|
| 362 |
+
) );
|
| 363 |
+
}
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
class Redirection_Log_Table extends WP_List_Table {
|
| 367 |
private $lookup;
|
| 368 |
|
| 369 |
function __construct( $options ) {
|
| 378 |
}
|
| 379 |
|
| 380 |
function column_created( $item ) {
|
| 381 |
+
$actions = array();
|
| 382 |
|
| 383 |
+
if ( $item->sent_to == '' ) {
|
| 384 |
+
$actions['add'] = '<a href="'.esc_url( $item->url ).'" class="add-log">'.__( 'Add redirect', 'redirection' ).'</a>';
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
return sprintf( '%1$s %2$s', date_i18n( get_option( 'date_format' ), $item->created ).' '.gmdate( get_option( 'time_format' ), $item->created ), $this->row_actions( $actions ) );
|
| 388 |
}
|
| 389 |
|
| 390 |
function column_ip( $item ) {
|
| 391 |
+
return '<a href="'.esc_attr( $this->lookup ).esc_attr( $item->ip ).'">'.esc_html( $item->ip ).'</a>';
|
|
|
|
|
|
|
| 392 |
}
|
| 393 |
|
| 394 |
function column_url( $item ) {
|
| 395 |
+
$actions = array(
|
| 396 |
+
'target' => esc_html( $item->sent_to ),
|
| 397 |
+
);
|
| 398 |
+
|
| 399 |
+
return sprintf( '%1$s %2$s', '<a href="'.esc_url( $item->url ).'">'.esc_html( $item->show_url( $item->url ) ).'</a>', $this->row_actions( $actions ) );
|
| 400 |
}
|
| 401 |
|
| 402 |
function column_referrer( $item ) {
|
| 418 |
function get_columns(){
|
| 419 |
$columns = array(
|
| 420 |
'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
|
| 421 |
+
'created' => __( 'Date', 'redirection' ),
|
| 422 |
'url' => __( 'Source URL', 'redirection' ),
|
| 423 |
'referrer' => __( 'Referrer', 'redirection' ),
|
| 424 |
'ip' => __( 'IP', 'redirection' ),
|
| 428 |
|
| 429 |
function get_sortable_columns() {
|
| 430 |
$sortable_columns = array(
|
| 431 |
+
'created' => array( 'id', true ),
|
| 432 |
'url' => array( 'url', false),
|
| 433 |
'referrer' => array( 'referrer', false ),
|
| 434 |
+
'ip' => array( 'item_id', false ),
|
| 435 |
);
|
| 436 |
return $sortable_columns;
|
| 437 |
}
|
| 446 |
function process_bulk_action() {
|
| 447 |
if ( 'delete' === $this->current_action() ) {
|
| 448 |
foreach( $_POST['item'] AS $id ) {
|
| 449 |
+
RE_Log::delete( intval( $id ) );
|
| 450 |
}
|
| 451 |
}
|
| 452 |
}
|
| 453 |
|
| 454 |
+
function prepare_items( $type = '', $id = 0 ) {
|
| 455 |
global $wpdb, $current_user;
|
| 456 |
|
| 457 |
$screen = get_current_screen();
|
| 479 |
if ( isset( $_GET['s'] ) )
|
| 480 |
$where[] = $wpdb->prepare( 'url LIKE %s', '%'.like_escape( $_GET['s'] ).'%' );
|
| 481 |
|
|
|
|
|
|
|
|
|
|
| 482 |
$where_cond = "";
|
| 483 |
if ( count( $where ) > 0 )
|
| 484 |
$where_cond = " WHERE ".implode( ' AND ', $where );
|
| 485 |
|
| 486 |
+
$table = $wpdb->prefix.'redirection_logs';
|
| 487 |
$rows = $wpdb->get_results( "SELECT * FROM {$table} ".$where_cond.$wpdb->prepare( " ORDER BY $orderby $order LIMIT %d,%d", ( $this->get_pagenum() - 1 ) * $per_page, $per_page ) );
|
| 488 |
$total_items = $wpdb->get_var( "SELECT COUNT(*) FROM {$table}".$where_cond );
|
| 489 |
|
| 500 |
}
|
| 501 |
}
|
| 502 |
|
| 503 |
+
class Redirection_404_Table extends WP_List_Table {
|
| 504 |
private $lookup;
|
| 505 |
|
| 506 |
function __construct( $options ) {
|
| 507 |
+
$this->lookup = $options['lookup'];
|
| 508 |
+
|
| 509 |
//Set parent defaults
|
| 510 |
parent::__construct( array(
|
| 511 |
'singular' => 'item', //singular name of the listed records
|
| 514 |
) );
|
| 515 |
}
|
| 516 |
|
| 517 |
+
function column_created( $item ) {
|
| 518 |
+
$actions['add'] = '<a href="'.esc_url( $item->url ).'" class="add-log">'.__( 'Add redirect', 'redirection' ).'</a>';
|
| 519 |
|
| 520 |
+
return sprintf( '%1$s%2$s', date_i18n( get_option( 'date_format' ), $item->created ).'<br/>'.gmdate( get_option( 'time_format' ), $item->created ), $this->row_actions( $actions ) );
|
| 521 |
}
|
| 522 |
|
| 523 |
+
function column_ip( $item ) {
|
| 524 |
$actions['add'] = '<a href="'.admin_url( 'tools.php?page=redirection.php&sub=404s&ip='.esc_attr( long2ip( $item->ip ) ) ).'">'.__( 'Show only this IP', 'redirection' ).'</a>';
|
| 525 |
|
| 526 |
+
return sprintf( '%1$s %2$s', '<a href="'.esc_attr( $this->lookup ).esc_attr( long2ip( $item->ip ) ).'">'.long2ip( $item->ip ).'</a>', $this->row_actions( $actions ) );
|
| 527 |
+
}
|
| 528 |
+
|
| 529 |
+
function column_url( $item ) {
|
| 530 |
+
return '<a href="'.esc_url( $item->url ).'">'.esc_html( $item->show_url( $item->url ) ).'</a>';
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
function column_referrer( $item ) {
|
| 534 |
+
$actions = array(
|
| 535 |
+
'agent' => esc_html( $item->agent ),
|
| 536 |
+
);
|
| 537 |
+
|
| 538 |
+
return sprintf( '%1$s %2$s', '<a href="'.esc_url( $item->referrer ).'">'.esc_html( parse_url( $item->referrer, PHP_URL_HOST ) ).'</a>', $this->row_actions( $actions ) );
|
| 539 |
}
|
| 540 |
|
| 541 |
function column_cb($item){
|
| 549 |
function get_columns(){
|
| 550 |
$columns = array(
|
| 551 |
'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
|
| 552 |
+
'created' => __( 'Date', 'redirection' ),
|
| 553 |
+
'url' => __( 'Source URL', 'redirection' ),
|
| 554 |
+
'referrer' => __( 'Referrer', 'redirection' ),
|
| 555 |
+
'ip' => __( 'IP', 'redirection' ),
|
| 556 |
);
|
| 557 |
return $columns;
|
| 558 |
}
|
| 559 |
|
| 560 |
function get_sortable_columns() {
|
| 561 |
$sortable_columns = array(
|
| 562 |
+
'created' => array( 'id', true ),
|
| 563 |
+
'url' => array( 'url', false),
|
| 564 |
+
'referrer' => array( 'referrer', false ),
|
| 565 |
);
|
| 566 |
return $sortable_columns;
|
| 567 |
}
|
| 576 |
function process_bulk_action() {
|
| 577 |
if ( 'delete' === $this->current_action() ) {
|
| 578 |
foreach( $_POST['item'] AS $id ) {
|
| 579 |
+
RE_404::delete( intval( $id ) );
|
| 580 |
}
|
| 581 |
}
|
| 582 |
}
|
| 584 |
function prepare_items( $restrict_by_ip = false ) {
|
| 585 |
global $wpdb, $current_user;
|
| 586 |
|
| 587 |
+
$screen = get_current_screen();
|
| 588 |
$per_page = get_user_meta( $current_user->ID, $screen->get_option( 'per_page', 'option' ), true );
|
| 589 |
|
| 590 |
+
$per_page = $per_page ? $per_page : 25;
|
| 591 |
+
$columns = $this->get_columns();
|
| 592 |
+
$sortable = $this->get_sortable_columns();
|
|
|
|
| 593 |
|
| 594 |
$this->_column_headers = array( $columns, array(), $sortable );
|
| 595 |
|
| 605 |
if ( !in_array( $order, array( 'asc', 'desc' ) ) )
|
| 606 |
$order = 'desc';
|
| 607 |
|
| 608 |
+
$where = array();
|
| 609 |
+
if ( isset( $_GET['s'] ) )
|
| 610 |
+
$where[] = $wpdb->prepare( 'url LIKE %s', '%'.like_escape( $_GET['s'] ).'%' );
|
| 611 |
|
| 612 |
+
if ( $restrict_by_ip !== false )
|
| 613 |
+
$where[] = $wpdb->prepare( 'ip=INET_ATON(%s)', $restrict_by_ip );
|
| 614 |
+
|
| 615 |
+
$where_cond = "";
|
| 616 |
+
if ( count( $where ) > 0 )
|
| 617 |
+
$where_cond = " WHERE ".implode( ' AND ', $where );
|
| 618 |
+
|
| 619 |
+
$table = $wpdb->prefix.'redirection_404';
|
| 620 |
$rows = $wpdb->get_results( "SELECT * FROM {$table} ".$where_cond.$wpdb->prepare( " ORDER BY $orderby $order LIMIT %d,%d", ( $this->get_pagenum() - 1 ) * $per_page, $per_page ) );
|
| 621 |
$total_items = $wpdb->get_var( "SELECT COUNT(*) FROM {$table}".$where_cond );
|
| 622 |
|
| 633 |
}
|
| 634 |
}
|
| 635 |
|
| 636 |
+
class Redirection_Module_Table extends WP_List_Table {
|
| 637 |
+
function __construct() {
|
| 638 |
+
//Set parent defaults
|
| 639 |
+
parent::__construct( array(
|
| 640 |
+
'singular' => 'item', //singular name of the listed records
|
| 641 |
+
'plural' => 'items', //plural name of the listed records
|
| 642 |
+
'ajax' => false //does this table support ajax?
|
| 643 |
+
) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 644 |
}
|
| 645 |
|
| 646 |
+
function get_columns() {
|
| 647 |
+
$columns = array(
|
| 648 |
+
'moduletype' => __( 'Type', 'redirection' ),
|
| 649 |
+
'name' => __( 'Name', 'redirection' ),
|
| 650 |
+
'groups' => __( 'Groups', 'redirection' ),
|
| 651 |
+
'hits' => __( 'Hits', 'redirection' ),
|
| 652 |
+
);
|
| 653 |
|
| 654 |
+
return $columns;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 655 |
}
|
| 656 |
|
| 657 |
+
function column_groups( $item ) {
|
| 658 |
+
return esc_html( $item->groups() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 659 |
}
|
| 660 |
|
| 661 |
+
function column_hits( $item ) {
|
| 662 |
+
return esc_html( $item->hits() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 663 |
}
|
| 664 |
|
| 665 |
+
function column_moduletype( $item ) {
|
| 666 |
+
return esc_html( $item->get_type_string() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 667 |
}
|
| 668 |
|
| 669 |
+
function column_name( $item ) {
|
| 670 |
+
$actions['edit'] = sprintf( '<a href="#" class="red-ajax" data-action="%s" data-nonce="%s" data-id="%s">'.__( 'Edit', 'redirection' ).'</a>', 'red_module_edit', wp_create_nonce( 'red_edit-'.$item->get_id() ), $item->get_id() );
|
| 671 |
|
| 672 |
+
return '<a href="#" data-action="%s" data-nonce="%s" data-id="%s">'.esc_html( $item->get_name() ).'</a>'.$this->row_actions( $actions );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 673 |
}
|
| 674 |
|
| 675 |
+
function prepare_items( $type = '', $id = 0 ) {
|
| 676 |
+
global $wpdb;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 677 |
|
| 678 |
+
$table = $wpdb->prefix.'redirection_modules';
|
| 679 |
+
$rows = $wpdb->get_results( "SELECT * FROM {$table}" );
|
| 680 |
+
$this->total_items = $wpdb->get_var( "SELECT COUNT(*) FROM {$table}" );
|
|
|
|
| 681 |
|
| 682 |
+
$columns = $this->get_columns();
|
| 683 |
+
$sortable = $this->get_sortable_columns();
|
|
|
|
| 684 |
|
| 685 |
+
$this->_column_headers = array( $columns, array(), $sortable );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 686 |
|
| 687 |
+
$this->items = array();
|
| 688 |
+
foreach ( (array)$rows AS $row ) {
|
| 689 |
+
$this->items[] = Red_Module::new_item( $row );
|
|
|
|
| 690 |
}
|
| 691 |
|
| 692 |
+
$this->set_pagination_args( array(
|
| 693 |
+
'total_items' => $this->total_items,
|
| 694 |
+
'per_page' => 100,
|
| 695 |
+
'total_pages' => ceil( $this->total_items / 100 )
|
| 696 |
+
) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 697 |
}
|
| 698 |
}
|
models/redirect.php
CHANGED
|
@@ -32,6 +32,8 @@ class Red_Item {
|
|
| 32 |
var $last_count = 0;
|
| 33 |
|
| 34 |
var $tracking = true;
|
|
|
|
|
|
|
| 35 |
|
| 36 |
function Red_Item( $values, $type = '', $match = '' ) {
|
| 37 |
if ( is_object( $values ) ) {
|
|
@@ -64,6 +66,18 @@ class Red_Item {
|
|
| 64 |
}
|
| 65 |
}
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
static function get_all_for_module( $module ) {
|
| 68 |
global $wpdb;
|
| 69 |
|
|
@@ -170,14 +184,17 @@ class Red_Item {
|
|
| 170 |
return $url;
|
| 171 |
}
|
| 172 |
|
| 173 |
-
static function create( $details ) {
|
| 174 |
global $wpdb;
|
| 175 |
|
|
|
|
|
|
|
|
|
|
| 176 |
// Auto generate URLs
|
| 177 |
-
if ( $details['source']
|
| 178 |
$details['source'] = self::auto_generate();
|
| 179 |
|
| 180 |
-
if ( $details['target']
|
| 181 |
$details['target'] = self::auto_generate();
|
| 182 |
|
| 183 |
// Make sure we don't redirect to ourself
|
|
@@ -239,16 +256,16 @@ class Red_Item {
|
|
| 239 |
|
| 240 |
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_items WHERE group_id=%d", $group ) );
|
| 241 |
|
| 242 |
-
$group = Red_Group::get( $
|
| 243 |
Red_Module::flush( $group->module_id );
|
| 244 |
}
|
| 245 |
|
| 246 |
-
|
| 247 |
global $wpdb;
|
| 248 |
|
| 249 |
-
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_items WHERE id=%d", $id ) );
|
| 250 |
|
| 251 |
-
RE_Log::delete_for_id( $id );
|
| 252 |
|
| 253 |
// Reorder all elements
|
| 254 |
$rows = $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}redirection_items ORDER BY position" );
|
|
@@ -275,6 +292,8 @@ class Red_Item {
|
|
| 275 |
if ( strlen( $details['old'] ) > 0 ) {
|
| 276 |
global $wpdb;
|
| 277 |
|
|
|
|
|
|
|
| 278 |
$this->regex = isset( $details['regex'] ) ? 1 : 0;
|
| 279 |
$this->url = self::sanitize_url( $details['old'], $this->regex );
|
| 280 |
$this->title = $details['title'];
|
|
@@ -289,7 +308,6 @@ class Red_Item {
|
|
| 289 |
$this->group_id = intval( $details['group_id'] );
|
| 290 |
|
| 291 |
// Save this
|
| 292 |
-
global $wpdb;
|
| 293 |
$wpdb->update( $wpdb->prefix.'redirection_items', array( 'url' => $this->url, 'regex' => $this->regex, 'action_code' => $this->action_code, 'action_data' => $data, 'group_id' => $this->group_id, 'title' => $this->title ), array( 'id' => $this->id ) );
|
| 294 |
|
| 295 |
$group = Red_Group::get( $this->group_id );
|
|
@@ -367,6 +385,10 @@ class Red_Item {
|
|
| 367 |
}
|
| 368 |
}
|
| 369 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
function reset() {
|
| 371 |
global $wpdb;
|
| 372 |
|
|
@@ -388,10 +410,17 @@ class Red_Item {
|
|
| 388 |
$wpdb->update( $wpdb->prefix.'redirection_items', array( 'group_id' => $group ), array( 'id' => $this->id ) );
|
| 389 |
}
|
| 390 |
|
| 391 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 392 |
global $wpdb;
|
| 393 |
|
| 394 |
-
$this->status =
|
| 395 |
$wpdb->update( $wpdb->prefix.'redirection_items', array( 'status' => $this->status ), array( 'id' => $this->id ) );
|
| 396 |
}
|
| 397 |
|
| 32 |
var $last_count = 0;
|
| 33 |
|
| 34 |
var $tracking = true;
|
| 35 |
+
private $status;
|
| 36 |
+
private $position;
|
| 37 |
|
| 38 |
function Red_Item( $values, $type = '', $match = '' ) {
|
| 39 |
if ( is_object( $values ) ) {
|
| 66 |
}
|
| 67 |
}
|
| 68 |
|
| 69 |
+
public function get_id() {
|
| 70 |
+
return $this->id;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
public function get_position() {
|
| 74 |
+
return $this->position;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
public function get_action_code() {
|
| 78 |
+
return $this->action_code;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
static function get_all_for_module( $module ) {
|
| 82 |
global $wpdb;
|
| 83 |
|
| 184 |
return $url;
|
| 185 |
}
|
| 186 |
|
| 187 |
+
static function create( array $details ) {
|
| 188 |
global $wpdb;
|
| 189 |
|
| 190 |
+
$details = array_map( 'trim', $details );
|
| 191 |
+
$details = array_map( 'stripslashes', $details );
|
| 192 |
+
|
| 193 |
// Auto generate URLs
|
| 194 |
+
if ( empty( $details['source'] ) )
|
| 195 |
$details['source'] = self::auto_generate();
|
| 196 |
|
| 197 |
+
if ( empty( $details['target'] ) )
|
| 198 |
$details['target'] = self::auto_generate();
|
| 199 |
|
| 200 |
// Make sure we don't redirect to ourself
|
| 256 |
|
| 257 |
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_items WHERE group_id=%d", $group ) );
|
| 258 |
|
| 259 |
+
$group = Red_Group::get( $wpdb->insert_id );
|
| 260 |
Red_Module::flush( $group->module_id );
|
| 261 |
}
|
| 262 |
|
| 263 |
+
public function delete() {
|
| 264 |
global $wpdb;
|
| 265 |
|
| 266 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}redirection_items WHERE id=%d", $this->id ) );
|
| 267 |
|
| 268 |
+
RE_Log::delete_for_id( $this->id );
|
| 269 |
|
| 270 |
// Reorder all elements
|
| 271 |
$rows = $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}redirection_items ORDER BY position" );
|
| 292 |
if ( strlen( $details['old'] ) > 0 ) {
|
| 293 |
global $wpdb;
|
| 294 |
|
| 295 |
+
$details = array_map( 'stripslashes', $details );
|
| 296 |
+
|
| 297 |
$this->regex = isset( $details['regex'] ) ? 1 : 0;
|
| 298 |
$this->url = self::sanitize_url( $details['old'], $this->regex );
|
| 299 |
$this->title = $details['title'];
|
| 308 |
$this->group_id = intval( $details['group_id'] );
|
| 309 |
|
| 310 |
// Save this
|
|
|
|
| 311 |
$wpdb->update( $wpdb->prefix.'redirection_items', array( 'url' => $this->url, 'regex' => $this->regex, 'action_code' => $this->action_code, 'action_data' => $data, 'group_id' => $this->group_id, 'title' => $this->title ), array( 'id' => $this->id ) );
|
| 312 |
|
| 313 |
$group = Red_Group::get( $this->group_id );
|
| 385 |
}
|
| 386 |
}
|
| 387 |
|
| 388 |
+
public function is_enabled() {
|
| 389 |
+
return $this->status == 'enabled';
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
function reset() {
|
| 393 |
global $wpdb;
|
| 394 |
|
| 410 |
$wpdb->update( $wpdb->prefix.'redirection_items', array( 'group_id' => $group ), array( 'id' => $this->id ) );
|
| 411 |
}
|
| 412 |
|
| 413 |
+
function enable() {
|
| 414 |
+
global $wpdb;
|
| 415 |
+
|
| 416 |
+
$this->status = true;
|
| 417 |
+
$wpdb->update( $wpdb->prefix.'redirection_items', array( 'status' => $this->status ), array( 'id' => $this->id ) );
|
| 418 |
+
}
|
| 419 |
+
|
| 420 |
+
function disable() {
|
| 421 |
global $wpdb;
|
| 422 |
|
| 423 |
+
$this->status = false;
|
| 424 |
$wpdb->update( $wpdb->prefix.'redirection_items', array( 'status' => $this->status ), array( 'id' => $this->id ) );
|
| 425 |
}
|
| 426 |
|
modules/apache.php
CHANGED
|
@@ -53,16 +53,15 @@ class Apache_Module extends Red_Module
|
|
| 53 |
|
| 54 |
function save ($data)
|
| 55 |
{
|
| 56 |
-
$save = array
|
| 57 |
-
|
| 58 |
-
'
|
| 59 |
-
'
|
| 60 |
-
'
|
| 61 |
-
'
|
| 62 |
-
'
|
| 63 |
-
'
|
| 64 |
-
'
|
| 65 |
-
'raw' => $data['raw'],
|
| 66 |
'site' => preg_replace ('@https?://@', '', $data['site'])
|
| 67 |
);
|
| 68 |
|
|
@@ -184,4 +183,8 @@ class Apache_Module extends Red_Module
|
|
| 184 |
|
| 185 |
echo '<small>'.ucfirst (implode (', ', $options)).'</small>';
|
| 186 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
}
|
| 53 |
|
| 54 |
function save ($data)
|
| 55 |
{
|
| 56 |
+
$save = array (
|
| 57 |
+
'location' => isset( $data['location'] ) ? $data['location'] : false,
|
| 58 |
+
'canonical' => isset( $data['canonical'] ) ? $data['canonical'] : false,
|
| 59 |
+
'strip_index' => isset( $data['strip_index'] ) ? $data['strip_index'] : false,
|
| 60 |
+
'memory_limit' => isset( $data['memory_limit'] ) ? $data['memory_limit'] : false,
|
| 61 |
+
'error_level' => isset( $data['error_level'] ) ? $data['error_level'] : false,
|
| 62 |
+
'ban_ip' => isset( $data['ban_ip'] ) ? $data['ban_ip'] : false,
|
| 63 |
+
'allow_ip' => isset( $data['allow_ip'] ) ? $data['allow_ip'] : false,
|
| 64 |
+
'raw' => isset( $data['raw'] ) ? $data['raw'] : false,
|
|
|
|
| 65 |
'site' => preg_replace ('@https?://@', '', $data['site'])
|
| 66 |
);
|
| 67 |
|
| 183 |
|
| 184 |
echo '<small>'.ucfirst (implode (', ', $options)).'</small>';
|
| 185 |
}
|
| 186 |
+
|
| 187 |
+
public function get_type_string() {
|
| 188 |
+
return __( 'Apache', 'redirection' );
|
| 189 |
+
}
|
| 190 |
}
|
modules/wordpress.php
CHANGED
|
@@ -115,4 +115,8 @@ class WordPress_Module extends Red_Module {
|
|
| 115 |
if ( !$this->is_valid() )
|
| 116 |
echo __( '<strong>Disabled: You must enable <a href="options-permalink.php">permalinks</a> before using this</strong>', 'redirection' );
|
| 117 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
}
|
| 115 |
if ( !$this->is_valid() )
|
| 116 |
echo __( '<strong>Disabled: You must enable <a href="options-permalink.php">permalinks</a> before using this</strong>', 'redirection' );
|
| 117 |
}
|
| 118 |
+
|
| 119 |
+
public function get_type_string() {
|
| 120 |
+
return __( 'WordPress', 'redirection' );
|
| 121 |
+
}
|
| 122 |
}
|
readme.txt
CHANGED
|
@@ -3,8 +3,8 @@ Contributors: johnny5
|
|
| 3 |
Donate link: http://urbangiraffe.com/about/
|
| 4 |
Tags: post, admin, seo, pages, manage, 301, 404, redirect, permalink
|
| 5 |
Requires at least: 3.2
|
| 6 |
-
Tested up to: 4.
|
| 7 |
-
Stable tag: 2.3.
|
| 8 |
|
| 9 |
Redirection is a WordPress plugin to manage 301 redirections and keep track of 404 errors without requiring knowledge of Apache .htaccess files.
|
| 10 |
|
|
@@ -51,12 +51,14 @@ Redirection is available in:
|
|
| 51 |
* Dutch by Marlon Navas, Pieter Carette, and Bart Kummel
|
| 52 |
* Hungarian by daSSad and Szépe Viktor
|
| 53 |
* Turkish by Fatih Cevik
|
| 54 |
-
* Romanian translation, thanks to
|
| 55 |
* Greek, thanks to Stefanos Kofopoulos
|
| 56 |
* Belarusian, thanks to Alexander Ovsov
|
| 57 |
* Czech, thanks to Martin Jurica
|
| 58 |
* Danish, thanks to Rasmus Himmelstrup
|
| 59 |
|
|
|
|
|
|
|
| 60 |
== Installation ==
|
| 61 |
|
| 62 |
The plugin is simple to install:
|
|
@@ -69,6 +71,8 @@ The plugin is simple to install:
|
|
| 69 |
|
| 70 |
You can find full details of installing a plugin on the [plugin installation page](http://urbangiraffe.com/articles/how-to-install-a-wordpress-plugin/).
|
| 71 |
|
|
|
|
|
|
|
| 72 |
== Frequently Asked Questions ==
|
| 73 |
|
| 74 |
= Why would I want to use this instead of .htaccess? =
|
|
@@ -79,15 +83,6 @@ Ease of use. Redirections are automatically created when a post URL changes, an
|
|
| 79 |
|
| 80 |
The plugin works in a similar manner to how WordPress handles permalinks and should not result in any noticeable slowdown to your site.
|
| 81 |
|
| 82 |
-
== Screenshots ==
|
| 83 |
-
|
| 84 |
-
1. Simple interface to add a redirection
|
| 85 |
-
2. A graphical interface to manage all your redirections
|
| 86 |
-
|
| 87 |
-
== Documentation ==
|
| 88 |
-
|
| 89 |
-
Full documentation can be found on the [Redirection](http://urbangiraffe.com/plugins/redirection/) page.
|
| 90 |
-
|
| 91 |
== Upgrade Notice ==
|
| 92 |
|
| 93 |
= 2.3.3 =
|
|
@@ -95,6 +90,18 @@ Full documentation can be found on the [Redirection](http://urbangiraffe.com/plu
|
|
| 95 |
|
| 96 |
== Changelog ==
|
| 97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
= 2.3.6 =
|
| 99 |
* Updated Italian translation, props to Raffaello Tesi
|
| 100 |
* Updated Romanian translation, props to Flo Bejgu
|
| 3 |
Donate link: http://urbangiraffe.com/about/
|
| 4 |
Tags: post, admin, seo, pages, manage, 301, 404, redirect, permalink
|
| 5 |
Requires at least: 3.2
|
| 6 |
+
Tested up to: 4.1
|
| 7 |
+
Stable tag: 2.3.8
|
| 8 |
|
| 9 |
Redirection is a WordPress plugin to manage 301 redirections and keep track of 404 errors without requiring knowledge of Apache .htaccess files.
|
| 10 |
|
| 51 |
* Dutch by Marlon Navas, Pieter Carette, and Bart Kummel
|
| 52 |
* Hungarian by daSSad and Szépe Viktor
|
| 53 |
* Turkish by Fatih Cevik
|
| 54 |
+
* Romanian translation, thanks to InboxTranslations
|
| 55 |
* Greek, thanks to Stefanos Kofopoulos
|
| 56 |
* Belarusian, thanks to Alexander Ovsov
|
| 57 |
* Czech, thanks to Martin Jurica
|
| 58 |
* Danish, thanks to Rasmus Himmelstrup
|
| 59 |
|
| 60 |
+
Please submit bugs and patches to https://github.com/johngodley/redirection
|
| 61 |
+
|
| 62 |
== Installation ==
|
| 63 |
|
| 64 |
The plugin is simple to install:
|
| 71 |
|
| 72 |
You can find full details of installing a plugin on the [plugin installation page](http://urbangiraffe.com/articles/how-to-install-a-wordpress-plugin/).
|
| 73 |
|
| 74 |
+
Full documentation can be found on the [Redirection](http://urbangiraffe.com/plugins/redirection/) page.
|
| 75 |
+
|
| 76 |
== Frequently Asked Questions ==
|
| 77 |
|
| 78 |
= Why would I want to use this instead of .htaccess? =
|
| 83 |
|
| 84 |
The plugin works in a similar manner to how WordPress handles permalinks and should not result in any noticeable slowdown to your site.
|
| 85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
== Upgrade Notice ==
|
| 87 |
|
| 88 |
= 2.3.3 =
|
| 90 |
|
| 91 |
== Changelog ==
|
| 92 |
|
| 93 |
+
= 2.3.8 =
|
| 94 |
+
* Fix plugin activation error
|
| 95 |
+
* Fix fatal error in table nav, props to spacedmonkey
|
| 96 |
+
|
| 97 |
+
= 2.3.7 =
|
| 98 |
+
* New redirect page to match WP style
|
| 99 |
+
* New module page to match WP style
|
| 100 |
+
* Configurable permissions via redirection_role filter, props to RodGer-GR
|
| 101 |
+
* Fix saving 2 month log period
|
| 102 |
+
* Fix importer
|
| 103 |
+
* Fix DB creation to check for existing tables
|
| 104 |
+
|
| 105 |
= 2.3.6 =
|
| 106 |
* Updated Italian translation, props to Raffaello Tesi
|
| 107 |
* Updated Romanian translation, props to Flo Bejgu
|
redirection.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
Plugin Name: Redirection
|
| 4 |
Plugin URI: http://urbangiraffe.com/plugins/redirection/
|
| 5 |
Description: Manage all your 301 redirects and monitor 404 errors
|
| 6 |
-
Version: 2.3.
|
| 7 |
Author: John Godley
|
| 8 |
Author URI: http://urbangiraffe.com
|
| 9 |
============================================================================================================
|
|
@@ -43,23 +43,24 @@ class Redirection extends Redirection_Plugin {
|
|
| 43 |
if ( is_admin() ) {
|
| 44 |
$this->add_action( 'admin_menu' );
|
| 45 |
$this->add_action( 'load-tools_page_redirection', 'redirection_head' );
|
| 46 |
-
$this->add_action( 'init', 'inject' );
|
| 47 |
|
| 48 |
add_filter( 'set-screen-option', array( $this, 'set_per_page' ), 10, 3 );
|
| 49 |
add_action( 'redirection_log_delete', array( $this, 'expire_logs' ) );
|
| 50 |
|
| 51 |
-
$this->register_activation( __FILE__ );
|
| 52 |
$this->register_plugin_settings( __FILE__ );
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
}
|
| 60 |
else {
|
| 61 |
-
$this->update();
|
| 62 |
-
|
| 63 |
// Create a WordPress exporter and let it handle the load
|
| 64 |
$this->wp = new WordPress_Module();
|
| 65 |
$this->wp->start();
|
|
@@ -75,8 +76,8 @@ class Redirection extends Redirection_Plugin {
|
|
| 75 |
if ( $version != REDIRECTION_VERSION ) {
|
| 76 |
include_once dirname( __FILE__ ).'/models/database.php';
|
| 77 |
|
| 78 |
-
$
|
| 79 |
-
return $
|
| 80 |
}
|
| 81 |
|
| 82 |
return true;
|
|
@@ -88,14 +89,6 @@ class Redirection extends Redirection_Plugin {
|
|
| 88 |
return $status;
|
| 89 |
}
|
| 90 |
|
| 91 |
-
function activate() {
|
| 92 |
-
if ( $this->update() === false ) {
|
| 93 |
-
$db = new RE_Database();
|
| 94 |
-
$db->remove( $version, REDIRECTION_VERSION );
|
| 95 |
-
exit();
|
| 96 |
-
}
|
| 97 |
-
}
|
| 98 |
-
|
| 99 |
function plugin_settings( $links ) {
|
| 100 |
$settings_link = '<a href="tools.php?page='.basename( __FILE__ ).'">'.__( 'Settings', 'redirection' ).'</a>';
|
| 101 |
array_unshift( $links, $settings_link );
|
|
@@ -111,18 +104,18 @@ class Redirection extends Redirection_Plugin {
|
|
| 111 |
}
|
| 112 |
|
| 113 |
function redirection_head() {
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
add_screen_option( 'per_page', array( 'label' => __( 'Log entries', 'redirection' ), 'default' => 25, 'option' => 'redirection_log_per_page' ) );
|
| 116 |
|
| 117 |
wp_enqueue_script( 'redirection', plugin_dir_url( __FILE__ ).'js/redirection.js', array( 'jquery-form', 'jquery-ui-sortable' ), $this->version() );
|
| 118 |
wp_enqueue_style( 'redirection', plugin_dir_url( __FILE__ ).'admin.css', $this->version() );
|
| 119 |
|
| 120 |
wp_localize_script( 'redirection', 'Redirectioni10n', array(
|
| 121 |
-
'
|
| 122 |
-
'type' => 1,
|
| 123 |
-
'progress' => '<img src="'.plugin_dir_url( __FILE__ ).'/images/progress.gif" alt="loading" width="50" height="16"/>',
|
| 124 |
-
'are_you_sure' => __( 'Are you sure?', 'redirection' ),
|
| 125 |
-
'none_select' => __( 'No items have been selected', 'redirection' )
|
| 126 |
) );
|
| 127 |
}
|
| 128 |
|
|
@@ -190,8 +183,10 @@ class Redirection extends Redirection_Plugin {
|
|
| 190 |
}
|
| 191 |
|
| 192 |
function admin_screen_modules() {
|
| 193 |
-
$
|
| 194 |
-
$
|
|
|
|
|
|
|
| 195 |
}
|
| 196 |
|
| 197 |
function get_options() {
|
|
@@ -235,6 +230,11 @@ class Redirection extends Redirection_Plugin {
|
|
| 235 |
function inject() {
|
| 236 |
$options = $this->get_options();
|
| 237 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
if ( isset( $_GET['token'] ) && isset( $_GET['page'] ) && isset( $_GET['sub'] ) && $_GET['token'] == $options['token'] && $_GET['page'] == 'redirection.php' ) {
|
| 239 |
include dirname( __FILE__ ).'/models/file_io.php';
|
| 240 |
|
|
@@ -269,8 +269,8 @@ class Redirection extends Redirection_Plugin {
|
|
| 269 |
$options['auto_target'] = stripslashes( $_POST['auto_target'] );
|
| 270 |
$options['support'] = isset( $_POST['support'] ) ? true : false;
|
| 271 |
$options['token'] = stripslashes( $_POST['token'] );
|
| 272 |
-
$options['expire_redirect'] = min( intval( $_POST['expire_redirect'] ),
|
| 273 |
-
$options['expire_404'] = min( intval( $_POST['expire_404'] ),
|
| 274 |
|
| 275 |
if ( trim( $options['token'] ) == '' )
|
| 276 |
$options['token'] = md5( uniqid() );
|
|
@@ -282,7 +282,7 @@ class Redirection extends Redirection_Plugin {
|
|
| 282 |
elseif ( isset( $_POST['delete'] ) && check_admin_referer( 'redirection-delete_plugin' ) ) {
|
| 283 |
include dirname( __FILE__ ).'/models/database.php';
|
| 284 |
|
| 285 |
-
$db = new RE_Database;
|
| 286 |
$db->remove( __FILE__ );
|
| 287 |
|
| 288 |
$this->render_message( __( 'Redirection data has been deleted and the plugin disabled', 'redirection' ) );
|
|
@@ -291,9 +291,8 @@ class Redirection extends Redirection_Plugin {
|
|
| 291 |
elseif ( isset( $_POST['import'] ) && check_admin_referer( 'redirection-import' ) ) {
|
| 292 |
include dirname( __FILE__ ).'/models/file_io.php';
|
| 293 |
|
| 294 |
-
$
|
| 295 |
|
| 296 |
-
$count = $importer->import( $_POST['group'], $_FILES['upload'] );
|
| 297 |
if ( $count > 0 )
|
| 298 |
$this->render_message( sprintf( _n( '%d redirection was successfully imported','%d redirections were successfully imported', $count, 'redirection' ), $count ) );
|
| 299 |
else
|
|
@@ -305,8 +304,6 @@ class Redirection extends Redirection_Plugin {
|
|
| 305 |
}
|
| 306 |
|
| 307 |
function admin_screen_log() {
|
| 308 |
-
include dirname( __FILE__ ).'/models/pager.php';
|
| 309 |
-
|
| 310 |
$options = $this->get_options();
|
| 311 |
|
| 312 |
if ( isset( $_POST['delete-all'] ) && check_admin_referer( 'redirection-log_management' ) ) {
|
|
@@ -329,8 +326,6 @@ class Redirection extends Redirection_Plugin {
|
|
| 329 |
}
|
| 330 |
|
| 331 |
function admin_screen_404() {
|
| 332 |
-
include dirname( __FILE__ ).'/models/pager.php';
|
| 333 |
-
|
| 334 |
if ( isset( $_POST['delete-all'] ) && check_admin_referer( 'redirection-log_management' ) ) {
|
| 335 |
RE_404::delete_all();
|
| 336 |
$this->render_message( __( 'Your logs have been deleted', 'redirection' ) );
|
|
@@ -345,8 +340,6 @@ class Redirection extends Redirection_Plugin {
|
|
| 345 |
}
|
| 346 |
|
| 347 |
function admin_groups( $module ) {
|
| 348 |
-
include dirname( __FILE__ ).'/models/pager.php';
|
| 349 |
-
|
| 350 |
if ( isset( $_POST['add'] ) && check_admin_referer( 'redirection-add_group' ) ) {
|
| 351 |
if ( Red_Group::create( stripslashes_deep( $_POST ) ) ) {
|
| 352 |
$this->render_message( __( 'Your group was added successfully', 'redirection' ) );
|
|
@@ -359,26 +352,26 @@ class Redirection extends Redirection_Plugin {
|
|
| 359 |
if ( $module == 0 )
|
| 360 |
$module = Red_Module::get_first_id();
|
| 361 |
|
| 362 |
-
$
|
| 363 |
-
$
|
| 364 |
|
| 365 |
$module = Red_Module::get( $module );
|
| 366 |
if ( $module )
|
| 367 |
-
$this->render_admin( 'group_list', array( 'options' => $this->get_options(), '
|
| 368 |
else
|
| 369 |
$this->render_message( __( 'Unknown module', 'redirection' ) );
|
| 370 |
}
|
| 371 |
|
| 372 |
-
function admin_redirects( $
|
| 373 |
-
|
|
|
|
| 374 |
|
| 375 |
-
|
| 376 |
-
$group = Red_Group::get_first_id();
|
| 377 |
|
| 378 |
-
$
|
| 379 |
-
$
|
| 380 |
|
| 381 |
-
$this->render_admin( 'item_list', array( 'options' => $this->get_options(), '
|
| 382 |
}
|
| 383 |
|
| 384 |
function setMatched( $match ) {
|
|
@@ -420,6 +413,160 @@ class Redirection extends Redirection_Plugin {
|
|
| 420 |
}
|
| 421 |
}
|
| 422 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 423 |
}
|
| 424 |
|
| 425 |
function red_get_url() {
|
| 3 |
Plugin Name: Redirection
|
| 4 |
Plugin URI: http://urbangiraffe.com/plugins/redirection/
|
| 5 |
Description: Manage all your 301 redirects and monitor 404 errors
|
| 6 |
+
Version: 2.3.8
|
| 7 |
Author: John Godley
|
| 8 |
Author URI: http://urbangiraffe.com
|
| 9 |
============================================================================================================
|
| 43 |
if ( is_admin() ) {
|
| 44 |
$this->add_action( 'admin_menu' );
|
| 45 |
$this->add_action( 'load-tools_page_redirection', 'redirection_head' );
|
|
|
|
| 46 |
|
| 47 |
add_filter( 'set-screen-option', array( $this, 'set_per_page' ), 10, 3 );
|
| 48 |
add_action( 'redirection_log_delete', array( $this, 'expire_logs' ) );
|
| 49 |
|
|
|
|
| 50 |
$this->register_plugin_settings( __FILE__ );
|
| 51 |
|
| 52 |
+
add_action( 'wp_ajax_red_log_delete', array( &$this, 'ajax_log_delete' ) );
|
| 53 |
+
add_action( 'wp_ajax_red_module_edit', array( &$this, 'ajax_module_edit' ) );
|
| 54 |
+
add_action( 'wp_ajax_red_module_save', array( &$this, 'ajax_module_save' ) );
|
| 55 |
+
add_action( 'wp_ajax_red_group_edit', array( &$this, 'ajax_group_edit' ) );
|
| 56 |
+
add_action( 'wp_ajax_red_group_save', array( &$this, 'ajax_group_save' ) );
|
| 57 |
+
add_action( 'wp_ajax_red_redirect_add', array( &$this, 'ajax_redirect_add' ) );
|
| 58 |
+
add_action( 'wp_ajax_red_redirect_edit', array( &$this, 'ajax_redirect_edit' ) );
|
| 59 |
+
add_action( 'wp_ajax_red_redirect_save', array( &$this, 'ajax_redirect_save' ) );
|
| 60 |
+
|
| 61 |
+
$this->update();
|
| 62 |
}
|
| 63 |
else {
|
|
|
|
|
|
|
| 64 |
// Create a WordPress exporter and let it handle the load
|
| 65 |
$this->wp = new WordPress_Module();
|
| 66 |
$this->wp->start();
|
| 76 |
if ( $version != REDIRECTION_VERSION ) {
|
| 77 |
include_once dirname( __FILE__ ).'/models/database.php';
|
| 78 |
|
| 79 |
+
$database = new RE_Database();
|
| 80 |
+
return $database->upgrade( $version, REDIRECTION_VERSION );
|
| 81 |
}
|
| 82 |
|
| 83 |
return true;
|
| 89 |
return $status;
|
| 90 |
}
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
function plugin_settings( $links ) {
|
| 93 |
$settings_link = '<a href="tools.php?page='.basename( __FILE__ ).'">'.__( 'Settings', 'redirection' ).'</a>';
|
| 94 |
array_unshift( $links, $settings_link );
|
| 104 |
}
|
| 105 |
|
| 106 |
function redirection_head() {
|
| 107 |
+
include dirname( __FILE__ ).'/models/pager.php';
|
| 108 |
+
|
| 109 |
+
$this->inject();
|
| 110 |
+
|
| 111 |
+
if ( !isset( $_GET['sub'] ) || ( isset( $_GET['sub'] ) && ( in_array( $_GET['sub'], array( 'log', '404s', 'groups' ) ) ) ) )
|
| 112 |
add_screen_option( 'per_page', array( 'label' => __( 'Log entries', 'redirection' ), 'default' => 25, 'option' => 'redirection_log_per_page' ) );
|
| 113 |
|
| 114 |
wp_enqueue_script( 'redirection', plugin_dir_url( __FILE__ ).'js/redirection.js', array( 'jquery-form', 'jquery-ui-sortable' ), $this->version() );
|
| 115 |
wp_enqueue_style( 'redirection', plugin_dir_url( __FILE__ ).'admin.css', $this->version() );
|
| 116 |
|
| 117 |
wp_localize_script( 'redirection', 'Redirectioni10n', array(
|
| 118 |
+
'error_msg' => __( 'Sorry, unable to do that. Please try refreshing the page.' ),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
) );
|
| 120 |
}
|
| 121 |
|
| 183 |
}
|
| 184 |
|
| 185 |
function admin_screen_modules() {
|
| 186 |
+
$pager = new Redirection_Module_Table();
|
| 187 |
+
$pager->prepare_items();
|
| 188 |
+
|
| 189 |
+
$this->render_admin( 'module_list', array( 'options' => $this->get_options(), 'table' => $pager ) );
|
| 190 |
}
|
| 191 |
|
| 192 |
function get_options() {
|
| 230 |
function inject() {
|
| 231 |
$options = $this->get_options();
|
| 232 |
|
| 233 |
+
if ( isset( $_POST['id'] ) && !isset( $_POST['action'] ) ) {
|
| 234 |
+
wp_safe_redirect( add_query_arg( 'id', intval( $_POST['id'] ), $_SERVER['REQUEST_URI'] ) );
|
| 235 |
+
die();
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
if ( isset( $_GET['token'] ) && isset( $_GET['page'] ) && isset( $_GET['sub'] ) && $_GET['token'] == $options['token'] && $_GET['page'] == 'redirection.php' ) {
|
| 239 |
include dirname( __FILE__ ).'/models/file_io.php';
|
| 240 |
|
| 269 |
$options['auto_target'] = stripslashes( $_POST['auto_target'] );
|
| 270 |
$options['support'] = isset( $_POST['support'] ) ? true : false;
|
| 271 |
$options['token'] = stripslashes( $_POST['token'] );
|
| 272 |
+
$options['expire_redirect'] = min( intval( $_POST['expire_redirect'] ), 60 );
|
| 273 |
+
$options['expire_404'] = min( intval( $_POST['expire_404'] ), 60 );
|
| 274 |
|
| 275 |
if ( trim( $options['token'] ) == '' )
|
| 276 |
$options['token'] = md5( uniqid() );
|
| 282 |
elseif ( isset( $_POST['delete'] ) && check_admin_referer( 'redirection-delete_plugin' ) ) {
|
| 283 |
include dirname( __FILE__ ).'/models/database.php';
|
| 284 |
|
| 285 |
+
$db = new RE_Database();
|
| 286 |
$db->remove( __FILE__ );
|
| 287 |
|
| 288 |
$this->render_message( __( 'Redirection data has been deleted and the plugin disabled', 'redirection' ) );
|
| 291 |
elseif ( isset( $_POST['import'] ) && check_admin_referer( 'redirection-import' ) ) {
|
| 292 |
include dirname( __FILE__ ).'/models/file_io.php';
|
| 293 |
|
| 294 |
+
$count = Red_FileIO::import( $_POST['group'], $_FILES['upload'] );
|
| 295 |
|
|
|
|
| 296 |
if ( $count > 0 )
|
| 297 |
$this->render_message( sprintf( _n( '%d redirection was successfully imported','%d redirections were successfully imported', $count, 'redirection' ), $count ) );
|
| 298 |
else
|
| 304 |
}
|
| 305 |
|
| 306 |
function admin_screen_log() {
|
|
|
|
|
|
|
| 307 |
$options = $this->get_options();
|
| 308 |
|
| 309 |
if ( isset( $_POST['delete-all'] ) && check_admin_referer( 'redirection-log_management' ) ) {
|
| 326 |
}
|
| 327 |
|
| 328 |
function admin_screen_404() {
|
|
|
|
|
|
|
| 329 |
if ( isset( $_POST['delete-all'] ) && check_admin_referer( 'redirection-log_management' ) ) {
|
| 330 |
RE_404::delete_all();
|
| 331 |
$this->render_message( __( 'Your logs have been deleted', 'redirection' ) );
|
| 340 |
}
|
| 341 |
|
| 342 |
function admin_groups( $module ) {
|
|
|
|
|
|
|
| 343 |
if ( isset( $_POST['add'] ) && check_admin_referer( 'redirection-add_group' ) ) {
|
| 344 |
if ( Red_Group::create( stripslashes_deep( $_POST ) ) ) {
|
| 345 |
$this->render_message( __( 'Your group was added successfully', 'redirection' ) );
|
| 352 |
if ( $module == 0 )
|
| 353 |
$module = Red_Module::get_first_id();
|
| 354 |
|
| 355 |
+
$table = new Redirection_Group_Table( Red_Module::get_for_select(), $module );
|
| 356 |
+
$table->prepare_items();
|
| 357 |
|
| 358 |
$module = Red_Module::get( $module );
|
| 359 |
if ( $module )
|
| 360 |
+
$this->render_admin( 'group_list', array( 'options' => $this->get_options(), 'table' => $table, 'modules' => Red_Module::get_for_select(), 'module' => $module ) );
|
| 361 |
else
|
| 362 |
$this->render_message( __( 'Unknown module', 'redirection' ) );
|
| 363 |
}
|
| 364 |
|
| 365 |
+
function admin_redirects( $group_id ) {
|
| 366 |
+
if ( $group_id == 0 )
|
| 367 |
+
$group_id = Red_Group::get_first_id();
|
| 368 |
|
| 369 |
+
$group = Red_Group::get( $group_id );
|
|
|
|
| 370 |
|
| 371 |
+
$table = new Redirection_Table( Red_Group::get_for_select(), $group );
|
| 372 |
+
$table->prepare_items();
|
| 373 |
|
| 374 |
+
$this->render_admin( 'item_list', array( 'options' => $this->get_options(), 'group' => $group, 'table' => $table, 'date_format' => get_option( 'date_format' ) ) );
|
| 375 |
}
|
| 376 |
|
| 377 |
function setMatched( $match ) {
|
| 413 |
}
|
| 414 |
}
|
| 415 |
}
|
| 416 |
+
|
| 417 |
+
public function ajax_log_delete() {
|
| 418 |
+
if ( check_ajax_referer( 'redirection-items' ) ) {
|
| 419 |
+
if ( preg_match_all( '/=(\d*)/', $_POST['checked'], $items ) > 0) {
|
| 420 |
+
foreach ( $items[1] AS $item ) {
|
| 421 |
+
RE_Log::delete( intval( $item ) );
|
| 422 |
+
}
|
| 423 |
+
}
|
| 424 |
+
}
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
private function check_ajax_referer( $nonce ) {
|
| 428 |
+
if ( check_ajax_referer( $nonce, 'nonce', false ) === false )
|
| 429 |
+
$this->output_ajax_response( array( 'error' => __( 'Unable to perform action' ).' - bad nonce' ) );
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
public function ajax_module_edit() {
|
| 433 |
+
$module_id = intval( $_POST['id'] );
|
| 434 |
+
|
| 435 |
+
$this->check_ajax_referer( 'red_edit-'.$module_id );
|
| 436 |
+
|
| 437 |
+
$module = Red_Module::get( $module_id );
|
| 438 |
+
if ( $module )
|
| 439 |
+
$json['html'] = $this->capture_admin( 'module_edit', array( 'module' => $module ) );
|
| 440 |
+
else
|
| 441 |
+
$json['error'] = __( 'Unable to perform action' ).' - could not find module';
|
| 442 |
+
|
| 443 |
+
$this->output_ajax_response( $json );
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
public function ajax_module_save() {
|
| 447 |
+
global $hook_suffix;
|
| 448 |
+
|
| 449 |
+
include dirname( __FILE__ ).'/models/pager.php';
|
| 450 |
+
|
| 451 |
+
$hook_suffix = '';
|
| 452 |
+
$module_id = intval( $_POST['id'] );
|
| 453 |
+
|
| 454 |
+
$this->check_ajax_referer( 'red_module_save_'.$module_id );
|
| 455 |
+
|
| 456 |
+
$module = Red_Module::get( $module_id );
|
| 457 |
+
|
| 458 |
+
if ( $module ) {
|
| 459 |
+
$module->update( $_POST );
|
| 460 |
+
|
| 461 |
+
$pager = new Redirection_Module_Table( array(), false );
|
| 462 |
+
$json = array( 'html' => $pager->column_name( $module ) );
|
| 463 |
+
}
|
| 464 |
+
else
|
| 465 |
+
$json['error'] = __( 'Unable to perform action' ).' - could not find module';
|
| 466 |
+
|
| 467 |
+
$this->output_ajax_response( $json );
|
| 468 |
+
}
|
| 469 |
+
|
| 470 |
+
public function ajax_group_edit() {
|
| 471 |
+
$group_id = intval( $_POST['id'] );
|
| 472 |
+
|
| 473 |
+
$this->check_ajax_referer( 'red-edit_'.$group_id );
|
| 474 |
+
|
| 475 |
+
$group = Red_Group::get( $group_id );
|
| 476 |
+
if ( $group )
|
| 477 |
+
$json['html'] = $this->capture_admin( 'group_edit', array( 'group' => $group, 'modules' => Red_Module::get_for_select() ) );
|
| 478 |
+
else
|
| 479 |
+
$json['error'] = __( 'Unable to perform action' ).' - could not find group';
|
| 480 |
+
|
| 481 |
+
$this->output_ajax_response( $json );
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
public function ajax_group_save() {
|
| 485 |
+
global $hook_suffix;
|
| 486 |
+
|
| 487 |
+
include dirname( __FILE__ ).'/models/pager.php';
|
| 488 |
+
|
| 489 |
+
$hook_suffix = '';
|
| 490 |
+
$group_id = intval( $_POST['id'] );
|
| 491 |
+
|
| 492 |
+
$this->check_ajax_referer( 'redirection-group_save_'.$group_id );
|
| 493 |
+
|
| 494 |
+
$group = Red_Group::get( $group_id );
|
| 495 |
+
if ( $group ) {
|
| 496 |
+
$group->update( $_POST );
|
| 497 |
+
|
| 498 |
+
$pager = new Redirection_Group_Table( array(), false );
|
| 499 |
+
$json = array( 'html' => $pager->column_name( $group ) );
|
| 500 |
+
}
|
| 501 |
+
else
|
| 502 |
+
$json['error'] = __( 'Unable to perform action' ).' - could not find redirect';
|
| 503 |
+
|
| 504 |
+
$this->output_ajax_response( $json );
|
| 505 |
+
}
|
| 506 |
+
|
| 507 |
+
public function ajax_redirect_edit() {
|
| 508 |
+
$this->check_ajax_referer( 'red-edit_'.intval( $_POST['id'] ) );
|
| 509 |
+
$redirect = Red_Item::get_by_id( intval( $_POST['id'] ) );
|
| 510 |
+
|
| 511 |
+
if ( $redirect )
|
| 512 |
+
$json['html'] = $this->capture_admin( 'item_edit', array( 'redirect' => $redirect, 'groups' => Red_Group::get_for_select() ) );
|
| 513 |
+
else
|
| 514 |
+
$json['error'] = __( 'Unable to perform action' ).' - could not find redirect';
|
| 515 |
+
|
| 516 |
+
$this->output_ajax_response( $json );
|
| 517 |
+
}
|
| 518 |
+
|
| 519 |
+
public function ajax_redirect_save() {
|
| 520 |
+
global $hook_suffix;
|
| 521 |
+
|
| 522 |
+
include dirname( __FILE__ ).'/models/pager.php';
|
| 523 |
+
|
| 524 |
+
$hook_suffix = '';
|
| 525 |
+
|
| 526 |
+
$red_id = intval( $_POST['id'] );
|
| 527 |
+
|
| 528 |
+
$this->check_ajax_referer( 'redirection-redirect_save_'.$red_id );
|
| 529 |
+
|
| 530 |
+
$redirect = Red_Item::get_by_id( $red_id );
|
| 531 |
+
if ( $redirect ) {
|
| 532 |
+
$redirect->update( $_POST );
|
| 533 |
+
|
| 534 |
+
$pager = new Redirection_Table( array() );
|
| 535 |
+
$json = array( 'html' => $pager->column_url( $redirect ), 'code' => $redirect->get_action_code() );
|
| 536 |
+
}
|
| 537 |
+
else
|
| 538 |
+
$json['error'] = __( 'Unable to perform action' ).' - could not find redirect';
|
| 539 |
+
|
| 540 |
+
$this->output_ajax_response( $json );
|
| 541 |
+
}
|
| 542 |
+
|
| 543 |
+
public function ajax_redirect_add() {
|
| 544 |
+
global $hook_suffix;
|
| 545 |
+
|
| 546 |
+
include dirname( __FILE__ ).'/models/pager.php';
|
| 547 |
+
|
| 548 |
+
$hook_suffix = '';
|
| 549 |
+
|
| 550 |
+
$this->check_ajax_referer( 'redirection-redirect_add' );
|
| 551 |
+
|
| 552 |
+
$item = Red_Item::create( $_POST );
|
| 553 |
+
if ( is_wp_error( $item ) )
|
| 554 |
+
$json['error'] = $item->get_error_message();
|
| 555 |
+
elseif ( $item !== false ) {
|
| 556 |
+
$pager = new Redirection_Table( array() );
|
| 557 |
+
$json = array( 'html' => $pager->get_row( $item ) );
|
| 558 |
+
}
|
| 559 |
+
else
|
| 560 |
+
$json['error'] = __( 'Sorry, but your redirection was not created', 'redirection' );
|
| 561 |
+
|
| 562 |
+
$this->output_ajax_response( $json );
|
| 563 |
+
}
|
| 564 |
+
|
| 565 |
+
private function output_ajax_response( array $data ) {
|
| 566 |
+
header( 'Content-Type: application/json' );
|
| 567 |
+
echo json_encode( $data );
|
| 568 |
+
die();
|
| 569 |
+
}
|
| 570 |
}
|
| 571 |
|
| 572 |
function red_get_url() {
|
screenshot-1.png
CHANGED
|
Binary file
|
screenshot-2.png
CHANGED
|
Binary file
|
view/admin/add.php
CHANGED
|
@@ -1,81 +1,57 @@
|
|
| 1 |
-
<?php if (!defined
|
| 2 |
-
<div class="wrap" id="add" <?php if ($hidden) echo ' style="display: none"' ?>>
|
| 3 |
-
<h2><?php _e ('Add new redirection', 'redirection') ?></h2>
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
</div>
|
| 8 |
-
|
| 9 |
-
<form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>" id="new-redirection">
|
| 10 |
-
<table width="100%">
|
| 11 |
-
<tr>
|
| 12 |
-
<th align="right" width="100"><?php _e ('Source URL', 'redirection') ?>:</th>
|
| 13 |
-
<td><input type="text" name="source" style="width: 95%" id="old"/></td>
|
| 14 |
-
</tr>
|
| 15 |
-
<tr>
|
| 16 |
-
<th align="right"><?php _e ('Match', 'redirection') ?>:</th>
|
| 17 |
-
<td>
|
| 18 |
-
<select name="match">
|
| 19 |
-
<?php echo $this->select (Red_Match::all ()); ?>
|
| 20 |
-
</select>
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
</select>
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
<input type="hidden" name="group" value="<?php echo esc_attr( $group ) ?>"/>
|
| 46 |
<?php endif; ?>
|
| 47 |
|
| 48 |
<input type="hidden" name="action" value="red_redirect_add"/>
|
| 49 |
<input type="hidden" name="_ajax_nonce" value="<?php echo wp_create_nonce( 'redirection-redirect_add' ); ?>"/>
|
| 50 |
|
| 51 |
-
<div
|
| 52 |
</td>
|
| 53 |
-
|
| 54 |
</table>
|
| 55 |
</form>
|
| 56 |
</div>
|
| 57 |
-
|
| 58 |
-
<script type="text/javascript" charset="utf-8">
|
| 59 |
-
jQuery( '#new-redirection' ).ajaxForm( {
|
| 60 |
-
beforeSubmit: function () {
|
| 61 |
-
jQuery( '#loading' ).show ();
|
| 62 |
-
},
|
| 63 |
-
success: function( response ) {
|
| 64 |
-
jQuery( '#loading' ).hide ();
|
| 65 |
-
|
| 66 |
-
if ( response.indexOf( 'fade error' ) != -1 )
|
| 67 |
-
jQuery( '#error' ).html (response);
|
| 68 |
-
else {
|
| 69 |
-
<?php if ( isset( $add_to_screen ) ) : ?>
|
| 70 |
-
jQuery( '#items' ).append( response );
|
| 71 |
-
<?php endif; ?>
|
| 72 |
-
|
| 73 |
-
jQuery( '#error' ).hide();
|
| 74 |
-
jQuery( '#added' ).show();
|
| 75 |
-
jQuery( '#none' ).hide();
|
| 76 |
-
|
| 77 |
-
redirection.edit_items( 'redirect' );
|
| 78 |
-
}
|
| 79 |
-
}
|
| 80 |
-
});
|
| 81 |
-
</script>
|
| 1 |
+
<?php if ( !defined( 'ABSPATH' ) ) die( 'No direct access allowed' ); ?>
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
<div class="wrap" id="add" <?php if ( $hidden ) echo ' style="display: none"' ?>>
|
| 4 |
+
<h2><?php _e( 'Add new redirection', 'redirection' ) ?></h2>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
<div class="red-added">
|
| 7 |
+
<p><?php _e( 'Your redirection has been added.', 'redirection' ); ?></p>
|
| 8 |
+
</div>
|
|
|
|
| 9 |
|
| 10 |
+
<form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>">
|
| 11 |
+
<table width="100%">
|
| 12 |
+
<tr>
|
| 13 |
+
<th align="right" width="100"><?php _e( 'Source URL', 'redirection' ) ?>:</th>
|
| 14 |
+
<td><input type="text" name="source" style="width: 95%" id="old"/></td>
|
| 15 |
+
</tr>
|
| 16 |
+
<tr>
|
| 17 |
+
<th align="right"><?php _e( 'Match', 'redirection' ) ?>:</th>
|
| 18 |
+
<td>
|
| 19 |
+
<select name="match">
|
| 20 |
+
<?php echo $this->select( Red_Match::all() ); ?>
|
| 21 |
+
</select>
|
| 22 |
+
|
| 23 |
+
<strong><?php _e( 'Action', 'redirection' ); ?>:</strong>
|
| 24 |
+
<select name="red_action">
|
| 25 |
+
<?php echo $this->select( Red_Item::actions(), 'url' ); ?>
|
| 26 |
+
</select>
|
| 27 |
+
|
| 28 |
+
<label><?php _e( 'Regular expression', 'redirection' ); ?>: <input id="regex" type="checkbox" name="regex"/></label>
|
| 29 |
+
</td>
|
| 30 |
+
</tr>
|
| 31 |
+
<tr id="target">
|
| 32 |
+
<th align="right"><?php _e( 'Target URL', 'redirection' ) ?>:</th>
|
| 33 |
+
<td><input type="text" name="target" style="width: 95%"/></td>
|
| 34 |
+
</tr>
|
| 35 |
+
<?php if ( !isset( $group ) ) : ?>
|
| 36 |
+
<tr>
|
| 37 |
+
<th><?php _e( 'Group', 'redirection' ); ?>:</th>
|
| 38 |
+
<td><select name="group"><?php echo $this->select( Red_Group::get_for_select(), isset( $_GET['group'] ) ? intval( $_GET['group'] ) : 0 )?></select></td>
|
| 39 |
+
</tr>
|
| 40 |
+
<?php endif; ?>
|
| 41 |
+
<tr>
|
| 42 |
+
<th></th>
|
| 43 |
+
<td>
|
| 44 |
+
<input class="button-primary" type="submit" name="add" value="<?php esc_attr_e( 'Add Redirection', 'redirection' ) ?>" id="submit"/>
|
| 45 |
+
<?php if ( isset( $group ) ) : ?>
|
| 46 |
<input type="hidden" name="group" value="<?php echo esc_attr( $group ) ?>"/>
|
| 47 |
<?php endif; ?>
|
| 48 |
|
| 49 |
<input type="hidden" name="action" value="red_redirect_add"/>
|
| 50 |
<input type="hidden" name="_ajax_nonce" value="<?php echo wp_create_nonce( 'redirection-redirect_add' ); ?>"/>
|
| 51 |
|
| 52 |
+
<div class="red-error"></div>
|
| 53 |
</td>
|
| 54 |
+
</tr>
|
| 55 |
</table>
|
| 56 |
</form>
|
| 57 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view/admin/group_edit.php
CHANGED
|
@@ -1,31 +1,33 @@
|
|
| 1 |
<?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?>
|
| 2 |
-
<
|
| 3 |
-
<
|
| 4 |
-
<
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
<
|
| 20 |
-
|
| 21 |
-
<input class="button-secondary" type="submit" name="cancel" value="<?php _e ('Cancel', 'redirection'); ?>"/>
|
| 22 |
-
<img class="loader" src="<?php echo $this->url(); ?>/images/progress.gif" alt="loading" width="50" height="16" style="display: none"/>
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
</div>
|
| 1 |
<?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?>
|
| 2 |
+
<table class="edit" data-url="<?php echo admin_url( 'admin-ajax.php' ) ?>">
|
| 3 |
+
<tr>
|
| 4 |
+
<th width="70"><?php _e ('Name', 'redirection'); ?>:</th>
|
| 5 |
+
<td><input style="width: 95%" type="text" name="name" value="<?php echo esc_attr( $group->get_name() ) ?>"/></td>
|
| 6 |
+
</tr>
|
| 7 |
+
<tr>
|
| 8 |
+
<th width="70"><?php _e ('Tracked', 'redirection'); ?>:</th>
|
| 9 |
+
<td><label><input type="checkbox" name="tracking"<?php echo $this->checked ($group->tracking) ?>/> <span class="sub"><?php _e ('Whether to track \'hits\' to items', 'redirection'); ?></span></label></td>
|
| 10 |
+
</tr>
|
| 11 |
+
<tr>
|
| 12 |
+
<th width="70"><?php _e ('Enabled', 'redirection'); ?>:</th>
|
| 13 |
+
<td><label><input type="checkbox" name="status"<?php if ($group->status == 'enabled') echo ' checked="checked"' ?>/> <span class="sub"><?php _e ('Disabling a group will disable all items contained within it', 'redirection'); ?></span></label></td>
|
| 14 |
+
</tr>
|
| 15 |
+
<tr>
|
| 16 |
+
<th width="70"></th>
|
| 17 |
+
<td>
|
| 18 |
+
<div class="table-actions">
|
| 19 |
+
<input class="button-primary" type="submit" name="save" value="<?php _e ('Save', 'redirection'); ?>"/>
|
| 20 |
+
<input class="button-secondary" type="submit" name="cancel" value="<?php _e ('Cancel', 'redirection'); ?>"/>
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
<input type="hidden" name="action" value="red_group_save"/>
|
| 23 |
+
<input type="hidden" name="id" value="<?php echo esc_attr( $group->id ); ?>"/>
|
| 24 |
+
<input type="hidden" name="_ajax_nonce" value="<?php echo wp_create_nonce ('redirection-group_save_'.$group->id); ?>"/>
|
| 25 |
+
</div>
|
| 26 |
+
|
| 27 |
+
<div class="table-loading">
|
| 28 |
+
<div class="spinner"></div>
|
| 29 |
+
</div>
|
| 30 |
+
</td>
|
| 31 |
+
</tr>
|
| 32 |
+
</table>
|
| 33 |
</div>
|
view/admin/group_item.php
DELETED
|
@@ -1,17 +0,0 @@
|
|
| 1 |
-
<?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?>
|
| 2 |
-
<div class="date">
|
| 3 |
-
<a href="<?php echo admin_url( 'admin-ajax.php' ); ?>?action=red_group_edit&id=<?php echo $group->id; ?>&_ajax_nonce=<?php echo wp_create_nonce( 'redirection-group_'.$group->id ); ?>" class="redirection-edit"><?php _e ('edit group', 'redirection'); ?></a>
|
| 4 |
-
</div>
|
| 5 |
-
|
| 6 |
-
<div class="item">
|
| 7 |
-
<input class="check" type="checkbox" name="checkall[]" value="<?php echo $group->id ?>"/>
|
| 8 |
-
<a href="<?php echo admin_url( 'tools.php?page=redirection.php&sub=redirects&id='.$group->id ) ?>">
|
| 9 |
-
<?php echo esc_html( $group->name ); ?>
|
| 10 |
-
</a>
|
| 11 |
-
|
| 12 |
-
<?php echo $group->items () ?>
|
| 13 |
-
|
| 14 |
-
<?php if ($group->status == 'disabled') : ?>
|
| 15 |
-
— <?php _e ('disabled', 'redirection'); ?>
|
| 16 |
-
<?php endif; ?>
|
| 17 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view/admin/group_list.php
CHANGED
|
@@ -2,90 +2,20 @@
|
|
| 2 |
<div class="wrap">
|
| 3 |
<?php screen_icon(); ?>
|
| 4 |
|
| 5 |
-
<h2><?php _e( 'Groups
|
| 6 |
|
| 7 |
<?php $this->render_admin( 'submenu', array( 'options' => $options ) ); ?>
|
| 8 |
|
| 9 |
-
<
|
| 10 |
-
<
|
| 11 |
-
|
| 12 |
-
<input type="hidden" name="curpage" value="<?php echo $pager->current_page() ?>"/>
|
| 13 |
-
<input type="hidden" name="sub" value="<?php echo esc_attr( $_GET['sub'] ) ?>"/>
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
<?php echo $this->select( $modules, isset($_GET['id'] ) ? intval( $_GET['id'] ) : '' )?>
|
| 18 |
-
</select>
|
| 19 |
-
|
| 20 |
-
<?php _e( 'Search', 'redirection' ); ?>:
|
| 21 |
-
<input type="text" class="search-input" name="search" value="<?php echo isset($_GET['search'] ) ? esc_attr( $_GET['search'] ) : '' ?>" style="font-size: 0.8em"/>
|
| 22 |
-
|
| 23 |
-
<?php $pager->per_page( 'redirection' ); ?>
|
| 24 |
-
|
| 25 |
-
<input class="button-secondary" type="submit" name="go" value="<?php _e( 'go', 'redirection' ) ?>"/>
|
| 26 |
-
</form>
|
| 27 |
-
</div>
|
| 28 |
-
|
| 29 |
-
<br/>
|
| 30 |
-
|
| 31 |
-
<?php if ( count( $groups ) > 0 ) : ?>
|
| 32 |
-
<ul id="redirections_header" class="redirections_header">
|
| 33 |
-
<li>
|
| 34 |
-
<div class="tools" style="width: 6.5em"> </div>
|
| 35 |
-
<div class="item"><?php echo __( 'Name', 'redirection' ) ?></div>
|
| 36 |
-
</li>
|
| 37 |
-
</ul>
|
| 38 |
-
|
| 39 |
-
<ul class="redirections" id="items">
|
| 40 |
-
<?php if ( count( $groups ) > 0 ) : ?>
|
| 41 |
-
<?php foreach ( $groups AS $group ) : ?>
|
| 42 |
-
<li id="item_<?php echo $group->id ?>" class="<?php if ( $group->status == 'disabled' ) echo 'disabled' ?>"><?php $this->render_admin( 'group_item', array( 'group' => $group ) ) ?></li>
|
| 43 |
-
<?php endforeach; ?>
|
| 44 |
-
<?php endif; ?>
|
| 45 |
-
</ul>
|
| 46 |
-
|
| 47 |
-
<?php if ( $pager->total_pages() > 0 ) : ?>
|
| 48 |
-
<div class="pagertools">
|
| 49 |
-
<?php foreach ( $pager->area_pages() AS $page ) : ?>
|
| 50 |
-
<?php echo $page ?>
|
| 51 |
-
<?php endforeach; ?>
|
| 52 |
-
</div>
|
| 53 |
-
<?php endif; ?>
|
| 54 |
-
|
| 55 |
-
<?php if ( count( $groups ) > 0 ) : ?>
|
| 56 |
-
<div class="pager pagertools">
|
| 57 |
-
<a class="select-all" href="#select-all"><?php _e( 'Select All', 'redirection' ); ?></a> |
|
| 58 |
-
<a class="toggle-all" href="#toggle-all"><?php _e( 'Toggle', 'redirection' ); ?></a> |
|
| 59 |
-
<a class="reset-all" href="#reset-all"><?php _e( 'Reset Hits', 'redirection' ); ?></a> |
|
| 60 |
-
<a class="delete-all" href="#delete-all"><?php _e( 'Delete', 'redirection' ); ?></a> |
|
| 61 |
-
|
| 62 |
-
<?php _e( 'Move To', 'redirection' ); ?>:
|
| 63 |
-
<select name="move" id="move">
|
| 64 |
-
<?php echo $this->select( $modules )?>
|
| 65 |
-
</select>
|
| 66 |
-
|
| 67 |
-
<input class="button-secondary move-all" type="submit" value="<?php _e( 'Go', 'redirection' ); ?>"/>
|
| 68 |
-
</div>
|
| 69 |
-
|
| 70 |
-
<div class="sort" id="sort">
|
| 71 |
-
<img src="<?php echo $this->url() ?>/images/sort.png" width="16" height="16" alt="Sort"/>
|
| 72 |
-
|
| 73 |
-
<a class="sort-on" id="toggle_sort_on" href="#"><?php _e( 're-order', 'redirection' ); ?></a>
|
| 74 |
-
<a class="sort-save" id="toggle_sort_off" href="#" style="display: none"><?php _e( 'save order', 'redirection' ); ?></a>
|
| 75 |
-
</div>
|
| 76 |
-
<?php endif; ?>
|
| 77 |
-
|
| 78 |
-
<div id="loading" style="display: none">
|
| 79 |
-
<img src="<?php echo $this->url() ?>/images/loading.gif" alt="loading" width="32" height="32"/>
|
| 80 |
-
</div>
|
| 81 |
-
|
| 82 |
-
<?php global $is_IE; if ( !$is_IE ) : ?>
|
| 83 |
-
<div style="clear: both"></div>
|
| 84 |
-
<?php endif; ?>
|
| 85 |
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
</div>
|
| 90 |
|
| 91 |
<div class="wrap">
|
|
@@ -110,16 +40,10 @@
|
|
| 110 |
</div>
|
| 111 |
|
| 112 |
<script type="text/javascript">
|
| 113 |
-
|
| 114 |
-
var redirection = new Redirection( {
|
| 115 |
-
progress: '<?php echo esc_js( '<img src="'.$this->url().'/images/progress.gif" alt="loading" width="50" height="16"/>' ) ?>',
|
| 116 |
-
ajaxurl: '<?php echo esc_js( admin_url( 'admin-ajax.php' ) ) ?>',
|
| 117 |
-
nonce: '<?php echo esc_js( wp_create_nonce( 'redirection-items' ) ); ?>',
|
| 118 |
-
none_select: '<?php echo esc_js( __( 'No items have been selected', 'redirection' ) ); ?>',
|
| 119 |
-
are_you_sure: '<?php echo esc_js( __( 'Are you sure?', 'redirection') ); ?>',
|
| 120 |
-
page: <?php echo( $pager->current_page - 1 ) * $pager->per_page ?>
|
| 121 |
-
} );
|
| 122 |
|
| 123 |
-
|
| 124 |
-
|
|
|
|
|
|
|
| 125 |
</script>
|
| 2 |
<div class="wrap">
|
| 3 |
<?php screen_icon(); ?>
|
| 4 |
|
| 5 |
+
<h2><?php _e( 'Groups', 'redirection' ); ?></a></h2>
|
| 6 |
|
| 7 |
<?php $this->render_admin( 'submenu', array( 'options' => $options ) ); ?>
|
| 8 |
|
| 9 |
+
<form action="tools.php">
|
| 10 |
+
<input type="hidden" name="page" value="redirection.php"/>
|
| 11 |
+
<input type="hidden" name="sub" value="groups"/>
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
<?php $table->search_box( __( 'Search' ), 'search_id' ); ?>
|
| 14 |
+
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
<form method="POST" action="">
|
| 17 |
+
<?php $table->display(); ?>
|
| 18 |
+
</form>
|
| 19 |
</div>
|
| 20 |
|
| 21 |
<div class="wrap">
|
| 40 |
</div>
|
| 41 |
|
| 42 |
<script type="text/javascript">
|
| 43 |
+
var redirection;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
jQuery(document).ready( function() {
|
| 46 |
+
new Redirection_Items();
|
| 47 |
+
new Redirection_Add( 'select[name=red_action]', '#target', '#add', true );
|
| 48 |
+
});
|
| 49 |
</script>
|
view/admin/item.php
DELETED
|
@@ -1,31 +0,0 @@
|
|
| 1 |
-
<?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?>
|
| 2 |
-
|
| 3 |
-
<div class="date" id="info_<?php echo $redirect->id ?>" style="width:8em">
|
| 4 |
-
<?php if ($redirect->last_access == 0) : ?>
|
| 5 |
-
—
|
| 6 |
-
<?php else : ?>
|
| 7 |
-
<?php echo date (str_replace ('F', 'M', get_option ('date_format')), $redirect->last_access) ?>
|
| 8 |
-
<?php endif; ?>
|
| 9 |
-
</div>
|
| 10 |
-
|
| 11 |
-
<div class="count">
|
| 12 |
-
<a href="<?php echo admin_url( 'tools.php?page=redirection.php' ); ?>&sub=log&redirect=<?php echo $redirect->id ?>"><?php echo $redirect->last_count ?></a>
|
| 13 |
-
</div>
|
| 14 |
-
|
| 15 |
-
<div class="type">
|
| 16 |
-
<?php echo $redirect->type () ?>
|
| 17 |
-
</div>
|
| 18 |
-
|
| 19 |
-
<div class="item<?php if ($redirect->regex) echo ' item-regex' ?>">
|
| 20 |
-
<input type="checkbox" class="check" name="checkall[]" value="<?php echo esc_attr( $redirect->id ) ?>"/>
|
| 21 |
-
|
| 22 |
-
<a href="<?php echo esc_attr( $this->url( $redirect->url ) ) ?>" class="redirection-edit">
|
| 23 |
-
<?php if ($redirect->title) echo esc_html( $redirect->title ); else echo esc_html( RE_Log::show_url( $redirect->url ) ); ?>
|
| 24 |
-
</a>
|
| 25 |
-
|
| 26 |
-
<?php if ($redirect->match_type != 'url') echo '('.esc_html( $redirect->match_name() ).')' ?>
|
| 27 |
-
|
| 28 |
-
<?php if ($redirect->status == 'disabled') : ?>
|
| 29 |
-
— <?php _e ('disabled', 'redirection'); ?>
|
| 30 |
-
<?php endif; ?>
|
| 31 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view/admin/item_edit.php
CHANGED
|
@@ -1,29 +1,27 @@
|
|
| 1 |
<?php if ( !defined( 'ABSPATH' ) ) die( 'No direct access allowed' ); ?>
|
| 2 |
-
<
|
| 3 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
<
|
| 6 |
-
<
|
| 7 |
-
|
| 8 |
-
<
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
</tr>
|
| 13 |
|
| 14 |
-
|
| 15 |
-
<th width="100"><a target="_blank" href="<?php echo esc_url( $redirect->url ) ?>"><?php _e( 'Source URL', 'redirection' ); ?>:</a></th>
|
| 16 |
-
<td>
|
| 17 |
-
<input style="width: 85%" type="text" name="old" value="<?php echo esc_attr( $redirect->url ); ?>" id="original"/>
|
| 18 |
-
<label><?php _e( 'Regex', 'redirection' ); ?>: <input type="checkbox" name="regex" <?php if ( $redirect->regex == true ) echo ' checked="checked"' ?>/></label>
|
| 19 |
-
</td>
|
| 20 |
-
</tr>
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
<
|
| 25 |
-
<
|
| 26 |
-
<td>
|
| 27 |
<input class="button-primary" type="submit" name="save" value="<?php _e( 'Save', 'redirection' ); ?>"/>
|
| 28 |
<input class="button-secondary" type="submit" name="cancel" value="<?php _e( 'Cancel', 'redirection' ); ?>"/>
|
| 29 |
|
|
@@ -32,7 +30,10 @@
|
|
| 32 |
<input type="hidden" name="_ajax_nonce" value="<?php echo wp_create_nonce( 'redirection-redirect_save_'.$redirect->id ); ?>"/>
|
| 33 |
|
| 34 |
<span id="info_<?php echo esc_attr( $redirect->id ) ?>"></span>
|
| 35 |
-
</
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
</
|
|
|
|
|
|
|
|
|
| 1 |
<?php if ( !defined( 'ABSPATH' ) ) die( 'No direct access allowed' ); ?>
|
| 2 |
+
<table class="edit" data-url="<?php echo admin_url( 'admin-ajax.php' ) ?>">
|
| 3 |
+
<tr>
|
| 4 |
+
<th width="100"><?php _e ('Description', 'redirection'); ?>:</th>
|
| 5 |
+
<td>
|
| 6 |
+
<input style="width: 85%" type="text" name="title" value="<?php echo esc_attr( $redirect->title ); ?>"/>
|
| 7 |
+
<span class="sub">(<?php _e( "optional", 'redirection' ); ?>)</span>
|
| 8 |
+
</td>
|
| 9 |
+
</tr>
|
| 10 |
|
| 11 |
+
<tr>
|
| 12 |
+
<th width="100"><a target="_blank" href="<?php echo esc_url( $redirect->url ) ?>"><?php _e( 'Source URL', 'redirection' ); ?>:</a></th>
|
| 13 |
+
<td>
|
| 14 |
+
<input style="width: 85%" type="text" name="old" value="<?php echo esc_attr( $redirect->url ); ?>" id="original"/>
|
| 15 |
+
<label><?php _e( 'Regex', 'redirection' ); ?>: <input type="checkbox" name="regex" <?php if ( $redirect->regex == true ) echo ' checked="checked"' ?>/></label>
|
| 16 |
+
</td>
|
| 17 |
+
</tr>
|
|
|
|
| 18 |
|
| 19 |
+
<?php $redirect->match->show(); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
<tr>
|
| 22 |
+
<th></th>
|
| 23 |
+
<td>
|
| 24 |
+
<div class="table-actions">
|
|
|
|
| 25 |
<input class="button-primary" type="submit" name="save" value="<?php _e( 'Save', 'redirection' ); ?>"/>
|
| 26 |
<input class="button-secondary" type="submit" name="cancel" value="<?php _e( 'Cancel', 'redirection' ); ?>"/>
|
| 27 |
|
| 30 |
<input type="hidden" name="_ajax_nonce" value="<?php echo wp_create_nonce( 'redirection-redirect_save_'.$redirect->id ); ?>"/>
|
| 31 |
|
| 32 |
<span id="info_<?php echo esc_attr( $redirect->id ) ?>"></span>
|
| 33 |
+
</div>
|
| 34 |
+
<div class="table-loading">
|
| 35 |
+
<div class="spinner"></div>
|
| 36 |
+
</div>
|
| 37 |
+
</td>
|
| 38 |
+
</tr>
|
| 39 |
+
</table>
|
view/admin/item_list.php
CHANGED
|
@@ -2,117 +2,30 @@
|
|
| 2 |
<div class="wrap">
|
| 3 |
<?php screen_icon(); ?>
|
| 4 |
|
| 5 |
-
<h2>
|
| 6 |
-
<?php _e ('Redirections for group', 'redirection'); ?>:
|
| 7 |
-
|
| 8 |
-
<?php if ( $group ) : ?>
|
| 9 |
-
<a href="<?php echo admin_url( 'tools.php?page=redirection.php' ); ?>&sub=groups&id=<?php echo $group->module_id ?>">
|
| 10 |
-
<?php echo esc_html( $group->name ); ?>
|
| 11 |
-
</a>
|
| 12 |
-
<?php endif; ?>
|
| 13 |
-
</h2>
|
| 14 |
|
| 15 |
<?php $this->render_admin( 'submenu', array( 'options' => $options ) ); ?>
|
| 16 |
|
| 17 |
-
<
|
| 18 |
-
<
|
| 19 |
-
<input type="hidden" name="page" value="<?php echo $_GET['page'] ?>"/>
|
| 20 |
-
<input type="hidden" name="curpage" value="<?php echo $pager->current_page () ?>"/>
|
| 21 |
-
<input type="hidden" name="sub" value="<?php echo esc_attr( isset($_GET['sub']) ? $_GET['sub'] : '' )?>"/>
|
| 22 |
-
|
| 23 |
-
<?php _e ('Group', 'redirection'); ?>:
|
| 24 |
-
<select name="id">
|
| 25 |
-
<?php echo $this->select ($groups, isset( $_GET['id'] ) ? intval( $_GET['id'] ) : '')?>
|
| 26 |
-
</select>
|
| 27 |
-
|
| 28 |
-
<?php _e ('Search', 'redirection'); ?>:
|
| 29 |
-
<input type="text" class="search-input" name="search" value="<?php echo isset($_GET['search']) ? esc_attr( $_GET['search'] ) : '' ?>" style="font-size: 0.8em"/>
|
| 30 |
-
|
| 31 |
-
<?php $pager->per_page ('redirection'); ?>
|
| 32 |
-
|
| 33 |
-
<input class="button-secondary" type="submit" name="go" value="<?php _e ('Go', 'redirection') ?>"/>
|
| 34 |
-
</form>
|
| 35 |
-
</div>
|
| 36 |
-
<br/>
|
| 37 |
-
|
| 38 |
-
<ul id="redirections_header" class="redirections_header">
|
| 39 |
-
<li>
|
| 40 |
-
<div class="date" style="width: 8em"><?php echo __ ('Last Access', 'redirection') ?></div>
|
| 41 |
-
<div class="count"><?php echo __('Hits', 'redirection') ?></div>
|
| 42 |
-
<div class="type"><?php echo __ ('Type', 'redirection') ?></div>
|
| 43 |
-
<div class="item"><?php echo __('URL', 'redirection') ?> / <?php echo __ ('Position', 'redirection') ?></div>
|
| 44 |
-
</li>
|
| 45 |
-
</ul>
|
| 46 |
-
|
| 47 |
-
<ul class="redirections" id="items">
|
| 48 |
-
<?php if (is_array ($items) && count ($items) > 0) : ?>
|
| 49 |
-
<?php foreach ($items AS $redirect) : ?>
|
| 50 |
-
<li class="type_<?php echo $redirect->action->type () ?><?php if ($redirect->status == 'disabled') echo ' disabled' ?>" id="item_<?php echo $redirect->id ?>">
|
| 51 |
-
<?php $this->render_admin ('item', array ('redirect' => $redirect, 'date_format' => $date_format)) ?>
|
| 52 |
-
</li>
|
| 53 |
-
<?php endforeach; ?>
|
| 54 |
-
<?php endif; ?>
|
| 55 |
-
</ul>
|
| 56 |
-
|
| 57 |
-
<?php if ($pager->total_pages () > 0) : ?>
|
| 58 |
-
<div class="pagertools">
|
| 59 |
-
<?php foreach ($pager->area_pages () AS $page) : ?>
|
| 60 |
-
<?php echo $page ?>
|
| 61 |
-
<?php endforeach; ?>
|
| 62 |
-
</div>
|
| 63 |
-
<?php endif;?>
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
<a class="toggle-all" href="#toggle-all"><?php _e ('Toggle', 'redirection'); ?></a> |
|
| 68 |
-
<a class="reset-all" href="#reset-all"><?php _e ('Reset Hits', 'redirection'); ?></a> |
|
| 69 |
-
<a class="delete-all" href="#delete-all"><?php _e ('Delete', 'redirection'); ?></a> |
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
</select>
|
| 75 |
|
| 76 |
-
<input class="button-secondary move-all" type="submit" value="<?php _e( 'Go', 'redirection'); ?>"/>
|
| 77 |
-
</div>
|
| 78 |
-
|
| 79 |
-
<div class="sort" id="sort">
|
| 80 |
-
<img src="<?php echo $this->url () ?>/images/sort.png" width="16" height="16" alt="Sort"/>
|
| 81 |
-
|
| 82 |
-
<a class="sort-on" id="toggle_sort_on" href="#"><?php _e ('re-order', 'redirection'); ?></a>
|
| 83 |
-
<a class="sort-save" id="toggle_sort_off" href="#" style="display: none"><?php _e ('save order', 'redirection'); ?></a>
|
| 84 |
-
</div>
|
| 85 |
-
|
| 86 |
-
<?php if (!is_array ($items) || count ($items) == 0) : ?>
|
| 87 |
-
<p id="none"><?php _e ('You have no redirections.', 'redirection') ?></p>
|
| 88 |
-
<?php endif; ?>
|
| 89 |
-
|
| 90 |
-
<div id="loading" style="display: none">
|
| 91 |
-
<img src="<?php echo $this->url () ?>/images/loading.gif" alt="loading" width="32" height="32"/>
|
| 92 |
-
</div>
|
| 93 |
-
|
| 94 |
-
<img src="<?php echo $this->url () ?>/images/progress.gif" width="50" height="16" alt="Progress" style="display: none"/>
|
| 95 |
-
|
| 96 |
-
<?php global $is_IE; if (!$is_IE) : ?>
|
| 97 |
<div style="clear: both"></div>
|
| 98 |
-
<?php endif; ?>
|
| 99 |
</div>
|
| 100 |
|
| 101 |
-
<?php $this->render_admin
|
| 102 |
|
| 103 |
<script type="text/javascript">
|
| 104 |
var redirection;
|
| 105 |
|
| 106 |
jQuery(document).ready( function() {
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
ajaxurl: '<?php echo esc_js( admin_url( 'admin-ajax.php' ) ) ?>',
|
| 110 |
-
nonce: '<?php echo esc_js( wp_create_nonce( 'redirection-items' ) ); ?>',
|
| 111 |
-
none_select: '<?php echo esc_js( __( 'No items have been selected', 'redirection' ) ); ?>',
|
| 112 |
-
are_you_sure: '<?php echo esc_js( __( 'Are you sure?', 'redirection') ); ?>',
|
| 113 |
-
page: <?php echo ($pager->current_page - 1) * $pager->per_page ?>
|
| 114 |
-
});
|
| 115 |
-
|
| 116 |
-
redirection.edit_items( 'redirect' );
|
| 117 |
});
|
| 118 |
</script>
|
| 2 |
<div class="wrap">
|
| 3 |
<?php screen_icon(); ?>
|
| 4 |
|
| 5 |
+
<h2><?php _e( 'Redirections', 'redirection' ); ?>:</h2>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
<?php $this->render_admin( 'submenu', array( 'options' => $options ) ); ?>
|
| 8 |
|
| 9 |
+
<form action="tools.php">
|
| 10 |
+
<input type="hidden" name="page" value="redirection.php"/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
<?php $table->search_box( __( 'Search' ), 'search_id' ); ?>
|
| 13 |
+
</form>
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
<form method="POST" action="">
|
| 16 |
+
<?php $table->display(); ?>
|
| 17 |
+
</form>
|
|
|
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
<div style="clear: both"></div>
|
|
|
|
| 20 |
</div>
|
| 21 |
|
| 22 |
+
<?php $this->render_admin( 'add', array( 'add_to_screen' => true, 'group' => $group ? $group->id : 0, 'hidden' => false ) ); ?>
|
| 23 |
|
| 24 |
<script type="text/javascript">
|
| 25 |
var redirection;
|
| 26 |
|
| 27 |
jQuery(document).ready( function() {
|
| 28 |
+
new Redirection_Items();
|
| 29 |
+
new Redirection_Add( 'select[name=red_action]', '#target', '#add', true );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
});
|
| 31 |
</script>
|
view/admin/log.php
CHANGED
|
@@ -39,15 +39,8 @@ var redirection;
|
|
| 39 |
|
| 40 |
(function($) {
|
| 41 |
$(document).ready( function() {
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
ajaxurl: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
|
| 45 |
-
nonce: '<?php echo wp_create_nonce( 'redirection-items' ); ?>',
|
| 46 |
-
none_select: '<?php echo esc_js( __( 'No items have been selected', 'redirection' ) ); ?>',
|
| 47 |
-
are_you_sure: '<?php echo esc_js( __( 'Are you sure?', 'redirection') ); ?>',
|
| 48 |
-
});
|
| 49 |
-
|
| 50 |
-
redirection.logs();
|
| 51 |
});
|
| 52 |
})(jQuery);
|
| 53 |
</script>
|
| 39 |
|
| 40 |
(function($) {
|
| 41 |
$(document).ready( function() {
|
| 42 |
+
new Redirection_Logs();
|
| 43 |
+
new Redirection_Add( 'select[name=red_action]', '#target', '#add', false );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
});
|
| 45 |
})(jQuery);
|
| 46 |
</script>
|
view/admin/module_edit.php
CHANGED
|
@@ -1,38 +1,28 @@
|
|
| 1 |
-
<?php if(
|
| 2 |
-
<
|
| 3 |
-
<
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
<img src="<?php echo $this->url() ?>/images/modules/wordpress.png" width="64" height="64" alt="Wordpress"/>
|
| 8 |
-
<?php elseif( $module->type == '404' ) : ?>
|
| 9 |
-
<img src="<?php echo $this->url() ?>/images/modules/404.png" width="64" height="64" alt="Wordpress"/>
|
| 10 |
-
<?php endif; ?>
|
| 11 |
-
</a>
|
| 12 |
-
</td>
|
| 13 |
|
| 14 |
-
|
| 15 |
-
<form action="<?php echo admin_url( 'admin-ajax.php' ) ?>" method="post" accept-charset="utf-8">
|
| 16 |
-
<table class="edit">
|
| 17 |
-
<tr>
|
| 18 |
-
<th><?php _e( 'Name', 'redirection' ); ?>:</th>
|
| 19 |
-
<td><input type="text" name="name" value="<?php echo esc_attr( $module->name ) ?>" style="width: 95%"/></td>
|
| 20 |
-
</tr>
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
-
<
|
| 26 |
-
<
|
| 27 |
-
|
| 28 |
-
<input class="button-secondary" type="submit" name="cancel" value="<?php _e( 'Cancel', 'redirection' ); ?>"/>
|
| 29 |
-
<img class="loader" src="<?php echo $this->url(); ?>/images/progress.gif" alt="loading" width="50" height="16" style="display: none"/>
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
</td>
|
| 1 |
+
<?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?>
|
| 2 |
+
<table class="edit" data-url="<?php echo admin_url( 'admin-ajax.php' ) ?>">
|
| 3 |
+
<tr>
|
| 4 |
+
<th width="70"><?php _e ('Name', 'redirection'); ?>:</th>
|
| 5 |
+
<td><input style="width: 95%" type="text" name="name" value="<?php echo esc_attr( $module->get_name() ) ?>"/></td>
|
| 6 |
+
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
<?php $module->config(); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
<tr>
|
| 11 |
+
<th width="70"></th>
|
| 12 |
+
<td>
|
| 13 |
+
<div class="table-actions">
|
| 14 |
+
<input class="button-primary" type="submit" name="save" value="<?php _e ('Save', 'redirection'); ?>"/>
|
| 15 |
+
<input class="button-secondary" type="submit" name="cancel" value="<?php _e ('Cancel', 'redirection'); ?>"/>
|
| 16 |
|
| 17 |
+
<input type="hidden" name="action" value="red_module_save"/>
|
| 18 |
+
<input type="hidden" name="id" value="<?php echo esc_attr( $module->get_id() ); ?>"/>
|
| 19 |
+
<input type="hidden" name="_ajax_nonce" value="<?php echo wp_create_nonce ('red_module_save_'.$module->get_id() ); ?>"/>
|
| 20 |
+
</div>
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
<div class="table-loading">
|
| 23 |
+
<div class="spinner"></div>
|
| 24 |
+
</div>
|
| 25 |
+
</td>
|
| 26 |
+
</tr>
|
| 27 |
+
</table>
|
| 28 |
+
</div>
|
|
|
view/admin/module_item.php
DELETED
|
@@ -1,52 +0,0 @@
|
|
| 1 |
-
<?php if( !defined( 'ABSPATH' ) ) die( 'No direct access allowed' ); ?>
|
| 2 |
-
<td class="logo">
|
| 3 |
-
<a href="<?php echo admin_url( 'tools.php?page=redirection.php' ); ?>&sub=groups&id=<?php echo $module->id ?>">
|
| 4 |
-
<?php if( $module->type == 'apache' ) : ?>
|
| 5 |
-
<img src="<?php echo $this->url() ?>/images/modules/apache.png" width="55" height="56" alt="Apache"/>
|
| 6 |
-
<?php elseif( $module->type == 'wp' ) : ?>
|
| 7 |
-
<img src="<?php echo $this->url() ?>/images/modules/wordpress.png" width="64" height="64" alt="Wordpress"/>
|
| 8 |
-
<?php elseif( $module->type == '404' ) : ?>
|
| 9 |
-
<img src="<?php echo $this->url() ?>/images/modules/404.png" width="64" height="64" alt="Wordpress"/>
|
| 10 |
-
<?php endif; ?>
|
| 11 |
-
</a>
|
| 12 |
-
</td>
|
| 13 |
-
|
| 14 |
-
<td valign="top">
|
| 15 |
-
<h4>
|
| 16 |
-
<a href="<?php echo admin_url( 'tools.php?page=redirection.php' ); ?>&sub=groups&id=<?php echo $module->id ?>"><?php echo esc_html( $module->name ); ?></a>
|
| 17 |
-
</h4>
|
| 18 |
-
|
| 19 |
-
<?php $module->options(); ?>
|
| 20 |
-
|
| 21 |
-
<?php if ( $module->is_valid() ) : ?>
|
| 22 |
-
<div class="toolbar">
|
| 23 |
-
<strong><?php _e( 'View as', 'redirection' ); ?>:</strong>
|
| 24 |
-
|
| 25 |
-
<a href="<?php echo admin_url( 'tools.php?page=redirection.php' ); ?>&sub=csv&module=<?php echo $module->id ?>&token=<?php echo $token ?>"><?php _e( 'CSV', 'redirection' ); ?></a>
|
| 26 |
-
<a href="<?php echo admin_url( 'tools.php?page=redirection.php' ); ?>&sub=apache&module=<?php echo $module->id ?>&token=<?php echo $token ?>"><?php _e( 'Apache', 'redirection' ); ?></a>
|
| 27 |
-
<a href="<?php echo admin_url( 'tools.php?page=redirection.php' ); ?>&sub=rss&module=<?php echo $module->id ?>&token=<?php echo $token ?>"><?php _e( 'RSS', 'redirection' ); ?></a>
|
| 28 |
-
</div>
|
| 29 |
-
<?php endif; ?>
|
| 30 |
-
</td>
|
| 31 |
-
|
| 32 |
-
<td class="center"><a href="<?php echo admin_url( 'tools.php?page=redirection.php' ); ?>&sub=groups&id=<?php echo $module->id ?>"><?php echo $module->groups(); ?></a></td>
|
| 33 |
-
<td class="center"><a href="<?php echo admin_url( 'tools.php?page=redirection.php' ); ?>&sub=log&module=<?php echo $module->id ?>"><?php echo number_format_i18n( $module->hits() ); ?></a></td>
|
| 34 |
-
|
| 35 |
-
<?php $nonce = wp_create_nonce( 'redirection-module_manage-'.$module->id ); ?>
|
| 36 |
-
|
| 37 |
-
<td id="info_<?php echo $module->id ?>" class="operations">
|
| 38 |
-
<div>
|
| 39 |
-
<a class="edit" href="<?php echo admin_url( 'admin-ajax.php' ); ?>?action=red_module_edit&id=<?php echo $module->id; ?>&_ajax_nonce=<?php echo wp_create_nonce( 'redirection-module_'.$module->id ); ?>"><?php _e( 'edit', 'redirection' ); ?></a>
|
| 40 |
-
|
|
| 41 |
-
<a class="rdelete" href="<?php echo admin_url( 'admin-ajax.php' ); ?>?action=red_module_delete&id=<?php echo $module->id; ?>&_ajax_nonce=<?php echo wp_create_nonce( 'redirection-module_'.$module->id ); ?>"><?php _e( 'delete', 'redirection' ); ?></a>
|
| 42 |
-
|
|
| 43 |
-
<a class="reset" href="<?php echo admin_url( 'admin-ajax.php' ); ?>?action=red_module_reset&id=<?php echo $module->id; ?>&_ajax_nonce=<?php echo wp_create_nonce( 'redirection-module_'.$module->id ); ?>"><?php _e( 'reset', 'redirection' ); ?></a>
|
| 44 |
-
</div>
|
| 45 |
-
|
| 46 |
-
<img class="loader" src="<?php echo $this->url(); ?>/images/progress.gif" alt="loading" width="50" height="16" style="display: none"/>
|
| 47 |
-
</td>
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view/admin/module_list.php
CHANGED
|
@@ -6,31 +6,13 @@
|
|
| 6 |
|
| 7 |
<?php $this->render_admin( 'submenu', array( 'options' => $options ) ); ?>
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
<th></th>
|
| 13 |
-
<th class="left"><?php _e( 'Details', 'redirection' ); ?></th>
|
| 14 |
-
<th><?php _e( 'Groups', 'redirection' ); ?></th>
|
| 15 |
-
<th><?php _e( 'Items', 'redirection' ); ?></th>
|
| 16 |
-
<th><?php _e( 'Operations', 'redirection' ); ?></th>
|
| 17 |
-
</tr>
|
| 18 |
-
|
| 19 |
-
<?php foreach ( $modules AS $pos => $module ): ?>
|
| 20 |
-
<tr id="item_<?php echo $module->id ?>">
|
| 21 |
-
<?php $this->render_admin( 'module_item', array( 'module' => $module, 'token' => $token ) ); ?>
|
| 22 |
-
</tr>
|
| 23 |
-
<?php endforeach ?>
|
| 24 |
-
</table>
|
| 25 |
-
<p><?php _e( 'Note: Hits are dependant on log entries', 'redirection' )?></p>
|
| 26 |
-
<?php else : ?>
|
| 27 |
-
<p><?php _e( 'You have no modules defined yet', 'redirection' ); ?>.</p>
|
| 28 |
-
<?php endif; ?>
|
| 29 |
</div>
|
| 30 |
|
| 31 |
<script type="text/javascript">
|
| 32 |
jQuery(document ).ready( function() {
|
| 33 |
-
|
| 34 |
-
redirection.modules();
|
| 35 |
} );
|
| 36 |
</script>
|
| 6 |
|
| 7 |
<?php $this->render_admin( 'submenu', array( 'options' => $options ) ); ?>
|
| 8 |
|
| 9 |
+
<form method="POST" action="">
|
| 10 |
+
<?php $table->display(); ?>
|
| 11 |
+
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
</div>
|
| 13 |
|
| 14 |
<script type="text/javascript">
|
| 15 |
jQuery(document ).ready( function() {
|
| 16 |
+
new Redirection_Items();
|
|
|
|
| 17 |
} );
|
| 18 |
</script>
|
view/admin/support.php
CHANGED
|
@@ -35,7 +35,7 @@
|
|
| 35 |
<input type="image" style="border: none" src="<?php echo $this->url () ?>/images/donate.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"/>
|
| 36 |
</form>
|
| 37 |
|
| 38 |
-
<p><strong>$
|
| 39 |
</li>
|
| 40 |
<li>
|
| 41 |
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
| 35 |
<input type="image" style="border: none" src="<?php echo $this->url () ?>/images/donate.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"/>
|
| 36 |
</form>
|
| 37 |
|
| 38 |
+
<p><strong>$16</strong><br/><?php _e( 'Individual<br/>Donation', 'redirection' ); ?></p>
|
| 39 |
</li>
|
| 40 |
<li>
|
| 41 |
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
