Articles of plugin development

WordPress Widget Not Saving Instance

I have very simple wordpress widget, that has 3 input field. Whenever i submit data, it does not save to database. I have added and deleted the plugin , deactivated and reactivated multiple times, but no luck. Below is my code :- class price_package extends WP_Widget { function __construct() { parent::__construct( ‘price_package’, ‘Price Package’, array( […]

How do I make this Metabox show current DB value?

<p> <?php $options = get_option( ‘city’ ); $names = explode( PHP_EOL, $options ); ?> <label for=”City” class=”timeshare-row-title”><?php _e( ‘City:’, ‘timeshare-textdomain’ )?></label> <select name=”city” id=”city”> <?php foreach ( $names as $name ) { printf( ‘<option value=”%s” selected=”selected”>%s</option>’, $name, $name ); } ?> </select> </p> Save function: if( isset( $_POST[ ‘city’ ] ) ) { update_post_meta( $post_id, […]

Create fixed static pages

I have inside a theme two important static pages. One is a confirmation page (after signing up for a newsletter) and the other one is a thank-you page. I am using these in various functions and create them upon theme install with predefined content. The problem is some users tend to change the slug, or […]

Woocommerce custom Plugin in wordpress

I want to access the ID of the product currently being displayed on the page. I am trying to do this in a separate custom plugin. I have tried global $post and global $product and get_the_ID() methods but not working. <?php /* Plugin Name: CleverTap Plugin URI: https://clevertap.com Description: CleverTap plugin Author: CleverTap Author URI: […]

How to get terms for taxonomy

how to get all terms for my taxonomy customcategorie i tried with this code i tried to keep code in taxonomy.php <?php /* Template Name:Taxoo */ get_header(); ?> <?php $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); ?> <h2> <?php $args = array( ‘type’ => ‘post’, ‘child_of’ => 0, ‘parent’ => 0, […]

is pre_get_comments not working?

I am following through the “Professional WordPress Plugin Development” book from WROX and I wanted to use this piece of code I found in it (I switched pre_get_posts with pre_get_comments) for my plugin, but for some reason it isn’t working? And when I googled it, I found multiple people who said that “pre_get_comments” stopped working […]

How to Customize Polylang Language Items

I am using Polylang plugin with WordPress 4.3.1, Can you please let me know if there is a way to display language items in short abbriviation like En for English or CH for Chinese I am using this code to display the active languages <?php pll_the_languages();?> and the result looks like Can you please let […]

Limit role to one plugin

This question already has an answer here: How do I create a custom role capability? 2 answers

Licensing a Plugin

I am developing some paid for premium features for my plugin which is already available in the WP Repo. What are the best ways to validate licensing etc. for premium features? I want to continue to use the repo so “calling home” is not an option as it is against plugin guidelines. These features are […]

Short code not working in boostrap modal dont no why?

I am trying to put a pluign into a short code it works on the page but when i try to insert it into a modal popup it doesnt render correct at all. <div id=”thanks” class=”modal fade” tabindex=”-1″ role=”dialog” aria-labelledby=”myModalLabel” aria-hidden=”true”> <div class=”modal-dialog”> <div class=”modal-content”> <div class=”modal-header”> <button type=”button” class=”close” data-dismiss=”modal” aria-hidden=”true”>×</button> <h4 class=”modal-title”>Redeem Points</h4> […]