Closed calebsmithdev closed 6 months ago
@calebsmithdev it indeed looks like this filter wasn't very well thought out. We definitely still want to sanitize whatever's passed through the filter, just for security purposes, but what the filter really ought to be doing is filter the new data instead of the existing data on the AIOSEO post object.
I'm going to update the code to this in our 4.6.2 update -
$thePost = self::getPost( $postId );
$data = apply_filters( 'aioseo_save_post', $data, $thePost );
// Before setting the data, we check if the title/description are the same as the defaults and clear them if so.
$data = self::checkForDefaultFormat( $postId, $thePost, $data );
$thePost = self::sanitizeAndSetDefaults( $postId, $thePost, $data );
I assume that will work for you?
That works perfectly! Thanks for taking a look at this.
@calebsmithdev no problem, thanks for confirming. This has been staged for our 4.6.2 release so I'll be closing the issue now.
Following the docs here, I am trying to use the
aioseo_save_post
filter to automatically adjust the robots to noindex and nofollow depending on the checked state of an ACF form value. Below is an example of my code.The $post value looks correct, but the values do not save and I see the values being reverted back to the default data state once it hits this line of code.
https://github.com/awesomemotive/all-in-one-seo-pack/blob/fcdbdd48252ca408eb020af2e2af5f5f333a4bf0/app/Common/Models/Post.php#L280
Shouldn't the filter happen after the sanitization and setting of default data?