Version Description
- 2020-03-21 =
- Compatibility : WordPress 5.4
- Enhancement: Dashboard Design updated.
Download this release
Release Info
| Developer | WPBrigade |
| Plugin | |
| Version | 1.1.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.0 to 1.1.0
- asset/css/style.css +66 -0
- classes/class-settings-api.php +657 -616
- classes/class-setup.php +97 -97
- languages/wp-header-and-footer.pot +101 -0
- readme.txt +12 -6
- wp-headers-and-footers.php +167 -160
asset/css/style.css
CHANGED
|
@@ -4,3 +4,69 @@
|
|
| 4 |
.wp-header-and-footer textarea{
|
| 5 |
width: 35em;
|
| 6 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
.wp-header-and-footer textarea{
|
| 5 |
width: 35em;
|
| 6 |
}
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
/*--Side bar style--*/
|
| 10 |
+
.header-and-footer-setting {
|
| 11 |
+
width: calc( 100% - 325px);
|
| 12 |
+
float: left;
|
| 13 |
+
padding-right: 30px;
|
| 14 |
+
padding-top:30px;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
.wp-header-and-footer .wpbr-sidebar {
|
| 18 |
+
padding-top:30px;
|
| 19 |
+
width: 295px;
|
| 20 |
+
float: right;
|
| 21 |
+
box-sizing: border-box;
|
| 22 |
+
}
|
| 23 |
+
.wp-header-and-footer .postbox {
|
| 24 |
+
padding: 0 10px 10px 10px;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
.wp-header-and-footer .wpbr-sidebar h2 {
|
| 28 |
+
margin: 0;
|
| 29 |
+
padding: 10px 10px 10px 30px;
|
| 30 |
+
border-bottom: 1px solid #000;
|
| 31 |
+
color: #000;
|
| 32 |
+
|
| 33 |
+
}
|
| 34 |
+
.wp-header-and-footer .wpbr-sidebar ul.plugins_lists li {
|
| 35 |
+
padding-left: 10px;
|
| 36 |
+
}
|
| 37 |
+
.wp-header-and-footer .wpbr-sidebar ul li a {
|
| 38 |
+
width: 100%;
|
| 39 |
+
display: block;
|
| 40 |
+
position: relative;
|
| 41 |
+
}
|
| 42 |
+
.wp-header-and-footer .wpbr-sidebar ul li a:hover{
|
| 43 |
+
text-decoration: underline;
|
| 44 |
+
}
|
| 45 |
+
.wp-header-and-footer .wpbr-sidebar .dashicons {
|
| 46 |
+
position: absolute;
|
| 47 |
+
right: 10px;
|
| 48 |
+
margin-top: 3px;
|
| 49 |
+
}
|
| 50 |
+
.wp-header-and-footer .wpbr-sidebar .button{
|
| 51 |
+
color: #000;
|
| 52 |
+
border-color:transparent;
|
| 53 |
+
}
|
| 54 |
+
.wp-header-and-footer .wpbr-sidebar .button:hover{
|
| 55 |
+
border-color:#000;
|
| 56 |
+
}
|
| 57 |
+
.wp-header-and-footer .wpbr-sidebar h2 .dashicons{
|
| 58 |
+
position: absolute;
|
| 59 |
+
left: 10px;
|
| 60 |
+
top: 5px;
|
| 61 |
+
font-size: 23px;
|
| 62 |
+
}
|
| 63 |
+
.wp-header-and-footer .plugins_lists a{
|
| 64 |
+
color:#000;
|
| 65 |
+
font-size:14px;
|
| 66 |
+
text-decoration: none;
|
| 67 |
+
font-weight: 600;
|
| 68 |
+
margin-bottom: 10px;
|
| 69 |
+
}
|
| 70 |
+
.wp-header-and-footer .plugins_lists a:hover{
|
| 71 |
+
text-decoration: underline;
|
| 72 |
+
}
|
classes/class-settings-api.php
CHANGED
|
@@ -3,621 +3,662 @@
|
|
| 3 |
/**
|
| 4 |
* WP Header and Footer Settings API wrapper class
|
| 5 |
*/
|
| 6 |
-
if ( !class_exists( 'WPHeaderAndFooter_Settings_API' ) ):
|
| 7 |
-
class WPHeaderAndFooter_Settings_API {
|
| 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 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 622 |
|
| 623 |
endif;
|
| 3 |
/**
|
| 4 |
* WP Header and Footer Settings API wrapper class
|
| 5 |
*/
|
| 6 |
+
if ( ! class_exists( 'WPHeaderAndFooter_Settings_API' ) ) :
|
| 7 |
+
class WPHeaderAndFooter_Settings_API {
|
| 8 |
+
|
| 9 |
+
/**
|
| 10 |
+
* settings sections array
|
| 11 |
+
*
|
| 12 |
+
* @var array
|
| 13 |
+
*/
|
| 14 |
+
protected $settings_sections = array();
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* Settings fields array
|
| 18 |
+
*
|
| 19 |
+
* @var array
|
| 20 |
+
*/
|
| 21 |
+
protected $settings_fields = array();
|
| 22 |
+
|
| 23 |
+
public function __construct() {
|
| 24 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Enqueue scripts and styles
|
| 29 |
+
*/
|
| 30 |
+
function admin_enqueue_scripts() {
|
| 31 |
+
wp_enqueue_style( 'wp-color-picker' );
|
| 32 |
+
|
| 33 |
+
wp_enqueue_media();
|
| 34 |
+
wp_enqueue_script( 'wp-color-picker' );
|
| 35 |
+
wp_enqueue_script( 'jquery' );
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* Set settings sections
|
| 40 |
+
*
|
| 41 |
+
* @param array $sections setting sections array
|
| 42 |
+
*/
|
| 43 |
+
function set_sections( $sections ) {
|
| 44 |
+
$this->settings_sections = $sections;
|
| 45 |
+
|
| 46 |
+
return $this;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* Add a single section
|
| 51 |
+
*
|
| 52 |
+
* @param array $section
|
| 53 |
+
*/
|
| 54 |
+
function add_section( $section ) {
|
| 55 |
+
$this->settings_sections[] = $section;
|
| 56 |
+
|
| 57 |
+
return $this;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* Set settings fields
|
| 62 |
+
*
|
| 63 |
+
* @param array $fields settings fields array
|
| 64 |
+
*/
|
| 65 |
+
function set_fields( $fields ) {
|
| 66 |
+
$this->settings_fields = $fields;
|
| 67 |
+
|
| 68 |
+
return $this;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
function add_field( $section, $field ) {
|
| 72 |
+
$defaults = array(
|
| 73 |
+
'name' => '',
|
| 74 |
+
'label' => '',
|
| 75 |
+
'desc' => '',
|
| 76 |
+
'type' => 'text',
|
| 77 |
+
);
|
| 78 |
+
|
| 79 |
+
$arg = wp_parse_args( $field, $defaults );
|
| 80 |
+
$this->settings_fields[ $section ][] = $arg;
|
| 81 |
+
|
| 82 |
+
return $this;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* Initialize and registers the settings sections and fileds to WordPress
|
| 87 |
+
*
|
| 88 |
+
* Usually this should be called at `admin_init` hook.
|
| 89 |
+
*
|
| 90 |
+
* This function gets the initiated settings sections and fields. Then
|
| 91 |
+
* registers them to WordPress and ready for use.
|
| 92 |
+
*/
|
| 93 |
+
function admin_init() {
|
| 94 |
+
// register settings sections
|
| 95 |
+
foreach ( $this->settings_sections as $section ) {
|
| 96 |
+
if ( false == get_option( $section['id'] ) ) {
|
| 97 |
+
add_option( $section['id'] );
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
if ( isset( $section['desc'] ) && ! empty( $section['desc'] ) ) {
|
| 101 |
+
$section['desc'] = '<div class="inside">' . $section['desc'] . '</div>';
|
| 102 |
+
$callback = create_function( '', 'echo "' . str_replace( '"', '\"', $section['desc'] ) . '";' );
|
| 103 |
+
} elseif ( isset( $section['callback'] ) ) {
|
| 104 |
+
$callback = $section['callback'];
|
| 105 |
+
} else {
|
| 106 |
+
$callback = null;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
add_settings_section( $section['id'], $section['title'], $callback, $section['id'] );
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
// register settings fields
|
| 113 |
+
foreach ( $this->settings_fields as $section => $field ) {
|
| 114 |
+
foreach ( $field as $option ) {
|
| 115 |
+
|
| 116 |
+
$name = $option['name'];
|
| 117 |
+
$type = isset( $option['type'] ) ? $option['type'] : 'text';
|
| 118 |
+
$label = isset( $option['label'] ) ? $option['label'] : '';
|
| 119 |
+
$callback = isset( $option['callback'] ) ? $option['callback'] : array( $this, 'callback_' . $type );
|
| 120 |
+
|
| 121 |
+
$args = array(
|
| 122 |
+
'id' => $name,
|
| 123 |
+
'class' => isset( $option['class'] ) ? $option['class'] : $name,
|
| 124 |
+
'label_for' => "{$section}[{$name}]",
|
| 125 |
+
'desc' => isset( $option['desc'] ) ? $option['desc'] : '',
|
| 126 |
+
'name' => $label,
|
| 127 |
+
'section' => $section,
|
| 128 |
+
'size' => isset( $option['size'] ) ? $option['size'] : null,
|
| 129 |
+
'options' => isset( $option['options'] ) ? $option['options'] : '',
|
| 130 |
+
'std' => isset( $option['default'] ) ? $option['default'] : '',
|
| 131 |
+
'sanitize_callback' => isset( $option['sanitize_callback'] ) ? $option['sanitize_callback'] : '',
|
| 132 |
+
'type' => $type,
|
| 133 |
+
'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : '',
|
| 134 |
+
'min' => isset( $option['min'] ) ? $option['min'] : '',
|
| 135 |
+
'max' => isset( $option['max'] ) ? $option['max'] : '',
|
| 136 |
+
'step' => isset( $option['step'] ) ? $option['step'] : '',
|
| 137 |
+
);
|
| 138 |
+
|
| 139 |
+
add_settings_field( "{$section}[{$name}]", $label, $callback, $section, $section, $args );
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
// creates our settings in the options table
|
| 144 |
+
foreach ( $this->settings_sections as $section ) {
|
| 145 |
+
register_setting( $section['id'], $section['id'], array( $this, 'sanitize_options' ) );
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
/**
|
| 150 |
+
* Get field description for display
|
| 151 |
+
*
|
| 152 |
+
* @param array $args settings field args
|
| 153 |
+
*/
|
| 154 |
+
public function get_field_description( $args ) {
|
| 155 |
+
if ( ! empty( $args['desc'] ) ) {
|
| 156 |
+
$desc = sprintf( '<p class="description">%s</p>', $args['desc'] );
|
| 157 |
+
} else {
|
| 158 |
+
$desc = '';
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
return $desc;
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
/**
|
| 165 |
+
* Displays a text field for a settings field
|
| 166 |
+
*
|
| 167 |
+
* @param array $args settings field args
|
| 168 |
+
*/
|
| 169 |
+
function callback_text( $args ) {
|
| 170 |
+
|
| 171 |
+
$value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
|
| 172 |
+
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular';
|
| 173 |
+
$type = isset( $args['type'] ) ? $args['type'] : 'text';
|
| 174 |
+
$placeholder = empty( $args['placeholder'] ) ? '' : ' placeholder="' . $args['placeholder'] . '"';
|
| 175 |
+
|
| 176 |
+
$html = sprintf( '<input type="%1$s" class="%2$s-text" id="%3$s[%4$s]" name="%3$s[%4$s]" value="%5$s"%6$s/>', $type, $size, $args['section'], $args['id'], $value, $placeholder );
|
| 177 |
+
$html .= $this->get_field_description( $args );
|
| 178 |
+
|
| 179 |
+
echo $html;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
/**
|
| 183 |
+
* Displays a url field for a settings field
|
| 184 |
+
*
|
| 185 |
+
* @param array $args settings field args
|
| 186 |
+
*/
|
| 187 |
+
function callback_url( $args ) {
|
| 188 |
+
$this->callback_text( $args );
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
/**
|
| 192 |
+
* Displays a number field for a settings field
|
| 193 |
+
*
|
| 194 |
+
* @param array $args settings field args
|
| 195 |
+
*/
|
| 196 |
+
function callback_number( $args ) {
|
| 197 |
+
$value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
|
| 198 |
+
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular';
|
| 199 |
+
$type = isset( $args['type'] ) ? $args['type'] : 'number';
|
| 200 |
+
$placeholder = empty( $args['placeholder'] ) ? '' : ' placeholder="' . $args['placeholder'] . '"';
|
| 201 |
+
$min = empty( $args['min'] ) ? '' : ' min="' . $args['min'] . '"';
|
| 202 |
+
$max = empty( $args['max'] ) ? '' : ' max="' . $args['max'] . '"';
|
| 203 |
+
$step = empty( $args['max'] ) ? '' : ' step="' . $args['step'] . '"';
|
| 204 |
+
|
| 205 |
+
$html = sprintf( '<input type="%1$s" class="%2$s-number" id="%3$s[%4$s]" name="%3$s[%4$s]" value="%5$s"%6$s%7$s%8$s%9$s/>', $type, $size, $args['section'], $args['id'], $value, $placeholder, $min, $max, $step );
|
| 206 |
+
$html .= $this->get_field_description( $args );
|
| 207 |
+
|
| 208 |
+
echo $html;
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
/**
|
| 212 |
+
* Displays a checkbox for a settings field
|
| 213 |
+
*
|
| 214 |
+
* @param array $args settings field args
|
| 215 |
+
*/
|
| 216 |
+
function callback_checkbox( $args ) {
|
| 217 |
+
|
| 218 |
+
$value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
|
| 219 |
+
|
| 220 |
+
$html = '<fieldset>';
|
| 221 |
+
$html .= sprintf( '<label for="wpuf-%1$s[%2$s]">', $args['section'], $args['id'] );
|
| 222 |
+
$html .= sprintf( '<input type="hidden" name="%1$s[%2$s]" value="off" />', $args['section'], $args['id'] );
|
| 223 |
+
$html .= sprintf( '<input type="checkbox" class="checkbox" id="wpuf-%1$s[%2$s]" name="%1$s[%2$s]" value="on" %3$s />', $args['section'], $args['id'], checked( $value, 'on', false ) );
|
| 224 |
+
$html .= sprintf( '%1$s</label>', $args['desc'] );
|
| 225 |
+
$html .= '</fieldset>';
|
| 226 |
+
|
| 227 |
+
echo $html;
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
/**
|
| 231 |
+
* Displays a multicheckbox a settings field
|
| 232 |
+
*
|
| 233 |
+
* @param array $args settings field args
|
| 234 |
+
*/
|
| 235 |
+
function callback_multicheck( $args ) {
|
| 236 |
+
|
| 237 |
+
$value = $this->get_option( $args['id'], $args['section'], $args['std'] );
|
| 238 |
+
$html = '<fieldset>';
|
| 239 |
+
$html .= sprintf( '<input type="hidden" name="%1$s[%2$s]" value="" />', $args['section'], $args['id'] );
|
| 240 |
+
foreach ( $args['options'] as $key => $label ) {
|
| 241 |
+
$checked = isset( $value[ $key ] ) ? $value[ $key ] : '0';
|
| 242 |
+
$html .= sprintf( '<label for="wpuf-%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key );
|
| 243 |
+
$html .= sprintf( '<input type="checkbox" class="checkbox" id="wpuf-%1$s[%2$s][%3$s]" name="%1$s[%2$s][%3$s]" value="%3$s" %4$s />', $args['section'], $args['id'], $key, checked( $checked, $key, false ) );
|
| 244 |
+
$html .= sprintf( '%1$s</label><br>', $label );
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
$html .= $this->get_field_description( $args );
|
| 248 |
+
$html .= '</fieldset>';
|
| 249 |
+
|
| 250 |
+
echo $html;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
/**
|
| 254 |
+
* Displays a multicheckbox a settings field
|
| 255 |
+
*
|
| 256 |
+
* @param array $args settings field args
|
| 257 |
+
*/
|
| 258 |
+
function callback_radio( $args ) {
|
| 259 |
+
|
| 260 |
+
$value = $this->get_option( $args['id'], $args['section'], $args['std'] );
|
| 261 |
+
$html = '<fieldset>';
|
| 262 |
+
|
| 263 |
+
foreach ( $args['options'] as $key => $label ) {
|
| 264 |
+
$html .= sprintf( '<label for="wpuf-%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key );
|
| 265 |
+
$html .= sprintf( '<input type="radio" class="radio" id="wpuf-%1$s[%2$s][%3$s]" name="%1$s[%2$s]" value="%3$s" %4$s />', $args['section'], $args['id'], $key, checked( $value, $key, false ) );
|
| 266 |
+
$html .= sprintf( '%1$s</label><br>', $label );
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
$html .= $this->get_field_description( $args );
|
| 270 |
+
$html .= '</fieldset>';
|
| 271 |
+
|
| 272 |
+
echo $html;
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
/**
|
| 276 |
+
* Displays a selectbox for a settings field
|
| 277 |
+
*
|
| 278 |
+
* @param array $args settings field args
|
| 279 |
+
*/
|
| 280 |
+
function callback_select( $args ) {
|
| 281 |
+
|
| 282 |
+
$value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
|
| 283 |
+
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular';
|
| 284 |
+
$html = sprintf( '<select class="%1$s" name="%2$s[%3$s]" id="%2$s[%3$s]">', $size, $args['section'], $args['id'] );
|
| 285 |
+
|
| 286 |
+
foreach ( $args['options'] as $key => $label ) {
|
| 287 |
+
$html .= sprintf( '<option value="%s"%s>%s</option>', $key, selected( $value, $key, false ), $label );
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
$html .= sprintf( '</select>' );
|
| 291 |
+
$html .= $this->get_field_description( $args );
|
| 292 |
+
|
| 293 |
+
echo $html;
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
/**
|
| 297 |
+
* Displays a textarea for a settings field
|
| 298 |
+
*
|
| 299 |
+
* @param array $args settings field args
|
| 300 |
+
*/
|
| 301 |
+
function callback_textarea( $args ) {
|
| 302 |
+
|
| 303 |
+
$value = esc_textarea( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
|
| 304 |
+
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular';
|
| 305 |
+
$placeholder = empty( $args['placeholder'] ) ? '' : ' placeholder="' . $args['placeholder'] . '"';
|
| 306 |
+
|
| 307 |
+
$html = sprintf( '<textarea rows="5" cols="100" class="%1$s-text" id="%2$s[%3$s]" name="%2$s[%3$s]"%4$s>%5$s</textarea>', $size, $args['section'], $args['id'], $placeholder, $value );
|
| 308 |
+
$html .= $this->get_field_description( $args );
|
| 309 |
+
|
| 310 |
+
echo $html;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
/**
|
| 314 |
+
* Displays a textarea for a settings field
|
| 315 |
+
*
|
| 316 |
+
* @param array $args settings field args
|
| 317 |
+
* @return string
|
| 318 |
+
*/
|
| 319 |
+
function callback_html( $args ) {
|
| 320 |
+
echo $this->get_field_description( $args );
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
/**
|
| 324 |
+
* Displays a rich text textarea for a settings field
|
| 325 |
+
*
|
| 326 |
+
* @param array $args settings field args
|
| 327 |
+
*/
|
| 328 |
+
function callback_wysiwyg( $args ) {
|
| 329 |
+
|
| 330 |
+
$value = $this->get_option( $args['id'], $args['section'], $args['std'] );
|
| 331 |
+
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : '500px';
|
| 332 |
+
|
| 333 |
+
echo '<div style="max-width: ' . $size . ';">';
|
| 334 |
+
|
| 335 |
+
$editor_settings = array(
|
| 336 |
+
'teeny' => true,
|
| 337 |
+
'textarea_name' => $args['section'] . '[' . $args['id'] . ']',
|
| 338 |
+
'textarea_rows' => 10,
|
| 339 |
+
);
|
| 340 |
+
|
| 341 |
+
if ( isset( $args['options'] ) && is_array( $args['options'] ) ) {
|
| 342 |
+
$editor_settings = array_merge( $editor_settings, $args['options'] );
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
wp_editor( $value, $args['section'] . '-' . $args['id'], $editor_settings );
|
| 346 |
+
|
| 347 |
+
echo '</div>';
|
| 348 |
+
|
| 349 |
+
echo $this->get_field_description( $args );
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
/**
|
| 353 |
+
* Displays a file upload field for a settings field
|
| 354 |
+
*
|
| 355 |
+
* @param array $args settings field args
|
| 356 |
+
*/
|
| 357 |
+
function callback_file( $args ) {
|
| 358 |
+
|
| 359 |
+
$value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
|
| 360 |
+
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular';
|
| 361 |
+
$id = $args['section'] . '[' . $args['id'] . ']';
|
| 362 |
+
$label = isset( $args['options']['button_label'] ) ? $args['options']['button_label'] : __( 'Choose File' );
|
| 363 |
+
|
| 364 |
+
$html = sprintf( '<input type="text" class="%1$s-text wpsa-url" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s"/>', $size, $args['section'], $args['id'], $value );
|
| 365 |
+
$html .= '<input type="button" class="button wpsa-browse" value="' . $label . '" />';
|
| 366 |
+
$html .= $this->get_field_description( $args );
|
| 367 |
+
|
| 368 |
+
echo $html;
|
| 369 |
+
}
|
| 370 |
+
|
| 371 |
+
/**
|
| 372 |
+
* Displays a password field for a settings field
|
| 373 |
+
*
|
| 374 |
+
* @param array $args settings field args
|
| 375 |
+
*/
|
| 376 |
+
function callback_password( $args ) {
|
| 377 |
+
|
| 378 |
+
$value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
|
| 379 |
+
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular';
|
| 380 |
+
|
| 381 |
+
$html = sprintf( '<input type="password" class="%1$s-text" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s"/>', $size, $args['section'], $args['id'], $value );
|
| 382 |
+
$html .= $this->get_field_description( $args );
|
| 383 |
+
|
| 384 |
+
echo $html;
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
/**
|
| 388 |
+
* Displays a color picker field for a settings field
|
| 389 |
+
*
|
| 390 |
+
* @param array $args settings field args
|
| 391 |
+
*/
|
| 392 |
+
function callback_color( $args ) {
|
| 393 |
+
|
| 394 |
+
$value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
|
| 395 |
+
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular';
|
| 396 |
+
|
| 397 |
+
$html = sprintf( '<input type="text" class="%1$s-text wp-color-picker-field" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s" data-default-color="%5$s" />', $size, $args['section'], $args['id'], $value, $args['std'] );
|
| 398 |
+
$html .= $this->get_field_description( $args );
|
| 399 |
+
|
| 400 |
+
echo $html;
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
/**
|
| 404 |
+
* Sanitize callback for Settings API
|
| 405 |
+
*
|
| 406 |
+
* @return mixed
|
| 407 |
+
*/
|
| 408 |
+
function sanitize_options( $options ) {
|
| 409 |
+
|
| 410 |
+
if ( ! $options ) {
|
| 411 |
+
return $options;
|
| 412 |
+
}
|
| 413 |
+
|
| 414 |
+
foreach ( $options as $option_slug => $option_value ) {
|
| 415 |
+
$sanitize_callback = $this->get_sanitize_callback( $option_slug );
|
| 416 |
+
|
| 417 |
+
// If callback is set, call it
|
| 418 |
+
if ( $sanitize_callback ) {
|
| 419 |
+
$options[ $option_slug ] = call_user_func( $sanitize_callback, $option_value );
|
| 420 |
+
continue;
|
| 421 |
+
}
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
return $options;
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
/**
|
| 428 |
+
* Get sanitization callback for given option slug
|
| 429 |
+
*
|
| 430 |
+
* @param string $slug option slug
|
| 431 |
+
*
|
| 432 |
+
* @return mixed string or bool false
|
| 433 |
+
*/
|
| 434 |
+
function get_sanitize_callback( $slug = '' ) {
|
| 435 |
+
if ( empty( $slug ) ) {
|
| 436 |
+
return false;
|
| 437 |
+
}
|
| 438 |
+
|
| 439 |
+
// Iterate over registered fields and see if we can find proper callback
|
| 440 |
+
foreach ( $this->settings_fields as $section => $options ) {
|
| 441 |
+
foreach ( $options as $option ) {
|
| 442 |
+
if ( $option['name'] != $slug ) {
|
| 443 |
+
continue;
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
// Return the callback name
|
| 447 |
+
return isset( $option['sanitize_callback'] ) && is_callable( $option['sanitize_callback'] ) ? $option['sanitize_callback'] : false;
|
| 448 |
+
}
|
| 449 |
+
}
|
| 450 |
+
|
| 451 |
+
return false;
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
/**
|
| 455 |
+
* Get the value of a settings field
|
| 456 |
+
*
|
| 457 |
+
* @param string $option settings field name
|
| 458 |
+
* @param string $section the section name this field belongs to
|
| 459 |
+
* @param string $default default text if it's not found
|
| 460 |
+
* @return string
|
| 461 |
+
*/
|
| 462 |
+
function get_option( $option, $section, $default = '' ) {
|
| 463 |
+
|
| 464 |
+
$options = get_option( $section );
|
| 465 |
+
|
| 466 |
+
if ( isset( $options[ $option ] ) ) {
|
| 467 |
+
return $options[ $option ];
|
| 468 |
+
}
|
| 469 |
+
|
| 470 |
+
return $default;
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
/**
|
| 474 |
+
* Show navigations as tab
|
| 475 |
+
*
|
| 476 |
+
* Shows all the settings section labels as tab
|
| 477 |
+
*/
|
| 478 |
+
function show_navigation() {
|
| 479 |
+
$html = '<h2 class="nav-tab-wrapper">';
|
| 480 |
+
|
| 481 |
+
$count = count( $this->settings_sections );
|
| 482 |
+
|
| 483 |
+
// don't show the navigation if only one section exists
|
| 484 |
+
if ( $count === 1 ) {
|
| 485 |
+
// return;
|
| 486 |
+
}
|
| 487 |
+
|
| 488 |
+
foreach ( $this->settings_sections as $tab ) {
|
| 489 |
+
$html .= sprintf( '<a href="#%1$s" class="nav-tab" id="%1$s-tab">%2$s</a>', $tab['id'], $tab['title'] );
|
| 490 |
+
}
|
| 491 |
+
|
| 492 |
+
$html .= '</h2>';
|
| 493 |
+
|
| 494 |
+
echo $html;
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
/**
|
| 498 |
+
* Show the section settings forms
|
| 499 |
+
*
|
| 500 |
+
* This function displays every sections in a different form
|
| 501 |
+
*/
|
| 502 |
+
function show_forms() {
|
| 503 |
+
?>
|
| 504 |
+
<div class="header-and-footer-setting">
|
| 505 |
+
<?php foreach ( $this->settings_sections as $form ) { ?>
|
| 506 |
+
<div id="<?php echo $form['id']; ?>" class="group" style="display: none;">
|
| 507 |
+
<form method="post" action="options.php">
|
| 508 |
+
<?php
|
| 509 |
+
do_action( 'wsa_form_top_' . $form['id'], $form );
|
| 510 |
+
settings_fields( $form['id'] );
|
| 511 |
+
do_settings_sections( $form['id'] );
|
| 512 |
+
do_action( 'wsa_form_bottom_' . $form['id'], $form );
|
| 513 |
+
if ( isset( $this->settings_fields[ $form['id'] ] ) ) :
|
| 514 |
+
?>
|
| 515 |
+
<div style="padding-left: 10px">
|
| 516 |
+
<?php submit_button(); ?>
|
| 517 |
+
</div>
|
| 518 |
+
<?php endif; ?>
|
| 519 |
+
</form>
|
| 520 |
+
</div>
|
| 521 |
+
<?php } ?>
|
| 522 |
+
</div>
|
| 523 |
+
<div class="wpbr-sidebar">
|
| 524 |
+
<div class="sidebar postbox">
|
| 525 |
+
<h2> <span class="dashicons dashicons-share"></span> <?php esc_html_e( 'Spread the Word', 'wp-header-and-footer' ); ?></h2>
|
| 526 |
+
<ul>
|
| 527 |
+
<li>
|
| 528 |
+
<a href="http://twitter.com/share?text=This is Best header and footer code JS and CSS insert plugin without touching theme files;url=https://wordpress.org/plugins/wp-headers-and-footers/" data-count="none" class="button twitter" target="_blank" title="<?php esc_html_e( 'Post to Twitter Now', 'wp-header-and-footer' ); ?>"><?php esc_html_e( 'Share on Twitter', 'wp-header-and-footer' ); ?><span class="dashicons dashicons-twitter"></span></a>
|
| 529 |
+
</li>
|
| 530 |
+
<li>
|
| 531 |
+
<a href="https://www.facebook.com/sharer/sharer.php?u=https://wordpress.org/plugins/wp-headers-and-footers/" class="button facebook" target="_blank" title="<?php esc_html_e( 'Share with your facebook friends about this awesome plugin', 'wp-header-and-footer' ); ?>"><?php esc_html_e( 'Share on Facebook', 'wp-header-and-footer' ); ?><span class="dashicons dashicons-facebook"></span>
|
| 532 |
+
</a>
|
| 533 |
+
</li>
|
| 534 |
+
<li>
|
| 535 |
+
<a href="https://wordpress.org/support/plugin/wp-headers-and-footers/reviews/#new-post" class="button wordpress" target="_blank" title="Rate on WordPress.org"><?php esc_html_e( 'Rate on WordPress.org', 'wp-header-and-footer' ); ?><span class="dashicons dashicons-wordpress"></span>
|
| 536 |
+
</a>
|
| 537 |
+
</li>
|
| 538 |
+
</ul>
|
| 539 |
+
</div>
|
| 540 |
+
<div class="sidebar postbox">
|
| 541 |
+
<h2><span class="dashicons dashicons-share-alt"> </span><?php esc_html_e( 'Recommended Plugins', 'wp-header-and-footer' ); ?></h2>
|
| 542 |
+
<!-- <p>Following are the plugins highly recommend by Team WPBrigade.</p> -->
|
| 543 |
+
<ul class="plugins_lists">
|
| 544 |
+
<li>
|
| 545 |
+
<a href="https://wpbrigade.com/wordpress/plugins/loginpress-pro/?utm_source=wp-header-and-footer&utm_medium=sidebar&utm_campaign=pro-upgrade" data-count="none" target="_blank" title="<?php esc_html_e( 'Customize your login screen', 'wp-header-and-footer' ); ?>">LoginPress - Login Customizer</a>
|
| 546 |
+
</li>
|
| 547 |
+
|
| 548 |
+
<li>
|
| 549 |
+
<a href="https://analytify.io/ref/73/?utm_source=wp-header-and-footer&utm_medium=sidebar&utm_campaign=pro-upgrade" target="_blank" title="<?php esc_html_e( 'Share with your facebook friends about this awesome plugin.', 'wp-header-and-footer' ); ?>">Google Analytics by Analytify
|
| 550 |
+
</a>
|
| 551 |
+
</li>
|
| 552 |
+
|
| 553 |
+
<li>
|
| 554 |
+
<a href="https://simplesocialbuttons.com?utm_source=wp-header-and-footer&utm_medium=sidebar&utm_campaign=pro-upgrade" target="_blank" title="<?php esc_html_e( 'Socialize your Website', 'wp-header-and-footer' ); ?>">Simple Social Buttons
|
| 555 |
+
</a>
|
| 556 |
+
</li>
|
| 557 |
+
<li>
|
| 558 |
+
<a href="http://wpbrigade.com/recommend/maintenance-mode?utm_source=wp-header-and-footer&utm_medium=sidebar&utm_campaign=pro-upgrade" target="_blank" title="<?php esc_html_e( 'Socialize your Website', 'wp-header-and-footer' ); ?>">Under Construction & Maintenance mode
|
| 559 |
+
</a>
|
| 560 |
+
</li>
|
| 561 |
+
</ul>
|
| 562 |
+
</div>
|
| 563 |
+
</div>
|
| 564 |
+
<?php
|
| 565 |
+
$this->script();
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
/**
|
| 569 |
+
* Tabbable JavaScript codes & Initiate Color Picker
|
| 570 |
+
*
|
| 571 |
+
* This code uses localstorage for displaying active tabs
|
| 572 |
+
*/
|
| 573 |
+
function script() {
|
| 574 |
+
?>
|
| 575 |
+
<script>
|
| 576 |
+
jQuery(document).ready(function($) {
|
| 577 |
+
//Initiate Color Picker
|
| 578 |
+
$('.wp-color-picker-field').wpColorPicker();
|
| 579 |
+
|
| 580 |
+
// Switches option sections
|
| 581 |
+
$('.group').hide();
|
| 582 |
+
var activetab = '';
|
| 583 |
+
if (typeof(localStorage) != 'undefined' ) {
|
| 584 |
+
activetab = localStorage.getItem("activetab");
|
| 585 |
+
}
|
| 586 |
+
if (activetab != '' && $(activetab).length ) {
|
| 587 |
+
$(activetab).fadeIn();
|
| 588 |
+
} else {
|
| 589 |
+
$('.group:first').fadeIn();
|
| 590 |
+
}
|
| 591 |
+
$('.group .collapsed').each(function(){
|
| 592 |
+
$(this).find('input:checked').parent().parent().parent().nextAll().each(
|
| 593 |
+
function(){
|
| 594 |
+
if ($(this).hasClass('last')) {
|
| 595 |
+
$(this).removeClass('hidden');
|
| 596 |
+
return false;
|
| 597 |
+
}
|
| 598 |
+
$(this).filter('.hidden').removeClass('hidden');
|
| 599 |
+
});
|
| 600 |
+
});
|
| 601 |
+
|
| 602 |
+
if (activetab != '' && $(activetab + '-tab').length ) {
|
| 603 |
+
$(activetab + '-tab').addClass('nav-tab-active');
|
| 604 |
+
}
|
| 605 |
+
else {
|
| 606 |
+
$('.nav-tab-wrapper a:first').addClass('nav-tab-active');
|
| 607 |
+
}
|
| 608 |
+
$('.nav-tab-wrapper a').click(function(evt) {
|
| 609 |
+
$('.nav-tab-wrapper a').removeClass('nav-tab-active');
|
| 610 |
+
$(this).addClass('nav-tab-active').blur();
|
| 611 |
+
var clicked_group = $(this).attr('href');
|
| 612 |
+
if (typeof(localStorage) != 'undefined' ) {
|
| 613 |
+
localStorage.setItem("activetab", $(this).attr('href'));
|
| 614 |
+
}
|
| 615 |
+
$('.group').hide();
|
| 616 |
+
$(clicked_group).fadeIn();
|
| 617 |
+
evt.preventDefault();
|
| 618 |
+
});
|
| 619 |
+
|
| 620 |
+
$('.wpsa-browse').on('click', function (event) {
|
| 621 |
+
event.preventDefault();
|
| 622 |
+
|
| 623 |
+
var self = $(this);
|
| 624 |
+
|
| 625 |
+
// Create the media frame.
|
| 626 |
+
var file_frame = wp.media.frames.file_frame = wp.media({
|
| 627 |
+
title: self.data('uploader_title'),
|
| 628 |
+
button: {
|
| 629 |
+
text: self.data('uploader_button_text'),
|
| 630 |
+
},
|
| 631 |
+
multiple: false
|
| 632 |
+
});
|
| 633 |
+
|
| 634 |
+
file_frame.on('select', function () {
|
| 635 |
+
attachment = file_frame.state().get('selection').first().toJSON();
|
| 636 |
+
self.prev('.wpsa-url').val(attachment.url).change();
|
| 637 |
+
});
|
| 638 |
+
|
| 639 |
+
// Finally, open the modal
|
| 640 |
+
file_frame.open();
|
| 641 |
+
});
|
| 642 |
+
});
|
| 643 |
+
</script>
|
| 644 |
+
<?php
|
| 645 |
+
$this->_style_fix();
|
| 646 |
+
}
|
| 647 |
+
|
| 648 |
+
function _style_fix() {
|
| 649 |
+
global $wp_version;
|
| 650 |
+
|
| 651 |
+
if ( version_compare( $wp_version, '3.8', '<=' ) ) :
|
| 652 |
+
?>
|
| 653 |
+
<style type="text/css">
|
| 654 |
+
/** WordPress 3.8 Fix **/
|
| 655 |
+
.form-table th { padding: 20px 10px; }
|
| 656 |
+
#wpbody-content .metabox-holder { padding-top: 5px; }
|
| 657 |
+
</style>
|
| 658 |
+
<?php
|
| 659 |
+
endif;
|
| 660 |
+
}
|
| 661 |
+
|
| 662 |
+
}
|
| 663 |
|
| 664 |
endif;
|
classes/class-setup.php
CHANGED
|
@@ -1,102 +1,102 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
/**
|
| 4 |
-
* WordPress
|
| 5 |
*/
|
| 6 |
-
if ( !class_exists('WPHeaderAndFooter_Setting' ) ):
|
| 7 |
-
class WPHeaderAndFooter_Setting {
|
| 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 |
endif;
|
| 1 |
<?php
|
| 2 |
|
| 3 |
/**
|
| 4 |
+
* WordPress Header and Footer Setup
|
| 5 |
*/
|
| 6 |
+
if ( ! class_exists( 'WPHeaderAndFooter_Setting' ) ) :
|
| 7 |
+
class WPHeaderAndFooter_Setting {
|
| 8 |
+
|
| 9 |
+
private $settings_api;
|
| 10 |
+
|
| 11 |
+
function __construct() {
|
| 12 |
+
|
| 13 |
+
include_once WPHEADERANDFOOTER_DIR_PATH . 'classes/class-settings-api.php';
|
| 14 |
+
$this->settings_api = new WPHeaderAndFooter_Settings_API();
|
| 15 |
+
|
| 16 |
+
add_action( 'admin_init', array( $this, 'admin_init' ) );
|
| 17 |
+
add_action( 'admin_menu', array( $this, 'register_options_page' ) );
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
function admin_init() {
|
| 21 |
+
|
| 22 |
+
// set the settings
|
| 23 |
+
$this->settings_api->set_sections( $this->get_settings_sections() );
|
| 24 |
+
$this->settings_api->set_fields( $this->get_settings_fields() );
|
| 25 |
+
|
| 26 |
+
// initialize settings
|
| 27 |
+
$this->settings_api->admin_init();
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* Register the plugin settings panel
|
| 32 |
+
*/
|
| 33 |
+
function register_options_page() {
|
| 34 |
+
|
| 35 |
+
add_submenu_page( 'options-general.php', __( 'WP Headers and Footers', 'wp-header-and-footer' ), __( 'WP Headers and Footers', 'wp-header-and-footer' ), 'manage_options', 'wp-header-and-footer', array( $this, 'wp_header_and_footer_callback' ) );
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
function get_settings_sections() {
|
| 39 |
+
$sections = array(
|
| 40 |
+
array(
|
| 41 |
+
'id' => 'wpheaderandfooter_basics',
|
| 42 |
+
'title' => __( 'Settings', 'wp-header-and-footer' ),
|
| 43 |
+
'desc' => __( 'WP Headers and Footers.', 'wp-header-and-footer' ),
|
| 44 |
+
),
|
| 45 |
+
);
|
| 46 |
+
return $sections;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* Returns all the settings fields
|
| 51 |
+
*
|
| 52 |
+
* @return array settings fields
|
| 53 |
+
*/
|
| 54 |
+
function get_settings_fields() {
|
| 55 |
+
$settings_fields = array(
|
| 56 |
+
'wpheaderandfooter_basics' => array(
|
| 57 |
+
array(
|
| 58 |
+
'name' => 'wp_header_textarea',
|
| 59 |
+
'label' => __( 'Scripts in Header', 'wp-header-and-footer' ),
|
| 60 |
+
'desc' => sprintf( __( 'These scripts will be printed in the %1$s%2$s%3$s section.', 'wp-header-and-footer' ), '<', 'head', '>' ),
|
| 61 |
+
'type' => 'textarea',
|
| 62 |
+
),
|
| 63 |
+
array(
|
| 64 |
+
'name' => 'wp_footer_textarea',
|
| 65 |
+
'label' => __( 'Scripts in Footer', 'wp-header-and-footer' ),
|
| 66 |
+
'desc' => sprintf( __( 'These scripts will be printed above the %1$s%2$s%3$s tag.', 'wp-header-and-footer' ), '<', '/body', '>' ),
|
| 67 |
+
'type' => 'textarea',
|
| 68 |
+
),
|
| 69 |
+
),
|
| 70 |
+
);
|
| 71 |
+
|
| 72 |
+
return $settings_fields;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
function wp_header_and_footer_callback() {
|
| 76 |
+
echo '<div class="wrap wp-header-and-footer">';
|
| 77 |
+
|
| 78 |
+
$this->settings_api->show_navigation();
|
| 79 |
+
$this->settings_api->show_forms();
|
| 80 |
+
|
| 81 |
+
echo '</div>';
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* Get all the pages
|
| 86 |
+
*
|
| 87 |
+
* @return array page names with key value pairs
|
| 88 |
+
*/
|
| 89 |
+
function get_pages() {
|
| 90 |
+
$pages = get_pages();
|
| 91 |
+
$pages_options = array();
|
| 92 |
+
if ( $pages ) {
|
| 93 |
+
foreach ( $pages as $page ) {
|
| 94 |
+
$pages_options[ $page->ID ] = $page->post_title;
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
return $pages_options;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
}
|
| 102 |
endif;
|
languages/wp-header-and-footer.pot
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (C) 2020 WPBrigade
|
| 2 |
+
# This file is distributed under the same license as the WP Headers and Footers plugin.
|
| 3 |
+
msgid ""
|
| 4 |
+
msgstr ""
|
| 5 |
+
"Project-Id-Version: 1.1.0\n"
|
| 6 |
+
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-header-and-footer\n"
|
| 7 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
| 8 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
| 9 |
+
"MIME-Version: 1.0\n"
|
| 10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
| 11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
| 12 |
+
"POT-Creation-Date: 2020-02-21T10:55:12+00:00\n"
|
| 13 |
+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
| 14 |
+
"X-Generator: WP-CLI 2.4.0\n"
|
| 15 |
+
"X-Domain: wp-header-and-footer\n"
|
| 16 |
+
|
| 17 |
+
#. Plugin Name of the plugin
|
| 18 |
+
#: classes/class-setup.php:35
|
| 19 |
+
msgid "WP Headers and Footers"
|
| 20 |
+
msgstr ""
|
| 21 |
+
|
| 22 |
+
#. Plugin URI of the plugin
|
| 23 |
+
msgid "http://www.WPBrigade.com/wordpress/plugins/wp-headers-and-footers/"
|
| 24 |
+
msgstr ""
|
| 25 |
+
|
| 26 |
+
#. Description of the plugin
|
| 27 |
+
msgid "Allows you to insert code or text in the header or footer of your WordPress site."
|
| 28 |
+
msgstr ""
|
| 29 |
+
|
| 30 |
+
#. Author of the plugin
|
| 31 |
+
msgid "WPBrigade"
|
| 32 |
+
msgstr ""
|
| 33 |
+
|
| 34 |
+
#. Author URI of the plugin
|
| 35 |
+
msgid "https://www.WPBrigade.com/"
|
| 36 |
+
msgstr ""
|
| 37 |
+
|
| 38 |
+
#: classes/class-settings-api.php:525
|
| 39 |
+
msgid "Spread the Word"
|
| 40 |
+
msgstr ""
|
| 41 |
+
|
| 42 |
+
#: classes/class-settings-api.php:528
|
| 43 |
+
msgid "Post to Twitter Now"
|
| 44 |
+
msgstr ""
|
| 45 |
+
|
| 46 |
+
#: classes/class-settings-api.php:528
|
| 47 |
+
msgid "Share on Twitter"
|
| 48 |
+
msgstr ""
|
| 49 |
+
|
| 50 |
+
#: classes/class-settings-api.php:531
|
| 51 |
+
msgid "Share with your facebook friends about this awesome plugin"
|
| 52 |
+
msgstr ""
|
| 53 |
+
|
| 54 |
+
#: classes/class-settings-api.php:531
|
| 55 |
+
msgid "Share on Facebook"
|
| 56 |
+
msgstr ""
|
| 57 |
+
|
| 58 |
+
#: classes/class-settings-api.php:535
|
| 59 |
+
msgid "Rate on WordPress.org"
|
| 60 |
+
msgstr ""
|
| 61 |
+
|
| 62 |
+
#: classes/class-settings-api.php:541
|
| 63 |
+
msgid "Recommended Plugins"
|
| 64 |
+
msgstr ""
|
| 65 |
+
|
| 66 |
+
#: classes/class-settings-api.php:545
|
| 67 |
+
msgid "Customize your login screen"
|
| 68 |
+
msgstr ""
|
| 69 |
+
|
| 70 |
+
#: classes/class-settings-api.php:549
|
| 71 |
+
msgid "Share with your facebook friends about this awesome plugin."
|
| 72 |
+
msgstr ""
|
| 73 |
+
|
| 74 |
+
#: classes/class-settings-api.php:554
|
| 75 |
+
#: classes/class-settings-api.php:558
|
| 76 |
+
msgid "Socialize your Website"
|
| 77 |
+
msgstr ""
|
| 78 |
+
|
| 79 |
+
#: classes/class-setup.php:42
|
| 80 |
+
msgid "Settings"
|
| 81 |
+
msgstr ""
|
| 82 |
+
|
| 83 |
+
#: classes/class-setup.php:43
|
| 84 |
+
msgid "WP Headers and Footers."
|
| 85 |
+
msgstr ""
|
| 86 |
+
|
| 87 |
+
#: classes/class-setup.php:59
|
| 88 |
+
msgid "Scripts in Header"
|
| 89 |
+
msgstr ""
|
| 90 |
+
|
| 91 |
+
#: classes/class-setup.php:60
|
| 92 |
+
msgid "These scripts will be printed in the %1$s%2$s%3$s section."
|
| 93 |
+
msgstr ""
|
| 94 |
+
|
| 95 |
+
#: classes/class-setup.php:65
|
| 96 |
+
msgid "Scripts in Footer"
|
| 97 |
+
msgstr ""
|
| 98 |
+
|
| 99 |
+
#: classes/class-setup.php:66
|
| 100 |
+
msgid "These scripts will be printed above the %1$s%2$s%3$s tag."
|
| 101 |
+
msgstr ""
|
readme.txt
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
=== WordPress Headers and Footers ===
|
| 2 |
-
Contributors: WPBrigade
|
| 3 |
Tags: header script, add footer script, insert header code, add script headers and footers,
|
| 4 |
-
Requires at least:
|
| 5 |
-
Tested up to: 4
|
| 6 |
-
Stable tag: 1.
|
|
|
|
| 7 |
License: GPLv3 or later
|
| 8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
| 9 |
|
|
@@ -43,11 +44,16 @@ It helps for WordPress users to add a JS/CSS code directly in their site without
|
|
| 43 |
|
| 44 |
== Changelog ==
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
= 1.0.0 =
|
| 47 |
* Initial Release.
|
| 48 |
|
| 49 |
|
| 50 |
== Upgrade Notice ==
|
| 51 |
|
| 52 |
-
= 1.
|
| 53 |
-
*
|
| 1 |
=== WordPress Headers and Footers ===
|
| 2 |
+
Contributors: WPBrigade, hiddenpearls
|
| 3 |
Tags: header script, add footer script, insert header code, add script headers and footers,
|
| 4 |
+
Requires at least: 4.0
|
| 5 |
+
Tested up to: 5.4
|
| 6 |
+
Stable tag: 1.1.0
|
| 7 |
+
Requires PHP: 5.6.0
|
| 8 |
License: GPLv3 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
| 10 |
|
| 44 |
|
| 45 |
== Changelog ==
|
| 46 |
|
| 47 |
+
= 1.1.0 - 2020-03-21 =
|
| 48 |
+
* Compatibility : WordPress 5.4
|
| 49 |
+
* Enhancement: Dashboard Design updated.
|
| 50 |
+
|
| 51 |
+
|
| 52 |
= 1.0.0 =
|
| 53 |
* Initial Release.
|
| 54 |
|
| 55 |
|
| 56 |
== Upgrade Notice ==
|
| 57 |
|
| 58 |
+
= 1.1.0 =
|
| 59 |
+
* Started giving life to this plugin now by making it compatible to 5.4
|
wp-headers-and-footers.php
CHANGED
|
@@ -1,175 +1,182 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
-
* Plugin Name: WP Headers and Footers
|
| 4 |
-
* Plugin URI:
|
| 5 |
-
* Description: Allows you to insert code or text in the header or footer of your WordPress site.
|
| 6 |
-
* Version: 1.
|
| 7 |
-
* Author: WPBrigade
|
| 8 |
-
* Author URI: https://www.WPBrigade.com/
|
| 9 |
-
* License: GPLv3
|
| 10 |
-
* Text Domain: wp-headers-and-footers
|
| 11 |
-
* Domain Path: /languages
|
| 12 |
-
*
|
| 13 |
-
* @package wp-headers-and-footers
|
| 14 |
-
* @category Core
|
| 15 |
-
* @author WPBrigade
|
| 16 |
-
*/
|
| 17 |
|
| 18 |
|
| 19 |
if ( ! class_exists( 'WPHeaderAndFooter' ) ) :
|
| 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 |
endif;
|
| 163 |
|
| 164 |
|
| 165 |
/**
|
| 166 |
-
* Returns the main instance of WP to prevent the need to use globals.
|
| 167 |
-
*
|
| 168 |
-
* @since 1.0.0
|
| 169 |
-
* @return WPHeaderAndFooter
|
| 170 |
-
*/
|
| 171 |
function wpheaderandfooter_loader() {
|
| 172 |
-
|
| 173 |
}
|
| 174 |
|
| 175 |
// Call the function
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
+
* Plugin Name: WP Headers and Footers
|
| 4 |
+
* Plugin URI: https://www.WPBrigade.com/wordpress/plugins/wp-headers-and-footers/
|
| 5 |
+
* Description: Allows you to insert code or text in the header or footer of your WordPress site.
|
| 6 |
+
* Version: 1.1.0
|
| 7 |
+
* Author: WPBrigade
|
| 8 |
+
* Author URI: https://www.WPBrigade.com/
|
| 9 |
+
* License: GPLv3
|
| 10 |
+
* Text Domain: wp-headers-and-footers
|
| 11 |
+
* Domain Path: /languages
|
| 12 |
+
*
|
| 13 |
+
* @package wp-headers-and-footers
|
| 14 |
+
* @category Core
|
| 15 |
+
* @author WPBrigade
|
| 16 |
+
*/
|
| 17 |
|
| 18 |
|
| 19 |
if ( ! class_exists( 'WPHeaderAndFooter' ) ) :
|
| 20 |
|
| 21 |
+
final class WPHeaderAndFooter {
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* @var string
|
| 25 |
+
*/
|
| 26 |
+
public $version = '1.1.0';
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* @var The single instance of the class
|
| 30 |
+
* @since 1.0.0
|
| 31 |
+
*/
|
| 32 |
+
|
| 33 |
+
protected static $_instance = null;
|
| 34 |
+
|
| 35 |
+
/*
|
| 36 |
+
* * * * * * * * *
|
| 37 |
+
* Class constructor
|
| 38 |
+
* * * * * * * * * */
|
| 39 |
+
public function __construct() {
|
| 40 |
+
|
| 41 |
+
$this->define_constants();
|
| 42 |
+
$this->includes();
|
| 43 |
+
$this->_hooks();
|
| 44 |
+
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* Include required core files used in admin and on the frontend.
|
| 49 |
+
*/
|
| 50 |
+
|
| 51 |
+
public function includes() {
|
| 52 |
+
|
| 53 |
+
include_once WPHEADERANDFOOTER_DIR_PATH . 'classes/class-setup.php';
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
* Hook into actions and filters
|
| 58 |
+
*
|
| 59 |
+
* @since 1.0.0
|
| 60 |
+
*/
|
| 61 |
+
private function _hooks() {
|
| 62 |
+
|
| 63 |
+
add_action( 'plugins_loaded', array( $this, 'textdomain' ) );
|
| 64 |
+
add_action( 'admin_enqueue_scripts', array( $this, '_admin_scripts' ) );
|
| 65 |
+
add_action( 'wp_head', array( $this, 'frontendHeader' ) );
|
| 66 |
+
add_action( 'wp_footer', array( $this, 'frontendFooter' ) );
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/**
|
| 70 |
+
* Define WP Header and Footer Constants
|
| 71 |
+
*/
|
| 72 |
+
private function define_constants() {
|
| 73 |
+
|
| 74 |
+
$this->define( 'WPHEADERANDFOOTER_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
| 75 |
+
$this->define( 'WPHEADERANDFOOTER_DIR_PATH', plugin_dir_path( __FILE__ ) );
|
| 76 |
+
$this->define( 'WPHEADERANDFOOTER_DIR_URL', plugin_dir_url( __FILE__ ) );
|
| 77 |
+
$this->define( 'WPHEADERANDFOOTER_ROOT_PATH', dirname( __FILE__ ) . '/' );
|
| 78 |
+
$this->define( 'WPHEADERANDFOOTER_VERSION', $this->version );
|
| 79 |
+
$this->define( 'WPHEADERANDFOOTER_FEEDBACK_SERVER', 'https://wpbrigade.com/' );
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
function _admin_scripts( $page ) {
|
| 83 |
+
|
| 84 |
+
if ( 'settings_page_wp-header-and-footer' === $page ) {
|
| 85 |
+
wp_enqueue_style( 'wpheaderandfooter_stlye', plugins_url( 'asset/css/style.css', __FILE__ ), array(), WPHEADERANDFOOTER_VERSION );
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* Define constant if not already set
|
| 91 |
+
*
|
| 92 |
+
* @param string $name
|
| 93 |
+
* @param string|bool $value
|
| 94 |
+
*/
|
| 95 |
+
private function define( $name, $value ) {
|
| 96 |
+
if ( ! defined( $name ) ) {
|
| 97 |
+
define( $name, $value );
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
/**
|
| 102 |
+
* Main Instance
|
| 103 |
+
*
|
| 104 |
+
* @since 1.0.0
|
| 105 |
+
* @static
|
| 106 |
+
* @see wpheaderandfooter_loader()
|
| 107 |
+
* @return Main instance
|
| 108 |
+
*/
|
| 109 |
+
public static function instance() {
|
| 110 |
+
if ( is_null( self::$_instance ) ) {
|
| 111 |
+
self::$_instance = new self();
|
| 112 |
+
}
|
| 113 |
+
return self::$_instance;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
/**
|
| 118 |
+
* Load Languages
|
| 119 |
+
*
|
| 120 |
+
* @since 1.0.0
|
| 121 |
+
*/
|
| 122 |
+
public function textdomain() {
|
| 123 |
+
|
| 124 |
+
$plugin_dir = dirname( plugin_basename( __FILE__ ) );
|
| 125 |
+
load_plugin_textdomain( 'wp-headers-and-footers', false, $plugin_dir . '/languages/' );
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
/**
|
| 129 |
+
* Outputs script / CSS to the header
|
| 130 |
+
*/
|
| 131 |
+
function frontendHeader() {
|
| 132 |
+
$this->_output( 'wp_header_textarea' );
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
/**
|
| 136 |
+
* Outputs script / CSS to the footer
|
| 137 |
+
*/
|
| 138 |
+
function frontendFooter() {
|
| 139 |
+
$this->_output( 'wp_footer_textarea' );
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
/**
|
| 143 |
+
* Outputs the given setting, if conditions are met
|
| 144 |
+
*
|
| 145 |
+
* @param string $script Setting Name
|
| 146 |
+
* @return output
|
| 147 |
+
*/
|
| 148 |
+
function _output( $script ) {
|
| 149 |
+
|
| 150 |
+
// Ignore admin, feed, robots or trackbacks
|
| 151 |
+
if ( is_admin() || is_feed() || is_robots() || is_trackback() ) :
|
| 152 |
+
return;
|
| 153 |
+
endif;
|
| 154 |
+
|
| 155 |
+
// Get meta
|
| 156 |
+
$_wphaf_setting = get_option( 'wpheaderandfooter_basics' );
|
| 157 |
+
$meta = ! empty( $_wphaf_setting[ $script ] ) ? $_wphaf_setting[ $script ] : false;
|
| 158 |
+
|
| 159 |
+
if ( trim( $meta ) == '' || ! $meta ) :
|
| 160 |
+
return;
|
| 161 |
+
endif;
|
| 162 |
+
|
| 163 |
+
// Output
|
| 164 |
+
echo wp_unslash( $meta );
|
| 165 |
+
|
| 166 |
+
}
|
| 167 |
+
}
|
| 168 |
|
| 169 |
endif;
|
| 170 |
|
| 171 |
|
| 172 |
/**
|
| 173 |
+
* Returns the main instance of WP to prevent the need to use globals.
|
| 174 |
+
*
|
| 175 |
+
* @since 1.0.0
|
| 176 |
+
* @return WPHeaderAndFooter
|
| 177 |
+
*/
|
| 178 |
function wpheaderandfooter_loader() {
|
| 179 |
+
return WPHeaderAndFooter::instance();
|
| 180 |
}
|
| 181 |
|
| 182 |
// Call the function
|
