PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 0.0.13
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v0.0.13
2.12.7 2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 0.0.2 All 97 releases
sureforms / inc / updater.php

updater.php in SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz 0.0.13, at inc/updater.php

114 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * SureForms Updater.
4 * Manages important update related to the plugin.
5 *
6 * @package sureforms.
7 * @since 0.0.12
8 */
9
10 namespace SRFM\Inc;
11
12 use SRFM\Inc\Traits\Get_Instance;
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit; // Exit if accessed directly.
16 }
17
18 /**
19 * Updater class.
20 *
21 * @since 0.0.12
22 */
23 class Updater {
24
25 use Get_Instance;
26
27 /**
28 * Constructor.
29 *
30 * @since 0.0.12
31 * @return void
32 */
33 public function __construct() {
34 add_action( 'admin_init', [ $this, 'init' ] );
35 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_styles' ] );
36 add_action( 'in_plugin_update_message-' . SRFM_BASENAME, [ $this, 'plugin_update_notification' ], 10 );
37 }
38
39 /**
40 * This function will help us to determine the plugin version and update it.
41 * Any major change in the option can be handed here on the basis of last plugin version found in the database.
42 *
43 * @since 0.0.12
44 * @return void
45 */
46 public function init() {
47 // Get auto saved version number.
48 $saved_version = get_option( 'srfm-version', false );
49
50 // Update auto saved version number.
51 if ( ! $saved_version || ! is_string( $saved_version ) ) {
52
53 // Update current version.
54 update_option( 'srfm-version', SRFM_VER );
55 return;
56 }
57 }
58
59 /**
60 * Plugin update notification.
61 * This function will help us to display the update notice to the user.
62 * before updating the plugin.
63 * this info is fetched from latest available readme from repository.
64 *
65 * @param array<mixed> $data Plugin data.
66 * @since 0.0.12
67 * @return void
68 */
69 public function plugin_update_notification( $data ) {
70 if ( ! empty( $data['upgrade_notice'] ) ) { ?>
71 <hr class="srfm-plugin-update-notification__separator" />
72 <div class="srfm-plugin-update-notification">
73 <div class="srfm-plugin-update-notification__icon">
74 <span class="dashicons dashicons-info"></span>
75 </div>
76 <div>
77 <div class="srfm-plugin-update-notification__title">
78 <?php echo esc_html__( 'Heads up!', 'sureforms' ); ?>
79 </div>
80 <div class="srfm-plugin-update-notification__message">
81 <?php
82 $upgrade_notice = is_string( $data['upgrade_notice'] ) ? $data['upgrade_notice'] : '';
83 printf(
84 wp_kses(
85 $upgrade_notice,
86 [ 'a' => [ 'href' => [] ] ]
87 )
88 );
89 ?>
90 </div>
91 </div>
92 </div>
93 <?php
94 } //end if
95 }
96
97 /**
98 * Enqueue styles.
99 * This function will help us to enqueue the styles for the update notice.
100 *
101 * @since 0.0.12
102 * @return void
103 */
104 public function enqueue_styles() {
105
106 $screen = get_current_screen();
107 if ( empty( $screen->id ) || 'plugins' !== $screen->id ) {
108 return;
109 }
110 wp_enqueue_style( 'srfm-update-notice', SRFM_URL . 'admin/assets/css/update-notice.css', [], SRFM_VER );
111 }
112
113 }
114