WP_Customize_Partial::__construct( WP_Customize_Selective_Refresh $component, string $id, array $args = array() )
Constructor.
Description
Supplied $args
override class property defaults.
If $args['settings']
is not defined, use the $id as the setting ID.
Parameters
- $component
-
(Required) Customize Partial Refresh plugin instance.
- $id
-
(Required) Control ID.
- $args
-
(Optional) Array of properties for the new Partials object. <br>
- 'type'
(string) Type of the partial to be created.<br> - 'selector'
(string) The jQuery selector to find the container element for the partial, that is, a partial's placement.<br> - 'settings'
(string[]) IDs for settings tied to the partial. If undefined,$id
will be used.<br> - 'primary_setting'
(string) The ID for the setting that this partial is primarily responsible for rendering. If not supplied, it will default to the ID of the first setting.<br> - 'capability'
(string) Capability required to edit this partial.<br> Normally this is empty and the capability is derived from the capabilities of the associated$settings
.<br> - 'render_callback'
(callable) Render callback.<br> Callback is called with one argument, the instance of WP_Customize_Partial.<br> The callback can either echo the partial or return the partial as a string, or return false if error.<br> - 'container_inclusive'
(bool) Whether the container element is included in the partial, or if only the contents are rendered.<br> - 'fallback_refresh'
(bool) Whether to refresh the entire preview in case a partial cannot be refreshed.<br> A partial render is considered a failure if the render_callback returns false.<br>
Default value: array()
- 'type'
Source
File: wp-includes/customize/class-wp-customize-partial.php
public function __construct( WP_Customize_Selective_Refresh $component, $id, $args = array() ) {
$keys = array_keys( get_object_vars( $this ) );
foreach ( $keys as $key ) {
if ( isset( $args[ $key ] ) ) {
$this->$key = $args[ $key ];
}
}
$this->component = $component;
$this->id = $id;
$this->id_data['keys'] = preg_split( '/\[/', str_replace( ']', '', $this->id ) );
$this->id_data['base'] = array_shift( $this->id_data['keys'] );
if ( empty( $this->render_callback ) ) {
$this->render_callback = array( $this, 'render_callback' );
}
// Process settings.
if ( ! isset( $this->settings ) ) {
$this->settings = array( $id );
} else if ( is_string( $this->settings ) ) {
$this->settings = array( $this->settings );
}
if ( empty( $this->primary_setting ) ) {
$this->primary_setting = current( $this->settings );
}
}
Changelog
Version | Description |
---|---|
4.5.0 | Introduced. |