omii
Forum Replies Created
-
Forum: Hacks
In reply to: WP MultiSite – Allow a SUBsite custom 301 URL redirects, any plugins?Thanks and I agree with the same amount of murphy’s law attention. Clients is the wrong term, users would be better, and they’re all developers.
I have a lot to read up on regarding anything like .htaccess. I did see comment-esque delimiters and had hoped there was a conventional way to add markup around areas of code so changes could be made in a controlled area. Thanks for confirming that so it doesn’t seem entirely impossible.
Then again consider the situation where the system has 50,000 redirects. It’s a ridiculous situation but I always need to think of the extremes. Is .htaccess, or anything really going to handle request well at that point.
Redirection was so nice, played well with apache/nginx/etc, allowed WP Core or .htaccess redirects, groups redirects into easy bundles, has a 404 manager, etc. It’s everything that’s needed, minus a coder that’s considering wp_* is not the only site..
If anyone else has a plugin they know handles this already please shout it out!
Forum: Hacks
In reply to: WP MultiSite – Allow a SUBsite custom 301 URL redirects, any plugins?Just noting, I added a faux shortcode-esque way for them to add a redirect in a pages content “for now”. The load on the server is manageable. Right now they just create a new page, customize the page URL and set the content as:
[redirect url=”https://…”%5D
I am hooking to pre_get_posts and look at the query->queried_object->post_content (if it exists) to see if that string is in there and if so use a regexp to pull out the URL to header(‘Location: …’); via HTTP/1.1 301 Moved Permanently. It works, for now.
This is terribly inefficient. At least only WP loads and not the gobs of theme libraries as this hook fires before that but there has to be some better/deeper way to do this at the server level (apache .htaccess, etc).
I’m not terribly confident I can make a plugin to that extent because there’s a multitude of customizations inside those .htaccess files by admins and other plugins.
Are there any plugins that are masters of the apache/nginx/etc configs or WP Core that have a better suggestion for letting clients easily set up custom URLs with redirects? Redirection was nice because it put all the redirects right in a single place rather than making a new page just for a redirect. There must be, and always is, a better way ??
Thanks for any tips!
Forum: Hacks
In reply to: Plugin Shortcode in wordpress 4.5 not WorkingTry this:
function example_shortcode() { return 'Is this shortcode working?'; // return the content } add_shortcode( 'examplesc', 'example_shortcode' );
Simple difference is returning the string. Just place in [examplesc] in any post/page.
I use a ton of custom shortcodes and I updated to 4.5. It’s working just fine.
Forum: Hacks
In reply to: Nav Walker, why do you hate me? (I'm missing something here)I totally agree with starting at 0. However where the next depth starts should be extremely clean and clear to me. In that case, it’s the next container of nav.
For example in a typical nested unordered list, this makes sense to me:
<ul depth=0> <li> <ul depth=1> <li> <ul depth=2> .. </ul> </li> </ul> </li> </ul>
But how it is right now, this happens:
<ul depth=0> <li> <ul> <li depth=1> <ul> <li depth=2></li> </ul> </li> </ul> </li> </ul>
To the navigation elements themselves which are in the < li > list items the depth will work fine but from any other angle I look at this it’s just invalid markup.
The depth doesn’t need to be reduced for the rest of the original < ul >s content on the main menu because the $depth+1 is being passed as an argument to the function, never actually affecting the functions current $depth.
I can create navs all day and this prints reliably, such as:
Main 1 Sub 1 Sub 2 Main 2 Main 3 Sub 1 Main 4 Sub 1 Sub 2 Sub 3 Sub 4 Sub 3
And that is exactly how it prints out when I print $indent+$depth:
0 1 2 0 0 1 2 3 4 3
I can’t see how this is more desirable which is what I get if I don’t use $depth+1:
0 0 1 0 0 0 1 2 3 2
Perhaps there’s just still something internal I don’t understand about that being desirable but nonetheless this is working perfectly for me. Thank you again!
Forum: Hacks
In reply to: Nav Walker, why do you hate me? (I'm missing something here)Thanks very much for pointing that out. I’m not even sure if they intend this or if messing with any of this code is going to desync anything internally (I thought perhaps classes), but it doesn’t appear to.
I’m now overriding display_element grabbed from class-wp-walker.php and just added $depth+1 on line 156, which was:
$cb_args = array_merge( array(&$output, $depth), $args);
But is now:
$cb_args = array_merge( array( &$output, $depth + 1 ), $args);
I’d love to know their reasoning on why the depth should start at 0 and I’ve run through my many-tier menus and they all work just fine with this change. The code clearly states “$newlevel = true;”, so why wouldn’t you consider adding a depth? Most importantly it doesn’t feel hacky, no classes changed and the way I wanted to do it now works perfectly fine with:
if ( $depth > 0 ) { return; }
Thanks a bunch for pointing me to those lines bcworkz!
Again I’m not sure if there is a context in which doing this is going to break the menu system output, but so far it’s working perfectly fine. If anyone thinks this is a bad practice please let me know as well as a better way to do it!
Forum: Hacks
In reply to: Nav Walker, why do you hate me? (I'm missing something here)Hi,
They’re a very approachable subject although some people can get lost in recursive functions. They’re hard to debug.
This isn’t my first nav walker extend. I made it conform to Bootstrap previously and had no such issues.
I am practically doing the same exact thing as the “advanced” walker. If ( 0 != $depth ) return; is the inverse of the tutorials if ($depth == 0) return; because we want inverse things. I want only main nav items, they want only nav items under the current nav.
The bit unorthodox 0 != $depth instead of $depth > 0 is just a JavaScript habit for other reasons but the statement doesn’t work any way I lay it out anyhow.
I even put an extra debug line in start/end_lvl() where the offending <ul class=”sub-menu”> and are being invalidly created. I put it right under the $depth check, and it prints out! This is one of these “but that’s just not possible” times. e.g.:
function start_lvl(...){ if ($depth > 0) { return; } print "<!-- debug, huh how am I here? -->"; print "<ul class=\"sub-nav222222\" ..."; }
If the $depth is above 0 there is no freaking way that should print. start_el and end_el do not print, they respect the return. However, both the comment is printed (ONLY around the main nav, not this offending sub-nav), and I verified the class was sub-nav222222 just to make sure this
< ul > wasn’t being printed from something I’m inheriting. Nope, the class was sub-nav222222 so I know that function is printing it.This makes no sense! I’m sure there’s a reason but if anyone knows how this possible, please save my sanity!
Otherwise the only thing I see from here is needing to make the walker class specifically to get secondary nav items from the current selection and set the depth => 1 in arguments on the main menu, essentially making me walk nav twice. I should be able to get the main nav and the subnav of the selected item in a single walk. That or I’m going to need to set .sub-nav{display:none;} which is equally impure.
Forum: Hacks
In reply to: What's the latest on (session like) saving data between page loads?Ahhh, I read that entirely wrong! I read in the doc that the “site_” functions work the same on multisite except it’s network wide.
So set_transient() is per-site and set_site_transient() is per-network.
Thank you a million, this looks perfect!
Forum: Hacks
In reply to: What's the latest on (session like) saving data between page loads?Darn! This is exactly what I need, minus one thing. I use MultiSite on my setup.
That isn’t to say I can’t simply give each site a unique transient slug, but just knowing every site will start littering multiple transient slugs in a large pool, especially memcached, the performance or encapsulation feels a bit breaching.
Thanks for alerting me of transients however! I can think of a lot of uses for these.
Forum: Hacks
In reply to: Best practice – Integrate data from remote site (API)We’re like-minded on the shortcodes approach because while I hesitate to give them control over a page in a way they could easily make mistakes, the flexibility is just a bit more important.
The display of the events (title, location, date, etc) and speakers (name, title, credits, bio, etc) are all the same regardless which page they’re displayed on. So although there’s several pages that list events and the events are different, it’s just re-using the same code to display it from the filter. Modular and testable.
I agree that with WP itself needing to initialize itself, then adding the remote API call, this could stall out and get into a “no data received folks, sorry” situation. Luckily it’s all built on Amazon cloud services which appear to be lightning quick so far.
Caching is a tricky subject. Event admins of course want to see their changes instantly on the site but you’re right, with systems like Amazon you do pay for what you use. I’ll be utilizing localStorage as much as I can, with a fairly quick expire (5min or so).
It’s nice to see that the approach we’re taking here is pretty similar so it gives me some extra confidence that this is the right way to go. WP content authoring ease with custom data where it belongs.
Thanks for all your responses!
Forum: Hacks
In reply to: Best practice – Integrate data from remote site (API)The site is fairly simple, just as explained. The events are live speakers talking to audiences in a convention context.
Multi-Site WordPress seems pretty ideal for this. Deployment is as easy as adding a new site to the network admin, customize a child theme to match the conference and use the same plugin to list speakers and events. I’ll just need to make sure I make it a multisite friendly plugin so the API each site in the multisite accesses different data.
The data coming from the API will be managed by a custom admin the conference admins can manage.
Pretty straight forward and a bit like reinventing the wheel but I’m just hoping to merge the API data with basic WordPress ease.
Forum: Hacks
In reply to: Best practice – Integrate data from remote site (API)Thanks very much for your input.
Do you feel this is working for you? Any areas you have noticed is difficult from this implementation?
If you had to do this again would you do it the same way?