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.

FooGallery_Yoast_Seo_Sitemap_Support   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A add_images_to_sitemap() 0 27 4
1
<?php
2
/**
3
 * Adds support for Yoast SEO Sitemaps
4
 *  - so that images in a FooGallery are added to the sitemap
5
 *
6
 * Created by brad.
7
 * Date: 21/12/2015
8
 */
9
if ( ! class_exists( 'FooGallery_Yoast_Seo_Sitemap_Support' ) ) {
10
11
	class FooGallery_Yoast_Seo_Sitemap_Support {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
12
13
		function __construct() {
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...
14
			add_filter( 'wpseo_sitemap_urlimages', array( $this, 'add_images_to_sitemap' ), 10, 2 );
15
		}
16
17
		function add_images_to_sitemap( $images, $post_id ) {
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...
18
			//check the content for $post_id contains a foogallery shortcode
19
			$post = get_post( $post_id );
20
21
			//get all the foogallery shortcodes in the post
22
			$gallery_shortcodes = foogallery_extract_gallery_shortcodes( $post->post_content );
23
24
			foreach ( $gallery_shortcodes as $gallery_id => $shortcode ) {
25
26
				//load each gallery
27
				$gallery = FooGallery::get_by_id( $gallery_id );
28
29
                if ( false === $gallery ) continue;
30
31
				//add each image to the sitemap image array
32
				foreach ( $gallery->attachments() as $attachment ) {
33
					$image = array(
34
						'src'   => $attachment->url,
35
						'title' => $attachment->caption,
36
						'alt'   => $attachment->alt
37
					);
38
					$images[] = $image;
39
				}
40
			}
41
42
			return $images;
43
		}
44
	}
45
}