PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.3.3
Gallery : FooGallery v3.3.3
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-rank-math-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-rank-math-seo-sitemaps.php
52 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 /**
8 * Adds support for Rank Math SEO Sitemaps
9 *
10 * Created by Rank Math.
11 * Date: 27/09/2019
12 */
13 if ( ! class_exists( 'FooGallery_RankMath_Seo_Sitemap_Support' ) ) {
14
15 class FooGallery_RankMath_Seo_Sitemap_Support {
16
17 function __construct() {
18 add_filter( 'rank_math/sitemap/urlimages', array( $this, 'add_images_to_sitemap' ), 10, 2 );
19 }
20
21 function add_images_to_sitemap( $images, $post_id ) {
22 //check the content for $post_id contains a foogallery shortcode
23
24 //get all the foogalleries used in the posts
25 $galleries = get_post_meta( $post_id, FOOGALLERY_META_POST_USAGE );
26 if ( is_array( $galleries ) ) {
27 foreach ( $galleries as $gallery_id ) {
28
29 //load each gallery
30 $gallery = FooGallery::get_by_id( $gallery_id );
31
32 if ( false === $gallery ) {
33 continue;
34 }
35
36 //add each image to the sitemap image array
37 foreach ( $gallery->attachments() as $attachment ) {
38 $image = array(
39 'src' => $attachment->url,
40 'title' => $attachment->caption,
41 'alt' => $attachment->alt
42 );
43 $images[] = $image;
44 }
45 }
46 }
47
48 return $images;
49 }
50 }
51 }
52