WP Customizer

WP Customizer Install Statistics

0
100%
Today: 0 Yesterday: 0 All-time: 3,880 downloads
WP Customizer Icon

Try plugin: WP Customizer

We'll create fresh WordPress site with WP Customizer installed. You have 20 minutes to test the plugin after that site we'll be deleted.

Takes ~10 seconds to install.

About WP Customizer

Easily load site specific functions, scripts and CSS files into your site without editing your theme's functions.php or other source files.

2


0


0


0


0

updated: 7 years ago
since: 11 years ago
author: Gary Gale

Description

This plugin allows you to manage and load site specific functions, scripts and CSS files into your WordPress site without the need to edit your theme’s functions.php or any other source file.

Settings and options include:

  1. Choose the type of customization you want to load; functions, scripts, CSS in any combination.
  2. Choose where you want the customizations to load; in the WordPress front-end, in the WordPress admin screens or both.
  3. Choose where you want to store your customization files, without the need to add to or modify your theme’s or your plugin’s source files.

Filter Support And Usage

WP Customizer supports multiple filters; the plugin’s filters allow you to

  • modify the set of functions files that are about to be loaded
  • modify the set of script files that are about to be loaded
  • modify the characteristics of each script file that is about to be loaded and which will be passed as arguments to wp_enqueue_script
  • modify the set of CSS files that are about to be loaded
  • modify the characteristics of each CSS file that is about to be loaded and which will be passed as arguments to wp_enqueue_style

Each filter will be only be called if the customization type is enabled in the plugin’s options; if a customization type is enabled but no files are found to be loaded, the filter will still be called but will be passed an empty argument.

As with all WordPress filters, any filter hook function should either return the modified argument or the original argument if no modification were made.

wp_customizer_functions, wp_customizer_admin_functions, wp_customizer_common_functions

The functions filters are called when preparing to load the list of front-end functions (wp_customizer_functions), of admin functions (wp_customizer_admin_functions) and of common functions (wp_customizer_common_functions). The arguments that each filter hook function receives is identical in all cases. The filter hook function takes a single argument which is an array of file names.

Example: Prevent all function files from loading by returning an empty file list.

add_filter('wp_customizer_functions', 'function_handler', 10, 1);

function function_handler($files) {
    // $files = array(
    //      array(
    //          'file' => (absolute path of function file)
    //      ),
    //      array(...)
    //  );

    return array();
}

wp_customizer_scripts, wp_customizer_admin_scripts, wp_customizer_common_scripts

The scripts filters are called when preparing to load the list of front-end scripts (wp_customizer_scripts), of admin scripts (wp_customizer_admin_scripts) and of common scripts (wp_customizer_common_scripts). The arguments that each filter hook function receives is identical in all cases. The filter hook function takes a single argument which is an array of file details.

Example: Add jQuery as a dependency to all scripts and enable each script to load in the post’s footer.

add_filter('wp_customizer_scripts', 'script_handler', 10, 1);

function script_handler($files) {
    // $files = array(
    //      array(
    //          'file' => (absolute path of script file),
    //          'handle' => (auto-generated handle for script),
    //          'src' => (URL of script file),
    //          'deps' => (dependencies, defaults to an empty array),
    //          'ver' => (version, defaults to false),
    //          'in_footer' => (load in footer, defaults to false),
    //      ),
    //      array(...)
    // );

    foreach ($files as $file) {
        $file['deps'] = array('jquery');
        $file['in_footer'] = true;
    }

    return $files;
}

wp_customizer_css, wp_customizer_admin_css, wp_customizer_common_css

The CSS filters are called when preparing to load the list of front-end CSS (wp_customizer_css), of admin CSS (wp_customizer_admin_css) and of common CSS (wp_customizer_common_css). The arguments that each filter hook function receives is identical in all cases. The filter hook function takes a single argument which is an array of file details.

Example: Override the media type for all CSS files to use the screen media type.

add_filter('wp_customizer_css', 'css_handler', 10, 1);

function css_handler($files) {
    // $files = array(
    //      array(
    //          'file' => (absolute path of css file),
    //          'handle' => (auto-generated handle for CSS),
    //          'src' => (URL of CSS file),
    //          'deps' => (dependencies, defaults to an empty array),
    //          'ver' => (version, defaults to false),
    //          'media' => (media type, defaults to 'all')
    //      ),
    //      array(...)
    // );

    foreach ($files as $file) {
        $file['media'] = 'screen';
    }

    return $files;
}