Problem sorting theme_mod array
-
Hi there,
I’m working on a thema with an extended customization panel. I’m creating a social media section, but the array of social media networks seen below is not being sorted correctly.
Maybe it’s because I didn’t put the values alphabetically first and now the old order is still being saved in some “hidden corner” of the system… When I do a
print_r()
of the sorted array, it’s being sorted correctly, but the output in the customization panel is not correct.Any idea? Thank you!
function mytheme_customize_extend( $wp_customize ) { /* Social Media customizer section */ $wp_customize->add_section( 'mytheme_section_socialmedia' , array( 'title' => __( 'Social Media Links', 'mytheme' ), 'priority' => 40, )); $social_media_settings = array('aim','behance','digg','dribbble','ember','evernote','facebook','flickr','forrst','github','googleplus','lastfm','linkedin','paypal','rss','sharethis','skype','soundcloud','tumblr','twitter','vimeo','wordpress','yahoo','youtube','zerply'); sort($social_media_settings); foreach($social_media_settings as $key => $setting) { $setting_shortname = 'link_'.$setting; $setting_output = ucfirst($setting); $setting_name = 'mytheme_theme_options['.$setting_shortname.']'; $wp_customize->add_setting($setting_name, array( 'default' => '', 'capability' => 'edit_theme_options', )); $wp_customize->add_control( new WP_Customize_Control($wp_customize, $setting_shortname, array( 'label' => sprintf(__( 'Link to %s page', 'mytheme' ).' '.$key, $setting_output), 'section' => 'mytheme_section_socialmedia', 'settings' => $setting_name, ))); } } add_action( 'customize_register', 'mytheme_customize_extend' );
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Problem sorting theme_mod array’ is closed to new replies.