[Solved] Most efficient way to get custom database records from 20 buttons and 20 tables?

I suppose the easiest way would be to have the action or other parameters in the button itself, i.e. <div class=”mybutton” data-action=”get_quote” data-type=”literary”>Get a literary quote</div> <div class=”mybutton” data-action=”get_quote” data-type=”political”>Get a political quote</div> data-foo=”bar” attributes can easily be accessed in jQuery with .data(“foo”), so you could change the jQuery around a bit to listen to … Read more

[Solved] WordPress Super Admin

I would recommend creating a Custom User Role, using the add_role() function, such as a “Site Admin” or “Sub-Admin” (or whatever you want to call it). Then, you can assign specific user capabilities to that custom role, thereby giving users exactly the capabilities you want them to have, without giving them the capabilities you don’t … Read more

[Solved] Shortcode outputs at the top of the_content

All functions have to return a string, you should not use echo anywhere. Rewrite the functions, use an internal variable to handle the strings and return that: // Output a single menu item function projects_menu_entry($id, $title, $link_self) { global $blog_id; $out=””; if ($link_self || $id != $blog_id) { $out .= ‘<li>’; if ($id == $blog_id) … Read more

[Solved] Modifying WordPress core files

If you must hack core, consider doing so in a way that makes it extensible for others. Add an Action Hook Nine times out of ten, you could do what it is you wanted if only there was an extra do_action call in a specific file. In that case, add the action, document it, and … Read more

[Solved] Create more Meta Boxes as needed

So you mean something like this? and when you click on Add tracks it becomes this: if it is what you mean the its done by creating a metabox that has simple jquery function to add and remove fields in it, and the data is saved as an array in of data in a single … Read more

[Solved] Clarification on filters and hooks

I am confused because add_filter uses the word add when I feel like it is more on the lines of replace or overwrite (unless I am misunderstanding) You are misunderstanding. Both add_action and add_filter insert function callbacks into a kind of queue. You can add many callbacks to the same hook and they will fire … Read more

[Solved] How to Protect Uploads, if User is not Logged In?

Only checking if the cookie exists, is not much of a strict protection. To get a stronger protection, you can pass or “proxy” all requests to the uploaded folder (exemplary uploads in the following example) through a php script: RewriteCond %{REQUEST_FILENAME} -s RewriteRule ^wp-content/uploads/(.*)$ dl-file.php?file=$1 [QSA,L] All requests to uploaded files (which includes images in … Read more

[Solved] Between functions.php (theme), widgets, and plugins, which is loaded first?

The plugins are loaded right before theme (yes, I’ve been looking for excuse to use this): However it is wrong to think about either as point of code execution. For most cases everything should be hooked and executed no earlier than init hook. According to Codex widget registration with register_widget() should be hooked to widget_init. … Read more

[Solved] Where is the right place to register/enqueue scripts & styles

Why registering and queuing properly matters it should be in time – earlier than script/style is up for being output to page, otherwise it is too late; it should be conditional – otherwise you are loading stuff where you don’t need it and cause performance and functionality issues, for this you need WP environment loaded … Read more

[Solved] Is there a flowchart for WordPress loading sequence?

There is this rather in-depth explanation found at, Part 1 http://theme.fm/2011/09/wordpress-internals-how-wordpress-boots-up-2315/ Part 2 http://theme.fm/2011/09/wordpress-internals-how-wordpress-boots-up-part-2-2437/ Which also includes some diagrams/flowcharts. and… This is also just the start of understanding the WordPress initialization process to which also should include information about the template hierarchy, as well as inspecting which hooks are fired on which pages and when. … Read more

[Solved] Uninstall, Activate, Deactivate a plugin: typical features & how-to

There are three different hooks. They trigger in the following cases: Uninstall Deactivation Activation How-to trigger functions safely during the scenarios The following shows the right ways to safely hook callback functions that get triggered during the mentioned actions. As you could use this code in a plugin that uses plain functions, a class or … Read more

[Solved] What’s the preferred method of writing AJAX-enabled plugins?

the “safer and cleaner” way would be to use admin-ajax.php that comes with wordpress and wp_ajax hook to call your processing function from your plugin file and use wp-nonce to check the integrity of the call. for example: your ajax JQuery call would be <script type=”text/javascript” > jQuery(document).ready(function($) { var data = { action: ‘ACTION_NAME’, … Read more

[Solved] Allow HTML in excerpt

COMPLETE GUIDE TO EXCERPTS I’ve recently answered a few questions regarding excerpts, so I’m going to give a detailed explanation covering as much as I can. PREFACE There seems to be a couple of questions arising from this answer on where the code should go, and the answer is, it is really up to you … Read more