function wptouch_admin_get_root_slug($network_admin = false) { $menu = wptouch_admin_get_predefined_menus(); $settings = wptouch_get_settings(); if (defined('WPTOUCH_IS_FREE')) { $show_wizard = $settings->show_free_wizard; } else { $show_wizard = $settings->show_wizard; } $show_network_wizard = $settings->show_network_wizard; $network_admin = is_network_admin(); if ($network_admin) { if ($show_network_wizard) { return $menu[WPTOUCH_PRO_ADMIN_WIZARD]->slug; } else { return $menu[WPTOUCH_PRO_ADMIN_GENERAL_SETTINGS]->slug; } } else { if ($show_wizard) { return $menu[WPTOUCH_PRO_ADMIN_WIZARD]->slug; } else { if (defined('WPTOUCH_SHOW_WIZARD')) { return $menu[WPTOUCH_PRO_ADMIN_WIZARD]->slug; } return $menu[WPTOUCH_PRO_ADMIN_GENERAL_SETTINGS]->slug; } } }
function foundation_get_page_walker($walker, $menu_name) { global $wptouch_pro; // Don't do anything for WordPress menus if (is_array($wptouch_pro->theme_menus) && count($wptouch_pro->theme_menus)) { foreach ($wptouch_pro->theme_menus as $menu_info) { $settings = wptouch_get_settings($menu_info->settings_domain); $setting_value = $menu_info->setting_name; if (isset($settings->{$setting_value})) { $menu_to_show = $settings->{$setting_value}; if ($menu_name == $menu_to_show) { // This is the menu that is showing switch ($menu_info->menu_type) { case 'dropdown': // This is already taken care of by the walkel break; default: $walker = apply_filters('wptouch_unhandled_page_walker', $walker, $menu_info->menu_type); break; } } } } } return $walker; // $wptouch_pro->theme_menus[] = $menu; }
function wptouch_admin_get_predefined_menus($network_only = false) { $available_menus = array(); if ($network_only) { $available_menus = array(WPTOUCH_PRO_ADMIN_TOUCHBOARD => wptouch_admin_create_menu(WPTOUCH_PRO_ADMIN_TOUCHBOARD, __('What\'s New', 'wptouch-pro'))); } else { $available_menus = array(WPTOUCH_PRO_ADMIN_TOUCHBOARD => wptouch_admin_create_menu(WPTOUCH_PRO_ADMIN_TOUCHBOARD, __('What\'s New', 'wptouch-pro')), WPTOUCH_PRO_ADMIN_GENERAL_SETTINGS => wptouch_admin_create_menu(WPTOUCH_PRO_ADMIN_GENERAL_SETTINGS, __('Core Settings', 'wptouch-pro')), WPTOUCH_PRO_ADMIN_THEMES_AND_ADDONS => wptouch_admin_create_menu(WPTOUCH_PRO_ADMIN_THEMES_AND_ADDONS, __('Themes & Extensions', 'wptouch-pro')), WPTOUCH_PRO_ADMIN_THEME_OPTIONS => wptouch_admin_create_menu(WPTOUCH_PRO_ADMIN_THEME_OPTIONS, __('Theme Settings', 'wptouch-pro'), WPTOUCH_PRO_ADMIN_SETTINGS_PAGE, sprintf(__('%s Settings', 'wptouch-pro'), wptouch_get_bloginfo('active_theme_friendly_name')))); $settings = wptouch_get_settings(); if (isset($settings->active_addons) && is_array($settings->active_addons) && count($settings->active_addons)) { $available_menus[WPTOUCH_PRO_ADMIN_ADDON_OPTIONS] = wptouch_admin_create_menu(WPTOUCH_PRO_ADMIN_ADDON_OPTIONS, __('Extension Settings', 'wptouch-pro')); } if (wptouch_get_registered_theme_count()) { // Need to see if a theme has a menu available $available_menus[WPTOUCH_PRO_ADMIN_MENUS] = wptouch_admin_create_menu(WPTOUCH_PRO_ADMIN_MENUS, __('Menus', 'wptouch-pro')); } else { $available_menus[WPTOUCH_PRO_ADMIN_MENUS_DISABLED] = wptouch_admin_create_menu(WPTOUCH_PRO_ADMIN_MENUS_DISABLED, __('Menus', 'wptouch-pro')); } } // Check multisite if (!defined('WPTOUCH_IS_FREE') && (wptouch_can_show_license_menu() || defined('WPTOUCH_FORCE_SHOW_LICENSE_PANEL'))) { $available_menus[WPTOUCH_PRO_ADMIN_LICENSE] = wptouch_admin_create_menu(WPTOUCH_PRO_ADMIN_LICENSE, __('License', 'wptouch-pro'), WPTOUCH_PRO_ADMIN_CUSTOM_PAGE); } // Check multisite if (defined('WPTOUCH_IS_FREE')) { $available_menus[WPTOUCH_PRO_ADMIN_UPGRADE] = wptouch_admin_create_menu(WPTOUCH_PRO_ADMIN_UPGRADE, __('Upgrade to Pro', 'wptouch-pro'), WPTOUCH_PRO_ADMIN_CUSTOM_PAGE); } elseif (!defined('WPTOUCH_CLIENT_MODE') && wptouch_license_upgrade_available()) { $available_menus[WPTOUCH_PRO_ADMIN_UPGRADE_LICENSE] = wptouch_admin_create_menu(WPTOUCH_PRO_ADMIN_UPGRADE_LICENSE, __('Upgrade License', 'wptouch-pro'), WPTOUCH_PRO_ADMIN_CUSTOM_PAGE); } return apply_filters('wptouch_available_menus', $available_menus); }
function foundation_google_fonts_init() { $settings = wptouch_get_settings('foundation'); if ($settings->typography_sets != 'default') { wp_enqueue_script('foundation_google_fonts', foundation_get_base_module_url() . '/google-fonts/google-fonts.js', false, md5(FOUNDATION_VERSION), true); } $selected_font_info = foundation_google_fonts_get_selected_info(); if ($selected_font_info) { $family_string = ''; $inline_style_data = ''; if (is_array($selected_font_info) && count($selected_font_info)) { $new_families = array(); foreach ($selected_font_info as $font_info) { $font_string = htmlentities($font_info->name); if (isset($font_info->variants) && is_array($font_info->variants)) { $font_string .= ':' . implode(',', $font_info->variants); } $new_families[] = $font_string; $inline_style_data .= "." . $font_info->selector . "-font" . " {\n"; $inline_style_data .= "\tfont-family: '" . $font_info->name . "', " . $font_info->fallback . ";\n"; $inline_style_data .= "}\n"; } $family_string = implode('|', $new_families); } if ($family_string) { wp_enqueue_style('foundation_google_fonts', 'http://fonts.googleapis.com/css?family=' . $family_string, false, FOUNDATION_VERSION, false); if ($inline_style_data) { wp_add_inline_style('foundation_google_fonts', $inline_style_data); } } } }
function wptouch_geolocation_enqueue_scripts() { $settings = wptouch_get_settings('foundation'); if ($settings->geolocation_enabled) { wp_enqueue_script('geolocation-js', WPTOUCH_URL . '/pro/modules/geolocation/geolocation.js', false, FOUNDATION_VERSION, true); } }
function wptouch_show_menu($menu_slug = false, $nav_menu_walker = false, $page_menu_walker = false) { $menu_html = false; $wptouch_menu_items = array(); $settings = wptouch_get_settings(); $parent_link_class = 'parent-links'; if (defined('WPTOUCH_MENU_LINK_PARENT_ITEMS') && WPTOUCH_MENU_LINK_PARENT_ITEMS == false) { $parent_link_class = 'no-parent-links'; } if (!$settings->enable_parent_items) { $parent_link_class = 'no-parent-links'; } if ($nav_menu_walker == false) { $nav_menu_walker = new WPtouchProMainNavMenuWalker($settings->enable_menu_icons); } if ($page_menu_walker == false) { $page_menu_walker = new WPtouchProMainPageMenuWalker($settings->enable_menu_icons); } // Render the menu echo apply_filters('wptouch_menu_start_html', '<ul class="menu-tree' . ' ' . $parent_link_class . '">'); $menu_slugs_to_show = apply_filters('wptouch_menu_slugs_to_show', array($menu_slug)); global $wptouch_pro; // Loop through all menus foreach ($menu_slugs_to_show as $key => $menu_slug) { foreach ($wptouch_pro->theme_menus as $menu_info) { if ($menu_info->setting_name == $menu_slug) { $can_be_disabled = $menu_info->can_be_disabled; } } _wptouch_show_menu($menu_slug, $nav_menu_walker, $page_menu_walker, $can_be_disabled); } echo apply_filters('wptouch_menu_end_html', '</ul>'); }
function wptouch_backup_settings() { global $wptouch_pro; $backup_domains = $wptouch_pro->get_active_setting_domains(); if (is_array($backup_domains) && count($backup_domains)) { $settings_to_save = array(); foreach ($backup_domains as $domain) { $settings_notused = wptouch_get_settings($domain); $settings = $wptouch_pro->settings_objects[$domain]; if (isset($settings->domain)) { unset($settings->domain); } $settings_to_save[$domain] = apply_filters('wptouch_backup_settings', $settings, $domain); } ksort($settings_to_save); $backup_string = base64_encode(gzcompress(serialize($settings_to_save), 9)); $backup_base_name = 'wptouch-backup-' . date('Ymd-His') . '.txt'; $backup_file_name = WPTOUCH_BACKUP_DIRECTORY . '/' . $backup_base_name; $backup_file = fopen($backup_file_name, 'w+t'); if ($backup_file) { fwrite($backup_file, $backup_string); fclose($backup_file); } } wptouch_prune_backup_files(); return $backup_base_name; }
function wptouch_admin_is_list_option_selected() { global $_primed_setting; $settings = wptouch_get_settings($_primed_setting->domain, false); $setting_name = $_primed_setting->name; return isset($settings->{$setting_name}) && wptouch_admin_get_list_option_key() == $settings->{$setting_name}; }
function wptouch_admin_get_setting_value() { global $_primed_setting; $settings = wptouch_get_settings($_primed_setting->domain, false); $setting_name = $_primed_setting->name; if (isset($settings->{$setting_name})) { return $settings->{$setting_name}; } }
function wptouch_fdn_show_login() { $settings = wptouch_get_settings(); if ($settings->show_login_box) { return true; } else { return false; } }
function wptouch_theme_custom_templates($templates) { $settings = wptouch_get_settings(); if ($settings->wptouch_theme_show_archives) { $templates[__('Archives', 'wptouch-pro')] = array('wptouch-archives'); } if ($settings->wptouch_theme_show_links) { $templates[__('Links', 'wptouch-pro')] = array('wptouch-links'); } return $templates; }
function wptouch_should_load_rtl() { global $wptouch_pro; if (is_admin()) { $settings = wptouch_get_settings(); if (!$settings->translate_admin) { return false; } } return is_rtl() || $wptouch_pro->locale == 'ar' || $wptouch_pro->locale == 'he_IL'; }
function wptouch_get_desktop_switch_link() { $settings = wptouch_get_settings(); if ($settings->show_switch_link) { if ($settings->home_page_redirect_address == 'same') { return apply_filters('wptouch_desktop_switch_link', get_bloginfo('url') . '?wptouch_switch=mobile&redirect=' . urlencode($_SERVER['REQUEST_URI'])); } else { return apply_filters('wptouch_desktop_switch_link', get_bloginfo('url') . '?wptouch_switch=mobile&redirect=' . get_bloginfo('url')); } } }
function wptouch_admin_is_setting_checked() { global $_primed_setting; $settings = wptouch_get_settings($_primed_setting->domain); if ($settings) { $name = $_primed_setting->name; if (isset($settings->{$name})) { return $settings->{$name} == 1; } } return false; }
function wptouch_admin_split_setting_newline() { global $_primed_setting; $settings = wptouch_get_settings($_primed_setting->domain, false); $setting_name = $_primed_setting->name; if ($settings->{$setting_name} != '') { $setting_data = explode("\r\n", $settings->{$setting_name}); } else { $setting_data = array(); } return $setting_data; }
function wptouch_wordpress_menu_has_children($parent) { global $wpdb; $settings = wptouch_get_settings(); $sql = $wpdb->prepare("SELECT count(*) as c FROM {$wpdb->prefix}posts WHERE ID IN (SELECT object_id FROM {$wpdb->prefix}term_relationships WHERE term_taxonomy_id = %d) AND ID IN (SELECT post_id FROM {$wpdb->prefix}postmeta WHERE meta_key = '_menu_item_menu_item_parent' AND meta_value = '%d') ORDER BY menu_order", $settings->custom_menu_name, $parent); // echo $sql . "<br/>"; $menu_items = $wpdb->get_row($sql); if ($menu_items && $menu_items->c) { return true; } return false; }
function wptouch_admin_build_menu($network_only = false) { wptouch_admin_check_api(); $settings = wptouch_get_settings(); $available_menus = wptouch_admin_get_predefined_menus($network_only); // Add the main plugin menu for WPtouch Pro add_menu_page(WPTOUCH_PRODUCT_NAME, WPTOUCH_PRODUCT_NAME, 'manage_options', wptouch_admin_get_root_slug(), '', WPTOUCH_ADMIN_URL . '/images/wptouch-admin-icon.png'); // Iterate through available menus foreach ($available_menus as $id => $menu) { add_submenu_page($available_menus[wptouch_admin_get_root_slug()]->slug, $menu->friendly_name, $menu->friendly_name, 'manage_options', $menu->slug, 'wptouch_admin_render_menu'); } }
function foundation_webapp_init() { $settings = foundation_get_settings(); if (isset($_REQUEST['wptouch_app_manifest'])) { echo json_encode(array('short_name' => $settings->homescreen_icon_title, 'icons' => array(array('src' => $settings->iphone_icon_retina, 'sizes' => '192x192'), array('src' => $settings->android_others_icon, 'sizes' => '57x57')), 'start_url' => site_url() . '?wptouch_webapp_start=manifest', 'display' => 'standalone', 'orientation' => 'portrait')); die; } // Do redirect in webapp mode if ($settings->webapp_enable_persistence && wptouch_fdn_is_web_app_mode()) { if (isset($_COOKIE[WPTOUCH_WEBAPP_PERSIST_COOKIE . '-' . foundation_webapp_get_persistence_salt()])) { $current_url = rtrim($_SERVER['HTTP_HOST'] . strtolower($_SERVER['REQUEST_URI']), '/'); $stored_url = str_replace(array('https://', 'http://'), array('', ''), rtrim(strtolower($_COOKIE[WPTOUCH_WEBAPP_PERSIST_COOKIE . '-' . foundation_webapp_get_persistence_salt()]), '/')); if (!strpos($stored_url, '/logout/') && !strpos($stored_url, '?action=logout') && $current_url != $stored_url && !isset($_COOKIE[WPTOUCH_WEBAPP_COOKIE . '-' . foundation_webapp_get_persistence_salt()]) && empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { $cookie = $_COOKIE[WPTOUCH_WEBAPP_PERSIST_COOKIE . '-' . foundation_webapp_get_persistence_salt()]; header('Location: ' . $cookie); die; } } } if (foundation_webapp_mode_enabled() && $settings->webapp_show_notice == true && !wptouch_fdn_is_web_app_mode()) { wp_enqueue_script('foundation_add2home', WPTOUCH_URL . '/pro/modules/webapp/add2home.js', false, FOUNDATION_VERSION, true); wp_enqueue_script('foundation_add2home_config', WPTOUCH_URL . '/pro/modules/webapp/add2home-config.js', array('foundation_add2home'), FOUNDATION_VERSION, true); $add_to_home_strings = array('bubbleMessage' => str_replace(array('[icon]', '[device]'), array('%icon', 'home screen'), $settings->webapp_notice_message), 'bubbleExpiryInDays' => $settings->webapp_notice_expiry_days * 60 * 24); wp_localize_script('foundation_add2home_config', 'wptouchFdnAddToHome', $add_to_home_strings); } if (foundation_webapp_mode_enabled()) { wp_enqueue_script('foundation_webapp', WPTOUCH_URL . '/pro/modules/webapp/webapp.js', array('jquery'), FOUNDATION_VERSION, true); $webapp_strings = array(); if ($settings->webapp_ignore_urls) { $ignored_wa_urls = explode("\n", $settings->webapp_ignore_urls); $trimmed_wa_urls = array(); foreach ($ignored_wa_urls as $wa_url) { $trimmed_wa_urls[] = strtolower(trim($wa_url)); } $webapp_strings['ignoredWebAppURLs'] = $trimmed_wa_urls; } $admin_settings = wptouch_get_settings(); if ($admin_settings->filtered_urls && $admin_settings->url_filter_behaviour == 'exclude_urls') { $ignored_urls = explode("\n", $admin_settings->filtered_urls); $trimmed_urls = array(); foreach ($ignored_urls as $url) { $trimmed_urls[] = strtolower(trim($url)); } $webapp_strings['ignoredURLs'] = $trimmed_urls; } $webapp_strings['externalLinkText'] = __('External link— open it in the browser?', 'wptouch-pro'); $webapp_strings['externalFileText'] = __('File link— Do you want to open it in the browser?', 'wptouch-pro'); $webapp_strings['persistence'] = $settings->webapp_enable_persistence ? '1' : '0'; $webapp_strings['persistenceSalt'] = foundation_webapp_get_persistence_salt(); wp_localize_script('foundation_webapp', 'wptouchWebApp', $webapp_strings); } }
function wptouch_should_load_rtl() { global $wptouch_pro; if (is_admin()) { $settings = wptouch_get_settings(); if (defined('WPTOUCH_ADMIN_IGNORE_LOCALIZATION')) { return false; } if (!$settings->translate_admin) { return false; } } return is_rtl() || $wptouch_pro->locale == 'ar' || $wptouch_pro->locale == 'he_IL'; }
function wptouch_render_general_page($page_options) { $settings = wptouch_get_settings(); wptouch_add_sub_page(WPTOUCH_ADMIN_SETUP_GENERAL, 'setup-general-general', $page_options); wptouch_add_sub_page(WPTOUCH_ADMIN_SETUP_COMPAT, 'setup-general-compat', $page_options); $these_settings = array(wptouch_add_setting('text', 'site_title', wptouchize_it(__('WPtouch Pro site title', 'wptouch-pro')), __('If the title of your site is long, you can shorten it for display within WPtouch Pro themes.', 'wptouch-pro'), WPTOUCH_SETTING_BASIC, '3.0'), wptouch_add_setting('checkbox', 'show_wptouch_in_footer', wptouchize_it(sprintf(__('Display %sPowered by WPtouch Pro%s in footer', 'wptouch-pro'), '"', '"')), '', WPTOUCH_SETTING_BASIC, 3.0)); wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_GENERAL, __('Site Title & Byline', 'wptouch-pro'), 'setup-title-byline', $these_settings, $page_options); // Build admin panel page here wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_GENERAL, __('Regionalization', 'wptouch-pro'), 'setup-regionalization', array(wptouch_add_setting('list', 'force_locale', __('Language', 'wptouch-pro'), wptouchize_it(__('The WPtouch Pro admin panel & supported themes will be shown in this locale.', 'wptouch-pro')), WPTOUCH_SETTING_BASIC, '3.0', wptouch_admin_get_languages())), $page_options); wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_GENERAL, __('Display Mode', 'wptouch-pro'), 'setup-display-mode', array(wptouch_add_setting('radiolist', 'display_mode', __('Mobile theme is visible to', 'wptouch-pro'), '', WPTOUCH_SETTING_BASIC, '3.1', array('normal' => __('All Visitors', 'wptouch-pro'), 'preview' => __('Site administrators', 'wptouch-pro'), 'disabled' => wptouchize_it(__('Nobody (disable WPtouch Pro)', 'wptouch-pro'))))), $page_options); wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_GENERAL, __('Landing Page', 'wptouch-pro'), 'setup-landing-page', array(wptouch_add_setting('radiolist', 'homepage_landing', wptouchize_it(__('WPtouch Pro landing page', 'wptouch-pro')), '', WPTOUCH_SETTING_BASIC, '3.0', array('none' => __('Default (same as desktop visitors)', 'wptouch-pro'), 'select' => __('Redirect to a page', 'wptouch-pro'), 'custom' => _x('Redirect to a custom URL', 'Refers to a custom landing page', 'wptouch-pro'))), wptouch_add_setting('redirect', 'homepage_redirect_wp_target', '', '', WPTOUCH_SETTING_BASIC, '3.0'), wptouch_add_setting('text', 'homepage_redirect_custom_target', __('Custom Slug or URL', 'wptouch-pro'), __('Enter a Slug (i.e. "/home") or a full URL path', 'wptouch-pro'), WPTOUCH_SETTING_BASIC, '3.0')), $page_options); wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_GENERAL, __('Desktop / Mobile Switching', 'wptouch-pro'), 'setup-general', array(wptouch_add_setting('checkbox', 'show_switch_link', __('Show switch link in mobile view', 'wptouch-pro'), __('Will show toggle buttons in the theme\'s footer allowing users to switch to your desktop theme. Is not shown in Web-App Mode.', 'wptouch-pro'), WPTOUCH_SETTING_ADVANCED, '3.0'), wptouch_add_pro_setting('radiolist', 'switch_link_method', __('Desktop theme switch buttons', 'wptouch-pro'), __('Allows visitors to switch from your desktop theme to your mobile theme. You can also customize the placement of Switch buttons by placing the wptouch_desktop_switch_link() template tag somewhere in your desktop theme.', 'wptouch-pro'), WPTOUCH_SETTING_ADVANCED, '3.0', array('automatic' => __('Automatically inserted inline', 'wptouch-pro'), 'ajax' => __('Automatically inserted with AJAX (better for caching)', 'wptouch-pro'), 'template_tag' => __('Template tag', 'wptouch-pro')))), $page_options); wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_GENERAL, __('Custom Code', 'wptouch-pro'), 'setup-custom-code', array(wptouch_add_setting('textarea', 'custom_stats_code', __('HTML, JavaScript, statistics or custom code', 'wptouch-pro'), __('Enter any custom code here to be output in the theme footer.', 'wptouch-pro'), WPTOUCH_SETTING_BASIC, '3.0')), $page_options); if ($settings->custom_css_file != '') { wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_GENERAL, __('Custom Stylesheet', 'wptouch-pro'), 'setup-custom-styles', array(wptouch_add_pro_setting('text', 'custom_css_file', __('URL to a custom CSS file to load', 'wptouch-pro'), __('Useful if you have specific compatibility CSS you need to add.', 'wptouch-pro'), WPTOUCH_SETTING_ADVANCED, '3.0')), $page_options); } wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_COMPAT, __('Shortcodes', 'wptouch-pro'), 'shortcodes-compatibility', array(wptouch_add_pro_setting('checkbox', 'enable_shortcode_compatibility', wptouchize_it(__('Enable shortcode handling', 'wptouch-pro')), __('For shortcodes registered by your desktop theme', 'wptouch-pro'), WPTOUCH_SETTING_BASIC, '3.7'), wptouch_add_pro_setting('radiolist', 'shortcode_compatibility_method', __('Shortcode handling', 'wptouch-pro'), '', WPTOUCH_SETTING_BASIC, '3.7', array('load_content_by_ajax' => wptouchize_it(__('Load content as output by desktop theme (you may need to load CSS/JavaScript)', 'wptouch-pro')), 'remove_shortcodes' => wptouchize_it(__('Remove selected shortcodes from content', 'wptouch-pro')))), wptouch_add_pro_setting('text', 'remove_shortcodes', wptouchize_it(__('Remove these shortcodes when WPtouch Pro is active', 'wptouch-pro')), __('Enter a comma separated list of shortcodes to remove.', 'wptouch-pro'), WPTOUCH_SETTING_BASIC, '3.0')), $page_options); wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_COMPAT, __('Filter URLs', 'wptouch-pro'), 'filtered-urls-compatibility', array(wptouch_add_setting('radiolist', 'url_filter_behaviour', wptouchize_it(__('Load WPtouch Pro for', 'wptouch-pro')), '', WPTOUCH_SETTING_BASIC, '3.5.3', array('disabled' => wptouchize_it(__('All URLs on my site', 'wptouch-pro')), 'exclude_urls' => wptouchize_it(__('All URLs/pages except these', 'wptouch-pro')), 'exclusive_urls' => wptouchize_it(__('Only these URLs/pages', 'wptouch-pro')))), wptouch_add_setting('textarea', 'filtered_urls', wptouchize_it(__('Apply filter to these URLs/Pages', 'wptouch-pro')), __('Each permalink URL fragment should be on its own line and relative, e.g. "/about" or "/products/store"', 'wptouch-pro'), WPTOUCH_SETTING_BASIC, '3.5.3')), $page_options); if ($settings->include_functions_from_desktop_theme) { wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_COMPAT, __('Desktop Theme', 'wptouch-pro'), 'desktop-theme-compatibility', array(wptouch_add_pro_setting('checkbox', 'include_functions_from_desktop_theme', __('Try to include desktop theme functions.php file', 'wptouch-pro'), wptouchize_it(__('This may be required for desktop themes with unique features that are not showing when WPtouch Pro is active.', 'wptouch-pro')), WPTOUCH_SETTING_ADVANCED, '3.0'), wptouch_add_setting('radiolist', 'functions_php_loading_method', __('Method to load file', 'wptouch-pro'), '', WPTOUCH_SETTING_ADVANCED, '3.0', array('direct' => __('Include file directly', 'wptouch-pro'), 'translate' => __('Translate and create new files', 'wptouch-pro')))), $page_options); } wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_COMPAT, __('Custom User-Agents', 'wptouch-pro'), 'custom-user-agents', array(wptouch_add_setting('textarea', 'custom_user_agents', __('User-agents (line separated)', 'wptouch-pro'), wptouchize_it(__('Adding additional user-agents will force WPtouch Pro to be active for matching browsers.', 'wptouch-pro')), WPTOUCH_SETTING_BASIC, '3.0'), wptouch_add_setting('user-agent-list', '')), $page_options); wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_GENERAL, __('JavaScript', 'wptouch-pro'), 'setup-javascript', array(wptouch_add_setting('checkbox', 'use_jquery_2', __('Replace jQuery 1.x with jQuery 2.x in mobile themes (faster for mobile devices)', 'wptouch-pro'), __('jQuery 2.x is significantly smaller and faster than previous jQuery versions - may cause problems with other plugins, use carefully.', 'wptouch-pro'), WPTOUCH_SETTING_ADVANCED, '3.0')), $page_options); wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_GENERAL, __('Backup & Import', 'wptouch-pro'), 'setup-backup', array(wptouch_add_pro_setting('checkbox', 'automatically_backup_settings', sprintf(__('Automatically backup settings to the %s folder', 'wptouch-pro'), '<em>/wptouch-data/backups</em>'), wptouchize_it(__('WPtouch Pro backups your settings each time they are saved.', 'wptouch-pro')), WPTOUCH_SETTING_BASIC, '3.0'), wptouch_add_pro_setting('custom', 'backup')), $page_options); $page_options = apply_filters('wptouch_settings_compat', $page_options); wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_COMPAT, __('WordPress Plugins', 'wptouch-pro'), 'setup-general-plugin-compat', array(wptouch_add_pro_setting('custom', 'plugin-compat')), $page_options); /* TODO: Deprecated wptouch_add_page_section( WPTOUCH_ADMIN_SETUP_GENERAL, __( 'Admin Mode', 'wptouch-pro' ), 'admin-mode', array( wptouch_add_setting( 'radiolist', 'settings_mode', __( 'Admin panel settings shown', 'wptouch-pro' ), '', WPTOUCH_SETTING_BASIC, '3.0', array( '0' => __( 'Default', 'wptouch-pro' ), '1' => __( 'Advanced', 'wptouch-pro' ) ) ) ), $page_options ); */ return $page_options; }
function wptouch_check_api($force_refresh = false) { global $wptouch_pro; $wptouch_pro->setup_bncapi(); $bnc_settings = wptouch_get_settings('bncid'); $last_accepted = $bnc_settings->license_accepted; $current_time = time(); if ($current_time > $bnc_settings->next_update_check_time || $force_refresh) { // Update next check time $bnc_settings->next_update_check_time = $current_time + WPTOUCH_API_CHECK_INTERVAL; $bnc_settings->save(); $result = $wptouch_pro->bnc_api->check_api(); if (isset($result['has_valid_license'])) { if ($result['has_valid_license']) { // The user HAS as valid license $bnc_settings->failures = 0; $bnc_settings->license_accepted = true; $bnc_settings->license_accepted_time = $current_time; $bnc_settings->license_expired = 0; $bnc_settings->license_expiry_date = 0; if ($result['license_expiry_date']) { $bnc_settings->license_expiry_date = $result['license_expiry_date']; } // Check for the user's referral code if (isset($result['user_id'])) { $bnc_settings->referral_user_id = $result['user_id']; } } else { $bnc_settings->license_accepted = false; $bnc_settings->license_accepted_time = 0; if (isset($result['license_expired'])) { $bnc_settings->license_expired = $result['license_expired']; } else { $bnc_settings->license_expired = 0; } if (isset($result['license_expiry_date'])) { $bnc_settings->license_expiry_date = $result['license_expiry_date']; } else { $bnc_settings->license_expiry_date = 0; } } } $bnc_settings->save(); } // We've changed license states here, so clear our theme and add-on transients if ($last_accepted != $bnc_settings->license_accepted || $force_refresh) { delete_transient('_wptouch_available_cloud_addons'); delete_transient('_wptouch_available_cloud_themes'); } }
function foundation_webapp_init() { $settings = foundation_get_settings(); // Do redirect in webapp mode if ($settings->webapp_enable_persistence && wptouch_fdn_is_web_app_mode()) { if (isset($_COOKIE[WPTOUCH_WEBAPP_PERSIST_COOKIE . '-' . foundation_webapp_get_persistence_salt()])) { $current_url = rtrim($_SERVER['HTTP_HOST'] . strtolower($_SERVER['REQUEST_URI']), '/'); $stored_url = str_replace(array('https://', 'http://'), array('', ''), rtrim(strtolower($_COOKIE[WPTOUCH_WEBAPP_PERSIST_COOKIE . '-' . foundation_webapp_get_persistence_salt()]), '/')); if ($current_url != $stored_url && !isset($_COOKIE[WPTOUCH_WEBAPP_COOKIE . '-' . foundation_webapp_get_persistence_salt()]) && empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { $cookie = $_COOKIE[WPTOUCH_WEBAPP_PERSIST_COOKIE . '-' . foundation_webapp_get_persistence_salt()]; header('Location: ' . $cookie); die; } } } if ($settings->webapp_mode_enabled && $settings->webapp_show_notice == true && !wptouch_fdn_is_web_app_mode()) { wp_enqueue_script('foundation_add2home_config', WPTOUCH_URL . '/pro/modules/webapp/add2home-config.js', false, FOUNDATION_VERSION, true); wp_enqueue_script('foundation_add2home', WPTOUCH_URL . '/pro/modules/webapp/add2home.js', array('foundation_add2home_config'), FOUNDATION_VERSION, true); $add_to_home_strings = array('bubbleMessage' => str_replace(array('[device]', '[icon]'), array('%device', '%icon'), $settings->webapp_notice_message), 'bubbleExpiryInDays' => $settings->webapp_notice_expiry_days * 60 * 24); wp_localize_script('foundation_add2home_config', 'wptouchFdnAddToHome', $add_to_home_strings); } if ($settings->webapp_mode_enabled) { wp_enqueue_script('foundation_webapp', WPTOUCH_URL . '/pro/modules/webapp/webapp.js', array('jquery'), FOUNDATION_VERSION, true); $webapp_strings = array(); if ($settings->webapp_ignore_urls) { $ignored_wa_urls = explode("\n", $settings->webapp_ignore_urls); $trimmed_wa_urls = array(); foreach ($ignored_wa_urls as $wa_url) { $trimmed_wa_urls[] = strtolower(trim($wa_url)); } $webapp_strings['ignoredWebAppURLs'] = $trimmed_wa_urls; } $admin_settings = wptouch_get_settings(); if ($admin_settings->ignore_urls) { $ignored_urls = explode("\n", $admin_settings->ignore_urls); $trimmed_urls = array(); foreach ($ignored_urls as $url) { $trimmed_urls[] = strtolower(trim($url)); } $webapp_strings['ignoredURLs'] = $trimmed_urls; } $webapp_strings['externalLinkText'] = __('External link— open it in the browser?', 'wptouch-pro'); $webapp_strings['externalFileText'] = __('File link— Do you want to open it in the browser?', 'wptouch-pro'); $webapp_strings['persistence'] = $settings->webapp_enable_persistence ? '1' : '0'; $webapp_strings['persistenceSalt'] = foundation_webapp_get_persistence_salt(); wp_localize_script('foundation_webapp', 'wptouchWebApp', $webapp_strings); } }
function wptouch_admin_is_list_option_selected() { global $_primed_setting; $settings = wptouch_get_settings($_primed_setting->domain, false); $setting_name = $_primed_setting->name; if (strstr($setting_name, '[')) { // It's an Array! preg_match('/(.*)\\[(.*)\\]/', $setting_name, $setting_info); $setting_name = $setting_info[1]; $setting_key = $setting_info[2]; $setting = $settings->{$setting_name}; return isset($settings->{$setting_name}) && wptouch_admin_get_list_option_key() == $setting[$setting_key]; } else { return isset($settings->{$setting_name}) && wptouch_admin_get_list_option_key() == $settings->{$setting_name}; } }
function foundation_get_tablet_devices($device_classes = false) { $settings = wptouch_get_settings(); $tablet_devices[] = array(); if ($settings->enable_ios_tablet) { $tablet_devices[] = 'iPad'; // Apple iPads } if ($settings->enable_android_tablet) { $tablet_devices[] = array('Android', 'Tablet'); // Catches ALL Android devices/browsers that explicitly state they're tablets $tablet_devices[] = array('Nexus', '7'); // Nexus 7 $tablet_devices[] = 'Xoom'; // Motorola Xoom $tablet_devices[] = 'SCH-I800'; // Galaxy Tab } if ($settings->enable_windows_tablet) { $tablet_devices[] = 'IEMobile/10.0'; // Windows IE 10 touch tablet devices } if ($settings->enable_kindle_tablet) { $tablet_devices[] = 'Kindle'; // Kindles $tablet_devices[] = 'Silk'; // Kindles in Silk mode } if ($settings->enable_blackberry_tablet) { $tablet_devices[] = 'PlayBook'; // BB PlayBook } if ($settings->enable_webos_tablet) { $tablet_devices[] = array('tablet', 'hpwOS'); $tablet_devices[] = array('tablet', 'WebOS'); $tablet_devices[] = 'hp-tablet'; $tablet_devices[] = 'P160U'; // HP TouchPad } if (is_array($device_classes) && isset($device_classes['default'])) { $device_classes['default'] = array_merge($device_classes['default'], $tablet_devices); return $device_classes; } else { return $tablet_devices; } }
function wptouch_wordtwit_get_enabled_accounts() { $enabled_accounts = array(); if (wordtwit_wptouch_has_accounts()) { $accounts = wordtwit_wptouch_get_accounts(); $settings = wptouch_get_settings(); foreach ($accounts as $name => $account) { if (wptouch_wordtwit_current_user_can_use_account($account)) { $setting_name = 'wordtwit_account_' . $name; if (isset($settings->{$setting_name}) && $settings->{$setting_name}) { $enabled_accounts[$name] = $account; } } } } return $enabled_accounts; }
function wptouch_has_plugin_warnings() { global $wptouch_pro; global $wptouch_plugin_warning_iterator; $settings = wptouch_get_settings(); if (!$wptouch_plugin_warning_iterator) { $warnings = apply_filters('wptouch_plugin_warnings', $wptouch_pro->warnings); ksort($warnings); $new_warnings = array(); foreach ($warnings as $key => $value) { if (!in_array($key, $settings->dismissed_warnings)) { $new_warnings[$key] = $value; } } $wptouch_plugin_warning_iterator = new WPtouchArrayIterator($new_warnings); } return $wptouch_plugin_warning_iterator->have_items(); }
function wptouch_backup_settings() { global $wptouch_pro; $backup_domains = $wptouch_pro->get_active_setting_domains(); if (is_array($backup_domains) && count($backup_domains)) { $settings_to_save = array(); foreach ($backup_domains as $domain) { $settings_notused = wptouch_get_settings($domain); $settings = clone $wptouch_pro->settings_objects[$domain]; if (isset($settings->domain)) { unset($settings->domain); } $settings_to_save[$domain] = apply_filters('wptouch_backup_settings', $settings, $domain); } if (isset($settings_to_save['bncid'])) { if (isset($settings_to_save['bncid']->wptouch_license_key)) { //unset( $settings_to_save[ 'bncid' ]->wptouch_license_key ); } if (isset($settings_to_save['bncid']->bncid)) { //unset( $settings_to_save[ 'bncid' ]->bncid ); } } ksort($settings_to_save); $backup_string = base64_encode(gzcompress(serialize($settings_to_save), 9)); $unique_key = ''; if (isset($bnc_settings->license_key)) { $unique_key = $bnc_settings->license; } else { if (defined('AUTH_KEY')) { $unique_key = AUTH_KEY; } } $backup_base_name = 'wptouch-backup-' . md5($unique_key) . '-' . date('Ymd-His') . '.txt'; $backup_file_name = WPTOUCH_BACKUP_DIRECTORY . '/' . $backup_base_name; $backup_file = fopen($backup_file_name, 'w+t'); if ($backup_file) { fwrite($backup_file, $backup_string); fclose($backup_file); } } wptouch_prune_backup_files(); return $backup_base_name; }
function wptouch_admin_is_post_type_checked() { global $_primed_setting; $settings = wptouch_get_settings($_primed_setting->domain); if ($settings) { $name = $_primed_setting->name; preg_match('/\\[(.*?)\\]/', $name, $matches); $matches[0] = str_replace(array('[', ']'), '', $matches[0]); $enabled_custom_post_types = get_option('wptouch_custom_post_types'); if (!is_array($enabled_custom_post_types) && !is_object($enabled_custom_post_types)) { $enabled_post_types = maybe_unserialize(stripslashes($enabled_custom_post_types)); } else { $enabled_post_types = $enabled_custom_post_types; } if (is_array($enabled_post_types) && array_key_exists($matches[0], $enabled_post_types)) { return true; } } return false; }
function wptouch_repair_active_theme_from_cloud(&$error_condition) { global $wptouch_pro; $result = true; $error_condition = false; $settings = wptouch_get_settings(); $wptouch_pro->setup_bncapi(); // We need to download the theme and then repair it $themes = $wptouch_pro->get_available_themes(true); if (isset($themes[$settings->current_theme_friendly_name])) { require_once WPTOUCH_DIR . '/core/addon-theme-installer.php'; $theme_to_install = $themes[$settings->current_theme_friendly_name]; $addon_installer = new WPtouchAddonThemeInstaller(); $result = $addon_installer->install($theme_to_install->base, $theme_to_install->download_url, 'themes'); if ($result) { $wptouch_pro->repair_active_theme(WPTOUCH_BASE_CONTENT_DIR . '/themes', $settings->current_theme_friendly_name); } } return $result; }
function wptouch_render_general_page($page_options) { $settings = wptouch_get_settings(); wptouch_add_sub_page(WPTOUCH_ADMIN_SETUP_GENERAL, 'setup-general-general', $page_options); wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_GENERAL, __('Mobile Site Title', 'wptouch-pro'), 'mobile-site-title', array(wptouch_add_setting('text', 'site_title', wptouchize_it(__('WPtouch Pro site title', 'wptouch-pro')), false, WPTOUCH_SETTING_BASIC, '3.0')), $page_options, 'wptouch_pro', false, false); if (defined('WPTOUCH_IS_FREE')) { $display_text = wptouchize_it(__('If disabled WPtouch Pro will be off for visitors but can be configured.', 'wptouch-pro')); } else { $display_text = wptouchize_it(__('If disabled WPtouch Pro will be off for visitors but can be configured in the Customizer.', 'wptouch-pro')); } wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_GENERAL, __('Display', 'wptouch-pro'), 'filtered-urls-compatibility', array(wptouch_add_setting('checkbox', 'new_display_mode', wptouchize_it(__('Display WPtouch Pro for mobile visitors', 'wptouch-pro')), $display_text, WPTOUCH_SETTING_BASIC, '3.1'), wptouch_add_pro_setting('list', 'url_filter_behaviour', __('URL filtering', 'wptouch-pro'), false, WPTOUCH_SETTING_BASIC, '3.5.3', array('disabled' => wptouchize_it(__('Show WPtouch Pro for all URLs', 'wptouch-pro')), 'exclude_urls' => wptouchize_it(__('Exclude WPtouch Pro on these URLs', 'wptouch-pro')), 'exclusive_urls' => wptouchize_it(__('Only show WPtouch Pro on these URLs', 'wptouch-pro')))), wptouch_add_pro_setting('multiline-newline', 'filtered_urls', __('Apply filter to these URLs/Pages', 'wptouch-pro'), 'e.g. "/about", "/products/store"', WPTOUCH_SETTING_BASIC, '3.5.3'), wptouch_add_pro_setting('checkbox', 'filtered_urls_exact', __('Require exact match', 'wptouch-pro'), false, WPTOUCH_SETTING_BASIC, '3.5.3')), $page_options); $landing_settings = array(wptouch_add_setting('list', 'homepage_landing', __('Mobile front page', 'wptouch-pro'), wptouchize_it(__('You can set a different front page for WPtouch Pro visitors.', 'wptouch-pro')), WPTOUCH_SETTING_BASIC, '3.0', array('none' => __('WordPress Reading Settings', 'wptouch-pro'), 'select' => __('Redirect to a page', 'wptouch-pro'), 'custom' => _x('Redirect to a custom URL', 'Refers to a custom landing page', 'wptouch-pro'))), wptouch_add_setting('text', 'homepage_redirect_custom_target', __('Custom Slug or URL', 'wptouch-pro'), __('Enter a Slug (i.e. "/home") or a full URL path', 'wptouch-pro'), WPTOUCH_SETTING_BASIC, '3.0'), wptouch_add_setting('redirect', 'homepage_redirect_wp_target', false, false, WPTOUCH_SETTING_BASIC, '3.0')); $landing_settings = apply_filters('foundation_settings_pages', $landing_settings); wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_GENERAL, __('Landing Pages', 'wptouch-pro'), 'setup-landing-page', $landing_settings, $page_options, 'wptouch_pro'); wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_GENERAL, __('Desktop / Mobile Switching', 'wptouch-pro'), 'setup-general', array(wptouch_add_pro_setting('checkbox', 'show_switch_link', _x('Theme switch toggle', 'switches between desktop and mobile themes', 'wptouch-pro'), false, WPTOUCH_SETTING_BASIC, '4.0')), $page_options, 'wptouch-pro', false, __('Shows a toggle in both the desktop mobile theme footers allowing users to switch between them.', 'wptouch-pro')); wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_GENERAL, __('Page Zoom', 'wptouch-pro'), 'foundation-zoom', array(wptouch_add_setting('checkbox', 'allow_zoom', __('Allow mobile browser zooming', 'wptouch-pro'), wptouchize_it(__('By default WPtouch Pro disables browser zooming.')), WPTOUCH_SETTING_BASIC, '2.0')), $page_options, FOUNDATION_SETTING_DOMAIN); wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_GENERAL, __('Smart App Banner', 'wptouch-pro'), 'foundation-smart-app-banner', array(wptouch_add_pro_setting('text', 'smart_app_banner', 'App Store ID', false, WPTOUCH_SETTING_BASIC, '2.0')), $page_options, FOUNDATION_SETTING_DOMAIN, false, sprintf(__('Find your ID from the %siTunes Link Maker%s.', 'wptouch-pro'), '<a href="http://itunes.apple.com/linkmaker/" target="_blank">', '</a>')); wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_GENERAL, __('Analytics', 'wptouch-pro'), 'setup-custom-code', array(wptouch_add_pro_setting('list', 'analytics_embed_method', __('Analytics Code', 'wptouch-pro'), false, WPTOUCH_SETTING_BASIC, '4.0', array('disabled' => __('None', 'wptouch-pro'), 'simple' => 'Google Analytics', 'custom' => __('Custom', 'wptouch-pro'))), wptouch_add_pro_setting('text', 'analytics_google_id', __('Site ID', 'wptouch-pro'), false, WPTOUCH_SETTING_BASIC, '3.0'), wptouch_add_pro_setting('textarea', 'custom_stats_code', false, false, WPTOUCH_SETTING_BASIC, '3.0')), $page_options, 'wptouch_pro'); wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_GENERAL, wptouchize_it(__('WPtouch Pro Love', 'wptouch-pro')), 'setup-powered-by', array(wptouch_add_setting('checkbox', 'show_wptouch_in_footer', wptouchize_it(__('Show powered by WPtouch Pro link in theme footer', 'wptouch-pro')), false, WPTOUCH_SETTING_BASIC, '3.0')), $page_options, 'wptouch_pro'); wptouch_add_page_section(WPTOUCH_ADMIN_SETUP_GENERAL, __('Language', 'wptouch-pro'), 'setup-regionalization', array(wptouch_add_setting('list', 'force_locale', __('Theme Language', 'wptouch-pro'), false, WPTOUCH_SETTING_BASIC, '3.0', wptouch_admin_get_languages()), wptouch_add_setting('checkbox', 'translate_admin', __('Also applies to admin', 'wptouch-pro'), false, WPTOUCH_SETTING_BASIC, '3.0')), $page_options, 'wptouch_pro'); return $page_options; }