Changeset 10777 for sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/admin-notices.php
- Timestamp:
- 03/05/2021 12:44:02 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/admin-notices.php
r10776 r10777 16 16 add_action( 'admin_notices', [ __CLASS__, 'show_new_handbook_message' ] ); 17 17 add_action( 'admin_notices', [ __CLASS__, 'show_imported_handbook_notice' ] ); 18 add_action( 'admin_notices', [ __CLASS__, 'show_imported_handbook_config_errors' ] ); 18 19 } 19 20 … … 109 110 } 110 111 112 /** 113 * Outputs admin error notice(s) for any misconfigured imported handbooks. 114 * 115 * @access public 116 */ 117 public static function show_imported_handbook_config_errors() { 118 global $wp_query; 119 120 // Bail if handbook importer is not available. 121 if ( ! class_exists( 'WPorg_Handbook_Importer' ) ) { 122 return; 123 } 124 125 $current_screen = get_current_screen(); 126 127 // Only show message in listing of handbook posts when no posts are present yet. 128 if ( 129 $current_screen 130 && 131 'edit' === $current_screen->base 132 && 133 in_array( $current_screen->post_type, wporg_get_handbook_post_types() ) 134 && 135 WPorg_Handbook_Importer::is_handbook_imported( $current_screen->post_type ) 136 ) { 137 $handbook_config = WPorg_Handbook_Init::get_handbooks_config( $current_screen->post_type ); 138 139 $handbook = WPorg_Handbook_Init::get_handbook( $current_screen->post_type ); 140 if ( ! $handbook ) { 141 return; 142 } 143 144 $handbook_config = $handbook->get_config(); 145 $cron_intervals = wp_get_schedules(); 146 $interval_display = $handbook_config[ 'cron_interval' ] ?? ''; 147 148 if ( ! empty( $cron_intervals[ $interval_display ] ) ) { 149 return; 150 } 151 152 echo '<div class="notice notice-warning"><p>'; 153 printf( 154 /* translators: %s: cron interval. */ 155 __( '<strong>Misconfigured cron interval!</strong> This imported handbook has a misconfigured cron interval. The config defines an interval of <strong>%s</strong>, which has not been defined. The fallback import interval shown in a notice above includes the default cron interval currently in use.', 'wporg' ), 156 $interval_display 157 ); 158 echo "</p></div>\n"; 159 } 160 } 111 161 } 112 162
Note: See TracChangeset
for help on using the changeset viewer.