Open newvision2112 opened 1 week ago
@newvision2112 you should be able to use the apple_news_exporter_title filter
@mogmarsh Thank you. So when I remove HTML tags on that:
$title_start = $post->post_title;
$title_start_2 = strip_tags($title_start);
$title = apply_filters( 'apple_news_exporter_title', $title_start_2, $post->ID );
It removes the html from ALL titles in the JSON. So it looks like we lose the ability to have italics tags in live article headline that people read in Apple News.
The article title JSON:
And the main headline:
Is there a way to only have the HTML removed from the "article document title"? But leave it in the regular title that shows up with the story on Apple News?
@newvision2112 The apple_news_generate_json filter should work. It gives you an array representation of the json, so you would just change $json['title']
@newvision2112 also, the tags should already be stripped: https://github.com/alleyinteractive/apple-news/blob/6eedc7922db8dac44a4191816a18a3b152492a8f/includes/apple-exporter/class-exporter.php#L212
@mogmarsh Thank you. I will work on apple_news_generate_json filter.
I saw that code in the plugin 'title' => wp_strip_all_tags( $this->content_title() ),
but it did not remove the html tags <I>title text</I>
or <em>title text</em>
from any of our JSON title fields in our submissions to Apple News drafts.
Apple News flagged the problem to us and halted our site going live until we fix it.
You're right, this is a bug. I was able to reproduce this on a vanilla installation of the plugin. It appears that the HTML in the title is getting partially transformed which is interfering with strip tags, which results in this output:
"title": "Test <i>italic title<\/i>"
Thank you Kevin! Please let me know if I can test anything, or what a timeline for the fix might be. All best, Dean
@newvision2112 My suggestion above should work until we get the bug fixed. That filter runs at the very last minute and allows you to change almost anything.
@mogmarsh Thank you, but I don't understand the code enough to use apple_news_generate_json.
For now, to get Apple News to approve us, I used the code above to strip all html from all titles
Description of the bug
We are submitting our draft articles to Apple News. The issue is our post titles need to italicize names of magazines and newspapers so we have
<I></I>
and<em></em>
tags in the title text. This works for WordPress showing the title on our website. But, it turns out Apple News will not accept "article document title" with HTML in them. This is not the title of the article that shows in Apple News.How do I configure the plugin strip the HTML characters from the "article document title" before submitting the JSON to Apple News?