summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/wordpress-mobile-pack/plugins/wpmp_switcher')
-rwxr-xr-xplugins/wordpress-mobile-pack/plugins/wpmp_switcher/lite_detection.php171
-rwxr-xr-xplugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/desktop_interstitial.php40
-rwxr-xr-xplugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/mobile.php127
-rwxr-xr-xplugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/mobile_admin.php442
-rwxr-xr-xplugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/mobile_interstitial.php38
-rwxr-xr-xplugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/mobile_login.php163
-rwxr-xr-xplugins/wordpress-mobile-pack/plugins/wpmp_switcher/wpmp_switcher.php708
-rwxr-xr-xplugins/wordpress-mobile-pack/plugins/wpmp_switcher/wpmp_switcher_admin.php122
8 files changed, 0 insertions, 1811 deletions
diff --git a/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/lite_detection.php b/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/lite_detection.php
deleted file mode 100755
index 42cf7853..00000000
--- a/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/lite_detection.php
+++ /dev/null
@@ -1,171 +0,0 @@
-<?php
-
-/*
-$Id: lite_detection.php 195195 2010-01-19 04:11:37Z jamesgpearce $
-
-$URL: http://plugins.svn.wordpress.org/wordpress-mobile-pack/trunk/plugins/wpmp_switcher/lite_detection.php $
-
-Copyright (c) 2009 James Pearce & friends, portions mTLD Top Level Domain Limited, ribot, Forum Nokia
-
-Online support: http://wordpress.org/extend/plugins/wordpress-mobile-pack/
-
-This file is part of the WordPress Mobile Pack.
-
-The WordPress Mobile Pack is Licensed under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with the
-License.
-
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software distributed
-under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
-CONDITIONS OF ANY KIND, either express or implied. See the License for the
-specific language governing permissions and limitations under the License.
-*/
-
-function lite_detection() {
- if (isset($_SERVER['HTTP_X_WAP_PROFILE']) ||
- isset($_SERVER['HTTP_PROFILE'])) {
- return true;
- }
- $user_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
- if (in_array(substr($user_agent, 0, 4), lite_detection_ua_prefixes())) {
- return true;
- }
- $accept = strtolower($_SERVER['HTTP_ACCEPT']);
- if (strpos($accept, 'wap') !== false) {
- return true;
- }
- if (preg_match("/(" . lite_detection_ua_contains() . ")/i", $user_agent)) {
- return true;
- }
- if (isset($_SERVER['ALL_HTTP']) && strpos(strtolower($_SERVER['ALL_HTTP']), 'operamini') !== false) {
- return true;
- }
- return false;
-}
-
-function lite_detection_ua_prefixes() {
- return array(
- 'w3c ',
- 'w3c-',
- 'acs-',
- 'alav',
- 'alca',
- 'amoi',
- 'audi',
- 'avan',
- 'benq',
- 'bird',
- 'blac',
- 'blaz',
- 'brew',
- 'cell',
- 'cldc',
- 'cmd-',
- 'dang',
- 'doco',
- 'eric',
- 'hipt',
- 'htc_',
- 'inno',
- 'ipaq',
- 'ipod',
- 'jigs',
- 'kddi',
- 'keji',
- 'leno',
- 'lg-c',
- 'lg-d',
- 'lg-g',
- 'lge-',
- 'lg/u',
- 'maui',
- 'maxo',
- 'midp',
- 'mits',
- 'mmef',
- 'mobi',
- 'mot-',
- 'moto',
- 'mwbp',
- 'nec-',
- 'newt',
- 'noki',
- 'palm',
- 'pana',
- 'pant',
- 'phil',
- 'play',
- 'port',
- 'prox',
- 'qwap',
- 'sage',
- 'sams',
- 'sany',
- 'sch-',
- 'sec-',
- 'send',
- 'seri',
- 'sgh-',
- 'shar',
- 'sie-',
- 'siem',
- 'smal',
- 'smar',
- 'sony',
- 'sph-',
- 'symb',
- 't-mo',
- 'teli',
- 'tim-',
- 'tosh',
- 'tsm-',
- 'upg1',
- 'upsi',
- 'vk-v',
- 'voda',
- 'wap-',
- 'wapa',
- 'wapi',
- 'wapp',
- 'wapr',
- 'webc',
- 'winw',
- 'winw',
- 'xda ',
- 'xda-',
- );
-}
-
-function lite_detection_ua_contains() {
- return implode("|", array(
- 'android',
- 'blackberry',
- 'hiptop',
- 'ipod',
- 'lge vx',
- 'midp',
- 'maemo',
- 'mmp',
- 'netfront',
- 'nintendo DS',
- 'novarra',
- 'openweb',
- 'opera mobi',
- 'opera mini',
- 'palm',
- 'psp',
- 'phone',
- 'smartphone',
- 'symbian',
- 'up.browser',
- 'up.link',
- 'wap',
- 'windows ce',
- ));
-}
-
-?>
diff --git a/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/desktop_interstitial.php b/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/desktop_interstitial.php
deleted file mode 100755
index 43afe489..00000000
--- a/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/desktop_interstitial.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-/*
-$Id: desktop_interstitial.php 195195 2010-01-19 04:11:37Z jamesgpearce $
-
-$URL: http://plugins.svn.wordpress.org/wordpress-mobile-pack/trunk/plugins/wpmp_switcher/pages/desktop_interstitial.php $
-
-Copyright (c) 2009 James Pearce & friends, portions mTLD Top Level Domain Limited, ribot, Forum Nokia
-
-Online support: http://wordpress.org/extend/plugins/wordpress-mobile-pack/
-
-This file is part of the WordPress Mobile Pack.
-
-The WordPress Mobile Pack is Licensed under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with the
-License.
-
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software distributed
-under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
-CONDITIONS OF ANY KIND, either express or implied. See the License for the
-specific language governing permissions and limitations under the License.
-*/
-
-?><html>
- <head>
- <title><?php bloginfo('name'); ?> - <?php _e("Select site", 'wpmp'); ?></title>
- <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
- <?php wp_head(); ?>
- </head>
- <body>
- <h2><?php _e("Select site", 'wpmp'); ?></h2>
- <p><?php _e("You've requested the mobile site, but you appear to have a desktop browser.", 'wpmp'); ?></p>
- <p><?php print wpmp_switcher_link('desktop', __("Revert to the desktop site", 'wpmp')); ?></p>
- <p><?php print wpmp_switcher_link('mobile', __("Continue to our mobile site", 'wpmp')); ?></p>
- </body>
-</html>
diff --git a/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/mobile.php b/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/mobile.php
deleted file mode 100755
index 49ed1516..00000000
--- a/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/mobile.php
+++ /dev/null
@@ -1,127 +0,0 @@
-<?php
-
-/*
-$Id: mobile.php 195195 2010-01-19 04:11:37Z jamesgpearce $
-
-$URL: http://plugins.svn.wordpress.org/wordpress-mobile-pack/trunk/plugins/wpmp_switcher/pages/mobile.php $
-
-Copyright (c) 2009 James Pearce & friends, portions mTLD Top Level Domain Limited, ribot, Forum Nokia
-
-Online support: http://wordpress.org/extend/plugins/wordpress-mobile-pack/
-
-This file is part of the WordPress Mobile Pack.
-
-The WordPress Mobile Pack is Licensed under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with the
-License.
-
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software distributed
-under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
-CONDITIONS OF ANY KIND, either express or implied. See the License for the
-specific language governing permissions and limitations under the License.
-*/
-
-function wpmp_ms_mobile_top($title, $menu=array()) {
- print "<?xml version='1.0' encoding='UTF-8'?>";
-
- //defend against old, confused or custom mobile themes
- include_once(get_theme_root() . DIRECTORY_SEPARATOR . 'mobile_pack_base' . DIRECTORY_SEPARATOR . 'functions.php');
- if(!function_exists('wpmp_theme_group_file')) {
- function wpmp_theme_group_file($file='index.php') {
- return 'none';
- }
- function wpmp_theme_base_style() {
- return get_bloginfo('stylesheet_url');
- }
- function wpmp_theme_group() {
- return 'none';
- }
- }
-
- if (file_exists($wpmp_include = wpmp_theme_group_file('header.php'))) {
- include_once($wpmp_include);
- } else {
- ?><!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.1//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head profile="http://gmpg.org/xfn/11">
- <?php if (get_bloginfo('stylesheet_url') != wpmp_theme_base_style()) { ?>
- <link href="<?php print wpmp_theme_base_style() ?>" rel="stylesheet" type="text/css" />
- <?php } ?>
- <link href="<?php bloginfo('stylesheet_url'); ?>" rel="stylesheet" type="text/css" />
- <link href="<?php print get_theme_root_uri(); ?>/mobile_pack_base/style_structure.css" rel="stylesheet" type="text/css" />
- <?php
- }
- ?>
- <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
- <title><?php bloginfo('name'); ?> <?php print $title; ?></title>
- <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
- <link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
- <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
- <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
- <?php wp_head(); ?>
- </head>
- <body class="<?php if($wpmp_theme_group = wpmp_theme_group()) {print $wpmp_theme_group;} else {print 'base';} ?>">
- <div id="wrap">
- <div id="header" style='height:auto'>
- <p><a href="<?php echo get_option('home'); ?>/"><strong><?php bloginfo('name'); ?></strong></a></p>
- <p><?php bloginfo('description'); ?></p>
- </div>
- <?php
- if($menu) {
- $base = get_option('home');
- print '<div id="menu"><ul class="breadcrumbs">';
- $page = $_SERVER['REQUEST_URI'];
- if(substr($page, -9)=="/wp-admin") {
- $page="$base/wp-admin/index.php";
- }
- foreach($menu as $name=>$link) {
- $item = '<li class="';
- if(strpos(strtolower($page), strtolower($link))!==false) {
- $item .= 'current_';
- $title = substr($name, ($name[0]=='_')?1:0);
- }
- if(substr($link, 0, 7)!="http://" && substr($link, 0, 8)!="https://") {
- $link = $base . $link;
- }
- $item .= 'page_item"><a href="' . $link . '" title="' . $name . '">' . __($name, 'wpmp') . '</a></li> ';
- if ($name[0]!='_') {
- print $item;
- }
- }
- print '</ul></div>';
- }
- ?>
- <div id="wrapper">
- <div id="content">
- <h1><?php print $title; ?></h1>
- <?php
- }
-
-
-
- function wpmp_ms_mobile_bottom() {
- ?>
- </div>
- </div>
- <div id="footer">
- <?php
- if (file_exists($wpmp_include = wpmp_theme_group_file('footer.php'))) {
- include_once($wpmp_include);
- } else {
- ?>
- <p><?php printf(__("Powered by the <a%s>WordPress Mobile Pack</a>", 'wpmp'), ' href="http://wordpress.org/extend/plugins/wordpress-mobile-pack/"');?> | <?php printf(__("Theme designed by <a%s>ribot</a>", 'wpmp'), ' href="http://ribot.co.uk"'); ?></p>
- <?php
- }
- ?>
- <?php wpmp_switcher_wp_footer(true); ?>
- </div>
- </div>
- </body>
-</html>
-<?php
-}
-?>
diff --git a/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/mobile_admin.php b/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/mobile_admin.php
deleted file mode 100755
index 19d798be..00000000
--- a/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/mobile_admin.php
+++ /dev/null
@@ -1,442 +0,0 @@
-<?php
-
-/*
-$Id: mobile_admin.php 195195 2010-01-19 04:11:37Z jamesgpearce $
-
-$URL: http://plugins.svn.wordpress.org/wordpress-mobile-pack/trunk/plugins/wpmp_switcher/pages/mobile_admin.php $
-
-Copyright (c) 2009 James Pearce & friends, portions mTLD Top Level Domain Limited, ribot, Forum Nokia
-
-Online support: http://wordpress.org/extend/plugins/wordpress-mobile-pack/
-
-This file is part of the WordPress Mobile Pack.
-
-The WordPress Mobile Pack is Licensed under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with the
-License.
-
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software distributed
-under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
-CONDITIONS OF ANY KIND, either express or implied. See the License for the
-specific language governing permissions and limitations under the License.
-*/
-
- include_once('mobile.php');
- wpmp_ms_mobile_admin();
-
- function wpmp_ms_mobile_admin() {
- $base = get_option('home');
-
- if (($user = wp_get_current_user())==null || $user->ID==0) {
- header("Location: $base/wp-login.php?redirect_to=" . urlencode($base) . "%2Fwp-admin%2F");
- }
-
- $menu = array(
- __("Overview", 'wpmp') => "/wp-admin/index.php",
- __("New post", 'wpmp') => "/wp-admin/post-new.php",
- __("Edit post", 'wpmp') => "/wp-admin/post.php?action=edit",
- __("Comments", 'wpmp') => "/wp-admin/edit-comments.php",
- "_" . __("Comment", 'wpmp') => "/wp-admin/comment.php",
- __("Switcher", 'wpmp') => "/wp-admin/themes.php",
- __("Settings", 'wpmp') => "/wp-admin/options-general.php",
- );
- if (function_exists('wp_logout_url')) {
- $menu[__("Log out", 'wpmp')] = wp_logout_url();
- } else {
- $menu[__("Log out", 'wpmp')] = "/wp-login.php?action=logout";
- }
-
- $page = $_SERVER['REQUEST_URI'];
- $function = "";
- foreach($menu as $link) {
- if(strpos(strtolower($page), strtolower($link))!==false) {
- $function = substr($link, 10);
- $function = explode(".", $function);
- $function = str_replace("-", "_", $function[0]);
- $function = strtolower($function);
- break;
- }
- }
- if(!function_exists("wpmp_msma_$function")) {
- $function = "overview";
- }
- if(!current_user_can('manage_options')) { // harsh but fair
- $menu = array();
- $function = "junior";
- }
-
- wpmp_ms_mobile_top("Admin", $menu);
- call_user_func("wpmp_msma_$function", $menu);
- wpmp_ms_mobile_bottom();
- }
-
- function wpmp_msma_overview($menu) {
- $base = get_option('home');
- $post_count = wp_count_posts('post');
- $page_count = wp_count_posts('page');
- print "<p>";
- printf(__ngettext("You have one post", "You have %d posts", $c=0+($post_count->publish), 'wpmp'), $c);
- print ' ';
- printf(__ngettext("and one page", "and %d pages", $c=0+($page_count->publish), 'wpmp'), $c);
- print ' ' . __("contained within", 'wpmp') . ' ';
- printf(__ngettext("one category", "%d categories", $c=0+(wp_count_terms('category')), 'wpmp'), $c);
- print ' ' . __("and", 'wpmp') . ' ';
- printf(__ngettext("one tag", "%d tags", $c=0+(wp_count_terms('post_tag')), 'wpmp'), $c);
- print ".</p>";
- global $wpdb;
- $comments = $wpdb->get_results("SELECT count(*) as cnt FROM $wpdb->comments WHERE comment_approved='0'" );
- $comment_count = $comments[0];
- printf("<p>" . __ngettext("You have one comment to moderate", "You have %d comments to moderate", $c=0+($comment_count->cnt), 'wpmp') . ".</p>", $c);
- print "<h3>" . __("Select an admin page:", 'wpmp') . "</h3>";
- print "<p><ul>";
- $not_first = false;
- foreach($menu as $name=>$link) {
- if($name[0]!='_' && $not_first) {
- if(substr($link, 0, 7)!="http://" && substr($link, 0, 8)!="https://") {
- $link = $base . $link;
- }
- print "<li><a href='$link'>" . __("$name", 'wpmp') . "</a>";
- }
- $not_first = true;
- }
- print "</ul></p>";
- print "<p>" . sprintf(__("...or <a%s>return to the site</a>", 'wpmp'), " href='$base/'") . "</p>";
- print "<p>" . __("A subset of the full WordPress administration is available through this mobile interface.", 'wpmp') . "</p>";
- }
-
- function wpmp_msma_junior($menu) {
- $base = get_option('home');
- print "<h3>" . __("Sorry! Permission denied...", 'wpmp') . "</h3>";
- print "<p>" . __("Only 'administrator' users can use the mobile admin panel.", 'wpmp') . "</p>";
- print "<p><a href='" . get_option('siteurl') . "$base/wp-login.php?action=logout'>" . __("Login as a different user", 'wpmp') . "</a> " . __("or", 'wpmp') . " <a href='$base/'>" . __("return to the site", 'wpmp') . "</a></p>";
- }
-
- function wpmp_msma_post_new() {
- wpmp_msma_post(null, true);
- }
- function wpmp_msma_post($menu, $new = false) {
- if (sizeof($_POST) > 0) {
- if (!wpmp_msma_check_referer()) { return; }
- @wp_update_post($_POST);
- print "<p>" . __("Your changes have been applied.", 'wpmp') . "</p>";
- wpmp_msma_post_list();
- } else {
- if(is_numeric($id = @$_GET['post'])) {
- $post = get_post($id, OBJECT, 'edit');
- if(!$post->ID) {
- print "<p>" . __("That post does not exist, but you may write a new one.", 'wpmp') . "</p>";
- }
- } elseif (!$new) {
- wpmp_msma_post_list();
- return;
- }
- if(!@$post->ID) {
- $post->ID = 0;
- $post->post_status = 'draft';
- }
- wpmp_msma_post_edit_form($post);
- }
- }
-
- function wpmp_msma_post_edit_form($post) {
- global $user_ID;
- print '<form name="post" action="' . $_SERVER['REQUEST_URI'] . '" method="post" id="post">';
-
- print '<input type="hidden" name="ID" value="' . $post->ID . '" />';
- print '<input type="hidden" name="user_ID" value="' . (int) $user_ID . '" />';
-
- print '<p><label for="title">' . __('Title', 'wpmp') . ':</label><br />';
- print '<input type="text" name="post_title" value="' . attribute_escape(@$post->post_title) . '" id="title" /></p>';
-
- print '<p><label for="post_status">' . __('Status', 'wpmp') . ':</label><br />';
- print '<select name="post_status" id="post_status">';
- print '<option ' . (($post->post_status == 'publish' || $post->post_status == 'private') ? 'selected="selected"' : "") . ' value="publish">' . __('Published', 'wpmp') . '</option>';
- print '<option ' . (($post->post_status == 'draft' || $post->post_status == 'future') ? 'selected="selected"' : "") . ' value="draft">' . __('Unpublished', 'wpmp') . '</option>';
- print '<option ' . (($post->post_status == 'pending') ? 'selected="selected"' : "") . ' value="pending">' . __('Pending Review', 'wpmp') . '</option>';
- print '</select></p>';
-
- print '<p><label for="post_content">' . __('Content', 'wpmp') . ':</label><br />';
- $safe_content = @$post->post_content;
- $safe_content = str_replace("<textarea", "<div", $safe_content);
- $safe_content = str_replace("<TEXTAREA", "<div", $safe_content);
- $safe_content = str_replace("</textarea", "</div", $safe_content);
- $safe_content = str_replace("</TEXTAREA", "</div", $safe_content);
- print '<textarea name="post_content" id="post_content" rows="6">' . $safe_content . '</textarea></p>';
- print '<input class="button" name="submit" type="submit" id="submit" value="' . __('Apply', 'wpmp') . '" />';
- print '<p>' . __('You can use HTML tags to format your post. Use &lt;!--more--&gt; to indicate the end of the teaser.', 'wpmp') . '</p>';
-
- print '</form>';
- }
-
- function wpmp_msma_post_list() {
- $base = get_option('home');
- wp('orderby=modified');
- if(have_posts()) {
- global $post;
- print "<p>" . __("Select a post to edit:", 'wpmp') . "</p>";
- add_filter('get_pagenum_link', 'wpmp_msma_get_pagenum_link');
- while (have_posts()) {
- the_post();
- print "<p>" .
- "<strong><a href='$base/wp-admin/post.php?action=edit&post=$post->ID'>" . get_the_title() . "</a></strong>" .
- "<br />" . get_the_modified_date() .
- "<br />" . wpmp_msma_post_status($post->post_status) .
- "</p>";
- }
- next_posts_link('Older');
- previous_posts_link('Newer');
- } else {
- print "<p>" . __("There are no posts to edit.", 'wpmp') . "</p>";
- }
- }
- function wpmp_msma_edit_comments() {
- global $wpdb;
- $comments = $wpdb->get_results("SELECT $wpdb->comments.*, $wpdb->posts.post_title FROM $wpdb->comments INNER JOIN $wpdb->posts ON $wpdb->comments.comment_post_id = $wpdb->posts.id WHERE comment_approved='0' ORDER BY comment_date_gmt DESC LIMIT 5" );
- if(sizeof($comments)==0) {
- print "<p>" . __("This site has no comments awaiting moderation.", 'wpmp') . "</p>";
- } else {
- switch($size = sizeof($comments)) {
- case 5:
- print "<p>" . __("There are at least 5 comments awaiting moderation:", 'wpmp') . "</p>";
- break;
- case 1:
- return wpmp_msma_edit_comment($comments[0], true);
- default:
- print "<p>" . __("There are $size comments awaiting moderation:", 'wpmp') . "</p>";
- }
- foreach($comments as $comment) {
- wpmp_msma_edit_comment($comment);
- }
- }
- }
- function wpmp_msma_comment() {
- $id = $_GET['c'];
- if(is_numeric($id)) {
- global $wpdb;
- if(isset($_GET['action']) && $_GET['action']=="approvecomment" && wpmp_msma_check_referer()) {
- wp_set_comment_status($id, 'approve');
- } elseif (isset($_GET['action']) && $_GET['action']=="deletecomment" && wpmp_msma_check_referer()) {
- wp_set_comment_status($id, 'delete');
- } elseif (isset($_GET['action']) && $_GET['action']=="spamcomment" && wpmp_msma_check_referer()) {
- wp_set_comment_status($id, 'spam');
- } else {
- $comment = $wpdb->get_results("SELECT $wpdb->comments.*, $wpdb->posts.post_title FROM $wpdb->comments INNER JOIN $wpdb->posts ON $wpdb->comments.comment_post_id = $wpdb->posts.id WHERE comment_ID=$id;" );
- }
- }
- if(!@$comment) {
- return wpmp_msma_edit_comments();
- }
- wpmp_msma_edit_comment($comment[0], true);
- }
-
- function wpmp_msma_themes() {
- if (isset($_POST['wpmp_switcher_mode'])) {
- if (!wpmp_msma_check_referer()) { return; }
- update_option('wpmp_switcher_mode', $_POST['wpmp_switcher_mode']);
- print "<p>" . __("Your changes have been applied.", 'wpmp') . "</p>";
- print "<p><a href='/wp-admin/'>" . __("Continue.", 'wpmp') . "</a></p>";
- return;
- }
- print '<form name="post" action="' . $_SERVER['REQUEST_URI'] . '" method="post" id="post">';
- print '<p><label for="title">' . __('Change the mobile switcher mode:', 'wpmp') . '</label><br />';
- $current = get_option('wpmp_switcher_mode');
- foreach(array(
- 'none'=>__('Disabled', 'wpmp'),
- 'browser'=>__('Browser detection', 'wpmp'),
- 'domain'=>__('Domain mapping', 'wpmp'),
- 'browserdomain'=>__('BOTH: browser detection and domain mapping', 'wpmp'),
- ) as $value=>$title) {
- print "<input style='width:32px;' type='radio' name='wpmp_switcher_mode' value='$value'";
- if ($value == $current) {
- print " checked";
- }
- print "/> $title<br />";
- }
- print '</select></p>';
- print '<input class="button" name="submit" type="submit" id="submit" value="' . __('Apply', 'wpmp') . '" />';
- print '</form>';
- print "<p>" . __("NB: Changing the switcher mode may return you to the desktop version of the admin pages. Be cautious if you are using a mobile device.", 'wpmp') . "</p>";
- }
-
- function wpmp_msma_edit_comment(&$comment, $full = false) {
- $base = get_option('home');
- $id = $comment->comment_ID;
- $content = strip_tags($comment->comment_content);
- $title = strip_tags($comment->comment_author);
- if(!$full) {
- $title = "<a href='$base/wp-admin/comment.php?action=editcomment&amp;c=$id'>$title</a>";
- if(strlen($content)>100) {
- $content = substr($content, 0, 100) . "...";
- }
- }
- $approve = "<a href='comment.php?action=approvecomment&amp;c=$id'>" . __('Approve', 'wpmp') . "</a>";
- $delete = "<a href='comment.php?action=deletecomment&amp;c=$id'>" . __('Delete', 'wpmp') . "</a>";
- $spam = "<a href='comment.php?action=spamcomment&amp;c=$id'>" . __('Spam', 'wpmp') . "</a>";
- print "<p>" . sprintf(_c('<strong>%1$s</strong> on %2$s|comment_title ON post_title', 'wpmp'), $title, $comment->post_title) .
- "<br />$content" .
- "<br />$approve | $delete | $spam" .
- "</p>";
- }
-
- function wpmp_msma_options_general() {
- if(isset($_GET['option']) && is_numeric($id = $_GET['option'])) {
- if (sizeof($_POST) > 0) {
- if (!wpmp_msma_check_referer()) { return; }
- wpmp_msma_option_update($_POST);
- print "<p>" . __("Your changes have been applied.", 'wpmp') . "</p>";
- return wpmp_msma_options_list();
- } else {
- return wpmp_msma_option_edit_form($id);
- }
- }
- wpmp_msma_options_list();
- }
-
- function wpmp_msma_options_filter() {
- return "WHERE option_name!='' AND " .
- "LEFT(option_name, 4)!='rss_' AND " .
- "NOT INSTR(option_name, 'widget') AND " .
- "NOT INSTR(option_name, 'plugin') AND " .
- "option_name NOT IN ('cron', 'update_core', 'recently_edited', 'wp_user_roles', 'category_children', 'wpmp_deviceatlas_json_location')" .
- "";
- }
-
- function wpmp_msma_options_list() {
- global $wpdb;
- $base = get_option('home');
- $count = $wpdb->get_results("SELECT count(*) as cnt FROM $wpdb->options " . wpmp_msma_options_filter());
- $count = ($count[0]->cnt);
- $size = 10;
- $page = 0;
- if(isset($_GET['page']) && is_numeric($_GET['page'])) {
- $page = $_GET['page'];
- }
- $start = $page * $size;
- $options = $wpdb->get_results("SELECT * FROM $wpdb->options " . wpmp_msma_options_filter() . " order by option_id asc LIMIT $start, $size" );
- foreach($options as $option) {
- $editable = false;
- $label = wpmp_msma_option_name($option->option_name);
- $value = wpmp_msma_option_value($option->option_name, $option->option_value, $editable);
- if ($editable) {
- $label = "<a href='$base/wp-admin/options-general.php?page=$page&amp;option=$option->option_id'>$label</a>";
- }
- print "<p>$label: " . htmlentities($value) . "</p>";
- }
- $next = "";
- $previous = "";
- if($page>0) {
- $previous = "<a href='?page=" . ($page-1) . "'>" . __('Previous page', 'wpmp') . "</a>";
- }
- if(($page+1) * $size < $count) {
- $next = "<a href='?page=" . ($page+1) . "'>" . __('Next page', 'wpmp') . "</a>";
- }
- if ($next || $previous) {
- print "<p>$previous";
- if ($next && $previous) {
- print " | ";
- }
- print "$next</p>";
- }
- print "<p>" . __("NB: Some complex options cannot be edited in this mobile interface.", 'wpmp') . "</p>";
-
- }
- function wpmp_msma_option_edit_form($id) {
- global $wpdb;
- $option = $wpdb->get_results("SELECT * FROM $wpdb->options " . wpmp_msma_options_filter() . " and option_id=$id");
- if(sizeof($option)==0) {
- print "<p>" . __("That option is not editable.", 'wpmp') . "</p>";
- return wpmp_msma_options_list();
- }
- $option = $option[0];
- $value = wpmp_msma_option_value($option->option_name, $option->option_value, $editable);
- if(!$editable) {
- print "<p>" . __("That option is not editable.", 'wpmp') . "</p>";
- return wpmp_msma_options_list();
- }
- print '<form name="post" action="' . $_SERVER['REQUEST_URI'] . '" method="post" id="post">';
- print '<input type="hidden" name="option_name" value="' . attribute_escape($option->option_name) . '" />';
-
- print '<p><label for="title">' . wpmp_msma_option_name($option->option_name) . ':</label><br />';
- print '<input type="text" name="option_value" value="' . attribute_escape($value) . '" id="title" /></p>';
-
- print '<input class="button" name="submit" type="submit" id="submit" value="' . __('Apply', 'wpmp') . '" />';
- if($value==='0' or $value==='1') {
- print '<p>' . __('For options that are usually a checkbox, use 1 for \'on\', and 0 for \'off\'', 'wpmp') . '</p>';
- }
- print '</form>'; }
-
- function wpmp_msma_option_update($option) {
- if(isset($option['option_name'])) {
- update_option($option['option_name'], stripslashes($option['option_value']));
- }
- }
-
- function wpmp_msma_option_name($name) {
- $name = str_replace("_", " ", $name);
- $name = strtoupper($name[0]) . substr($name, 1);
- if(substr($name, 0, 5)=='Wpmp ') {
- $name = "Mobile " . substr($name, 5);
- }
- $name = str_replace("Mobile deviceatlas", "DeviceAtlas", $name);
- $name = str_replace("Siteurl", "Site url", $name);
- $name = str_replace("Blogname", "Blog name", $name);
- $name = str_replace("Blogdescription", "Blog description", $name);
- $name = str_replace("Gzipcompression", "GZIP compression", $name);
- $name = str_replace("linksupdate", "links update", $name);
- $name = str_replace("yearmonth", "year/month", $name);
- $name = str_replace(" url", " URL", $name);
- $name = str_replace(" uri", " URI", $name);
- $name = str_replace("Gmt", "GMT", $name);
- $name = str_replace("Html", "HTML", $name);
- $name = str_replace("rss", "RSS", $name);
- return $name;
- }
- function wpmp_msma_option_value($name, $value, &$editable) {
- $value = maybe_unserialize($value);
- if (gettype($value)=='object') { //is_object has incomplete class bug
- $value = "(locked)";
- } elseif (is_array($value)) {
- $value = "(locked)";
- } else {
- $editable = true;
- }
- return print_r($value, 1);
- }
-
- function wpmp_msma_get_pagenum_link($link) {
- return str_replace('&amp;post=', '&amp;_post=',
- str_replace('&post=', '&_post=', $link)); // remove post-post-POST evidence
- }
-
- function wpmp_msma_post_status($status) {
- switch($status) {
- case 'publish':
- case 'private':
- return __('Published', 'wpmp');
- case 'future':
- return __('Scheduled', 'wpmp');
- case 'pending':
- return __('Pending Review', 'wpmp');
- default:
- return __('Unpublished', 'wpmp');
- }
- }
-
-
- function wpmp_msma_check_referer() {
- $base = get_option('home');
- $admin = "$base/wp-admin";
- $referer = $_SERVER['HTTP_REFERER'];
- if (substr($referer, 0, strlen($admin)) != $admin) {
- print __("You may only originate this action from the admin pages", 'wpmp');
- return false;
- }
- return true;
- }
-
-
-?>
diff --git a/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/mobile_interstitial.php b/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/mobile_interstitial.php
deleted file mode 100755
index 9cff7489..00000000
--- a/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/mobile_interstitial.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-
-/*
-$Id: mobile_interstitial.php 195195 2010-01-19 04:11:37Z jamesgpearce $
-
-$URL: http://plugins.svn.wordpress.org/wordpress-mobile-pack/trunk/plugins/wpmp_switcher/pages/mobile_interstitial.php $
-
-Copyright (c) 2009 James Pearce & friends, portions mTLD Top Level Domain Limited, ribot, Forum Nokia
-
-Online support: http://wordpress.org/extend/plugins/wordpress-mobile-pack/
-
-This file is part of the WordPress Mobile Pack.
-
-The WordPress Mobile Pack is Licensed under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with the
-License.
-
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software distributed
-under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
-CONDITIONS OF ANY KIND, either express or implied. See the License for the
-specific language governing permissions and limitations under the License.
-*/
-
- include_once('mobile.php');
- wpmp_ms_mobile_top(__("Select site", 'wpmp'));
-?>
-
-<p><?php _e("You've requested the desktop site, but you appear to have a mobile browser.", 'wpmp'); ?></p>
-<p><?php print wpmp_switcher_link('mobile', __("Revert to the mobile site", 'wpmp')); ?></p>
-<p><?php print wpmp_switcher_link('desktop', __("Continue to our desktop site", 'wpmp')); ?></p>
-
-<?php
- wpmp_ms_mobile_bottom();
-?>
diff --git a/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/mobile_login.php b/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/mobile_login.php
deleted file mode 100755
index 1b81af11..00000000
--- a/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/pages/mobile_login.php
+++ /dev/null
@@ -1,163 +0,0 @@
-<?php
-
-/*
-$Id: mobile_login.php 195195 2010-01-19 04:11:37Z jamesgpearce $
-
-$URL: http://plugins.svn.wordpress.org/wordpress-mobile-pack/trunk/plugins/wpmp_switcher/pages/mobile_login.php $
-
-Copyright (c) 2009 James Pearce & friends, portions mTLD Top Level Domain Limited, ribot, Forum Nokia
-
-Online support: http://wordpress.org/extend/plugins/wordpress-mobile-pack/
-
-This file is part of the WordPress Mobile Pack.
-
-The WordPress Mobile Pack is Licensed under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with the
-License.
-
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software distributed
-under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
-CONDITIONS OF ANY KIND, either express or implied. See the License for the
-specific language governing permissions and limitations under the License.
-*/
-
-function wpmp_switcher_login_header($title, $message = '', $wp_error = '') {
- global $error;
-
- if ( empty($wp_error) )
- $wp_error = new WP_Error();
-
- include_once('mobile.php');
- wpmp_ms_mobile_top($title);
-
- if ( !empty( $message ) ) echo apply_filters('login_message', $message) . "\n";
-
- if ( !empty( $error ) ) {
- $wp_error->add('error', $error);
- unset($error);
- }
-
- if ( $wp_error->get_error_code() ) {
- $errors = '';
- $messages = '';
- foreach ( $wp_error->get_error_codes() as $code ) {
- $severity = $wp_error->get_error_data($code);
- foreach ( $wp_error->get_error_messages($code) as $error ) {
- if ( 'message' == $severity )
- $messages .= ' ' . $error . "<br />\n";
- else
- $errors .= ' ' . $error . "<br />\n";
- }
- }
- if ( !empty($errors) )
- echo '<div id="login_error">' . apply_filters('login_errors', $errors) . "</div>\n";
- if ( !empty($messages) )
- echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
- }
-}
-
-$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
-$errors = new WP_Error();
-
-if ( isset($_GET['key']) )
- $action = 'resetpass';
-
-nocache_headers();
-
-header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
-
-if ( defined('RELOCATE') ) { // Move flag is set
- if ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) )
- $_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] );
-
- $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
- if ( dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != get_option('siteurl') )
- update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) );
-}
-
-setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
-if ( SITECOOKIEPATH != COOKIEPATH )
- setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
-
-$http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
-switch ($action) {
-
-case 'logout' :
-
- wp_logout();
-
- $redirect_to = 'wp-login.php?loggedout=true';
- if ( isset( $_REQUEST['redirect_to'] ) )
- $redirect_to = $_REQUEST['redirect_to'];
-
- wp_safe_redirect($redirect_to);
- exit();
-
-break;
-
-case 'login' :
-default:
- if ( isset( $_REQUEST['redirect_to'] ) )
- $redirect_to = $_REQUEST['redirect_to'];
- else
- $redirect_to = 'wp-admin/';
-
- $user = wp_signon();
-
- if ( !is_wp_error($user) ) {
- if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' ) )
- $redirect_to = get_option('siteurl') . '/wp-admin/profile.php';
- wp_safe_redirect($redirect_to);
- exit();
- }
-
- $errors = $user;
- if ( !empty($_GET['loggedout']) )
- $errors = new WP_Error();
-
- if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) )
- $errors->add('test_cookie', sprintf(__("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a%s>enable cookies</a> to use WordPress.", 'wpmp'), " href='http://www.google.com/cookies.html'"));
-
- if ( isset($_GET['loggedout']) && TRUE == $_GET['loggedout'] ) $errors->add('loggedout', __('You are now logged out.', 'wpmp'), 'message');
- elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] ) $errors->add('registerdiabled', __('User registration is currently not allowed.', 'wpmp'));
- elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] ) $errors->add('confirm', __('Check your e-mail for the confirmation link.', 'wpmp'), 'message');
- elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] ) $errors->add('newpass', __('Check your e-mail for your new password.', 'wpmp'), 'message');
- elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) $errors->add('registered', __('Registration complete. Please check your e-mail.', 'wpmp'), 'message');
-
- wpmp_switcher_login_header(__('Login', 'wpmp'), '', $errors);
-?>
-
-<form name="loginform" id="loginform" action="wp-login.php" method="post">
-<?php if ( !isset($_GET['checkemail']) || !in_array( $_GET['checkemail'], array('confirm', 'newpass') ) ) : ?>
- <p>
- <label><?php _e('Username', 'wpmp') ?><br />
- <input type="text" name="log" id="user_login" class="input" value="<?php echo attribute_escape(stripslashes(@$user_login)); ?>" size="20" tabindex="10" /></label>
- </p>
- <p>
- <label><?php _e('Password', 'wpmp') ?><br />
- <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="20" /></label>
- </p>
-<?php do_action('login_form'); ?>
- <p class="forgetmenot"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90" /> <?php _e('Remember Me', 'wpmp'); ?></label></p>
- <p class="submit">
- <input type="submit" name="wp-submit" id="submit" value="<?php _e('Log In', 'wpmp'); ?>" tabindex="100" />
- <input type="hidden" name="redirect_to" value="<?php echo attribute_escape($redirect_to); ?>" />
- <input type="hidden" name="testcookie" value="1" />
- </p>
-<?php else : ?>
- <p>&nbsp;</p>
-<?php endif; ?>
-</form>
-
-<p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?', 'wpmp') ?>"><?php print '&laquo; ' . sprintf(__('Back to %s', 'wpmp'), get_bloginfo('title', 'display' )); ?></a></p>
-
-<?php
- wpmp_ms_mobile_bottom();
- break;
-}
-
-?>
diff --git a/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/wpmp_switcher.php b/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/wpmp_switcher.php
deleted file mode 100755
index 72f756f5..00000000
--- a/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/wpmp_switcher.php
+++ /dev/null
@@ -1,708 +0,0 @@
-<?php
-
-/*
-$Id: wpmp_switcher.php 567923 2012-07-05 18:10:01Z jamesgpearce $
-
-$URL: http://plugins.svn.wordpress.org/wordpress-mobile-pack/trunk/plugins/wpmp_switcher/wpmp_switcher.php $
-
-Copyright (c) 2009 James Pearce & friends, portions mTLD Top Level Domain Limited, ribot, Forum Nokia
-
-Online support: http://wordpress.org/extend/plugins/wordpress-mobile-pack/
-
-This file is part of the WordPress Mobile Pack.
-
-The WordPress Mobile Pack is Licensed under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with the
-License.
-
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software distributed
-under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
-CONDITIONS OF ANY KIND, either express or implied. See the License for the
-specific language governing permissions and limitations under the License.
-*/
-
-/*
-Plugin Name: Mobile Switcher
-Plugin URI: http://wordpress.org/extend/plugins/wordpress-mobile-pack/
-Description: Detects a mobile user accessing your site and switches theme accordingly. This plugin is tested with WordPress 2.5, 2.6, 2.7 and 2.8.
-Version: 1.2.5
-Author: James Pearce & friends
-Author URI: http://www.assembla.com/spaces/wordpress-mobile-pack
-*/
-
-define("WPMP_SWITCHER_COOKIE_VAR", "wpmp_switcher");
-define("WPMP_SWITCHER_CGI_VAR", "wpmp_switcher");
-define("WPMP_SWITCHER_NO_SWITCH", 0);
-define("WPMP_SWITCHER_DESKTOP_PAGE", 1);
-define("WPMP_SWITCHER_MOBILE_PAGE", 2);
-define("WPMP_SWITCHER_REDIRECT_TO_MOBILE", 3);
-define("WPMP_SWITCHER_REDIRECT_TO_DESKTOP", 4);
-define("WPMP_SWITCHER_MOBILE_INTERSTITIAL", 5);
-define("WPMP_SWITCHER_DESKTOP_INTERSTITIAL", 6);
-
-if (file_exists($theme_functions_persist = str_replace('/', DIRECTORY_SEPARATOR, get_theme_root()) . DIRECTORY_SEPARATOR . 'mobile_pack_base' . DIRECTORY_SEPARATOR . 'functions_persist.php')) {
- include_once($theme_functions_persist);
-}
-
-add_action('init', 'wpmp_switcher_init');
-add_action('admin_menu', 'wpmp_switcher_admin_menu');
-add_action('wp_footer', 'wpmp_switcher_wp_footer');
-add_filter('stylesheet', 'wpmp_switcher_stylesheet');
-add_filter('template', 'wpmp_switcher_template');
-add_filter('option_home', 'wpmp_switcher_option_home_siteurl');
-add_filter('option_siteurl', 'wpmp_switcher_option_home_siteurl');
-
-if (function_exists('add_cacheaction')) {
- // WP Super Cache integration
- if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
- wp_cache_debug("Adding hook for wpmp mobile detection", 5);
- }
- add_cacheaction('wp_cache_get_cookies_values', 'wpmp_switcher_wp_cache_check_mobile');
-}
-
-function wpmp_switcher_init() {
- wp_register_sidebar_widget('wpmp_switcher_widget_link', __('Mobile Switcher Link', 'wpmp'), 'wpmp_switcher_widget_link',
- array('classname' => 'wpmp_switcher_widget_link', 'description' => __( "A link that allows users to toggle between desktop and mobile sites (when a switcher mode is enabled)", 'wpmp'))
- );
- switch($switcher_outcome = wpmp_switcher_outcome()) {
- case WPMP_SWITCHER_NO_SWITCH:
- break;
- case WPMP_SWITCHER_DESKTOP_PAGE:
- wpmp_switcher_hit('desktop');
- wpmp_switcher_set_cookie('desktop');
- break;
- case WPMP_SWITCHER_MOBILE_PAGE:
- wpmp_switcher_hit('mobile');
- wpmp_switcher_set_cookie('mobile');
- if (strpos(strtolower($_SERVER['REQUEST_URI']), '/wp-login.php')!==false) {
- wpmp_switcher_mobile_login();
- }
- if (is_admin() || strtolower(substr($_SERVER['REQUEST_URI'], -9))=='/wp-admin') {
- wpmp_switcher_mobile_admin();
- }
- break;
- case WPMP_SWITCHER_DESKTOP_INTERSTITIAL:
- wpmp_switcher_desktop_interstitial();
- break;
- case WPMP_SWITCHER_MOBILE_INTERSTITIAL:
- wpmp_switcher_mobile_interstitial();
- break;
- case WPMP_SWITCHER_REDIRECT_TO_MOBILE:
- $target_url = "http://" . wpmp_switcher_domains('mobile', true) . wpmp_switcher_current_path_plus_cgi();
- header("Location: $target_url");
- exit;
- case WPMP_SWITCHER_REDIRECT_TO_DESKTOP:
- $target_url = "http://" . wpmp_switcher_domains('desktop', true) . wpmp_switcher_current_path_plus_cgi();
- header("Location: $target_url");
- exit;
- }
- if($switcher_outcome!=WPMP_SWITCHER_NO_SWITCH) {
- remove_filter('template_redirect', 'redirect_canonical');
- }
-}
-function wpmp_switcher_widget_link($args) {
- extract($args);
- if(get_option('wpmp_switcher_mode')=='none') {
- return;
- }
- print $before_widget . $before_title . __('Switch site', 'wpmp') . $after_title;
- switch (wpmp_switcher_outcome()) {
- case WPMP_SWITCHER_MOBILE_PAGE:
- print "<ul><li>" . wpmp_switcher_link('desktop', __('Switch to our desktop site', 'wpmp')) . "</li></ul>";
- break;
- case WPMP_SWITCHER_DESKTOP_PAGE:
- print "<ul><li>" . wpmp_switcher_link('mobile', __('Switch to our mobile site', 'wpmp')) . "</li></ul>";
- break;
- }
- print $after_widget;
-}
-function wpmp_switcher_activate() {
- $default_desktop_domain=wpmp_switcher_trim_domain(get_option('home'));
- $default_desktop_domains = array();
- $default_mobile_domains = array();
-
- $default_desktop_domains[] = $default_desktop_domain;
- if(($tld=substr($default_desktop_domain, 0, -4))==".com" || $tld==".org" || $tld==".net") {
- $default_mobile_domains[] = substr($default_desktop_domain, 0, -4) . ".mobi";
- }
- if(substr($default_desktop_domain, 0, 4)=="www.") {
- $default_desktop_domains[] = substr($default_desktop_domain, 4);
- $default_mobile_domains[] = "m." . substr($default_desktop_domain, 4);
- } else {
- $default_mobile_domains[] = "m." . $default_desktop_domain;
- }
- $default_theme = '';
- foreach(get_themes() as $name=>$theme) {
- if ($default_theme=='') {
- $default_theme = $theme;
- }
- if(strpos(strtolower($name), 'mobile')!==false) {
- $default_theme = $theme;
- break;
- }
- }
- foreach(array(
- 'wpmp_switcher_mode'=>'browser',
- 'wpmp_switcher_detection'=>'simple',
- 'wpmp_switcher_desktop_domains'=>implode(", ", $default_desktop_domains),
- 'wpmp_switcher_mobile_domains'=>implode(", ", $default_mobile_domains),
- 'wpmp_switcher_mobile_theme'=>$default_theme['Name'],
- 'wpmp_switcher_mobile_theme_stylesheet'=>$default_theme['Stylesheet'],
- 'wpmp_switcher_mobile_theme_template'=>$default_theme['Template'],
- 'wpmp_switcher_footer_links'=>'true',
- 'wpmp_switcher_hits_desktop'=>'0',
- 'wpmp_switcher_hits_mobile'=>'0',
- 'wpmp_switcher_hits_start'=>microtime(true),
- ) as $name=>$value) {
- if (get_option($name)=='') {
- update_option($name, $value);
- }
- }
- //fixing incorrect settings from WP1.1.2 & earlier
- foreach(array('desktop', 'mobile') as $type) {
- $domains = strtolower(get_option('wpmp_switcher_' . $type . '_domains'));
- $domains = explode(",", $domains);
- $trimmed_domains = array();
- foreach($domains as $domain) {
- $trimmed_domains[] = wpmp_switcher_trim_domain($domain);
- }
- update_option('wpmp_switcher_' . $type . '_domains', join(', ', $trimmed_domains));
- }
-}
-
-function wpmp_switcher_trim_domain($domain) {
- $trimmed_domain = trim(strtolower($domain));
- if(substr($trimmed_domain, 0, 7) == 'http://') {
- $trimmed_domain = substr($trimmed_domain, 7);
- } elseif(substr($trimmed_domain, 0, 8) == 'https://') {
- $trimmed_domain = substr($trimmed_domain, 8);
- }
- $trimmed_domain = explode("/", "$trimmed_domain/");
- $trimmed_domain = $trimmed_domain[0];
- return $trimmed_domain;
-}
-
-function wpmp_switcher_deactivate() {
-}
-
-
-function wpmp_switcher_admin_menu() {
- add_theme_page(__('Mobile Switcher', 'wpmp'), __('Mobile Switcher', 'wpmp'), 3, 'wpmp_switcher_admin', 'wpmp_switcher_admin');
-}
-function wpmp_switcher_admin() {
- if(sizeof($_POST)>0) {
- print '<div id="message" class="updated fade"><p><strong>' . wpmp_switcher_options_write() . '</strong></p></div>';
- }
- include_once('wpmp_switcher_admin.php');
-}
-
-function wpmp_switcher_wp_footer($force=false) {
- if(!$force && (get_option('wpmp_switcher_mode')=='none' || get_option('wpmp_switcher_footer_links')!='true')) {
- return;
- }
- switch (wpmp_switcher_outcome()) {
- case WPMP_SWITCHER_MOBILE_PAGE:
- print "<p>" . wpmp_switcher_link('desktop', __('Switch to our desktop site', 'wpmp')) . "</p>";
- break;
- case WPMP_SWITCHER_DESKTOP_PAGE:
- print "<p>" . wpmp_switcher_link('mobile', __('Switch to our mobile site', 'wpmp')) . "</p>";
- break;
- }
-}
-function wpmp_switcher_stylesheet($stylesheet) {
- switch (wpmp_switcher_outcome()) {
- case WPMP_SWITCHER_MOBILE_PAGE:
- case WPMP_SWITCHER_MOBILE_INTERSTITIAL:
- if($mobile_stylesheet = get_option('wpmp_switcher_mobile_theme_stylesheet')) {
- return $mobile_stylesheet;
- }
- }
- return $stylesheet;
-}
-
-function wpmp_switcher_template($template) {
- switch (wpmp_switcher_outcome()) {
- case WPMP_SWITCHER_MOBILE_PAGE:
- case WPMP_SWITCHER_MOBILE_INTERSTITIAL:
- if($mobile_template = get_option('wpmp_switcher_mobile_theme_template')) {
- return $mobile_template;
- }
- }
- return $template;
-}
-
-function wpmp_switcher_option_home_siteurl($value) {
- switch (wpmp_switcher_outcome()) {
- case WPMP_SWITCHER_MOBILE_PAGE:
- case WPMP_SWITCHER_MOBILE_INTERSTITIAL:
- if(($scheme = substr($value, 0, 7))=="http://" || ($scheme = substr($value, 0, 8))=="https://") {
- $path = "";
- if(sizeof($parts=(explode('/', "$value", 4)))==4) {
- $path = '/' . array_pop($parts);
- }
- if (strpos(get_option('wpmp_switcher_mode'), 'domain')!==false){
- $domain = wpmp_switcher_domains('mobile', true);
- } else {
- $domain = $_SERVER['HTTP_HOST'];
- }
- return $scheme . $domain . $path;
- }
- }
- return $value;
-}
-
-function wpmp_switcher_hit($type='desktop') {
- $current = get_option("wpmp_switcher_hits_$type");
- if(!is_numeric($current)) {
- wpmp_switcher_hit_reset();
- $current = '0';
- }
- if(function_exists('bcadd')) {
- $next = bcadd($current, '1');
- } else {
- $next = $current + 1;
- }
- update_option("wpmp_switcher_hits_$type", $next);
-}
-function wpmp_switcher_hit_reset() {
- update_option("wpmp_switcher_hits_desktop", 0);
- update_option("wpmp_switcher_hits_mobile", 0);
- update_option("wpmp_switcher_hits_start", microtime(true));
-}
-function wpmp_switcher_hit_data() {
- $desktop = get_option("wpmp_switcher_hits_desktop");
- $mobile = get_option("wpmp_switcher_hits_mobile");
- $duration = floor(microtime(true) - get_option("wpmp_switcher_hits_start"))+1;
- return "1.$desktop.$mobile.$duration";
-}
-function wpmp_switcher_hit_summary() {
- $desktop = get_option("wpmp_switcher_hits_desktop");
- $desktop_text = sprintf(__ngettext('one desktop hit', '%d desktop hits', wpmp_switcher_humanize_number($desktop), 'wpmp'), $desktop);
- $mobile = get_option("wpmp_switcher_hits_mobile");
- $mobile_text = sprintf(__ngettext('one mobile hit', '%d mobile hits', wpmp_switcher_humanize_number($mobile), 'wpmp'), $mobile);
- $duration = wpmp_switcher_humanize_delta(microtime(true) - get_option("wpmp_switcher_hits_start"));
- $percentage = round(100 * $mobile / ($desktop + $mobile), 1);
- return "<strong>" . sprintf(__('%d%% of your traffic is currently from mobile users.', 'wpmp'), $percentage) . "</strong><br />" .
- sprintf(__('You\'ve had %1$s and %2$s in the last %3$s.', 'wpmp'), $desktop_text, $mobile_text, $duration);
-}
-
-function wpmp_switcher_humanize_number($number) {
- $number = $number * 1;
- $suffix = '';
- if ($number>(1000000000000)){
- $suffix=' ' . __('trillion', 'wpmp');
- $number = $number / (1000000000000);
- } elseif ($number>(1000000000)){
- $suffix=' ' . __('billion', 'wpmp');
- $number = $number / (1000000000);
- } elseif ($number>(1000000)){
- $suffix=' ' . __('million', 'wpmp');
- $number = $number / (1000000);
- }
- return round($number, 1) . $suffix;
-}
-
-function wpmp_switcher_humanize_delta($seconds) {
- $seconds = $seconds * 1;
- $suffix = ' ' . __('seconds', 'wpmp');
- if (($seconds)>60*60*24*365*2){
- $suffix=' ' . __('years', 'wpmp');
- $seconds = round($seconds / (60*60*24*365), 1);
- } elseif ($seconds>60*60*24*30*2){
- $suffix=' ' . __('months', 'wpmp');
- $seconds = round($seconds / (60*60*24*30), 0);
- } elseif ($seconds>60*60*24*7*2){
- $suffix=' ' . __('weeks', 'wpmp');
- $seconds = round($seconds / (60*60*24*7), 1);
- } elseif ($seconds>60*60*24*2){
- $suffix=' ' . __('days', 'wpmp');
- $seconds = round($seconds / (60*60*24), 1);
- } elseif ($seconds>60*60*2){
- $suffix=' ' . __('hours', 'wpmp');
- $seconds = round($seconds / (60*60), 1);
- } elseif ($seconds>60){
- $suffix=' ' . __('minutes', 'wpmp');
- $seconds = round($seconds / 60, 1);
- } else {
- $seconds = round($seconds, 1);
- }
- return $seconds . $suffix;
-}
-
-function wpmp_switcher_outcome() {
- global $wpmp_switcher_outcome;
- if(!isset($wpmp_switcher_outcome)) {
- $switcher_mode = get_option('wpmp_switcher_mode');
- if (wpmp_switcher_domains('desktop', true) == wpmp_switcher_domains('mobile', true)) {
- $switcher_mode = "browser";
- }
- $desktop_domain = wpmp_switcher_is_domain('desktop');
- $mobile_domain = wpmp_switcher_is_domain('mobile');
- if($desktop_domain==$mobile_domain) {
- $desktop_domain=!$desktop_domain;
- }
- $desktop_browser = wpmp_switcher_is_browser('desktop');
- $mobile_browser = wpmp_switcher_is_browser('mobile');
- if($desktop_browser==$mobile_browser) {
- $desktop_browser=!$desktop_browser;
- }
- $desktop_cookie = wpmp_switcher_is_cookie('desktop');
- $mobile_cookie = wpmp_switcher_is_cookie('mobile');
- $cgi = wpmp_switcher_is_cgi_parameter_present();
- $wpmp_switcher_outcome = wpmp_switcher_outcome_process($switcher_mode, $desktop_domain, $mobile_domain, $desktop_browser, $mobile_browser, $desktop_cookie, $mobile_cookie, $cgi);
- }
- return $wpmp_switcher_outcome;
-}
-function wpmp_switcher_outcome_process($switcher_mode, $desktop_domain, $mobile_domain, $desktop_browser, $mobile_browser, $desktop_cookie, $mobile_cookie, $cgi) {
- switch ($switcher_mode) {
- case 'browser':
- if ($cgi=='desktop' || $desktop_cookie) {
- return WPMP_SWITCHER_DESKTOP_PAGE;
- } elseif ($cgi=='mobile' || $mobile_cookie) {
- return WPMP_SWITCHER_MOBILE_PAGE;
- }
- return $mobile_browser ? WPMP_SWITCHER_MOBILE_PAGE : WPMP_SWITCHER_DESKTOP_PAGE;
- case 'domain':
- return $mobile_domain ? WPMP_SWITCHER_MOBILE_PAGE : WPMP_SWITCHER_DESKTOP_PAGE;
- case 'browserdomain':
- if ($desktop_domain) {
- if ($desktop_browser) {
- if ($mobile_cookie && !$cgi) {
- return WPMP_SWITCHER_REDIRECT_TO_MOBILE;
- } else {
- return WPMP_SWITCHER_DESKTOP_PAGE;
- }
- } else {
- if ($cgi || $desktop_cookie) {
- return WPMP_SWITCHER_DESKTOP_PAGE;
- } else {
- if ($mobile_cookie) {
- return WPMP_SWITCHER_REDIRECT_TO_MOBILE;
- } else {
- return WPMP_SWITCHER_MOBILE_INTERSTITIAL;
- }
- }
- }
- } else {
- if ($mobile_browser) {
- if ($desktop_cookie && !$cgi) {
- return WPMP_SWITCHER_REDIRECT_TO_DESKTOP;
- } else {
- return WPMP_SWITCHER_MOBILE_PAGE;
- }
- } else {
- if ($cgi || $mobile_cookie) {
- return WPMP_SWITCHER_MOBILE_PAGE;
- } else {
- if ($desktop_cookie) {
- return WPMP_SWITCHER_REDIRECT_TO_DESKTOP;
- } else {
- return WPMP_SWITCHER_DESKTOP_INTERSTITIAL;
- }
- }
- }
- }
- default:
- return WPMP_SWITCHER_NO_SWITCH;
- }
-}
-
-function wpmp_switcher_domains($type='desktop', $first_only=false) {
- if(get_option('wpmp_switcher_mode')=='browser'){
- $type = 'desktop';
- }
- $domains = strtolower(get_option('wpmp_switcher_' . $type . '_domains'));
- $domains = explode(",", $domains);
- $trimmed_domains = array();
- foreach($domains as $domain) {
- if($first_only) {
- return wpmp_switcher_trim_domain($domain);
- }
- $trimmed_domains[] = wpmp_switcher_trim_domain($domain);
- }
- return $trimmed_domains;
-}
-function wpmp_switcher_is_domain($type='desktop') {
- $this_domain = strtolower($_SERVER['HTTP_HOST']);
- $domains = wpmp_switcher_domains($type);
- foreach($domains as $domain) {
- if (substr($this_domain, -strlen($domain)) == $domain) {
- return true;
- }
- }
- return false;
-}
-
-function wpmp_switcher_is_browser($type='desktop') {
- return call_user_func('wpmp_switcher_is_' . $type . '_browser');
-}
-function wpmp_switcher_is_desktop_browser() {
- return !wpmp_switcher_is_mobile_browser();
-}
-function wpmp_switcher_is_mobile_browser() {
- global $wpmp_switcher_is_mobile_browser;
- if (!isset($wpmp_switcher_is_mobile_browser)) {
- if(get_option('wpmp_switcher_detection')=='deviceatlas' &&
- function_exists('wpmp_deviceatlas_enabled') &&
- wpmp_deviceatlas_enabled()
- ) {
- $wpmp_switcher_is_mobile_browser = (wpmp_deviceatlas_property("mobileDevice")==1);
- } else {
- include_once('lite_detection.php');
- $wpmp_switcher_is_mobile_browser = lite_detection();
- }
- }
- return $wpmp_switcher_is_mobile_browser;
-}
-function wpmp_switcher_is_cookie($type='desktop') {
- return (isset($_COOKIE[WPMP_SWITCHER_COOKIE_VAR]) && $_COOKIE[WPMP_SWITCHER_COOKIE_VAR] == $type);
-}
-function wpmp_switcher_is_cgi_parameter_present() {
- if(isset($_GET[WPMP_SWITCHER_CGI_VAR])) {
- return $_GET[WPMP_SWITCHER_CGI_VAR];
- }
- return false;
-}
-
-
-
-function wpmp_switcher_link($type, $label) {
- $cookie = WPMP_SWITCHER_COOKIE_VAR . "=$type;path=/;expires=Tue, 01-01-2030 00:00:00 GMT";
- $target_url = esc_url("http://" . wpmp_switcher_domains($type, true) . wpmp_switcher_current_path_plus_cgi('', $type));
- if ($target_url) {
- return "<a onclick='document.cookie=\"$cookie\";' href='$target_url'>$label</a>";
- }
-}
-
-function wpmp_switcher_current_path_plus_cgi($path='', $type='true') {
- if($path) {
- if(strpos(strtolower($path), 'http://')===0 || strpos(strtolower($path), 'https://')===0) {
- $path = explode("/", $path, 4);
- $path = '/' . array_pop($path);
- }
- } else {
- $path = $_SERVER['REQUEST_URI'];
- }
- $path = htmlentities($path);
- foreach(array("true", "desktop", "mobile") as $t) {
- $path = str_replace(WPMP_SWITCHER_CGI_VAR . "=$t&amp;", "", $path);
- $path = str_replace(WPMP_SWITCHER_CGI_VAR . "=$t&", "", $path);
- $path = str_replace("&amp;" . WPMP_SWITCHER_CGI_VAR . "=$t", "", $path);
- $path = str_replace("&" . WPMP_SWITCHER_CGI_VAR . "=$t", "", $path);
- $path = str_replace(WPMP_SWITCHER_CGI_VAR . "=$t", "", $path);
- } //surely there's a better way
- if (strpos($path, "?") === false) {
- return $path . "?" . WPMP_SWITCHER_CGI_VAR . "=$type";
- } elseif (substr($path, -1) == "?") {
- return $path . WPMP_SWITCHER_CGI_VAR . "=$type";
- }
- return $path . "&amp;" . WPMP_SWITCHER_CGI_VAR . "=$type";
-}
-function wpmp_switcher_set_cookie($type) {
- setcookie(WPMP_SWITCHER_COOKIE_VAR, $type, time()+60*60*24*365, '/');
-}
-function wpmp_switcher_interstitial($type) {
- return call_user_func('wpmp_switcher_' . $type . '_interstitial');
-}
-function wpmp_switcher_desktop_interstitial() {
- add_action('template_redirect', 'wpmp_switcher_template_redirect_desktop_insterstitial');
-}
-function wpmp_switcher_template_redirect_desktop_insterstitial() {
- include_once('pages/desktop_interstitial.php');
- exit;
-}
-function wpmp_switcher_mobile_interstitial() {
- add_action('template_redirect', 'wpmp_switcher_template_redirect_mobile_insterstitial');
-}
-function wpmp_switcher_template_redirect_mobile_insterstitial() {
- include_once('pages/mobile_interstitial.php');
- exit;
-}
-function wpmp_switcher_mobile_login() {
- include_once('pages/mobile_login.php');
- exit;
-}
-function wpmp_switcher_mobile_admin() {
- include_once('pages/mobile_admin.php');
- exit;
-}
-function wpmp_switcher_options_write() {
- $message = __('Settings saved.', 'wpmp');
- foreach(array(
- 'wpmp_switcher_mode'=>false,
- 'wpmp_switcher_detection'=>false,
- 'wpmp_switcher_desktop_domains'=>false,
- 'wpmp_switcher_mobile_domains'=>false,
- 'wpmp_switcher_mobile_theme'=>false,
- 'wpmp_switcher_footer_links'=>true,
- ) as $option=>$checkbox) {
- if(isset($_POST[$option])){
- $value = $_POST[$option];
- if(!is_array($value)) {
- $value = trim($value);
- }
- $value = stripslashes_deep($value);
- update_option($option, $value);
- } elseif ($checkbox) {
- update_option($option, 'false');
- }
- }
- $option = 'wpmp_switcher_mobile_theme';
- $theme_data = get_theme(get_option($option));
- if(isset($theme_data['Stylesheet']) && isset($theme_data['Template'])) {
- update_option($option . "_stylesheet", $theme_data['Stylesheet']);
- update_option($option . "_template", $theme_data['Template']);
- }
- if (strpos(get_option('wpmp_switcher_mode'), 'none')===false) {
- foreach(array('wpmp_switcher_mobile_domains', 'wpmp_switcher_desktop_domains') as $option) {
- $trimmed_domains=array();
- foreach(split(",", get_option($option)) as $domain) {
- $domain = trim($domain);
- $trimmed_domain = wpmp_switcher_trim_domain($domain);
- if ($trimmed_domain!=$domain) {
- $message = __('You must provide clean domain names without any leading or trailing syntax. We fixed them for you.', 'wpmp');
- }
- $trimmed_domains[] = $trimmed_domain;
- }
- update_option($option, join(', ', $trimmed_domains));
- }
- }
-
- if (get_option('wpmp_switcher_desktop_domains')=='' || get_option('wpmp_switcher_mobile_domains')=='') {
- switch(get_option('wpmp_switcher_mode')) {
- case 'domain':
- update_option('wpmp_switcher_mode', 'none');
- $message = __('You must provide both desktop and mobile domains. Switching has been disabled.', 'wpmp');
- break;
- case 'browserdomain':
- update_option('wpmp_switcher_mode', 'browser');
- $message = __('You must provide both desktop and mobile domains. Switching has been changed to browser detection only.', 'wpmp');
- break;
- }
- }
- return $message;
-}
-
-function wpmp_switcher_option($option, $onchange='') {
- switch ($option) {
- case 'wpmp_switcher_mode':
- return wpmp_switcher_option_dropdown(
- $option,
- array(
- 'none'=>__('Disabled', 'wpmp'),
- 'browser'=>__('Browser detection', 'wpmp'),
- 'domain'=>__('Domain mapping', 'wpmp'),
- 'browserdomain'=>__('BOTH: browser detection and domain mapping', 'wpmp'),
- ),
- $onchange
- );
-
- case 'wpmp_switcher_mobile_theme':
- return wpmp_switcher_option_themes($option);
-
- case 'wpmp_switcher_detection':
- $options = array('simple'=>__('User-agent prefixes', 'wpmp'));
- if(function_exists('wpmp_deviceatlas_enabled') && wpmp_deviceatlas_enabled()) {
- $options['simple']=__('SIMPLE: User-agent prefixes', 'wpmp');
- $options['deviceatlas']=__('ADVANCED: DeviceAtlas recognition', 'wpmp');
- }
- return wpmp_switcher_option_dropdown(
- $option, $options, $onchange
- );
- case 'wpmp_switcher_desktop_domains':
- case 'wpmp_switcher_mobile_domains':
- return wpmp_switcher_option_text(
- $option,
- $onchange
- );
-
- case 'wpmp_switcher_footer_links':
- return wpmp_switcher_option_checkbox(
- $option,
- $onchange
- );
- }
-}
-
-
-function wpmp_switcher_option_dropdown($option, $options, $onchange='') {
- if ($onchange!='') {
- $onchange = 'onchange="' . attribute_escape($onchange) . '" onkeyup="' . attribute_escape($onchange) . '"';
- }
- $dropdown = "<select id='$option' name='$option' $onchange>";
- foreach($options as $value=>$description) {
- if(get_option($option)==$value) {
- $selected = ' selected="true"';
- } else {
- $selected = '';
- }
- $dropdown .= '<option value="' . attribute_escape($value) . '"' . $selected . '>' . __($description, 'wpmp') . '</option>';
- }
- $dropdown .= "</select>";
- return $dropdown;
-}
-
-function wpmp_switcher_option_text($option, $onchange='') {
- if ($onchange!='') {
- $onchange = 'onchange="' . attribute_escape($onchange) . '" onkeyup="' . attribute_escape($onchange) . '"';
- }
- $text = '<input type="text" id="' . $option . '" name="' . $option . '" value="' . attribute_escape(get_option($option)) . '" ' . $onchange . '/>';
- return $text;
-}
-
-function wpmp_switcher_option_checkbox($option, $onchange='') {
- if ($onchange!='') {
- $onchange = 'onchange="' . attribute_escape($onchange) . '"';
- }
- $checkbox = '<input type="checkbox" id="' . $option . '" name="' . $option . '" value="true" ' . (get_option($option)==='true'?'checked="true"':'') . ' ' . $onchange . ' />';
- return $checkbox;
-}
-
-function wpmp_switcher_option_themes($option) {
- $mobile_themes = array();
- $non_mobile_themes = array();
- foreach(get_themes() as $name=>$theme) {
- if(strpos(strtolower($name), 'mobile')!==false) {
- $mobile_themes[$name] = $name;
- } else {
- $non_mobile_themes[$name] = $name;
- }
- }
- if(sizeof($mobile_themes)>0) {
- $mobile_themes[''] = '-------';
- }
- $options = array_merge($mobile_themes, $non_mobile_themes);
- return wpmp_switcher_option_dropdown($option, $options);
-}
-
-function wpmp_switcher_desktop_theme() {
- $info = current_theme_info();
- return $info->title;
-}
-
-function wpmp_switcher_wp_cache_check_mobile( $cache_key ) {
- if (!isset($_SERVER["HTTP_USER_AGENT"])) {
- return $cache_key;
- }
-
- $is_mobile = wpmp_switcher_is_mobile_browser();
- $mobile_group = '';
- $wp_mobile_pack_dir = WP_CONTENT_DIR . '/plugins/wordpress-mobile-pack';
- if ($is_mobile && is_file($wp_mobile_pack_dir . '/themes/mobile_pack_base/group_detection.php')) {
- include_once($wp_mobile_pack_dir . '/themes/mobile_pack_base/group_detection.php');
- $mobile_group = group_detection();
- }
- if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
- wp_cache_debug("Lite detection says is_mobile: {$is_mobile} and group: {$mobile_group} for User-Agent: " . $_SERVER[ "HTTP_USER_AGENT" ], 5);
- }
-
- $new_cache_key = $cache_key . $is_mobile . $mobile_group;
- // In the worst case we return the cache_key as it came in
- return $new_cache_key;
-}
-
-?>
diff --git a/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/wpmp_switcher_admin.php b/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/wpmp_switcher_admin.php
deleted file mode 100755
index b034c365..00000000
--- a/plugins/wordpress-mobile-pack/plugins/wpmp_switcher/wpmp_switcher_admin.php
+++ /dev/null
@@ -1,122 +0,0 @@
-<?php
-
-/*
-$Id: wpmp_switcher_admin.php 195195 2010-01-19 04:11:37Z jamesgpearce $
-
-$URL: http://plugins.svn.wordpress.org/wordpress-mobile-pack/trunk/plugins/wpmp_switcher/wpmp_switcher_admin.php $
-
-Copyright (c) 2009 James Pearce & friends, portions mTLD Top Level Domain Limited, ribot, Forum Nokia
-
-Online support: http://wordpress.org/extend/plugins/wordpress-mobile-pack/
-
-This file is part of the WordPress Mobile Pack.
-
-The WordPress Mobile Pack is Licensed under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with the
-License.
-
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software distributed
-under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
-CONDITIONS OF ANY KIND, either express or implied. See the License for the
-specific language governing permissions and limitations under the License.
-*/
-
-?>
-
-<div class="wrap">
- <h2>
- <?php _e('Mobile Switcher', 'wpmp') ?>
- <p style='font-size:small;font-style:italic;margin:0'>
- <?php _e('Part of the WordPress Mobile Pack', 'wpmp'); ?>
- </p>
- </h2>
- <form method="post" action="">
- <table class="form-table">
- <tr>
- <th><?php _e('Switcher mode', 'wpmp'); ?></th>
- <td>
- <?php print wpmp_switcher_option('wpmp_switcher_mode', 'wpmpSwitcherMode();'); ?>
- <br />
- <?php _e('The switcher can detect whether the user is using a mobile device or has requested a mobile domain. It will switch theme accordingly.', 'wpmp'); ?>
- </td>
- </tr>
- <tr class='wpmp_theme'>
- <th><?php _e('Mobile theme', 'wpmp'); ?></th>
- <td>
- <?php print wpmp_switcher_option('wpmp_switcher_mobile_theme'); ?>
- <br />
- <?php _e('The theme that will be sent to a mobile user. Desktop users will receive ', 'wpmp'); ?>
- <a href='/wp-admin/themes.php' target='_blank'><?php print wpmp_switcher_desktop_theme(); ?></a>
- </td>
- </tr>
- <tr class='wpmp_browser'>
- <th><?php _e('Browser detection', 'wpmp'); ?></th>
- <td><?php print wpmp_switcher_option('wpmp_switcher_detection'); ?></td>
- </tr>
- <tr class='wpmp_desktop_domain'>
- <th><?php _e('Desktop domains', 'wpmp'); ?></th>
- <td>
- <?php print wpmp_switcher_option('wpmp_switcher_desktop_domains'); ?>
- <br />
- <?php _e('Use comma-separated domain names. eg:', 'wpmp'); ?> <b>mysite.com, downloads.mysite.com</b>
- <br />
- <?php _e("Desktop users who mistakenly access a mobile domain will be given the option to return to the first domain in this list.", 'wpmp'); ?>
- <br />
- <?php _e("This is also the domain used for switching when 'browser detection' is used, and in that case should be your site's primary domain.", 'wpmp'); ?>
- </td>
- </tr>
- <tr class='wpmp_mobile_domain'>
- <th><?php _e('Mobile domains', 'wpmp'); ?></th>
- <td>
- <?php print wpmp_switcher_option('wpmp_switcher_mobile_domains'); ?>
- <br />
- <?php _e('Use comma-separated domain fragments. eg:', 'wpmp'); ?> <b>mysite.mobi, m.mysite.com</b>
- <?php
- if (strpos(get_option('wpmp_switcher_mode'), 'domain')!==false && wpmp_switcher_domains('desktop', true) == wpmp_switcher_domains('mobile', true)) {
- _e("<br /><strong style='color:#770000'>Warning</strong>: your primary desktop and mobile domains are the same. The switcher will default to 'browser detection' mode unless one is changed.", 'wpmp');
- }
- ?>
- <br/>
- <?php _e('Mobile users who mistakenly access a desktop domain will be given the option to return to the first domain in this list.', 'wpmp'); ?>
- <br/>
- <?php _e('<b>NB</b>: The plugin does not <i>create</i> these domains. You must be sure their DNS entries already resolve and are served by this web server.', 'wpmp'); ?>
- </td>
- </tr>
- <tr class='wpmp_links'>
- <th><?php _e('Footer links', 'wpmp'); ?></th>
- <td>
- <?php print wpmp_switcher_option('wpmp_switcher_footer_links'); ?>
- <br />
- <?php _e('Places a link in the theme footer to allow users to override the detection.', 'wpmp'); ?>
- <?php _e('You can also enable the widget that contains this link.', 'wpmp'); ?>
- <?php _e('Both the footer link and the widget will only appear when a switcher mode is enabled.', 'wpmp'); ?>
- <?php _e('Regardless of this setting, the switcher link will always appear on the mobile admin pages.', 'wpmp'); ?>
- </td>
- </tr>
- </table>
- <p class="submit">
- <input type="submit" name="Submit" value="<?php _e('Save Changes', 'wpmp'); ?>" />
- </p>
- </form>
-</div>
-
-<script>
- var wpmp_pale = 0.3;
- var wpmp_speed = 'slow';
- function wpmpSwitcherMode(speed) {
- if (speed==null) {speed=wpmp_speed;}
- var value = jQuery("#wpmp_switcher_mode").val();
- var browser = value.indexOf("browser")>-1;
- var domain = value.indexOf("domain")>-1;
- jQuery(".wpmp_browser").children().fadeTo(speed, browser ? 1 : wpmp_pale);
- jQuery(".wpmp_desktop_domain").children().fadeTo(speed, (domain||browser) ? 1 : wpmp_pale);
- jQuery(".wpmp_mobile_domain").children().fadeTo(speed, domain ? 1 : wpmp_pale);
- jQuery(".wpmp_theme").children().fadeTo(speed, (domain||browser) ? 1 : wpmp_pale);
- jQuery(".wpmp_links").children().fadeTo(speed, (domain||browser) ? 1 : wpmp_pale);
- }
- wpmpSwitcherMode(-1);
-</script>