Version Description
- Fixed widget ticker title bug.
- Added a centralized licensing system for all extensions. Extensions will be updated soon to utilize this feature.
Download this release
Release Info
Developer | metaphorcreations |
Plugin | Ditty News Ticker |
Version | 2.1.17 |
Comparing to | |
See all releases |
Code changes from version 2.1.16 to 2.1.17
- assets/css/style-admin.css +10 -0
- assets/js/ditty-news-ticker.js +4 -0
- assets/sass/style-admin.scss +15 -0
- ditty-news-ticker.php +4 -3
- eddsl/EDD_SL_Plugin_Updater.php +491 -0
- eddsl/eddsl.php +704 -0
- includes/admin/scripts.php +2 -1
- includes/scripts.php +5 -0
- includes/widget.php +28 -11
- readme.txt +6 -2
assets/css/style-admin.css
CHANGED
@@ -7,6 +7,16 @@
|
|
7 |
/* --------------------------------------------------------- */
|
8 |
/* !Variables */
|
9 |
/* --------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
/* --------------------------------------------------------- */
|
11 |
/* !Dashboard Menu Icon */
|
12 |
/* --------------------------------------------------------- */
|
7 |
/* --------------------------------------------------------- */
|
8 |
/* !Variables */
|
9 |
/* --------------------------------------------------------- */
|
10 |
+
/* --------------------------------------------------------- */
|
11 |
+
/* !Licenses */
|
12 |
+
/* --------------------------------------------------------- */
|
13 |
+
.mtphr-dnt-license-spinner {
|
14 |
+
float: none;
|
15 |
+
margin: 0 0 0 5px; }
|
16 |
+
|
17 |
+
.mtphr-dnt-license-group:not(.mtphr-dnt-license-valid) .ditty-news-ticker-license-deactivate {
|
18 |
+
display: none; }
|
19 |
+
|
20 |
/* --------------------------------------------------------- */
|
21 |
/* !Dashboard Menu Icon */
|
22 |
/* --------------------------------------------------------- */
|
assets/js/ditty-news-ticker.js
CHANGED
@@ -462,7 +462,11 @@
|
|
462 |
break;
|
463 |
|
464 |
case 'right':
|
|
|
465 |
position = parseInt('-'+($tick.width()+settings.offset));
|
|
|
|
|
|
|
466 |
$tick.stop(true,true).css('left',position+'px');
|
467 |
break;
|
468 |
|
462 |
break;
|
463 |
|
464 |
case 'right':
|
465 |
+
//console.log(settings.offset);
|
466 |
position = parseInt('-'+($tick.width()+settings.offset));
|
467 |
+
if( mtphr_dnt_vars.is_rtl ) {
|
468 |
+
position = parseInt('-'+($tick.width()+(ticker_width/2)));
|
469 |
+
}
|
470 |
$tick.stop(true,true).css('left',position+'px');
|
471 |
break;
|
472 |
|
assets/sass/style-admin.scss
CHANGED
@@ -24,6 +24,21 @@ $green: $highlight-color;
|
|
24 |
$red: hsl(0, 100%, 50%);
|
25 |
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
/* --------------------------------------------------------- */
|
28 |
/* !Dashboard Menu Icon */
|
29 |
/* --------------------------------------------------------- */
|
24 |
$red: hsl(0, 100%, 50%);
|
25 |
|
26 |
|
27 |
+
/* --------------------------------------------------------- */
|
28 |
+
/* !Licenses */
|
29 |
+
/* --------------------------------------------------------- */
|
30 |
+
|
31 |
+
.mtphr-dnt-license-spinner {
|
32 |
+
float: none;
|
33 |
+
margin: 0 0 0 5px;
|
34 |
+
}
|
35 |
+
.mtphr-dnt-license-group:not(.mtphr-dnt-license-valid) {
|
36 |
+
.ditty-news-ticker-license-deactivate {
|
37 |
+
display: none;
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
/* --------------------------------------------------------- */
|
43 |
/* !Dashboard Menu Icon */
|
44 |
/* --------------------------------------------------------- */
|
ditty-news-ticker.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://dittynewsticker.com/
|
|
5 |
Description: Ditty News Ticker is a multi-functional data display plugin
|
6 |
Text Domain: ditty-news-ticker
|
7 |
Domain Path: languages
|
8 |
-
Version: 2.1.
|
9 |
Author: Metaphor Creations
|
10 |
Author URI: http://www.metaphorcreations.com
|
11 |
Contributors: metaphorcreations
|
@@ -31,16 +31,17 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
31 |
|
32 |
|
33 |
|
34 |
-
define( 'MTPHR_DNT_VERSION', '2.1.
|
35 |
define( 'MTPHR_DNT_DIR', trailingslashit(plugin_dir_path( __FILE__ )) );
|
36 |
define( 'MTPHR_DNT_FILE', trailingslashit( __FILE__ ) );
|
37 |
-
|
38 |
|
39 |
/* --------------------------------------------------------- */
|
40 |
/* !Include files - 1.5.0 */
|
41 |
/* --------------------------------------------------------- */
|
42 |
|
43 |
// Load the general functions
|
|
|
44 |
require_once( MTPHR_DNT_DIR.'includes/helpers.php' );
|
45 |
require_once( MTPHR_DNT_DIR.'includes/post-types.php' );
|
46 |
require_once( MTPHR_DNT_DIR.'includes/settings.php' );
|
5 |
Description: Ditty News Ticker is a multi-functional data display plugin
|
6 |
Text Domain: ditty-news-ticker
|
7 |
Domain Path: languages
|
8 |
+
Version: 2.1.17
|
9 |
Author: Metaphor Creations
|
10 |
Author URI: http://www.metaphorcreations.com
|
11 |
Contributors: metaphorcreations
|
31 |
|
32 |
|
33 |
|
34 |
+
define( 'MTPHR_DNT_VERSION', '2.1.17' );
|
35 |
define( 'MTPHR_DNT_DIR', trailingslashit(plugin_dir_path( __FILE__ )) );
|
36 |
define( 'MTPHR_DNT_FILE', trailingslashit( __FILE__ ) );
|
37 |
+
define( 'MTPHR_DNT_STORE_URL', 'https://www.metaphorcreations.com' );
|
38 |
|
39 |
/* --------------------------------------------------------- */
|
40 |
/* !Include files - 1.5.0 */
|
41 |
/* --------------------------------------------------------- */
|
42 |
|
43 |
// Load the general functions
|
44 |
+
require_once( MTPHR_DNT_DIR.'eddsl/eddsl.php' );
|
45 |
require_once( MTPHR_DNT_DIR.'includes/helpers.php' );
|
46 |
require_once( MTPHR_DNT_DIR.'includes/post-types.php' );
|
47 |
require_once( MTPHR_DNT_DIR.'includes/settings.php' );
|
eddsl/EDD_SL_Plugin_Updater.php
ADDED
@@ -0,0 +1,491 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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easy Digital Downloads
|
10 |
+
* @version 1.6.14
|
11 |
+
*/
|
12 |
+
class EDD_SL_Plugin_Updater {
|
13 |
+
|
14 |
+
private $api_url = '';
|
15 |
+
private $api_data = array();
|
16 |
+
private $name = '';
|
17 |
+
private $slug = '';
|
18 |
+
private $version = '';
|
19 |
+
private $wp_override = false;
|
20 |
+
private $cache_key = '';
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Class constructor.
|
24 |
+
*
|
25 |
+
* @uses plugin_basename()
|
26 |
+
* @uses hook()
|
27 |
+
*
|
28 |
+
* @param string $_api_url The URL pointing to the custom API endpoint.
|
29 |
+
* @param string $_plugin_file Path to the plugin file.
|
30 |
+
* @param array $_api_data Optional data to send with API calls.
|
31 |
+
*/
|
32 |
+
public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
|
33 |
+
|
34 |
+
global $edd_plugin_data;
|
35 |
+
|
36 |
+
$this->api_url = trailingslashit( $_api_url );
|
37 |
+
$this->api_data = $_api_data;
|
38 |
+
$this->name = plugin_basename( $_plugin_file );
|
39 |
+
$this->slug = basename( $_plugin_file, '.php' );
|
40 |
+
$this->version = $_api_data['version'];
|
41 |
+
$this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
|
42 |
+
$this->beta = ! empty( $this->api_data['beta'] ) ? true : false;
|
43 |
+
$this->cache_key = md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
|
44 |
+
|
45 |
+
$edd_plugin_data[ $this->slug ] = $this->api_data;
|
46 |
+
|
47 |
+
// Set up hooks.
|
48 |
+
$this->init();
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Set up WordPress filters to hook into WP's update process.
|
54 |
+
*
|
55 |
+
* @uses add_filter()
|
56 |
+
*
|
57 |
+
* @return void
|
58 |
+
*/
|
59 |
+
public function init() {
|
60 |
+
|
61 |
+
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
|
62 |
+
add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
|
63 |
+
remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );
|
64 |
+
add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
|
65 |
+
add_action( 'admin_init', array( $this, 'show_changelog' ) );
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Check for Updates at the defined API endpoint and modify the update array.
|
71 |
+
*
|
72 |
+
* This function dives into the update API just when WordPress creates its update array,
|
73 |
+
* then adds a custom API call and injects the custom plugin data retrieved from the API.
|
74 |
+
* It is reassembled from parts of the native WordPress plugin update code.
|
75 |
+
* See wp-includes/update.php line 121 for the original wp_update_plugins() function.
|
76 |
+
*
|
77 |
+
* @uses api_request()
|
78 |
+
*
|
79 |
+
* @param array $_transient_data Update array build by WordPress.
|
80 |
+
* @return array Modified update array with custom plugin data.
|
81 |
+
*/
|
82 |
+
public function check_update( $_transient_data ) {
|
83 |
+
|
84 |
+
global $pagenow;
|
85 |
+
|
86 |
+
if ( ! is_object( $_transient_data ) ) {
|
87 |
+
$_transient_data = new stdClass;
|
88 |
+
}
|
89 |
+
|
90 |
+
if ( 'plugins.php' == $pagenow && is_multisite() ) {
|
91 |
+
return $_transient_data;
|
92 |
+
}
|
93 |
+
|
94 |
+
if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
|
95 |
+
return $_transient_data;
|
96 |
+
}
|
97 |
+
|
98 |
+
$version_info = $this->get_cached_version_info();
|
99 |
+
|
100 |
+
if ( false === $version_info ) {
|
101 |
+
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
|
102 |
+
|
103 |
+
$this->set_version_info_cache( $version_info );
|
104 |
+
|
105 |
+
}
|
106 |
+
|
107 |
+
if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
|
108 |
+
|
109 |
+
if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
110 |
+
|
111 |
+
$_transient_data->response[ $this->name ] = $version_info;
|
112 |
+
|
113 |
+
}
|
114 |
+
|
115 |
+
$_transient_data->last_checked = current_time( 'timestamp' );
|
116 |
+
$_transient_data->checked[ $this->name ] = $this->version;
|
117 |
+
|
118 |
+
}
|
119 |
+
|
120 |
+
return $_transient_data;
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
|
125 |
+
*
|
126 |
+
* @param string $file
|
127 |
+
* @param array $plugin
|
128 |
+
*/
|
129 |
+
public function show_update_notification( $file, $plugin ) {
|
130 |
+
|
131 |
+
if ( is_network_admin() ) {
|
132 |
+
return;
|
133 |
+
}
|
134 |
+
|
135 |
+
if( ! current_user_can( 'update_plugins' ) ) {
|
136 |
+
return;
|
137 |
+
}
|
138 |
+
|
139 |
+
if( ! is_multisite() ) {
|
140 |
+
return;
|
141 |
+
}
|
142 |
+
|
143 |
+
if ( $this->name != $file ) {
|
144 |
+
return;
|
145 |
+
}
|
146 |
+
|
147 |
+
// Remove our filter on the site transient
|
148 |
+
remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
|
149 |
+
|
150 |
+
$update_cache = get_site_transient( 'update_plugins' );
|
151 |
+
|
152 |
+
$update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
|
153 |
+
|
154 |
+
if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
|
155 |
+
|
156 |
+
$version_info = $this->get_cached_version_info();
|
157 |
+
|
158 |
+
if ( false === $version_info ) {
|
159 |
+
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
|
160 |
+
|
161 |
+
$this->set_version_info_cache( $version_info );
|
162 |
+
}
|
163 |
+
|
164 |
+
if ( ! is_object( $version_info ) ) {
|
165 |
+
return;
|
166 |
+
}
|
167 |
+
|
168 |
+
if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
169 |
+
|
170 |
+
$update_cache->response[ $this->name ] = $version_info;
|
171 |
+
|
172 |
+
}
|
173 |
+
|
174 |
+
$update_cache->last_checked = current_time( 'timestamp' );
|
175 |
+
$update_cache->checked[ $this->name ] = $this->version;
|
176 |
+
|
177 |
+
set_site_transient( 'update_plugins', $update_cache );
|
178 |
+
|
179 |
+
} else {
|
180 |
+
|
181 |
+
$version_info = $update_cache->response[ $this->name ];
|
182 |
+
|
183 |
+
}
|
184 |
+
|
185 |
+
// Restore our filter
|
186 |
+
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
|
187 |
+
|
188 |
+
if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
189 |
+
|
190 |
+
// build a plugin list row, with update notification
|
191 |
+
$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
|
192 |
+
# <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
|
193 |
+
echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
|
194 |
+
echo '<td colspan="3" class="plugin-update colspanchange">';
|
195 |
+
echo '<div class="update-message notice inline notice-warning notice-alt">';
|
196 |
+
|
197 |
+
$changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
|
198 |
+
|
199 |
+
if ( empty( $version_info->download_link ) ) {
|
200 |
+
printf(
|
201 |
+
__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ),
|
202 |
+
esc_html( $version_info->name ),
|
203 |
+
'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
|
204 |
+
esc_html( $version_info->new_version ),
|
205 |
+
'</a>'
|
206 |
+
);
|
207 |
+
} else {
|
208 |
+
printf(
|
209 |
+
__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads' ),
|
210 |
+
esc_html( $version_info->name ),
|
211 |
+
'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
|
212 |
+
esc_html( $version_info->new_version ),
|
213 |
+
'</a>',
|
214 |
+
'<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',
|
215 |
+
'</a>'
|
216 |
+
);
|
217 |
+
}
|
218 |
+
|
219 |
+
do_action( "in_plugin_update_message-{$file}", $plugin, $version_info );
|
220 |
+
|
221 |
+
echo '</div></td></tr>';
|
222 |
+
}
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Updates information on the "View version x.x details" page with custom data.
|
227 |
+
*
|
228 |
+
* @uses api_request()
|
229 |
+
*
|
230 |
+
* @param mixed $_data
|
231 |
+
* @param string $_action
|
232 |
+
* @param object $_args
|
233 |
+
* @return object $_data
|
234 |
+
*/
|
235 |
+
public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
|
236 |
+
|
237 |
+
if ( $_action != 'plugin_information' ) {
|
238 |
+
|
239 |
+
return $_data;
|
240 |
+
|
241 |
+
}
|
242 |
+
|
243 |
+
if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
|
244 |
+
|
245 |
+
return $_data;
|
246 |
+
|
247 |
+
}
|
248 |
+
|
249 |
+
$to_send = array(
|
250 |
+
'slug' => $this->slug,
|
251 |
+
'is_ssl' => is_ssl(),
|
252 |
+
'fields' => array(
|
253 |
+
'banners' => array(),
|
254 |
+
'reviews' => false
|
255 |
+
)
|
256 |
+
);
|
257 |
+
|
258 |
+
$cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
|
259 |
+
|
260 |
+
// Get the transient where we store the api request for this plugin for 24 hours
|
261 |
+
$edd_api_request_transient = $this->get_cached_version_info( $cache_key );
|
262 |
+
|
263 |
+
//If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
|
264 |
+
if ( empty( $edd_api_request_transient ) ) {
|
265 |
+
|
266 |
+
$api_response = $this->api_request( 'plugin_information', $to_send );
|
267 |
+
|
268 |
+
// Expires in 3 hours
|
269 |
+
$this->set_version_info_cache( $api_response, $cache_key );
|
270 |
+
|
271 |
+
if ( false !== $api_response ) {
|
272 |
+
$_data = $api_response;
|
273 |
+
}
|
274 |
+
|
275 |
+
} else {
|
276 |
+
$_data = $edd_api_request_transient;
|
277 |
+
}
|
278 |
+
|
279 |
+
// Convert sections into an associative array, since we're getting an object, but Core expects an array.
|
280 |
+
if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
|
281 |
+
$new_sections = array();
|
282 |
+
foreach ( $_data->sections as $key => $value ) {
|
283 |
+
$new_sections[ $key ] = $value;
|
284 |
+
}
|
285 |
+
|
286 |
+
$_data->sections = $new_sections;
|
287 |
+
}
|
288 |
+
|
289 |
+
// Convert banners into an associative array, since we're getting an object, but Core expects an array.
|
290 |
+
if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
|
291 |
+
$new_banners = array();
|
292 |
+
foreach ( $_data->banners as $key => $value ) {
|
293 |
+
$new_banners[ $key ] = $value;
|
294 |
+
}
|
295 |
+
|
296 |
+
$_data->banners = $new_banners;
|
297 |
+
}
|
298 |
+
|
299 |
+
return $_data;
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Disable SSL verification in order to prevent download update failures
|
304 |
+
*
|
305 |
+
* @param array $args
|
306 |
+
* @param string $url
|
307 |
+
* @return object $array
|
308 |
+
*/
|
309 |
+
public function http_request_args( $args, $url ) {
|
310 |
+
|
311 |
+
$verify_ssl = $this->verify_ssl();
|
312 |
+
if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
|
313 |
+
$args['sslverify'] = $verify_ssl;
|
314 |
+
}
|
315 |
+
return $args;
|
316 |
+
|
317 |
+
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
* Calls the API and, if successfull, returns the object delivered by the API.
|
321 |
+
*
|
322 |
+
* @uses get_bloginfo()
|
323 |
+
* @uses wp_remote_post()
|
324 |
+
* @uses is_wp_error()
|
325 |
+
*
|
326 |
+
* @param string $_action The requested action.
|
327 |
+
* @param array $_data Parameters for the API action.
|
328 |
+
* @return false|object
|
329 |
+
*/
|
330 |
+
private function api_request( $_action, $_data ) {
|
331 |
+
|
332 |
+
global $wp_version;
|
333 |
+
|
334 |
+
$data = array_merge( $this->api_data, $_data );
|
335 |
+
|
336 |
+
if ( $data['slug'] != $this->slug ) {
|
337 |
+
return;
|
338 |
+
}
|
339 |
+
|
340 |
+
if( $this->api_url == trailingslashit (home_url() ) ) {
|
341 |
+
return false; // Don't allow a plugin to ping itself
|
342 |
+
}
|
343 |
+
|
344 |
+
$api_params = array(
|
345 |
+
'edd_action' => 'get_version',
|
346 |
+
'license' => ! empty( $data['license'] ) ? $data['license'] : '',
|
347 |
+
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
|
348 |
+
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
|
349 |
+
'version' => isset( $data['version'] ) ? $data['version'] : false,
|
350 |
+
'slug' => $data['slug'],
|
351 |
+
'author' => $data['author'],
|
352 |
+
'url' => home_url(),
|
353 |
+
'beta' => ! empty( $data['beta'] ),
|
354 |
+
);
|
355 |
+
|
356 |
+
$verify_ssl = $this->verify_ssl();
|
357 |
+
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
|
358 |
+
|
359 |
+
if ( ! is_wp_error( $request ) ) {
|
360 |
+
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
361 |
+
}
|
362 |
+
|
363 |
+
if ( $request && isset( $request->sections ) ) {
|
364 |
+
$request->sections = maybe_unserialize( $request->sections );
|
365 |
+
} else {
|
366 |
+
$request = false;
|
367 |
+
}
|
368 |
+
|
369 |
+
if ( $request && isset( $request->banners ) ) {
|
370 |
+
$request->banners = maybe_unserialize( $request->banners );
|
371 |
+
}
|
372 |
+
|
373 |
+
if( ! empty( $request->sections ) ) {
|
374 |
+
foreach( $request->sections as $key => $section ) {
|
375 |
+
$request->$key = (array) $section;
|
376 |
+
}
|
377 |
+
}
|
378 |
+
|
379 |
+
return $request;
|
380 |
+
}
|
381 |
+
|
382 |
+
public function show_changelog() {
|
383 |
+
|
384 |
+
global $edd_plugin_data;
|
385 |
+
|
386 |
+
if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
|
387 |
+
return;
|
388 |
+
}
|
389 |
+
|
390 |
+
if( empty( $_REQUEST['plugin'] ) ) {
|
391 |
+
return;
|
392 |
+
}
|
393 |
+
|
394 |
+
if( empty( $_REQUEST['slug'] ) ) {
|
395 |
+
return;
|
396 |
+
}
|
397 |
+
|
398 |
+
if( ! current_user_can( 'update_plugins' ) ) {
|
399 |
+
wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
|
400 |
+
}
|
401 |
+
|
402 |
+
$data = $edd_plugin_data[ $_REQUEST['slug'] ];
|
403 |
+
$beta = ! empty( $data['beta'] ) ? true : false;
|
404 |
+
$cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );
|
405 |
+
$version_info = $this->get_cached_version_info( $cache_key );
|
406 |
+
|
407 |
+
if( false === $version_info ) {
|
408 |
+
|
409 |
+
$api_params = array(
|
410 |
+
'edd_action' => 'get_version',
|
411 |
+
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
|
412 |
+
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
|
413 |
+
'slug' => $_REQUEST['slug'],
|
414 |
+
'author' => $data['author'],
|
415 |
+
'url' => home_url(),
|
416 |
+
'beta' => ! empty( $data['beta'] )
|
417 |
+
);
|
418 |
+
|
419 |
+
$verify_ssl = $this->verify_ssl();
|
420 |
+
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
|
421 |
+
|
422 |
+
if ( ! is_wp_error( $request ) ) {
|
423 |
+
$version_info = json_decode( wp_remote_retrieve_body( $request ) );
|
424 |
+
}
|
425 |
+
|
426 |
+
|
427 |
+
if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
|
428 |
+
$version_info->sections = maybe_unserialize( $version_info->sections );
|
429 |
+
} else {
|
430 |
+
$version_info = false;
|
431 |
+
}
|
432 |
+
|
433 |
+
if( ! empty( $version_info ) ) {
|
434 |
+
foreach( $version_info->sections as $key => $section ) {
|
435 |
+
$version_info->$key = (array) $section;
|
436 |
+
}
|
437 |
+
}
|
438 |
+
|
439 |
+
$this->set_version_info_cache( $version_info, $cache_key );
|
440 |
+
|
441 |
+
}
|
442 |
+
|
443 |
+
if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
|
444 |
+
echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';
|
445 |
+
}
|
446 |
+
|
447 |
+
exit;
|
448 |
+
}
|
449 |
+
|
450 |
+
public function get_cached_version_info( $cache_key = '' ) {
|
451 |
+
|
452 |
+
if( empty( $cache_key ) ) {
|
453 |
+
$cache_key = $this->cache_key;
|
454 |
+
}
|
455 |
+
|
456 |
+
$cache = get_option( $cache_key );
|
457 |
+
|
458 |
+
if( empty( $cache['timeout'] ) || current_time( 'timestamp' ) > $cache['timeout'] ) {
|
459 |
+
return false; // Cache is expired
|
460 |
+
}
|
461 |
+
|
462 |
+
return json_decode( $cache['value'] );
|
463 |
+
|
464 |
+
}
|
465 |
+
|
466 |
+
public function set_version_info_cache( $value = '', $cache_key = '' ) {
|
467 |
+
|
468 |
+
if( empty( $cache_key ) ) {
|
469 |
+
$cache_key = $this->cache_key;
|
470 |
+
}
|
471 |
+
|
472 |
+
$data = array(
|
473 |
+
'timeout' => strtotime( '+3 hours', current_time( 'timestamp' ) ),
|
474 |
+
'value' => json_encode( $value )
|
475 |
+
);
|
476 |
+
|
477 |
+
update_option( $cache_key, $data, 'no' );
|
478 |
+
|
479 |
+
}
|
480 |
+
|
481 |
+
/**
|
482 |
+
* Returns if the SSL of the store should be verified.
|
483 |
+
*
|
484 |
+
* @since 1.6.13
|
485 |
+
* @return bool
|
486 |
+
*/
|
487 |
+
private function verify_ssl() {
|
488 |
+
return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
|
489 |
+
}
|
490 |
+
|
491 |
+
}
|
eddsl/eddsl.php
ADDED
@@ -0,0 +1,704 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* --------------------------------------------------------- */
|
4 |
+
/* !Add the plugin updater - 2.1.17 */
|
5 |
+
/* --------------------------------------------------------- */
|
6 |
+
|
7 |
+
if( !class_exists( 'EDD_SL_Plugin_Updater' ) ) {
|
8 |
+
include( dirname( __FILE__ ) . '/EDD_SL_Plugin_Updater.php' );
|
9 |
+
}
|
10 |
+
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Return strings
|
14 |
+
* @since 2.1.17
|
15 |
+
*/
|
16 |
+
function mtphr_dnt_strings() {
|
17 |
+
|
18 |
+
$strings = array(
|
19 |
+
'successful_activation' => __('Your license is activated!', 'ditty-news-ticker'),
|
20 |
+
'unsuccessful_activation' => __('Sorry, this license is not valid.', 'ditty-news-ticker'),
|
21 |
+
'successful_deactivation' => __('Your license has been deactivated.', 'ditty-news-ticker'),
|
22 |
+
'unsuccessful_deactivation' => __('Sorry, something went wrong with the deactivation.', 'ditty-news-ticker'),
|
23 |
+
'deactivate_license' => __('Deactivate License', 'ditty-news-ticker'),
|
24 |
+
'activate_license' => __('Activate License', 'ditty-news-ticker'),
|
25 |
+
'refresh_license' => __('Refresh License', 'ditty-news-ticker')
|
26 |
+
);
|
27 |
+
|
28 |
+
return apply_filters( 'mtphr_dnt_license_strings', $strings );
|
29 |
+
}
|
30 |
+
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Return a single string
|
34 |
+
* @since 2.1.17
|
35 |
+
*/
|
36 |
+
function mtphr_dnt_string( $slug ) {
|
37 |
+
|
38 |
+
$strings = mtphr_dnt_strings();
|
39 |
+
if( isset($strings[$slug]) ) {
|
40 |
+
return $strings[$slug];
|
41 |
+
} else {
|
42 |
+
return sprintf(__('% string does not exist', 'ditty-news-ticker'), $slug);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Return extension license data
|
49 |
+
* @since 2.1.17
|
50 |
+
*/
|
51 |
+
function mtphr_dnt_all_license_data() {
|
52 |
+
|
53 |
+
$data = array(
|
54 |
+
/*
|
55 |
+
'ditty-test-ticker' => array(
|
56 |
+
'version' => '2.3',
|
57 |
+
'item_name' => 'Ditty Test Ticker',
|
58 |
+
'path' => 'ditty-test-ticker/ditty-test-ticker.php',
|
59 |
+
'author' => 'Metaphor Creations'
|
60 |
+
)
|
61 |
+
*/
|
62 |
+
);
|
63 |
+
|
64 |
+
return apply_filters( 'mtphr_dnt_license_data', $data );
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Initialize the extension updaters
|
70 |
+
* @since 2.1.17
|
71 |
+
*/
|
72 |
+
function mtphr_dnt_plugin_updater() {
|
73 |
+
|
74 |
+
// Get the various license data
|
75 |
+
$all_license_data = mtphr_dnt_all_license_data();
|
76 |
+
|
77 |
+
// retrieve our license key from the DB
|
78 |
+
$mtphr_edd_licenses = get_option( 'mtphr_edd_licenses', array() );
|
79 |
+
|
80 |
+
if( is_array($all_license_data) && count($all_license_data) > 0 ) {
|
81 |
+
foreach( $all_license_data as $slug=>$data ) {
|
82 |
+
|
83 |
+
$license_key = isset($mtphr_edd_licenses[$slug]) ? trim($mtphr_edd_licenses[$slug]) : '';
|
84 |
+
|
85 |
+
// setup the updater
|
86 |
+
$edd_updater = new EDD_SL_Plugin_Updater( MTPHR_DNT_STORE_URL, $data['path'], array(
|
87 |
+
'version' => $data['version'], // current version number
|
88 |
+
'license' => $license_key, // license key (used get_option above to retrieve from DB)
|
89 |
+
'item_name' => $data['item_name'], // name of this plugin
|
90 |
+
'author' => isset($data['author']) ? $data['author'] : 'Metaphor Creations' // author of this plugin
|
91 |
+
)
|
92 |
+
);
|
93 |
+
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
97 |
+
add_action( 'admin_init', 'mtphr_dnt_plugin_updater', 0 );
|
98 |
+
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Create the settings page
|
102 |
+
* @since 2.1.17
|
103 |
+
*/
|
104 |
+
function mtphr_dnt_edd_settings_menu() {
|
105 |
+
|
106 |
+
global $mtphr_edd_license_page;
|
107 |
+
|
108 |
+
if( empty($mtphr_edd_license_page) ) {
|
109 |
+
|
110 |
+
$all_license_data = mtphr_dnt_all_license_data();
|
111 |
+
if( is_array($all_license_data) && count($all_license_data) > 0 ) {
|
112 |
+
|
113 |
+
$mtphr_edd_license_page = 'ditty-news-ticker';
|
114 |
+
|
115 |
+
add_options_page(
|
116 |
+
__('Metaphor Licenses', 'ditty-news-ticker'),
|
117 |
+
__('Metaphor Licenses', 'ditty-news-ticker'),
|
118 |
+
'manage_options',
|
119 |
+
'mtphr_licenses',
|
120 |
+
'mtphr_dnt_licenses_display'
|
121 |
+
);
|
122 |
+
}
|
123 |
+
}
|
124 |
+
}
|
125 |
+
add_action( 'admin_menu', 'mtphr_dnt_edd_settings_menu', 9 );
|
126 |
+
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Render the settings page
|
130 |
+
* @since 2.1.17
|
131 |
+
*/
|
132 |
+
function mtphr_dnt_licenses_display( $active_tab = null ) {
|
133 |
+
?>
|
134 |
+
<!-- Create a header in the default WordPress 'wrap' container -->
|
135 |
+
<div class="wrap">
|
136 |
+
|
137 |
+
<h2><?php _e('Metaphor Creations Licenses', 'ditty-news-ticker'); ?></h2>
|
138 |
+
<?php //settings_errors(); ?>
|
139 |
+
|
140 |
+
<br class="clear" />
|
141 |
+
|
142 |
+
<form method="post" action="options.php">
|
143 |
+
<?php
|
144 |
+
settings_fields( 'mtphr_edd_licenses' );
|
145 |
+
do_settings_sections( 'mtphr_edd_licenses' );
|
146 |
+
?>
|
147 |
+
</form>
|
148 |
+
|
149 |
+
</div><!-- /.wrap -->
|
150 |
+
<?php
|
151 |
+
}
|
152 |
+
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Setup the settings
|
156 |
+
* @since 2.1.17
|
157 |
+
*/
|
158 |
+
function mtphr_dnt_edd_initialize_settings() {
|
159 |
+
|
160 |
+
global $mtphr_edd_license_page;
|
161 |
+
|
162 |
+
// Get the various license data
|
163 |
+
$all_license_data = mtphr_dnt_all_license_data();
|
164 |
+
|
165 |
+
// Add the setting sections
|
166 |
+
if( $mtphr_edd_license_page == 'ditty-news-ticker' ) {
|
167 |
+
add_settings_section( 'mtphr_edd_licenses_section', false, false, 'mtphr_edd_licenses' );
|
168 |
+
}
|
169 |
+
|
170 |
+
// Add the settings
|
171 |
+
if( is_array($all_license_data) && count($all_license_data) > 0 ) {
|
172 |
+
foreach( $all_license_data as $slug=>$data ) {
|
173 |
+
add_settings_field( $slug, $data['item_name'], 'mtphr_dnt_license', 'mtphr_edd_licenses', 'mtphr_edd_licenses_section', array('slug'=>$slug) );
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
// Register the settings
|
178 |
+
if( $mtphr_edd_license_page == 'ditty-news-ticker' ) {
|
179 |
+
if( false == get_option('mtphr_edd_licenses') ) {
|
180 |
+
add_option( 'mtphr_edd_licenses' );
|
181 |
+
}
|
182 |
+
register_setting( 'mtphr_edd_licenses', 'mtphr_edd_licenses', 'mtphr_edd_licenses_sanitize' );
|
183 |
+
}
|
184 |
+
}
|
185 |
+
add_action( 'admin_init', 'mtphr_dnt_edd_initialize_settings' );
|
186 |
+
|
187 |
+
|
188 |
+
/**
|
189 |
+
* License field render
|
190 |
+
* @since 2.1.17
|
191 |
+
*/
|
192 |
+
if( !function_exists('mtphr_dnt_license') ) {
|
193 |
+
function mtphr_dnt_license( $args ) {
|
194 |
+
|
195 |
+
$slug = $args['slug'];
|
196 |
+
$mtphr_edd_licenses = get_option( 'mtphr_edd_licenses', array() );
|
197 |
+
$mtphr_edd_license_data = get_option( 'mtphr_edd_license_data', array() );
|
198 |
+
|
199 |
+
$license = '';
|
200 |
+
$data = array();
|
201 |
+
$status = 'none';
|
202 |
+
$expires = false;
|
203 |
+
if( isset($mtphr_edd_licenses[$slug]) ) {
|
204 |
+
$license = isset( $mtphr_edd_licenses[$slug] ) ? $mtphr_edd_licenses[$slug] : '';
|
205 |
+
$data = isset( $mtphr_edd_license_data[$slug] ) ? $mtphr_edd_license_data[$slug] : array();
|
206 |
+
$status = isset( $data->license ) ? $data->license : 'none';
|
207 |
+
$expires = isset( $data->expires ) ? date( 'F j, Y', strtotime($data->expires) ) : false;
|
208 |
+
$expires = ( isset($data->expires) && $data->expires == 'lifetime' ) ? $data->expires : $expires;
|
209 |
+
$activations_left = ( isset($data->activations_left) && $data->activations_left <= 0 ) ? 'none' : '';
|
210 |
+
}
|
211 |
+
$customer_dashboard = 'https://www.metaphorcreations.com/customer-dashboard/';
|
212 |
+
?>
|
213 |
+
<div class="mtphr-dnt-license-group mtphr-dnt-license-<?php echo $status; ?>">
|
214 |
+
|
215 |
+
<?php wp_nonce_field( 'mtphr_dnt_license_nonce', 'mtphr_dnt_license_nonce' ); ?>
|
216 |
+
<input class="mtphr_dnt_license_key regular-text" name="mtphr_edd_licenses[<?php echo $slug; ?>]" type="text" class="regular-text" placeholder="<?php _e('Add your license key here', 'ditty-news-ticker'); ?>" value="<?php esc_attr_e( $license ); ?>" />
|
217 |
+
<input type="submit" class="button-secondary ditty-news-ticker-license-deactivate" data-slug="<?php echo $slug; ?>" value="<?php echo mtphr_dnt_string('deactivate_license'); ?>"/>
|
218 |
+
|
219 |
+
<?php $activate_class = ($status == 'valid') ? ' button' : ' button-primary'; ?>
|
220 |
+
<?php $activate_string = ($status == 'valid') ? 'refresh_license' : 'activate_license'; ?>
|
221 |
+
<input type="submit" class="ditty-news-ticker-license-activate<?php echo $activate_class; ?>" data-slug="<?php echo $slug; ?>" value="<?php echo mtphr_dnt_string($activate_string); ?>"/>
|
222 |
+
<span class="spinner mtphr-dnt-license-spinner"></span>
|
223 |
+
|
224 |
+
<div class="mtphr_dnt_license_description">
|
225 |
+
|
226 |
+
<?php if( $status !== false && $status == 'valid' ) { ?>
|
227 |
+
<?php if( $expires == 'lifetime' ) { ?>
|
228 |
+
<p><em><?php _e('Your license is activated!', 'ditty-news-ticker'); ?></em></p>
|
229 |
+
<?php } else { ?>
|
230 |
+
<p><em><?php printf( __('Your license key expires on %s', 'ditty-news-ticker'), $expires); ?></em></p>
|
231 |
+
<?php } ?>
|
232 |
+
<?php } elseif( $status !== false && $status == 'invalid' ) { ?>
|
233 |
+
|
234 |
+
<?php
|
235 |
+
$error = isset( $data->error ) ? $data->error : false;
|
236 |
+
switch( $error ) {
|
237 |
+
case 'no_activations_left':
|
238 |
+
echo '<p><em>'.__('Sorry, it looks like all of your licenses have already been activated.', 'ditty-news-ticker').'</em></p>';
|
239 |
+
echo '<p><em>'.sprintf(__('View your license activations <a href="%s" target="_blank">here</a>', 'ditty-news-ticker'), $customer_dashboard).'</em></p>';
|
240 |
+
break;
|
241 |
+
|
242 |
+
default:
|
243 |
+
if( $license != '' ) {
|
244 |
+
echo '<p><em>'.sprintf(__('Sorry, this license is not valid. View your licenses <a href="%s" target="_blank">here</a>', 'ditty-news-ticker'), $customer_dashboard).'</em></p>';
|
245 |
+
}
|
246 |
+
break;
|
247 |
+
}
|
248 |
+
} elseif( $status !== false ) {
|
249 |
+
switch( $status ) {
|
250 |
+
|
251 |
+
case 'expired':
|
252 |
+
echo '<p><em>'.sprintf(__('Sorry, your license has expired. Update your license <a href="%s" target="_blank">here</a>', 'ditty-news-ticker'), $customer_dashboard).'</em></p>';
|
253 |
+
break;
|
254 |
+
|
255 |
+
case 'disabled':
|
256 |
+
echo '<p><em>'.__('Sorry, your license has been disabled.', 'ditty-news-ticker').'</em></p>';
|
257 |
+
break;
|
258 |
+
|
259 |
+
case 'site_inactive':
|
260 |
+
if( $activations_left == 'none' ) {
|
261 |
+
echo '<p><em>'.__('Sorry, it looks like all of your licenses have already been activated.', 'ditty-news-ticker').'</em></p>';
|
262 |
+
echo '<p><em>'.sprintf(__('View your license activations <a href="%s" target="_blank">here</a>', 'ditty-news-ticker'), $customer_dashboard).'</em></p>';
|
263 |
+
}
|
264 |
+
break;
|
265 |
+
|
266 |
+
default:
|
267 |
+
break;
|
268 |
+
}
|
269 |
+
|
270 |
+
} ?>
|
271 |
+
|
272 |
+
</div>
|
273 |
+
</div>
|
274 |
+
<?php
|
275 |
+
}
|
276 |
+
}
|
277 |
+
|
278 |
+
|
279 |
+
/**
|
280 |
+
* Sanitize the setting fields
|
281 |
+
* @since 2.1.17
|
282 |
+
*/
|
283 |
+
if( !function_exists('mtphr_edd_licenses_sanitize') ) {
|
284 |
+
function mtphr_edd_licenses_sanitize( $new ) {
|
285 |
+
|
286 |
+
$mtphr_edd_licenses = get_option( 'mtphr_edd_licenses', array() );
|
287 |
+
$mtphr_edd_license_data = get_option( 'mtphr_edd_license_data', array() );
|
288 |
+
|
289 |
+
if( is_array($new) && count($new) > 0 ) {
|
290 |
+
foreach( $new as $product=>$license ) {
|
291 |
+
|
292 |
+
// If there is a new license, reset the data
|
293 |
+
if( isset($mtphr_edd_licenses[$product]) && $mtphr_edd_licenses[$product] !== $license ) {
|
294 |
+
unset( $mtphr_edd_license_data[$product] );
|
295 |
+
}
|
296 |
+
}
|
297 |
+
}
|
298 |
+
|
299 |
+
return $new;
|
300 |
+
}
|
301 |
+
}
|
302 |
+
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Check licenses daily
|
306 |
+
* @since 2.1.17
|
307 |
+
*/
|
308 |
+
function mtphr_dnt_license_check() {
|
309 |
+
|
310 |
+
global $wp_version;
|
311 |
+
|
312 |
+
$mtphr_edd_licenses = get_option( 'mtphr_edd_licenses', array() );
|
313 |
+
$mtphr_edd_license_data = get_option( 'mtphr_edd_license_data', array() );
|
314 |
+
|
315 |
+
$all_license_data = mtphr_dnt_all_license_data();
|
316 |
+
if( is_array($all_license_data) && count($all_license_data) > 0 ) {
|
317 |
+
foreach( $all_license_data as $slug=>$data ) {
|
318 |
+
|
319 |
+
$license_key = isset($mtphr_edd_licenses[$slug]) ? trim($mtphr_edd_licenses[$slug]) : '';
|
320 |
+
|
321 |
+
$api_params = array(
|
322 |
+
'edd_action' => 'check_license',
|
323 |
+
'license' => $license_key,
|
324 |
+
'item_name' => urlencode( $data['item_name'] ),
|
325 |
+
'url' => home_url()
|
326 |
+
);
|
327 |
+
|
328 |
+
// Call the custom API.
|
329 |
+
$response = wp_remote_post( MTPHR_DNT_STORE_URL, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
|
330 |
+
|
331 |
+
if ( is_wp_error( $response ) )
|
332 |
+
return false;
|
333 |
+
|
334 |
+
// decode & store the license data
|
335 |
+
$mtphr_edd_license_data[$slug] = json_decode( wp_remote_retrieve_body( $response ) );
|
336 |
+
}
|
337 |
+
}
|
338 |
+
|
339 |
+
update_option( 'mtphr_edd_license_data', $mtphr_edd_license_data );
|
340 |
+
|
341 |
+
}
|
342 |
+
add_action( 'mtphr_dnt_license_check_action', 'mtphr_dnt_license_check' );
|
343 |
+
|
344 |
+
|
345 |
+
/**
|
346 |
+
* Enable daily license check
|
347 |
+
* @since 2.1.17
|
348 |
+
*/
|
349 |
+
function mtphr_dnt_enable_daily_license_check() {
|
350 |
+
if( !wp_next_scheduled('mtphr_dnt_license_check_action') ) {
|
351 |
+
wp_schedule_event( time(), 'daily', 'mtphr_dnt_license_check_action' );
|
352 |
+
}
|
353 |
+
}
|
354 |
+
register_activation_hook('ditty-news-ticker/ditty-news-ticker.php', 'mtphr_dnt_enable_daily_license_check');
|
355 |
+
|
356 |
+
|
357 |
+
/**
|
358 |
+
* Disable daily license check
|
359 |
+
* @since 2.1.17
|
360 |
+
*/
|
361 |
+
function mtphr_dnt_disable_daily_license_check() {
|
362 |
+
wp_clear_scheduled_hook( 'mtphr_dnt_license_check_action' );
|
363 |
+
}
|
364 |
+
register_deactivation_hook('ditty-news-ticker/ditty-news-ticker.php', 'mtphr_dnt_disable_daily_license_check');
|
365 |
+
|
366 |
+
|
367 |
+
/**
|
368 |
+
* Add a license check notice
|
369 |
+
* @since 2.1.17
|
370 |
+
*/
|
371 |
+
function mtphr_dnt_license_bug() {
|
372 |
+
|
373 |
+
// Get the various license data
|
374 |
+
$all_license_data = mtphr_dnt_all_license_data();
|
375 |
+
|
376 |
+
// Check if the notice has been disabled
|
377 |
+
$mtphr_edd_license_notices = get_option( 'mtphr_edd_license_notices', array() );
|
378 |
+
|
379 |
+
$display_notice = false;
|
380 |
+
$slugs = array();
|
381 |
+
|
382 |
+
ob_start();
|
383 |
+
|
384 |
+
|
385 |
+
$url = admin_url('options-general.php?page=mtphr_licenses');
|
386 |
+
|
387 |
+
if( is_array($all_license_data) && count($all_license_data) > 0 ) {
|
388 |
+
foreach( $all_license_data as $slug=>$data ) {
|
389 |
+
|
390 |
+
if( !isset($mtphr_edd_license_notices[$slug]) ) {
|
391 |
+
|
392 |
+
if( !$display_notice ) {
|
393 |
+
echo '<p style="margin-bottom:0;">'.sprintf(__('Don\'t forget to <a href="%1s">activate your license</a> for your Ditty Extensions!', 'ditty-news-ticker'), $url).'</p>';
|
394 |
+
echo '<ul style="list-style:square;list-style-position:inside;margin:0;">';
|
395 |
+
}
|
396 |
+
|
397 |
+
$display_notice = true;
|
398 |
+
$slugs[] = $slug;
|
399 |
+
|
400 |
+
echo '<li>'.$data['item_name'].'</li>';
|
401 |
+
}
|
402 |
+
}
|
403 |
+
|
404 |
+
if( $display_notice ) {
|
405 |
+
echo '</ul>';
|
406 |
+
}
|
407 |
+
}
|
408 |
+
|
409 |
+
$notices = ob_get_clean();
|
410 |
+
|
411 |
+
if( $display_notice ) {
|
412 |
+
echo '<div id="ditty-news-ticker-license-notice" class="notice notice-warning is-dismissible" data-slugs="'.implode(',', $slugs).'">';
|
413 |
+
echo $notices;
|
414 |
+
echo '</div>';
|
415 |
+
}
|
416 |
+
|
417 |
+
}
|
418 |
+
add_action('admin_notices', 'mtphr_dnt_license_bug' );
|
419 |
+
|
420 |
+
|
421 |
+
/**
|
422 |
+
* Dismiss the bug via ajax
|
423 |
+
* @since 2.1.17
|
424 |
+
*/
|
425 |
+
function mtphr_dnt_license_bug_dismiss() {
|
426 |
+
|
427 |
+
// Check the nonce
|
428 |
+
check_ajax_referer( 'ditty-news-ticker', 'security' );
|
429 |
+
|
430 |
+
$slugs = isset($_POST['slugs']) ? explode(',', $_POST['slugs']) : array();
|
431 |
+
|
432 |
+
$mtphr_edd_license_notices = get_option( 'mtphr_edd_license_notices', array() );
|
433 |
+
|
434 |
+
if( is_array($slugs) && count($slugs) > 0 ) {
|
435 |
+
foreach( $slugs as $slug ) {
|
436 |
+
$mtphr_edd_license_notices[$slug] = '1';
|
437 |
+
}
|
438 |
+
}
|
439 |
+
|
440 |
+
update_option( 'mtphr_edd_license_notices', $mtphr_edd_license_notices );
|
441 |
+
|
442 |
+
die(); // this is required to return a proper result
|
443 |
+
}
|
444 |
+
add_action( 'wp_ajax_mtphr_dnt_license_bug_dismiss', 'mtphr_dnt_license_bug_dismiss' );
|
445 |
+
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Deactivate a license via ajax
|
449 |
+
* @since 2.1.17
|
450 |
+
*/
|
451 |
+
function mtphr_dnt_license_deactivate_ajax() {
|
452 |
+
|
453 |
+
// Check the nonce
|
454 |
+
check_ajax_referer( 'ditty-news-ticker', 'security' );
|
455 |
+
|
456 |
+
$slug = isset($_POST['slug']) ? $_POST['slug'] : false;
|
457 |
+
$all_license_data = mtphr_dnt_all_license_data();
|
458 |
+
|
459 |
+
$action = 'success';
|
460 |
+
$message = '';
|
461 |
+
$ajax_response = array();
|
462 |
+
|
463 |
+
if( !isset($all_license_data[$slug]) ) {
|
464 |
+
$action = 'fail';
|
465 |
+
$message = __('This license is not active.', 'ditty-news-ticker');
|
466 |
+
}
|
467 |
+
|
468 |
+
if( !$slug ) {
|
469 |
+
$action = 'fail';
|
470 |
+
$message = __('Something went wrong, please try again.', 'ditty-news-ticker');
|
471 |
+
}
|
472 |
+
|
473 |
+
if( $slug && $all_license_data[$slug] ) {
|
474 |
+
|
475 |
+
$mtphr_edd_licenses = get_option( 'mtphr_edd_licenses', array() );
|
476 |
+
$license = isset( $mtphr_edd_licenses[$slug] ) ? trim( $mtphr_edd_licenses[$slug] ) : '';
|
477 |
+
|
478 |
+
// data to send in our API request
|
479 |
+
$api_params = array(
|
480 |
+
'edd_action'=> 'deactivate_license',
|
481 |
+
'license' => $license,
|
482 |
+
'item_name' => urlencode( $all_license_data[$slug]['item_name'] ), // the name of our product in EDD
|
483 |
+
'url' => home_url()
|
484 |
+
);
|
485 |
+
|
486 |
+
// Call the custom API.
|
487 |
+
$response = wp_remote_post( MTPHR_DNT_STORE_URL, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
|
488 |
+
|
489 |
+
// make sure the response came back okay
|
490 |
+
if( is_wp_error($response) ) {
|
491 |
+
$action = 'fail';
|
492 |
+
$message = __('Something went wrong, please try again.', 'ditty-news-ticker');
|
493 |
+
$ajax_response = $response;
|
494 |
+
|
495 |
+
} else {
|
496 |
+
|
497 |
+
// decode the license data
|
498 |
+
$license_data = json_decode( wp_remote_retrieve_body($response) );
|
499 |
+
$ajax_response = $license_data;
|
500 |
+
|
501 |
+
$status = isset( $license_data->license ) ? $license_data->license : 'none';
|
502 |
+
|
503 |
+
// $license_data->license will be either "deactivated" or "failed"
|
504 |
+
if( $status == 'deactivated' ) {
|
505 |
+
$mtphr_edd_license_data = get_option( 'mtphr_edd_license_data', array() );
|
506 |
+
if( isset($mtphr_edd_license_data[$slug]) ) {
|
507 |
+
unset($mtphr_edd_license_data[$slug]);
|
508 |
+
update_option( 'mtphr_edd_license_data', $mtphr_edd_license_data );
|
509 |
+
}
|
510 |
+
}
|
511 |
+
|
512 |
+
if( $status == 'deactivated' ) {
|
513 |
+
$message = mtphr_dnt_string('successful_deactivation');
|
514 |
+
} else {
|
515 |
+
$message = mtphr_dnt_string('unsuccessful_deactivation');
|
516 |
+
}
|
517 |
+
|
518 |
+
}
|
519 |
+
}
|
520 |
+
|
521 |
+
$return = array(
|
522 |
+
'status' => $status,
|
523 |
+
'message' => $message,
|
524 |
+
'ajax_response' => $ajax_response
|
525 |
+
);
|
526 |
+
|
527 |
+
wp_send_json( $return );
|
528 |
+
}
|
529 |
+
add_action( 'wp_ajax_mtphr_dnt_license_deactivate_ajax', 'mtphr_dnt_license_deactivate_ajax' );
|
530 |
+
|
531 |
+
|
532 |
+
/**
|
533 |
+
* Aactivate a license via ajax
|
534 |
+
* @since 2.1.17
|
535 |
+
*/
|
536 |
+
function mtphr_dnt_license_activate_ajax() {
|
537 |
+
|
538 |
+
// Check the nonce
|
539 |
+
check_ajax_referer( 'ditty-news-ticker', 'security' );
|
540 |
+
|
541 |
+
$slug = isset($_POST['slug']) ? $_POST['slug'] : false;
|
542 |
+
$license = isset($_POST['license']) ? trim(sanitize_text_field($_POST['license'])) : false;
|
543 |
+
$status = 'fail';
|
544 |
+
$message = '';
|
545 |
+
$ajax_response = array();
|
546 |
+
|
547 |
+
if( !$license ) {
|
548 |
+
$message = __('Please add a valid license.', 'ditty-news-ticker');
|
549 |
+
}
|
550 |
+
|
551 |
+
if( !$slug ) {
|
552 |
+
$message = __('Something went wrong, please try again.', 'ditty-news-ticker');
|
553 |
+
}
|
554 |
+
|
555 |
+
if( $slug ) {
|
556 |
+
|
557 |
+
$all_license_data = mtphr_dnt_all_license_data();
|
558 |
+
$mtphr_edd_licenses = get_option( 'mtphr_edd_licenses', array() );
|
559 |
+
|
560 |
+
// data to send in our API request
|
561 |
+
$api_params = array(
|
562 |
+
'edd_action'=> 'activate_license',
|
563 |
+
'license' => $license,
|
564 |
+
'item_name' => urlencode( $all_license_data[$slug]['item_name'] ), // the name of our product in EDD
|
565 |
+
'url' => home_url()
|
566 |
+
);
|
567 |
+
|
568 |
+
// Call the custom API.
|
569 |
+
$response = wp_remote_post( MTPHR_DNT_STORE_URL, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
|
570 |
+
|
571 |
+
// make sure the response came back okay
|
572 |
+
if( is_wp_error($response) ) {
|
573 |
+
$action = 'fail';
|
574 |
+
$message = __('Something went wrong, please try again.', 'ditty-news-ticker');
|
575 |
+
$ajax_response = $response;
|
576 |
+
|
577 |
+
} else {
|
578 |
+
|
579 |
+
// Decode the response
|
580 |
+
$license_data = json_decode( wp_remote_retrieve_body($response) );
|
581 |
+
$ajax_response = $license_data;
|
582 |
+
|
583 |
+
$status = isset( $license_data->license ) ? $license_data->license : 'none';
|
584 |
+
|
585 |
+
// Store the license data
|
586 |
+
$mtphr_edd_license_data = get_option( 'mtphr_edd_license_data', array() );
|
587 |
+
$mtphr_edd_license_data[$slug] = $license_data;
|
588 |
+
update_option( 'mtphr_edd_license_data', $mtphr_edd_license_data );
|
589 |
+
|
590 |
+
// Store the license
|
591 |
+
$mtphr_edd_licenses[$slug] = $license;
|
592 |
+
update_option( 'mtphr_edd_licenses', $mtphr_edd_licenses );
|
593 |
+
|
594 |
+
if( $status == 'valid' ) {
|
595 |
+
$message = mtphr_dnt_string('successful_activation');
|
596 |
+
} else {
|
597 |
+
$message = mtphr_dnt_string('unsuccessful_activation');
|
598 |
+
}
|
599 |
+
|
600 |
+
}
|
601 |
+
}
|
602 |
+
|
603 |
+
$return = array(
|
604 |
+
'status' => $status,
|
605 |
+
'message' => $message,
|
606 |
+
'ajax_response' => $ajax_response
|
607 |
+
);
|
608 |
+
|
609 |
+
wp_send_json( $return );
|
610 |
+
}
|
611 |
+
add_action( 'wp_ajax_mtphr_dnt_license_activate_ajax', 'mtphr_dnt_license_activate_ajax' );
|
612 |
+
|
613 |
+
|
614 |
+
/**
|
615 |
+
* Admin footer scripts
|
616 |
+
* @since 2.1.17
|
617 |
+
*/
|
618 |
+
function mtphr_dnt_license_bug_ajax() {
|
619 |
+
?>
|
620 |
+
<script>
|
621 |
+
jQuery(document).ready(function($){
|
622 |
+
|
623 |
+
$('#ditty-news-ticker-license-notice').click( function(e){
|
624 |
+
if( $(e.target).is('.notice-dismiss') ) {
|
625 |
+
|
626 |
+
var data = {
|
627 |
+
action:'mtphr_dnt_license_bug_dismiss',
|
628 |
+
slugs:$(this).data('slugs'),
|
629 |
+
security:'<?php echo wp_create_nonce( 'ditty-news-ticker' ); ?>'
|
630 |
+
};
|
631 |
+
|
632 |
+
jQuery.post(ajaxurl,data,function(response){});
|
633 |
+
|
634 |
+
}
|
635 |
+
});
|
636 |
+
|
637 |
+
$('.ditty-news-ticker-license-deactivate').click( function(e){
|
638 |
+
|
639 |
+
e.preventDefault();
|
640 |
+
var $container = $(this).parent(),
|
641 |
+
$spinner = $(this).siblings('.spinner'),
|
642 |
+
$description = $(this).siblings('.mtphr_dnt_license_description'),
|
643 |
+
$activate_button = $(this).siblings('.ditty-news-ticker-license-activate');
|
644 |
+
|
645 |
+
$spinner.css('visibility', 'visible');
|
646 |
+
|
647 |
+
var data = {
|
648 |
+
action: 'mtphr_dnt_license_deactivate_ajax',
|
649 |
+
slug: $(this).data('slug'),
|
650 |
+
security: '<?php echo wp_create_nonce( 'ditty-news-ticker' ); ?>'
|
651 |
+
};
|
652 |
+
|
653 |
+
jQuery.post(ajaxurl,data,function(response){
|
654 |
+
|
655 |
+
$container.attr('class', 'mtphr-dnt-license-group mtphr-dnt-license-'+response.status);
|
656 |
+
if( response.status === 'deactivated' ) {
|
657 |
+
$activate_button.addClass('button-primary');
|
658 |
+
$activate_button.val('<?php echo mtphr_dnt_string('activate_license'); ?>');
|
659 |
+
}
|
660 |
+
$description.html('<p><em>'+response.message+'</em></p>');
|
661 |
+
$spinner.css('visibility', 'hidden');
|
662 |
+
|
663 |
+
}, 'json');
|
664 |
+
});
|
665 |
+
|
666 |
+
$('.ditty-news-ticker-license-activate').click( function(e){
|
667 |
+
|
668 |
+
e.preventDefault();
|
669 |
+
|
670 |
+
var $button = $(this),
|
671 |
+
$container = $(this).parent(),
|
672 |
+
$spinner = $(this).siblings('.spinner'),
|
673 |
+
$input = $(this).siblings('.mtphr_dnt_license_key'),
|
674 |
+
$description = $(this).siblings('.mtphr_dnt_license_description');
|
675 |
+
|
676 |
+
$spinner.css('visibility', 'visible');
|
677 |
+
|
678 |
+
var data = {
|
679 |
+
action: 'mtphr_dnt_license_activate_ajax',
|
680 |
+
license: $input.val(),
|
681 |
+
slug: $(this).data('slug'),
|
682 |
+
security: '<?php echo wp_create_nonce( 'ditty-news-ticker' ); ?>'
|
683 |
+
};
|
684 |
+
|
685 |
+
jQuery.post(ajaxurl,data,function(response){
|
686 |
+
|
687 |
+
$container.attr('class', 'mtphr-dnt-license-group mtphr-dnt-license-'+response.status);
|
688 |
+
if( response.status === 'valid' ) {
|
689 |
+
$button.removeClass('button-primary').addClass('button');
|
690 |
+
$button.val('<?php echo mtphr_dnt_string('refresh_license'); ?>');
|
691 |
+
}
|
692 |
+
$description.html('<p><em>'+response.message+'</em></p>');
|
693 |
+
$spinner.css('visibility', 'hidden');
|
694 |
+
|
695 |
+
}, 'json');
|
696 |
+
});
|
697 |
+
|
698 |
+
|
699 |
+
|
700 |
+
});
|
701 |
+
</script>
|
702 |
+
<?php
|
703 |
+
}
|
704 |
+
add_action( 'admin_footer', 'mtphr_dnt_license_bug_ajax' );
|
includes/admin/scripts.php
CHANGED
@@ -45,7 +45,8 @@ function mtphr_dnt_admin_scripts( $hook ) {
|
|
45 |
wp_localize_script( 'ditty-news-ticker', 'ditty_news_ticker_vars', array(
|
46 |
'security' => wp_create_nonce( 'ditty-news-ticker' ),
|
47 |
'img_title' => __( 'Upload or select an image', 'ditty-news-ticker' ),
|
48 |
-
'img_button' => __( 'Use Image', 'ditty-news-ticker' )
|
|
|
49 |
)
|
50 |
);
|
51 |
}
|
45 |
wp_localize_script( 'ditty-news-ticker', 'ditty_news_ticker_vars', array(
|
46 |
'security' => wp_create_nonce( 'ditty-news-ticker' ),
|
47 |
'img_title' => __( 'Upload or select an image', 'ditty-news-ticker' ),
|
48 |
+
'img_button' => __( 'Use Image', 'ditty-news-ticker' ),
|
49 |
+
'strings' => mtphr_dnt_strings()
|
50 |
)
|
51 |
);
|
52 |
}
|
includes/scripts.php
CHANGED
@@ -21,6 +21,11 @@ function mtphr_dnt_scripts() {
|
|
21 |
wp_enqueue_style( 'ditty-news-ticker' );
|
22 |
wp_register_script( 'imagesLoaded', plugins_url('ditty-news-ticker/assets/js/imagesloaded.pkgd.min.js'), array('jquery'), '4.1.0', true );
|
23 |
wp_register_script( 'ditty-news-ticker', plugins_url('ditty-news-ticker/assets/js/ditty-news-ticker.js'), array('jquery', 'imagesLoaded', 'touchSwipe', 'jquery-easing'), filemtime(MTPHR_DNT_DIR.'assets/js/ditty-news-ticker.js'), true );
|
|
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
add_action( 'wp_enqueue_scripts', 'mtphr_dnt_scripts' );
|
26 |
|
21 |
wp_enqueue_style( 'ditty-news-ticker' );
|
22 |
wp_register_script( 'imagesLoaded', plugins_url('ditty-news-ticker/assets/js/imagesloaded.pkgd.min.js'), array('jquery'), '4.1.0', true );
|
23 |
wp_register_script( 'ditty-news-ticker', plugins_url('ditty-news-ticker/assets/js/ditty-news-ticker.js'), array('jquery', 'imagesLoaded', 'touchSwipe', 'jquery-easing'), filemtime(MTPHR_DNT_DIR.'assets/js/ditty-news-ticker.js'), true );
|
24 |
+
wp_localize_script( 'ditty-news-ticker', 'mtphr_dnt_vars', array(
|
25 |
+
'is_rtl' => is_rtl(),
|
26 |
+
)
|
27 |
+
);
|
28 |
+
|
29 |
}
|
30 |
add_action( 'wp_enqueue_scripts', 'mtphr_dnt_scripts' );
|
31 |
|
includes/widget.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
* Create a class for the widget
|
5 |
*
|
6 |
-
* @since 2.1.
|
7 |
*/
|
8 |
class mtphr_dnt_widget extends WP_Widget {
|
9 |
|
@@ -29,9 +29,10 @@ class mtphr_dnt_widget extends WP_Widget {
|
|
29 |
$title = apply_filters( 'widget_title', $title );
|
30 |
|
31 |
$ticker = $instance['ticker'];
|
32 |
-
$ticker_title = isset( $instance['ticker_title'] );
|
33 |
-
$ticker_hide = isset( $instance['ticker_hide'] );
|
34 |
|
|
|
|
|
|
|
35 |
global $mtphr_dnt_meta_data;
|
36 |
|
37 |
// Set custom attributes
|
@@ -63,18 +64,34 @@ class mtphr_dnt_widget extends WP_Widget {
|
|
63 |
// Only display the widget if ticks exist
|
64 |
if( !$ticker_hide || intval($mtphr_dnt_meta_data['_mtphr_dnt_total_ticks']) > 0 ) {
|
65 |
|
66 |
-
|
67 |
-
echo $before_widget;
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
72 |
}
|
73 |
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
-
|
77 |
-
echo $after_widget;
|
78 |
}
|
79 |
}
|
80 |
|
3 |
/**
|
4 |
* Create a class for the widget
|
5 |
*
|
6 |
+
* @since 2.1.17
|
7 |
*/
|
8 |
class mtphr_dnt_widget extends WP_Widget {
|
9 |
|
29 |
$title = apply_filters( 'widget_title', $title );
|
30 |
|
31 |
$ticker = $instance['ticker'];
|
|
|
|
|
32 |
|
33 |
+
$ticker_title = isset($instance['ticker_title']) ? $instance['ticker_title'] : 0;
|
34 |
+
$ticker_hide = isset( $instance['ticker_hide']) ? $instance['ticker_hide'] : 1;
|
35 |
+
|
36 |
global $mtphr_dnt_meta_data;
|
37 |
|
38 |
// Set custom attributes
|
64 |
// Only display the widget if ticks exist
|
65 |
if( !$ticker_hide || intval($mtphr_dnt_meta_data['_mtphr_dnt_total_ticks']) > 0 ) {
|
66 |
|
67 |
+
$display = true;
|
|
|
68 |
|
69 |
+
if( intval($mtphr_dnt_meta_data['_mtphr_dnt_total_ticks']) == 1 ) {
|
70 |
+
if( is_array($mtphr_dnt_meta_data['_mtphr_dnt_ticks'][0]) ) {
|
71 |
+
if( $mtphr_dnt_meta_data['_mtphr_dnt_ticks'][0]['tick'] == '' ) {
|
72 |
+
$display = false;
|
73 |
+
}
|
74 |
+
} elseif( $mtphr_dnt_meta_data['_mtphr_dnt_ticks'][0] == '' ) {
|
75 |
+
$display = false;
|
76 |
+
}
|
77 |
}
|
78 |
|
79 |
+
if( !$ticker_hide || $display ) {
|
80 |
+
|
81 |
+
// Before widget (defined by themes)
|
82 |
+
echo $before_widget;
|
83 |
+
|
84 |
+
// Title of widget (before and after defined by themes)
|
85 |
+
if ( $title ) {
|
86 |
+
echo $before_title . $title . $after_title;
|
87 |
+
}
|
88 |
+
|
89 |
+
echo $ticker_output;
|
90 |
+
|
91 |
+
// After widget (defined by themes)
|
92 |
+
echo $after_widget;
|
93 |
|
94 |
+
}
|
|
|
95 |
}
|
96 |
}
|
97 |
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: metaphorcreations
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FUZKZGAJSBAE6
|
4 |
Tags: ticker, news, news ticker, rotator, data rotator, lists, data
|
5 |
Requires at least: 4.5
|
6 |
-
Tested up to: 4.9.
|
7 |
Stable tag: /trunk/
|
8 |
License: GPL2
|
9 |
|
@@ -72,6 +72,10 @@ The most common cause for an unresponsive ticker (when using scroll or rotate mo
|
|
72 |
|
73 |
== Changelog ==
|
74 |
|
|
|
|
|
|
|
|
|
75 |
= 2.1.16 =
|
76 |
* Minor javascript update for scrolling tickers.
|
77 |
|
@@ -454,4 +458,4 @@ The most common cause for an unresponsive ticker (when using scroll or rotate mo
|
|
454 |
|
455 |
== Upgrade Notice ==
|
456 |
|
457 |
-
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FUZKZGAJSBAE6
|
4 |
Tags: ticker, news, news ticker, rotator, data rotator, lists, data
|
5 |
Requires at least: 4.5
|
6 |
+
Tested up to: 4.9.7
|
7 |
Stable tag: /trunk/
|
8 |
License: GPL2
|
9 |
|
72 |
|
73 |
== Changelog ==
|
74 |
|
75 |
+
= 2.1.17 =
|
76 |
+
* Fixed widget ticker title bug.
|
77 |
+
* Added a centralized licensing system for all extensions. Extensions will be updated soon to utilize this feature.
|
78 |
+
|
79 |
= 2.1.16 =
|
80 |
* Minor javascript update for scrolling tickers.
|
81 |
|
458 |
|
459 |
== Upgrade Notice ==
|
460 |
|
461 |
+
Fixed widget ticker title bug. Added centralized licensing code.
|