PluginProbe
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 2.25.2
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v2.25.2
4.7.2 4.7.1 4.7.0 4.6.6 4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.1 4.5.0 4.4.2 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.3 4.2.2 4.2.1 1.0.3 1.0.4 1.0.5 All 281 releases
surecart / app / src / Integrations / RankMath / CollectionSiteMap.php
CollectionSiteMap.php
69 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SureCart\Integrations\RankMath;
4
5 defined( 'ABSPATH' ) || exit;
6
7 /**
8 * Controls the Product Sitemap integration.
9 */
10 class CollectionSiteMap implements \RankMath\Sitemap\Providers\Provider {
11 /**
12 * What type of content this provider handles.
13 *
14 * @param string $type Type of content.
15 */
16 public function handles_type( $type ) {
17 return 'sc_collection' === $type;
18 }
19
20 /**
21 * Get the index links.
22 *
23 * @param int $max_entries Maximum number of entries per sitemap.
24 *
25 * @return array
26 */
27 public function get_index_links( $max_entries ) {
28 return [
29 [
30 'loc' => \RankMath\Sitemap\Router::get_base_url( 'sc_collection-sitemap.xml' ),
31 'lastmod' => date( 'c', time() ),
32 ],
33 ];
34 }
35
36 /**
37 * Get the sitemap links.
38 *
39 * @param string $type Type of content.
40 * @param int $max_entries Maximum number of entries per sitemap.
41 * @param int $current_page Current page.
42 *
43 * @return array
44 */
45 public function get_sitemap_links( $type, $max_entries, $current_page ) {
46 // get products.
47 $collection = \SureCart\Models\ProductCollection::where( [ 'status' => 'published' ] )->paginate(
48 [
49 'page' => $current_page,
50 'per_page' => $max_entries,
51 ]
52 );
53
54 $links = array_map(
55 function( $collection ) {
56 $lastmod = new \DateTime( '@' . $collection->updated_at );
57 $lastmod_w3c = $lastmod->format( 'c' );
58 return [
59 'loc' => $collection->permalink,
60 'mod' => $lastmod_w3c,
61 ];
62 },
63 $collection->data
64 );
65
66 return $links;
67 }
68 }
69