Enter This Code in function.php
1 2 3 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 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 624 625 626 627 |
function theme_settings_page() { ?> <?php if( isset( $_GET[ 'tab' ] ) ) { $active_tab = $_GET[ 'tab' ]; } else { $active_tab = 'tab_one'; } ?> <div class="wrap"> <h1>Empire Theme</h1> <?php settings_errors(); ?> <h2 class="nav-tab-wrapper"> <a href="?page=theme-panel&tab=tab_one" class="nav-tab <?php echo $active_tab == 'tab_one' ? 'nav-tab-active' : ''; ?>">Home</a> <a href="?page=theme-panel&tab=tab_two" class="nav-tab <?php echo $active_tab == 'tab_two' ? 'nav-tab-active' : ''; ?>">Footer</a> <a href="?page=theme-panel&tab=tab_three" class="nav-tab <?php echo $active_tab == 'tab_three' ? 'nav-tab-active' : ''; ?>">Alerts</a> </h2> <?php if( $active_tab == 'tab_one' ) { ?> <form method="post" action="options.php" enctype="multipart/form-data"> <?php settings_fields("section"); do_settings_sections("theme-options"); submit_button(); ?> </form> <?php } elseif( $active_tab == 'tab_two' ) { ?> <form method="post" action="options.php" enctype="multipart/form-data"> <?php settings_fields("footersection"); do_settings_sections("footertheme-options"); submit_button(); ?> </form> <?php }elseif( $active_tab == 'tab_three' ) { ?> <form method="post" action="options.php" enctype="multipart/form-data"> <?php settings_fields("alertsection"); do_settings_sections("alerttheme-options"); submit_button(); ?> </form> <?php } ?> </div> <?php } function display_facebook_element() { ?> <input type="text" name="facebook_url" id="facebook_url" value="<?php echo get_option('facebook_url'); ?>" /> <?php } function display_twitter_element() { ?> <input type="text" name="twitter_url" id="twitter_url" value="<?php echo get_option('twitter_url'); ?>" /> <?php } function display_instagram_element() { ?> <input type="text" name="instagram_url" id="instagram_url" value="<?php echo get_option('instagram_url'); ?>" /> <?php } function display_googleplus_element() { ?> <input type="text" name="googleplus_url" id="googleplus_url" value="<?php echo get_option('googleplus_url'); ?>" /> <?php } function display_pintrest_element() { ?> <input type="text" name="pintrest_url" id="pintrest_url" value="<?php echo get_option('pintrest_url'); ?>" /> <?php } function display_youtube_element() { ?> <input type="text" name="youtube_url" id="youtube_url" value="<?php echo get_option('youtube_url'); ?>" /> <?php } function display_foursquare_element() { ?> <input type="text" name="foursquare_url" id="foursquare_url" value="<?php echo get_option('foursquare_url'); ?>" /> <?php } // left image function leftimage_display() { ?> <input type="file" name="leftimage" /> <img src="<?php echo get_option('leftimage'); ?>" /> <?php } function handle_leftimage_upload() { if(!empty($_FILES["leftimage"]["tmp_name"])) { $urls = wp_handle_upload($_FILES["leftimage"], array('test_form' => FALSE)); $temp = $urls["url"]; return $temp; } return $option; } // left image url function display_leftimageurl_element() { ?> <input type="text" name="leftimageurl" id="leftimageurl" value="<?php echo get_option('leftimageurl'); ?>" /> <?php } // left image Link text function display_leftimagelinktext_element() { ?> <input type="text" name="leftimagelinktext" id="leftimagelinktext" value="<?php echo get_option('leftimagelinktext'); ?>" /> <?php } // right image function rightimage_display() { ?> <input type="file" name="rightimage" /> <img src="<?php echo get_option('rightimage'); ?>" /> <?php } function handle_rightimage_upload() { if(!empty($_FILES["rightimage"]["tmp_name"])) { $urls = wp_handle_upload($_FILES["rightimage"], array('test_form' => FALSE)); $temp = $urls["url"]; return $temp; } return $option; } // right image url function display_rightimageurl_element() { ?> <input type="text" name="rightimageurl" id="rightimageurl" value="<?php echo get_option('rightimageurl'); ?>" /> <?php } // right image Link text function display_rightimagelinktext_element() { ?> <input type="text" name="rightimagelinktext" id="rightimagelinktext" value="<?php echo get_option('rightimagelinktext'); ?>" /> <?php } // slider image 1 function sliderimage1_display() { ?> <input type="file" name="sliderimage1" /> <img src="<?php echo get_option('sliderimage1'); ?>" /> <?php } function handle_sliderimage1_upload() { if(!empty($_FILES["sliderimage1"]["tmp_name"])) { $urls = wp_handle_upload($_FILES["sliderimage1"], array('test_form' => FALSE)); $temp = $urls["url"]; return $temp; } return $option; } // slider image 1 url function display_sliderimage1url_element() { ?> <input type="text" name="sliderimage1url" id="sliderimage1url" value="<?php echo get_option('sliderimage1url'); ?>" /> <?php } // slider image 2 function sliderimage2_display() { ?> <input type="file" name="sliderimage2" /> <img src="<?php echo get_option('sliderimage2'); ?>" /> <?php } function handle_sliderimage2_upload() { if(!empty($_FILES["sliderimage2"]["tmp_name"])) { $urls = wp_handle_upload($_FILES["sliderimage2"], array('test_form' => FALSE)); $temp = $urls["url"]; return $temp; } return $option; } // slider image 2 url function display_sliderimage2url_element() { ?> <input type="text" name="sliderimage2url" id="sliderimage2url" value="<?php echo get_option('sliderimage2url'); ?>" /> <?php } // slider image 3 function sliderimage3_display() { ?> <input type="file" name="sliderimage3" /> <img src="<?php echo get_option('sliderimage3'); ?>" /> <?php } function handle_sliderimage3_upload() { if(!empty($_FILES["sliderimage3"]["tmp_name"])) { $urls = wp_handle_upload($_FILES["sliderimage3"], array('test_form' => FALSE)); $temp = $urls["url"]; return $temp; } return $option; } // slider image 3 url function display_sliderimage3url_element() { ?> <input type="text" name="sliderimage3url" id="sliderimage3url" value="<?php echo get_option('sliderimage3url'); ?>" /> <?php } // slider image 4 function sliderimage4_display() { ?> <input type="file" name="sliderimage4" /> <img src="<?php echo get_option('sliderimage4'); ?>" /> <?php } function handle_sliderimage4_upload() { if(!empty($_FILES["sliderimage4"]["tmp_name"])) { $urls = wp_handle_upload($_FILES["sliderimage4"], array('test_form' => FALSE)); $temp = $urls["url"]; return $temp; } return $option; } // slider image 4 url function display_sliderimage4url_element() { ?> <input type="text" name="sliderimage4url" id="sliderimage4url" value="<?php echo get_option('sliderimage4url'); ?>" /> <?php } // slider image 5 function sliderimage5_display() { ?> <input type="file" name="sliderimage5" /> <img src="<?php echo get_option('sliderimage5'); ?>" /> <?php } function handle_sliderimage5_upload() { if(!empty($_FILES["sliderimage5"]["tmp_name"])) { $urls = wp_handle_upload($_FILES["sliderimage5"], array('test_form' => FALSE)); $temp = $urls["url"]; return $temp; } return $option; } // slider image 5 url function display_sliderimage5url_element() { ?> <input type="text" name="sliderimage5url" id="sliderimage5url" value="<?php echo get_option('sliderimage5url'); ?>" /> <?php } // slider image 6 function sliderimage6_display() { ?> <input type="file" name="sliderimage6" /> <img src="<?php echo get_option('sliderimage6'); ?>" /> <?php } function handle_sliderimage6_upload() { if(!empty($_FILES["sliderimage6"]["tmp_name"])) { $urls = wp_handle_upload($_FILES["sliderimage6"], array('test_form' => FALSE)); $temp = $urls["url"]; return $temp; } return $option; } // slider image 6 url function display_sliderimage6url_element() { ?> <input type="text" name="sliderimage6url" id="sliderimage6url" value="<?php echo get_option('sliderimage6url'); ?>" /> <?php } // slider image 7 function sliderimage7_display() { ?> <input type="file" name="sliderimage7" /> <img src="<?php echo get_option('sliderimage7'); ?>" /> <?php } function handle_sliderimage7_upload() { if(!empty($_FILES["sliderimage7"]["tmp_name"])) { $urls = wp_handle_upload($_FILES["sliderimage7"], array('test_form' => FALSE)); $temp = $urls["url"]; return $temp; } return $option; } // slider image 7 url function display_sliderimage7url_element() { ?> <input type="text" name="sliderimage7url" id="sliderimage7url" value="<?php echo get_option('sliderimage7url'); ?>" /> <?php } // slider image 8 function sliderimage8_display() { ?> <input type="file" name="sliderimage8" /> <img src="<?php echo get_option('sliderimage8'); ?>" /> <?php } function handle_sliderimage8_upload() { if(!empty($_FILES["sliderimage8"]["tmp_name"])) { $urls = wp_handle_upload($_FILES["sliderimage8"], array('test_form' => FALSE)); $temp = $urls["url"]; return $temp; } return $option; } // slider image 8 url function display_sliderimage8url_element() { ?> <input type="text" name="sliderimage8url" id="sliderimage8url" value="<?php echo get_option('sliderimage8url'); ?>" /> <?php } // slider image 9 function sliderimage9_display() { ?> <input type="file" name="sliderimage9" /> <img src="<?php echo get_option('sliderimage9'); ?>" /> <?php } function handle_sliderimage9_upload() { if(!empty($_FILES["sliderimage9"]["tmp_name"])) { $urls = wp_handle_upload($_FILES["sliderimage9"], array('test_form' => FALSE)); $temp = $urls["url"]; return $temp; } return $option; } // slider image 9 url function display_sliderimage9url_element() { ?> <input type="text" name="sliderimage9url" id="sliderimage9url" value="<?php echo get_option('sliderimage9url'); ?>" /> <?php } // slider image 10 function sliderimage10_display() { ?> <input type="file" name="sliderimage10" /> <img src="<?php echo get_option('sliderimage10'); ?>" /> <?php } function handle_sliderimage10_upload() { if(!empty($_FILES["sliderimage10"]["tmp_name"])) { $urls = wp_handle_upload($_FILES["sliderimage10"], array('test_form' => FALSE)); $temp = $urls["url"]; return $temp; } return $option; } // slider image 10 url function display_sliderimage10url_element() { ?> <input type="text" name="sliderimage10url" id="sliderimage10url" value="<?php echo get_option('sliderimage10url'); ?>" /> <?php } // footer CTA title function display_footertitle_element() { ?> <input type="text" name="footertitle" id="footertitle" value="<?php echo get_option('footertitle'); ?>" /> <?php } // footer CTA url function display_footerurl_element() { ?> <input type="text" name="footerurl" id="footerurl" value="<?php echo get_option('footerurl'); ?>" /> <?php } // footer CTA Image function footerimage_display() { ?> <input type="file" name="footerimage" /> <img src="<?php echo get_option('footerimage'); ?>" /> <?php } function handle_footerimage_upload() { if(!empty($_FILES["footerimage"]["tmp_name"])) { $urls = wp_handle_upload($_FILES["footerimage"], array('test_form' => FALSE)); $temp = $urls["url"]; return $temp; } return $option; } // Home Page Alert function display_homealert_element() { ?> <textarea name="homealert" id="homealert" ><?php echo get_option('homealert'); ?></textarea> <?php } // Racing Page Alert function display_racingalert_element() { ?> <textarea name="racingalert" id="racingalert" ><?php echo get_option('racingalert'); ?></textarea> <?php } function display_theme_panel_fields() { add_settings_section("section", "All Settings", null, "theme-options"); add_settings_section("footersection", "All Settings", null, "footertheme-options"); add_settings_section("alertsection", "All Settings", null, "alerttheme-options"); // image add_settings_field("leftimage", "left image", "leftimage_display", "theme-options", "section"); add_settings_field("rightimage", "right image", "rightimage_display", "theme-options", "section"); add_settings_field("sliderimage1", "slider image1", "sliderimage1_display", "theme-options", "section"); add_settings_field("sliderimage2", "slider image2", "sliderimage2_display", "theme-options", "section"); add_settings_field("sliderimage3", "slider image3", "sliderimage3_display", "theme-options", "section"); add_settings_field("sliderimage4", "slider image4", "sliderimage4_display", "theme-options", "section"); add_settings_field("sliderimage5", "slider image5", "sliderimage5_display", "theme-options", "section"); add_settings_field("sliderimage6", "slider image6", "sliderimage6_display", "theme-options", "section"); add_settings_field("sliderimage7", "slider image7", "sliderimage7_display", "theme-options", "section"); add_settings_field("sliderimage8", "slider image8", "sliderimage8_display", "theme-options", "section"); add_settings_field("sliderimage9", "slider image9", "sliderimage9_display", "theme-options", "section"); add_settings_field("sliderimage10", "slider image10", "sliderimage10_display", "theme-options", "section"); // image link text add_settings_field("leftimagelinktext", "left image Link Text", "display_leftimagelinktext_element", "theme-options", "section"); add_settings_field("rightimagelinktext", "right image Link Text", "display_rightimagelinktext_element", "theme-options", "section"); // image link text call function register_setting("section", "leftimagelinktext"); register_setting("section", "rightimagelinktext"); // image url add_settings_field("leftimageurl", "left image Url", "display_leftimageurl_element", "theme-options", "section"); add_settings_field("rightimageurl", "right image Url", "display_rightimageurl_element", "theme-options", "section"); add_settings_field("sliderimage1url", "slider image1 Url", "display_sliderimage1url_element", "theme-options", "section"); add_settings_field("sliderimage2url", "slider image2 Url", "display_sliderimage2url_element", "theme-options", "section"); add_settings_field("sliderimage3url", "slider image3 Url", "display_sliderimage3url_element", "theme-options", "section"); add_settings_field("sliderimage4url", "slider image4 Url", "display_sliderimage4url_element", "theme-options", "section"); add_settings_field("sliderimage5url", "slider image5 Url", "display_sliderimage5url_element", "theme-options", "section"); add_settings_field("sliderimage6url", "slider image6 Url", "display_sliderimage6url_element", "theme-options", "section"); add_settings_field("sliderimage7url", "slider image7 Url", "display_sliderimage7url_element", "theme-options", "section"); add_settings_field("sliderimage8url", "slider image8 Url", "display_sliderimage8url_element", "theme-options", "section"); add_settings_field("sliderimage9url", "slider image9 Url", "display_sliderimage9url_element", "theme-options", "section"); add_settings_field("sliderimage10url", "slider image10 Url", "display_sliderimage10url_element", "theme-options", "section"); // image url call function register_setting("section", "leftimageurl"); register_setting("section", "rightimageurl"); register_setting("section", "sliderimage1url"); register_setting("section", "sliderimage2url"); register_setting("section", "sliderimage3url"); register_setting("section", "sliderimage4url"); register_setting("section", "sliderimage5url"); register_setting("section", "sliderimage6url"); register_setting("section", "sliderimage7url"); register_setting("section", "sliderimage8url"); register_setting("section", "sliderimage9url"); register_setting("section", "sliderimage10url"); // image call function if(!empty($_FILES["leftimage"]["tmp_name"])) register_setting("section", "leftimage", "handle_leftimage_upload"); if(!empty($_FILES["rightimage"]["tmp_name"])) register_setting("section", "rightimage", "handle_rightimage_upload"); if(!empty($_FILES["sliderimage1"]["tmp_name"])) register_setting("section", "sliderimage1", "handle_sliderimage1_upload"); if(!empty($_FILES["sliderimage2"]["tmp_name"])) register_setting("section", "sliderimage2", "handle_sliderimage2_upload"); if(!empty($_FILES["sliderimage3"]["tmp_name"])) register_setting("section", "sliderimage3", "handle_sliderimage3_upload"); if(!empty($_FILES["sliderimage4"]["tmp_name"])) register_setting("section", "sliderimage4", "handle_sliderimage4_upload"); if(!empty($_FILES["sliderimage5"]["tmp_name"])) register_setting("section", "sliderimage5", "handle_sliderimage5_upload"); if(!empty($_FILES["sliderimage6"]["tmp_name"])) register_setting("section", "sliderimage6", "handle_sliderimage6_upload"); if(!empty($_FILES["sliderimage7"]["tmp_name"])) register_setting("section", "sliderimage7", "handle_sliderimage7_upload"); if(!empty($_FILES["sliderimage8"]["tmp_name"])) register_setting("section", "sliderimage8", "handle_sliderimage8_upload"); if(!empty($_FILES["sliderimage9"]["tmp_name"])) register_setting("section", "sliderimage9", "handle_sliderimage9_upload"); if(!empty($_FILES["sliderimage10"]["tmp_name"])) register_setting("section", "sliderimage10", "handle_sliderimage10_upload"); // footer // social url add_settings_field("twitter_url", "Twitter Profile Url", "display_twitter_element", "footertheme-options", "footersection"); add_settings_field("facebook_url", "Facebook Profile Url", "display_facebook_element", "footertheme-options", "footersection"); add_settings_field("instagram_url", "Instagram Profile Url", "display_instagram_element", "footertheme-options", "footersection"); add_settings_field("googleplus_url", "Google + Profile Url", "display_googleplus_element", "footertheme-options", "footersection"); add_settings_field("pintrest_url", "Pintrest Profile Url", "display_pintrest_element", "footertheme-options", "footersection"); add_settings_field("youtube_url", "YouTube Profile Url", "display_youtube_element", "footertheme-options", "footersection"); add_settings_field("foursquare_url", "Foursquare Profile Url", "display_foursquare_element", "footertheme-options", "footersection"); // social call function register_setting("footersection", "twitter_url"); register_setting("footersection", "facebook_url"); register_setting("footersection", "instagram_url"); register_setting("footersection", "googleplus_url"); register_setting("footersection", "pintrest_url"); register_setting("footersection", "youtube_url"); register_setting("footersection", "foursquare_url"); add_settings_field("footertitle", "CTA Title", "display_footertitle_element", "footertheme-options", "footersection"); register_setting("footersection", "footertitle"); add_settings_field("footerurl", "CTA url", "display_footerurl_element", "footertheme-options", "footersection"); register_setting("footersection", "footerurl"); add_settings_field("footerimage", "CTA Image", "footerimage_display", "footertheme-options", "footersection"); if(!empty($_FILES["footerimage"]["tmp_name"])) register_setting("footersection", "footerimage", "handle_footerimage_upload"); // alert add_settings_field("homealert", "Home Page Alert", "display_homealert_element", "alerttheme-options", "alertsection"); add_settings_field("racingalert", "Racing Page Alert", "display_racingalert_element", "alerttheme-options", "alertsection"); register_setting("alertsection", "homealert"); register_setting("alertsection", "racingalert"); } add_action("admin_init", "display_theme_panel_fields"); function add_theme_menu_item() { add_menu_page("Empire Theme", "Empire Theme", "manage_options", "theme-panel", "theme_settings_page", null, 99); } add_action("admin_menu", "add_theme_menu_item"); |
Leave a reply