Adds a partial.
Description
See also
Parameters
$id
WP_Customize_Partial|stringrequired- Customize Partial object, or Partial ID.
$args
arrayoptional- Array of properties for the new Partials object.
See WP_Customize_Partial::__construct() for information on accepted arguments.Default:
array()
Source
public function add_partial( $id, $args = array() ) {
if ( $id instanceof WP_Customize_Partial ) {
$partial = $id;
} else {
$class = 'WP_Customize_Partial';
/** This filter is documented in wp-includes/customize/class-wp-customize-selective-refresh.php */
$args = apply_filters( 'customize_dynamic_partial_args', $args, $id );
/** This filter is documented in wp-includes/customize/class-wp-customize-selective-refresh.php */
$class = apply_filters( 'customize_dynamic_partial_class', $class, $id, $args );
$partial = new $class( $this, $id, $args );
}
$this->partials[ $partial->id ] = $partial;
return $partial;
}
Hooks
- apply_filters( ‘customize_dynamic_partial_args’,
false|array $partial_args ,string $partial_id ) Filters a dynamic partial’s constructor arguments.
- apply_filters( ‘customize_dynamic_partial_class’,
string $partial_class ,string $partial_id ,array $partial_args ) Filters the class used to construct partials.
Changelog
Version | Description |
---|---|
4.5.0 | Introduced. |
In case you wonder why the pencil icon is not showing in your theme (and maybe the “Shift-click to edit this element.” title does), it might be because you chose an “illegal” container selector to place it in. E.g:
If you look into
customize-selective-refresh.js
you will find that the “illegal” selectors areIn other words, you need to be sure that whatever element you point to as the container for the pencil icon is not one of those (not an image, not a hr, etc).