我正在使用Customize Posts 和Customize Object Selector WordPress自定义程序插件。
自定义帖子编辑链接在初始页面加载时显示在预览中,但不会应用于通过选择性刷新添加到页面的部分。有没有办法将编辑链接添加到刷新的分区中?
我使用php创建的设置以及动态创建的JavaScript设置。下面是一个使用php创建的设置的快速示例:
namespace MyTheme\\Customizer;
add_filter( \'customize_register\', __NAMESPACE__ . \'\\\\register\', 30 );
function register( \\WP_Customize_Manager $wp_customize ) {
$wp_customize->add_section( \'theme_options\', array(
\'title\' => __( \'Theme options\', \'mytheme\' ),
\'priority\' => 130, // Before Additional CSS.
) );
$wp_customize->add_setting( \'selected_posts\', array(
\'default\' => [],
\'transport\' => \'postMessage\',
\'sanitize_callback\' => __NAMESPACE__ . \'\\\\sanitize_ids\',
) );
$selected_posts = new \\CustomizeObjectSelector\\Control( $wp_customize, \'selected_posts\', array(
\'label\' => __( \'Posts\', \'mytheme\' ),
\'section\' => \'theme_options\',
\'post_query_vars\' => array(
\'post_type\' => \'post\',
\'post_status\' => \'publish\',
),
\'select2_options\' => array(
\'multiple\' => true,
\'allowClear\' => true,
\'placeholder\' => __( \'— Select —\', \'default\' ),
),
) );
$wp_customize->add_control( $selected_posts );
$wp_customize->selective_refresh->add_partial( \'selected_posts\', array(
\'selector\' => \'.editorsPicks\',
\'render_callback\' => __NAMESPACE__ . \'\\\\customize_partial_selected_posts\',
\'container_inclusive\' => true,
\'fallback_refresh\' => false,
) );
}
/**
* Sanitize IDs
*
* @param array $ids An array of IDs.
* @return array A sanitized array of IDs.
*/
function sanitize_ids( $ids ) {
return array_map( \'intval\', $ids );
}
function customize_partial_selected_posts() {
get_template_part( \'partials/layouts/editors-picks\' );
}