| [ Index ] |
PHP Cross Reference of PageLines Framework |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Extend Actions 4 * 5 * @author PageLines 6 * 7 * @since 2.0.b3 8 */ 9 10 class PageLinesExtendActions { 11 12 13 14 /** 15 * 16 * @TODO document 17 * 18 */ 19 function __construct() { 20 21 $this->ui = new PageLinesExtendUI; 22 23 add_action( 'wp_ajax_pagelines_ajax_extend_it_callback', array(&$this, 'extend_it_callback' ) ); 24 add_action( 'admin_init', array(&$this, 'extension_uploader' ) ); 25 add_action( 'admin_init', array(&$this, 'check_creds' ) ); 26 } 27 28 /** 29 * 30 * Extension AJAX callbacks 31 * 32 */ 33 function extend_it_callback( $uploader = false, $checked = null ) { 34 35 // 2. Variable Setup 36 $mode = $_POST['extend_mode']; 37 $type = $_POST['extend_type']; 38 $file = $_POST['extend_file']; 39 $path = $_POST['extend_path']; 40 $product = $_POST['extend_product']; 41 $dash = isset( $_POST['extend_dash'] ) ? $_POST['extend_dash'] : false; 42 43 44 45 if ( $uploader === 'pagelines_ajax_extend_it_callback' ) 46 $uploader = false; 47 48 // 3. Do our thing... 49 50 switch ( $mode ) { 51 52 case 'integration_download': 53 54 $this->integration_download( $type, $file, $path, $uploader, $checked ); 55 56 break; 57 58 case 'integration_activate': 59 60 integration_activate( $type, $file, $path, $uploader, $checked ); 61 62 break; 63 64 case 'integration_deactivate': 65 66 integration_deactivate( $type, $file, $path, $uploader, $checked ); 67 68 break; 69 70 case 'plugin_install': 71 72 $this->plugin_install( $type, $file, $path, $uploader, $checked, $dash ); 73 74 break; 75 76 case 'plugin_upgrade': 77 78 $this->plugin_upgrade( $type, $file, $path, $uploader, $checked, $dash ); 79 80 break; 81 82 case 'plugin_delete': 83 84 $this->plugin_delete( $type, $file, $path, $uploader, $checked ); 85 86 break; 87 88 case 'plugin_activate': 89 90 $this->plugin_activate( $type, $file, $path, $uploader, $checked ); 91 92 break; 93 94 case 'plugin_deactivate': 95 96 $this->plugin_deactivate( $type, $file, $path, $uploader, $checked ); 97 98 break; 99 100 case 'section_install': 101 102 $this->section_install( $type, $file, $path, $uploader, $checked ); 103 104 break; 105 106 case 'section_upgrade': 107 108 $this->section_upgrade( $type, $file, $path, $uploader, $checked, $dash ); 109 110 break; 111 112 case 'section_delete': 113 114 $this->section_delete( $type, $file, $path, $uploader, $checked ); 115 116 break; 117 118 case 'section_activate': 119 120 $this->section_activate( $type, $file, $path, $uploader, $checked ); 121 122 break; 123 124 case 'section_deactivate': 125 126 $this->section_deactivate( $type, $file, $path, $uploader, $checked ); 127 128 break; 129 130 case 'theme_install': 131 132 $this->theme_install( $type, $file, $path, $uploader, $checked ); 133 134 break; 135 136 case 'theme_upgrade': 137 138 $this->theme_upgrade( $type, $file, $path, $uploader, $checked, $dash ); 139 140 break; 141 142 case 'theme_delete': 143 144 $this->theme_delete( $type, $file, $path, $uploader, $checked ); 145 146 break; 147 148 case 'theme_activate': 149 150 $this->theme_activate( $type, $file, $path, $uploader, $checked ); 151 152 break; 153 154 case 'theme_deactivate': 155 156 $this->theme_deactivate( $type, $file, $path, $uploader, $checked ); 157 158 break; 159 160 case 'redirect': 161 162 $this->redirect( $type, $file, $path, $uploader, $checked ); 163 164 break; 165 166 case 'purchase': 167 168 $this->purchase( $type, $file, $path, $uploader, $checked ); 169 170 break; 171 172 case 'login': 173 174 $this->login( $type, $file, $path, $uploader, $checked ); 175 176 break; 177 178 case 'version_fail': 179 180 $this->version_fail( $type, $file, $path, $uploader, $checked ); 181 182 break; 183 184 case 'depends_fail': 185 186 $this->depends_fail( $type, $file, $path, $uploader, $checked ); 187 188 break; 189 190 case 'pro_fail': 191 192 $this->pro_fail( $type, $file, $path, $uploader, $checked ); 193 194 break; 195 196 case 'subscribe': 197 198 $this->subscribe( $type, $file, $path, $uploader, $checked ); 199 200 break; 201 202 case 'unsubscribe': 203 204 $this->unsubscribe( $type, $file, $path, $uploader, $checked ); 205 206 break; 207 } 208 die(); // needed at the end of ajax callbacks 209 } 210 211 /** 212 * Uploader for sections. 213 * 214 */ 215 function extension_uploader() { 216 217 if ( !empty($_POST['upload_check'] ) && check_admin_referer( 'pagelines_extend_upload', 'upload_check') ) { 218 219 if ( $_FILES[ $_POST['type']]['size'] == 0 ) { 220 $this->page_reload( PL_ADMIN_STORE_SLUG.'&extend_error=blank', null, 0 ); 221 exit(); 222 } 223 224 // right we made it this far! It needs to be a section! 225 $type = $_POST['type']; 226 $filename = $_FILES[ $type ][ 'name' ]; 227 $payload = $_FILES[ $type ][ 'tmp_name' ]; 228 229 if ( !preg_match( '/section-([^\.]*)\.zip/i', $filename, $out ) ) { 230 $this->page_reload( PL_ADMIN_STORE_SLUG.'&extend_error=filename', null, 0 ); 231 exit(); 232 } 233 234 $uploader = true; 235 $_POST['extend_mode'] = 'section_install'; 236 $_POST['extend_file'] = $payload; 237 $_POST['extend_path'] = $out[1]; 238 $_POST['extend_type'] = 'section'; 239 $_POST['extend_product']= ''; 240 241 $this->extend_it_callback( $uploader, null ); 242 exit; 243 } 244 } 245 246 /** 247 * See if we have filesystem permissions. 248 * 249 */ 250 251 /** 252 * 253 * @TODO document 254 * 255 */ 256 function check_creds( $extend = null, $context = WP_PLUGIN_DIR ) { 257 258 if ( get_filesystem_method() == 'direct' ) { 259 260 WP_Filesystem(); 261 return; 262 } 263 264 if ( isset( $_GET['creds'] ) && $_POST && WP_Filesystem( $_POST ) ) 265 $this->extend_it_callback( false, true ); 266 267 if ( !$extend ) 268 return; 269 270 if ( false === ( $creds = @request_filesystem_credentials( admin_url( PL_ADMIN_STORE_URL.'&creds=yes' ), $type = '', $error = false, $context, $extra_fields = array( 'extend_mode', 'extend_type', 'extend_file', 'extend_path', 'extend_product' ) ) ) ) { 271 exit; 272 } 273 } 274 275 276 // return true if were NOT using direct fs. 277 278 /** 279 * 280 * @TODO document 281 * 282 */ 283 function get_fs_method(){ 284 285 global $wp_filesystem; 286 287 if ( is_object( $wp_filesystem ) && $wp_filesystem->method != 'direct' ) 288 return true; 289 else 290 return false; 291 } 292 293 294 /** 295 * Generate a download link. 296 * 297 */ 298 function make_url( $type, $file, $product = null ) { 299 300 return sprintf( '%s%ss/download.php?d=%s.zip%s', PL_API_FETCH, $type, $file, ( isset( $product ) ) ? '&product=' . $product : '' ); 301 302 } 303 304 /** 305 * Get a PayPal link. 306 * 307 */ 308 function get_payment_link( $product ) { 309 310 return sprintf( 'https://pagelines.com/api/?paypal=%s|%s', $product, admin_url( 'admin.php' ) ); 311 } 312 313 314 /** 315 * Reload the page 316 * Helper function 317 */ 318 function page_reload( $location, $product = null, $message = '') { 319 320 do_action( 'extend_flush' ); 321 322 if ( $this->get_fs_method() ) { 323 324 $time = 0; 325 } else { 326 $time = 700; 327 echo $message; 328 } 329 330 $r = rand( 1,100 ); 331 332 $admin = admin_url( sprintf( 'admin.php?r=%1$s&page=%2$s', $r, $location ) ); 333 334 $location = ( $product ) ? self::get_payment_link( $product ) : $admin; 335 336 printf( 337 '<script type="text/javascript">setTimeout(function(){ window.location.href = \'%s\';}, %s);</script>', 338 $location, 339 $time 340 ); 341 342 } 343 344 function int_download( $location, $time = 300 ) { 345 346 $r = rand( 1,100 ); 347 $admin = admin_url( sprintf( 'admin.php?r=%1$s&page=%2$s', $r, PL_ADMIN_STORE_SLUG.'#integrations' ) ); 348 printf( '<script type="text/javascript">setTimeout(function(){ window.location.href = \'%s\';}, %s);</script>', $location, $time ); 349 printf( '<script type="text/javascript">setTimeout(function(){ window.location.href = \'%s\';}, %s);</script>', $admin, 700 ); 350 } 351 352 353 /** 354 * 355 * @TODO document 356 * 357 */ 358 function sandbox( $file, $type ) { 359 360 register_shutdown_function( array(&$this, 'error_handler'), $type ); 361 @include_once( $file ); 362 } 363 364 /** 365 * Throw up on error 366 */ 367 function error_handler( $type ) { 368 369 $a = error_get_last(); 370 371 $error = ''; 372 373 // Unable to activate 374 if( $a['type'] == 4 || $a['type'] == 1 ) 375 $error .= sprintf( 'Unable to activate the %s.', $type ); 376 377 //Error on line 378 if( $error && is_pl_debug() ) 379 $error .= sprintf( '<br />%s in %s on line: %s', $a['message'], basename( $a['file'] ), $a['line'] ); 380 381 echo $error; 382 } 383 384 385 /** 386 * Provide Download to integration 387 */ 388 function integration_download( $type, $file, $path, $uploader, $checked ) { 389 390 $url = $this->make_url( $type, $file ); 391 392 echo __( 'Downloaded', 'pagelines' ); 393 394 $this->int_download( $url ); 395 396 } 397 /** 398 * 399 * @TODO document 400 * 401 */ 402 function subscribe( $type, $file, $path, $uploader, $checked ) { 403 404 print __( 'Subscribing...', 'pagelines' ); 405 406 $data = explode ( '|', $path ); 407 408 $options = array( 409 'body' => array( 410 'email' => get_bloginfo( 'admin_email'), 411 'version' => $data[2], 412 'username' => $data[0] 413 ) 414 ); 415 416 $url = 'api.pagelines.com/subscribe/' . $data[1]; 417 418 $result = pagelines_try_api($url, $options); 419 420 if ( $result['response']['code'] == 200 && $result['body'] == $data[1] ) 421 { 422 423 delete_transient( sprintf( PL_ADMIN_STORE_SLUG.'_%ss', $type ) ); 424 $message = __( 'Done.', 'pagelines' ); 425 $text = sprintf( '&extend_text=%s_install', $type ); 426 $this->page_reload( PL_ADMIN_STORE_SLUG . $text, null, $message ); 427 } 428 429 } 430 431 /** 432 * 433 * @TODO document 434 * 435 */ 436 function unsubscribe( $type, $file, $path, $uploader, $checked ) { 437 438 print __( 'Unsubscribing...', 'pagelines'); 439 440 $data = explode ( '|', $path ); 441 442 $options = array( 443 'body' => array( 444 'email' => get_bloginfo( 'admin_email'), 445 'version' => $data[2], 446 'username' => $data[0] 447 ) 448 ); 449 450 $url = 'api.pagelines.com/unsubscribe/' . $data[1]; 451 452 $result = pagelines_try_api($url, $options); 453 454 if ( $result['response']['code'] == 200 && $result['body'] == $data[1] ) 455 { 456 457 delete_transient( sprintf( PL_ADMIN_STORE_SLUG.'_%ss', $type ) ); 458 $message = __( 'Done.', 'pagelines' ); 459 $text = sprintf( '&extend_text=%s_install#added', $type ); 460 $this->page_reload( PL_ADMIN_STORE_SLUG . $text, null, $message ); 461 } 462 463 } 464 465 /** 466 * 467 * @TODO document 468 * 469 */ 470 function version_fail( $type, $file, $path, $uploader, $checked ) { 471 472 printf( __( 'You need to have version %s of the framework for this %s', 'pagelines' ), $file, $path ); 473 474 } 475 476 477 /** 478 * 479 * @TODO document 480 * 481 */ 482 function depends_fail( $type, $file, $path, $uploader, $checked ) { 483 484 printf( __( 'You need to install %s first.', 'pagelines' ), $file ); 485 486 } 487 488 489 /** 490 * 491 * @TODO document 492 * 493 */ 494 function pro_fail( $type, $file, $path, $uploader, $checked ) { 495 496 printf( __( 'This %s needs a Pro license.', 'pagelines' ), $path ); 497 498 } 499 500 501 /** 502 * 503 * @TODO document 504 * 505 */ 506 function plugin_install( $type, $file, $path, $uploader, $checked, $dash) { 507 508 509 $this->wp_libs(); 510 511 if ( !$checked ) 512 $this->check_creds( 'extend', WP_PLUGIN_DIR ); 513 514 $skin = new PageLines_Upgrader_Skin(); 515 $upgrader = new Plugin_Upgrader( $skin ); 516 $destination = $this->make_url( $type, $file ); 517 @$upgrader->install( $destination ); 518 519 $this->sandbox( WP_PLUGIN_DIR . $path, 'plugin' ); 520 activate_plugin( $path ); 521 522 $message = __( 'Plugin Installed.', 'pagelines' ); 523 $text = '&extend_text=plugin_install#your_plugins'; 524 525 $url = PL_ADMIN_STORE_SLUG; 526 527 if ( $dash ) { 528 $url = PL_MAIN_DASH; 529 } 530 $this->page_reload( $url, null, $message ); 531 } 532 533 534 /** 535 * 536 * @TODO document 537 * 538 */ 539 function plugin_delete( $type, $file, $path, $uploader, $checked ) { 540 541 $this->wp_libs(); 542 543 if ( !$checked ) 544 $this->check_creds( 'extend', WP_PLUGIN_DIR ); 545 global $wp_filesystem; 546 delete_plugins( array( ltrim( $file, '/' ) ) ); 547 $message = __( 'Plugin Deleted.', 'pagelines' ); 548 $text = '&extend_text=plugin_delete#your_plugins'; 549 $this->page_reload( PL_ADMIN_STORE_SLUG . $text, null, $message ); 550 551 } 552 553 554 /** 555 * 556 * @TODO document 557 * 558 */ 559 function plugin_upgrade( $type, $file, $path, $uploader, $checked, $dash ) { 560 561 $this->wp_libs(); 562 563 if ( !$checked ) 564 $this->check_creds( 'extend' ); 565 global $wp_filesystem; 566 567 $skin = new PageLines_Upgrader_Skin(); 568 $upgrader = new Plugin_Upgrader( $skin ); 569 570 $active = is_plugin_active( ltrim( $file, '/' ) ); 571 deactivate_plugins( array( $file ) ); 572 573 $wp_filesystem->delete( trailingslashit( WP_PLUGIN_DIR ) . $path, true, false ); 574 @$upgrader->install( $this->make_url( $type, $path ) ); 575 576 $this->sandbox( WP_PLUGIN_DIR . $file, 'plugin'); 577 if ( $active ) 578 activate_plugin( ltrim( $file, '/' ) ); 579 // Output 580 $message = __( 'Plugin Upgraded.', 'pagelines' ); 581 $text = '&extend_text=plugin_upgrade#your_plugins'; 582 583 $url = PL_ADMIN_STORE_SLUG; 584 585 if ( $dash ) { 586 $url = PL_MAIN_DASH; 587 $this->remove_update( $path ); 588 } 589 $this->page_reload( $url, null, $message ); 590 591 } 592 593 function remove_update( $slug ) { 594 595 $updates = json_decode( get_theme_mod( 'pending_updates' ) ); 596 if( isset( $updates->$slug ) ) { 597 unset( $updates->$slug ); 598 set_theme_mod( 'pending_updates', json_encode( $updates ) ); 599 remove_theme_mod( 'available_updates' ); 600 } 601 } 602 603 604 /** 605 * 606 * @TODO document 607 * 608 */ 609 function plugin_activate( $type, $file, $path, $uploader, $checked ) { 610 611 $this->sandbox( WP_PLUGIN_DIR . $file, 'plugin' ); 612 activate_plugin( $file ); 613 $message = __( 'Plugin Activated.', 'pagelines' ); 614 $this->page_reload( PL_ADMIN_STORE_SLUG, null, $message ); 615 616 } 617 618 619 /** 620 * 621 * @TODO document 622 * 623 */ 624 function plugin_deactivate( $type, $file, $path, $uploader, $checked ) { 625 626 deactivate_plugins( array( $file ) ); 627 // Output 628 $message = __( 'Plugin Deactivated.', 'pagelines' ); 629 $this->page_reload( PL_ADMIN_STORE_SLUG, null, $message ); 630 631 } 632 633 634 /** 635 * 636 * @TODO document 637 * 638 */ 639 function section_install( $type, $file, $path, $uploader, $checked ) { 640 641 $this->wp_libs(); 642 643 if ( !$checked ) 644 $this->check_creds( 'extend', WP_PLUGIN_DIR ); 645 global $wp_filesystem; 646 647 $skin = new PageLines_Upgrader_Skin(); 648 $upgrader = new PageLines_Section_Installer( $skin ); 649 $time = 0; 650 651 $url = ( $uploader ) ? $file : $this->make_url( $type, $path ); 652 $out = @$upgrader->install( $url ); 653 654 $wp_filesystem->move( trailingslashit( $wp_filesystem->wp_plugins_dir() ) . $path, sprintf( '%s/pagelines-sections/%s', trailingslashit( $wp_filesystem->wp_plugins_dir() ), $path ) ); 655 656 $this->sections_reset(); 657 $text = '&extend_text=section_install#your_added_sections'; 658 if ( $uploader && is_wp_error( $out ) ) 659 $this->page_reload( sprintf( PL_ADMIN_STORE_SLUG.'&extend_error=%s', $out->get_error_code() ) , null, 0 ); 660 else 661 $this->page_reload( PL_ADMIN_STORE_SLUG . $text, null, __( 'Section Installed.', 'pagelines' ) ); 662 663 } 664 665 666 /** 667 * 668 * @TODO document 669 * 670 */ 671 function section_delete( $type, $file, $path, $uploader, $checked ) { 672 673 $this->wp_libs(); 674 675 if ( !$checked ) { 676 $this->check_creds( 'extend', PL_EXTEND_DIR ); 677 } 678 global $wp_filesystem; 679 680 $wp_filesystem->delete( sprintf( '%s/pagelines-sections/%s', trailingslashit( $wp_filesystem->wp_plugins_dir() ), $file ), true, false ); 681 682 $this->sections_reset(); 683 $message = __( 'Section Deleted.', 'pagelines' ); 684 $text = '&extend_text=section_delete#your_added_sections'; 685 $this->page_reload( PL_ADMIN_STORE_SLUG . $text, null, $message ); 686 687 } 688 689 690 /** 691 * 692 * @TODO document 693 * 694 */ 695 function section_upgrade( $type, $file, $path, $uploader, $checked, $dash ) { 696 697 $this->wp_libs(); 698 699 if ( !$checked ) 700 $this->check_creds( 'extend', PL_EXTEND_DIR ); 701 global $wp_filesystem; 702 703 $skin = new PageLines_Upgrader_Skin(); 704 $upgrader = new PageLines_Section_Installer($skin); 705 706 707 $folder = sprintf( '%s/pagelines-sections/%s', trailingslashit( $wp_filesystem->wp_plugins_dir() ), $file ); 708 709 $wp_filesystem->delete( $folder, true, false ); 710 711 @$upgrader->install( $this->make_url( 'section', $file ) ); 712 $wp_filesystem->move( trailingslashit( $wp_filesystem->wp_plugins_dir() ) . $file, sprintf( '%s/pagelines-sections/%s', trailingslashit( $wp_filesystem->wp_plugins_dir() ), $file ) ); 713 714 $this->sections_reset(); 715 // Output 716 $text = '&extend_text=section_upgrade#your_added_sections'; 717 $message = __( 'Section Upgraded', 'pagelines' ); 718 719 $url = PL_ADMIN_STORE_SLUG; 720 if ( $dash ) { 721 $url = PL_MAIN_DASH; 722 $this->remove_update( $file ); 723 } 724 $this->page_reload( $url, null, $message ); 725 } 726 727 728 /** 729 * 730 * @TODO document 731 * 732 */ 733 function section_activate( $type, $file, $path, $uploader, $checked ) { 734 735 $this->sandbox( $path, 'section' ); 736 $available = get_option( 'pagelines_sections_disabled' ); 737 unset( $available[$path][$file] ); 738 update_option( 'pagelines_sections_disabled', $available ); 739 // Output 740 $message = __( 'Section Activated.', 'pagelines' ); 741 $this->page_reload( PL_ADMIN_STORE_SLUG, null, $message ); 742 743 } 744 745 746 /** 747 * 748 * @TODO document 749 * 750 */ 751 function section_deactivate( $type, $file, $path, $uploader, $checked ) { 752 753 $disabled = get_option( 'pagelines_sections_disabled', array( 'child' => array(), 'parent' => array() ) ); 754 $disabled[$path][$file] = true; 755 update_option( 'pagelines_sections_disabled', $disabled ); 756 $this->sections_reset(); 757 // Output 758 $message = __( 'Section Deactivated.', 'pagelines' ); 759 $this->page_reload( PL_ADMIN_STORE_SLUG, null, $message ); 760 761 } 762 763 764 /** 765 * 766 * @TODO document 767 * 768 */ 769 function theme_install( $type, $file, $path, $uploader, $checked ) { 770 771 $this->wp_libs(); 772 773 if ( !$checked ) { 774 $this->check_creds( 'extend', PL_EXTEND_THEMES_DIR ); 775 } 776 $skin = new PageLines_Upgrader_Skin(); 777 $upgrader = new Theme_Upgrader( $skin ); 778 global $wp_filesystem; 779 @$upgrader->install( $this->make_url( $type, $file ) ); 780 781 // Output 782 $text = '&extend_text=theme_install#your_themes'; 783 $message = __( 'Theme Installed.', 'pagelines' ); 784 $this->page_reload( PL_ADMIN_STORE_SLUG . $text, null, $message ); 785 786 } 787 788 789 /** 790 * 791 * @TODO document 792 * 793 */ 794 function theme_delete( $type, $file, $path, $uploader, $checked ) { 795 796 $this->wp_libs(); 797 798 if ( !$checked ) { 799 $this->check_creds( 'extend', PL_EXTEND_THEMES_DIR ); 800 } 801 global $wp_filesystem; 802 $wp_filesystem->delete( trailingslashit( PL_EXTEND_THEMES_DIR ) . $file, true, false ); 803 804 $text = '&extend_text=theme_delete#your_themes'; 805 $message = __( 'Theme Deleted.', 'pagelines' ); 806 $this->page_reload( PL_ADMIN_STORE_SLUG . $text, null, $message ); 807 808 } 809 810 811 /** 812 * 813 * @TODO document 814 * 815 */ 816 function theme_upgrade( $type, $file, $path, $uploader, $checked, $dash) { 817 818 $this->wp_libs(); 819 820 if ( !$checked ) 821 $this->check_creds( 'extend', PL_EXTEND_THEMES_DIR ); 822 global $wp_filesystem; 823 824 $active = ( basename( get_stylesheet_directory() ) === $file ) ? true : false; 825 826 if ( $active ) 827 switch_theme( basename( get_template_directory() ), basename( get_template_directory() ) ); 828 829 $skin = new PageLines_Upgrader_Skin(); 830 $upgrader = new Theme_Upgrader( $skin ); 831 832 $wp_filesystem->delete( trailingslashit( PL_EXTEND_THEMES_DIR ) . $file, true, false ); 833 834 @$upgrader->install( $this->make_url( $type, $file ) ); 835 836 if ( $active ) 837 switch_theme( basename( get_template_directory() ), $file ); 838 // Output 839 $text = '&extend_text=theme_upgrade#your_themes'; 840 $message = __( 'Theme Upgraded.', 'pagelines' ); 841 842 $url = PL_ADMIN_STORE_SLUG; 843 844 if ( $dash ) { 845 $url = PL_MAIN_DASH; 846 $this->remove_update( $path ); 847 } 848 $this->page_reload( $url, null, $message ); 849 850 } 851 852 853 /** 854 * 855 * @TODO document 856 * 857 */ 858 function theme_activate( $type, $file, $path, $uploader, $checked ) { 859 860 switch_theme( basename( get_template_directory() ), $file ); 861 delete_transient( 'pagelines_sections_cache' ); 862 863 $message = __( 'Theme Activated.', 'pagelines' ); 864 $this->page_reload( PL_ADMIN_STORE_SLUG, null, $message ); 865 866 } 867 868 869 /** 870 * 871 * @TODO document 872 * 873 */ 874 function theme_deactivate( $type, $file, $path, $uploader, $checked ) { 875 876 switch_theme( basename( get_template_directory() ), basename( get_template_directory() ) ); 877 delete_transient( 'pagelines_sections_cache' ); 878 879 $message = __( 'Theme Deactivated.', 'pagelines' ); 880 $this->page_reload( PL_ADMIN_STORE_SLUG, null, $message ); 881 882 } 883 884 885 /** 886 * 887 * @TODO document 888 * 889 */ 890 function redirect( $type, $file, $path, $uploader, $checked ) { 891 892 echo sprintf( __( 'Sorry only network admins can install %ss.', 'pagelines' ), $type ); 893 894 } 895 896 897 /** 898 * 899 * @TODO document 900 * 901 */ 902 function purchase( $type, $file, $path, $uploader, $checked ) { 903 904 _e( 'Taking you to PayPal.com', 'pagelines' ); 905 $this->page_reload( PL_ADMIN_STORE_SLUG, $file ); 906 907 } 908 909 910 /** 911 * 912 * @TODO document 913 * 914 */ 915 function login( $type, $file, $path, $uploader, $checked ) { 916 917 _e( 'Moving to account setup..', 'pagelines' ); 918 $this->page_reload( PL_MAIN_DASH . '#Your_Account' ); 919 920 } 921 922 923 /** 924 * 925 * @TODO document 926 * 927 */ 928 function wp_libs() { 929 930 include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); 931 include ( PL_ADMIN . '/library.extension.php' ); 932 933 } 934 935 936 /** 937 * 938 * @TODO document 939 * 940 */ 941 function sections_reset() { 942 943 global $load_sections; 944 delete_transient( 'pagelines_sections_cache' ); 945 $load_sections->pagelines_register_sections( true, false ); 946 } 947 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Apr 6 23:00:27 2013 | Cross-referenced by PHPXref 0.7.1 |