Что делают операторы selective_refresh и add_partial
Установил wordpress тему Newses из репозитория. В файле C:\OSPanel\domains\myfirstwpsite.ru\wp-content\themes\newses\inc\ansar\customize\customizer.php есть код
d postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function newses_customize_register($wp_customize) {
// Load customize controls.
require get_template_directory().'/inc/ansar/customize/customizer-control.php';
// Load customize sanitize.
require get_template_directory().'/inc/ansar/customize/customizer-sanitize.php';
$wp_customize->get_setting('blogname')->transport = 'postMessage';
$wp_customize->get_setting('blogdescription')->transport = 'postMessage';
$wp_customize->get_setting('header_textcolor')->transport = 'postMessage';
if (isset($wp_customize->selective_refresh)) {
$wp_customize->selective_refresh->add_partial('blogname', array(
'selector' => '.site-title a',
'render_callback' => 'newses_customize_partial_blogname',
));
$wp_customize->selective_refresh->add_partial('blogdescription', array(
'selector' => '.site-description',
'render_callback' => 'newses_customize_partial_blogdescription',
));
$wp_customize->selective_refresh->add_partial('newses_header_fb_link', array(
'selector' => '.mg-headwidget .mg-head-detail .info-right',
'render_callback' => 'newses_customize_partial_newses_header_fb_link',
));
$wp_customize->selective_refresh->add_partial('banner_advertisement_section', array(
'selector' => '.header-ads',
'render_callback' => 'newses_customize_partial_banner_advertisement_section',
));
$wp_customize->selective_refresh->add_partial('select_slider_news_category', array(
'selector' => '.homemain',
'render_callback' => '.newses_customize_partial_select_slider_news_category',
));
$wp_customize->selective_refresh->add_partial('latest_tab_title', array(
'selector' => '.top-right-area .nav-tabs',
'render_callback' => '.newses_customize_partial_latest_tab_title',
));
$wp_customize->selective_refresh->add_partial('show_popular_tags_title', array(
'selector' => '.mg-tpt-txnlst strong',
'render_callback' => 'newses_customize_partial_show_popular_tags_title',
));
$wp_customize->selective_refresh->add_partial('newses_date_time_show_type', array(
'selector' => '.mg-head-detail .info-left li',
'render_callback' => 'newses_customize_partial_newses_date_time_show_type',
));
$wp_customize->selective_refresh->add_partial('flash_news_title', array(
'selector' => '.mg-latest-news .bn_title h2',
'render_callback' => 'newses_customize_partial_flash_news_title',
));
$wp_customize->selective_refresh->add_partial('trending_post_title', array(
'selector' => '.recentarea .mg-sec-title h4',
'render_callback' => 'newses_customize_partial_trending_section_title',
));
$wp_customize->selective_refresh->add_partial('you_missed_title', array(
'selector' => '.missed-inner .mg-sec-title h4',
'render_callback' => 'newses_customize_partial_you_missed_title',
));
$wp_customize->selective_refresh->add_partial('header_search_enable', array(
'selector' => '.mg-search-box',
'render_callback' => 'newses_customize_partial_header_search_enable',
));
$wp_customize->selective_refresh->add_partial('newses_footer_fb_link', array(
'selector' => '.mg-social',
'render_callback' => 'newses_customize_partial_newses_footer_fb_link',
));
}
- Что делают операторы
$wp_customize->selective_refresh->add_partial(...)? - А что такое
.site-title aи в каком файле его можно найти?
Ответы (1 шт):
Автор решения: lezhni
→ Ссылка
Позволяет задать элемент кастомайзера, который может обновляться самостоятельно (без полного обновления страницы), что позволяет немного быстрее отображать изменения. https://florianbrinkmann.com/en/selective-refresh-customizer-3790