Skip to content

Commit 85cb970

Browse files
authored
Merge pull request #60 from BenjaminMedia/FORD-48-allow-slashes-in-text
Added code to allow slashes in acf markdown-editor fields
2 parents 53be4ec + 3102f78 commit 85cb970

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/ACF/MarkdownEditor.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,13 @@ function update_value( $value, $post_id, $field ) {
341341
}
342342
343343
*/
344-
345-
344+
345+
function update_value( $value, $post_id, $field ) {
346+
// acf saves calls stripslashes_deep() on save which removes all slashes from content
347+
// to allow slashes we call wp_slash() on value before it is saved to the database
348+
return wp_slash($value);
349+
}
350+
346351
/*
347352
* format_value()
348353
*

src/Commands/Composites.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Bonnier\WP\ContentHub\Editor\Commands;
44

5+
use Bonnier\WP\Cache\Models\Post;
56
use Bonnier\WP\ContentHub\Editor\Commands\Taxonomy\Helpers\WpTerm;
67
use Bonnier\WP\ContentHub\Editor\Helpers\SlugHelper;
78
use Bonnier\WP\ContentHub\Editor\Models\WpAttachment;
@@ -48,6 +49,11 @@ public function import($args, $assocArgs)
4849
return [];
4950
});
5051

52+
// Disable on save hook to prevent call to content hub on import
53+
remove_action( 'save_post', [WpComposite::class, 'on_save'], 10, 2 );
54+
// Disable on save hook in wp bonnier cache, to avoid triggering cxense crawl on import
55+
remove_action( 'save_post', [Post::class, 'update_post'], 10, 1 );
56+
5157
if($id = $assocArgs['id'] ?? null) {
5258
$this->import_composite(CompositeRepository::find_by_id($id));
5359
return;

0 commit comments

Comments
 (0)