Plugin Development Flashcards

(25 cards)

1
Q

What is a WordPress plugin?

A

A WordPress plugin is a PHP-based add-on that extends or modifies WordPress functionality.

Plugins allow developers to add features like contact forms, SEO tools, or e-commerce without altering core files. Freelancers create plugins to meet client needs, while enterprise architects use them to integrate WordPress with complex systems, ensuring modularity and scalability.

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

What is the minimum requirement for a WordPress plugin?

A

A plugin requires a main PHP file with a header comment containing metadata.

The header comment (e.g., /* Plugin Name: My Plugin */) in the main PHP file (e.g., my-plugin.php) is read by WordPress to list the plugin in the admin panel. Freelancers start with this structure, while enterprise architects ensure minimal, optimized setups for performance.

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

What is the purpose of the plugin header comment?

A

The header comment provides metadata like Plugin Name, Description, and Version for WordPress to recognize the plugin.

Located at the top of the main plugin file (e.g., /* Plugin Name: My Plugin */), it ensures the plugin appears in the admin dashboard. Freelancers use it to brand plugins, while enterprise architects include details like compatibility for system integration.

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

What is the WordPress Plugin API?

A

The Plugin API is a set of hooks (actions and filters) that allows plugins to modify WordPress behavior.

It enables developers to hook into WordPress events (e.g., wp_enqueue_scripts) or modify data (e.g., the_content). Freelancers use it for custom functionality, while enterprise architects leverage it for extensible, modular system designs.

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

What is add_action() in plugin development?

A

add_action() attaches a custom function to a WordPress action hook to execute at specific points.

For example, add_action(‘init’, ‘my_function’) runs code on WordPress initialization. Freelancers use actions to add features like custom post types, while enterprise architects use them for scalable, event-driven integrations.

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

What is add_filter() in plugin development?

A

add_filter() attaches a function to a WordPress filter hook to modify data.

For example, add_filter(‘the_content’, ‘add_to_content’) alters post content. Freelancers use filters for client-specific tweaks, while enterprise architects apply them for consistent data transformations across large systems.

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

What is register_activation_hook()?

A

register_activation_hook() runs a function when a plugin is activated.

For example, register_activation_hook(__FILE__, ‘my_activation’) sets up database tables or settings. Freelancers use it for initial setup, while enterprise architects ensure activation tasks are efficient for large-scale deployments.

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

What is register_deactivation_hook()?

A

register_deactivation_hook() runs a function when a plugin is deactivated.

For example, register_deactivation_hook(__FILE__, ‘my_deactivation’) cleans up settings. Freelancers use it to prevent data clutter, while enterprise architects ensure deactivation doesn’t disrupt system integrity.

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

What is register_uninstall_hook()?

A

register_uninstall_hook() runs a function when a plugin is uninstalled.

For example, register_uninstall_hook(__FILE__, ‘my_uninstall’) deletes plugin data. Freelancers use it for clean uninstalls, while enterprise architects ensure it removes data securely without affecting other systems.

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

What is a WordPress shortcode?

A

A shortcode is a bracketed tag (e.g., [my_shortcode]) that triggers custom functionality in content.

Created with add_shortcode(‘my_shortcode’, ‘my_function’), shortcodes add dynamic features like forms. Freelancers build shortcodes for client flexibility, while enterprise architects use them for reusable, scalable components.

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

What is the Shortcode API?

A

The Shortcode API allows developers to create and manage custom shortcodes.

Using add_shortcode(), developers define shortcodes that users can embed in posts or pages. Freelancers create client-specific shortcodes, while enterprise architects integrate them into modular content systems.

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

What is wp_enqueue_script() in plugins?

A

wp_enqueue_script() loads JavaScript files with dependency management.

For example, wp_enqueue_script(‘my-script’, plugins_url(‘/js/script.js’, __FILE__)) loads a plugin script. Freelancers add interactivity, while enterprise architects ensure efficient script loading for scalability.

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

