function sl_add_options_page() { global $sl_dir, $sl_base, $sl_uploads_base, $text_domain, $sl_top_nav_links, $sl_vars, $sl_version; $parent_url = SL_PARENT_URL; //SL_PAGES_DIR.'/information.php'; $warning_count = 0; $warning_title = __("Update(s) currently available for Store Locator", SL_TEXT_DOMAIN) . ":"; ####Base Plugin Update Notification in WP Menu ============= // if (function_exists("plugins_api")) { $sl_vars['sl_latest_version_check_time'] = empty($sl_vars['sl_latest_version_check_time']) ? date("Y-m-d H:i:s") : $sl_vars['sl_latest_version_check_time']; if (empty($sl_vars['sl_latest_version']) || (time() - strtotime($sl_vars['sl_latest_version_check_time'])) / 60 >= 60 * 12) { //12-hr db caching of version info /*if (!function_exists("plugins_api")) { $plugin_install_url = ABSPATH."wp-admin/includes/plugin-install.php"; //die($plugin_install_url); include_once($plugin_install_url); }*/ // Causing fatal errors in some installs -- so must assume it's available to all already -- 2/23/15 //$sl_api = plugins_api('plugin_information', array('slug' => 'store-locator', 'fields' => array('sections' => false) ) ); $sl_api = sl_remote_data(array('host' => 'api.wordpress.org', 'url' => '/plugins/info/1.0/store-locator', 'ua' => 'none'), 'serial'); /*need 'true' if trying to include changelog info in future*/ //var_dump($sl_api); die(); $sl_latest_version = $sl_api->version; //$sl_version="2.6"; //$sl_latest_changelog = $sl_api->sections['changelog']; //var_dump($sl_latest_changelog); die(); //preg_match_all("@<ul>(.*)</ul>@", $sl_latest_changelog, $sl_version_matches); var_dump($sl_version_matches); die(); $sl_vars['sl_latest_version_check_time'] = date("Y-m-d H:i:s"); $sl_vars['sl_latest_version'] = $sl_latest_version; } else { $sl_latest_version = $sl_vars['sl_latest_version']; } //$sl_version = 2.6; //testing purposes if (strnatcmp($sl_latest_version, $sl_version) > 0) { $warning_title .= "\n- Store Locator v{$sl_latest_version} " . __("is available, you are using", SL_TEXT_DOMAIN) . " v{$sl_version}"; $warning_count++; $sl_plugin = SL_DIR . "/store-locator.php"; $sl_update_link = admin_url('update.php?action=upgrade-plugin&plugin=' . $sl_plugin); $sl_update_link_nonce = wp_nonce_url($sl_update_link, 'upgrade-plugin_' . $sl_plugin); $sl_update_msg = " > <a href='{$sl_update_link_nonce}' style='color:#900; font-weight:bold;' onclick='confirmClick(\"" . __("You will now be updating to Store Locator", SL_TEXT_DOMAIN) . " v{$sl_latest_version}, " . __("click OK or Confirm to continue", SL_TEXT_DOMAIN) . ".\", this.href); return false;'>" . __("Update to", SL_TEXT_DOMAIN) . " {$sl_latest_version}</a>"; } else { $sl_update_msg = ""; } // } ####Addons Platform Update Notification in WP Menu (increases warning count) =========== if (defined("SL_ADDONS_PLATFORM_DIR")) { $sl_vars['sl_latest_ap_check_time'] = empty($sl_vars['sl_latest_ap_check_time']) ? date("Y-m-d H:i:s") : $sl_vars['sl_latest_ap_check_time']; if (empty($sl_vars['sl_latest_ap_version']) || (time() - strtotime($sl_vars['sl_latest_ap_check_time'])) / 60 >= 60 * 12) { //12-hr db caching of version info $ap_update = sl_remote_data(array('pagetype' => 'ap', 'dir' => SL_ADDONS_PLATFORM_DIR, 'key' => sl_data('sl_license_' . SL_ADDONS_PLATFORM_DIR))); $ap_latest_version = !empty($ap_update[0]) ? preg_replace("@\\.zip|" . SL_ADDONS_PLATFORM_DIR . "\\.@", "", $ap_update[0]['filename']) : 0; //var_dump($ap_update); die(); $sl_vars['sl_latest_ap_check_time'] = date("Y-m-d H:i:s"); $sl_vars['sl_latest_ap_version'] = $ap_latest_version; } else { $ap_latest_version = $sl_vars['sl_latest_ap_version']; } $ap_readme = SL_ADDONS_PLATFORM_PATH . "/readme.txt"; if (file_exists($ap_readme)) { $rm_txt = file_get_contents($ap_readme); preg_match("/\n[ ]*stable tag:[ ]?([^\n]+)(\n)?/i", $rm_txt, $cv); //var_dump($rm_txt); var_dump($cv); $ap_version = !empty($cv[1]) ? trim($cv[1]) : "1.0"; } else { $ap_version = "1.0"; } if (strnatcmp($ap_latest_version, $ap_version) > 0) { $ap_title = ucwords(str_replace("-", " ", SL_ADDONS_PLATFORM_DIR)); $warning_title .= "\n- {$ap_title} v{$ap_latest_version} " . __("is available, you are using", SL_TEXT_DOMAIN) . " v{$ap_version}"; $warning_count++; } } $notify = $warning_count > 0 ? " <span class='update-plugins count-{$warning_count}' title='{$warning_title}'><span class='update-count'>" . $warning_count . "</span></span>" : ""; $sl_menu_pages['main'] = array('title' => __("Store Locator", SL_TEXT_DOMAIN) . "{$notify}", 'capability' => 'administrator', 'page_url' => $parent_url, 'icon' => SL_BASE . '/images/logo.ico.png', 'menu_position' => 47); $sl_menu_pages['sub']['information'] = array('parent_url' => $parent_url, 'title' => __("News & Upgrades", SL_TEXT_DOMAIN), 'capability' => 'administrator', 'page_url' => $parent_url); $sl_menu_pages['sub']['locations'] = array('parent_url' => $parent_url, 'title' => __("Locations", SL_TEXT_DOMAIN), 'capability' => 'administrator', 'page_url' => SL_PAGES_DIR . '/locations.php'); $sl_menu_pages['sub']['mapdesigner'] = array('parent_url' => $parent_url, 'title' => __("MapDesigner", SL_TEXT_DOMAIN), 'capability' => 'administrator', 'page_url' => SL_PAGES_DIR . '/mapdesigner.php'); sl_menu_pages_filter($sl_menu_pages); /* add_menu_page(__("Store Locator", SL_TEXT_DOMAIN), __("Store Locator", SL_TEXT_DOMAIN), 'administrator', SL_PAGES_DIR.'/locations.php', '', SL_BASE.'/images/logo.ico.png', 25.1); $sl_pg_loc = add_submenu_page(SL_PAGES_DIR.'/locations.php', __("Locations", SL_TEXT_DOMAIN), __("Locations", SL_TEXT_DOMAIN), 'administrator', SL_PAGES_DIR.'/locations.php'); $sl_pg_md = add_submenu_page(SL_PAGES_DIR.'/locations.php', __("MapDesigner", SL_TEXT_DOMAIN), __("MapDesigner", SL_TEXT_DOMAIN), 'administrator', SL_PAGES_DIR.'/mapdesigner.php');*/ //} }
$sl_latest_version = $sl_vars['sl_latest_version']; } if (strnatcmp($sl_latest_version, $sl_version) > 0) { $sl_plugin = SL_DIR . "/store-locator.php"; $sl_update_link = admin_url('update.php?action=upgrade-plugin&plugin=' . $sl_plugin); $sl_update_link_nonce = wp_nonce_url($sl_update_link, 'upgrade-plugin_' . $sl_plugin); $sl_update_msg = " > <a href='{$sl_update_link_nonce}' style='color:#900; font-weight:bold;' onclick='confirmClick(\"" . __("You will now be updating to Store Locator", SL_TEXT_DOMAIN) . " v{$sl_latest_version}, " . __("click OK or Confirm to continue", SL_TEXT_DOMAIN) . ".\", this.href); return false;'>" . __("Update to", SL_TEXT_DOMAIN) . " {$sl_latest_version}</a>"; } else { $sl_update_msg = ""; } #Notice for Addons Platform update if (defined("SL_ADDONS_PLATFORM_DIR")) { $sl_vars['sl_latest_ap_check_time'] = empty($sl_vars['sl_latest_ap_check_time']) ? date("Y-m-d H:i:s") : $sl_vars['sl_latest_ap_check_time']; if (empty($sl_vars['sl_latest_ap_version']) || (time() - strtotime($sl_vars['sl_latest_ap_check_time'])) / 60 >= 60 * 12) { //12-hr db caching of version info $ap_update = sl_remote_data(array('pagetype' => 'ap', 'dir' => SL_ADDONS_PLATFORM_DIR, 'key' => sl_data('sl_license_' . SL_ADDONS_PLATFORM_DIR))); $ap_latest_version = !empty($ap_update[0]) ? preg_replace("@\\.zip|" . SL_ADDONS_PLATFORM_DIR . "\\.@", "", $ap_update[0]['filename']) : 0; //var_dump($ap_update); die(); $sl_vars['sl_latest_ap_check_time'] = date("Y-m-d H:i:s"); $sl_vars['sl_latest_ap_version'] = $ap_latest_version; } else { $ap_latest_version = $sl_vars['sl_latest_ap_version']; } $ap_readme = SL_ADDONS_PLATFORM_PATH . "/readme.txt"; if (file_exists($ap_readme)) { $rm_txt = file_get_contents($ap_readme); preg_match("/\n[ ]*stable tag:[ ]?([^\n]+)(\n)?/i", $rm_txt, $cv); //var_dump($rm_txt); var_dump($cv); $ap_version = !empty($cv[1]) ? trim($cv[1]) : "1.0"; } else { $ap_version = "1.0";