Changeset 8776
- Timestamp:
- 05/10/2019 06:43:32 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-markdown/inc/class-importer.php
r8720 r8776 234 234 WP_CLI::log( "Created post {$post_id} for {$doc['slug']}." ); 235 235 } 236 update_post_meta( $post_id, $this->meta_key, esc_url_raw( $ doc['markdown_source']) );236 update_post_meta( $post_id, $this->meta_key, esc_url_raw( $this->generate_markdown_source_url( $doc['markdown_source'] ) ) ); 237 237 update_post_meta( $post_id, $this->manifest_entry_meta_key, $doc ); 238 238 return get_post( $post_id ); … … 249 249 update_post_meta( $post_id, $this->manifest_entry_meta_key, $doc ); 250 250 251 $did_update = update_post_meta( $post_id, $this->meta_key, esc_url_raw( $ doc['markdown_source']) );251 $did_update = update_post_meta( $post_id, $this->meta_key, esc_url_raw( $this->generate_markdown_source_url( $doc['markdown_source'] ) ) ); 252 252 if ( ! $did_update ) { 253 253 return false; … … 422 422 423 423 /** 424 * Generates a fully qualified markdown source URL in the event a relative 425 * path was defined. 426 * 427 * @param string $markdown_source The markdwon_source value defined for a 428 * document in the manifest. 429 * @return string 430 */ 431 public function generate_markdown_source_url( $markdown_source ) { 432 // If source is not explicit URL, then it is relative. 433 if ( false === strpos( $markdown_source, 'https://' ) ) { 434 // Base URL is the location of the manifest. 435 $base = $this->get_manifest_url(); 436 $base = rtrim( dirname( $base ), '/' ); 437 438 // Markdown source can relatively refer to manifest's parent directory, 439 // but no higher. 440 if ( false !== strpos( $markdown_source, '../' ) ) { 441 $base = rtrim( dirname( $base ), '/' ); 442 $markdown_source = str_replace( '../', '/', $markdown_source ); 443 } 444 445 $markdown_source = $base . '/' . ltrim( $markdown_source, '/' ); 446 } 447 448 return $markdown_source; 449 } 450 451 /** 424 452 * Retrieve the markdown source URL for a given post. 425 453 */
Note: See TracChangeset
for help on using the changeset viewer.