Changeset 10791
- Timestamp:
- 03/07/2021 08:38:58 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/watchlist.php
r10768 r10791 1 1 <?php 2 /** 3 * Class providing P2/O2 watchlist functionality. 4 * 5 * @package handbook 6 */ 2 7 3 8 class WPorg_Handbook_Watchlist { 4 9 10 /** 11 * Memoized array of handbook post types. 12 * 13 * @var array 14 */ 5 15 private static $post_types; 6 16 17 /** 18 * Initializes actions. 19 */ 7 20 public static function init() { 8 add_action( 'init', array( __CLASS__, 'on_init' ));21 add_action( 'init', [ __CLASS__, 'on_init' ] ); 9 22 } 10 23 24 /** 25 * Performs actions intended to occur during 'init' action. 26 */ 11 27 public static function on_init() { 12 28 self::$post_types = WPorg_Handbook_Init::get_post_types(); 13 29 14 add_action( 'p2_action_links', array(__CLASS__, 'display_action_link'), 100 );15 add_filter( 'o2_filter_post_actions', array( __CLASS__, 'add_o2_action_link' ));16 add_filter( 'o2_filter_post_action_html', array( __CLASS__, 'get_o2_action_link' ), 10, 2 );30 add_action( 'p2_action_links', [ __CLASS__, 'display_action_link' ], 100 ); 31 add_filter( 'o2_filter_post_actions', [ __CLASS__, 'add_o2_action_link' ] ); 32 add_filter( 'o2_filter_post_action_html', [ __CLASS__, 'get_o2_action_link' ], 10, 2 ); 17 33 } 18 34 19 35 /** 20 * Adds a 'Watch' action link to O2 36 * Adds a 'Watch' action link to O2. 37 * 38 * @param array $actions Array of O2 actions. 39 * @return array 21 40 */ 22 41 public static function add_o2_action_link( $actions ) { … … 51 70 } 52 71 } 72 53 73 return $actions; 54 74 } 55 75 56 76 /** 57 * Create the HTML for the watch o2 post action. 77 * Returns the HTML for the watch o2 post action. 78 * 79 * @param string $html The HTML for the given action. 80 * @param array $action Data about the action. 81 * @return string 58 82 */ 59 83 public static function get_o2_action_link( $html, $action ) { … … 72 96 73 97 /** 74 * Adds a 'Watch' action link to P298 * Outputs a 'Watch' action link to P2. 75 99 */ 76 100 public static function display_action_link() { 77 78 101 if ( ! is_user_logged_in() ) { 79 102 return; … … 83 106 84 107 if ( 'page' == $post->post_type || ( in_array( $post->post_type, self::$post_types ) && ! is_post_type_archive( self::$post_types ) ) ) { 85 86 108 $watchlist = get_post_meta( $post->ID, '_wporg_watchlist', true ); 87 109 … … 101 123 ); 102 124 } 103 104 125 } 105 106 126 } 107 127 … … 109 129 110 130 WPorg_Handbook_Watchlist::init(); 111
Note: See TracChangeset
for help on using the changeset viewer.