Skip to content

Wordpress

eswarsaladi edited this page Jan 5, 2023 · 1 revision

WordPress


WordPress WordPress is a PHP, MySQL, and JavaScript based project, and uses Node for its JavaScript dependencies. A local development environment is available to quickly get up and running.

Installation

You will need Node and npm installed on your computer. Node is a JavaScript runtime used for developer tooling, and npm is the package manager included with Node. If you have a package manager installed for your operating system, setup can be as straightforward as:

  • macOS: brew install node
  • Windows: choco install nodejs
  • Ubuntu: apt install nodejs npm

Functions

wp_register_script


Registers a script to be enqueued later using the wp_enqueue_script() function.

Usage:

  • wp_register_script( $handle, $src, $deps, $ver, $in_footer );

Registering scripts is technically not necessary, but highly recommended nonetheless. If the handle of a registered script is listed in the $deps array of dependencies of another script that is enqueued with wp_enqueue_script(), that script will be automatically loaded prior to loading the enqueued script. This greatly simplifies the process of ensuring that a script has all the dependencies it needs. See below for a simple example.

Source:

File: wp-includes/functions.wp-scripts.php. View all references

wp_register_style


Register a CSS stylesheet.

Usage:

  • wp_register_style( string $handle, string|false $src, string[] $deps = array(), string|bool|null $ver = false, string $media = 'all' ): bool

Source:

File: wp-includes/functions.wp-styles.php. View all references

register_block_type


Registers a block type. The recommended way is to register a block type using the metadata stored in the block.json file.

Usage:

  • register_block_type( string|WP_Block_Type $block_type, array $args = array() ): WP_Block_Type|false

Source:

File: wp-includes/blocks.php. View all references

register_block_type_from_metadata


Registers a block type from the metadata stored in the block.json file.

Usage:

  • register_block_type_from_metadata( string $file_or_folder, array $args = array() ): WP_Block_Type|false

Source:

File: wp-includes/blocks.php. View all references