I have a problem, I create my panel in a normal way, but when I see it after 1 second it disappears, I do not understand what is happening, does anyone know why?
Link Video: http://recordit.co/poHGr09I3d
My code:
add_action( 'customize_register', 'add_custom2' );
function add_custom2( $wp_customize ){
/**
* Add Header Settings Panel
*/
$wp_customize->add_panel(
'pf-panel-test-1',
array(
'priority' => 10,
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => esc_html__( 'Header PX', 'faceblog' ),
)
);
/**
* Header Menu Section
*/
$wp_customize->add_section(
'pf-section-01',
array(
'title' => esc_html__( 'Menu PX', 'faceblog' ),
'priority' => 20,
'panel' => 'pf-panel-test-1'
)
);
// Menu Featured Image
$wp_customize->add_setting(
'pf-algo-set-01',
array(
'default' => '',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
'pf-algo-set-01',
array(
'type' => 'text',
'label' => esc_html__( 'About Us link text', 'faceblog' ),
'section' => 'pf-section-01',
//'settings'=> 'pf-algo-set-01',
'priority' => 20,
)
);
}
UPDATE & RESOLVE
1) I am using this function
if( is_admin() || is_customize_preview() )
add_action( 'customize_register', array( &$this, 'add_customizer_fields') );
else
return false;
I thought it would help me to optimize that it only show when it is in the administrator area, but it is not so, in the web page this returns false
I add this:
if(!function_exists('wp_get_current_user')) {
include(ABSPATH . "wp-includes/pluggable.php");
}
$is_user_admin = current_user_can('administrator');
if( is_admin() || is_customize_preview() || $is_user_admin )
add_action( 'customize_register', array( &$this, 'add_customizer_fields') );
else
return false;
With this it makes it enter when it is an administrator user and already it works.