Thread Starter
Joe
(@joecole1)
The issue is (likely, I think!) on line 513 of the post_types.php plugin. The preg match all regex query matches [gallery order="asc" ids="123,124,etc"] but not if the other options are at the end of the gallery shortcode.
To fix this, it’s simply to add another “.*” to the end like so:
preg_match_all( '/\[gallery.*ids="([0-9,]*)".*\]/', $content, $results );
See here for a test of this: http://regexr.com/3eq5n
Next, in order to find the ids, you are looking for $results[1][0], which will ONLY match if ids is in the first position of the gallery shortcode. I won’t lie, I’m not sure how to solve this one, as it goes a bit beyond my capabilities, but if the pre_match_all is changed as I showed above, at least I could put my settings after the IDs and it would work as I intend.
-
This reply was modified 7 years, 4 months ago by Joe.
Thread Starter
Joe
(@joecole1)
Unfortunately I made the changes as I mentioned in the above comment and it seems to still not be working. I’m not certain why not. But I still believe that is where the problem lies.
As far as finding the IDs part of the array, instead of simply designating which array index to use, perhaps you could use http://php.net/manual/en/function.array-search.php ?
-
This reply was modified 7 years, 4 months ago by Joe.
Hi,
If you get this message in the error log, it really means that the gallery couldn’t be found by the plugin. What is exactly the shortcode currently if you look at the raw HTML code of your post? Is it exactly like what you used in http://regexr.com/3eq5n? I am pretty sure there might be a slight difference, maybe a space or something else. Then we can improve this regexp.
However, to look for the ID in the gallery, I am already using array_search (line 520).
Thread Starter
Joe
(@joecole1)
Sorry, I definitely should have posted the actual shortcode I’m using. My bad.
Here’s an example. WordPress processes it correctly, applying the sort and showing all the photos. It’s just that WP/LR can’t sync to a page with shortcode like this.
[gallery ids="375,377,379,381,383,385,387" orderby="post_date" order="ASC"]
From my understanding, you’re using array_search to find the current ids in variable $ids and either remove or leave alone. However, to set the $ids array it just assumes that the $str = $results[1][0]; is “ids”, not “orderby” or “order” or any other options right? Anyway, just trying to help with the debugging. Sorry if I’m way off, I definitely don’t fully understand what you’re doing here.
After looking at it a bit further, to find “ids” in gallery, you are only using the $str = $results[1][0]; which just assumes it’s the first thing in the gallery shortcode, not actually searching for it in the gallery array of options.
Ah, but the preg_match should only match those ids, not anything else. Hmm… ok, no idea why it wouldn’t return anything into $results.
I’ll try resetting with extensions and then starting from scratch. It’s just a pain!
-
This reply was modified 7 years, 4 months ago by Joe.
-
This reply was modified 7 years, 4 months ago by Joe.
-
This reply was modified 7 years, 4 months ago by Joe.
Thread Starter
Joe
(@joecole1)
I reset, then resynced it. It creates all the folders, galleries, and pages just fine. As soon as I add the orderby and order options, it is no longer able to sync or add new photos and returns that error.
Thread Starter
Joe
(@joecole1)
Ok, interesting new development. After re-syncing, without changing anything, I attempted to re-sync with extensions again, and got the same error!
So my theory about the shortcode being the issue must not be true. I’m completely at a loss now.
Thread Starter
Joe
(@joecole1)
Hey Jordy, what specifically does your plugin do when attempting to create a collection? That seems to be where the plugin is failing. Does it write any files to the server? I’m wondering if it’s a permission issue that is just showing itself as this error.
I uninstalled/reinstalled everything and am still getting the same errors if I try to re-sync. Doesn’t seem to be related to the shortcode, as it’s failing on pages where I haven’t changed anything.
Other things I have done would be changing the name of the title (that shouldn’t matter) and changing the parent page (again, shouldn’t matter as it’s all based on the post!)
So it’s really leading me to believe there is a permissions issue and I’m just missing something your plugin is trying to do and is not being allowed to do.
Thanks,
Joe
Thread Starter
Joe
(@joecole1)
Jordy, I’ve emailed you so we can attempt to figure this out without junking up the forums.
Okay, sure. When you write so many messages it’s good to delete the previous ones (if you can) and/or try to write a unique/concise message as the final one. I have a lot of support to do everyday and to get so many messages is really difficult to follow 🙂 That would help me in getting aboard faster and help you.
Thread Starter
Joe
(@joecole1)
Closing this as resolved since we finally determined the root cause to be the Real Media Library plugin. Unfortunately no resolution on the issue.