Articles of plugin development

Converting core modification to a plugin

I needed to change two strings shown to the user on the site upon clicking the confirmation links in the email (not to modify the emails sent out). I made the following modifications and it worked.: — wp-activate.bak 2017-02-28 13:01:03.883175677 +0530 +++ wp-activate.php 2017-02-28 13:47:35.000000000 +0530 @@ -13,6 +13,10 @@ require( dirname(__FILE__) . ‘/wp-load.p require( […]

Search users with custom meta data

I’m looking for a way to search to make wordpress search for matches on a WC users billing-/shipping-company – but im not sure how to achive this. I found out how i can do it with the most common user fields (ID, login, email & nicename). Searching for common user data: $customers_query = new WP_User_Query( […]

Class or function wrapper for plugin code

When developing plugins, to avoid using a prefix for all functions and variables, it is common to use a wrapper for the plugin code. I have seen in many places the practice of using a class and I want to compare that to simply using a function as a wrapper. A. Class wrapper class Nice_Plugin […]

Order properties should not be accessed directly

This code: foreach ($order->meta_data as $row) { if ($row->key == ‘tid’) { $tid = $row->value; break; } } within the function function function_name($order_id, $checkout = null) { global $woocommerce; $order = new WC_Order($order_id); foreach ($order->meta_data as $row) { if ($row->key == ‘tid’) { $tid = $row->value; break; } } if (!empty($tid)) { … } } […]

Upload files to the plugin menu

I’m currently trying to build a wordpress plugin. I’d like its users to be able to add an upload file to the settings field menu of my plugin and then to be registered into the wordpress database, is there some way to do that?

Adding <div> Automatically To <table> In WordPress Using Filter Referencing?

Does anyone know how I would automatically add <div class=”table-responsive”> before every instance of a <table> on a WordPress site using filter referencing? I would also need to add a </div> to every instance of </table> as well.

Best practice for Designing a Plugin with this scenario

I have a HTML page which I wanna use inside a WordPress website. But this page should be only available to users who logged-in and non logged-in users should be redirected to login page. Since I need to check user status a PHP page should do the job and if user is logged-in it returns […]

Get content and send to 3rd party

I’ve been asked to create a WordPress plugin that will basically show a button on the “edit” and the “new” pages of the admin panel which (when clicking the button) verify an API key (which you can set in the settings) and then send the post contents to a 3rd party. When the 3rd party […]

add_filter : Passing an array instead of the callback function?

I was just reading through BuddyPress code because I want to develop a custom plugin on top of it. I encountered was something very peculiar that I haven’t seen before and cannot seem to find any material on. The following code is from a protected function under a class named as BP_Legacy // Filter BuddyPress […]

Action Hook Inside WordPress Plugin Shortcode

I’m developing a WordPress plugin and I’m having trouble getting $_POST data using an action inside my shortcode. The form I’m parsing is on a page that I’ve added my shortcode to. Here’s what I’ve got: function wpd_post_parse() { $string = ‘wp hook: ‘ . var_dump($_POST) . “\r\n”; //$string = ‘wp hook: first name: ‘ […]