Using WordPress ‘install_theme_information()’ PHP function

The install_theme_information() WordPress PHP function displays theme information in a dialog box form.

Usage

To use the install_theme_information() function, simply call it:

install_theme_information();

Parameters

  • There are no parameters for this function.

More information

See WordPress Developer Resources: install_theme_information()

Examples

Display Theme Information Dialog

In this example, the install_theme_information() function is used to display theme information in a dialog box.

// Call the function to display the theme information dialog
install_theme_information();

Display Theme Information on Admin Page

This example shows how to use the install_theme_information() function to display theme information on a custom admin page.

// Create a custom admin page
add_action('admin_menu', 'my_admin_menu');
function my_admin_menu() {
    add_menu_page('Theme Information', 'Theme Information', 'manage_options', 'theme-information', 'display_theme_information');
}

// Display theme information on the custom admin page
function display_theme_information() {
    install_theme_information();
}

Display Theme Information on Theme Activation

In this example, the install_theme_information() function is called when a theme is activated, displaying the theme information dialog.

add_action('after_switch_theme', 'show_theme_information');
function show_theme_information() {
    install_theme_information();
}

Display Theme Information on a Shortcode

This example demonstrates how to use the install_theme_information() function with a shortcode to display theme information.

add_shortcode('theme_information', 'shortcode_theme_information');
function shortcode_theme_information() {
    ob_start();
    install_theme_information();
    return ob_get_clean();
}

Display Theme Information on a Custom Button Click

In this example, the install_theme_information() function is triggered when a custom button is clicked.

// Enqueue script to handle the button click
add_action('admin_enqueue_scripts', 'my_enqueue_scripts');
function my_enqueue_scripts() {
    wp_enqueue_script('my-script-handle', get_template_directory_uri() . '/js/my-script.js', array('jquery'), '1.0', true);
}

// Add the custom button
add_action('admin_notices', 'add_custom_button');
function add_custom_button() {
    echo '<button id="theme-information-button">Show Theme Information</button>';
}

// Display theme information when the custom button is clicked
add_action('wp_ajax_show_theme_information', 'ajax_show_theme_information');
function ajax_show_theme_information() {
    install_theme_information();
    wp_die();
}

my-script.js

jQuery(document).ready(function ($) {
    $('#theme-information-button').click(function () {
        $.post(ajaxurl, { action: 'show_theme_information' });
    });
});