What is wp_enqueue_style() in plugins?

A

wp_enqueue_style() loads CSS files with proper dependency management.

For example, wp_enqueue_style(‘my-style’, plugins_url(‘/css/style.css’, __FILE__)) loads plugin styles. Freelancers use it for custom styling, while enterprise architects optimize it for performance.

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

What is plugins_url()?

A

plugins_url() returns the URL to a plugin’s directory or file.

For example, plugins_url(‘css/style.css’, __FILE__) links to a plugin’s CSS file. Freelancers use it for asset paths, while enterprise architects ensure consistent resource linking in large systems.

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

What is a WordPress widget?

A

A widget is a small block of functionality added to widget areas like sidebars.

Created via the Widgets API, widgets display content like search bars or custom data. Freelancers build widgets for client features, while enterprise architects use them for modular UI components.

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

How do you create a custom widget?

A

Extend the WP_Widget class and register the widget with register_widget().

For example, a custom widget class defines form(), update(), and widget() methods. Freelancers create widgets for client-specific sidebars, while enterprise architects ensure they’re reusable and scalable.

17
Q

What is the Settings API in WordPress?

A

The Settings API allows plugins to create custom admin settings pages.

Using functions like add_settings_field() and register_setting(), developers build user-friendly options. Freelancers use it for plugin configuration, while enterprise architects create robust settings for system-wide controls.

18
Q

What is add_menu_page()?

A

add_menu_page() adds a top-level admin menu for a plugin.

For example, add_menu_page(‘My Plugin’, ‘My Plugin’, ‘manage_options’, ‘my-plugin’, ‘my_page_function’) creates a menu. Freelancers use it for plugin dashboards, while enterprise architects ensure intuitive admin interfaces.

19
Q

What is add_submenu_page()?

A

add_submenu_page() adds a submenu under an existing admin menu.

For example, add_submenu_page(‘my-plugin’, ‘Settings’, ‘Settings’, ‘manage_options’, ‘my-settings’, ‘my_settings_page’) adds a submenu. Freelancers use it for organized settings, while enterprise architects streamline admin navigation.

20
Q

What is wp_nonce_field()?

A

wp_nonce_field() adds a security nonce to forms to prevent unauthorized actions.

For example, wp_nonce_field(‘my_action’, ‘my_nonce’) secures form submissions. Freelancers use nonces for secure plugins, while enterprise architects ensure robust security in large systems.

21
Q

What is check_admin_referer()?

A

check_admin_referer() verifies a nonce to ensure a request comes from a trusted source.

For example, check_admin_referer(‘my_action’, ‘my_nonce’) validates form submissions. Freelancers use it for secure processing, while enterprise architects enforce it for system integrity.

22
Q

What is wp_ajax_ in plugin development?

A

wp_ajax_ is a prefix for hooks that handle AJAX requests in WordPress.

For example, add_action(‘wp_ajax_my_action’, ‘my_callback’) processes AJAX requests. Freelancers use it for dynamic features like live search, while enterprise architects implement it for scalable, real-time interactions.

23
Q

What is admin_post_ in plugin development?

A

admin_post_ is a prefix for hooks that handle form submissions in the admin area.

For example, add_action(‘admin_post_my_action’, ‘my_callback’) processes form data. Freelancers use it for plugin settings, while enterprise architects ensure secure, efficient form handling.

24
Q

What is the purpose of is_plugin_active()?

A

is_plugin_active() checks if a specific plugin is active.

For example, is_plugin_active(‘woocommerce/woocommerce.php’) checks for WooCommerce. Freelancers use it for compatibility, while enterprise architects ensure plugins integrate seamlessly in complex environments.

25
What is the best practice for securing WordPress plugins?
Use nonces, sanitize input, escape output, and follow WordPress coding standards. Functions like wp_nonce_field(), sanitize_text_field(), and esc_html() prevent vulnerabilities. Freelancers secure plugins for client trust, while enterprise architects enforce strict security for large-scale, high-stakes systems.