GC_Customize_Selective_Refresh::add_dynamic_partials()
最后更新于:2021-11-27 07:57:39
GC_Customize_Selective_Refresh::add_dynamic_partials( string[]$partial_ids)Registers dynamically-created partials.
参数
- $partial_ids
-
(string[]) (Required) Array of the partial IDs to add.
响应
(GC_Customize_Partial[]) Array of added GC_Customize_Partial instances.
源文件
文件: gc-includes/customize/class-gc-customize-selective-refresh.php
public function add_dynamic_partials( $partial_ids ) {
$new_partials = array();
foreach ( $partial_ids as $partial_id ) {
// Skip partials already created.
$partial = $this->get_partial( $partial_id );
if ( $partial ) {
continue;
}
$partial_args = false;
$partial_class = 'GC_Customize_Partial';
/**
* Filters a dynamic partial's constructor arguments.
*
* For a dynamic partial to be registered, this filter must be employed
* to override the default false value with an array of args to pass to
* the GC_Customize_Partial constructor.
*
* @since 4.5.0
*
* @param false|array $partial_args The arguments to the GC_Customize_Partial constructor.
* @param string $partial_id ID for dynamic partial.
*/
$partial_args = apply_filters( 'customize_dynamic_partial_args', $partial_args, $partial_id );
if ( false === $partial_args ) {
continue;
}
/**
* Filters the class used to construct partials.
*
* Allow non-statically created partials to be constructed with custom GC_Customize_Partial subclass.
*
* @since 4.5.0
*
* @param string $partial_class GC_Customize_Partial or a subclass.
* @param string $partial_id ID for dynamic partial.
* @param array $partial_args The arguments to the GC_Customize_Partial constructor.
*/
$partial_class = apply_filters( 'customize_dynamic_partial_class', $partial_class, $partial_id, $partial_args );
$partial = new $partial_class( $this, $partial_id, $partial_args );
$this->add_partial( $partial );
$new_partials[] = $partial;
}
return $new_partials;
}