Нема описа

twitter-timeline.php 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. <?php
  2. /*
  3. * Based on Evolution Twitter Timeline
  4. * (https://wordpress.org/extend/plugins/evolution-twitter-timeline/)
  5. * For details on Twitter Timelines see:
  6. * - https://twitter.com/settings/widgets
  7. * - https://dev.twitter.com/docs/embedded-timelines
  8. */
  9. use Automattic\Jetpack\Assets;
  10. use Automattic\Jetpack\Redirect;
  11. /**
  12. * Register the widget for use in Appearance -> Widgets
  13. */
  14. add_action( 'widgets_init', 'jetpack_twitter_timeline_widget_init' );
  15. function jetpack_twitter_timeline_widget_init() {
  16. register_widget( 'Jetpack_Twitter_Timeline_Widget' );
  17. }
  18. class Jetpack_Twitter_Timeline_Widget extends WP_Widget {
  19. /**
  20. * Register widget with WordPress.
  21. */
  22. public function __construct() {
  23. parent::__construct(
  24. 'twitter_timeline',
  25. /** This filter is documented in modules/widgets/facebook-likebox.php */
  26. apply_filters( 'jetpack_widget_name', esc_html__( 'Twitter Timeline', 'jetpack' ) ),
  27. array(
  28. 'classname' => 'widget_twitter_timeline',
  29. 'description' => __( 'Display an official Twitter Embedded Timeline widget.', 'jetpack' ),
  30. 'customize_selective_refresh' => true,
  31. )
  32. );
  33. if ( is_active_widget( false, false, $this->id_base ) || is_active_widget( false, false, 'monster' ) || is_customize_preview() ) {
  34. add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
  35. }
  36. add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
  37. }
  38. /**
  39. * Enqueue scripts.
  40. */
  41. public function enqueue_scripts() {
  42. if ( ! class_exists( 'Jetpack_AMP_Support' ) || ! Jetpack_AMP_Support::is_amp_request() ) {
  43. wp_enqueue_script( 'jetpack-twitter-timeline' );
  44. }
  45. }
  46. /**
  47. * Enqueue Twitter's widget library.
  48. *
  49. * @deprecated
  50. */
  51. public function library() {
  52. _deprecated_function( __METHOD__, '4.0.0' );
  53. wp_print_scripts( array( 'jetpack-twitter-timeline' ) );
  54. }
  55. /**
  56. * Enqueue script to improve admin UI
  57. */
  58. public function admin_scripts( $hook ) {
  59. // This is still 'widgets.php' when managing widgets via the Customizer.
  60. if ( 'widgets.php' === $hook ) {
  61. wp_enqueue_script(
  62. 'twitter-timeline-admin',
  63. Assets::get_file_url_for_environment(
  64. '_inc/build/widgets/twitter-timeline-admin.min.js',
  65. 'modules/widgets/twitter-timeline-admin.js'
  66. )
  67. );
  68. }
  69. }
  70. /**
  71. * Front-end display of widget.
  72. *
  73. * @see WP_Widget::widget()
  74. *
  75. * @param array $args Widget arguments.
  76. * @param array $instance Saved values from database.
  77. */
  78. public function widget( $args, $instance ) {
  79. $output = '';
  80. // Twitter deprecated `data-widget-id` on 2018-05-25,
  81. // with cease support deadline on 2018-07-27.
  82. if ( isset( $instance['type'] ) && 'widget-id' === $instance['type'] ) {
  83. if ( current_user_can( 'edit_theme_options' ) ) {
  84. $output .= $args['before_widget']
  85. . $args['before_title'] . esc_html__( 'Twitter Timeline', 'jetpack' ) . $args['after_title']
  86. . '<p>' . esc_html__( "The Twitter Timeline widget can't display tweets based on searches or hashtags. To display a simple list of tweets instead, change the Widget ID to a Twitter username. Otherwise, delete this widget.", 'jetpack' ) . '</p>'
  87. . '<p>' . esc_html__( '(Only administrators will see this message.)', 'jetpack' ) . '</p>'
  88. . $args['after_widget'];
  89. }
  90. echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  91. return;
  92. }
  93. $instance['lang'] = substr( strtoupper( get_locale() ), 0, 2 );
  94. $output .= $args['before_widget'];
  95. $title = isset( $instance['title'] ) ? $instance['title'] : '';
  96. /** This filter is documented in core/src/wp-includes/default-widgets.php */
  97. $title = apply_filters( 'widget_title', $title );
  98. if ( ! empty( $title ) ) {
  99. $output .= $args['before_title'] . $title . $args['after_title'];
  100. }
  101. $possible_data_attribs = array(
  102. 'width',
  103. 'height',
  104. 'theme',
  105. 'border-color',
  106. 'tweet-limit',
  107. 'lang',
  108. );
  109. $data_attrs = '';
  110. foreach ( $possible_data_attribs as $att ) {
  111. if ( ! empty( $instance[ $att ] ) && ! is_array( $instance[ $att ] ) ) {
  112. $data_attrs .= ' data-' . esc_attr( $att ) . '="' . esc_attr( $instance[ $att ] ) . '"';
  113. }
  114. }
  115. /** This filter is documented in modules/shortcodes/tweet.php */
  116. $partner = apply_filters( 'jetpack_twitter_partner_id', 'jetpack' );
  117. if ( ! empty( $partner ) ) {
  118. $data_attrs .= ' data-partner="' . esc_attr( $partner ) . '"';
  119. }
  120. /**
  121. * Allow the activation of Do Not Track for the Twitter Timeline Widget.
  122. *
  123. * @see https://developer.twitter.com/en/docs/twitter-for-websites/timelines/guides/parameter-reference.html
  124. *
  125. * @module widgets
  126. *
  127. * @since 6.9.0
  128. *
  129. * @param bool false Should the Twitter Timeline use the DNT attribute? Default to false.
  130. */
  131. $dnt = apply_filters( 'jetpack_twitter_timeline_default_dnt', false );
  132. if ( true === $dnt ) {
  133. $data_attrs .= ' data-dnt="true"';
  134. }
  135. if ( ! empty( $instance['chrome'] ) && is_array( $instance['chrome'] ) ) {
  136. $data_attrs .= ' data-chrome="' . esc_attr( join( ' ', $instance['chrome'] ) ) . '"';
  137. }
  138. $timeline_placeholder = __( 'My Tweets', 'jetpack' );
  139. /**
  140. * Filter the Timeline placeholder text.
  141. *
  142. * @module widgets
  143. *
  144. * @since 3.4.0
  145. *
  146. * @param string $timeline_placeholder Timeline placeholder text.
  147. */
  148. $timeline_placeholder = apply_filters( 'jetpack_twitter_timeline_placeholder', $timeline_placeholder );
  149. $type = ( isset( $instance['type'] ) ? $instance['type'] : '' );
  150. $widget_id = ( isset( $instance['widget-id'] ) ? $instance['widget-id'] : '' );
  151. if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
  152. $width = ! empty( $instance['width'] ) ? $instance['width'] : 600;
  153. $height = ! empty( $instance['height'] ) ? $instance['height'] : 480;
  154. $output .= '<amp-twitter' . $data_attrs . ' layout="responsive" data-timeline-source-type="profile" data-timeline-screen-name="' . esc_attr( $widget_id ) . '" width="' . absint( $width ) . '" height="' . absint( $height ) . '">'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  155. $output .= esc_html( $timeline_placeholder ) . '</amp-twitter>';
  156. echo $output . $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  157. return;
  158. }
  159. // Start tag output
  160. // This tag is transformed into the widget markup by Twitter's
  161. // widgets.js code.
  162. $output .= '<a class="twitter-timeline"' . $data_attrs; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  163. switch ( $type ) {
  164. case 'profile':
  165. $output .= ' href="https://twitter.com/' . esc_attr( $widget_id ) . '"';
  166. break;
  167. case 'widget-id':
  168. default:
  169. $output .= ' data-widget-id="' . esc_attr( $widget_id ) . '"';
  170. break;
  171. }
  172. $output .= ' href="https://twitter.com/' . esc_attr( $widget_id ) . '"';
  173. // End tag output.
  174. $output .= '>';
  175. $output .= esc_html( $timeline_placeholder ) . '</a>';
  176. // End tag output
  177. echo $output . $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  178. /** This action is documented in modules/widgets/gravatar-profile.php */
  179. do_action( 'jetpack_stats_extra', 'widget_view', 'twitter_timeline' );
  180. }
  181. /**
  182. * Sanitize widget form values as they are saved.
  183. *
  184. * @see WP_Widget::update()
  185. *
  186. * @param array $new_instance Values just sent to be saved.
  187. * @param array $old_instance Previously saved values from database.
  188. *
  189. * @return array Updated safe values to be saved.
  190. */
  191. public function update( $new_instance, $old_instance ) {
  192. $instance = array();
  193. $instance['title'] = sanitize_text_field( $new_instance['title'] );
  194. $width = (int) $new_instance['width'];
  195. if ( $width ) {
  196. // From publish.twitter.com: 220 <= width <= 1200
  197. $instance['width'] = min( max( $width, 220 ), 1200 );
  198. } else {
  199. // Set default width value to minimum.
  200. $instance['width'] = 220;
  201. }
  202. $tweet_display = sanitize_text_field( $new_instance['tweet-display'] );
  203. $instance['tweet-display'] = $tweet_display;
  204. /**
  205. * A timeline with a specified limit is expanded to the height of those Tweets.
  206. * The specified height value no longer applies, so reject the height value
  207. * when a valid limit is set: a widget attempting to save both limit 5 and
  208. * height 400 would be saved with just limit 5.
  209. * So if the tweet display option is set to 'dynamic' the limit will be unset and we'll
  210. * take into account the height value.
  211. * If the tweet display option is set to 'fixed' the height will be unset and we'll
  212. * take into account the limit value.
  213. */
  214. $instance['height'] = '';
  215. $instance['tweet-limit'] = null;
  216. switch ( $tweet_display ) {
  217. case 'dynamic':
  218. $height = (int) $new_instance['height'];
  219. // From publish.twitter.com: height >= 200.
  220. $instance['height'] = max( $height, 200 );
  221. break;
  222. case 'fixed':
  223. $tweet_limit = (int) $new_instance['tweet-limit'];
  224. // From publish.twitter.com: 1 >= tweet-limit >= 20.
  225. $instance['tweet-limit'] = min( max( $tweet_limit, 1 ), 20 );
  226. break;
  227. }
  228. // If they entered something that might be a full URL, try to parse it out
  229. if ( is_string( $new_instance['widget-id'] ) ) {
  230. if ( preg_match(
  231. '#https?://twitter\.com/settings/widgets/(\d+)#s',
  232. $new_instance['widget-id'],
  233. $matches
  234. ) ) {
  235. $new_instance['widget-id'] = $matches[1];
  236. }
  237. }
  238. $instance['widget-id'] = sanitize_text_field( $new_instance['widget-id'] );
  239. $new_border_color = sanitize_hex_color( $new_instance['border-color'] );
  240. if ( ! empty( $new_border_color ) ) {
  241. $instance['border-color'] = $new_border_color;
  242. }
  243. $instance['type'] = 'profile';
  244. $instance['theme'] = 'light';
  245. if ( in_array( $new_instance['theme'], array( 'light', 'dark' ) ) ) {
  246. $instance['theme'] = $new_instance['theme'];
  247. }
  248. $instance['chrome'] = array();
  249. $chrome_settings = array(
  250. 'noheader',
  251. 'nofooter',
  252. 'noborders',
  253. 'transparent',
  254. 'noscrollbar',
  255. );
  256. foreach ( $chrome_settings as $chrome ) {
  257. switch ( $chrome ) {
  258. case 'noheader':
  259. case 'nofooter':
  260. case 'noborders':
  261. case 'noscrollbar':
  262. if ( ! isset( $new_instance['chrome'] ) || ! in_array( $chrome, $new_instance['chrome'], true ) ) {
  263. $instance['chrome'][] = $chrome;
  264. }
  265. break;
  266. default:
  267. if ( isset( $new_instance['chrome'] ) && in_array( $chrome, $new_instance['chrome'], true ) ) {
  268. $instance['chrome'][] = $chrome;
  269. }
  270. break;
  271. }
  272. }
  273. return $instance;
  274. }
  275. /**
  276. * Returns a link to the documentation for a feature of this widget on
  277. * Jetpack or WordPress.com.
  278. */
  279. public function get_docs_link( $hash = '' ) {
  280. if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
  281. $base_url = 'https://wordpress.com/support/widgets/twitter-timeline-widget/';
  282. } else {
  283. $base_url = esc_url( Redirect::get_url( 'jetpack-support-extra-sidebar-widgets-twitter-timeline-widget' ) );
  284. }
  285. return '<a class="widget-access-link" href="' . $base_url . $hash . '" target="_blank"> Need help?</a>';
  286. }
  287. /**
  288. * Back end widget form.
  289. *
  290. * @see WP_Widget::form()
  291. *
  292. * @param array $instance Previously saved values from database.
  293. */
  294. public function form( $instance ) {
  295. $defaults = array(
  296. 'title' => esc_html__( 'Follow me on Twitter', 'jetpack' ),
  297. 'width' => '220',
  298. 'height' => '200',
  299. 'type' => 'profile',
  300. 'widget-id' => '',
  301. 'border-color' => '#f0f0f1',
  302. 'theme' => 'light',
  303. 'chrome' => array(),
  304. 'tweet-limit' => 1,
  305. 'tweet-display' => 'dynamic',
  306. );
  307. $instance = wp_parse_args( (array) $instance, $defaults );
  308. if ( 'widget-id' === $instance['type'] ) {
  309. $instance['widget-id'] = '';
  310. }
  311. $instance['type'] = 'profile';
  312. /**
  313. * Set the tweet-display option to 'fixed' if height is empty and tweet-limit set
  314. * to ensure backwards compatibility with pre-existing widgets.
  315. */
  316. if ( empty( $instance['height'] ) && isset( $instance['tweet-limit'] ) ) {
  317. $instance['tweet-display'] = 'fixed';
  318. }
  319. ?>
  320. <p class="jetpack-twitter-timeline-widget-id-container">
  321. <label for="<?php echo esc_attr( $this->get_field_id( 'widget-id' ) ); ?>">
  322. <?php esc_html_e( 'Twitter username:', 'jetpack' ); ?>
  323. <?php
  324. echo wp_kses(
  325. $this->get_docs_link( '#twitter-username' ),
  326. array(
  327. 'a' => array(
  328. 'href' => array(),
  329. 'rel' => array(),
  330. 'target' => array(),
  331. 'class' => array(),
  332. ),
  333. )
  334. );
  335. ?>
  336. </label>
  337. <input
  338. class="widefat"
  339. id="<?php echo esc_attr( $this->get_field_id( 'widget-id' ) ); ?>"
  340. name="<?php echo esc_attr( $this->get_field_name( 'widget-id' ) ); ?>"
  341. type="text"
  342. value="<?php echo esc_attr( $instance['widget-id'] ); ?>"
  343. />
  344. </p>
  345. <p>
  346. <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>">
  347. <?php esc_html_e( 'Title:', 'jetpack' ); ?>
  348. </label>
  349. <input
  350. class="widefat"
  351. id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"
  352. name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>"
  353. type="text"
  354. value="<?php echo esc_attr( $instance['title'] ); ?>"
  355. />
  356. </p>
  357. <p>
  358. <label>
  359. <strong><?php esc_html_e( 'Number of tweets shown:', 'jetpack' ); ?></strong>
  360. </label>
  361. <ul>
  362. <li>
  363. <label>
  364. <input
  365. id="<?php echo esc_attr( $this->get_field_id( 'tweet-display' ) ); ?>-dynamic"
  366. name="<?php echo esc_attr( $this->get_field_name( 'tweet-display' ) ); ?>"
  367. type="radio"
  368. class="jetpack-twitter-timeline-widget-tweet-display-radio"
  369. value="dynamic"
  370. <?php checked( 'dynamic', $instance['tweet-display'] ); ?>
  371. />
  372. <?php esc_html_e( 'Dynamic', 'jetpack' ); ?>
  373. </label>
  374. </li>
  375. <li>
  376. <label>
  377. <input
  378. id="<?php echo esc_attr( $this->get_field_id( 'tweet-display' ) ); ?>-fixed"
  379. name="<?php echo esc_attr( $this->get_field_name( 'tweet-display' ) ); ?>"
  380. type="radio"
  381. class="jetpack-twitter-timeline-widget-tweet-display-radio"
  382. value="fixed"
  383. <?php checked( 'fixed', $instance['tweet-display'] ); ?>
  384. />
  385. <?php esc_html_e( 'Fixed', 'jetpack' ); ?>
  386. </label>
  387. </li>
  388. </ul>
  389. </p>
  390. <p class="jetpack-twitter-timeline-widget-height-container" <?php echo ( 'fixed' === $instance['tweet-display'] ) ? ' style="display:none;"' : ''; ?>>
  391. <label for="<?php echo esc_attr( $this->get_field_id( 'height' ) ); ?>">
  392. <?php esc_html_e( 'Height (in pixels; at least 200):', 'jetpack' ); ?>
  393. </label>
  394. <input
  395. class="widefat"
  396. id="<?php echo esc_attr( $this->get_field_id( 'height' ) ); ?>"
  397. name="<?php echo esc_attr( $this->get_field_name( 'height' ) ); ?>"
  398. type="number" min="200"
  399. value="<?php echo esc_attr( $instance['height'] ); ?>"
  400. />
  401. </p>
  402. <p class="jetpack-twitter-timeline-widget-tweet-limit-container" <?php echo ( 'dynamic' === $instance['tweet-display'] ) ? ' style="display:none;"' : ''; ?>>
  403. <label for="<?php echo esc_attr( $this->get_field_id( 'tweet-limit' ) ); ?>">
  404. <?php esc_html_e( 'Number of tweets in the timeline (1 to 20):', 'jetpack' ); ?>
  405. </label>
  406. <input
  407. class="widefat"
  408. id="<?php echo esc_attr( $this->get_field_id( 'tweet-limit' ) ); ?>"
  409. name="<?php echo esc_attr( $this->get_field_name( 'tweet-limit' ) ); ?>"
  410. type="number" min="1" max="20"
  411. value="<?php echo esc_attr( $instance['tweet-limit'] ); ?>"
  412. />
  413. </p>
  414. <p>
  415. <label for="<?php echo esc_attr( $this->get_field_id( 'width' ) ); ?>">
  416. <?php esc_html_e( 'Maximum width (in pixels; 220 to 1200):', 'jetpack' ); ?>
  417. </label>
  418. <input
  419. class="widefat"
  420. id="<?php echo esc_attr( $this->get_field_id( 'width' ) ); ?>"
  421. name="<?php echo esc_attr( $this->get_field_name( 'width' ) ); ?>"
  422. type="number" min="220" max="1200"
  423. value="<?php echo esc_attr( $instance['width'] ); ?>"
  424. />
  425. </p>
  426. <p>
  427. <label for="<?php echo esc_attr( $this->get_field_id( 'chrome-noheader' ) ); ?>">
  428. <strong><?php esc_html_e( 'Layout options:', 'jetpack' ); ?></strong>
  429. </label>
  430. </p>
  431. <p>
  432. <input
  433. type="checkbox"
  434. <?php checked( false, in_array( 'noheader', $instance['chrome'], true ) ); ?>
  435. id="<?php echo esc_attr( $this->get_field_id( 'chrome-noheader' ) ); ?>"
  436. name="<?php echo esc_attr( $this->get_field_name( 'chrome' ) ); ?>[]"
  437. value="noheader"
  438. />
  439. <label for="<?php echo esc_attr( $this->get_field_id( 'chrome-noheader' ) ); ?>">
  440. <?php esc_html_e( 'Show header', 'jetpack' ); ?>
  441. </label>
  442. <br />
  443. <input
  444. type="checkbox"
  445. <?php checked( false, in_array( 'nofooter', $instance['chrome'], true ) ); ?>
  446. id="<?php echo esc_attr( $this->get_field_id( 'chrome-nofooter' ) ); ?>"
  447. name="<?php echo esc_attr( $this->get_field_name( 'chrome' ) ); ?>[]"
  448. value="nofooter"
  449. />
  450. <label for="<?php echo esc_attr( $this->get_field_id( 'chrome-nofooter' ) ); ?>">
  451. <?php esc_html_e( 'Show footer', 'jetpack' ); ?>
  452. </label>
  453. <br />
  454. <input
  455. type="checkbox"
  456. <?php checked( false, in_array( 'noborders', $instance['chrome'], true ) ); ?>
  457. id="<?php echo esc_attr( $this->get_field_id( 'chrome-noborders' ) ); ?>"
  458. name="<?php echo esc_attr( $this->get_field_name( 'chrome' ) ); ?>[]"
  459. value="noborders"
  460. />
  461. <label for="<?php echo esc_attr( $this->get_field_id( 'chrome-noborders' ) ); ?>">
  462. <?php esc_html_e( 'Show borders', 'jetpack' ); ?>
  463. </label>
  464. <br />
  465. <input
  466. type="checkbox"
  467. <?php checked( false, in_array( 'noscrollbar', $instance['chrome'], true ) ); ?>
  468. id="<?php echo esc_attr( $this->get_field_id( 'chrome-noscrollbar' ) ); ?>"
  469. name="<?php echo esc_attr( $this->get_field_name( 'chrome' ) ); ?>[]"
  470. value="noscrollbar"
  471. <?php disabled( 'fixed', $instance['tweet-display'] ); ?>
  472. />
  473. <label for="<?php echo esc_attr( $this->get_field_id( 'chrome-noscrollbar' ) ); ?>">
  474. <?php esc_html_e( 'Show scrollbar', 'jetpack' ); ?>
  475. </label>
  476. <br />
  477. <input
  478. type="checkbox"
  479. <?php checked( in_array( 'transparent', $instance['chrome'], true ) ); ?>
  480. id="<?php echo esc_attr( $this->get_field_id( 'chrome-transparent' ) ); ?>"
  481. name="<?php echo esc_attr( $this->get_field_name( 'chrome' ) ); ?>[]"
  482. value="transparent"
  483. />
  484. <label for="<?php echo esc_attr( $this->get_field_id( 'chrome-transparent' ) ); ?>">
  485. <?php esc_html_e( 'Transparent background', 'jetpack' ); ?>
  486. </label>
  487. </p>
  488. <p>
  489. <label for="<?php echo esc_attr( $this->get_field_id( 'border-color' ) ); ?>">
  490. <?php esc_html_e( 'Border color (in hex format):', 'jetpack' ); ?>
  491. </label>
  492. <input
  493. class="widefat"
  494. id="<?php echo esc_attr( $this->get_field_id( 'border-color' ) ); ?>"
  495. name="<?php echo esc_attr( $this->get_field_name( 'border-color' ) ); ?>"
  496. type="text"
  497. value="<?php echo esc_attr( $instance['border-color'] ); ?>"
  498. />
  499. </p>
  500. <p>
  501. <label for="<?php echo esc_attr( $this->get_field_id( 'theme' ) ); ?>">
  502. <?php esc_html_e( 'Color scheme:', 'jetpack' ); ?>
  503. </label>
  504. <select
  505. name="<?php echo esc_attr( $this->get_field_name( 'theme' ) ); ?>"
  506. id="<?php echo esc_attr( $this->get_field_id( 'theme' ) ); ?>"
  507. class="widefat"
  508. >
  509. <option value="light"<?php selected( $instance['theme'], 'light' ); ?>>
  510. <?php esc_html_e( 'Light', 'jetpack' ); ?>
  511. </option>
  512. <option value="dark"<?php selected( $instance['theme'], 'dark' ); ?>>
  513. <?php esc_html_e( 'Dark', 'jetpack' ); ?>
  514. </option>
  515. </select>
  516. </p>
  517. <?php
  518. }
  519. }