You need to start by adding the register
action and then add section
, setting
and control
. Be sure the change the $my_theme to your theme’s slug so this options only show up on your theme.
class SampleAddonCustomizer {
public $my_theme="enter-your-theme-slug-here"; // <- Enter your theme slug here
public function hooks() {
$current_theme = wp_get_theme();
if( $current_theme->template == $this->my_theme ) {
add_action( 'customize_register', array( $this, 'register' ), 99 );
}
}
public function register( $wp_customize ) {
$wp_customize->add_section( 'my_custom_section_links', array(
'capability' => 'edit_theme_options',
'priority' => 50,
'title' => __( 'Index/Archive', 'sample-customizer-addon' )
) );
$wp_customize->add_setting( 'special', array(
'capability' => 'edit_theme_options',
'type' => 'hidden',
'autoload' => false
) );
$wp_customize->add_control( 'special', array(
'label' => 'Links to settings',
'description' => $this->get_links(),
'section' => 'my_custom_section_links',
'type' => 'hidden',
) );
}
public function get_links() {
$links = array(
array('url' => 'http://example.com/', 'text' => 'Example', 'desc' => 'Just an example'),
array('url' => 'https://yahoo.com/', 'text' => 'Yahoo!', 'desc' => 'More entertainment'),
array('url' => 'https://google.com/', 'text' => 'Google', 'desc' => 'Just Search'),
array('url' => 'https://bing.com/', 'text' => 'Bing', 'desc' => 'Nice pictures'),
);
$html="";
foreach ($links as $link) {
$html .= '<p>'.$link['desc'].'<br>'.PHP_EOL;
$html .= sprintf('<a href="https://wordpress.stackexchange.com/questions/280385/%s">%s</a>', $link['url'], $link['text']) . '<br>' . PHP_EOL;
$html .= '</p>'.PHP_EOL;
}
return $html;
}
}
$sampleAddonCustomizer = new SampleAddonCustomizer();
$sampleAddonCustomizer->hooks();