These are functions which can be used from within plugins' files.
This function is used to register plugin in Instant Update's Plugin System (further: IUPS). It accepts two arguments, first is Plugin ID, which is actually file name of main plugin file, and second is array of plugin data.
Exists from version: 3.0
| variable | type | description |
|---|---|---|
| $plugin_id | string | Plugin ID, name of plugin's main file |
| $data | array | Array with plugin data |
//set plugin id as file name of plugin $plugin_id = basename(__FILE__); //some plugin data $data['name'] = "IU Footer ad"; $data['description'] = "Advertise Instant Update in the footer of your website."; $data['author'] = "Instant Update team"; $data['url'] = "http://www.instant-update.com/"; //register plugin to IUPS if (function_exists('register_plugin')) { register_plugin($plugin_id, $data); }
This function is used to attach plugin function to IUPS. It accepts two arguments, first is hook name and second is name of the function you want to attach to the hook.
Exists from version: 3.0
| variable | type | description |
|---|---|---|
| $where | string | Name of the hook (chosen from the list of hooks) you want to attach function to |
| $function | string | Name of the function you want to attach to hook |
if (function_exists('add_hook')) { add_hook('iu_page_footer','iufooterad_add2footer'); add_hook('below_dashboard','iufooterad_add2dash'); }
Function to add navigation menu item to the automatically generated menus. All items added via this function will be added right before last menu item added by Instant Update's automatic menus.
This function can be used only in plugin functions which are attached to following hooks: iu_navigation_menu
Exists from version: 3.0
| variable | type | description |
|---|---|---|
| $text | string | Text which will be linked |
| $link | string | Linking URL |
function nav_link() { add_menu_item("Google", "http://www.google.com/"); }
Function to add navigation menu item to the menus used in Instant Update administration.
This function can be used only in plugin functions which are attached to following hooks: below_dashboard, above_dashboard, main_nav
Exists from version: 3.0
| variable | type | required | default value | description |
|---|---|---|---|---|
| $text | string | yes | NULL | Text which will be linked |
| $link | string | yes | NULL | Linking URL |
| $mode | const. | no | IU_LINK_NORMAL | How to open link. Possible values: IU_LINK_NORMAL for normal links, IU_LINK_POPUP for small popup links and IU_LINK_BIGPOPUP for full screen popups. |
| $title | string | no | Instant Update | Title of popup window. Used only if $mode is set to IU_LINK_POPUP or IU_LINK_BIGPOPUP |
| $width | integer | no | 500 | Width of popup window. Used only if $mode is set to IU_LINK_POPUP |
| $height | integer | no | 250 | Height of popup window. Used only if $mode is set to IU_LINK_POPUP |
function iufooterad_add2dash() { if (iu_is_admin()) { add_menu_item("Configure footer Ad", "plugins/iu-footer/iu-footer-config.php", IU_LINK_POPUP, "Footer AD administration", 500, 450); } }
Function to add navigation menu item to the menus used in Instant Update sidebar (in administration panel).
This function can be used only in plugin functions which are attached to following hooks: sidebar
Exists from version: 3.1
| variable | type | required | default value | description |
|---|---|---|---|---|
| $text | string | yes | NULL | Text which will be linked |
| $link | string | yes | NULL | Linking URL |
| $image | string | yes | NULL | Icon (16x16px) URL, can be relative to manage/ folder |
| $mode | const. | no | IU_LINK_NORMAL | How to open link. Possible values: IU_LINK_NORMAL for normal links, IU_LINK_POPUP for small popup links and IU_LINK_BIGPOPUP for full screen popups. |
| $title | string | no | Instant Update | Title of popup window. Used only if $mode is set to IU_LINK_POPUP or IU_LINK_BIGPOPUP |
| $width | integer | no | 500 | Width of popup window. Used only if $mode is set to IU_LINK_POPUP |
| $height | integer | no | 250 | Height of popup window. Used only if $mode is set to IU_LINK_POPUP |
function iufooterad_add2sidebar() { if (iu_is_admin()) { add_menu_item("Configure footer Ad", "plugins/iu-footer/iu-footer-config.php", "plugins/iu-footer/icon.gif", IU_LINK_POPUP, "Footer AD administration", 500, 450); } }
This function accepts no arguments and returns TRUE or FALSE if currently logged in user is administrator user or not, respectively.
Exists from version: 3.0
NONE
function iufooterad_add2dash() { if (iu_is_admin()) { add_menu_item("Configure footer Ad", "plugins/iu-footer/iu-footer-config.php", IU_LINK_POPUP, "Footer AD administration", 500, 450); } }
This function accepts no arguments and returns TRUE or FALSE if current web site visitor is logged in into Instant Update administration panel or not, respectively.
Exists from version: 3.0
NONE
function plugin_function() { if (iu_is_loggedin()) { echo "You are logged in :)"; } else { echo "You are not logged in :("; } }
This function returns value of a setting in MySQL database. If there is no such setting in MySQL database, it'll return default value (if specified, otherwise it'll return boolean false).
Exists from version: 3.0, modified in 3.1
| variable | type | required | description |
|---|---|---|---|
| $setting | string | yes | Name of the setting which value you want |
| $default | variant | no | Value returned on error, default: false |
if (!GetSettingsValue('iu_footer_url')) { $iu_footer_url = 'http://www.instant-update.com/'; } else { $iu_footer_url = GetSettingsValue('iu_footer_url'); }
From version 3.1 you can specify default value which will be returned if there is no value for our setting (in this example it's iu_footer_url) in database:
$iu_footer_url = GetSettingsValue('iu_footer_url', 'http://www.instant-update.com/');
This function removes a setting in MySQL database. If there is no such setting in MySQL database, it'll return FALSE.
Exists from version: 3.0
| variable | type | description |
|---|---|---|
| $setting | string | Name of the setting which you want to remove |
if (isset($_GET['uninstall']) && iu_is_admin()) { RemoveSetting('iu_footer_url'); RemoveSetting('iu_footer_image_alt'); RemoveSetting('iu_footer_image'); RemoveSetting('iu_footer_image_align'); RemoveSetting('iu_footer_image_target'); RemoveSetting('iu_footer_active'); die("<p>IU footer Ad data removed! Now you can remove folder iu-footer from your plugins directory!</p>"); }
This function updates setting value in MySQL database. If there is no such setting in MySQL database, it'll create it.
Exists from version: 3.0
| variable | type | required | default value | description |
|---|---|---|---|---|
| $setting | string | yes | NULL | Name of the setting which value you want to write |
| $value | string | yes | NULL | Value of the setting which will be written |
| $type | string | no | text | Setting type: text for a text box, radio for a radio button or select for a drop down list |
| $offer | string | no | 500 | Offered values, divided with pipe. Used only if $type is set to radio or select |
if (GetSettingsValue('iu_footer_image_target') == false) { WriteSettingsValue('iu_footer_image_target', '_blank','select','_blank|_self|_top'); }
This function returns HTML code of HTML form field based on setting type in MySQL database.
Exists from version: 3.0
| variable | type | required | default value | description |
|---|---|---|---|---|
| $setting | string | yes | NULL | Name of the setting which HTML form field you want to display |
| $delimiter | string | no | SPACE | Value of the divider with which offered values will be divided. Used only if type of the setting is radio |
| $updating | boolean | no | TRUE | Whether current value will be shown in HTML form field (TRUE) or not (FALSE) |
echo CreateSettingFormField('iu_footer_active','<br />');
Function to add reference to external JS file in HEAD of both Instant Update (internal) pages and Instant Update powered web pages.
This function can be used only in plugin functions which are attached to following hooks: meta, iu_page_meta
Exists from version: 3.1
| variable | type | required | default value | description |
|---|---|---|---|---|
| $path | string | yes | NULL | URL of external JavaScript file |
function plugin_meta() { insert_js('path/to/scripts.js'); }
Function to add reference to external CSS file in HEAD of both Instant Update (internal) pages and Instant Update powered web pages.
This function should be used in plugin functions which are attached to following hooks: meta, iu_page_meta
Exists from version: 3.1
| variable | type | required | default value | description |
|---|---|---|---|---|
| $path | string | yes | NULL | URL of external CSS file |
| $media | string/array | no | screen | Media type for included file |
function plugin_meta() { insert_css('path/to/styles.css'); insert_css('path/to/styles2.css', array('screen','handheld')); insert_css('http://www.website.com/path/to/styles.css', 'screen, print'); }
Function to set minimum version of IU required for plugin to work. If plugin is loaded in older version than required, it will not work and it will display warning message.
| |
|---|
| Because this function is not available in older versions of IU, it is wise to check if function exists before you make a call to the function. |
Exists from version: 3.1
| variable | type | required | default value | description |
|---|---|---|---|---|
| $version | double | yes | NULL | Minimum required version of IU |
| $plugin_id | string | no | NULL | Unique plugin ID, also passed to register_plugin() function. |
| $explicit | boolean | no | false | Whether we require EXACT version or just same/newer version than specified in 1st parameter |
if (function_exists('iu_plugin_require_version')) { iu_plugin_require_version(3.1, $plugin_id); } else die("({$data[name]}) Please upgrade Instant Update to the latest version.");
Returns Instant Update version number, as string or float.
Exists from version: 3.1
| variable | type | required | default value | description |
|---|---|---|---|---|
| $float | boolean | no | false | Whether we want result to be returned as float or as string |
echo "You are using Instant Update version: " . iu_version(); // This will return "You are using Instant Update version: 3.1" if (iu_version(true) < 3.2) echo "Your Instant Update version is lower than 3.2"; // If we want to compare versions or to do some computing, we want to get IU version as float
Sends HTTP HEADER with Content-type and charset information. If headers are already sent it will return false, otherwise it'll return true.
Exists from version: 3.1
| variable | type | required | default value | description |
|---|---|---|---|---|
| $type | string | no | text/html | Type of content being served. |
| $charset | string | no | utf-8 | Charset (character encoding) of content being served. |
iu_set_encoding('text/javascript'); //if you're dumping JavaScript code from within PHP script