Changeset 8688
- Timestamp:
- 04/25/2019 09:34:14 PM (6 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/functions.php
r8686 r8688 75 75 // Coding Standards handbook. 76 76 require __DIR__ . '/inc/import-coding-standards.php'; 77 } 78 79 /** 80 * REST API handbook. 81 */ 82 if ( class_exists( '\\WordPressdotorg\\Markdown\\Importer' ) ) { 77 78 // REST API handbook. 83 79 require __DIR__ . '/inc/rest-api.php'; 84 80 } -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/handbooks.php
r8684 r8688 27 27 add_filter( 'handbook_post_type_defaults', array( __CLASS__, 'filter_handbook_post_type_defaults' ), 10, 2 ); 28 28 add_filter( 'handbook_post_types', array( __CLASS__, 'filter_handbook_post_types' ) ); 29 add_filter( 'handbook_label', array( __CLASS__, 'filter_handbook_label' ), 10, 2 );30 29 add_action( 'init', array( __CLASS__, 'do_init' ) ); 31 30 } … … 98 97 public static function filter_handbook_post_types( $types ) { 99 98 if ( ! self::$post_types ) { 100 self::$post_types = apply_filters( 'devhub_handbook_post_types', [ 'plugin', ' rest-api', 'theme' ] );99 self::$post_types = apply_filters( 'devhub_handbook_post_types', [ 'plugin', 'theme' ] ); 101 100 } 102 101 … … 188 187 189 188 /** 190 * Overrides the default handbook label used as the base for various handbook191 * post type related strings.192 *193 * @param string $label The default label, which is merely a santized194 * version of the handbook name.195 * @param string $post_type The handbook post type.196 * @return string197 */198 public static function filter_handbook_label( $label, $post_type ) {199 if ( 'rest-api-handbook' === $post_type ) {200 $label = __( 'REST API Handbook', 'wporg' );201 }202 203 return $label;204 }205 206 /**207 189 * For specific credit pages, link @usernames references to their profiles on 208 190 * profiles.wordpress.org. -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/rest-api.php
r5993 r8688 1 1 <?php 2 2 3 use WordPressdotorg\Markdown\Editor; 4 use WordPressdotorg\Markdown\Importer; 3 class DevHub_REST_API extends DevHub_Docs_Importer { 4 /** 5 * Initializes object. 6 */ 7 public function init() { 8 parent::do_init( 9 'rest-api', 10 'rest-api', 11 'https://raw.githubusercontent.com/WP-API/docs/master/bin/manifest.json' 12 ); 5 13 6 class DevHub_REST_API extends Importer { 7 /** 8 * Singleton instance. 9 * 10 * @var static 11 */ 12 protected static $instance; 13 14 /** 15 * Get the singleton instance, or create if needed. 16 * 17 * @return static 18 */ 19 public static function instance() { 20 if ( empty( static::$instance ) ) { 21 static::$instance = new static(); 22 } 23 24 return static::$instance; 25 } 26 27 protected function get_base() { 28 return home_url( 'rest-api/' ); 29 } 30 31 protected function get_manifest_url() { 32 return 'https://raw.githubusercontent.com/WP-API/docs/master/bin/manifest.json'; 33 } 34 35 public function get_post_type() { 36 return 'rest-api-handbook'; 37 } 38 39 public function init() { 40 add_filter( 'cron_schedules', array( $this, 'filter_cron_schedules' ) ); 41 add_action( 'init', array( $this, 'register_cron_jobs' ) ); 42 add_action( 'devhub_restapi_import_manifest', array( $this, 'import_manifest' ) ); 43 add_action( 'devhub_restapi_import_all_markdown', array( $this, 'import_all_markdown' ) ); 44 45 $editor = new Editor( $this ); 46 $editor->init(); 14 add_filter( 'handbook_label', array( $this, 'change_handbook_label' ), 10, 2 ); 47 15 } 48 16 49 17 /** 50 * Filter cron schedules to add a 15 minute schedule, if there isn't one. 18 * Overrides the default handbook label since post type name does not directly 19 * translate to post type label. 20 * 21 * @param string $label The default label, which is merely a sanitized 22 * version of the handbook name. 23 * @param string $post_type The handbook post type. 24 * @return string 51 25 */ 52 public function filter_cron_schedules( $schedules ) { 53 if ( empty( $schedules['15_minutes'] ) ) { 54 $schedules['15_minutes'] = array( 55 'interval' => 15 * MINUTE_IN_SECONDS, 56 'display' => '15 minutes' 57 ); 26 public static function change_handbook_label( $label, $post_type ) { 27 if ( $this->get_post_type() === $post_type ) { 28 $label = __( 'REST API Handbook', 'wporg' ); 58 29 } 59 return $schedules;60 }61 30 62 public function register_cron_jobs() { 63 if ( ! wp_next_scheduled( 'devhub_restapi_import_manifest' ) ) { 64 wp_schedule_event( time(), '15_minutes', 'devhub_restapi_import_manifest' ); 65 } 66 if ( ! wp_next_scheduled( 'devhub_restapi_import_all_markdown' ) ) { 67 wp_schedule_event( time(), '15_minutes', 'devhub_restapi_import_all_markdown' ); 68 } 31 return $label; 69 32 } 70 33 }
Note: See TracChangeset
for help on using the changeset viewer.