PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / trunk
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! vtrunk
3.8.0 3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 All 112 releases
templately / modules / utilities / Notice / ActivationNotice.php

ActivationNotice.php in Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! trunk, at modules/utilities/Notice/ActivationNotice.php

62 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The one-time "turn on cleanup" prompt.
4 *
5 * @package Templately
6 */
7
8 namespace Templately\Modules\Utilities\Notice;
9
10 use Templately\Modules\Utilities\Cleanup\Activation;
11
12 /**
13 * Lives OUTSIDE the settings page on purpose.
14 *
15 * The activation gate means an unactivated site reclaims nothing, ever — that
16 * was a deliberate decision, and its whole cost falls on administrators who
17 * never open the plugin's settings. If the only way to discover the prompt were
18 * inside the tab, those are exactly the sites that would keep leaking.
19 *
20 * Dismissal hides the notice but is NOT consent: the tab keeps showing the
21 * pending state and the prompt remains reachable, so dismissing once cannot
22 * silently strand a site in "nothing is ever reclaimed and nothing says so".
23 */
24 final class ActivationNotice {
25
26 public static function boot(): void {
27 add_action( 'admin_notices', [ self::class, 'render' ] );
28 }
29
30 public static function render(): void {
31 if ( ! current_user_can( 'manage_options' ) ) {
32 return;
33 }
34
35 // Only when there is genuinely something to reclaim — a site with a clean
36 // uploads directory should never see this.
37 if ( ! Activation::should_prompt() ) {
38 return;
39 }
40
41 $state = Activation::state();
42 // The settings SPA is its OWN admin page (`templately_settings`), not a
43 // path inside the template library. Pointing at the library page lands on
44 // the router's catch-all and renders an unrelated view — verified in a
45 // live instance, which is the only place that shows up.
46 $settings = admin_url( 'admin.php?page=templately_settings&path=settings/elementor/utilities' );
47
48 printf(
49 '<div class="notice notice-info"><p>%s</p><p><a class="button button-primary" href="%s">%s</a></p></div>',
50 esc_html(
51 sprintf(
52 /* translators: %s: reclaimable size, e.g. "412 MB". */
53 __( 'Templately can reclaim about %s of leftover import files. Nothing is removed until you turn cleanup on.', 'templately' ),
54 size_format( (int) $state['last_estimate_bytes'] )
55 )
56 ),
57 esc_url( $settings ),
58 esc_html__( 'Review and turn on cleanup', 'templately' )
59 );
60 }
61 }
62