Timeline for Conditionally Loading JavaScript/CSS for Shortcodes
Current License: CC BY-SA 3.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
S Nov 26, 2011 at 3:31 | history | suggested | CommunityBot | CC BY-SA 3.0 |
how about removing the end "]" ..? so it can check with and without args...
|
Nov 26, 2011 at 2:45 | review | Suggested edits | |||
S Nov 26, 2011 at 3:31 | |||||
Jun 23, 2011 at 18:44 | comment | added | Ian Dunn | Ah, you're talking about the default templates (e.g., single.php, home.php) as opposed to a custom template build specifically for a page (e.g., map.php), right? That's a good point. I'll bet there is a way to figure out which one is being used, but I don't know it off the top of my head. | |
Jun 23, 2011 at 18:20 | comment | added | onetrickpony | your confusing page (as in the page post-type) templates with theme files used a templates | |
Jun 23, 2011 at 18:06 | comment | added | Ian Dunn | The assigned template is just stored in the post_meta table, what's so hard about finding it out? You can hook into the_posts to get access to the current $post before anything is output. By 'PHP parser' I assumed you meant the entire engine, not just a strpos or regex function. Commented lines are an edge case that I'm not really worried about. | |
Jun 23, 2011 at 16:59 | comment | added | onetrickpony | Assuming that you could find out which template file is being used by the current page (which I doubt), how would you parse it without a parser? regexes? What if the line with the code is commented? There are dozones of ways to comment PHP code | |
Jun 23, 2011 at 16:38 | comment | added | Ian Dunn | I always want valid markup, no matter what the circumstance... The plugin doesn't tell the user to call the function, but it's always an option. A user can always call any shortcode by either typing it into a post/page content area, or just calling do_shortcode() in a template, so both situations have to be handled. And I don't think I need to write my own PHP parser, I just need to parse the template file assigned to the current page (if there is one) to see if the shortcode is inside it. | |
Jun 23, 2011 at 16:12 | comment | added | onetrickpony | ok, so this is why you want valid markup :) You're saying that your plugin instructs the user to edit template files and call that function? Then unless you create your own PHP parser, there's no way you can know where and when that function is being called... | |
Jun 23, 2011 at 16:06 | comment | added | Ian Dunn | I'm not the one calling the shortcode, the user is. This is for a distributed plugin, not a private one. | |
Jun 23, 2011 at 15:50 | comment | added | onetrickpony |
Why it would need to do that? If you call do_shortcode() manually in the template then you already know you will be running the shortcode
|
|
Jun 23, 2011 at 15:45 | comment | added | Ian Dunn | That's basically the same as method 2, but it still doesn't check the template for do_shortcode() calls. | |
Jun 23, 2011 at 15:39 | comment | added | EAMann | Like I said, "potential" answer that I haven't tested yet ... :-) | |
Jun 23, 2011 at 15:39 | comment | added | onetrickpony |
This wont't work if the shortcode has arguments. If you really want to go this way, which is slow, use WP's get_shortcode_regex() for searching.
|
|
Jun 23, 2011 at 15:34 | history | answered | EAMann | CC BY-SA 3.0 |