Changeset 42343 for trunk/src/wp-includes/class-wp-theme.php
- Timestamp:
- 11/30/2017 11:09:33 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/class-wp-theme.php (modified) (43 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-theme.php
r42242 r42343 194 194 if ( self::$persistently_cache ) { 195 195 wp_cache_add_global_groups( 'themes' ); 196 if ( is_int( self::$persistently_cache ) ) 196 if ( is_int( self::$persistently_cache ) ) { 197 197 self::$cache_expiration = self::$persistently_cache; 198 } 198 199 } else { 199 200 wp_cache_add_non_persistent_groups( 'themes' ); … … 211 212 212 213 $this->cache_hash = md5( $this->theme_root . '/' . $this->stylesheet ); 213 $theme_file = $this->stylesheet . '/style.css';214 $theme_file = $this->stylesheet . '/style.css'; 214 215 215 216 $cache = $this->cache_get( 'theme' ); … … 217 218 if ( is_array( $cache ) ) { 218 219 foreach ( array( 'errors', 'headers', 'template' ) as $key ) { 219 if ( isset( $cache[ $key ] ) ) 220 if ( isset( $cache[ $key ] ) ) { 220 221 $this->$key = $cache[ $key ]; 221 } 222 if ( $this->errors ) 222 } 223 } 224 if ( $this->errors ) { 223 225 return; 224 if ( isset( $cache['theme_root_template'] ) ) 226 } 227 if ( isset( $cache['theme_root_template'] ) ) { 225 228 $theme_root_template = $cache['theme_root_template']; 229 } 226 230 } elseif ( ! file_exists( $this->theme_root . '/' . $theme_file ) ) { 227 231 $this->headers['Name'] = $this->stylesheet; 228 if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet ) ) 232 if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet ) ) { 229 233 $this->errors = new WP_Error( 'theme_not_found', sprintf( __( 'The theme directory "%s" does not exist.' ), esc_html( $this->stylesheet ) ) ); 230 else234 } else { 231 235 $this->errors = new WP_Error( 'theme_no_stylesheet', __( 'Stylesheet is missing.' ) ); 236 } 232 237 $this->template = $this->stylesheet; 233 $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) ); 234 if ( ! file_exists( $this->theme_root ) ) // Don't cache this one. 238 $this->cache_add( 239 'theme', array( 240 'headers' => $this->headers, 241 'errors' => $this->errors, 242 'stylesheet' => $this->stylesheet, 243 'template' => $this->template, 244 ) 245 ); 246 if ( ! file_exists( $this->theme_root ) ) { // Don't cache this one. 235 247 $this->errors->add( 'theme_root_missing', __( 'ERROR: The themes directory is either empty or doesn’t exist. Please check your installation.' ) ); 248 } 236 249 return; 237 250 } elseif ( ! is_readable( $this->theme_root . '/' . $theme_file ) ) { 238 251 $this->headers['Name'] = $this->stylesheet; 239 $this->errors = new WP_Error( 'theme_stylesheet_not_readable', __( 'Stylesheet is not readable.' ) ); 240 $this->template = $this->stylesheet; 241 $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) ); 252 $this->errors = new WP_Error( 'theme_stylesheet_not_readable', __( 'Stylesheet is not readable.' ) ); 253 $this->template = $this->stylesheet; 254 $this->cache_add( 255 'theme', array( 256 'headers' => $this->headers, 257 'errors' => $this->errors, 258 'stylesheet' => $this->stylesheet, 259 'template' => $this->template, 260 ) 261 ); 242 262 return; 243 263 } else { … … 246 266 // Properly identify default themes that are inside a directory within wp-content/themes. 247 267 if ( $default_theme_slug = array_search( $this->headers['Name'], self::$default_themes ) ) { 248 if ( basename( $this->stylesheet ) != $default_theme_slug ) 268 if ( basename( $this->stylesheet ) != $default_theme_slug ) { 249 269 $this->headers['Name'] .= '/' . $this->stylesheet; 270 } 250 271 } 251 272 } … … 254 275 /* translators: %s: Template */ 255 276 $this->errors = new WP_Error( 'theme_child_invalid', sprintf( __( 'The theme defines itself as its parent theme. Please check the %s header.' ), '<code>Template</code>' ) ); 256 $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet ) ); 277 $this->cache_add( 278 'theme', array( 279 'headers' => $this->headers, 280 'errors' => $this->errors, 281 'stylesheet' => $this->stylesheet, 282 ) 283 ); 257 284 258 285 return; … … 271 298 ); 272 299 $this->errors = new WP_Error( 'theme_no_index', $error_message ); 273 $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) ); 300 $this->cache_add( 301 'theme', array( 302 'headers' => $this->headers, 303 'errors' => $this->errors, 304 'stylesheet' => $this->stylesheet, 305 'template' => $this->template, 306 ) 307 ); 274 308 return; 275 309 } … … 290 324 // Parent theme is missing. 291 325 $this->errors = new WP_Error( 'theme_no_parent', sprintf( __( 'The parent theme is missing. Please install the "%s" parent theme.' ), esc_html( $this->template ) ) ); 292 $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) ); 326 $this->cache_add( 327 'theme', array( 328 'headers' => $this->headers, 329 'errors' => $this->errors, 330 'stylesheet' => $this->stylesheet, 331 'template' => $this->template, 332 ) 333 ); 293 334 $this->parent = new WP_Theme( $this->template, $this->theme_root, $this ); 294 335 return; … … 302 343 $_child->parent = null; 303 344 $_child->errors = new WP_Error( 'theme_parent_invalid', sprintf( __( 'The "%s" theme is not a valid parent theme.' ), esc_html( $_child->template ) ) ); 304 $_child->cache_add( 'theme', array( 'headers' => $_child->headers, 'errors' => $_child->errors, 'stylesheet' => $_child->stylesheet, 'template' => $_child->template ) ); 345 $_child->cache_add( 346 'theme', array( 347 'headers' => $_child->headers, 348 'errors' => $_child->errors, 349 'stylesheet' => $_child->stylesheet, 350 'template' => $_child->template, 351 ) 352 ); 305 353 // The two themes actually reference each other with the Template header. 306 354 if ( $_child->stylesheet == $this->template ) { 307 355 $this->errors = new WP_Error( 'theme_parent_invalid', sprintf( __( 'The "%s" theme is not a valid parent theme.' ), esc_html( $this->template ) ) ); 308 $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) ); 356 $this->cache_add( 357 'theme', array( 358 'headers' => $this->headers, 359 'errors' => $this->errors, 360 'stylesheet' => $this->stylesheet, 361 'template' => $this->template, 362 ) 363 ); 309 364 } 310 365 return; … … 316 371 // We're good. If we didn't retrieve from cache, set it. 317 372 if ( ! is_array( $cache ) ) { 318 $cache = array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ); 373 $cache = array( 374 'headers' => $this->headers, 375 'errors' => $this->errors, 376 'stylesheet' => $this->stylesheet, 377 'template' => $this->template, 378 ); 319 379 // If the parent theme is in another root, we'll want to cache this. Avoids an entire branch of filesystem calls above. 320 if ( isset( $theme_root_template ) ) 380 if ( isset( $theme_root_template ) ) { 321 381 $cache['theme_root_template'] = $theme_root_template; 382 } 322 383 $this->cache_add( 'theme', $cache ); 323 384 } … … 332 393 */ 333 394 public function __toString() { 334 return (string) $this->display( 'Name');395 return (string) $this->display( 'Name' ); 335 396 } 336 397 … … 347 408 public function __isset( $offset ) { 348 409 static $properties = array( 349 'name', 'title', 'version', 'parent_theme', 'template_dir', 'stylesheet_dir', 'template', 'stylesheet', 350 'screenshot', 'description', 'author', 'tags', 'theme_root', 'theme_root_uri', 410 'name', 411 'title', 412 'version', 413 'parent_theme', 414 'template_dir', 415 'stylesheet_dir', 416 'template', 417 'stylesheet', 418 'screenshot', 419 'description', 420 'author', 421 'tags', 422 'theme_root', 423 'theme_root_uri', 351 424 ); 352 425 … … 364 437 public function __get( $offset ) { 365 438 switch ( $offset ) { 366 case 'name' :367 case 'title' :368 return $this->get( 'Name');369 case 'version' :370 return $this->get( 'Version');371 case 'parent_theme' :372 return $this->parent() ? $this->parent()->get( 'Name') : '';373 case 'template_dir' :439 case 'name': 440 case 'title': 441 return $this->get( 'Name' ); 442 case 'version': 443 return $this->get( 'Version' ); 444 case 'parent_theme': 445 return $this->parent() ? $this->parent()->get( 'Name' ) : ''; 446 case 'template_dir': 374 447 return $this->get_template_directory(); 375 case 'stylesheet_dir' :448 case 'stylesheet_dir': 376 449 return $this->get_stylesheet_directory(); 377 case 'template' :450 case 'template': 378 451 return $this->get_template(); 379 case 'stylesheet' :452 case 'stylesheet': 380 453 return $this->get_stylesheet(); 381 case 'screenshot' :454 case 'screenshot': 382 455 return $this->get_screenshot( 'relative' ); 383 456 // 'author' and 'description' did not previously return translated data. 384 case 'description' :385 return $this->display( 'Description');386 case 'author' :387 return $this->display( 'Author');388 case 'tags' :457 case 'description': 458 return $this->display( 'Description' ); 459 case 'author': 460 return $this->display( 'Author' ); 461 case 'tags': 389 462 return $this->get( 'Tags' ); 390 case 'theme_root' :463 case 'theme_root': 391 464 return $this->get_theme_root(); 392 case 'theme_root_uri' :465 case 'theme_root_uri': 393 466 return $this->get_theme_root_uri(); 394 467 // For cases where the array was converted to an object. 395 default :468 default: 396 469 return $this->offsetGet( $offset ); 397 470 } … … 429 502 public function offsetExists( $offset ) { 430 503 static $keys = array( 431 'Name', 'Version', 'Status', 'Title', 'Author', 'Author Name', 'Author URI', 'Description', 432 'Template', 'Stylesheet', 'Template Files', 'Stylesheet Files', 'Template Dir', 'Stylesheet Dir', 433 'Screenshot', 'Tags', 'Theme Root', 'Theme Root URI', 'Parent Theme', 504 'Name', 505 'Version', 506 'Status', 507 'Title', 508 'Author', 509 'Author Name', 510 'Author URI', 511 'Description', 512 'Template', 513 'Stylesheet', 514 'Template Files', 515 'Stylesheet Files', 516 'Template Dir', 517 'Stylesheet Dir', 518 'Screenshot', 519 'Tags', 520 'Theme Root', 521 'Theme Root URI', 522 'Parent Theme', 434 523 ); 435 524 … … 454 543 public function offsetGet( $offset ) { 455 544 switch ( $offset ) { 456 case 'Name' :457 case 'Title' :545 case 'Name': 546 case 'Title': 458 547 /* 459 548 * See note above about using translated data. get() is not ideal. 460 549 * It is only for backward compatibility. Use display(). 461 550 */ 462 return $this->get( 'Name');463 case 'Author' :464 return $this->display( 'Author' );465 case 'Author Name' :466 return $this->display( 'Author', false );467 case 'Author URI' :468 return $this->display( 'AuthorURI');469 case 'Description' :470 return $this->display( 'Description' );471 case 'Version' :472 case 'Status' :551 return $this->get( 'Name' ); 552 case 'Author': 553 return $this->display( 'Author' ); 554 case 'Author Name': 555 return $this->display( 'Author', false ); 556 case 'Author URI': 557 return $this->display( 'AuthorURI' ); 558 case 'Description': 559 return $this->display( 'Description' ); 560 case 'Version': 561 case 'Status': 473 562 return $this->get( $offset ); 474 case 'Template' :563 case 'Template': 475 564 return $this->get_template(); 476 case 'Stylesheet' :565 case 'Stylesheet': 477 566 return $this->get_stylesheet(); 478 case 'Template Files' :567 case 'Template Files': 479 568 return $this->get_files( 'php', 1, true ); 480 case 'Stylesheet Files' :569 case 'Stylesheet Files': 481 570 return $this->get_files( 'css', 0, false ); 482 case 'Template Dir' :571 case 'Template Dir': 483 572 return $this->get_template_directory(); 484 case 'Stylesheet Dir' :573 case 'Stylesheet Dir': 485 574 return $this->get_stylesheet_directory(); 486 case 'Screenshot' :575 case 'Screenshot': 487 576 return $this->get_screenshot( 'relative' ); 488 case 'Tags' :489 return $this->get( 'Tags');490 case 'Theme Root' :577 case 'Tags': 578 return $this->get( 'Tags' ); 579 case 'Theme Root': 491 580 return $this->get_theme_root(); 492 case 'Theme Root URI' :581 case 'Theme Root URI': 493 582 return $this->get_theme_root_uri(); 494 case 'Parent Theme' :495 return $this->parent() ? $this->parent()->get( 'Name') : '';496 default :583 case 'Parent Theme': 584 return $this->parent() ? $this->parent()->get( 'Name' ) : ''; 585 default: 497 586 return null; 498 587 } … … 570 659 */ 571 660 public function cache_delete() { 572 foreach ( array( 'theme', 'screenshot', 'headers', 'post_templates' ) as $key ) 661 foreach ( array( 'theme', 'screenshot', 'headers', 'post_templates' ) as $key ) { 573 662 wp_cache_delete( $key . '-' . $this->cache_hash, 'themes' ); 663 } 574 664 $this->template = $this->textdomain_loaded = $this->theme_root_uri = $this->parent = $this->errors = $this->headers_sanitized = $this->name_translated = null; 575 $this->headers = array();665 $this->headers = array(); 576 666 $this->__construct( $this->stylesheet, $this->theme_root ); 577 667 } … … 594 684 */ 595 685 public function get( $header ) { 596 if ( ! isset( $this->headers[ $header ] ) ) 686 if ( ! isset( $this->headers[ $header ] ) ) { 597 687 return false; 688 } 598 689 599 690 if ( ! isset( $this->headers_sanitized ) ) { 600 691 $this->headers_sanitized = $this->cache_get( 'headers' ); 601 if ( ! is_array( $this->headers_sanitized ) ) 692 if ( ! is_array( $this->headers_sanitized ) ) { 602 693 $this->headers_sanitized = array(); 603 } 604 605 if ( isset( $this->headers_sanitized[ $header ] ) ) 694 } 695 } 696 697 if ( isset( $this->headers_sanitized[ $header ] ) ) { 606 698 return $this->headers_sanitized[ $header ]; 699 } 607 700 608 701 // If themes are a persistent group, sanitize everything and cache it. One cache add is better than many cache sets. 609 702 if ( self::$persistently_cache ) { 610 foreach ( array_keys( $this->headers ) as $_header ) 703 foreach ( array_keys( $this->headers ) as $_header ) { 611 704 $this->headers_sanitized[ $_header ] = $this->sanitize_header( $_header, $this->headers[ $_header ] ); 705 } 612 706 $this->cache_add( 'headers', $this->headers_sanitized ); 613 707 } else { … … 634 728 } 635 729 636 if ( $translate && ( empty( $value ) || ! $this->load_textdomain() ) ) 730 if ( $translate && ( empty( $value ) || ! $this->load_textdomain() ) ) { 637 731 $translate = false; 638 639 if ( $translate ) 732 } 733 734 if ( $translate ) { 640 735 $value = $this->translate_header( $header, $value ); 641 642 if ( $markup ) 736 } 737 738 if ( $markup ) { 643 739 $value = $this->markup_header( $header, $value, $translate ); 740 } 644 741 645 742 return $value; … … 660 757 private function sanitize_header( $header, $value ) { 661 758 switch ( $header ) { 662 case 'Status' :759 case 'Status': 663 760 if ( ! $value ) { 664 761 $value = 'publish'; … … 666 763 } 667 764 // Fall through otherwise. 668 case 'Name' :765 case 'Name': 669 766 static $header_tags = array( 670 767 'abbr' => array( 'title' => true ), … … 674 771 'strong' => true, 675 772 ); 676 $value = wp_kses( $value, $header_tags );773 $value = wp_kses( $value, $header_tags ); 677 774 break; 678 case 'Author' :775 case 'Author': 679 776 // There shouldn't be anchor tags in Author, but some themes like to be challenging. 680 case 'Description' :777 case 'Description': 681 778 static $header_tags_with_a = array( 682 'a' => array( 'href' => true, 'title' => true ), 779 'a' => array( 780 'href' => true, 781 'title' => true, 782 ), 683 783 'abbr' => array( 'title' => true ), 684 784 'acronym' => array( 'title' => true ), … … 687 787 'strong' => true, 688 788 ); 689 $value = wp_kses( $value, $header_tags_with_a );789 $value = wp_kses( $value, $header_tags_with_a ); 690 790 break; 691 case 'ThemeURI' :692 case 'AuthorURI' :791 case 'ThemeURI': 792 case 'AuthorURI': 693 793 $value = esc_url_raw( $value ); 694 794 break; 695 case 'Tags' :795 case 'Tags': 696 796 $value = array_filter( array_map( 'trim', explode( ',', strip_tags( $value ) ) ) ); 697 797 break; 698 case 'Version' :798 case 'Version': 699 799 $value = strip_tags( $value ); 700 800 break; … … 707 807 * Mark up a theme header. 708 808 * 709 * @since 3.4.0809 * @since 3.4.0 710 810 * 711 811 * @staticvar string $comma … … 718 818 private function markup_header( $header, $value, $translate ) { 719 819 switch ( $header ) { 720 case 'Name' :820 case 'Name': 721 821 if ( empty( $value ) ) { 722 822 $value = esc_html( $this->get_stylesheet() ); 723 823 } 724 824 break; 725 case 'Description' :825 case 'Description': 726 826 $value = wptexturize( $value ); 727 827 break; 728 case 'Author' :729 if ( $this->get( 'AuthorURI') ) {828 case 'Author': 829 if ( $this->get( 'AuthorURI' ) ) { 730 830 $value = sprintf( '<a href="%1$s">%2$s</a>', $this->display( 'AuthorURI', true, $translate ), $value ); 731 831 } elseif ( ! $value ) { … … 733 833 } 734 834 break; 735 case 'Tags' :835 case 'Tags': 736 836 static $comma = null; 737 837 if ( ! isset( $comma ) ) { … … 741 841 $value = implode( $comma, $value ); 742 842 break; 743 case 'ThemeURI' :744 case 'AuthorURI' :843 case 'ThemeURI': 844 case 'AuthorURI': 745 845 $value = esc_url( $value ); 746 846 break; … … 763 863 private function translate_header( $header, $value ) { 764 864 switch ( $header ) { 765 case 'Name' :865 case 'Name': 766 866 // Cached for sorting reasons. 767 if ( isset( $this->name_translated ) ) 867 if ( isset( $this->name_translated ) ) { 768 868 return $this->name_translated; 769 $this->name_translated = translate( $value, $this->get('TextDomain' ) ); 869 } 870 $this->name_translated = translate( $value, $this->get( 'TextDomain' ) ); 770 871 return $this->name_translated; 771 case 'Tags' :872 case 'Tags': 772 873 if ( empty( $value ) || ! function_exists( 'get_theme_feature_list' ) ) { 773 874 return $value; … … 778 879 $tags_list = array( 779 880 // As of 4.6, deprecated tags which are only used to provide translation for older themes. 780 'black' => __( 'Black' ), 'blue' => __( 'Blue' ), 'brown' => __( 'Brown' ), 781 'gray' => __( 'Gray' ), 'green' => __( 'Green' ), 'orange' => __( 'Orange' ), 782 'pink' => __( 'Pink' ), 'purple' => __( 'Purple' ), 'red' => __( 'Red' ), 783 'silver' => __( 'Silver' ), 'tan' => __( 'Tan' ), 'white' => __( 'White' ), 784 'yellow' => __( 'Yellow' ), 'dark' => __( 'Dark' ), 'light' => __( 'Light' ), 785 'fixed-layout' => __( 'Fixed Layout' ), 'fluid-layout' => __( 'Fluid Layout' ), 786 'responsive-layout' => __( 'Responsive Layout' ), 'blavatar' => __( 'Blavatar' ), 787 'photoblogging' => __( 'Photoblogging' ), 'seasonal' => __( 'Seasonal' ), 881 'black' => __( 'Black' ), 882 'blue' => __( 'Blue' ), 883 'brown' => __( 'Brown' ), 884 'gray' => __( 'Gray' ), 885 'green' => __( 'Green' ), 886 'orange' => __( 'Orange' ), 887 'pink' => __( 'Pink' ), 888 'purple' => __( 'Purple' ), 889 'red' => __( 'Red' ), 890 'silver' => __( 'Silver' ), 891 'tan' => __( 'Tan' ), 892 'white' => __( 'White' ), 893 'yellow' => __( 'Yellow' ), 894 'dark' => __( 'Dark' ), 895 'light' => __( 'Light' ), 896 'fixed-layout' => __( 'Fixed Layout' ), 897 'fluid-layout' => __( 'Fluid Layout' ), 898 'responsive-layout' => __( 'Responsive Layout' ), 899 'blavatar' => __( 'Blavatar' ), 900 'photoblogging' => __( 'Photoblogging' ), 901 'seasonal' => __( 'Seasonal' ), 788 902 ); 789 903 … … 804 918 return $value; 805 919 806 default :807 $value = translate( $value, $this->get( 'TextDomain') );920 default: 921 $value = translate( $value, $this->get( 'TextDomain' ) ); 808 922 } 809 923 return $value; … … 849 963 */ 850 964 public function get_stylesheet_directory() { 851 if ( $this->errors() && in_array( 'theme_root_missing', $this->errors()->get_error_codes() ) ) 965 if ( $this->errors() && in_array( 'theme_root_missing', $this->errors()->get_error_codes() ) ) { 852 966 return ''; 967 } 853 968 854 969 return $this->theme_root . '/' . $this->stylesheet; … … 866 981 */ 867 982 public function get_template_directory() { 868 if ( $this->parent() ) 983 if ( $this->parent() ) { 869 984 $theme_root = $this->parent()->theme_root; 870 else985 } else { 871 986 $theme_root = $this->theme_root; 987 } 872 988 873 989 return $theme_root . '/' . $this->template; … … 899 1015 */ 900 1016 public function get_template_directory_uri() { 901 if ( $this->parent() ) 1017 if ( $this->parent() ) { 902 1018 $theme_root_uri = $this->parent()->get_theme_root_uri(); 903 else1019 } else { 904 1020 $theme_root_uri = $this->get_theme_root_uri(); 1021 } 905 1022 906 1023 return $theme_root_uri . '/' . str_replace( '%2F', '/', rawurlencode( $this->template ) ); … … 932 1049 */ 933 1050 public function get_theme_root_uri() { 934 if ( ! isset( $this->theme_root_uri ) ) 1051 if ( ! isset( $this->theme_root_uri ) ) { 935 1052 $this->theme_root_uri = get_theme_root_uri( $this->stylesheet, $this->theme_root ); 1053 } 936 1054 return $this->theme_root_uri; 937 1055 } … … 953 1071 $screenshot = $this->cache_get( 'screenshot' ); 954 1072 if ( $screenshot ) { 955 if ( 'relative' == $uri ) 1073 if ( 'relative' == $uri ) { 956 1074 return $screenshot; 1075 } 957 1076 return $this->get_stylesheet_directory_uri() . '/' . $screenshot; 958 1077 } elseif ( 0 === $screenshot ) { … … 963 1082 if ( file_exists( $this->get_stylesheet_directory() . "/screenshot.$ext" ) ) { 964 1083 $this->cache_add( 'screenshot', 'screenshot.' . $ext ); 965 if ( 'relative' == $uri ) 1084 if ( 'relative' == $uri ) { 966 1085 return 'screenshot.' . $ext; 1086 } 967 1087 return $this->get_stylesheet_directory_uri() . '/' . 'screenshot.' . $ext; 968 1088 } … … 1013 1133 $post_templates = array(); 1014 1134 1015 $files = (array) $this->get_files( 'php', 1, true );1135 $files = (array) $this->get_files( 'php', 1, true ); 1016 1136 1017 1137 foreach ( $files as $file => $full_path ) { … … 1110 1230 1111 1231 if ( $extensions ) { 1112 $extensions = (array) $extensions;1232 $extensions = (array) $extensions; 1113 1233 $_extensions = implode( '|', $extensions ); 1114 1234 } … … 1120 1240 1121 1241 $results = scandir( $path ); 1122 $files = array();1242 $files = array(); 1123 1243 1124 1244 /** … … 1139 1259 continue; 1140 1260 } 1141 $found = self::scandir( $path . '/' . $result, $extensions, $depth - 1 , $relative_path . $result );1261 $found = self::scandir( $path . '/' . $result, $extensions, $depth - 1, $relative_path . $result ); 1142 1262 $files = array_merge_recursive( $files, $found ); 1143 1263 } elseif ( ! $extensions || preg_match( '~\.(' . $_extensions . ')$~', $result ) ) { … … 1158 1278 * 1159 1279 * @return bool True if the textdomain was successfully loaded or has already been loaded. 1160 * False if no textdomain was specified in the file headers, or if the domain could not be loaded.1280 * False if no textdomain was specified in the file headers, or if the domain could not be loaded. 1161 1281 */ 1162 1282 public function load_textdomain() { 1163 if ( isset( $this->textdomain_loaded ) ) 1283 if ( isset( $this->textdomain_loaded ) ) { 1164 1284 return $this->textdomain_loaded; 1165 1166 $textdomain = $this->get('TextDomain'); 1285 } 1286 1287 $textdomain = $this->get( 'TextDomain' ); 1167 1288 if ( ! $textdomain ) { 1168 1289 $this->textdomain_loaded = false; … … 1176 1297 1177 1298 $path = $this->get_stylesheet_directory(); 1178 if ( $domainpath = $this->get( 'DomainPath') )1299 if ( $domainpath = $this->get( 'DomainPath' ) ) { 1179 1300 $path .= $domainpath; 1180 else1301 } else { 1181 1302 $path .= '/languages'; 1303 } 1182 1304 1183 1305 $this->textdomain_loaded = load_theme_textdomain( $textdomain, $path ); … … 1191 1313 * 1192 1314 * @param string $check Optional. Whether to check only the 'network'-wide settings, the 'site' 1193 * settings, or 'both'. Defaults to 'both'.1315 * settings, or 'both'. Defaults to 'both'. 1194 1316 * @param int $blog_id Optional. Ignored if only network-wide settings are checked. Defaults to current site. 1195 1317 * @return bool Whether the theme is allowed for the network. Returns true in single-site. 1196 1318 */ 1197 1319 public function is_allowed( $check = 'both', $blog_id = null ) { 1198 if ( ! is_multisite() ) 1320 if ( ! is_multisite() ) { 1199 1321 return true; 1322 } 1200 1323 1201 1324 if ( 'both' == $check || 'network' == $check ) { 1202 1325 $allowed = self::get_allowed_on_network(); 1203 if ( ! empty( $allowed[ $this->get_stylesheet() ] ) ) 1326 if ( ! empty( $allowed[ $this->get_stylesheet() ] ) ) { 1204 1327 return true; 1328 } 1205 1329 } 1206 1330 1207 1331 if ( 'both' == $check || 'site' == $check ) { 1208 1332 $allowed = self::get_allowed_on_site( $blog_id ); 1209 if ( ! empty( $allowed[ $this->get_stylesheet() ] ) ) 1333 if ( ! empty( $allowed[ $this->get_stylesheet() ] ) ) { 1210 1334 return true; 1335 } 1211 1336 } 1212 1337 … … 1303 1428 static $allowed_themes = array(); 1304 1429 1305 if ( ! $blog_id || ! is_multisite() ) 1430 if ( ! $blog_id || ! is_multisite() ) { 1306 1431 $blog_id = get_current_blog_id(); 1432 } 1307 1433 1308 1434 if ( isset( $allowed_themes[ $blog_id ] ) ) { … … 1343 1469 } else { 1344 1470 $converted = array(); 1345 $themes = wp_get_themes();1471 $themes = wp_get_themes(); 1346 1472 foreach ( $themes as $stylesheet => $theme_data ) { 1347 if ( isset( $allowed_themes[ $blog_id ][ $theme_data->get( 'Name') ] ) )1473 if ( isset( $allowed_themes[ $blog_id ][ $theme_data->get( 'Name' ) ] ) ) { 1348 1474 $converted[ $stylesheet ] = true; 1475 } 1349 1476 } 1350 1477 $allowed_themes[ $blog_id ] = $converted;
Note:
See TracChangeset
for help on using the changeset viewer.