PluginProbe
Force Refresh / 3.2.0
Force Refresh v3.2.0
3.2.1 3.2.0 3.1.2 3.1.1 3.1.0 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.2.0 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.11.0 2.11.1 2.12.0 All 54 releases
force-refresh / includes / services / classes / class-refresh-service.php

class-refresh-service.php in Force Refresh 3.2.0, at includes/services/classes/class-refresh-service.php

55 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Our class responsible for coordinating site and page refreshes.
4 *
5 * @package ForceRefresh
6 */
7
8 namespace JordanLeven\Plugins\ForceRefresh\Services;
9
10 use JordanLeven\Plugins\ForceRefresh\Services\Refresh_Counter_Service;
11 use JordanLeven\Plugins\ForceRefresh\Services\Versions_Storage_Service;
12
13 /**
14 * Class for refresh operations.
15 */
16 class Refresh_Service {
17
18 /**
19 * Generate a new version, persist it as the site version, increment the
20 * site refresh counter, and return the new version.
21 *
22 * @return string The new site version.
23 */
24 public static function update_version_site(): string {
25 $version = self::get_new_version();
26 Versions_Storage_Service::set_site_version( $version );
27 Refresh_Counter_Service::increment_site_refresh_count();
28 return $version;
29 }
30
31 /**
32 * Generate a new version, persist it as the page version, increment the
33 * page refresh counter, and return the new version.
34 *
35 * @param int $page_id The post ID to refresh.
36 *
37 * @return string The new page version.
38 */
39 public static function update_version_page( int $page_id ): string {
40 $version = self::get_new_version();
41 Versions_Storage_Service::set_page_version( $page_id, $version );
42 Refresh_Counter_Service::increment_page_refresh_count( $page_id );
43 return $version;
44 }
45
46 /**
47 * Generate a new unique version string.
48 *
49 * @return string
50 */
51 private static function get_new_version(): string {
52 return Versions_Storage_Service::get_new_version();
53 }
54 }
55