Articles of plugin development

How to change post status in hook?

I have similar problem as described in How to trap "Publish" button to check for meta box validation? Answer there is to hook into save_post and change post type. How can I do it? I try to use wp_transition_post_status but it doesn’t work for me… function myHook( $post_ID, $post ) { wp_transition_post_status(‘pending’, $post->post_status, $post ); […]

How to store an extra (surrogate) ID when creating a post with wp_insert_post?

I am generating posts based on rows from a table on an existing database. If a row in the database gets updated I will have to update the respective post. The proble is that I have to find the post to be able to update it, and I don’t have any suitable key for that… […]

“You do not have sufficient permissions to access this page” upon accessing my newly created plugin page

I am following “Write your own plugin tutorial” and I made it, activated it, added it to settings to have it’s own plugin page but upon trying to access that plugin page I get above message saying that “I do not have sufficient permissions to access this page” even though I am logged in as […]

How to debug a unit test for a WordPress plugin, which uses wordpress-test?

I’m attempting to debug a unit test for a WordPress plugin. The unit test uses wordpress-test (and PHPUnit). However, wordpress-test: calls system(php …) the new external PHP process attempts to connect to the same debugger, but the debugger is already busy so both PHP processes hang. — How can I prevent this? Details / clarifications: […]

Can't echo get_delete_post_link

I am using custom post_type and inside the loop I echo get_delete_post_link but there is nothing echoing. <?php $wpquery = new WP_Query(‘post_type=myposts’); if( $wpquery->have_posts() ) { while ($wpquery->have_posts()) : $wpquery->the_post(); $id = get_the_ID(); //just a test to see can I get post IDs and I get them echo $id; ?> <a href=”<?php echo get_delete_post_link($id); ?>”>Delete</a> […]

Including file or library from other plugin

I’m creating a plugin I would like to use from other different plugins. This plugin declares classes and functions. So, I am thinking about the best way to include, from one plugin, a php file present in another plugin. I think this should work: require_once WP_PLUGIN_DIR . “/the-other-plugin/required-file.php”; But I am not sure; is it […]

Default Plugin Settings Not Writing to Database

I have my plugin setup as such: Main plugin file mouldings.php <?php /* Plugin Name: Moulding Profiles Plugin URI: Description: Creates a ‘Moulding Profiles’ and ‘Idea Gallery’ custom post type, creates a ‘Wood Types’ and ‘Categories’ taxonomy for ‘Moulding Profiles’ Version: 0.1 Author: Author URI: License: GPL2 */ // Global Variables $mouldings_prefix = ‘mouldings_’; $mouldings_name […]

what is the best practice for including 'wp-includes' classes

I have a class ‘wp_php_flickr’ which will use the wordpress core class ‘WP_HTTP’ in a plugin which i’m writing if( !class_exists( ‘WP_Http’ ) ) { require_once( WP_INSTALL_DIR.’\wp-includes\class-http.php’); } class wp_php_flickr { … } As i’m testing i’m noticing that i am required to include more and more core classes, which the WP_HTTP class is dependent […]

On Plugin Activation, How Do I Check for Proper Transport Mechanism?

For a plugin that communicates with somewhere else, I hear we’re supposed to use wp_remote_post and wp_remote_get instead of PHP’s Curl library. Okay, but is there a fast and proper way on plugin execution to test for a blog’s PHP/host OS to have the proper transport mechanism installed? I mean, I could attempt a test […]

Resizing Images for a Gallery-Plugin?

I’m currently working on a gallery plugin similar to the one found on Posterous. I’m needing all images in the gallery in a very small thumbnail-size. Probably only 50px wide. What’s the best practice to implement the image resizing? 1.) Adding the Image size via add_image_size()? This method has the obvious disadvantage, that all previously […]