Skip to content

Functions visibility needed

Moisés Barrachina Planelles edited this page Oct 4, 2023 · 2 revisions

A quick summary for what visibility to use on the functions of your plugin:

Private

Don't use private functions, BFT use inheritance on the classes and a private function can't inheritance

Protected

Ideal for the internal functions for security reasons, only your classes can use these functions

Public

Some functions need to be public due to how WordPress works:

* Functions called via $this->admin_pages -> an_admin_page -> 'function_load' data
* Functions called via $this->admin_pages -> an_admin_page -> 'function' data
* Functions called via install, upgrade or uninstall
* Functions called via shortcodes
* Functions called via AJAX responses
Clone this wiki locally