Plugin install manifest
(→Options button) |
(→Adding a button to the main menu) |
||
(10 intermediate revisions by 3 users not shown) | |||
Line 17: | Line 17: | ||
# Description text | # Description text | ||
$plugin_description = "Adds '- Hello World!' next to the 'Basic Features Group' on the main menu."; | $plugin_description = "Adds '- Hello World!' next to the 'Basic Features Group' on the main menu."; | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</pre> | </pre> | ||
Line 113: | Line 46: | ||
?> | ?> | ||
</pre> | </pre> | ||
+ | |||
+ | |||
+ | ==Special Hooks== | ||
+ | Special hooks allow you to perform common tasks (like adding a button to the main menu) without having to go the long way and replacing the source code via a normal hook_attach, hook_overwrite, or hook_replace. | ||
+ | |||
+ | Typically, special hooks require a specific set of data being set into array values and then passed to the hook_special() function. | ||
+ | |||
+ | ===Adding a button to the main menu=== | ||
+ | |||
+ | <pre># SPECIAL HOOK: Main menu button | ||
+ | $data = array(); | ||
+ | $data['enabled_button_image'] = "plugin_icon-supersearch.gif"; | ||
+ | $data['disabled_button_image'] = "plugin_icon-supersearch.gif"; | ||
+ | $data['enabled_button_link'] = "myadminscreen.php"; | ||
+ | $data['button_caption_text'] = "Super Search"; | ||
+ | hook_special("main_menu_button", $data);</pre> | ||
+ | |||
+ | ==Additional Options== | ||
+ | |||
+ | ===$plugin_install_form=== | ||
+ | |||
+ | <pre> | ||
+ | $plugin_install_form = "install_form.php"; | ||
+ | </pre> | ||
+ | |||
+ | $plugin_install_form lets plugin developers redirect to a form in the middle of the plugin install process, collect user info and do something with it (like write hard-coded data to plugin files), and THEN reprocess install manifest again. Your script must redirect back to sohoadmin/program/webmaster/plugin_manager/install_plugin.php and pass a get string with the following parameters. | ||
+ | <pre>todo=finish_install&plugin=plugin_folder</pre> | ||
+ | Just change "plugin_folder" to your plugins folder name. | ||
+ | |||
[[Category:Plugins]] | [[Category:Plugins]] |
Latest revision as of 16:01, 7 July 2010
Each plugin must include in it's folder a file named install_manifest.php. Pro Edition reads this file to know what to do when it attempts to install your plugin. All plugins must have a valid install_manifest.php in their folder.
Contents |
Overview of file contents
There are two types of content in any given install_manifest.php:
- Information - Plugin title, author, etc
- Instructions - Overwrite this file with my modified version, replace these lines of source code with my custom code, include my custom file at this point in this source file, etc.
Include basic info about your plugin
# PLUGIN INFO $plugin_folder = "HELLO_WORLD"; $plugin_title = "Hello World"; $plugin_version = "1.0"; $plugin_author = "John Smith"; $plugin_homepage = "http://example.com"; # Description text $plugin_description = "Adds '- Hello World!' next to the 'Basic Features Group' on the main menu.";
Tell Pro Edition how to plug-in your plugin
This is the part where you tell Pro Edition how and where to plug-in your plugin (heh). So our specific task at the moment is to tell Pro Edition (through our install manifest) to add our "- Hello World" change to the main menu.
Add this line to your install_manifest.php file...
hook_overwrite("sohoadmin/program/main_menu.php", "main_menu-helloworld.php");
The hook_overwrite function tells Pro Edition to use your version of main_menu.php (main_menu-helloworld.php) instead of the regular one.
Completed install manifest
Here's what your completed install_manifest.php file should look like...
<? # PLUGIN INFO $plugin_folder = "HELLO_WORLD"; $plugin_title = "Hello World"; $plugin_version = "1.0"; $plugin_author = "John Smith"; $plugin_homepage = "http://example.com"; # Description text $plugin_description = "Adds '- Hello World!' next to the 'Basic Features Group' on the main menu."; # Replace main_menu.php with my custom-modified version hook_overwrite("sohoadmin/program/main_menu.php", "main_menu-helloworld.php"); ?>
Special Hooks
Special hooks allow you to perform common tasks (like adding a button to the main menu) without having to go the long way and replacing the source code via a normal hook_attach, hook_overwrite, or hook_replace.
Typically, special hooks require a specific set of data being set into array values and then passed to the hook_special() function.
# SPECIAL HOOK: Main menu button $data = array(); $data['enabled_button_image'] = "plugin_icon-supersearch.gif"; $data['disabled_button_image'] = "plugin_icon-supersearch.gif"; $data['enabled_button_link'] = "myadminscreen.php"; $data['button_caption_text'] = "Super Search"; hook_special("main_menu_button", $data);
Additional Options
$plugin_install_form
$plugin_install_form = "install_form.php";
$plugin_install_form lets plugin developers redirect to a form in the middle of the plugin install process, collect user info and do something with it (like write hard-coded data to plugin files), and THEN reprocess install manifest again. Your script must redirect back to sohoadmin/program/webmaster/plugin_manager/install_plugin.php and pass a get string with the following parameters.
todo=finish_install&plugin=plugin_folder
Just change "plugin_folder" to your plugins folder name.