PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.3.2
Gallery : FooGallery v3.3.2
3.3.2 3.3.3 3.3.0 3.1.31 3.1.32 3.1.34 3.1.36 3.2.0 3.2.6 trunk 1.10.3 2.0.24 2.1.34 2.2.44 2.3.3 2.4.32 3.0.6 3.1.11 3.1.12 3.1.13 3.1.20 3.1.25 3.1.26 3.1.26.1 3.1.26.2
foogallery / includes / public / class-yoast-seo-sitemaps.php
foogallery / includes / public Last commit date
class-admin-bar.php 2 days ago class-aioseo-sitemaps.php 2 days ago class-css-load-optimizer.php 2 days ago class-foogallery-template-loader.php 2 days ago class-public.php 2 days ago class-rank-math-seo-sitemaps.php 2 days ago class-shortcodes.php 2 days ago class-yoast-seo-sitemaps.php 2 days ago index.php 2 days ago
class-yoast-seo-sitemaps.php
53 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 /**
8 * Adds support for Yoast SEO Sitemaps
9 * - so that images in a FooGallery are added to the sitemap
10 *
11 * Created by brad.
12 * Date: 21/12/2015
13 */
14 if ( ! class_exists( 'FooGallery_Yoast_Seo_Sitemap_Support' ) ) {
15
16 class FooGallery_Yoast_Seo_Sitemap_Support {
17
18 function __construct() {
19 add_filter( 'wpseo_sitemap_urlimages', array( $this, 'add_images_to_sitemap' ), 10, 2 );
20 }
21
22 function add_images_to_sitemap( $images, $post_id ) {
23 //check the content for $post_id contains a foogallery shortcode
24
25 //get all the foogalleries used in the posts
26 $galleries = get_post_meta( $post_id, FOOGALLERY_META_POST_USAGE );
27 if ( is_array( $galleries ) ) {
28 foreach ( $galleries as $gallery_id ) {
29
30 //load each gallery
31 $gallery = FooGallery::get_by_id( $gallery_id );
32
33 if ( false === $gallery ) {
34 continue;
35 }
36
37 //add each image to the sitemap image array
38 foreach ( $gallery->attachments() as $attachment ) {
39 $image = array(
40 'src' => $attachment->url,
41 'title' => $attachment->caption,
42 'alt' => $attachment->alt
43 );
44 $images[] = $image;
45 }
46 }
47 }
48
49 return $images;
50 }
51 }
52 }
53