Articles of plugin development

Autogenerate a Table of Contents

I am trying to generate a Table of Contents at the top of each of my posts and would like to minimize the requirements on the author. Ideally, the author would enter only various levels of the header tag along with an anchor link — e.g. <h1 id=”introduction>Introduction</h1> — and the WP function would scoop […]

Custom post type in Custom widget – $listItem

Hi i have a slight problem when making a custom post type widget. the problem is that when i add a custom field in the code the part that shows the custom field information get’s on top of the output code. here is the code that i use: class Agenda_widget extends WP_Widget{ function __construct() { […]

Find the URL of the current plugin directory

So i’m working on a plugin where I assign a default avatar to anyone that comments. The line i’m stuck on contains a theme directory reference but I want to reference the image in the plugin directory instead. Thanks in advance! $new_avatar_url = get_bloginfo( ‘plugin_directory’ ) . ‘/avatar-1.jpg’;

Plugin not properly prepared for localization

I published my first plugin (https://wordpress.org/plugins/multi-google-analytics/) on WordPress.org and I get this notice about it not being prepared for localization, even though it’s perfectly translated when I use it in the admin. I’ve read through the how to internationalize your plugin guide and I can’t put my finger on anything missing from the plugin. My […]

custom post type with role Vendor

I’m trying to create add-ones of WC-Vendors where I have to create custom post type for Vendor user Only. Here is code snippet I used register_post_type( ‘acme_product’, array( ‘labels’ => array( ‘name’ => __( ‘Products’ ), ‘singular_name’ => __( ‘Product’ ) ), ‘public’ => true, ‘has_archive’ => true, ) ); above code works well with […]

Way to send multiple values for column to MySQL?

I am creating a plugin that allows the user to select multiple options (as a checkbox), which sends these integer values to MySQL. The way I have this set up at the moment is by taking these values and passing them as a comma separate string. Then I take this string, remove the comma’s, and […]

How to add and display custom content that is not a post

I’m building a WordPress site for a local newspaper. This newspaper currently has a “service directory” online which is a bunch of yellow-page style ads for different local businesses. Each of these ads is just a single image with a click-through, although there are two different sized ads (priced at different rates) that need to […]

WordPress Object Oriented plugin development

Hello I am creating a plugin using WordPress, because the scale of this plugin is pretty big I am attempting to use OOP to implement what I need. The way I am using it is that in the main plugin file I am including all the classes, then when plugins_loaded action is fired I make […]

How to rename the plugin PHP file without affecting existent users?

A plugin of mine has main PHP file named “init.php”, now I want to follow best practice and rename it to “plugin-name.php” As users are used to upgrade the plugin by overwriting the old folder with update, so there will be init.php plugin-name.php both exist in the plugin folder after upgrade, which results in a […]

Include HTML (Bootstrap Modal Box) with a plugin into my header

I want to include some HTML, spezific a bootstrap modal box. This is my function with the HTML part: public function dmd_fav_modal_box() { $content = ‘<div class=”modal fade” id=”dmd_favorite_modal” tabindex=”-1″ role=”dialog” aria-labelledby=”dmd_favorite_modalLabel”> <div class=”modal-dialog” role=”document”> <div class=”modal-content”> <div class=”modal-header”> <button type=”button” class=”close” data-dismiss=”modal” aria-label=”Close”><span aria-hidden=”true”>&times;</span></button> </div> <div class=”modal-body”> <p>Test</p> </div> <!–div class=”modal-footer”> <button type=”button” class=”btn […]