PHP/plugin Development Flashcards

1
Q

Should you ever touch any wordpress core files?

A

NO!!!!!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

what is this doing:

if ( ! defined( ‘ABSPATH’ ) ) {
exit;
}

A

defined( ‘ABSPATH’ ): This checks if the constant ABSPATH has been defined. ABSPATH is a constant in WordPress that contains the absolute path to the root directory of the WordPress installation.

!: This is a negation operator, so ! defined( ‘ABSPATH’ ) means “if ABSPATH has not been defined.”

exit;: This stops the script from running.

Purpose:
The purpose of this code is to prevent direct access to PHP files in WordPress. If someone tries to directly access a file (such as by typing its URL in the browser), WordPress will prevent it from running unless it’s being accessed through WordPress itself.

If ABSPATH is not defined, it means the file is likely being accessed directly, and the script exits immediately to avoid potential security risks. This is a common security measure in WordPress development, especially for plugins and themes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what does the add_action function do in wordpress?

A

The add_action function allows you to attach your custom function to a specific action hook in WordPress. When that action hook is triggered, your custom function will be executed.

add_action( ‘hook_name’, ‘function_name’, [priority], [arguments] );

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is the php function isset()?

A

In PHP, isset() is a built-in function that checks if a variable is set and is not null. It returns a boolean value (true or false) depending on whether the variable is defined and has a value other than null.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is maybe_unserialize

A

In WordPress, the function maybe_unserialize() is a utility function used to conditionally unserialize data. It checks if a string is serialized and only unserializes it if it is, otherwise it returns the value as-is. This helps prevent errors when trying to unserialize data that is not in a serialized format.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what does the init wordpress action do?

A

// The init action runs after WordPress has finished loading but before any output is sent to the browser.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is a wordpress action

A

In WordPress, an action is a type of hook that allows you to add or modify functionality at specific points in the WordPress lifecycle. Actions are part of WordPress’ Hooks system, which enables developers to insert their custom code into WordPress without modifying core files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

is there a refrence for all the built in functions that wordpress has?

A

yes it can be found here: https://developer.wordpress.org/reference/functions/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly