This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
ru:plugins:hooks_filters [2013/10/09 06:56] Arkady [Plugin Hooks & Filters] |
ru:plugins:hooks_filters [2013/10/09 07:22] Arkady [Хуки ядра] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Хуки и фильтры ====== | ====== Хуки и фильтры ====== | ||
- | ===== Core Filters ===== | + | ===== Фильтры ядра ===== |
- | <code>add_filter('filter_name','function_to_call');</code> | + | <code>add_filter('filter_name','function_to_call'); |
- | * **content** Will allow you to alter or filter the //$content// variable. The function that you pass $content to should then return your results back to the system. | + | add_filter('имя_фильтра','имя_привязываемой_функции');</code> |
- | * **menuitems** Will allow you to alter or filter the main navigation that is shown with the //get_navigation// template tag. The function that you pass //$menu// to should then return your results back to the system. | + | |
- | ===== Core Hooks ===== | + | * **content** – позволяет изменять содержание переменной //$content//. Привязываемая функция, которой передается переменная //$content//, должна возвращать результат в систему. |
+ | * **menuitems** - позволяет изменять или фильтровать главное меню сайта, формируемое тэгом шаблона //get_navigation//. Привязываемая функция, которой передается переменная //$menu//, должна возвращать результат в систему. | ||
- | <code>add_action('hook_name','function_to_call',array(arguments));</code> | + | ===== Хуки ядра ===== |
- | The last argument is only necessary if function_to_call accepts parameters. | ||
- | hook_name can be any of these and determines where the function will be called. | + | <code>add_action('hook_name','function_to_call',array(arguments)); |
+ | add_action('наименование_хука','имя_привязываемая_функция',array(аргументы_привязываемой_функции));</code> | ||
- | **FRONT-END HOOKS** | + | Последний аргумент в //add_action// обязателен, если привязываемая функция принимает параметры. |
- | * **theme-header** Fired in //<head>// section of theme. Requires //get_header()// in template | + | |
- | * **theme-footer** Fired in the footer of the theme. Requires //get_footer()// in template | + | |
- | * **content-top** Fired right above content area of theme | + | |
- | * **content-bottom** Fired right below content area of theme | + | |
- | * **index-pretemplate** Called before your template files are rendered | + | |
- | * **index-posttemplate** Called after your template files are rendered | + | |
- | * **error-404** Called if the page does not exist, before rendering the error page. | + | |
- | **BACK-END HOOKS** | + | Ознакомьтесь со списком хуков (//hook_name// или //наименование_хука//), к которым возможна привязка пользовательских функций ('//function_to_call//'). |
- | * **header** Called in the head section of the rendered page | + | |
- | * **header-body** Called in the body before output of the page | + | |
- | * **admin-pre-header** Called before the header.php template file is loaded (3.1+) | + | |
- | * **footer** Called in the footer section of the rendered page | + | |
- | * **common** Called immediately after the plugin functions are included in common.php (3.1+) | + | |
- | * **logout** Fired when a user logs out | + | |
- | * **index-login** Fired above the login form | + | |
- | * **login-reqs** Fired on the login sidebar | + | |
- | * **resetpw-success** Fired when password reset and successful | + | |
- | * **resetpw-error** Fired when password reset and error | + | |
- | * **settings-user** Fired before the settings user file is created | + | |
- | * **settings-website** Fired before the settings website page is created | + | |
- | * **settings-cpsettings** Fired before the settings cp_settings file is created | + | |
- | * **settings-website-extras** Fired on the settings page, before "save settings" button in the website section | + | |
- | * **settings-user-extras** Fired on the settings page, before "save settings" button in the user section | + | |
- | * **sitemap-additem** Allow insertion of a new sitemap XML entry | + | |
- | * **sitemap-save** Fired before the sitemap.xml file is saved | + | |
- | * **theme-extras** Fired after the theme screenshot | + | |
- | * **theme-edit-extras** Fired in the theme edit screen before the submit button | + | |
- | * **welcome-link** Allows additional links on the Welcome page | + | |
- | * **welcome-doc-link** Allows additional documentation links on the Welcome page | + | |
- | * **healthcheck-extras** Allows additional Health-check entries | + | |
- | * **support-extras** Allows additional support setting form entries | + | |
- | * **support-save** Fired before cp_settings.xml file is created, allows additional support-extras to be saved | + | |
- | * **plugin-hook** Fired before the Plugin page is rendered. | + | |
- | * **archive-backup** Fired when an archive backup has been created | + | |
- | * **component-save** Fired before components are saved | + | |
- | * **component-extras** Fired when creating component sections, allows additional form elements to be embedded | + | |
- | * **logfile_delete** fired when a logfile is deleted | + | |
- | * **page-delete** fired when a page is deleted | + | |
- | * **changedata-save** Called just before a page is saved | + | |
- | * **changedata-aftersave** Called after a page is saved (3.1+) | + | |
- | * **caching-save** Fired before //pages.xml// file (in //data/other//) is saved for Caching (3.1+) | + | |
- | * **edit-extras** Fired within the Page Options toggle-div within edit.php | + | |
- | * **edit-content** Creating additional data/fields after the textarea on edit.php | + | |
- | * **file-uploaded** Fired after a file has been successfully uploaded | + | |
- | * **files-extras** Fired at the end of the file list | + | |
- | * **successful-login-start** | + | |
- | * **successful-login-end** | + | |
- | The following actions allow the customization of the administration menu and are described on [[plugins:tabs_menus|Tabs and Menus]]: | ||
- | * **backups-sidebar, files-sidebar, pages-sidebar, plugins-sidebar, settings-sidebar, support-sidebar, theme-sidebar** Allows additional sidebar menu items | + | **Фронтенд-хуки** |
- | * **nav-tab** Allow insertion of a new tabbed entry in the navigation bar | + | * **theme-header** - вызывается в секции //<head>// темы. Требует обязательного наличия тэга //get_header()// в шаблоне |
+ | * **theme-footer** - вызывается в секции footer темы. Требует обязательного наличия тэга //get_footer()// в шаблоне | ||
+ | * **content-top** - вызывается перед формированием секции контента в теме | ||
+ | * **content-bottom** - вызывается после формирования секции контента в теме | ||
+ | * **index-pretemplate** - вызывается перед началом обработки файлов шаблона | ||
+ | * **index-posttemplate** - вызывается после окончания обработки файлов шаблона | ||
+ | * **error-404** - срабатывает при отсутствии запрошенной страницы, перед формированием страницы 404. | ||
+ | |||
+ | **Бэкенд-хуки** | ||
+ | * **header** - вызывается в секции //head// обрабатываемой страницы | ||
+ | * **header-body** - вызывается в секции //body// страницы перед ее отдачей | ||
+ | * **admin-pre-header** - вызывается перед загрузкой файла шаблона административной панели //header.php// (3.1+) | ||
+ | * **footer** - вызывается при формировании секции footer формируемой страницы | ||
+ | * **common** - срабатывает сразу после того, как функции плагина включены в файл //common.php// (3.1+) | ||
+ | * **logout** - вызывается при выходе пользователя из административной панели | ||
+ | * **index-login** - вызывается перед отображением формы логина | ||
+ | * **login-reqs** - вызывается в логин-сайдбаре | ||
+ | * **resetpw-success** - срабатывает при успешной смене пароля | ||
+ | * **resetpw-error** - срабатывает при возникновении ошибки при смене пароля | ||
+ | * **settings-user** - вызывается перед созданием файла настроек пользователя | ||
+ | * **settings-website** - вызывается перед созданием страницы **Настройки сайта** | ||
+ | * **settings-cpsettings** - вызывается перед созданием файла настроек //cp_settings// | ||
+ | * **settings-website-extras** - вызывается на странице **Настройки** перед нажатием кнопки «**Сохранить изменения**» в секции настроек сайта | ||
+ | * **settings-user-extras** - вызывается на странице **Настройки** до нажатия кнопки «**Сохранить изменения**» в секции Профиль пользователя | ||
+ | * **sitemap-additem** - позволяет внести новую запись в файл //sitemap.xml// | ||
+ | * **sitemap-save** - вызывается перед сохранением файла //sitemap.xml// | ||
+ | * **theme-extras** - срабатывает после показа скриншота темы | ||
+ | * **theme-edit-extras** - срабатывает при редактировании темы перед нажатием кнопки **Сохранить** | ||
+ | * **welcome-link** - разрешает размещение дополнительны ссылок на стартовой странице административной панели (Welcome page) | ||
+ | * **welcome-doc-link** - разрешает добавление дополнительных ссылок на документацию на стартовой странице административной панели (Welcome page) | ||
+ | * **healthcheck-extras** - разрешает добавление дополнительных параметров при проверке работоспособности сайта (Health-check) | ||
+ | * **support-extras** - разрешает добавлять дополнительную информацию на странице **Поддержка** | ||
+ | * **support-save** - срабатывает перед созданием файла //cp_settings.xml//, позволяет сохранять дополнительную информацию со страницы **Поддержка** | ||
+ | * **plugin-hook** - срабатывает перед выводом на экран страницы/вкладки **Плагины** | ||
+ | * **archive-backup** - срабатывает после создания резервной копии сайта на вкладке **Бэкап** | ||
+ | * **component-save** - срабатывает перед сохранением компонента | ||
+ | * **component-extras** - срабатывает при создании формы для ввода нового компонента, позволяет добавлять к форме дополнительные элементы | ||
+ | * **logfile_delete** - вызывается при удалении лог-файла | ||
+ | * **page-delete** - вызывается при удалении страницы | ||
+ | * **changedata-save** - вызывается перед сохранением страницы | ||
+ | * **changedata-aftersave** - вызывается после сохранения страницы (3.1+) | ||
+ | * **caching-save** - срабатывает перед сохранением файла //pages.xml// в папке //data/other// при кэшировании (3.1+) | ||
+ | * **edit-extras** - вызывается во время редактирования страниц в контейнере (div) //toggle// в файле //edit.php// | ||
+ | * **edit-content** - создает дополнительные поля/данные после текстового поля в файле //edit.php// | ||
+ | * **file-uploaded** - вызывается после успешной загрузки файла | ||
+ | * **files-extras** - вызывается после окончания списка файлов | ||
+ | * **successful-login-start** – комментарии в англоязычной ВИКИ отсутствуют | ||
+ | * **successful-login-end** - комментарии в англоязычной ВИКИ отсутствуют | ||
+ | |||
+ | Следующие экшн-хуки (actions) позволяют настраивать меню административной панели. Более подробно в ними можно ознакомиться в секции ВИКИ [[ru:plugins:tabs_menus|Вкладки и боковые меню]]. | ||
+ | |||
+ | * **backups-sidebar**, **files-sidebar**, **pages-sidebar**, **plugins-sidebar**, **settings-sidebar**, **support-sidebar**, **theme-sidebar** – используются для добавления дополнительных пунктов в боковое меню сайдбара административной панели. | ||
+ | * **nav-tab** – позволяет добавлять новую вкладку в административную панель. | ||