Plugin Development Flashcards

1
Q

function update_option

A

Used to create or update a new key in wp_options table

Accepts name of key to create or update, and the vale that needs to be stored in it

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

init action hook

A

Fires after Wordpress finished loading but before any headers are sent
Accepts name of custom function to callback
Good stage to set values needed for the plugin to work, like custom post types and taxonomies.

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

What is a text domain

A

Unique identifier that helps Wordpress to distinguish between different translations of this plugin.
Domain name should be the name of main plugin file without extension.
Must use dashes, not underscores

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

Function __()

A

Used to demote text elements that can be translated into other languages.

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

Function register_post_type

A

Used to register new post type
Should be called within init action hook
Its value is stored wp_posts post_type field
Accepts name of the post type and arguments / settings.

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

admin_menu action hook

A

Used to add menu pages to admin

Accepts name of the callback function that will be called to create the menu

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

Function add_options_page

A

Adds submenu item under dashboard > settings
Accepts page title tag, menu item’s anchor text, user capability, slug, callback to output HTML form of the settings page

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

Function get_option

A

A safe way of getting value of a saved option from wp_options table
Accepts name of the key whose value to retrieve

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

Function _e()

A

Same as __(), but in addition to making it translatable, outputs the vale to screen

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

Function settings_fields

A

Accepts name of settings group
Should be called before register_setting functions
Is called inside of options html form
Tells register_setting that once submitted the group name should be matched with group name in register setting! and if matched values should be saved in the right option key.

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

Function esc_attr()

A

Should be used to sanitize vales of HTML attributes

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

Function sanitize_text_field()

A

Does the same as esc_atts, but is used for the actual values that come from input tags. Good to use before display and before querying the database.

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

add_meta_boxes action hook

A

Runs whe edit post screen is loaded

Used to construct custom meta fields for a post

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

Function add_meta_box()

A

Allows plugin developers to add meta boxes to edit / create post screen
Should be called from add_meta_boxes action hook
Accepts ID attribute name of wrapping element, section heading, callback that prints the HTML form, screen - name of post type, context - section of the page

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

Function get_post_meta

A

Retrieve post meta fields
Requires ID of the post
Returns either all meta associated with post, or just meta of specific key
Data is pulled from wp_postmeta

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

Function wp_nonce_field

A

Used to ensure that data sent for saving comes from the actual form and not somewhere else.
Accepts action name that describes what this form does, and nonce name, which can be anything

17
Q

Function selected()

A

Used in select options, checks two values given, and if they match selected attribute is added.

18
Q

save_post action hook

A

Runs when a post or a page is created or updated

The callback function gets ID of the last saved post

19
Q

Function get_post_type

A

Retrieves the post type of the current or given post

Returns a string that matched post_type field of wp_posts table.

20
Q

Function wp_verify_nonce

A

Checks if data sent comes from the actual site and form, and not somewhere else. Should be passed action and name set earlier by wp_nonce_field.

21
Q

Function array_map()

A

Accepts call back function that will be applied on each value of the array passed to it, such as sanitize_text_field. Returns array with values sanitized.

22
Q

Function update_post_meta

A

Queries database
Either creates or updates wp_postmeta table
Accepts post ID, name of the key, and value

23
Q

What is a shortcode

A

Placeholder you add to content that is replaced by Wordpress with other content. Can be with or without attributes

24
Q

Function add_shortcode

A

Used to add replace code macros with the actual content

Accepts tag and callback function

25
Q

What’s a widget

A

Widget is a small program that allows users to easily add plugin info into sidebar or any other widgetized area.

26
Q

widgets_init action hook

A

Triggered right after all default widgets are built

27
Q

Function wp_parse_args()

A

Merges user defined arguments into $defaults array, and returns updated array with default keys overwritten.

28
Q

function register_activation_hook

A

Is run when plugin activated
Says which function to call upon activation
Accepts full path to main plugin file and name of the custom function to run