class-wp-widget-text.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. <?php
  2. /**
  3. * Widget API: WP_Widget_Text class
  4. *
  5. * @package WordPress
  6. * @subpackage Widgets
  7. * @since 4.4.0
  8. */
  9. /**
  10. * Core class used to implement a Text widget.
  11. *
  12. * @since 2.8.0
  13. *
  14. * @see WP_Widget
  15. */
  16. class WP_Widget_Text extends WP_Widget {
  17. /**
  18. * Whether or not the widget has been registered yet.
  19. *
  20. * @since 4.8.1
  21. * @var bool
  22. */
  23. protected $registered = false;
  24. /**
  25. * Sets up a new Text widget instance.
  26. *
  27. * @since 2.8.0
  28. */
  29. public function __construct() {
  30. $widget_ops = array(
  31. 'classname' => 'widget_text',
  32. 'description' => __( 'Arbitrary text.' ),
  33. 'customize_selective_refresh' => true,
  34. );
  35. $control_ops = array(
  36. 'width' => 400,
  37. 'height' => 350,
  38. );
  39. parent::__construct( 'text', __( 'Text' ), $widget_ops, $control_ops );
  40. }
  41. /**
  42. * Add hooks for enqueueing assets when registering all widget instances of this widget class.
  43. *
  44. * @param integer $number Optional. The unique order number of this widget instance
  45. * compared to other instances of the same class. Default -1.
  46. */
  47. public function _register_one( $number = -1 ) {
  48. parent::_register_one( $number );
  49. if ( $this->registered ) {
  50. return;
  51. }
  52. $this->registered = true;
  53. wp_add_inline_script( 'text-widgets', sprintf( 'wp.textWidgets.idBases.push( %s );', wp_json_encode( $this->id_base ) ) );
  54. if ( $this->is_preview() ) {
  55. add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_preview_scripts' ) );
  56. }
  57. // Note that the widgets component in the customizer will also do the 'admin_print_scripts-widgets.php' action in WP_Customize_Widgets::print_scripts().
  58. add_action( 'admin_print_scripts-widgets.php', array( $this, 'enqueue_admin_scripts' ) );
  59. // Note that the widgets component in the customizer will also do the 'admin_footer-widgets.php' action in WP_Customize_Widgets::print_footer_scripts().
  60. add_action( 'admin_footer-widgets.php', array( 'WP_Widget_Text', 'render_control_template_scripts' ) );
  61. }
  62. /**
  63. * Determines whether a given instance is legacy and should bypass using TinyMCE.
  64. *
  65. * @since 4.8.1
  66. *
  67. * @param array $instance {
  68. * Instance data.
  69. *
  70. * @type string $text Content.
  71. * @type bool|string $filter Whether autop or content filters should apply.
  72. * @type bool $legacy Whether widget is in legacy mode.
  73. * }
  74. * @return bool Whether Text widget instance contains legacy data.
  75. */
  76. public function is_legacy_instance( $instance ) {
  77. // Legacy mode when not in visual mode.
  78. if ( isset( $instance['visual'] ) ) {
  79. return ! $instance['visual'];
  80. }
  81. // Or, the widget has been added/updated in 4.8.0 then filter prop is 'content' and it is no longer legacy.
  82. if ( isset( $instance['filter'] ) && 'content' === $instance['filter'] ) {
  83. return false;
  84. }
  85. // If the text is empty, then nothing is preventing migration to TinyMCE.
  86. if ( empty( $instance['text'] ) ) {
  87. return false;
  88. }
  89. $wpautop = ! empty( $instance['filter'] );
  90. $has_line_breaks = ( false !== strpos( trim( $instance['text'] ), "\n" ) );
  91. // If auto-paragraphs are not enabled and there are line breaks, then ensure legacy mode.
  92. if ( ! $wpautop && $has_line_breaks ) {
  93. return true;
  94. }
  95. // If an HTML comment is present, assume legacy mode.
  96. if ( false !== strpos( $instance['text'], '<!--' ) ) {
  97. return true;
  98. }
  99. // In the rare case that DOMDocument is not available we cannot reliably sniff content and so we assume legacy.
  100. if ( ! class_exists( 'DOMDocument' ) ) {
  101. // @codeCoverageIgnoreStart
  102. return true;
  103. // @codeCoverageIgnoreEnd
  104. }
  105. $doc = new DOMDocument();
  106. // Suppress warnings generated by loadHTML
  107. $errors = libxml_use_internal_errors( true );
  108. // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
  109. @$doc->loadHTML(
  110. sprintf(
  111. '<!DOCTYPE html><html><head><meta charset="%s"></head><body>%s</body></html>',
  112. esc_attr( get_bloginfo( 'charset' ) ),
  113. $instance['text']
  114. )
  115. );
  116. libxml_use_internal_errors( $errors );
  117. $body = $doc->getElementsByTagName( 'body' )->item( 0 );
  118. // See $allowedposttags.
  119. $safe_elements_attributes = array(
  120. 'strong' => array(),
  121. 'em' => array(),
  122. 'b' => array(),
  123. 'i' => array(),
  124. 'u' => array(),
  125. 's' => array(),
  126. 'ul' => array(),
  127. 'ol' => array(),
  128. 'li' => array(),
  129. 'hr' => array(),
  130. 'abbr' => array(),
  131. 'acronym' => array(),
  132. 'code' => array(),
  133. 'dfn' => array(),
  134. 'a' => array(
  135. 'href' => true,
  136. ),
  137. 'img' => array(
  138. 'src' => true,
  139. 'alt' => true,
  140. ),
  141. );
  142. $safe_empty_elements = array( 'img', 'hr', 'iframe' );
  143. foreach ( $body->getElementsByTagName( '*' ) as $element ) {
  144. /** @var DOMElement $element */
  145. $tag_name = strtolower( $element->nodeName );
  146. // If the element is not safe, then the instance is legacy.
  147. if ( ! isset( $safe_elements_attributes[ $tag_name ] ) ) {
  148. return true;
  149. }
  150. // If the element is not safely empty and it has empty contents, then legacy mode.
  151. if ( ! in_array( $tag_name, $safe_empty_elements, true ) && '' === trim( $element->textContent ) ) {
  152. return true;
  153. }
  154. // If an attribute is not recognized as safe, then the instance is legacy.
  155. foreach ( $element->attributes as $attribute ) {
  156. /** @var DOMAttr $attribute */
  157. $attribute_name = strtolower( $attribute->nodeName );
  158. if ( ! isset( $safe_elements_attributes[ $tag_name ][ $attribute_name ] ) ) {
  159. return true;
  160. }
  161. }
  162. }
  163. // Otherwise, the text contains no elements/attributes that TinyMCE could drop, and therefore the widget does not need legacy mode.
  164. return false;
  165. }
  166. /**
  167. * Filter gallery shortcode attributes.
  168. *
  169. * Prevents all of a site's attachments from being shown in a gallery displayed on a
  170. * non-singular template where a $post context is not available.
  171. *
  172. * @since 4.9.0
  173. *
  174. * @param array $attrs Attributes.
  175. * @return array Attributes.
  176. */
  177. public function _filter_gallery_shortcode_attrs( $attrs ) {
  178. if ( ! is_singular() && empty( $attrs['id'] ) && empty( $attrs['include'] ) ) {
  179. $attrs['id'] = -1;
  180. }
  181. return $attrs;
  182. }
  183. /**
  184. * Outputs the content for the current Text widget instance.
  185. *
  186. * @since 2.8.0
  187. *
  188. * @global WP_Post $post Global post object.
  189. *
  190. * @param array $args Display arguments including 'before_title', 'after_title',
  191. * 'before_widget', and 'after_widget'.
  192. * @param array $instance Settings for the current Text widget instance.
  193. */
  194. public function widget( $args, $instance ) {
  195. global $post;
  196. $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
  197. /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
  198. $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
  199. $text = ! empty( $instance['text'] ) ? $instance['text'] : '';
  200. $is_visual_text_widget = ( ! empty( $instance['visual'] ) && ! empty( $instance['filter'] ) );
  201. // In 4.8.0 only, visual Text widgets get filter=content, without visual prop; upgrade instance props just-in-time.
  202. if ( ! $is_visual_text_widget ) {
  203. $is_visual_text_widget = ( isset( $instance['filter'] ) && 'content' === $instance['filter'] );
  204. }
  205. if ( $is_visual_text_widget ) {
  206. $instance['filter'] = true;
  207. $instance['visual'] = true;
  208. }
  209. /*
  210. * Suspend legacy plugin-supplied do_shortcode() for 'widget_text' filter for the visual Text widget to prevent
  211. * shortcodes being processed twice. Now do_shortcode() is added to the 'widget_text_content' filter in core itself
  212. * and it applies after wpautop() to prevent corrupting HTML output added by the shortcode. When do_shortcode() is
  213. * added to 'widget_text_content' then do_shortcode() will be manually called when in legacy mode as well.
  214. */
  215. $widget_text_do_shortcode_priority = has_filter( 'widget_text', 'do_shortcode' );
  216. $should_suspend_legacy_shortcode_support = ( $is_visual_text_widget && false !== $widget_text_do_shortcode_priority );
  217. if ( $should_suspend_legacy_shortcode_support ) {
  218. remove_filter( 'widget_text', 'do_shortcode', $widget_text_do_shortcode_priority );
  219. }
  220. // Override global $post so filters (and shortcodes) apply in a consistent context.
  221. $original_post = $post;
  222. if ( is_singular() ) {
  223. // Make sure post is always the queried object on singular queries (not from another sub-query that failed to clean up the global $post).
  224. $post = get_queried_object();
  225. } else {
  226. // Nullify the $post global during widget rendering to prevent shortcodes from running with the unexpected context on archive queries.
  227. $post = null;
  228. }
  229. // Prevent dumping out all attachments from the media library.
  230. add_filter( 'shortcode_atts_gallery', array( $this, '_filter_gallery_shortcode_attrs' ) );
  231. /**
  232. * Filters the content of the Text widget.
  233. *
  234. * @since 2.3.0
  235. * @since 4.4.0 Added the `$this` parameter.
  236. * @since 4.8.1 The `$this` param may now be a `WP_Widget_Custom_HTML` object in addition to a `WP_Widget_Text` object.
  237. *
  238. * @param string $text The widget content.
  239. * @param array $instance Array of settings for the current widget.
  240. * @param WP_Widget_Text|WP_Widget_Custom_HTML $this Current Text widget instance.
  241. */
  242. $text = apply_filters( 'widget_text', $text, $instance, $this );
  243. if ( $is_visual_text_widget ) {
  244. /**
  245. * Filters the content of the Text widget to apply changes expected from the visual (TinyMCE) editor.
  246. *
  247. * By default a subset of the_content filters are applied, including wpautop and wptexturize.
  248. *
  249. * @since 4.8.0
  250. *
  251. * @param string $text The widget content.
  252. * @param array $instance Array of settings for the current widget.
  253. * @param WP_Widget_Text $this Current Text widget instance.
  254. */
  255. $text = apply_filters( 'widget_text_content', $text, $instance, $this );
  256. } else {
  257. // Now in legacy mode, add paragraphs and line breaks when checkbox is checked.
  258. if ( ! empty( $instance['filter'] ) ) {
  259. $text = wpautop( $text );
  260. }
  261. /*
  262. * Manually do shortcodes on the content when the core-added filter is present. It is added by default
  263. * in core by adding do_shortcode() to the 'widget_text_content' filter to apply after wpautop().
  264. * Since the legacy Text widget runs wpautop() after 'widget_text' filters are applied, the widget in
  265. * legacy mode here manually applies do_shortcode() on the content unless the default
  266. * core filter for 'widget_text_content' has been removed, or if do_shortcode() has already
  267. * been applied via a plugin adding do_shortcode() to 'widget_text' filters.
  268. */
  269. if ( has_filter( 'widget_text_content', 'do_shortcode' ) && ! $widget_text_do_shortcode_priority ) {
  270. if ( ! empty( $instance['filter'] ) ) {
  271. $text = shortcode_unautop( $text );
  272. }
  273. $text = do_shortcode( $text );
  274. }
  275. }
  276. // Restore post global.
  277. $post = $original_post;
  278. remove_filter( 'shortcode_atts_gallery', array( $this, '_filter_gallery_shortcode_attrs' ) );
  279. // Undo suspension of legacy plugin-supplied shortcode handling.
  280. if ( $should_suspend_legacy_shortcode_support ) {
  281. add_filter( 'widget_text', 'do_shortcode', $widget_text_do_shortcode_priority );
  282. }
  283. echo $args['before_widget'];
  284. if ( ! empty( $title ) ) {
  285. echo $args['before_title'] . $title . $args['after_title'];
  286. }
  287. $text = preg_replace_callback( '#<(video|iframe|object|embed)\s[^>]*>#i', array( $this, 'inject_video_max_width_style' ), $text );
  288. // Adds noreferrer and noopener relationships, without duplicating values, to all HTML A elements that have a target.
  289. $text = wp_targeted_link_rel( $text );
  290. ?>
  291. <div class="textwidget"><?php echo $text; ?></div>
  292. <?php
  293. echo $args['after_widget'];
  294. }
  295. /**
  296. * Inject max-width and remove height for videos too constrained to fit inside sidebars on frontend.
  297. *
  298. * @since 4.9.0
  299. *
  300. * @see WP_Widget_Media_Video::inject_video_max_width_style()
  301. * @param array $matches Pattern matches from preg_replace_callback.
  302. * @return string HTML Output.
  303. */
  304. public function inject_video_max_width_style( $matches ) {
  305. $html = $matches[0];
  306. $html = preg_replace( '/\sheight="\d+"/', '', $html );
  307. $html = preg_replace( '/\swidth="\d+"/', '', $html );
  308. $html = preg_replace( '/(?<=width:)\s*\d+px(?=;?)/', '100%', $html );
  309. return $html;
  310. }
  311. /**
  312. * Handles updating settings for the current Text widget instance.
  313. *
  314. * @since 2.8.0
  315. *
  316. * @param array $new_instance New settings for this instance as input by the user via
  317. * WP_Widget::form().
  318. * @param array $old_instance Old settings for this instance.
  319. * @return array Settings to save or bool false to cancel saving.
  320. */
  321. public function update( $new_instance, $old_instance ) {
  322. $new_instance = wp_parse_args(
  323. $new_instance,
  324. array(
  325. 'title' => '',
  326. 'text' => '',
  327. 'filter' => false, // For back-compat.
  328. 'visual' => null, // Must be explicitly defined.
  329. )
  330. );
  331. $instance = $old_instance;
  332. $instance['title'] = sanitize_text_field( $new_instance['title'] );
  333. if ( current_user_can( 'unfiltered_html' ) ) {
  334. $instance['text'] = $new_instance['text'];
  335. } else {
  336. $instance['text'] = wp_kses_post( $new_instance['text'] );
  337. }
  338. $instance['filter'] = ! empty( $new_instance['filter'] );
  339. // Upgrade 4.8.0 format.
  340. if ( isset( $old_instance['filter'] ) && 'content' === $old_instance['filter'] ) {
  341. $instance['visual'] = true;
  342. }
  343. if ( 'content' === $new_instance['filter'] ) {
  344. $instance['visual'] = true;
  345. }
  346. if ( isset( $new_instance['visual'] ) ) {
  347. $instance['visual'] = ! empty( $new_instance['visual'] );
  348. }
  349. // Filter is always true in visual mode.
  350. if ( ! empty( $instance['visual'] ) ) {
  351. $instance['filter'] = true;
  352. }
  353. return $instance;
  354. }
  355. /**
  356. * Enqueue preview scripts.
  357. *
  358. * These scripts normally are enqueued just-in-time when a playlist shortcode is used.
  359. * However, in the customizer, a playlist shortcode may be used in a text widget and
  360. * dynamically added via selective refresh, so it is important to unconditionally enqueue them.
  361. *
  362. * @since 4.9.3
  363. */
  364. public function enqueue_preview_scripts() {
  365. require_once dirname( dirname( __FILE__ ) ) . '/media.php';
  366. wp_playlist_scripts( 'audio' );
  367. wp_playlist_scripts( 'video' );
  368. }
  369. /**
  370. * Loads the required scripts and styles for the widget control.
  371. *
  372. * @since 4.8.0
  373. */
  374. public function enqueue_admin_scripts() {
  375. wp_enqueue_editor();
  376. wp_enqueue_media();
  377. wp_enqueue_script( 'text-widgets' );
  378. wp_add_inline_script( 'text-widgets', 'wp.textWidgets.init();', 'after' );
  379. }
  380. /**
  381. * Outputs the Text widget settings form.
  382. *
  383. * @since 2.8.0
  384. * @since 4.8.0 Form only contains hidden inputs which are synced with JS template.
  385. * @since 4.8.1 Restored original form to be displayed when in legacy mode.
  386. * @see WP_Widget_Text::render_control_template_scripts()
  387. * @see _WP_Editors::editor()
  388. *
  389. * @param array $instance Current settings.
  390. * @return void
  391. */
  392. public function form( $instance ) {
  393. $instance = wp_parse_args(
  394. (array) $instance,
  395. array(
  396. 'title' => '',
  397. 'text' => '',
  398. )
  399. );
  400. ?>
  401. <?php if ( ! $this->is_legacy_instance( $instance ) ) : ?>
  402. <?php
  403. if ( user_can_richedit() ) {
  404. add_filter( 'the_editor_content', 'format_for_editor', 10, 2 );
  405. $default_editor = 'tinymce';
  406. } else {
  407. $default_editor = 'html';
  408. }
  409. /** This filter is documented in wp-includes/class-wp-editor.php */
  410. $text = apply_filters( 'the_editor_content', $instance['text'], $default_editor );
  411. // Reset filter addition.
  412. if ( user_can_richedit() ) {
  413. remove_filter( 'the_editor_content', 'format_for_editor' );
  414. }
  415. // Prevent premature closing of textarea in case format_for_editor() didn't apply or the_editor_content filter did a wrong thing.
  416. $escaped_text = preg_replace( '#</textarea#i', '&lt;/textarea', $text );
  417. ?>
  418. <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" class="title sync-input" type="hidden" value="<?php echo esc_attr( $instance['title'] ); ?>">
  419. <textarea id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>" class="text sync-input" hidden><?php echo $escaped_text; ?></textarea>
  420. <input id="<?php echo $this->get_field_id( 'filter' ); ?>" name="<?php echo $this->get_field_name( 'filter' ); ?>" class="filter sync-input" type="hidden" value="on">
  421. <input id="<?php echo $this->get_field_id( 'visual' ); ?>" name="<?php echo $this->get_field_name( 'visual' ); ?>" class="visual sync-input" type="hidden" value="on">
  422. <?php else : ?>
  423. <input id="<?php echo $this->get_field_id( 'visual' ); ?>" name="<?php echo $this->get_field_name( 'visual' ); ?>" class="visual" type="hidden" value="">
  424. <p>
  425. <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
  426. <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>"/>
  427. </p>
  428. <div class="notice inline notice-info notice-alt">
  429. <?php if ( ! isset( $instance['visual'] ) ) : ?>
  430. <p><?php _e( 'This widget may contain code that may work better in the &#8220;Custom HTML&#8221; widget. How about trying that widget instead?' ); ?></p>
  431. <?php else : ?>
  432. <p><?php _e( 'This widget may have contained code that may work better in the &#8220;Custom HTML&#8221; widget. If you haven&#8217;t yet, how about trying that widget instead?' ); ?></p>
  433. <?php endif; ?>
  434. </div>
  435. <p>
  436. <label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e( 'Content:' ); ?></label>
  437. <textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>"><?php echo esc_textarea( $instance['text'] ); ?></textarea>
  438. </p>
  439. <p>
  440. <input id="<?php echo $this->get_field_id( 'filter' ); ?>" name="<?php echo $this->get_field_name( 'filter' ); ?>" type="checkbox"<?php checked( ! empty( $instance['filter'] ) ); ?> />&nbsp;<label for="<?php echo $this->get_field_id( 'filter' ); ?>"><?php _e( 'Automatically add paragraphs' ); ?></label>
  441. </p>
  442. <?php
  443. endif;
  444. }
  445. /**
  446. * Render form template scripts.
  447. *
  448. * @since 4.8.0
  449. * @since 4.9.0 The method is now static.
  450. */
  451. public static function render_control_template_scripts() {
  452. $dismissed_pointers = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
  453. ?>
  454. <script type="text/html" id="tmpl-widget-text-control-fields">
  455. <# var elementIdPrefix = 'el' + String( Math.random() ).replace( /\D/g, '' ) + '_' #>
  456. <p>
  457. <label for="{{ elementIdPrefix }}title"><?php esc_html_e( 'Title:' ); ?></label>
  458. <input id="{{ elementIdPrefix }}title" type="text" class="widefat title">
  459. </p>
  460. <?php if ( ! in_array( 'text_widget_custom_html', $dismissed_pointers, true ) ) : ?>
  461. <div hidden class="wp-pointer custom-html-widget-pointer wp-pointer-top">
  462. <div class="wp-pointer-content">
  463. <h3><?php _e( 'New Custom HTML Widget' ); ?></h3>
  464. <?php if ( is_customize_preview() ) : ?>
  465. <p><?php _e( 'Did you know there is a &#8220;Custom HTML&#8221; widget now? You can find it by pressing the &#8220;<a class="add-widget" href="#">Add a Widget</a>&#8221; button and searching for &#8220;HTML&#8221;. Check it out to add some custom code to your site!' ); ?></p>
  466. <?php else : ?>
  467. <p><?php _e( 'Did you know there is a &#8220;Custom HTML&#8221; widget now? You can find it by scanning the list of available widgets on this screen. Check it out to add some custom code to your site!' ); ?></p>
  468. <?php endif; ?>
  469. <div class="wp-pointer-buttons">
  470. <a class="close" href="#"><?php _e( 'Dismiss' ); ?></a>
  471. </div>
  472. </div>
  473. <div class="wp-pointer-arrow">
  474. <div class="wp-pointer-arrow-inner"></div>
  475. </div>
  476. </div>
  477. <?php endif; ?>
  478. <?php if ( ! in_array( 'text_widget_paste_html', $dismissed_pointers, true ) ) : ?>
  479. <div hidden class="wp-pointer paste-html-pointer wp-pointer-top">
  480. <div class="wp-pointer-content">
  481. <h3><?php _e( 'Did you just paste HTML?' ); ?></h3>
  482. <p><?php _e( 'Hey there, looks like you just pasted HTML into the &#8220;Visual&#8221; tab of the Text widget. You may want to paste your code into the &#8220;Text&#8221; tab instead. Alternately, try out the new &#8220;Custom HTML&#8221; widget!' ); ?></p>
  483. <div class="wp-pointer-buttons">
  484. <a class="close" href="#"><?php _e( 'Dismiss' ); ?></a>
  485. </div>
  486. </div>
  487. <div class="wp-pointer-arrow">
  488. <div class="wp-pointer-arrow-inner"></div>
  489. </div>
  490. </div>
  491. <?php endif; ?>
  492. <p>
  493. <label for="{{ elementIdPrefix }}text" class="screen-reader-text"><?php esc_html_e( 'Content:' ); ?></label>
  494. <textarea id="{{ elementIdPrefix }}text" class="widefat text wp-editor-area" style="height: 200px" rows="16" cols="20"></textarea>
  495. </p>
  496. </script>
  497. <?php
  498. }
  499. }