@@ -77,6 +77,7 @@ public function init() {
7777 * @see Bootstrap::__construct
7878 */
7979 $ this ->status = \get_option ( Sync::LOG_KEY );
80+
8081 \add_action ( 'admin_enqueue_scripts ' , array ( $ this , 'enqueueScript ' ) );
8182
8283 // \add_action( 'wp_ajax_' . self::ACTION_NAME, array( $this, 'sendStatus' ) );
@@ -101,23 +102,33 @@ public function renderAdminNotice() {
101102 return ;
102103 }
103104
105+ if ( empty ( $ this ->status ) ) {
106+ return ;
107+ }
108+
104109 $ status = isset ( $ this ->status ['get ' ]['response ' ] ) && 200 === $ this ->status ['get ' ]['response ' ] ? 'success ' : 'warning ' ;
105110 $ response = isset ( $ this ->status ['get ' ]['response ' ] ) ? isset ( $ this ->status ['get ' ]['response ' ] ) : \esc_html ( 'Request Failed ' , 'wp-action-network-events ' );
106-
107- switch ( $ this ->status ['source ' ] ) {
108- case 'manual ' :
109- $ source = esc_html__ ( 'Manually Synced ' , 'wp-action-network-events ' );
110- break ;
111- case 'import ' :
112- $ source = esc_html__ ( 'Manually Synced (Full Import) ' , 'wp-action-network-events ' );
113- break ;
114- default :
115- $ source = esc_html__ ( 'Auto-synced ' , 'wp-action-network-events ' );
111+ $ source = '' ;
112+ $ last_run = isset ( $ this ->status ['last_run ' ] ) ? $ this ->status ['last_run ' ] : '' ;
113+
114+ if ( isset ( $ this ->status ['source ' ] ) ) {
115+ switch ( $ this ->status ['source ' ] ) {
116+ case 'manual ' :
117+ $ source = esc_html__ ( 'Manually Synced ' , 'wp-action-network-events ' );
118+ break ;
119+ case 'import ' :
120+ $ source = esc_html__ ( 'Manually Synced (Full Import) ' , 'wp-action-network-events ' );
121+ break ;
122+ default :
123+ $ source = esc_html__ ( 'Auto-synced ' , 'wp-action-network-events ' );
124+ }
116125 }
117126
127+
128+
118129 ?>
119130 <div class="notice notice-<?php echo $ status ; ?> is-dismissible">
120- <p><?php printf ( 'Last %s at %s - Status %s ' , $ source , $ this -> status [ ' last_run ' ] , $ response ); ?> </p>
131+ <p><?php printf ( 'Last %s at %s - Status %s ' , $ source , $ last_run , $ response ); ?> </p>
121132 <p><?php print_r ( $ this ->status ); ?> </p>
122133 </div>
123134 <?php
0 commit comments