function initialize() { require_once 'mobile-user-agents.php'; // Check to see if we should initialize WPtouch Pro - can be used by certain other plugins to disable WPtouch Pro // When not initialized, WPtouch Pro is effectively disabled $should_init = apply_filters('wptouch_should_init_pro', true); if (!$should_init) { return false; } require_once WPTOUCH_DIR . '/admin/customizer/wptouch-customizer.php'; if (defined('WPTOUCH_IS_FREE')) { add_filter('wptouch_settings_override_defaults', array(&$this, 'handle_free_migration'), 10, 2); } // Only check directories when admin is showing if (is_admin()) { $this->check_directories(); require_once WPTOUCH_DIR . '/core/admin-page-templates.php'; } $this->cleanup_post_and_get(); // Prime the settings $settings = $this->get_settings(); // Check license $bncid_settings = wptouch_get_settings('bncid'); if (!isset($bncid_settings->current_version) || $bncid_settings->current_version != WPTOUCH_VERSION) { $bncid_settings->current_version = WPTOUCH_VERSION; do_action('wptouch_version_update', WPTOUCH_VERSION); if (!$bncid_settings->license_accepted) { $settings = wptouch_get_settings(); // Check for old license accepted code if (isset($settings->license_accepted) && $settings->license_accepted) { $bncid_settings->license_accepted = $settings->license_accepted; } } // Perform upgrade here WPTOUCH_DEBUG(WPTOUCH_INFO, '...saving BNCID settings in upgrade path'); $bncid_settings->save(); // Delete the language information transient so we check for a new language file delete_site_transient('_wptouch_language_info'); } require_once WPTOUCH_DIR . '/core/class-cache-smash.php'; $this->cache_smash = new WPtouchCacheSmash(); if (is_admin()) { // New Admin panels require_once WPTOUCH_DIR . '/core/admin-load.php'; add_action('admin_init', array(&$this, 'admin_handle_init')); add_action('all_admin_notices', array(&$this, 'handle_admin_notices')); add_action('admin_menu', 'wptouch_admin_build_menu'); add_action('network_admin_menu', 'wptouch_admin_build_network_menu'); // Icon Upload Ajax add_action('wp_ajax_upload_file', array(&$this, 'handle_upload_file')); add_action('wp_ajax_nopriv_upload_file', array(&$this, 'handle_upload_file')); // Handle admin AJAX requests from JS add_action('wp_ajax_wptouch_client_ajax', array(&$this, 'handle_client_ajax')); add_action('wp_ajax_nopriv_wptouch_client_ajax', array(&$this, 'handle_client_ajax')); // Languages add_filter('wptouch_admin_languages', array(&$this, 'setup_custom_languages')); // Plugin page add_filter('plugin_action_links', array(&$this, 'wptouch_pro_settings_link'), 9, 2); add_action('install_plugins_pre_plugin-information', array(&$this, 'show_plugin_info')); add_action('after_plugin_row_wptouch-pro/wptouch-pro.php', array(&$this, 'plugin_row')); // Backup/Restore add_action('wptouch_settings_saved', array(&$this, 'check_for_restored_settings')); require_once WPTOUCH_DIR . '/core/cloud-migrate.php'; if ($this->should_do_desktop_shortcode_magic($settings)) { add_action('save_post', array(&$this, 'handle_desktop_shortcode_save_post')); } } else { if ($this->should_do_desktop_shortcode_magic($settings)) { add_filter('wptouch_force_mobile_device', array(&$this, 'shortcode_override')); add_action('init', array(&$this, 'handle_desktop_shortcode')); } add_action('wp', array(&$this, 'set_cache_cookie')); } wptouch_debug_enable(false); add_filter('wptouch_available_icon_sets_post_sort', array(&$this, 'setup_custom_icons')); // Can be used to adjust the support mobile devices add_filter('wptouch_supported_device_classes', array(&$this, 'augment_supported_devices')); $this->check_for_settings_changes(false); WPTOUCH_DEBUG(WPTOUCH_INFO, 'Adding root functions files'); // Loads root functions files from the themes $this->load_root_functions_files(); $this->load_addon_modules(); // Do settings download after we load root functions if ($this->admin_is_wptouch_page()) { $this->check_for_settings_download(); } // Foundation modules are loaded off of this one do_action('wptouch_root_functions_loaded'); // This is where the main user-agent matching happens to determine module or non-mobile $this->analyze_user_agent_string(); // Mobile content handler (delayed to allow device/display check) if (!is_admin()) { if ($this->should_do_desktop_shortcode_magic($settings) && ($this->is_mobile_device && $this->showing_mobile_theme)) { remove_filter('the_content', 'wptexturize'); // Need finer-grain control over what gets processed or not. global $shortcode_tags; foreach ($shortcode_tags as $shortcode => $object) { if (!in_array($shortcode, $this->preprocess_shortcodes)) { unset($shortcode_tags[$shortcode]); } } add_filter('the_content', array(&$this, 'desktop_shortcode_magic'), 99); } } // We have a mobile device, so WPtouch Pro could potentially cache it or allow another app to cache if ($this->is_mobile_device) { WPTOUCH_DEBUG(WPTOUCH_INFO, 'User is viewing on a MOBILE device'); do_action('wptouch_cache_enable'); } else { WPTOUCH_DEBUG(WPTOUCH_INFO, 'User is viewing on a NON-MOBILE device'); } // Check if we're using a version of WordPress that supports themes if (function_exists('add_theme_support')) { add_theme_support('menus'); add_action('after_setup_theme', array(&$this, 'finish_thumbnail_setup')); } // Check to see if the mobile theme should be shown - if so, initialize it if ($this->is_showing_mobile_theme_on_mobile_device() && !$this->cache_smash->should_disable_mobile_theme()) { $this->setup_mobile_theme_for_viewing(); // For Google Best Practices header('Vary: User-Agent'); } else { remove_action('wp_enqueue_scripts', 'wptouch_foundation_load_framework_styles', 1); add_action('wp_footer', array(&$this, 'handle_desktop_footer')); } add_action('init', array(&$this, 'finish_initialization')); add_action('init', array(&$this, 'setup_desktop_nonce')); $this->check_for_critical_notifications(); }
function initialize() { // Check to see if we should initialize WPtouch Pro - can be used by certain other plugins to disable WPtouch Pro // When not initialized, WPtouch Pro is effectively disabled $should_init = apply_filters('wptouch_should_init_pro', true); if (!$should_init) { return false; } if (defined('WPTOUCH_IS_FREE')) { add_filter('wptouch_settings_override_defaults', array(&$this, 'handle_free_migration'), 10, 2); } // Only check directories when admin is showing if (is_admin()) { $this->check_directories(); require_once WPTOUCH_DIR . '/core/admin-page-templates.php'; } // Prime the settings $settings = $this->get_settings(); // Check license $bncid_settings = wptouch_get_settings('bncid'); if (!isset($bncid_settings->current_version) || $bncid_settings->current_version != WPTOUCH_VERSION) { do_action('wptouch_version_update', WPTOUCH_VERSION); if (!$bncid_settings->license_accepted) { $settings = wptouch_get_settings(); // Check for old license accepted code if (isset($settings->license_accepted) && $settings->license_accepted) { $bncid_settings->license_accepted = $settings->license_accepted; } } // Perform upgrade here WPTOUCH_DEBUG(WPTOUCH_INFO, '...saving BNCID settings in upgrade path'); $bncid_settings->save(); } $this->cleanup_post_and_get(); if (is_admin()) { // New 3.0 Admin panels require_once WPTOUCH_DIR . '/core/admin-load.php'; // Admin panel warnings notifications require_once WPTOUCH_DIR . '/core/notifications.php'; add_action('admin_init', array(&$this, 'admin_handle_init')); add_action('admin_head', array(&$this, 'handle_admin_head')); add_action('all_admin_notices', array(&$this, 'handle_admin_notices')); add_action('admin_menu', 'wptouch_admin_build_menu'); add_action('network_admin_menu', 'wptouch_admin_build_network_menu'); // Icon Upload Ajax add_action('wp_ajax_upload_file', array(&$this, 'handle_upload_file')); add_action('wp_ajax_nopriv_upload_file', array(&$this, 'handle_upload_file')); // Handle admin AJAX requests from JS add_action('wp_ajax_wptouch_client_ajax', array(&$this, 'handle_client_ajax')); add_action('wp_ajax_nopriv_wptouch_client_ajax', array(&$this, 'handle_client_ajax')); // Languages add_filter('wptouch_admin_languages', array(&$this, 'setup_custom_languages')); // Plugin page add_filter('plugin_action_links', array(&$this, 'wptouch_pro_settings_link'), 9, 2); add_action('install_plugins_pre_plugin-information', array(&$this, 'show_plugin_info')); add_action('after_plugin_row_wptouch-pro-3/wptouch-pro-3.php', array(&$this, 'plugin_row')); // Backup/Restore add_action('wptouch_settings_saved', array(&$this, 'check_for_restored_settings')); add_action('wptouch_ajax_desktop_switch', array(&$this, 'handle_desktop_switch_ajax')); require_once WPTOUCH_DIR . '/core/cloud-migrate.php'; } // Set up debug log if ($settings->debug_log) { wptouch_debug_enable(true); wptouch_debug_set_log_level(WPTOUCH_ALL); } add_filter('wptouch_available_icon_sets_post_sort', array(&$this, 'setup_custom_icons')); // Can be used to adjust the support mobile devices add_filter('wptouch_supported_device_classes', array(&$this, 'augment_supported_devices')); $this->check_for_settings_changes(); $this->setup_languages(); WPTOUCH_DEBUG(WPTOUCH_INFO, 'Adding root functions files'); // Loads root functions files from the themes $this->load_root_functions_files(); $this->load_addon_modules(); // Do settings download after we load root functions if ($this->admin_is_wptouch_page()) { $this->check_for_settings_download(); } // Foundation modules are loaded off of this one do_action('wptouch_root_functions_loaded'); // This is where the main user-agent matching happens to determine module or non-mobile $this->analyze_user_agent_string(); $this->set_cache_cookie(); // We have a mobile device, so WPtouch Pro could potentially cache it or allow another app to cache if ($this->is_mobile_device) { WPTOUCH_DEBUG(WPTOUCH_INFO, 'User is viewing on a MOBILE device'); do_action('wptouch_cache_enable'); } else { WPTOUCH_DEBUG(WPTOUCH_INFO, 'User is viewing on a NON-MOBILE device'); } // Check if we're using a version of WordPress that supports themes if (function_exists('add_theme_support')) { add_theme_support('menus'); add_action('after_setup_theme', array(&$this, 'finish_thumbnail_setup')); } // Check to see if the mobile theme should be shown - if so, initialize it if ($this->is_showing_mobile_theme_on_mobile_device()) { $this->setup_mobile_theme_for_viewing(); } else { add_action('wp_footer', array(&$this, 'handle_desktop_footer')); } add_action('init', array(&$this, 'finish_initialization')); add_action('init', array(&$this, 'setup_desktop_nonce')); $this->check_for_critical_notifications(); }
function initialize() { if (function_exists('piggy_should_be_shown') && piggy_should_be_shown() || defined('XMLRPC_REQUEST') || defined('APP_REQUEST')) { return false; } $this->check_directories(); $this->load_modules(); $this->cleanup_post_and_get(); $settings = $this->get_settings(); if (is_admin()) { // Admin Panel Warnings require_once WPTOUCH_DIR . '/admin/template-tags/warnings.php'; // Administration Panel require_once WPTOUCH_DIR . '/admin/admin-panel.php'; add_action('admin_menu', 'wptouch_admin_menu'); add_action('publish_page', array(&$this, 'invalidate_menu_tree_cache')); // add_action( 'admin_head', array( &$this, 'show_plugin_help_text' ) ); add_action('wptouch_settings_saved', array(&$this, 'create_settings_backup_file')); } // Set up debug log if ($settings->debug_log) { wptouch_debug_enable(true); wptouch_debug_set_log_level($settings->debug_log_level); } WPTOUCH_DEBUG(WPTOUCH_INFO, 'WPtouch Pro Initializations ' . WPTOUCH_VERSION); // These actions and filters are always loaded add_action('init', array(&$this, 'wptouch_init')); add_action('admin_init', array(&$this, 'initialize_admin_section')); add_action('admin_init', array(&$this, 'check_for_product_upgrade')); add_action('admin_head', array(&$this, 'wptouch_admin_head')); add_action('install_plugins_pre_plugin-information', array(&$this, 'show_plugin_info')); add_action('comment_post', array(&$this, 'prowl_handle_new_comment')); add_action('user_register', array(&$this, 'prowl_handle_new_comment')); add_filter('wptouch_available_icon_sets_post_sort', array(&$this, 'setup_custom_icons')); add_filter('plugin_action_links', array(&$this, 'wptouch_pro_settings_link'), 9, 2); add_action('wp_ajax_wptouch_client_ajax', array(&$this, 'handle_client_ajax')); add_action('wp_ajax_nopriv_wptouch_client_ajax', array(&$this, 'handle_client_ajax')); add_action('wptouch_settings_saved', array(&$this, 'check_for_restored_settings')); add_filter('wptouch_admin_languages', array(&$this, 'setup_custom_languages')); add_action('wptouch_pre_head', array(&$this, 'add_ignored_urls')); // iPad add_filter('wptouch_supported_device_classes', array(&$this, 'setup_ipad_user_agents')); // WP Super Cache add_filter('cached_mobile_prefixes', array(&$this, 'filter_wp_super_cache_prefixes')); add_filter('cached_mobile_browsers', array(&$this, 'filter_wp_super_cache_browsers')); // ManageWP add_filter('mwp_premium_update_notification', array(&$this, 'mwp_update_notification')); add_filter('mwp_premium_perform_update', array(&$this, 'mwp_perform_update')); if (wptouch_is_multisite_secondary()) { add_filter('wptouch_default_settings', array(&$this, 'setup_inherited_multisite_settings')); add_action('wptouch_later_admin_tabs', array(&$this, 'alter_admin_tabs_for_multisite')); } add_shortcode('wptouch', array(&$this, 'handle_shortcode')); if (WPTOUCH_PRO_BETA) { add_action('after_plugin_row_wptouch-pro-beta/wptouch-pro.php', array(&$this, 'plugin_row')); } else { add_action('after_plugin_row_wptouch-pro/wptouch-pro.php', array(&$this, 'plugin_row')); } // Load root-functions always for now //if ( $this->wptouch_is_wptouch_pro_page() || !is_admin() ) { if (true) { $clear_settings = false; // Load the current theme functions.php, or the child root functions if it exists in WPtouch themes if (file_exists($this->get_current_theme_directory() . '/root-functions.php')) { require_once $this->get_current_theme_directory() . '/root-functions.php'; // next time get_settings is called, the current theme defaults will be added in $clear_settings = true; } // Load the parent root-functions if it exists if ($this->has_parent_theme()) { $parent_info = $this->get_parent_theme_info(); if (file_exists(WP_CONTENT_DIR . $parent_info->location . '/root-functions.php')) { require_once WP_CONTENT_DIR . $parent_info->location . '/root-functions.php'; } // next time get_settings is called, the current theme defaults will be added in $clear_settings = true; } // Load a custom functions.php file if (file_exists(WPTOUCH_BASE_CONTENT_DIR . '/functions.php')) { require_once WPTOUCH_BASE_CONTENT_DIR . '/functions.php'; } do_action('wptouch_functions_loaded'); if ($clear_settings) { // each theme can add it's own default settings, so we need to reset our internal settings object // so that the defaults will get merged in from the current theme $this->reload_settings(); } } $this->check_user_agent(); if ($settings->desktop_is_first_view && $this->is_mobile_device && !$this->showing_mobile_theme) { add_action('wp_head', array(&$this, 'handle_desktop_redirect_for_webapp')); } // Check if we're using a version of WordPress that supports themes if (function_exists('add_theme_support')) { add_theme_support('menus'); } if ($this->is_mobile_device && $this->showing_mobile_theme) { do_action('wptouch_mobile_theme_showing'); // Remove the admin bar in WPtouch Pro themes for now if (function_exists('show_admin_bar')) { add_filter('show_admin_bar', '__return_false'); } // Theme functions require_once WPTOUCH_DIR . '/include/template-tags/theme.php'; // Menu Tags require_once WPTOUCH_DIR . '/include/template-tags/menu.php'; // Compatibility require_once WPTOUCH_DIR . '/include/compat.php'; add_action('wptouch_functions_start', array(&$this, 'load_functions_file_for_desktop')); // These actions and filters are only loaded when WPtouch and a mobile theme are active add_action('wp', array(&$this, 'check_for_redirect')); add_filter('init', array(&$this, 'init_theme')); add_filter('excerpt_length', array(&$this, 'get_excerpt_length')); add_filter('excerpt_more', array(&$this, 'get_excerpt_more')); // New switch hooks add_filter('template_directory', array(&$this, 'get_template_directory')); add_filter('template_directory_uri', array(&$this, 'get_template_directory_uri')); add_filter('stylesheet_directory', array(&$this, 'get_stylesheet_directory')); add_filter('stylesheet_directory_uri', array(&$this, 'get_stylesheet_directory_uri')); add_action('wptouch_post_head', array(&$this, 'add_mobile_header_info')); // This is used to add the RSS, email items, etc add_filter('wptouch_menu_items', array(&$this, 'add_static_menu_items')); if ($settings->menu_disable_parent_as_child) { add_filter('wptouch_menu_items', array(&$this, 'remove_duplicate_menu_items')); } if ($settings->make_links_clickable) { add_filter('the_content', 'make_clickable'); } // Check to see if we're a child theme so we can add the child stylesheet if ($this->is_child_theme()) { add_action('wptouch_post_head', array(&$this, 'output_child_scripts'), 999); } if (isset($settings->remove_shortcodes) && strlen($settings->remove_shortcodes)) { $this->remove_shortcodes($settings->remove_shortcodes); } } // Setup Post Thumbnails $create_thumbnails = apply_filters('wptouch_create_thumbnails', $settings->post_thumbnails_enabled && function_exists('add_theme_support')); // Setup Post Thumbnails if ($create_thumbnails) { add_theme_support('post-thumbnails'); add_image_size('wptouch-new-thumbnail', $settings->post_thumbnails_new_image_size, $settings->post_thumbnails_new_image_size, true); } $this->custom_page_templates = apply_filters('wptouch_custom_templates', $this->custom_page_templates); if (!$settings->has_migrated_icons) { $this->check_old_version(); $settings->has_migrated_icons = true; $this->save_settings($settings); } if (defined('WORDTWIT_PRO_INSTALLED')) { add_filter('wptouch_default_settings', array(&$this, 'add_default_wordtwit_pro_settings')); } }