Changeset 13254
- Timestamp:
- 02/29/2024 11:40:41 PM (14 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/random.php
r13253 r13254 37 37 */ 38 38 public static function init() { 39 // Add 'random' URL endpoint to front-end. 39 40 add_action( 'init', [ __CLASS__, 'add_rewrite_rule' ] ); 40 41 add_filter( 'query_vars', [ __CLASS__, 'add_query_var' ] ); … … 42 43 add_action( 'template_redirect', [ __CLASS__, 'redirect_if_random' ] ); 43 44 add_filter( 'wp_robots', [ __CLASS__, 'noindex' ] ); 45 46 // Accommodate randomization of queue. 47 add_filter( 'admin_body_class', [ __CLASS__, 'random_in_admin_body_class' ] ); 44 48 } 45 49 … … 136 140 } 137 141 142 /** 143 * Determines if the current query is for an admin listing of photos 144 * that should be randomly ordered. 145 * 146 * @return bool True if the query is for an admin listing of photos that should be 147 * randomly ordered, else false. 148 */ 149 public static function is_random_admin_listing() { 150 return ( 151 is_admin() 152 && 153 is_main_query() 154 && 155 Registrations::get_post_type() === ( $_GET['post_type'] ?? false ) 156 && 157 'pending' === ( $_GET['post_status'] ?? '' ) 158 ); 159 } 160 161 /** 162 * Adds class denoting a random listing of photos when appropriate. 163 * 164 * @param string $classes Space-separated list of CSS classes. 165 * @return string[] 166 */ 167 public static function random_in_admin_body_class( $classes ) { 168 if ( self::is_random_admin_listing() ) { 169 $classes .= ' photos-random'; 170 } 171 172 return trim( $classes ); 173 } 174 138 175 } 139 176
Note: See TracChangeset
for help on using the changeset viewer.