Changeset 51216
- Timestamp:
- 06/23/2021 01:33:20 AM (3 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-widget-factory.php
r50995 r51216 113 113 */ 114 114 public function get_widget_object( $id_base ) { 115 foreach ( $this->widgets as $widget_object ) { 115 $key = $this->get_widget_key( $id_base ); 116 if ( '' === $key ) { 117 return null; 118 } 119 120 return $this->widgets[ $key ]; 121 } 122 123 /** 124 * Returns the registered key for the given widget type. 125 * 126 * @since 5.8.0 127 * 128 * @param string $id_base Widget type ID. 129 * @return string 130 */ 131 public function get_widget_key( $id_base ) { 132 foreach ( $this->widgets as $key => $widget_object ) { 116 133 if ( $widget_object->id_base === $id_base ) { 117 return $ widget_object;134 return $key; 118 135 } 119 136 } 120 137 121 return null;138 return ''; 122 139 } 123 140 } -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php
r51183 r51216 472 472 473 473 $serialized_instance = serialize( $instance ); 474 $widget_key = $wp_widget_factory->get_widget_key( $id ); 474 475 475 476 $response = array( … … 482 483 'preview' => trim( 483 484 $this->get_widget_preview( 484 $widget_ object,485 $widget_key, 485 486 $instance 486 487 ) … … 504 505 * instance. Used by encode_form_data() to preview a widget. 505 506 506 * @param WP_Widget $widget_object Widget object to call widget() on.507 * @param string $widget The widget's PHP class name (see class-wp-widget.php). 507 508 * @param array $instance Widget instance settings. 508 509 * @return string 509 510 */ 510 private function get_widget_preview( $widget _object, $instance ) {511 private function get_widget_preview( $widget, $instance ) { 511 512 ob_start(); 512 the_widget( get_class( $widget_object ), $instance );513 the_widget( $widget, $instance ); 513 514 return ob_get_clean(); 514 515 }
Note: See TracChangeset
for help on using the changeset viewer.