I am just starting to learn PHP
and WordPress
. there is a default simple plugin in WordPress called Hello Dolly
.In its file hello.php
I can see some WordPress functions like wptexturize()
or add_action()
but there isn't any include
or require
expression in that file. How that plugin can uses WordPress functions without including theme?
Asked
Active
Viewed 170 times
0

Saeed Noori
- 83
- 2
- 11
-
Can you post the code? – rmc00 Oct 07 '16 at 13:21
-
@rmc00 Its code take too much space. you can download it from this link: https://wordpress.org/plugins/hello-dolly/ – Saeed Noori Oct 07 '16 at 13:53
1 Answers
0
add_action() and others (see https://codex.wordpress.org/Plugin_API) are part of the Wordpress Plugin API and available in the global execution space of your plugin.
There are tons of tutorials on plugin development online or check this out https://codex.wordpress.org/Writing_a_Plugin
Edit:
Simplified flow:
Request --> index.php --> wp-settings.php -> (checks for active plugins) -> List of active plugins -> each list item (plugin) is included (basically your plugin index file) --> plugin index file uses plugin API
So you can think of your plugin code as a part of the wp index file... everything loaded before is available to your plugin code as well.

user3798397
- 146
- 5
-
Thank you for your response, I know this already, but I want to know the mechanism of availability of them. – Saeed Noori Oct 07 '16 at 13:01
-
Does it means that if we have 3 `php` files: `1.php`, `2.php` and `index.php`, if `1.php` and `2.php` are included in `index.php` then the functions belong to `1.php` are available in `2.php`? – Saeed Noori Oct 07 '16 at 13:59
-