public function test_get_option() { $option_manager = new Hello_Kushimoto_Option_Manager(); $options = $option_manager->get_options(); $this->assertTrue(is_array($options)); $this->assertArrayHasKey('speaker', $options); }
public function options_page() { if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.')); } ?> <div id="hello_kushimoto" class="wrap"> <h2><?php _e('Hello Kushimoto', 'hello-kushimoto'); ?> </h2> <form method="post" action="options.php"> <?php settings_fields('hello_kushimoto_setting'); do_settings_sections('hello_kushimoto_setting'); $options = $this->option_manager->get_options(); $name = $this->option_manager->get_option_name(); ?> <table class="form-table"> <tbody> <tr> <th scope="row"><label for="<?php echo esc_attr($name); ?> "><?php _e('キャラクター設定', 'hello-kushimoto'); ?> </label></th> <td> <select name="<?php echo esc_attr($name); ?> [speaker]" id="<?php echo esc_attr($name); ?> "> <?php $current_speaker = $options['speaker']; $speakers = $this->get_speakers(); foreach ($speakers as $speaker) { $class_name = get_class($speaker); ?> <option value="<?php echo esc_attr($class_name); ?> " <?php selected($current_speaker, $class_name); ?> > <?php echo esc_html($speaker->whoami()); ?> </option> <?php } ?> </select> </td> </tr> </tbody> </table> <?php submit_button(); ?> </form> </div><!-- #hello_kushimoto --> <?php }