{"id":6100,"date":"2026-02-13T18:24:27","date_gmt":"2026-02-13T23:24:27","guid":{"rendered":"https:\/\/chubes.net\/?documentation=selective-refresh"},"modified":"2026-03-13T03:28:12","modified_gmt":"2026-03-13T07:28:12","slug":"selective-refresh","status":"publish","type":"documentation","link":"https:\/\/chubes.net\/docs\/wordpress-core\/customize-classes\/selective-refresh\/","title":{"rendered":"Selective Refresh"},"content":{"rendered":"<p>Classes for implementing selective (partial) refresh in the Customizer preview.<\/p><hr class=\"wp-block-separator\"\/><h2 class=\"wp-block-heading\">WP_Customize_Selective_Refresh<\/h2><p>Core class for implementing selective refresh. Manages partial registration and handles Ajax rendering requests.<\/p><p><strong>Source:<\/strong> <code>wp-includes\/customize\/class-wp-customize-selective-refresh.php<\/code><br \/>\n<strong>Since:<\/strong> 4.5.0<br \/>\n<strong>Final:<\/strong> Yes<br \/>\n<strong>Attributes:<\/strong> <code>#[AllowDynamicProperties]<\/code><\/p><h3 class=\"wp-block-heading\">Constants<\/h3><figure class=\"wp-block-table\"><table><thead><tr><th>Constant<\/th><th>Value<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>RENDER_QUERY_VAR<\/code><\/td><td><code>'wp_customize_render_partials'<\/code><\/td><td>POST query var used in partial render requests<\/td><\/tr><\/tbody><\/table><\/figure><h3 class=\"wp-block-heading\">Properties<\/h3><figure class=\"wp-block-table\"><table><thead><tr><th>Property<\/th><th>Type<\/th><th>Visibility<\/th><th>Default<\/th><th>Since<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$manager<\/code><\/td><td>WP_Customize_Manager<\/td><td>public<\/td><td>\u2014<\/td><td>4.5.0<\/td><td>Customize manager instance<\/td><\/tr><tr><td><code>$partials<\/code><\/td><td>WP_Customize_Partial[]<\/td><td>protected<\/td><td><code>array()<\/code><\/td><td>4.5.0<\/td><td>Registered partial instances<\/td><\/tr><tr><td><code>$triggered_errors<\/code><\/td><td>array<\/td><td>protected<\/td><td><code>array()<\/code><\/td><td>4.5.0<\/td><td>Log of errors during partial rendering<\/td><\/tr><tr><td><code>$current_partial_id<\/code><\/td><td>string|null<\/td><td>protected<\/td><td>\u2014<\/td><td>4.5.0<\/td><td>Currently-rendering partial ID<\/td><\/tr><\/tbody><\/table><\/figure><h3 class=\"wp-block-heading\">Methods<\/h3><figure class=\"wp-block-table\"><table><thead><tr><th>Method<\/th><th>Visibility<\/th><th>Since<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>__construct( $manager )<\/code><\/td><td>public<\/td><td>4.5.0<\/td><td>Stores manager, requires <code>class-wp-customize-partial.php<\/code>, hooks <code>init_preview<\/code> to <code>customize_preview_init<\/code>.<\/td><\/tr><tr><td><code>partials()<\/code><\/td><td>public<\/td><td>4.5.0<\/td><td>Returns all registered partials.<\/td><\/tr><tr><td><code>add_partial( $id, $args )<\/code><\/td><td>public<\/td><td>4.5.0<\/td><td>Adds a partial. Accepts <code>WP_Customize_Partial<\/code> object or ID + args. Applies <code>customize_dynamic_partial_args<\/code> and <code>customize_dynamic_partial_class<\/code> filters when constructing from args.<\/td><\/tr><tr><td><code>get_partial( $id )<\/code><\/td><td>public<\/td><td>4.5.0<\/td><td>Returns partial by ID, or <code>null<\/code>.<\/td><\/tr><tr><td><code>remove_partial( $id )<\/code><\/td><td>public<\/td><td>4.5.0<\/td><td>Removes a partial by ID.<\/td><\/tr><tr><td><code>init_preview()<\/code><\/td><td>public<\/td><td>4.5.0<\/td><td>Hooks <code>handle_render_partials_request<\/code> to <code>template_redirect<\/code> and <code>enqueue_preview_scripts<\/code> to <code>wp_enqueue_scripts<\/code>.<\/td><\/tr><tr><td><code>enqueue_preview_scripts()<\/code><\/td><td>public<\/td><td>4.5.0<\/td><td>Enqueues <code>customize-selective-refresh<\/code> script and hooks <code>export_preview_data<\/code> to <code>wp_footer<\/code> at priority 1000.<\/td><\/tr><tr><td><code>export_preview_data()<\/code><\/td><td>public<\/td><td>4.5.0<\/td><td>Exports partials JSON, <code>renderQueryVar<\/code>, and localized strings to JS via inline script <code>_customizePartialRefreshExports<\/code>. Switches to user locale for l10n.<\/td><\/tr><tr><td><code>add_dynamic_partials( $partial_ids )<\/code><\/td><td>public<\/td><td>4.5.0<\/td><td>Registers partials dynamically. For each ID, applies <code>customize_dynamic_partial_args<\/code> filter (must return non-false array) and <code>customize_dynamic_partial_class<\/code> filter. Returns array of newly-added partials.<\/td><\/tr><tr><td><code>is_render_partials_request()<\/code><\/td><td>public<\/td><td>4.5.0<\/td><td>Returns <code>true<\/code> if <code>$_POST[RENDER_QUERY_VAR]<\/code> is set.<\/td><\/tr><tr><td><code>handle_error( $errno, $errstr, $errfile, $errline )<\/code><\/td><td>public<\/td><td>4.5.0<\/td><td>Error handler during rendering. Logs error with partial ID, number, string, file, and line. Always returns <code>true<\/code>.<\/td><\/tr><tr><td><code>handle_render_partials_request()<\/code><\/td><td>public<\/td><td>4.5.0<\/td><td>Main Ajax handler. Validates customize preview, decodes <code>$_POST['partials']<\/code> JSON, registers dynamic partials, renders each partial for its container contexts, and sends JSON response with <code>contents<\/code>, <code>errors<\/code> (if <code>WP_DEBUG_DISPLAY<\/code>), and <code>setting_validities<\/code>.<\/td><\/tr><\/tbody><\/table><\/figure><h3 class=\"wp-block-heading\">Hooks<\/h3><figure class=\"wp-block-table\"><table><thead><tr><th>Hook<\/th><th>Type<\/th><th>Since<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>customize_dynamic_partial_args<\/code><\/td><td>filter<\/td><td>4.5.0<\/td><td>Filters dynamic partial constructor args. Must return non-false array for partial to be registered.<\/td><\/tr><tr><td><code>customize_dynamic_partial_class<\/code><\/td><td>filter<\/td><td>4.5.0<\/td><td>Filters the class used to construct partials. Default <code>'WP_Customize_Partial'<\/code>.<\/td><\/tr><tr><td><code>customize_render_partials_before<\/code><\/td><td>action<\/td><td>4.5.0<\/td><td>Fires immediately before partials are rendered. Plugins can enqueue scripts\/styles here.<\/td><\/tr><tr><td><code>customize_render_partials_after<\/code><\/td><td>action<\/td><td>4.5.0<\/td><td>Fires immediately after partials are rendered. Plugins can scrape footer scripts here.<\/td><\/tr><tr><td><code>customize_render_partials_response<\/code><\/td><td>filter<\/td><td>4.5.0<\/td><td>Filters the response array. Plugins can inject <code>$scripts<\/code> and <code>$styles<\/code> dependencies.<\/td><\/tr><\/tbody><\/table><\/figure><h3 class=\"wp-block-heading\">Localized Strings (exported to JS)<\/h3><figure class=\"wp-block-table\"><table><thead><tr><th>Key<\/th><th>Text<\/th><\/tr><\/thead><tbody><tr><td><code>shiftClickToEdit<\/code><\/td><td>&quot;Shift-click to edit this element.&quot;<\/td><\/tr><tr><td><code>clickEditMenu<\/code><\/td><td>&quot;Click to edit this menu.&quot;<\/td><\/tr><tr><td><code>clickEditWidget<\/code><\/td><td>&quot;Click to edit this widget.&quot;<\/td><\/tr><tr><td><code>clickEditTitle<\/code><\/td><td>&quot;Click to edit the site title.&quot;<\/td><\/tr><tr><td><code>clickEditMisc<\/code><\/td><td>&quot;Click to edit this element.&quot;<\/td><\/tr><tr><td><code>badDocumentWrite<\/code><\/td><td>&quot;document.write() is forbidden&quot;<\/td><\/tr><\/tbody><\/table><\/figure><hr class=\"wp-block-separator\"\/><h2 class=\"wp-block-heading\">WP_Customize_Partial<\/h2><p>Representation of a rendered region in the previewed page that gets selectively refreshed when an associated setting changes.<\/p><p><strong>Source:<\/strong> <code>wp-includes\/customize\/class-wp-customize-partial.php<\/code><br \/>\n<strong>Since:<\/strong> 4.5.0<br \/>\n<strong>Attributes:<\/strong> <code>#[AllowDynamicProperties]<\/code><\/p><h3 class=\"wp-block-heading\">Properties<\/h3><figure class=\"wp-block-table\"><table><thead><tr><th>Property<\/th><th>Type<\/th><th>Visibility<\/th><th>Default<\/th><th>Since<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$component<\/code><\/td><td>WP_Customize_Selective_Refresh<\/td><td>public<\/td><td>\u2014<\/td><td>4.5.0<\/td><td>Parent selective refresh component<\/td><\/tr><tr><td><code>$id<\/code><\/td><td>string<\/td><td>public<\/td><td>\u2014<\/td><td>4.5.0<\/td><td>Unique identifier. Typically matches the associated setting ID.<\/td><\/tr><tr><td><code>$id_data<\/code><\/td><td>array<\/td><td>protected<\/td><td>\u2014<\/td><td>4.5.0<\/td><td>Parsed ID with <code>base<\/code> and <code>keys<\/code> for multidimensional settings<\/td><\/tr><tr><td><code>$type<\/code><\/td><td>string<\/td><td>public<\/td><td><code>'default'<\/code><\/td><td>4.5.0<\/td><td>Partial type<\/td><\/tr><tr><td><code>$selector<\/code><\/td><td>string<\/td><td>public<\/td><td>\u2014<\/td><td>4.5.0<\/td><td>jQuery selector to find the container element<\/td><\/tr><tr><td><code>$settings<\/code><\/td><td>string[]<\/td><td>public<\/td><td>\u2014<\/td><td>4.5.0<\/td><td>IDs for settings tied to this partial. Defaults to <code>[$id]<\/code>.<\/td><\/tr><tr><td><code>$primary_setting<\/code><\/td><td>string<\/td><td>public<\/td><td>\u2014<\/td><td>4.5.0<\/td><td>ID of the primary setting. Defaults to first setting.<\/td><\/tr><tr><td><code>$capability<\/code><\/td><td>string<\/td><td>public<\/td><td>\u2014<\/td><td>4.5.0<\/td><td>Required capability. Empty = derived from settings.<\/td><\/tr><tr><td><code>$render_callback<\/code><\/td><td>callable<\/td><td>public<\/td><td>\u2014<\/td><td>4.5.0<\/td><td>Render callback. Called with <code>($partial, $container_context)<\/code>. Can echo or return string\/array, or return <code>false<\/code> on error. Defaults to <code>[$this, 'render_callback']<\/code>.<\/td><\/tr><tr><td><code>$container_inclusive<\/code><\/td><td>bool<\/td><td>public<\/td><td><code>false<\/code><\/td><td>4.5.0<\/td><td>Whether the container element is included in the partial<\/td><\/tr><tr><td><code>$fallback_refresh<\/code><\/td><td>bool<\/td><td>public<\/td><td><code>true<\/code><\/td><td>4.5.0<\/td><td>Whether to do a full refresh if partial render fails<\/td><\/tr><\/tbody><\/table><\/figure><h3 class=\"wp-block-heading\">Methods<\/h3><figure class=\"wp-block-table\"><table><thead><tr><th>Method<\/th><th>Visibility<\/th><th>Since<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>__construct( $component, $id, $args )<\/code><\/td><td>public<\/td><td>4.5.0<\/td><td>Accepts args matching property names. Parses ID into <code>id_data<\/code>. Defaults <code>render_callback<\/code> to <code>$this-&gt;render_callback()<\/code>. Normalizes <code>$settings<\/code> to array; defaults to <code>[$id]<\/code>. Sets <code>$primary_setting<\/code> to first setting if empty.<\/td><\/tr><tr><td><code>id_data()<\/code><\/td><td>public final<\/td><td>4.5.0<\/td><td>Returns parsed <code>$id_data<\/code> array with <code>base<\/code> and <code>keys<\/code>.<\/td><\/tr><tr><td><code>render( $container_context )<\/code><\/td><td>public final<\/td><td>4.5.0<\/td><td>Calls <code>$render_callback<\/code>, captures output buffer. Warns if callback both echoes and returns. Applies <code>customize_partial_render<\/code> and <code>customize_partial_render_{$partial-&gt;id}<\/code> filters. Returns string, array, or <code>false<\/code>.<\/td><\/tr><tr><td><code>render_callback( $partial, $context )<\/code><\/td><td>public<\/td><td>4.5.0<\/td><td>Default callback \u2014 returns <code>false<\/code> (no render). Subclasses override this.<\/td><\/tr><tr><td><code>json()<\/code><\/td><td>public<\/td><td>4.5.0<\/td><td>Returns array with <code>settings<\/code>, <code>primarySetting<\/code>, <code>selector<\/code>, <code>type<\/code>, <code>fallbackRefresh<\/code>, <code>containerInclusive<\/code>.<\/td><\/tr><tr><td><code>check_capabilities()<\/code><\/td><td>public final<\/td><td>4.5.0<\/td><td>Returns <code>false<\/code> if user lacks <code>$capability<\/code> or if any associated setting fails <code>check_capabilities()<\/code>.<\/td><\/tr><\/tbody><\/table><\/figure><h3 class=\"wp-block-heading\">Hooks<\/h3><figure class=\"wp-block-table\"><table><thead><tr><th>Hook<\/th><th>Type<\/th><th>Since<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>customize_partial_render<\/code><\/td><td>filter<\/td><td>4.5.0<\/td><td>Filters partial rendering result. Params: <code>$rendered<\/code>, <code>$partial<\/code>, <code>$container_context<\/code>.<\/td><\/tr><tr><td><code>customize_partial_render_{$partial-&gt;id}<\/code><\/td><td>filter<\/td><td>4.5.0<\/td><td>Filters partial rendering for a specific partial ID. Same params.<\/td><\/tr><\/tbody><\/table><\/figure>","protected":false},"excerpt":{"rendered":"<p>Classes for implementing selective (partial) refresh in the Customizer preview. WP_Customize_Selective_Refresh Core class for implementing selective refresh. Manages partial registration and handles Ajax rendering requests. Source: wp-includes\/customize\/class-wp-customize-selective-refresh.php Since: 4.5.0 Final:&#8230;<\/p>\n","protected":false},"featured_media":0,"template":"","meta":{"footnotes":""},"tags":[],"project":[756],"project_type":[749],"class_list":["post-6100","documentation","type-documentation","status-publish","hentry","project-customize-classes","project_type-wordpress-reference"],"project_info":{"id":589,"name":"WordPress Core","slug":"wordpress-core"},"project_type_info":{"id":749,"name":"WordPress Reference","slug":"wordpress-reference"},"_links":{"self":[{"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/documentation\/6100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/documentation"}],"about":[{"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/types\/documentation"}],"version-history":[{"count":2,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/documentation\/6100\/revisions"}],"predecessor-version":[{"id":7322,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/documentation\/6100\/revisions\/7322"}],"wp:attachment":[{"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/media?parent=6100"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/tags?post=6100"},{"taxonomy":"project","embeddable":true,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/project?post=6100"},{"taxonomy":"project_type","embeddable":true,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/project_type?post=6100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}