示例#1
0
 /**
  * @return \WP_Widget
  */
 public function get_widget_instance()
 {
     if (is_null($this->_widget_instance)) {
         global $wp_widget_factory;
         if (isset($wp_widget_factory->widgets[$this->_widget_name])) {
             $this->_widget_instance = $wp_widget_factory->widgets[$this->_widget_name];
             $this->_widget_instance->_set('REPLACE_TO_ID');
         } elseif (class_exists($this->_widget_name)) {
             $this->_widget_instance = new $this->_widget_name();
             $this->_widget_instance->_set('REPLACE_TO_ID');
         }
     }
     return $this->_widget_instance;
 }
示例#2
0
 /**
  * @see WP_Widget::get_field_id()
  */
 function test_wp_widget_get_field_id()
 {
     $widget = new WP_Widget('foo', 'Foo');
     $widget->_set(2);
     $this->assertEquals('widget-foo-2-title', $widget->get_field_id('title'));
 }
示例#3
0
 /**
  * @see WP_Widget::get_field_id()
  * @dataProvider data_wp_widget_get_field_id
  *
  */
 function test_wp_widget_get_field_id($expected, $value_to_test)
 {
     $widget = new WP_Widget('foo', 'Foo');
     $widget->_set(2);
     $this->assertEquals($expected, $widget->get_field_id($value_to_test));
 }