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

Problem with the REST API #446

Open
Nefastor opened this issue Sep 14, 2018 · 2 comments
Open

Problem with the REST API #446

Nefastor opened this issue Sep 14, 2018 · 2 comments

Comments

@Nefastor
Copy link

Nefastor commented Sep 14, 2018

Hi,

Here's the deal : I'm using the REST API to create pages and posts on a WordPress website with Crayon installed and active. Some of those posts include code snippets encapsulated in <pre> tags. Problem is, Crayon doesn't seem to render them, it's like it doesn't see them at all, and I end-up with a generic gray square that contains my code in monochrome, no highlighting whatsoever.

At first I figured I must have done something wrong with my <pre> tags and tried all sorts of things, with the same result. So I moved on, and things got freaky.

If I edit my freshly-published pages in WordPress itself, and click "update" without touching anything else, then Crayon does its job. Even though nothing has changed in the page, according to WordPress' own "diff". In fact, updating a page without modifying it doesn't even create a revision.

Note that once I've done this "fake update" on a page, if I use the REST API to update it with more code snippets, Crayon now sees them too, and highlights them. It's like the page is "fixed" forever.

It gets freakier. If I disable Crayon and re-enable it, any page where it didn't highlight the code snippets will now be highlighted correctly.

I'm a C# programmer, I know nothing about WordPress plug-in programming, so I have no idea what it is I'm seeing and how to address it. Basically, I want to know what I need to do from my end (C# posting REST API commands to a site) to ensure that <pre> tags will be highlighted by Crayon from the get-go, without requiring human intervention.

Can you help me ?

Regards,

Jean Roch

@Nefastor
Copy link
Author

It's me again. I've looked around and found this:

aramk.com/blog/2012/09/26/internal-post-management-crayon/

Clearly, that's the cause of my problem.

Is there a way to force Crayon to update its list of posts programmatically ? I'm looking for an HTTP request I could send to my site. I've tried manually navigating to https:///wp-admin/options.php, which is what the Refresh button appears to be doing, but that doesn't have the desired effect.

@mipon
Copy link

mipon commented Nov 10, 2018

I posted a fix here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants