Changeset 10775
- Timestamp:
- 03/05/2021 12:40:59 AM (4 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/handbook.php
r9990 r10775 3 3 * Plugin Name: Handbook 4 4 * Description: Features for a handbook, complete with glossary and table of contents 5 * Version: 2.0 5 6 * Author: WordPress.org 6 7 * Author URI: https://wordpress.org/ … … 25 26 require_once __DIR__ . '/inc/blocks.php'; 26 27 28 add_action( 'plugins_loaded', function () { 29 if ( class_exists( 'WordPressdotorg\\Markdown\\Importer' ) ) { 30 require_once __DIR__ . '/inc/importer.php'; 31 } 32 }, 1 ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/handbook.php
r10772 r10775 35 35 */ 36 36 protected $label = ''; 37 38 /** 39 * The associated importer object, if warranted. 40 */ 41 protected $importer; 37 42 38 43 /** … … 78 83 * Associative array of handbook configuration. 79 84 * 85 * @type string $cron_interval The cron interval for which an imported handbook gets 86 * imported, e.g. 'hourly', 'daily'. If defined as an 87 * unrecognized interval, 'hourly' will be used. 88 * Default '15_minutes'. 80 89 * @type string $label The label for the handbook. Default is the 81 90 * post type slug converted to titlecase (e.g. 82 91 * plugin-handbok => "Plugin Handbook"). 92 * @type string manifest The URL to the manifest JSON file for an imported 93 * handbook. 83 94 * @type string $slug The slug for the post type. Default is the 84 95 * post type. … … 86 97 */ 87 98 return (array) apply_filters( 'handbook_default_handbook_config', [ 99 'cron_interval' => '15_minutes', 88 100 'label' => '', 101 'manifest' => '', 89 102 'slug' => '', 90 103 ] ); … … 142 155 $this->setting_name = $this->post_type . '_name'; 143 156 157 add_action( 'after_handbooks_init', [ $this, 'init_importer' ] ); 144 158 add_filter( 'user_has_cap', [ $this, 'grant_handbook_caps' ] ); 145 159 add_action( 'widgets_init', [ $this, 'register_post_type' ] ); … … 171 185 public function get_config() { 172 186 return $this->config; 187 } 188 189 /** 190 * Returns the handbook's importer object, if applicable. 191 * 192 * @return WPorg_Handbook_Importer|null 193 */ 194 public function get_importer() { 195 return $this->importer; 196 } 197 198 /** 199 * Initializes the importer, if applicable. 200 */ 201 public function init_importer() { 202 $config = $this->get_config(); 203 204 if ( class_exists( 'WPorg_Handbook_Importer' ) ) { 205 if ( WPorg_Handbook_Importer::is_handbook_imported( $this->post_type ) ) { 206 $this->importer = new WPorg_Handbook_Importer( $this ); 207 } 208 } elseif ( is_admin() && ( $config['manifest'] ?: false ) ) { 209 add_action( 'admin_notices', function () { 210 echo '<div class="notice notice-error"><p>' . __( 'Error: The <strong>WPORG Markdown Importer</strong> plugin needs to be activated in order to allow importing of handbooks.', 'wporg' ) . '</p></div>'; 211 } ); 212 } 173 213 } 174 214 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/phpunit/includes/utils.php
r10773 r10775 32 32 function dataprovider_get_default_config() { 33 33 return [ 34 [ 'cron_interval', '15_minutes' ], 34 35 [ 'label', '' ], 36 [ 'manifest', '' ], 35 37 [ 'slug', '' ], 36 38 ];
Note: See TracChangeset
for help on using the changeset viewer.