Changeset 10237 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/class-markdown-import.php
- Timestamp:
- 09/03/2020 11:57:12 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/class-markdown-import.php
r10169 r10237 1 1 <?php 2 /** 3 * Markdown Import 4 * 5 * This functionality has been disabled as of 2020-08-12. All of the lesson plans have been imported 6 * to learn.wordpress.org and can be updated via the WP admin interface. Leaving this here for now 7 * in case we need to re-activate for some reason. 8 */ 2 9 3 10 namespace WPOrg_Learn; 4 11 5 use WP_Error; 6 use WP_Query; 7 12 use WP_Error, WP_Query; 13 14 // These actions/filters should not be added while markdown import is disabled. 15 //add_action( 'init', array( 'WPOrg_Learn\Markdown_Import', 'action_init' ) ); 16 //add_action( 'wporg_learn_manifest_import', array( 'WPOrg_Learn\Markdown_Import', 'action_wporg_learn_manifest_import' ) ); 17 //add_action( 'wporg_learn_markdown_import', array( 'WPOrg_Learn\Markdown_Import', 'action_wporg_learn_markdown_import' ) ); 18 //add_action( 'load-post.php', array( 'WPOrg_Learn\Markdown_Import', 'action_load_post_php' ) ); 19 //add_action( 'edit_form_after_title', array( 'WPOrg_Learn\Markdown_Import', 'action_edit_form_after_title' ) ); 20 //add_action( 'save_post', array( 'WPOrg_Learn\Markdown_Import', 'action_save_post' ) ); 21 //add_filter( 'cron_schedules', array( 'WPOrg_Learn\Markdown_Import', 'filter_cron_schedules' ) ); 22 23 // This filter is still necessary because the lesson plans that were originally imported from GitHub still require 24 // that image assets be loaded from the same repositories. 25 add_filter( 'the_content', array( 'WPOrg_Learn\Markdown_Import', 'replace_image_links' ) ); 26 27 /** 28 * Class Markdown_Import 29 * 30 * @package WPOrg_Learn 31 */ 8 32 class Markdown_Import { 9 33 … … 184 208 placeholder="Enter a URL representing a markdown file to import" 185 209 size="50" /> 186 </label> 210 </label> 187 211 <?php 188 212 if ( $markdown_source ) : … … 319 343 return $html; 320 344 } 345 346 /** 347 * Source images from the GitHub repo. 348 * 349 * @param string $content 350 * 351 * @return string|string[] 352 */ 353 public static function replace_image_links( $content ) { 354 $post_id = get_the_ID(); 355 $markdown_source = self::get_markdown_source( $post_id ); 356 if ( is_wp_error( $markdown_source ) ) { 357 return $content; 358 } 359 $markdown_source = str_replace( '/README.md', '', $markdown_source ); 360 $content = str_replace( '<img src="/images/', '<img src="' . $markdown_source . '/images/', $content ); 361 362 return $content; 363 } 321 364 }
Note: See TracChangeset
for help on using the changeset viewer.