PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.1.36
Gallery : FooGallery v3.1.36
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 / class-foogallery-sitemaps.php
foogallery / includes Last commit date
abilities 2 months ago admin 2 months ago compatibility 2 months ago extensions 2 months ago foopluginbase 2 months ago public 2 months ago thumbs 2 months ago asset-manifest.php 2 months ago class-attachment-filters.php 2 months ago class-command-palette.php 2 months ago class-foogallery-animated-gif-support.php 2 months ago class-foogallery-attachment-custom-class.php 2 months ago class-foogallery-attachment-filename.php 2 months ago class-foogallery-attachment-type.php 2 months ago class-foogallery-attachment.php 2 months ago class-foogallery-cache.php 2 months ago class-foogallery-common-fields.php 2 months ago class-foogallery-crop-position.php 2 months ago class-foogallery-datasource-media_library.php 2 months ago class-foogallery-debug.php 2 months ago class-foogallery-delayed-runtime-loader.php 2 months ago class-foogallery-extensions-compatibility.php 2 months ago class-foogallery-force-https.php 2 months ago class-foogallery-lazyload.php 2 months ago class-foogallery-license-constant-handler.php 2 months ago class-foogallery-lightbox.php 2 months ago class-foogallery-paging.php 2 months ago class-foogallery-password-protect.php 2 months ago class-foogallery-sitemaps.php 2 months ago class-foogallery-widget.php 2 months ago class-foogallery.php 2 months ago class-gallery-advanced-settings.php 2 months ago class-il8n.php 2 months ago class-override-thumbnail.php 2 months ago class-posttypes.php 2 months ago class-previews.php 2 months ago class-retina.php 2 months ago class-thumbnail-dimensions.php 2 months ago class-thumbnails.php 2 months ago class-version-check.php 2 months ago constants.php 2 months ago functions.php 2 months ago includes.php 2 months ago index.php 2 months ago render-functions.php 2 months ago
class-foogallery-sitemaps.php
100 lines
1 <?php
2 /**
3 * Class for managing sitemaps within FooGallery
4 */
5
6 if ( ! class_exists( 'FooGallery_Sitemaps' ) ) {
7 class FooGallery_Sitemaps {
8 public function __construct() {
9 //add_action('init', array( $this, 'register_sitemaps' ) );
10 //add_filter( 'wp_sitemaps_posts_entry', array( $this, 'add_images_to_sitemap_entry'), 10, 3 );
11 }
12
13 public function register_sitemaps() {
14 //check if WordPress sitemaps are supported
15 if ( function_exists( 'wp_register_sitemap_provider' ) && class_exists( 'WP_Sitemaps_Provider' ) ) {
16 $provider = new FooGallery_Sitemaps_Provider();
17 wp_register_sitemap_provider( 'foogallery', $provider );
18 }
19 }
20
21 public function add_images_to_sitemap_entry( $sitemap_entry, $post, $post_type ) {
22 $galleries = get_post_meta( $post->ID, FOOGALLERY_META_POST_USAGE );
23 foreach ( $galleries as $gallery_id ) {
24
25 //load each gallery
26 $gallery = FooGallery::get_by_id( $gallery_id );
27
28 if ( false === $gallery ) continue;
29
30 //add each image to the sitemap image array
31 foreach ( $gallery->attachments() as $attachment ) {
32 $sitemap_entry['image:image'][] = array(
33 'image:loc' => $attachment->url,
34 'image:title' => $attachment->caption,
35 'image:caption' => $attachment->alt
36 );
37 }
38 }
39
40 return $sitemap_entry;
41 }
42 }
43 }
44
45 if ( ! class_exists( 'FooGallery_Sitemaps_Provider' ) ) {
46 class FooGallery_Sitemaps_Provider extends WP_Sitemaps_Provider {
47
48 /**
49 * WP_Sitemaps_My_Plugin constructor.
50 *
51 * @since 5.5.0 (use your plugin version)
52 */
53 public function __construct() {
54 $this->name = 'foogallery';
55 $this->object_type = 'image';
56 }
57
58 public function get_url_list( $page_num, $object_subtype = '' ) {
59 $url_list = array();
60
61 //get all galleries
62 $galleries = foogallery_get_all_galleries();
63
64 //find all pages or posts that have galleries
65 foreach ( $galleries as $gallery ) {
66 $gallery_usages = $gallery->find_usages();
67
68 foreach ( $gallery_usages as $post ) {
69 $sitemap_entry = array(
70 'loc' => get_permalink( $post ),
71 );
72
73 $url_list[] = $sitemap_entry;
74 }
75 }
76
77 return $url_list;
78 }
79
80 /**
81 * Gets the max number of pages available for the object type.
82 *
83 * @since 5.5.0 (use your plugin version)
84 *
85 * @see WP_Sitemaps_Provider::max_num_pages
86 *
87 * @param string $object_subtype Optional. Default empty.
88 *
89 * @return int Total page count.
90 */
91 public function get_max_num_pages( $object_subtype = '' ) {
92 // again, use a function from your own plugin to fetch this data.
93 //$pages = plugin_prefix_get_my_pagination();
94
95 //return count( $pages );
96
97 return 0;
98 }
99 }
100 }