PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.8
WpStream – Live Streaming, Video on Demand, Pay Per View v4.8
4.14.1 4.14.0 4.13.2 4.13.1 4.13 4.12.5 4.12.4 4.12.3 4.12.2 4.12.1 4.12 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5 4.5.1 4.5.11 4.5.11.1 4.5.11.2 4.5.11.4 4.5.11.5 4.5.11.6 All 181 releases
wpstream / includes / class-wpstream-theme-notice.php

class-wpstream-theme-notice.php in WpStream – Live Streaming, Video on Demand, Pay Per View 4.8, at includes/class-wpstream-theme-notice.php

55 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Handle theme update notice
4 */
5 class WPStream_Theme_Notice {
6
7 private $theme_slug = 'hello-wpstream';
8 private $notice_option = 'wpstream_theme_notice_dismissed';
9 private $nonce_action = 'wpstream_dismiss_notice';
10
11 public function __construct() {
12 add_action( 'admin_notices', array( $this, 'display_admin_notice' ) );
13 }
14
15 public function display_admin_notice() {
16 if ( !$this->should_display_notice() ) {
17 return;
18 }
19
20 $theme_data = $this->get_theme_update_data();
21 if ( !$theme_data ) {
22 return;
23 }
24
25 $this->render_notice( $theme_data );
26 }
27
28 private function should_display_notice() {
29 return !get_option( $this->notice_option ) &&
30 current_user_can( 'update_themes' ) &&
31 !wp_doing_ajax();
32 }
33
34 private function get_theme_update_data() {
35 $theme = wp_get_theme( $this->theme_slug );
36 if ( !$theme->exists() ) {
37 return false;
38 }
39
40 $updates = get_site_transient( 'update_themes' );
41 if ( !isset( $updates->response[$this->theme_slug] ) ) {
42 return false;
43 }
44
45 return array(
46 'current_version' => $theme->get( 'Version' ),
47 'new_version' => $updates->response[$this->theme_slug]['new_version'],
48 );
49 }
50
51
52 public function render_notice( $data ) {
53 include plugin_dir_path( __FILE__ ) . 'templates/wpstream-theme-update-notice.php';
54 }
55 }