Articles of plugin development

How to load a new template page according to a particular URL?

I want to load some of the pages(not wordpress page, a template file other than wordpress’s default template file) according to the url came on the address bar. for instance, I have page in my template file ie my_account.php to show my profile pic and other informations from to my wordpress pofile. and it is […]

Change template dynamically

Is it possible to change the template loaded for a page, as it loads, without having to change the record in the database? I suspect it can be done with the template_redirect action, and the will probably have something to do with the template-loader.php file in the WP core, but I can’t figure it out. […]

How to deal with equal & similar arguments for a function?

I’m currently extending my pagination plugin, after a hint by @toscho. So the plugin will now use the same filters, hooks and arguments as the native wordpress pagination functions. My problem is that the different wp functions name their arguments … different. Example: This is how you change the text for the “Next” link. wp_link_page() […]

How to check if certain plugin exists and in expected version

I’ve created plugin that goes to wordpress plugin repositories. Now, I need to create another plugin (sub plugin or child plugin you may call) that require this certain plugin to be already installed and activated. I know I can use register_activation_hook. However, how do I check using that hook? Or, maybe there’s another solution exists?

What could cause my plugin's options/settings page not to load?

I’m having an issue with one site in which my plugin is installed. The “settings” page will not load. When I click on “settings”, it loads the settings page but the page is blank after the “Upgrade to 3.1” nag div as if there was a die() there. I have two files, plugin.php and plugin-admin.php […]

add a class when login

i add this code in index.php. <div class=”Div1″></div>. then write some css(absolution position) to the Div1. so when i login in my wordpress. the admin nav will push down some spaces to the site body. so the conetent shows unnormal. now, i want to add a class to <div class=”Div1″> when logins. is there a […]

Finding posts containing matching array elements in a meta field usign WP_Query

I have a metafield, that contains a series of options and writes the results to an array in a single meta field: array([0]=>’First’, [1]=>’Second’, [2]=>’Third’, ); I find posts that contain any of the array elements, and display them using WP_Query $search = new WP_Query(‘meta_key=mykey&meta_value=second’); But this doesn’t seem to work. Any idea on how […]

What parameter should I pass to wp_enqueue_style to depend on the themes stylesheet?

I have written a basic gallery plugin that uses wp_enqueue_style to include a stylesheet on the page. I’d like for the WordPress theme to be able to override the style of the plugin which means I’d like to my plugin to play nice and output the css file before the theme css file. wp_enqueue_style has […]

Plugin Upgrade Strategy

Reading register_activation_hook() told me that in wordpress 3.1, this will only work for every plugin activation, not plugin upgrade. What I want to know is, what’s the best plugin upgrade strategy? My though is: on action ‘admin_init’ check for ‘{plugin_name}_version’ option if ‘{plugin_name}_version’ doesn’t exist, let’s assume it’s from previous version (because at that version, […]

Auto-Update Plugin Creating .tmp directory, not overwriting old version

I’m using this library to auto-update my plugin, but it’s only extracting the new plugin files into a .tmp directory, while the old plugin files stay where they are. Can anybody help me fix this to overwrite the old files or any ideas as to why it would be doing that? Edit: I know that […]