Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to remove HTML from "article document title" before submitting to Apple News? #1191

Open
newvision2112 opened this issue Nov 6, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@newvision2112
Copy link

newvision2112 commented Nov 6, 2024

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?

@newvision2112 newvision2112 added the bug Something isn't working label Nov 6, 2024
@newvision2112 newvision2112 changed the title How to remove <em> <I> or other HTML from post title before submitting to Apple News? How to remove <em> <I> or other HTML from "article document title" before submitting to Apple News? Nov 6, 2024
@newvision2112 newvision2112 changed the title How to remove <em> <I> or other HTML from "article document title" before submitting to Apple News? How to remove HTML from "article document title" before submitting to Apple News? Nov 6, 2024
@mogmarsh
Copy link

mogmarsh commented Nov 6, 2024

@newvision2112 you should be able to use the apple_news_exporter_title filter

@newvision2112
Copy link
Author

newvision2112 commented Nov 6, 2024

@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:
SCR-20241106-kpja

And the main headline:
SCR-20241106-kqje

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?

@mogmarsh
Copy link

mogmarsh commented Nov 6, 2024

@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']

@mogmarsh
Copy link

mogmarsh commented Nov 6, 2024

@newvision2112 also, the tags should already be stripped:

'title' => wp_strip_all_tags( $this->content_title() ),

@newvision2112
Copy link
Author

newvision2112 commented Nov 6, 2024

@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.

@kevinfodness
Copy link
Member

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 &lt;i>italic title&lt;\/i>"

@newvision2112
Copy link
Author

Thank you Kevin! Please let me know if I can test anything, or what a timeline for the fix might be.
All best,
Dean

@mogmarsh
Copy link

mogmarsh commented Nov 7, 2024

@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.

@newvision2112
Copy link
Author

newvision2112 commented Nov 8, 2024

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants