Using a plugin class inside a template

The best way to use your class without knowing the object is an action. You register the action before the theme files for presentation are loaded, WordPress will handle the rest. Sample code: <?php # -*- coding: utf-8 -*- /** * Plugin Name: Plugin Action Demo */ add_action( ‘init’, array ( ‘Plugin_Action_Demo’, ‘init’ ) ); … Read more

Is wp-content/install.php a Drop-in?

To answer your question, Yes In fact, there are many other functions you can override in that file, it’s included as the first line of “wp-admin/includes/upgrade.php” & there are many functions inside to be overridden Unfortunately, there is not too much information available regarding drop-in plugins but i’ll try to put a few points They … Read more

Inserting Taxonomy Terms During a Plugin Activation?

Here is the fixed version of your code. class vsetup { function __construct() { register_activation_hook(__FILE__,array($this,’activate’)); add_action( ‘init’, array( $this, ‘create_taxonomies’ ) ); } function activate() { $this->create_taxonomies(); wp_insert_term(‘Action’,’genre’); wp_insert_term(‘Adventure’,’genre’); } function create_taxonomies() { $genre_args = array( ‘hierarchical’ => true, ‘labels’ => array( ‘name’=> _x(‘Genres’, ‘taxonomy general name’ ), ‘singular_name’ => _x(‘Genre’, ‘taxonomy singular name’), ‘search_items’ … Read more

How should one implement add_settings_error on custom menu pages?

There are several components to error/notice creation and display process: add_settings_error() call to add item to stack (global $wp_settings_errors variable). settings_errors transient that keeps the errors so they survive move from page to page. settings_errors() function get_settings_errors() to retrieve errors from memory or transient and then displays them. These work like a charm for Settings … Read more

How are bulk actions handled in custom list table classes?

Assuming you’re using the standard column_cb() function, the list table will pass the IDs of the selected rows in an array in $_GET, labeled as whatever you assigned to ‘singular’ in the list table’s constructor. Here’s a typical column_cb(): function column_cb($item){ return sprintf( ‘<input type=”checkbox” name=”%1$s[]” value=”%2$s” />’, /*$1%s*/ $this->_args[‘singular’], //Let’s simply repurpose the table’s … Read more

How to Use Checkbox in Custom Option Page Using The Setting API

Have a look at: The Complete Guide To The WordPress Settings API (Part 8: Validation, Sanitisation, and Input II): add_settings_field( ‘Checkbox Element’, ‘Checkbox Element’, ‘sandbox_checkbox_element_callback’, ‘sandbox_theme_input_examples’, ‘input_examples_section’ ); function sandbox_checkbox_element_callback() { $options = get_option( ‘sandbox_theme_input_examples’ ); $html=”<input type=”checkbox” id=”checkbox_example” name=”sandbox_theme_input_examples[checkbox_example]” value=”1″” . checked( 1, $options[‘checkbox_example’], false ) . ‘/>’; $html .= ‘<label for=”checkbox_example”>This is an … Read more

File not found.