/** * Outputs the options form on admin * * @param array $instance The widget options */ public function form($instance) { $title = esc_attr($instance['title']); $demo_instr = esc_attr($instance['demo_instr']); $dmo_btn_cta = esc_attr(empty($instance['dmo_btn_cta']) ? 'Go!' : $instance['dmo_btn_cta']); $demo_setup_id = empty($instance['demo_setup_id']) ? 0 : (int) $instance['demo_setup_id']; $qs_admin = qSandbox_Admin::get_instance(); $opts = $qs_admin->get_options(); $api_obj = qSandbox_API::get_instance(); $setups_result_obj = $api_obj->get_demo_setups($opts['api_key']); $dropdown_elements = qSandbox_Util::array2dropdown_array($setups_result_obj->data('items')); // if present we'll use it otherwise we'll default to the first element's ID. $sel_demo_id = empty($demo_setup_id) ? array_shift(array_keys($dropdown_elements)) : $sel_demo_id; ?> <p> <label for="<?php echo $this->get_field_id('demo_setup_id'); ?> "><?php _e('Demo Setup:'); ?> </label> <?php echo qSandbox_Util::html_select($this->get_field_name('demo_setup_id'), $sel_demo_id, $dropdown_elements, sprintf('id="%s"', $this->get_field_id('demo_setup_id'))); ?> </p> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " placeholder="Optional" name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo $title; ?> " /> </p> <p> <label for="<?php echo $this->get_field_id('demo_instr'); ?> "><?php _e('Demo Instructions'); ?> </label> <textarea class="widefat" id="<?php echo $this->get_field_id('demo_instr'); ?> " name="<?php echo $this->get_field_name('demo_instr'); ?> " rows="3" placeholder="Try our cool themes." ><?php echo $demo_instr; ?> </textarea> <div> Text and HTML allowed <?php echo htmlentities($this->allowed_tags_str); ?> </div> </p> <p class="submit_button_wrapper"> <label for="<?php echo $this->get_field_id('dmo_btn_cta'); ?> "><?php _e('Demo Button Label (Call to Action)'); ?> </label> <input class="submit_button widefat" id="<?php echo $this->get_field_id('dmo_btn_cta'); ?> " placeholder="Enter some text" name="<?php echo $this->get_field_name('dmo_btn_cta'); ?> " type="text" value="<?php echo $dmo_btn_cta; ?> " /> </p> <?php }
<?php $qs_admin = qSandbox_Admin::get_instance(); add_action('init', array($qs_admin, 'init')); class qSandbox_Admin { private function __construct() { } /** * qSandbox_Admin::get_instance(); * Singleton * @staticvar obj $instance * @return \cls */ public static function get_instance() { static $instance = null; if (is_null($instance)) { $cls = __CLASS__; $instance = new $cls(); } return $instance; } /** * */ public function init() { $suffix = ''; /*wp_enqueue_script( 'jquery' );