- Timestamp:
- 06/17/2014 12:00:42 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/widgets.php
r705 r706 3 3 class WPorg_Handbook_Widget extends WP_Widget { 4 4 5 protected $post_types = 'handbook';5 protected $post_types = array( 'handbook' ); 6 6 7 7 function __construct() { 8 $this->post_types = apply_filters( 'handbook_post_types', $this->post_types ); 9 if ( ! is_array( $this->post_types ) ) { 10 $this->post_types = (array) $this->post_types; 11 } 8 $this->post_types = (array) apply_filters( 'handbook_post_types', $this->post_types ); 12 9 $this->post_types = array_map( array( $this, 'append_suffix' ), $this->post_types ); 13 parent::__construct( 'handbook', 'Handbook Tools', array( 'classname' => 'widget_wporg_handbook', 'description' => 'Shows watch/unwatch links for handbook pages.') );10 parent::__construct( 'handbook', __( 'Handbook Tools', 'wporg' ), array( 'classname' => 'widget_wporg_handbook', 'description' => __( 'Shows watch/unwatch links for handbook pages.', 'wporg' ) ) ); 14 11 } 15 12 16 function widget( ) {13 function widget( $args ) { 17 14 if ( ! is_user_logged_in() ) 18 15 return; … … 21 18 if ( $post->post_type == 'page' || ( in_array( $post->post_type, $this->post_types ) && ! is_post_type_archive( $this->post_types ) ) ) { 22 19 $watchlist = get_post_meta( $post->ID, '_wporg_watchlist', true ); 20 if ( isset( $args['before_widget'] ) && $args['before_widget'] ) { 21 echo $args['before_widget']; 22 } 23 echo '<p>'; 23 24 if ( $watchlist && in_array( get_current_user_id(), $watchlist ) ) { 24 printf( '<p>You are watching this page. <a href="%s">Unwatch</a></p>',25 printf( __( 'You are watching this page. <a href="%s">Unwatch</a>', 'wporg' ), 25 26 wp_nonce_url( admin_url( 'admin-post.php?action=wporg_watchlist&post_id=' . $post->ID ), 'unwatch-' . $post->ID ) ); 26 27 } else { 27 printf( '<p><a href="%s">Watch this page</a></p>',28 printf( __( '<a href="%s">Watch this page</a>', 'wporg' ), 28 29 wp_nonce_url( admin_url( 'admin-post.php?action=wporg_watchlist&watch=1&post_id=' . $post->ID ), 'watch-' . $post->ID ) ); 30 } 31 echo '</p>'; 32 if ( isset( $args['after_widget'] ) && $args['after_widget'] ) { 33 echo $args['after_widget']; 29 34 } 30 35 } else { … … 35 40 36 41 function append_suffix( $t ) { 37 if ( 'handbook' == $t )42 if ( in_array( $t, array( 'handbook', 'page' ) ) ) { 38 43 return $t; 44 } 39 45 40 46 return $t . '-handbook'; … … 44 50 class WPorg_Handbook_Widget_for_Pages extends WPorg_Handbook_Widget { 45 51 46 protected $post_type = 'page';52 protected $post_types = array( 'page' ); 47 53 48 54 function __construct() { 49 WP_Widget::__construct( 'handbook_for_pages', 'Handbook Tools (for Pages)', array( 'classname' => 'widget_wporg_handbook', 'description' => 'Shows watch/unwatch links for Pages.') );55 WP_Widget::__construct( 'handbook_for_pages', __( 'Handbook Tools (for Pages)', 'wporg' ), array( 'classname' => 'widget_wporg_handbook', 'description' => __( 'Shows watch/unwatch links for Pages.', 'wporg' ) ) ); 50 56 } 51 57 } … … 53 59 class WPorg_Handbook_Pages_Widget extends WP_Widget_Pages { 54 60 55 protected $post_types = 'handbook';61 protected $post_types = array( 'handbook' ); 56 62 57 63 function __construct() { 58 $widget_ops = array('classname' => 'widget_wporg_handbook_pages', 'description' => __( 'Your site’s Handbook Pages' ) );59 WP_Widget::__construct( 'handbook_pages', __('Handbook Pages'), $widget_ops);64 $widget_ops = array('classname' => 'widget_wporg_handbook_pages', 'description' => __( 'Your site’s Handbook Pages', 'wporg' ) ); 65 WP_Widget::__construct( 'handbook_pages', __( 'Handbook Pages', 'wporg' ), $widget_ops ); 60 66 } 61 67 … … 69 75 $post = get_post(); 70 76 71 $this->post_types = apply_filters( 'handbook_post_types', $this->post_types ); 72 if ( ! is_array( $this->post_types ) ) { 73 $this->post_types = (array) $this->post_types; 74 } 77 $this->post_types = (array) apply_filters( 'handbook_post_types', $this->post_types ); 75 78 $this->post_types = array_map( array( $this, 'append_suffix' ), $this->post_types ); 76 79 … … 82 85 83 86 function append_suffix( $t ) { 84 if ( 'handbook' == $t )87 if ( in_array( $t, array( 'handbook', 'page' ) ) ) { 85 88 return $t; 89 } 86 90 87 91 return $t . '-handbook';
Note: See TracChangeset
for help on using the changeset viewer.