I am using http://wordpress.org/extend/plugins/pdf24-post-to-pdf/ pdf generator plugin for my site, but I only want it present on certain pages.
How can I remove it from all pages except a certain template I allow?
I believe this can be done with filters, but I have googled and googled and can't seem to get anywhere.
I don't think that's possible without modifying the plugin source code. That would be a nice security issue, IMO.
Plugins are files simply included on the loading process. At least, there's no hook I could find on WordPress source code for you to interfere in this behavior. Take a look just above the plugins_loaded hook, and the wp_get_active_and_valid_plugins function.
What you can try to do, instead, is just modifying the plugin with the condition you need. In the top of the pdf24.php file, just below the standard comments, put:
if (!condition_met())
return;
Related
I'm looking at a site someone else developed. We're using a child theme that is calling back to a lot of its parent's functions. There are about two dozen plugins. Somewhere in there is a bug that's preventing a theme setting from propagating to the rendered page. The problem is, I am not sure what's involved.
I've tried enabling wp_debug, but the page is fairly silent. I've inserted HTML comments into functions and templates that I thought would be involved, but I haven't found one that is actually involved.
Is there a plugin or some way to force WordPress to log every file/function that's loaded for a page? How would you approach this scenario?
This is probably not the best answer, but I've dealt with a lot of similar situations on some of my customers who own WordPress websites.
I usually download the database and website locally and setup a local website using LocalWP, but you can use any web server like XAMPP or WAMP, actually. In the end, this is helpful, because I can quickly find apply functions of my hooks by doing a full-text search on the project.
To track down the error, I echo some logging with a helper function which will also print hook information.
If the code of your child theme is reached, this is a good start. If your website renders with the parent theme, you can focus on the hooks and calls in your child theme and hopefully you will find the error.
You really have to bite the bullet and follow the chain. If your parent theme renders anything you should be able to comment your child theme step by step to pinpoint the cause of the problem.
I have a strange question but I don't find any hint about that (if it's possible), for a drupal 7 website I have to modify some content of a page in the backoffice, but I really don't know from where some content of this page is created (a table, similar to a view table but not a view table).
I just want to know if there is any way to show which php function the page use to finally be showed. I know there is something like that for the theme (drupal theme debug) but I don't find something for my case.
Any idea ?
You need PHP profiler to check all functions called on page, there's a module for Drupal7 for XHProf integration. But I would suggest you to use your browsers inspector as mentioned by 2pha before. For example if there's a form on the page just use the form ID to find it. Custom classes are very useful in these cases, parts of the html codes etc. In your case search for table headers...
The code you are looking for is most probably in custom modules and the
general suggestion is to keep you custom modules in separated folder from contributed ones.
I am trying to build a search form that looks a bit different from the default WP search box. I can edit the searchform.php for that, but I want it to be in form of a plugin, so that I can easily enable it and disable it at will. But the problem is that if WP finds searchform.php, it will use the form in that file, so no tricks like add_filter, add_action will work here. So, what I want to ask from folks here is: does there wxist some way by which I can achieve the above. i.e override the code of searchform.php
Also on a different note, if I name the search box to anything other than "s", then the code goes to index.php, instead of search.php. This, I have verified by putting debug echo's and other wierd statements.
What could be the possible reason for this?
Thanks in advance for your help.
Okay, I found a hack. Not very good though, but works for me. So what I did is, in the activation filter of my plugin, I wrote the code to rename the original searchform.php (the one residing in the current theme folder) to searchform_orig.php This way WP does not find searchform.php and so renders the searchform which I have hooked to the filter. Similarly, on deactivation part, I rename the file back to searchform.php. May not be ideal , but is working on y systems that I have tested. Though I would be interested in knowing loopholes/caveats in this approach. Marking it as an answer ;-)
In the WordPress documentation page for the function wp_enqueue_script, it is clearly written:
Note: This function will not work if it is called from a wp_head action, as the tags are output before wp_head runs. Instead, call wp_enqueue_script from an init action function (to load it in all pages), template_redirect (to load it in public pages only), or admin_print_scripts (for admin pages only). Do not use wp_print_scripts (see here for an explanation).
Do not use wp_print_scripts action is what I want to highlight, but do a simple google search on "How to include Javscript in WordPress". You will find most of examples are using wp_print_scripts action to call wp_enqueue_script. And it seems like everyone is ok with it.
So am I missing or misunderstanding something here?
EDIT
The codex has been modified. It now says:
This function will not work if it is called from a wp_head or wp_print_scripts actions, as the files need to be enqueued before those actions are run. See the Usage section for the correct hooks to use.
Yeah, I been there lots of times. The short answer is all those guys that print script requests are all wrong or as some folks suggest it is faster not to use wp_enqueue_script but to load everything dynamically with Modernizr.load (yesnope.js) or any other js loader lib.
My recommendation would be to stick with wp_enqueue_script as the best practice, but if you are developing themes for mobile, or you are extremely worried about speed and not bloating your browser with requests, I really recommend to load everything dynamically with a single js file (that you may call with wp_enqueue_script). Even consider inlining everything out and not loading jQuery but zepto.js or so.
Many developers do this terrible practice of loading everything printed, not only bad taste, but terrible for experienced theme developers I might say :S
For example thematic and several other blank themes rely on this practices and this truncates development speed with childthemes.
If you are not sure about wp_enqueue_script just give the wordpress codex a read. It is thoroughly documented.
Regards,
I'm looking for a commenting system with a specific feature, and I wondered if anyone could advise.
I want to be able to load different comment threads without reloading the entire page, via JavaScript callbacks. That means I need a commenting system that allows multiple comment threads to be associated with the same URL, with threads defined by custom IDs.
I've just found out this isn't possible with Disqus. Although Disqus does allow you to associate a unique ID of your choice with a thread, it also requires a unique URL for each comment thread.
Does anyone know a system that does offer the ability to associate multiple comment threads with the same URL, via unique IDs?
Not sure if it's possible with either IntenseDebate or Wordpress - or maybe I need to write a custom Wordpress plugin (the page itself will actually be within a Wordpress install).
You should have no problems creating you own custom comment page by 'hacking' comments.php.
By using jQuery and jQuery.load you can call a php page where you have code to retrieve custom comments.
But messing about comments.php is not that easy. Therefore this page might help you get an insight in comments.php
This answer doesn't solve you problem, but hopefully it'll give you some ideas.