summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/wordpress-mobile-pack/admin/class-admin.php')
-rwxr-xr-xplugins/wordpress-mobile-pack/admin/class-admin.php96
1 files changed, 53 insertions, 43 deletions
diff --git a/plugins/wordpress-mobile-pack/admin/class-admin.php b/plugins/wordpress-mobile-pack/admin/class-admin.php
index 181bc238..a4bd8595 100755
--- a/plugins/wordpress-mobile-pack/admin/class-admin.php
+++ b/plugins/wordpress-mobile-pack/admin/class-admin.php
@@ -120,11 +120,20 @@ if ( ! class_exists( 'WMobilePack_Admin' ) ) {
include(WMP_PLUGIN_PATH.'admin/pages/settings.php');
}
+ /**
+ *
+ * Method used to render the PRO page from the admin area
+ *
+ */
+ public function pro(){
+
+ include(WMP_PLUGIN_PATH.'admin/pages/pro.php');
+ }
/**
*
- * Method used to render the Premium page from the admin area
+ * Method used to render the Premium page from the admin area (connected API key)
*
*/
public function premium(){
@@ -360,52 +369,54 @@ if ( ! class_exists( 'WMobilePack_Admin' ) ) {
$json_data = get_transient(WMobilePack_Options::$transient_prefix.'more_updates');
- // the transient is not set or expired
- if (!$json_data) {
-
- // check if we have a https connection
- $is_secure = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443;
+ if ($json_data){
- // JSON URL that should be requested
- $json_url = ($is_secure ? WMP_MORE_UPDATES_HTTPS : WMP_MORE_UPDATES);
+ if ($json_data == 'warning') {
+ return $json_data;
+ }
// get response
- $json_response = WMobilePack::read_data($json_url);
+ $response = json_decode($json_data, true);
- if ($json_response !== false && $json_response != '') {
+ if (isset($response["content"]) && is_array($response["content"]) && !empty($response["content"])) {
- // Store this data in a transient
- set_transient(WMobilePack_Options::$transient_prefix.'more_updates', $json_response, 3600*24*2);
+ if (isset($response['content']['version']) && $response['content']['version'] == WMP_MORE_UPDATES_VERSION) {
+ return $response["content"];
+ }
+ }
+ }
- // get response
- $response = json_decode($json_response, true);
+ // check if we have a https connection
+ $is_secure = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443;
- if (isset($response["content"]) && is_array($response["content"]) && !empty($response["content"])){
+ // JSON URL that should be requested
+ $json_url = ($is_secure ? WMP_MORE_UPDATES_HTTPS : WMP_MORE_UPDATES);
- // return response
- return $response["content"];
- }
+ // get response
+ $json_response = WMobilePack::read_data($json_url);
- } elseif ($json_response == false) {
+ if ($json_response !== false && $json_response != '') {
- // Store this data in a transient
- set_transient(WMobilePack_Options::$transient_prefix.'more_updates', 'warning', 3600*24*2 );
+ // Store this data in a transient
+ set_transient(WMobilePack_Options::$transient_prefix.'more_updates', $json_response, 3600*24*2);
- // return message
- return 'warning';
- }
+ // get response
+ $response = json_decode($json_response, true);
- } else {
+ if (isset($response["content"]) && is_array($response["content"]) && !empty($response["content"])){
- if ($json_data == 'warning')
- return $json_data;
+ // return response
+ return $response["content"];
+ }
- // get response
- $response = json_decode($json_data, true);
+ } elseif ($json_response == false) {
- if (isset($response["content"]) && is_array($response["content"]) && !empty($response["content"]))
- return $response["content"];
- }
+ // Store this data in a transient
+ set_transient(WMobilePack_Options::$transient_prefix.'more_updates', 'warning', 3600*24*2 );
+
+ // return message
+ return 'warning';
+ }
// by default return empty array
return array();
@@ -425,14 +436,13 @@ if ( ! class_exists( 'WMobilePack_Admin' ) ) {
if (array_key_exists('premium', $upgrade_content)) {
- if (array_key_exists('packages', $upgrade_content['premium']) && is_array($upgrade_content['premium']['packages']) && count($upgrade_content['premium']['packages']) >= 1) {
-
- $package = $upgrade_content['premium']['packages'][0];
+ if (isset($upgrade_content['premium']['packages']['upgrade_link']) &&
+ filter_var($upgrade_content['premium']['packages']['upgrade_link'], FILTER_VALIDATE_URL)) {
- if (array_key_exists('button_link', $package)) {
- return $package['button_link'];
- }
+ return $upgrade_content['premium']['packages']['upgrade_link'];
}
+
+ return false;
}
}
@@ -453,16 +463,16 @@ if ( ! class_exists( 'WMobilePack_Admin' ) ) {
if (is_array($upgrade_content) && !empty($upgrade_content)){
- if (array_key_exists('premium', $upgrade_content)) {
+ if (array_key_exists('premium', $upgrade_content) && array_key_exists('themes', $upgrade_content['premium'])) {
- if (array_key_exists('themes', $upgrade_content['premium']) && is_array($upgrade_content['premium']['themes'])) {
+ if (array_key_exists('list', $upgrade_content['premium']['themes']) && is_array($upgrade_content['premium']['themes']['list'])) {
- foreach ($upgrade_content['premium']['themes'] as $theme){
+ foreach ($upgrade_content['premium']['themes']['list'] as $theme){
if (isset($theme['title']) &&
isset($theme['icon']) && filter_var($theme['icon'], FILTER_VALIDATE_URL) &&
- (!isset($theme['bundle']) || is_numeric($theme['bundle'])) &&
- (!isset($theme['preorder']) || is_numeric($theme['preorder']))
+ (!isset($theme['demo']['link']) || filter_var($theme['demo']['link'], FILTER_VALIDATE_URL)) &&
+ (!isset($theme['details']['link']) || filter_var($theme['details']['link'], FILTER_VALIDATE_URL))
){
$themes[] = $theme;
}