How do i validate data entered in a meta box so that only floats can be entered in a field?

Not shure if this isn´t a general php question… Use the WP_Error Class. // http://php.net/manual/de/function.is-float.php // http://php.net/manual/de/function.is-int.php // inside your save_post/update_post hooks callback function, // just type cast to float. You could also do a check if it contains non numeric chars // and then simply return; $check = ! is_float( $value ) OR ! … Read more

Is there any way to allow a plugin to write over a previous version?

If you’re manually installing a plugin, you need to disable and delete the old version. However, WordPress does allow you to update your plugin programatically. If your plugin is hosted on the WordPress.org repository, it will prompt the users to install updates for you. You’ve likely seen this with Akismet and other plugins already. If … Read more

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

Now I’ve found a solution [to issue 2 above]: I prefixed the external PHP command with: XDEBUG_CONFIG=”remote_enable=Off” and then it didn’t attempt to connect to the debugger. So, in wordpress-tests/init.php I changed from: system( WP_PHP_BINARY . ‘ ‘ . escapeshellarg( dirname( __FILE__ ) . ‘/bin/install.php’ ) . ‘ ‘ . escapeshellarg( $config_file_path ) ); to: … Read more

Which themes do you use to test compatibilities with your plugin [closed]

Themes, anyone? I don’t test »against« or »with« themes. Just with some other plugins that might conflict (but I normally leave that open until something happens – you’ll never figure out all edge cases). At least, you’re intercepting/extending/altering stuff via filters. So why test against themes, when you’re modifying core functions? If you’re intercepting the_content … Read more

Resizing Images for a Gallery-Plugin?

Its best practice to always use internal WordPress API functions that already exist in place of external scripts. You would need to regenerate the thumbnails yourself, which is not overly difficult, if for instance you give yourself a head start and study the source code of existing and similar solutions; Regenerate Thumbnails Plugin http://wordpress.org/extend/plugins/regenerate-thumbnails/ browse … Read more

Avoiding Duplicate function names in Post Loop (WP_Footer script)

I would wrap the whole thing in a class and put your data into a class var. class WPA69616_Plugin { private $data=””; public function __construct() { add_shortcode(‘my_shortcode’, array($this, ‘add_content’)); add_action(‘wp_footer’, array($this, ‘output_content’)); } public function add_content($atts) { extract( shortcode_atts( array( ‘content’ => ” ), $atts ) ); $this->data .= $content; } public function output_content() { … Read more