Changeset 1397 for sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php
- Timestamp:
- 03/13/2015 12:04:27 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php
r1395 r1397 339 339 wporg_themes_update_wpthemescom( $post->post_name, $version ); 340 340 341 // Update the post with this version's description and tags. 342 $theme_data = wporg_themes_get_header_data( sprintf( 'https://themes.svn.wordpress.org/%1$s/%2$s/style.css', $post->post_name, $version ) ); 343 wp_update_post( array( 344 'ID' => $post_id, 345 'post_content' => $theme_data['Description'], 346 'tags_input' => $theme_data['Tags'], 347 ) ); 348 341 349 /* 342 350 * Bail if we're activating an old version, the author does not need to be … … 499 507 } 500 508 } 509 510 /** 511 * Custom version of core's deprecated `get_theme_data()` function. 512 * 513 * @param string $theme_file Path to the file. 514 * @return array File headers. 515 */ 516 function wporg_themes_get_header_data( $theme_file ) { 517 $themes_allowed_tags = array( 518 'a' => array( 519 'href' => array(), 520 'title' => array(), 521 ), 522 'abbr' => array( 523 'title' => array(), 524 ), 525 'acronym' => array( 526 'title' => array(), 527 ), 528 'code' => array(), 529 'em' => array(), 530 'strong' => array(), 531 ); 532 533 $theme_data = implode( '', file( $theme_file ) ); 534 $theme_data = str_replace( '\r', '\n', $theme_data ); 535 preg_match( '|^[ \t\/*#@]*Theme Name:(.*)$|mi', $theme_data, $theme_name ); 536 preg_match( '|^[ \t\/*#@]*Theme URI:(.*)$|mi', $theme_data, $theme_uri ); 537 preg_match( '|^[ \t\/*#@]*Description:(.*)$|mi', $theme_data, $description ); 538 539 if ( preg_match( '|^[ \t\/*#@]*Author URI:(.*)$|mi', $theme_data, $author_uri ) ) { 540 $author_uri = esc_url( trim( $author_uri[1] ) ); 541 } else { 542 $author_uri = ''; 543 } 544 545 if ( preg_match( '|^[ \t\/*#@]*Template:(.*)$|mi', $theme_data, $template ) ) { 546 $template = wp_kses( trim( $template[1] ), $themes_allowed_tags ); 547 } else { 548 $template = ''; 549 } 550 551 if ( preg_match( '|^[ \t\/*#@]*Version:(.*)$|mi', $theme_data, $version ) ) { 552 $version = wp_kses( trim( $version[1] ), $themes_allowed_tags ); 553 } else { 554 $version = ''; 555 } 556 557 if ( preg_match( '|^[ \t\/*#@]*Status:(.*)$|mi', $theme_data, $status ) ) { 558 $status = wp_kses( trim( $status[1] ), $themes_allowed_tags ); 559 } else { 560 $status = 'publish'; 561 } 562 563 if ( preg_match( '|^[ \t\/*#@]*Tags:(.*)$|mi', $theme_data, $tags ) ) { 564 $tags = array_map( 'trim', explode( ',', wp_kses( trim( $tags[1] ), array() ) ) ); 565 } else { 566 $tags = array(); 567 } 568 569 if ( preg_match( '|^[ \t\/*#@]*Author:(.*)$|mi', $theme_data, $author_name ) ) { 570 $author = wp_kses( trim( $author_name[1] ), $themes_allowed_tags ); 571 } else { 572 $author = 'Anonymous'; 573 } 574 575 $name = $theme = wp_kses( trim( $theme_name[1] ), $themes_allowed_tags ); 576 $theme_uri = esc_url( trim( $theme_uri[1] ) ); 577 $description = wp_kses( trim( $description[1] ), $themes_allowed_tags ); 578 579 return array( 580 'Name' => $name, 581 'Title' => $theme, 582 'URI' => $theme_uri, 583 'Description' => $description, 584 'Author' => $author, 585 'Author_URI' => $author_uri, 586 'Version' => $version, 587 'Template' => $template, 588 'Status' => $status, 589 'Tags' => $tags, 590 ); 591 }
Note: See TracChangeset
for help on using the changeset viewer.