1111require_once plugin_dir_path ( __FILE__ ) . '../class-api-action.php ' ;
1212require_once plugin_dir_path ( __FILE__ ) . 'class-export.php ' ;
1313
14+ use Admin_Apple_Async ;
1415use Admin_Apple_Notice ;
1516use Admin_Apple_Sections ;
1617use Apple_Actions \Action_Exception ;
1718use Apple_Actions \API_Action ;
19+ use Apple_Exporter \Exporter ;
20+ use Apple_Exporter \Settings ;
21+ use Apple_Push_API \Request \Request_Exception ;
1822
1923/**
2024 * A class to handle a push request from the admin.
@@ -51,21 +55,20 @@ class Push extends API_Action {
5155 /**
5256 * Current instance of the Exporter.
5357 *
54- * @var Exporter
58+ * @var Exporter;
5559 * @access private
5660 */
57- private $ exporter ;
61+ private Exporter $ exporter ;
5862
5963 /**
6064 * Constructor.
6165 *
62- * @param \Apple_Exporter\ Settings $settings A settings object containing settings at load time.
66+ * @param Settings $settings A settings object containing settings at load time.
6367 * @param int $id The ID for the content object to be pushed.
6468 */
6569 public function __construct ( $ settings , $ id ) {
6670 parent ::__construct ( $ settings );
6771 $ this ->id = $ id ;
68- $ this ->exporter = null ;
6972 }
7073
7174 /**
@@ -88,7 +91,7 @@ public function perform( $doing_async = false, $user_id = null ) {
8891 // Track this publish event as pending with the timestamp it was sent.
8992 update_post_meta ( $ this ->id , 'apple_news_api_pending ' , time () );
9093
91- wp_schedule_single_event ( time (), \ Admin_Apple_Async::ASYNC_PUSH_HOOK , [ $ this ->id , get_current_user_id () ] );
94+ wp_schedule_single_event ( time (), Admin_Apple_Async::ASYNC_PUSH_HOOK , [ $ this ->id , get_current_user_id () ] );
9295 } else {
9396 return $ this ->push ( $ user_id );
9497 }
@@ -312,7 +315,6 @@ private function push( $user_id = null ) {
312315
313316 // If there's an API ID, update, otherwise create.
314317 $ remote_id = get_post_meta ( $ this ->id , 'apple_news_api_id ' , true );
315- $ result = null ;
316318
317319 /**
318320 * Actions to be taken before the article is pushed to Apple News.
@@ -441,7 +443,7 @@ private function push( $user_id = null ) {
441443 * @param object $result The JSON returned by the Apple News API.
442444 */
443445 do_action ( 'apple_news_after_push ' , $ this ->id , $ result );
444- } catch ( \ Apple_Push_API \ Request \ Request_Exception $ e ) {
446+ } catch ( Request_Exception $ e ) {
445447
446448 // Remove the pending designation if it exists.
447449 delete_post_meta ( $ this ->id , 'apple_news_api_pending ' );
@@ -502,7 +504,7 @@ private function process_errors( $errors ) {
502504
503505 // Build the component alert error message, if required.
504506 if ( ! empty ( $ errors [0 ]['component_errors ' ] ) ) {
505- // Build an list of the components that caused errors.
507+ // Build a list of the components that caused errors.
506508 $ component_names = implode ( ', ' , $ errors [0 ]['component_errors ' ] );
507509
508510 if ( 'warn ' === $ component_alerts ) {
@@ -539,7 +541,7 @@ private function process_errors( $errors ) {
539541 // Throw an exception.
540542 throw new Action_Exception ( esc_html ( $ alert_message ) );
541543 } elseif ( 'warn ' === $ component_alerts && ! empty ( $ errors [0 ]['component_errors ' ] ) ) {
542- \ Admin_Apple_Notice::error ( $ alert_message , $ user_id );
544+ Admin_Apple_Notice::error ( $ alert_message , $ user_id );
543545 }
544546 }
545547
0 commit comments