| | 194 | |
| | 195 | /** |
| | 196 | * @ticket 38738 |
| | 197 | */ |
| | 198 | function test_video_header_callback_front_page_from_front_page() { |
| | 199 | // Back up theme features global to avoid poisoning later tests. |
| | 200 | global $_wp_theme_features; |
| | 201 | $_wp_theme_features_backup = $_wp_theme_features; |
| | 202 | |
| | 203 | add_theme_support( 'custom-header', array( |
| | 204 | 'video' => true, |
| | 205 | '__jit' => true, // Force refresh. |
| | 206 | ) ); |
| | 207 | |
| | 208 | $this->go_to( home_url() ); |
| | 209 | |
| | 210 | $result = is_header_video_active(); |
| | 211 | |
| | 212 | // Restore theme features global to initial state. |
| | 213 | $_wp_theme_features = $_wp_theme_features_backup; |
| | 214 | |
| | 215 | $this->assertTrue( $result ); |
| | 216 | } |
| | 217 | |
| | 218 | /** |
| | 219 | * @ticket 38738 |
| | 220 | */ |
| | 221 | function test_video_header_callback_front_page_from_elsewhere() { |
| | 222 | // Back up theme features global to avoid poisoning later tests. |
| | 223 | global $_wp_theme_features; |
| | 224 | $_wp_theme_features_backup = $_wp_theme_features; |
| | 225 | |
| | 226 | add_theme_support( 'custom-header', array( |
| | 227 | 'video' => true, |
| | 228 | '__jit' => true, // Force refresh. |
| | 229 | ) ); |
| | 230 | |
| | 231 | $p = self::factory()->post->create( array( |
| | 232 | 'post_status' => 'publish', |
| | 233 | ) ); |
| | 234 | |
| | 235 | $this->go_to( get_permalink( $p ) ); |
| | 236 | |
| | 237 | $result = is_header_video_active(); |
| | 238 | |
| | 239 | // Restore theme features global to initial state. |
| | 240 | $_wp_theme_features = $_wp_theme_features_backup; |
| | 241 | |
| | 242 | $this->assertFalse( $result ); |
| | 243 | } |
| | 244 | |
| | 245 | /** |
| | 246 | * @ticket 38738 |
| | 247 | */ |
| | 248 | function test_video_header_callback_globally_from_front_page() { |
| | 249 | // Back up theme features global to avoid poisoning later tests. |
| | 250 | global $_wp_theme_features; |
| | 251 | $_wp_theme_features_backup = $_wp_theme_features; |
| | 252 | |
| | 253 | add_theme_support( 'custom-header', array( |
| | 254 | 'video' => true, |
| | 255 | 'video-active-callback' => '__return_true', |
| | 256 | '__jit' => true, // Force refresh. |
| | 257 | ) ); |
| | 258 | |
| | 259 | $this->go_to( home_url() ); |
| | 260 | |
| | 261 | $result = is_header_video_active(); |
| | 262 | |
| | 263 | // Restore theme features global to initial state. |
| | 264 | $_wp_theme_features = $_wp_theme_features_backup; |
| | 265 | |
| | 266 | $this->assertTrue( $result ); |
| | 267 | } |
| | 268 | |
| | 269 | /** |
| | 270 | * @ticket 38738 |
| | 271 | */ |
| | 272 | function test_video_header_callback_globally_from_elsewhere() { |
| | 273 | // Back up theme features global to avoid poisoning later tests. |
| | 274 | global $_wp_theme_features; |
| | 275 | $_wp_theme_features_backup = $_wp_theme_features; |
| | 276 | |
| | 277 | add_theme_support( 'custom-header', array( |
| | 278 | 'video' => true, |
| | 279 | 'video-active-callback' => '__return_true', |
| | 280 | '__jit' => true, // Force refresh. |
| | 281 | ) ); |
| | 282 | |
| | 283 | $p = self::factory()->post->create( array( |
| | 284 | 'post_status' => 'publish', |
| | 285 | ) ); |
| | 286 | |
| | 287 | $this->go_to( get_permalink( $p ) ); |
| | 288 | |
| | 289 | $result = is_header_video_active(); |
| | 290 | |
| | 291 | // Restore theme features global to initial state. |
| | 292 | $_wp_theme_features = $_wp_theme_features_backup; |
| | 293 | |
| | 294 | $this->assertTrue( $result ); |
| | 295 | } |
| | 296 | |
| | 297 | /** |
| | 298 | * @ticket 38738 |
| | 299 | */ |
| | 300 | function test_video_header_callback_globally_with_negative_filter() { |
| | 301 | // Back up theme features global to avoid poisoning later tests. |
| | 302 | global $_wp_theme_features; |
| | 303 | $_wp_theme_features_backup = $_wp_theme_features; |
| | 304 | |
| | 305 | add_theme_support( 'custom-header', array( |
| | 306 | 'video' => true, |
| | 307 | 'video-active-callback' => '__return_true', |
| | 308 | '__jit' => true, // Force refresh. |
| | 309 | ) ); |
| | 310 | |
| | 311 | $p = self::factory()->post->create( array( |
| | 312 | 'post_status' => 'publish', |
| | 313 | ) ); |
| | 314 | |
| | 315 | $this->go_to( get_permalink( $p ) ); |
| | 316 | |
| | 317 | add_filter( 'is_header_video_active', '__return_false' ); |
| | 318 | $result = is_header_video_active(); |
| | 319 | remove_filter( 'is_header_video_active', '__return_false' ); |
| | 320 | |
| | 321 | // Restore theme features global to initial state. |
| | 322 | $_wp_theme_features = $_wp_theme_features_backup; |
| | 323 | |
| | 324 | $this->assertFalse( $result ); |
| | 325 | } |