Using WordPress ‘install_plugins_favorites_form()’ PHP function

The install_plugins_favorites_form() WordPress PHP function displays a username form for the favorites page.

Usage

install_plugins_favorites_form();

Parameters

  • None

More information

See WordPress Developer Resources: install_plugins_favorites_form

Examples

Display the form for a user’s favorite plugins

This example shows how to use the install_plugins_favorites_form() function to display the form for a user’s favorite plugins.

function show_favorites_form() {
    install_plugins_favorites_form();
}
add_action('admin_menu', 'show_favorites_form');

Create a shortcode to display the favorites form

This example demonstrates how to create a shortcode [favorites_form] that can be used in posts or pages to display the favorites form.

function favorites_form_shortcode() {
    ob_start();
    install_plugins_favorites_form();
    return ob_get_clean();
}
add_shortcode('favorites_form', 'favorites_form_shortcode');

Display the favorites form in a custom admin page

This example shows how to create a custom admin page and display the favorites form inside it.

function create_custom_admin_page() {
    add_menu_page('Favorites Form', 'Favorites Form', 'manage_options', 'favorites_form', 'display_favorites_form');
}
add_action('admin_menu', 'create_custom_admin_page');

function display_favorites_form() {
    install_plugins_favorites_form();
}

Add the favorites form to the customizer

This example demonstrates how to add the favorites form to the customizer.

function add_favorites_form_to_customizer($wp_customize) {
    $wp_customize->add_section('favorites_form_section', array(
        'title' => 'Favorites Form',
    ));

    $wp_customize->add_setting('favorites_form_setting', array(
        'default' => '',
    ));

    $wp_customize->add_control('favorites_form_control', array(
        'label' => 'Username',
        'section' => 'favorites_form_section',
        'settings' => 'favorites_form_setting',
        'type' => 'text',
    ));
}
add_action('customize_register', 'add_favorites_form_to_customizer');

Display the favorites form on a custom page template

This example shows how to create a custom page template and display the favorites form inside it.

/**
 * Template Name: Custom Favorites Form Page
 */

get_header();

echo '<div class="favorites-form-wrapper">';
install_plugins_favorites_form();
echo '</div>';

get_footer();