Small Plugin Toolkit

Downloads: 7873
Category: Plugin
Compatible with: GetSimple 3.1 - 3.3

Last Updated: November 3, 2014
Tags: plugin toolkit helper function hook data form easy
Author: jason.dixon.email
Author Website: http://internetimagery.com
Support: Support Forum

(4.7) 3 Votes

Plugin Description:

1.5 Simplified and loosened the restrictions when discovering tokens.

This plugin is a small collection of tools to hopefully make the creation of plugins easier.

It is important to note that other plugins can only use this plugins functions from the common hook and beyond signifying all plugins are loaded. (thanks shawn_a)

HOOKS

  • edit-above-content = Called above the WYSIWYG editor, and below the Page title box.

  • register-data = Registers data to the plugin under the variable given. More information below. Required for some functions.

  • development-settings = Called in the development section of the settings page.

  • dev-#### = Placing "dev-" ahead of any existing tab or sidebar hook hides it while development mode is inactive.

FILTERS

  • ###-exec = When a user types into the content :["someitem"]: the filter "someitem-exec" will be fired.

FUNCTIONS

  • Toolkit_print( ARRAY ) = Prints out an array within a

     tag. Pretty!

  • Toolkit_array( ARRAY, SEARCH ) = Searches a multidimensional array for a key-name specified in SEARCH.

  • Toolkit_page( SEARCH )= Attempts to find SEARCH in all xml pages, returning the pages and locations if found.

  • Toolkit_load( SEARCH ) = Loads all items with the key-name SEARCH from data registered to the calling plugin.

  • Toolkit_form(DATA, TITLE, ARRAY) = Creates a simple form. More information below.

  • Toolkit_template( FILE, FOLDER ) = Searches the template for tokens. Returning function calls. More below.

  • Toolkit_token() = For use with Toolkit_template.

TEMPLATE FUNCTION SEARCH

By default, a template search automatically happens when loading up the edit.php file. It will search the currently active template and populate the global variable $FUNCTION_CALLS with an array of content function calls and their parameters.

You can invoke the search manually with the function Toolkit_template( FILE, FOLDER ). Which will then return the array.

The search looks for the function Toolkit_token(). All functions that connect to the "content" filter will automatically have tokens applied. Call the token within your plugins function if you want it to be visible in the search.

REGISTER DATA

You can register data for your plugins use which small plugin toolkit will handle loading and saving.

To do so, add an action same as any other.

add_action("register-data","mydata");

However unlike a regular action, the function call is not a function but a variable. Make sure it is unique as a global variable ("mydata") will be created and populated with your information.

The data will be saved automatically near script close. Data is stored as JSON so standard JSON limitations apply to what can be saved.

SIMPLE FORM

You can create a simple form with this plugin. However first ensure you have registered data.

Lets break it down:

Toolkit_form( DATA, TITLE, ARRAY );

DATA refers to your registered data. The form will use this to save its information, under the array key of "FORM".

TITLE is a string that will appear above your form in h3 format. This is not necessary and you can put nothing in the slot.

ARRAY is an array of values that will make up the forms inputs. The values are as follows:


  • type = REQUIRED. Options are "checkbox" "text" "dropdown" "textarea" "hidden".

  • name = REQUIRED. The name of the form element. Will also be the name of the corresponding key in data.

  • value = Sets a value for the form element. Also acts as default content. Dropdown types require this to be an array. Each item represents a choice in this case.

  • label = String that will be displayed as the form element's label.

  • class = Makes the element of this class.

  • override = Currently unused.


The function will take care of the save button and the data storage. An example usage:

$form = array(
array("type"=>"checkbox","name"=>"mycheck","label"=>"Click me for a good time!"),
array("type"=>"text","name"=>"mytext","value"=>"Write in me!"));

Toolkit_form("mydata","This is my form!",$form);

Install Instructions:

Simply unzip the file and place it in your Plugins directory.

Archived Versions:

These are old versions of this file. Please use with caution as they are probably out of date and no longer supported. ShowHide