diff --git a/app/RestController.php b/app/RestController.php index b1605fc..70b3562 100644 --- a/app/RestController.php +++ b/app/RestController.php @@ -103,7 +103,7 @@ public function pantheonCloudStatusCheck() /** * Handle incoming webhook requests. - * @return void + * @return void|WP_REST_Response */ public function handleWebhook(WP_REST_Request $request) { @@ -122,7 +122,7 @@ public function handleWebhook(WP_REST_Request $request) if (!$isPCCConfiguredCorrectly) { return new WP_REST_Response( esc_html__('Website is not correctly configured', PCC_HANDLE), - 200 + 500 ); } diff --git a/app/Settings.php b/app/Settings.php index feabedb..eee6900 100644 --- a/app/Settings.php +++ b/app/Settings.php @@ -8,6 +8,7 @@ namespace PCC; +use Exception; use PccPhpSdk\api\Query\Enums\PublishingLevel; use function add_action; @@ -112,6 +113,38 @@ public function verifyCollectionUrl() } } + /** + * Get access token from the database. + * + * @return array|mixed + */ + private function getAccessToken(): mixed + { + $pccToken = get_option(PCC_ACCESS_TOKEN_OPTION_KEY); + + return $pccToken ?: []; + } + + /** + * @return false|mixed|null + */ + private function getSiteId(): mixed + { + return get_option(PCC_SITE_ID_OPTION_KEY); + } + + /** + * Get access token from the database. + * + * @return array|mixed + */ + private function getAPIAccessKey(): mixed + { + $apiKey = get_option(PCC_API_KEY_OPTION_KEY); + + return $apiKey ?: []; + } + /** * Allow style tags in the content. * @@ -151,7 +184,7 @@ public function publishDocuments(): void $pcc = new PccSyncManager(); $postId = $pcc->fetchAndStoreDocument($documentId, PublishingLevel::PRODUCTION); - wp_redirect(get_permalink($postId)); + wp_redirect(add_query_arg('nocache', 'true', get_permalink($postId))); exit; } @@ -185,7 +218,7 @@ public function publishDocuments(): void wp_redirect($url); exit; } - } catch (\Exception $ex) { + } catch (Exception $ex) { // No Action needed for safe exit } } @@ -362,26 +395,6 @@ public function renderSettingsPage(): void require $this->pages['setup']; } - /** - * @return false|mixed|null - */ - private function getSiteId(): mixed - { - return get_option(PCC_SITE_ID_OPTION_KEY); - } - - /** - * Get access token from the database. - * - * @return array|mixed - */ - private function getAccessToken(): mixed - { - $pccToken = get_option(PCC_ACCESS_TOKEN_OPTION_KEY); - - return $pccToken ?: []; - } - /** * Enqueue plugin assets on the WP Admin Dashboard. * @@ -498,16 +511,4 @@ private function getEncodedSiteURL(): mixed { return get_option(PCC_ENCODED_SITE_URL_OPTION_KEY); } - - /** - * Get access token from the database. - * - * @return array|mixed - */ - private function getAPIAccessKey(): mixed - { - $apiKey = get_option(PCC_API_KEY_OPTION_KEY); - - return $apiKey ?: []; - } }