Articles of plugin development

jquery document ready function not being called

For some reason I can’t get the jquery document ready to fire for my plugin my javascript jquery(document).ready(function($) { alert(“hello world”); $(“#testdiv”).text(“hi”); }); the source from my website <link rel=’stylesheet’ id=’admin-bar-css’ href=’′ type=’text/css’ media=’all’ /> <script type=’text/javascript’ src=’′></script> <script type=’text/javascript’> /* <![CDATA[ */ var fantasy_golf = {“ajaxurl”:”http:\/\/\/wp-admin\/admin-ajax.php”}; /* ]]> */ </script> <script type=’text/javascript’ src=’′></script> <script […]

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

We have a custom post type in our plugin and now i must provide the user a meta box where he enters latitude and longitude. I want them to be floats, i have no problems in doing the validation client side, but i don’t know how i should handle server side validation in wordpress. I […]

How to access function from outside of a class within this class in WP plugin?

I am developing a WP plugin called e.g. DD_Awesome_Plugin and this is my code so far (simplified version without additional code logic within class functions): class DD_Awesome_PLugin { public function __construct() { } public function add_menu_page() { add_options_page(‘DD Awesome PLugin’, ‘DD Awesome PLugin’, ‘administrator’, __FILE__, array(‘DD_Awesome_PLugin’, ‘display_options_page’)); } public function display_options_page() { $plugin_options = get_option(‘dd_my_awesome_plugin’); […]

Row actions not showing? Why?

I have constructed a WP_List_Table that displays on a custom theme page that I have built. I am having some trouble getting the row actions to display, despite me reviewing all the possible info on the Internet about WP_List_Table. Any help would be great! class Testimonials_List_Table extends WP_List_Table { function __construct() { parent::__construct( array( ‘singular’=> […]

Remove Internal Style Sheet if no Value Provided?

I am using this code to add my options inside head section code works but my problem is that if no values are provided my function still echoes an empty <style type=”text/css”><style> into my head. How can I remove style tags if no values are returned? Thank You!! //Hook into WP head and add our […]

Frontend Ajax call not working using wp_ajax, wp_enqueue_script and wp_localize_script

I think i’ve almost got my head around this ajax is WordPress business, thoroughly ejoying learning it but i’m now totally stumped. First up is the nasty bits! I have these in my main plugin file: wp_enqueue_script( ‘function’, plugin_dir_url( __FILE__ ) . ‘function.js’, array( ‘jquery’, ‘json2’ ) ); wp_localize_script( ‘function’, ‘MyAjax’, array( ‘ajaxurl’ => admin_url( […]

plugins_url() works everywhere but wp_reqister_script()

So I should probably mention up front that I’m developing a plugin so my url is ‘’ (Just in case this is related to my issue. So, In my main plugin file (myplugin.php) I have added the following: $plugin_url = plugins_url(‘/my-plugin-directory/’); immediately followed by wp_enqueue_style(‘wp_enqueue_scripts’, $plugin_url . ‘css/boxes.css’); Great, so far so good. The plugin […]

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

When installing a plugin, it will not install if the directory to which it is attempting to install already exists. This means that users of our plugin must first manually deactivate and delete the plugin. Is there any way to forcibly overwrite the directory or to deactivate the plugin and delete the directory at installation? […]

Enqueue WordPress plugin scripts below all other JS

I am developing a simple WordPress app but I am having an issue as all of the plugin scripts are rendered before those which are enqueued in my functions.php. Here is a sample section of the functions.php: function my_scripts() { wp_register_script(‘app-js’, get_template_directory_uri() . ‘/javascripts/app.js’, array(‘jquery’), null, true ); wp_enqueue_script(‘app-js’); } add_action( ‘wp_enqueue_scripts’, ‘my_scripts’); The important […]

Allow only 1 taxonomy per custom post type

This question already has an answer here: WordPress taxonomy radio buttons 3 answers