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.

Issues (1881)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

includes/public/class-css-load-optimizer.php (7 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * FooGallery_CSS_Load_Optimizer class which enqueues CSS in the head
4
 */
5
if (!class_exists('class-css-load-optimizer.php')) {
6
7
    class FooGallery_CSS_Load_Optimizer {
8
9
        function __construct() {
10
            add_action( 'wp_enqueue_scripts', array( $this, 'include_gallery_css' ) );
11
            add_action( 'foogallery_enqueue_style', array( $this, 'enqueue_style_to_persist' ), 10, 5 );
12
            add_action( 'wp_footer', array( $this, 'persist_enqueued_styles' ) );
13
        }
14
15
		/**
16
		 * Persist any styles that are enqueued to be persisted
17
		 */
18
        function persist_enqueued_styles() {
0 ignored issues
show
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...
19
			global $wp_query, $foogallery_styles_to_persist;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
20
21
			//we only want to do this if we are looking at a single post
22
			if ( ! is_singular() ) {
23
				return;
24
			}
25
26
			$post_id = $wp_query->post->ID;
27
			if ( $post_id  && is_array( $foogallery_styles_to_persist ) ) {
28
				foreach( $foogallery_styles_to_persist as $style_handle => $style ) {
29
					add_post_meta( $post_id, FOOGALLERY_META_POST_USAGE_CSS, array( $style_handle => $style ), false );
30
				}
31
			}
32
		}
33
34
        /**
35
         * Get the current post ids for the view that is being shown
36
         */
37
        function get_post_ids_from_query() {
38
            global $wp_query;
39
40
            if ( is_singular() ) {
41
                return array( $wp_query->post->ID );
42
            } else if ( is_array( $wp_query->posts ) ) {
43
                return wp_list_pluck( $wp_query->posts, 'ID' );
44
            } else {
45
                return array();
46
            }
47
        }
48
49
        /**
50
         * Checks the post meta for any FooGallery CSS that needs to be added to the head
51
         *
52
         */
53
        function include_gallery_css() {
54
            global $enqueued_foogallery_styles;
55
56
            $enqueued_foogallery_styles = array();
57
58
            foreach( $this->get_post_ids_from_query() as $post_id ) {
59
                $this->include_gallery_stylesheets_for_post( $post_id );
60
            }
61
        }
62
63
        /**
64
         * includes any CSS that needs to be added for a post
65
         *
66
         * @param $post_id int ID of the post
67
         */
68
        function include_gallery_stylesheets_for_post( $post_id ) {
69
            global $enqueued_foogallery_styles;
70
71
            if ( $post_id ) {
72
                //get any foogallery stylesheets that the post might need to include
73
                $css = get_post_meta($post_id, FOOGALLERY_META_POST_USAGE_CSS);
74
75
				if ( empty( $css ) || !is_array( $css ) ) return;
76
77
                foreach ($css as $css_item) {
78
                    if (!$css_item) continue;
79
                    foreach ($css_item as $handle => $style) {
80
                        //only enqueue the stylesheet once
81
                        if ( !array_key_exists( $handle, $enqueued_foogallery_styles ) ) {
82
                            $cache_buster_key = $handle;
83
                            if ( is_array( $style ) ) {
84
                                $cache_buster_key = $this->create_cache_buster_key( $handle, $style['ver'], array_key_exists( 'site', $style ) ? $style['site'] : '' );
85
                                wp_enqueue_style( $handle, $style['src'], $style['deps'], $style['ver'], $style['media'] );
86
                            } else {
87
                                wp_enqueue_style( $handle, $style );
88
                            }
89
90
                            $enqueued_foogallery_styles[$handle] = $cache_buster_key;
91
                        }
92
                    }
93
                }
94
            }
95
        }
96
97
        /**
98
         * Check to make sure we have added the stylesheets to our custom post meta field,
99
         * so that on next render the stylesheet will be added to the page header
100
         *
101
         * @param $style_handle string The stylesheet handle
102
         * @param $src string The location for the stylesheet
103
         * @param array $deps
104
         * @param bool $ver
105
         * @param string $media
106
         */
107
        function enqueue_style_to_persist($style_handle, $src, $deps = array(), $ver = false, $media = 'all') {
0 ignored issues
show
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...
108
            global $wp_query, $enqueued_foogallery_styles, $foogallery_styles_to_persist;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
109
110
            //we only want to do this if we are looking at a single post
111
            if ( ! is_singular() ) {
112
                return;
113
            }
114
115
            $post_id = $wp_query->post->ID;
116
            if ( $post_id ) {
117
118
                //check if the saved stylesheet needs to be cache busted
119
                if ( is_array( $enqueued_foogallery_styles ) && array_key_exists( $style_handle, $enqueued_foogallery_styles ) ) {
120
                    $registered_cache_buster_key = $enqueued_foogallery_styles[$style_handle];
121
122
                    //generate the key we want
123
                    $cache_buster_key = $this->create_cache_buster_key( $style_handle, $ver, home_url() );
124
125
                    if ( $registered_cache_buster_key !== $cache_buster_key ) {
126
                        //we need to bust this cached stylesheet!
127
                        $style = $this->get_old_style_post_meta_value( $post_id, $style_handle );
128
129
                        if ( false !== $style ) {
130
                            delete_post_meta( $post_id, FOOGALLERY_META_POST_USAGE_CSS, array( $style_handle => $style ) );
131
132
                            //unset the handle from, to force the save of the post meta
133
                            unset( $enqueued_foogallery_styles[$style_handle] );
134
                        }
135
                    }
136
                }
137
138
                //first check that the template has not been enqueued before
139
                if ( is_array( $enqueued_foogallery_styles ) && ! array_key_exists( $style_handle, $enqueued_foogallery_styles ) ) {
140
141
                    $style = array(
142
                        'src'   => $src,
143
                        'deps'  => $deps,
144
                        'ver'   => $ver,
145
                        'media' => $media,
146
                        'site'  => home_url()
147
                    );
148
149
                    if ( !is_array( $foogallery_styles_to_persist ) ) {
150
						$foogallery_styles_to_persist = array();
151
					}
152
153
					if ( !array_key_exists( $style_handle, $foogallery_styles_to_persist ) ) {
154
						$foogallery_styles_to_persist[$style_handle] = $style;
155
					}
156
157
//                    add_post_meta( $post_id, FOOGALLERY_META_POST_USAGE_CSS, array( $style_handle => $style ), false );
0 ignored issues
show
Unused Code Comprehensibility introduced by
53% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
158
//
159
//					$cache_buster_key = $this->create_cache_buster_key( $style_handle, $ver, home_url() );
160
//					$enqueued_foogallery_styles[$style_handle] = $cache_buster_key;
161
                }
162
            }
163
        }
164
165
        function create_cache_buster_key( $name, $version, $site = '' ) {
0 ignored issues
show
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...
166
            return "{$site}::{$name}_{$version}";
167
        }
168
169
        function get_old_style_post_meta_value( $post_id, $handle_to_find ) {
0 ignored issues
show
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...
170
            $css = get_post_meta($post_id, FOOGALLERY_META_POST_USAGE_CSS);
171
172
            foreach ($css as $css_item) {
173
                if ( ! $css_item ) {
174
                    continue;
175
                }
176
                foreach ( $css_item as $handle => $style ) {
177
                    //only enqueue the stylesheet once
178
                    if ( $handle_to_find === $handle ) {
179
                        return $style;
180
                    }
181
                }
182
            }
183
184
            return false;
185
        }
186
    }
187
}