GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 6e44b1...c642a0 )
by Brad
03:14
created

FooGallery_Album_Rewrite_Rules::flush_rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * FooGallery Album Rewrite Rules
4
 */
5
if (!class_exists('FooGallery_Album_Rewrite_Rules')) {
6
7
    class FooGallery_Album_Rewrite_Rules {
8
9
        function __construct() {
10
	        add_action( 'init',  array( $this, 'add_gallery_endpoint' ) );
11
			add_filter( 'redirect_canonical', array( $this, 'disable_canonical_redirect_for_front_page' ), 10, 2 );
12
			add_action( 'update_option_page_on_front', array( $this, 'flush_rules' ) );
13
        }
14
15
	    function add_gallery_endpoint() {
16
	    	$gallery_slug = foogallery_album_gallery_url_slug();
17
18
			// Ensures the $query_vars['item'] is available
19
			add_rewrite_tag( "%{$gallery_slug}%", '([^&]+)' );
20
21
			// Requires flushing endpoints whenever the front page is switched to a different page
22
			$page_on_front = get_option( 'page_on_front' );
23
24
			// Match the front page and pass item value as a query var.
25
			add_rewrite_rule( "^{$gallery_slug}/([^/]*)/?", 'index.php?page_id='.$page_on_front.'&'.$gallery_slug.'=$matches[1]', 'top' );
26
			// Match non-front page pages.
27
			add_rewrite_rule( "^(.*)/{$gallery_slug}/([^/]*)/?", 'index.php?pagename=$matches[1]&static=true&'.$gallery_slug.'=$matches[2]', 'top' );
28
	    }
29
30
		// http://wordpress.stackexchange.com/a/220484/52463
31
		// In order to keep WordPress from forcing a redirect to the canonical
32
		// home page, the redirect needs to be disabled.
33
		function disable_canonical_redirect_for_front_page( $redirect_url, $requested_url ) {
0 ignored issues
show
Unused Code introduced by
The parameter $requested_url is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
34
			if ( is_page() && $front_page = get_option( 'page_on_front' ) ) {
35
				if ( is_page( $front_page ) ) {
36
					$redirect_url = false;
37
				}
38
			}
39
40
			return $redirect_url;
41
		}
42
43
	    function flush_rules() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
44
			flush_rewrite_rules();
45
		}
46
    }
47
}