Articles of plugin development

Plugin base URL

In a question that is related to, but not the same as, How to link to images in my plugin regardless of the plugin folder's name plugin-folder/plugin-main-file.php plugin-folder/images/ containing all images plugin-folder/classes/ containing class definitions plugin-folder/classes/class1-files containing additional files for class 1 plugin-folder/classes/class2-files containing additional files for class 2 etc To access images, I can […]

Cleaning a filename after image sideloading a url that contains `%20`

Right now I’m creating a plugin to sideload images from an external source. The UI allows me to select files on the external server then downloads them via AJAX & media_sideload_image. Everything is working great. After the images is loaded I clean up the attachment’s title by replacing the dashes and underscores with spaces in […]

Plugin Development: Storing and Manipulating Data That Fits JSON in Database

I am new to WordPress plugin development but not web development in general. I have a website whose functionality I am trying to port over to WordPress for a client that needs it in a custom plugin and theme. On my other (non-Wordpress) website, which is a shop page, I have no way of editing […]

Adding another field to user table

I would like to add another field to user such as address, phone no. Added related fields in wp_users and add some come and updated with wp_update_user but it doesn’t work. I can add in wp_usermeta with update_user_meta. Is there any way to add in up_users.

Using AJAX in FrontEnd with WordPress Plugin Boilerplate (wppb.io)

I’m trying to do a tag box similar to that of the backend, but for the frontend. I’m using AJAX to get tag suggestions as the user types in the input field. I’ve used AJAX in WordPress in the past with no problem in themes and such, but right now I’m trying to build a […]

Insert terms for custom taxonomy on plugin activation, or each page load (init hook)

Consider a plugin which adds a custom Taxonomy and then fills the taxonomy with a large term hierarchy (tens of hierarchical terms, may become hundreds in specific installations). I understand that register_taxonomy() does not store data in the database, therefore it must be used via the init hook so that the taxonomy is registered on […]

Validate Custom Post Type fields

I’m developing a plugin, in which the administrator has the ability to add and remove ZIP codes on the backend. I found that the best way to do this is by creating a custom post type named zip_code with only a title being supported , as that functionality is already built-in to WordPress. What I’m […]

get_avatar filter in WordPress 4.4, how to filter properly

Old code in my plugin replaced the get_avatar. It stopped working with the release of WP 4.4, therefore, I decided to try to learn how to use add_filter instead. There are other posts discussing the number of arguments / parameters being passed, etc. I’ve even looked at WordPress plugins in the repository which use add_filter, […]

How to add Request header in WordPress remote api calls

Hey am new to WP development, can any one tell me how to add request headers in wp_remote_get() or wp_remote_post() remote api calls. I tried the following but didnt work $response = wp_remote_get( add_query_arg( array( ‘Affiliate-Id’ => XXXXX, ‘Affiliate-Token’ => XXXXX ), $api_url ) , array( ‘timeout’ => 10));

Where to enqueue stylesheets for plugin?

I want to enqueue stylesheet to plugin I’m developing, like this: function utm_user_scripts() { $plugin_url = plugin_dir_url( __FILE__ ); wp_enqueue_style( ‘style’, $plugin_url . “/css/style.css”); } add_action( ‘wp_enqueue_scripts’, ‘utm_user_scripts’ ); I am adding this code in the main file, [plugin_name].php. Nothing is loaded, which part am I doing wrong?