PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.5.8
Shortcodes and extra features for Phlox theme v2.5.8
2.17.21 2.17.20 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.6 1.0.9 1.1.0 1.3.0 1.3.1 1.3.10 1.3.14 1.3.2 1.3.3 1.3.6 1.4.0 1.4.1 1.4.2 1.5.0 1.5.2 1.6.0 1.6.2 1.6.4 1.7.0 1.7.2 2.10.0 2.10.1 2.10.3 2.10.5 2.10.7 2.10.8 2.10.9 2.11.0 2.11.1 2.11.2 2.12.0 2.14.0 2.15.0 2.15.2 2.15.4 2.15.5 2.15.6 2.15.7 2.15.8 2.15.9 2.16.0 2.16.1 2.16.2 2.16.3 2.16.4 2.17.0 2.17.1 2.17.12 2.17.13 2.17.14 2.17.15 2.17.16 2.17.2 2.17.3 2.17.4 2.17.5 2.17.6 2.17.8 2.17.9 2.4.12 2.4.13 2.4.14 2.4.16 2.4.18 2.4.19 2.4.9 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.14 2.5.15 2.5.16 2.5.17 2.5.19 2.5.2 2.5.20 2.5.3 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.10 2.6.12 2.6.13 2.6.14 2.6.15 2.6.16 2.6.17 2.6.19 2.6.2 2.6.20 2.6.4 2.6.5 2.6.7 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.9 2.9.0 2.9.12 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.19 2.9.2 2.9.20 2.9.21 2.9.22 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8
auxin-elements / admin / includes / classes / class-auxin-dashboard-notice.php
auxin-elements / admin / includes / classes Last commit date
class-auxels-plugin-check-update.php 6 years ago class-auxin-dashboard-notice.php 7 years ago class-auxin-license-activation.php 7 years ago class-auxin-notices.php 6 years ago class-auxin-upgrader-ajax-handlers.php 7 years ago class-auxin-upgrader-http-api.php 6 years ago class-auxin-upgrader-plugin.php 7 years ago class-auxin-upgrader-prepare.php 6 years ago class-auxin-upgrader-theme.php 7 years ago
class-auxin-dashboard-notice.php
241 lines
1 <?php
2 /**
3 * Auxin admin notices
4 */
5 class Auxin_Dashboard_Notice {
6
7 /**
8 * Instance of this class.
9 *
10 * @var object
11 */
12 protected static $instance = null;
13
14
15 /**
16 * The list of notice IDs
17 *
18 * @var object
19 */
20 private $notice_ids = array();
21
22 /**
23 * Notices
24 *
25 * @var array
26 */
27 private $notices = array();
28
29 /**
30 * Base API URL
31 *
32 * @var string
33 */
34 private $base_url = '';
35
36 /**
37 * Prefix
38 *
39 * @var string
40 */
41 private $prefix = 'auxin-';
42
43
44 function __construct(){
45
46 $this->notice_ids = array(
47 'auxels-notice-info-dashboard'
48 );
49
50 $this->prefix = THEME_ID . '-';
51
52 $this->base_url = 'http://cdn.averta.net/project/phlox/free/info/';
53 }
54
55 // Methods using the plugin API
56 // =========================================================================
57
58 private function get_option( $option_key ){
59 return auxin_get_option( $this->prefix . $option_key );
60 }
61
62 private function update_option( $option_key, $option_value ){
63 return auxin_update_option( $this->prefix . $option_key, $option_value );
64 }
65
66 private function get_transient( $transient ){
67 return auxin_get_transient( $this->prefix . $transient );
68 }
69
70 private function set_transient( $transient, $value, $expiration = 0 ){
71 return auxin_set_transient( $this->prefix . $transient, $value, $expiration );
72 }
73
74 private function delete_transient( $transient ){
75 return auxin_delete_transient( $this->prefix . $transient );
76 }
77
78 private function get_remote_post( $url ){
79 return auxin_remote_post( $url );
80 }
81
82 // =========================================================================
83
84 private function get_notice_info_transient_id( $notice_id ){
85 return 'notice-info-' . esc_attr( $notice_id );
86 }
87
88 private function fetch_notice_info( $notice_id, $force_update = false ){
89
90 if( empty( $notice_id ) ){
91 return false;
92 }
93
94 // defaults
95 $defaults = array(
96 'remote_url' => '', // the remote notice url
97 'beta_url' => '', // beta remote content
98 'revision' => '', // empty means don't display
99 'first_delay' => 0, // in seconds
100 'id' => $notice_id,
101 'enabled' => true,
102
103 'content' => '', // the remote notice content
104 'delay_passed' => false, // the remote notice content
105 'debug' => array()
106 );
107
108 // info transient id
109 $transient_id = $this->get_notice_info_transient_id( $notice_id );
110
111 if( isset( $_GET['msafi'] ) ){
112 $this->delete_transient( $transient_id );
113 }
114
115 if( ! $force_update && false !== ( $result = $this->get_transient( $transient_id ) ) ){
116 // wp_parse_args to prevent the errors while new args implemented in new versions
117 $defaults['debug'][] = '1.1';
118 return wp_parse_args( $result, $defaults );
119 }
120
121 if( false === $info = $this->get_remote_post( $this->base_url . $notice_id . '.json' ) ){
122 $defaults['debug'][] = '1.2';
123 return $defaults;
124 } else {
125 $info = json_decode( $info, true );
126 $info = wp_parse_args( $info, $defaults );
127 $info['debug'][] = '1.3';
128 }
129
130 // get remote content
131 $remote_url = isset( $_GET['msbeta'] ) ? $info["beta_url"] : $info["remote_url"];
132 $info["content"] = $this->fetch_file_content( $remote_url );
133
134 if( empty( $info["revision"] ) ){
135 $info["enabled"] = false;
136 $info['debug'][] = '1.4';
137
138 } elseif( is_numeric( $info['revision'] ) && $info['revision'] != $this->get_option( 'notice-'. $notice_id .'-latest-revision' ) ){
139 $info["enabled"] = true;
140 $info['debug'][] = '1.5';
141 } else {
142 $info["enabled"] = false;
143 $info['debug'][] = '1.55';
144 }
145
146 if( ! $this->get_option( 'notice-installtion-time' ) ){
147 $this->update_option( 'notice-installtion-time', time() );
148 $info['debug'][] = '1.6';
149 }
150
151 $first_delay_diff = ( ( $this->get_option( 'notice-installtion-time' ) + ( (int) $info['first_delay'] ) ) - time() );
152 $info['debug'][] = 'Due - Now: '. ( $first_delay_diff < 0 ? 'Passed ' . abs($first_delay_diff) : ' Remaining ' . abs($first_delay_diff) ) . ' seconds';
153 $info['debug'][] = 'Previous revision: '. $this->get_option( 'notice-'. $notice_id .'-latest-revision' );
154 $info['debug'][] = 'Remote revision: '. $info['revision'];
155
156 // check for initial delay
157 if( $info['first_delay'] ){
158 if( $this->get_option( 'notice-installtion-time' ) + ( (int) $info['first_delay'] ) > time() ){
159 $info['debug'][] = '1.7';
160 $info["delay_passed"] = false;
161 } else {
162 $info["delay_passed"] = true;
163 $info['debug'][] = '1.8';
164 }
165 } else {
166 $info["delay_passed"] = true;
167 }
168
169 $this->set_transient( $transient_id, $info, 6 * HOUR_IN_SECONDS );
170
171 return $info;
172 }
173
174 private function fetch_file_content( $url ){
175 if( false === $result = $this->get_remote_post( $url ) ){
176 return '';
177 }
178 return $result;
179 }
180
181 public function get_content( $notice_id ){
182 $result = $this->fetch_notice_info( $notice_id );
183
184 if( isset( $_GET['msdebug'] ) ){
185 $debug_info = $result;
186 unset( $debug_info['content'] );
187 $debug = axpp( $debug_info, false, true );
188 } else {
189 $debug = '';
190 }
191
192 if( ! empty( $result['content'] ) && $result['enabled'] && $result['delay_passed'] ){
193 return $result['content'] . $debug;
194 }
195
196 return $debug;
197 }
198
199
200 public function get_notice( $notice_id ){
201 if( $content = $this->get_content( $notice_id ) ){
202 return '<div class="aux-welcome-notice-wrapper aux-welcome-banner-wrapper">' . $content . '</div>';
203 }
204 return '';
205 }
206
207 public function disable_notice( $notice_id ){
208
209 if( ! in_array( $notice_id, $this->notice_ids ) ){
210 return false;
211 }
212
213 // info transient id
214 $transient_id = $this->get_notice_info_transient_id( $notice_id );
215
216 if( false !== ( $info = $this->fetch_notice_info( $notice_id ) ) ){
217 $this->update_option( 'notice-'. $notice_id .'-latest-revision', $info['revision'] );
218 $info['enabled'] = false;
219 $this->set_transient( $transient_id, $info, 6 * HOUR_IN_SECONDS );
220 }
221
222 return true;
223 }
224
225 /**
226 * Return an instance of this class.
227 *
228 * @return object A single instance of this class.
229 */
230 public static function get_instance() {
231
232 // If the single instance hasn't been set, set it now.
233 if ( null == self::$instance ) {
234 self::$instance = new self;
235 }
236
237 return self::$instance;
238 }
239
240 }
241