Skeleton Widget Installer Script
You will need to update various components of this file to match your widget's settings.
What to Edit
Widget ID, Name, and Type
Variable | Type | Purpose |
---|---|---|
$widget_id | String | Unique ID for this widget. |
$widget_name | String | Name of your widget. |
$widget_type | Enum | Should always be set as "code" for our purposes. |
Widget Options
You mostly likely will not need to use this, however if you want to establish options that can be used in the widget, you can do this using the $options array.
Widget Hooks
Hooks should not be used with standard PHP code widgets.
The Script
<?php /** * THIS IS A SAMPLE WIDGET INSTALLER. THIS WIDGET * INSTALLER WILL CREATE A NEW WIDGET BASED ON THE * SPECIFICATIONS YOU OUTLINE BELOW. * * @docs /Widgets/File-List * * @author Ascad Networks * @link http://www.ascadnetworks.com/ * @link http://www.zenbership.com/ * @copyright (c) 2013 Ascad Networks * @license /Basics/License * @project Zenbership Membership Software */ $widget_id = 'my_unique_widget_id'; $widget_name = 'My Widget Name'; $widget_type = 'code'; if (empty($widget_id)) { $id = uniqid(); } /** * Establish the widget's data. * id: Widget ID. Lowercase, numbers, and underscores only. * name: Widget's reference name. * type: 'plugin', 'menu', 'html', 'code', 'upload_list' * content: If the widget is an HTML block, this is the content. */ $widget = array( 'id' => $widget_id, 'name' => $widget_name, 'type' => $widget_type, 'content' => '', ); /** * Options array. Create an array within the $options * array for each widget option. * * display: Display name * value: Value * description: Description * type: 'text','select','radio','checkbox','timeframe','special','file_size','textarea' * width: Width of field * maxlength: * options: array of options for select or radio, separated by vertical bar "|", or for special, "list:..." */ $options = array(); // New Option /* $options[] = array( 'id' => 'my_unique_option_id', 'name' => 'Option Name', 'value' => 'default_value_here', 'description' => 'My option description.', 'type' => 'text', 'width' => '200', 'maxlength' => '', 'options' => '', ); */ /** * Hooks array. * trigger: * specific_trigger: * type: 1 = PHP Include, 2 = email, 3 = MySQL Query, 4 = Function name * data: PHP: path to file. * Email: E-mail array. * MySQL Query: Array of commands to run. * Function: Array of function names to run. * when: 1 = before action, 2 = after action */ $hooks = array(); // New Hook /* $hooks[] = array( 'trigger' => '', 'specific_trigger' => '', 'type' => '', 'data' => '', 'when' => '', ); */
Article Links
Related Articles
Article Tags
Details
Published on 2014/04/18.
Last updated on 2014/04/18.