Hooks
Functions
Hooks::set($name, $function, $order = int)
Registers a function to be called at page startup. The order defaults to 10 and determines the sequence of function calls. If a number is high, the function will be executed later; if it's low, it will be executed earlier.
Hooks::run($name, ...args)
Executes the function registered for the name
Returns the value returned by the function if there is a hook, otherwise returns the first argument value
Active Hooks
At Various Page Execution Points
Hooks::run('modules_loaded');
In get.class.php is called after all modules have been loaded, before loading the template function and before the init hook. It's used to set, for example, whether the user is logged in or not.
Hooks::run('init');
In index.php: is called after all modules have been loaded and the modules_loaded hook (which sets the user) has been executed. It runs immediately before loading the theme function
Hooks::run('cli-init');
In cli.php: is called immediately after the init hook when executing code from the command line
Hooks::run('jobs-init');
In jobs.php: is called immediately after the init hook when executing code from the command line
$name = Hooks::run('route_before_run', $name);
In route.class.php Is called before executing the route and returns the page to execute
$name = Hooks::run('route_after_run', $name);
In route.class.php
$theme = Hooks::run('render-theme', $theme, $page);
In get.class.php
Is called after the page has been rendered.
$theme is the rendered page HTML
$page The theme page that has been rendered
Hooks::run('end-page');
In index.php
Is called just before closing the database connection, after the page has been rendered and printed
CRON
Hooks::run('cron');
In cron.php
Is called every minute if the code is running from command line.
For cron, there's nothing else by default, how it's handled is up to the various modules.
THEME HOOKS
$query_string = Hooks::run('route_url', $query_string);
In route.class.php
Is called before generating any URL
$data = Hooks::run('theme_set_'.$path, $data);
In theme.class.php
Is called every time data is set for the theme
return Hooks::run('theme_get_'.$path, $return, 'string' | 'array');
In theme.class.php
Viene chiamato prima di restituire i dati per il tema
$file = Hooks::run('load_ini_file', $file);
In lang.class.php
Viene chiamato prima di caricare un file di lingua
Plugin Table
Hooks::run('table_actions_row', $header['options'], $row, $table_id);
In table.class.php
Viene chiamato prima di renderizzare le azioni di una riga di una tabella
Plugin Title
$title_txt = Hooks::run('plugin_title.title_txt', $title_txt);
In title.php
$btns = Hooks::run('plugin_title.btns', $btns, $title_txt);
In title.php
$right = Hooks::run('plugin_title.right', $right, $title_txt);
In title.php
$description = Hooks::run('plugin_title.description', $description, $title_txt);
In title.php
Plugin FORM UPLOAD FILE
$max_size = Hooks::run("upload_maxsize_".$name, 10000000);
$accept = Hooks::run("upload_accept_".$name, '');
$error_msg = Hooks::run("upload_check_".$name, '', $_FILES['file']);
Send the error message. If an error message is compiled, the upload is interrupted
$temp_dir = Hooks::run('upload_save_dir_'.$name, $temp_dir);
The directory where the file is saved can be changed with a hook
$file_name = Hooks::run('upload_file_name_'.$name, $file_name, $_FILES['file']);
$permission = Hooks::run('upload_permission_file_'.$name, 0666);
FORM
$field = Hooks::run('form_input', $field, $type, $name, $label, $value, $options);
In form.class.php
$field = Hooks::run('form_textarea', $field, $name, $label, $value, $rows, $options);
In form.class.php
$field = Hooks::run('form_checkbox', $field, $name, $label, $value, $options);
In form.class.php
$field = Hooks::run('form_checkboxes', $field, $name, $list_of_radio, $selected_value, $inline, $options_group, $options_field);
In form.class.php
$field = Hooks::run('form_radio', $field, $name, $label, $value, $options);
In form.class.php
$field = Hooks::run('form_radios', $field, $name, $list_of_radio, $selected_value, $inline, $options_group, $options_field);
In form.class.php
$field = Hooks::run('form_select', $field, $name, $label, $options, $selected);
In form.class.php
Installation
return Hooks::run('install.get_html_modules', $html, $this->errors);
In install.model.php
$this->errors = Hooks::run('install.check_data', $errors, $data);
In install.model.php
Hooks::run('install.execute', $data);
In install.model.php
echo Hooks::run('install.done', $html);
In install_done.page.php
return Hooks::run('install.update', $data);
In install.model.php