=')) { add_action('admin_notices', create_function( '', "echo '
WP Mobile is incorrectly installed. Please check the README.
Esci dalla Edizione per Cellulare (vai alla versione standard del browser).
'; } function cfmobi_mobile_available($content) { if (!defined('WPCACHEHOME')) { $content = $content.'Ritorna all\'Edizione per Cellulare.
'; } return $content; } function cfmobi_mobile_link() { if (!defined('WPCACHEHOME')) { echo 'Mobile Editione'; } } // TODO - add sidebar widget for link, with some sort of graphic? function cfmobi_request_handler() { if (!empty($_GET['cf_action'])) { $url = parse_url(get_bloginfo('home')); $domain = $url['host']; if (!empty($url['path'])) { $path = $url['path']; } else { $path = '/'; } $redirect = false; switch ($_GET['cf_action']) { case 'cfmobi_admin_js': cfmobi_admin_js(); break; case 'cfmobi_admin_css': cfmobi_admin_css(); die(); break; case 'reject_mobile': setcookie( 'cf_mobile' , 'false' , time() + 300000 , $path , $domain ); $redirect = true; break; case 'show_mobile': setcookie( 'cf_mobile' , 'true' , time() + 300000 , $path , $domain ); $redirect = true; break; case 'cfmobi_who': if (current_user_can('manage_options')) { header("Content-type: text/plain"); echo sprintf(__('Browser: %s', 'cf-mobile'), strip_tags($_SERVER['HTTP_USER_AGENT'])); die(); } break; } if ($redirect) { if (!empty($_SERVER['HTTP_REFERER'])) { $go = $_SERVER['HTTP_REFERER']; } else { $go = get_bloginfo('home'); } header('Location: '.$go); die(); } } if (!empty($_POST['cf_action'])) { switch ($_POST['cf_action']) { case 'cfmobi_update_settings': cfmobi_save_settings(); wp_redirect(trailingslashit(get_bloginfo('wpurl')).'wp-admin/options-general.php?page=wp-mobile.php&updated=true'); die(); break; } } } add_action('init', 'cfmobi_request_handler'); function cfmobi_admin_js() { global $cfmobi_default_mobile_browsers, $cfmobi_default_touch_browsers; header('Content-type: text/javascript'); $mobile = str_replace(array("'","\r", "\n"), array("\'", '', ''), implode('\\n', cfmobi_default_browsers('mobile'))); $touch = str_replace(array("'","\r", "\n"), array("\'", '', ''), implode('\\n', cfmobi_default_browsers('touch'))); ?> jQuery(function($) { $('#cfmobi_mobile_reset').click(function() { $('#cfmobi_mobile_browsers').val(''); return false; }); $('#cfmobi_touch_reset').click(function() { $('#cfmobi_touch_browsers').val(''); return false; }); }); fieldset.options div.option { background: #EAF3FA; margin-bottom: 8px; padding: 10px; } fieldset.options div.option label { display: block; float: left; font-weight: bold; margin-right: 10px; width: 150px; } fieldset.options div.option span.help { color: #666; font-size: 11px; margin-left: 8px; } #cfmobi_mobile_browsers, #cfmobi_touch_browsers { height: 200px; width: 300px; } #cfmobi_mobile_reset, #cfmobi_touch_reset { display: block; font-size: 11px; font-weight: normal; } '; } add_action('admin_head', 'cfmobi_admin_head'); $cfmobi_settings = array( 'cfmobi_mobile_browsers' => array( 'type' => 'textarea', 'label' => 'Mobile Browsers Reset to Default', 'default' => cfmobi_default_browsers('mobile'), 'help' => '', ), 'cfmobi_touch_browsers' => array( 'type' => 'textarea', 'label' => 'Touch Browsers Reset to Default', 'default' => cfmobi_default_browsers('touch'), 'help' => '(iPhone, Android G1, BlackBerry Storm, etc.)', ), ); function cfmobi_setting($option) { $value = get_option($option); if (empty($value)) { global $cfmobi_settings; $value = $cfmobi_settings[$option]['default']; } return $value; } function cfmobi_admin_menu() { if (current_user_can('manage_options')) { add_options_page( __('WordPress Mobile Edition', 'cf-mobile') , __('Mobile', 'cf-mobile') , 10 , basename(__FILE__) , 'cfmobi_settings_form' ); } } add_action('admin_menu', 'cfmobi_admin_menu'); function cfmobi_plugin_action_links($links, $file) { $plugin_file = basename(__FILE__); if ($file == $plugin_file) { $settings_link = ''.__('Settings', 'cf-mobile').''; array_unshift($links, $settings_link); } return $links; } add_filter('plugin_action_links', 'cfmobi_plugin_action_links', 10, 2); if (!function_exists('cf_settings_field')) { function cf_settings_field($key, $config) { $option = get_option($key); $label = ''; $help = ''.$config['help'].''; switch ($config['type']) { case 'select': $output = $label.''.$help; break; case 'textarea': if (is_array($option)) { $option = implode("\n", $option); } $output = $label.''.$help; break; case 'string': case 'int': default: $output = $label.''.$help; break; } return '