Skip to content

Commit

Permalink
Merge pull request #86 from pantheon-systems/1.2.2
Browse files Browse the repository at this point in the history
1.2.2
  • Loading branch information
al-esc authored Sep 4, 2024
2 parents eec8abb + 66742ab commit be846b7
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
3 changes: 3 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Trying to directly edit a page built with Pantheon Content Publisher will redire
All posts/pages created with Pantheon Content Publisher will remain on your WordPress site. However, you will no longer be able to edit them from Google Docs.

== Changelog ==
= 1.2.2 =
* Compatibility: Save <style> tag at the end of post content
* Stability: Improve edge case handling for PCC articles
= 1.2.1 =
* Fix: Ensure clean excerpts for PCC articles
* Compatibility: Improve image upload compatibility
Expand Down
20 changes: 18 additions & 2 deletions app/PccSyncManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function fetchAndStoreDocument(
ContentType::TREE_PANTHEON_V2
);

return $this->storeArticle($article, $isDraft);
return $article ? $this->storeArticle($article, $isDraft) : 0;
}

/**
Expand Down Expand Up @@ -116,9 +116,25 @@ public function findExistingConnectedPost($value)
*/
private function createOrUpdatePost($postId, Article $article, bool $isDraft = false)
{
// Original content
$content = $article->content;

// Regular expression to match all <style>...</style> blocks
$pattern = '/<style.*?>.*?<\/style>/is';

// Find all <style> blocks
preg_match_all($pattern, $content, $matches);

// Remove all <style> blocks from the original content
$content = preg_replace($pattern, '', $content);

// Concatenate all <style> blocks at the end
foreach ($matches[0] as $styleBlock) {
$content .= $styleBlock;
}
$data = [
'post_title' => $article->title,
'post_content' => $article->content,
'post_content' => $content,
'post_status' => $isDraft ? 'draft' : 'publish',
'post_name' => $article->slug,
'post_type' => $this->getIntegrationPostType(),
Expand Down
2 changes: 1 addition & 1 deletion app/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function publishDocuments(): void
$pcc = new PccSyncManager();
$postId = $pcc->fetchAndStoreDocument($documentId, PublishingLevel::PRODUCTION);

wp_redirect(add_query_arg('nocache', 'true', get_permalink($postId)));
wp_redirect(add_query_arg('nocache', 'true', get_permalink($postId) ?: site_url()));
exit;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pantheon-content-publisher-for-wordpress",
"version": "1.2.1",
"version": "1.2.2",
"description": "Publish WordPress content from Google Docs with Pantheon Content Cloud.",
"scripts": {
"dev": "NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js",
Expand Down
2 changes: 1 addition & 1 deletion pantheon-content-publisher-for-wordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Plugin URI: https://pantheon.io
* Author: Pantheon
* Author URI: https://pantheon.io
* Version: 1.2.1
* Version: 1.2.2
*
* @package pantheon\pantheon-content-publisher-for-wordpress
*/
Expand Down

0 comments on commit be846b7

Please sign in to comment.