function wptouch_get_body_classes() { global $wptouch_pro; $body_classes = array(); // Add a class to the body when we're in preview mode, or the preview window if (wptouch_in_preview()) { $body_classes[] = 'preview-mode'; } $colors = foundation_get_theme_colors(); foreach ($colors as $color) { $domain_settings = $wptouch_pro->get_settings($color->domain); if (isset($color->luma_threshold) && $color->luma_threshold != false) { $current_luma = wptouch_hex_to_luma($domain_settings->{$color->setting}); if ($current_luma < $color->luma_threshold) { $body_classes[] = 'dark-' . $color->luma_class; } else { $body_classes[] = 'light-' . $color->luma_class; } } } return implode(' ', apply_filters('wptouch_body_classes', $body_classes)); }
function wptouch_admin_handle_ajax(&$wptouch_pro, $ajax_action) { switch ($ajax_action) { case 'dismiss-warning': $wptouch_pro->check_plugins_for_warnings(); $settings = $wptouch_pro->get_settings(); if ($wptouch_pro->post['plugin']) { if (!in_array($wptouch_pro->post['plugin'], $settings->dismissed_warnings)) { $settings->dismissed_warnings[] = $wptouch_pro->post['plugin']; $settings->save(); } } echo wptouch_get_plugin_warning_count(); break; case 'delete-image-upload': if (isset($wptouch_pro->post['setting_name'])) { $wptouch_pro->update_encoded_setting($wptouch_pro->post['setting_name'], false); echo '0'; } break; case 'delete-custom-icon': if (current_user_can('upload_files')) { if (isset($wptouch_pro->post['icon_name'])) { $icon_location = WPTOUCH_CUSTOM_ICON_DIRECTORY . '/' . $wptouch_pro->post['icon_name']; unlink($icon_location); echo '0'; } } break; case 'load-plugin-compat-list': $wptouch_pro->generate_plugin_hook_list(true); $compat_settings = wptouch_get_settings('compat'); if (is_array($compat_settings->plugin_hooks) && count($compat_settings->plugin_hooks)) { $changed = false; foreach ($compat_settings->plugin_hooks as $name => $value) { if (!isset($compat_settings->enabled_plugins[$name])) { $compat_settings->enabled_plugins[$name] = 1; $changed = true; } } if ($changed) { $compat_settings->save(); } } echo wptouch_capture_include_file(WPTOUCH_DIR . '/admin/settings/html/plugin-compat-ajax.php'); break; case 'prep-settings-download': require_once WPTOUCH_DIR . '/core/admin-backup-restore.php'; $backup_file = wptouch_backup_settings(); echo $backup_file; break; case 'load-upgrade-area': $content = wp_remote_get('http://wptouch-pro-4.s3.amazonaws.com/free-upgrade-area/page.xhtml'); if (!is_wp_error($content)) { echo $content['body']; } break; case 'download-icon-set': global $wptouch_pro; require_once WPTOUCH_DIR . '/core/icon-set-installer.php'; $icon_set_installer = new WPtouchIconSetInstaller(); $icon_set_installer->install($wptouch_pro->post['base'], $wptouch_pro->post['url']); if (file_exists(WPTOUCH_BASE_CONTENT_DIR . '/icons/' . $wptouch_pro->post['base'])) { echo '1'; } else { echo '0'; } break; case 'get-icon-set-info': require_once WPTOUCH_DIR . '/core/admin-icons.php'; echo wptouch_capture_include_file(WPTOUCH_DIR . '/admin/settings/html/installed_icon_sets_ajax.php'); break; case 'admin-change-log': if (!defined('WPTOUCH_IS_FREE')) { $change_log = wp_remote_get(WPTOUCH_PRO_README_FILE); } else { $change_log = wp_remote_get('http://plugins.svn.wordpress.org/wptouch/trunk/readme.txt'); } if (!is_wp_error($change_log)) { $content = $change_log['body']; $result = preg_match_all("#= Version (.*) =(.*)\n=#iUs", $content, $matches); if ($result) { $entries = count($matches[0]); for ($i = 0; $i < $entries; $i++) { echo '<h4 style="font-family: Helvetica, sans-serif">' . sprintf(__('Version %s', 'wptouch-pro'), $matches[1][$i]) . '</h4><ul style="font-family: Helvetica, sans-serif; font-size: 13px">'; echo str_replace('* ', '<li style="padding-top:3px;padding-bottom:3px;">', str_replace("\n", "</li>\n", $matches[2][$i])); echo '</ul>'; } } } else { echo __('There is a temporary issue retrieving the change-log. Please try again later.', 'wptouch-pro'); } break; case 'load-addon-browser': require_once WPTOUCH_DIR . '/admin/settings/html/extension-browser-ajax.php'; break; case 'repair-active-theme': $result = wptouch_repair_active_theme_from_cloud($errors); if (wptouch_migration_is_theme_broken()) { echo '0'; } else { echo '1'; } break; case 'wizard-language': $settings = $wptouch_pro->get_settings(); if ($wptouch_pro->post['force_locale'] && $settings->force_locale != $wptouch_pro->post['force_locale']) { $settings->force_locale = $wptouch_pro->post['force_locale']; $settings->save(); echo '1'; } elseif ($wptouch_pro->post['force_network_locale'] && $settings->force_network_locale != $wptouch_pro->post['force_network_locale']) { $settings->force_network_locale = $wptouch_pro->post['force_network_locale']; $settings->save(); echo '1'; } else { echo '0'; } break; case 'wizard-update-extensions': $result = json_decode(wptouch_update_all_addons()); echo $result['status']; break; case 'wizard-theme': if (isset($wptouch_pro->post['theme'])) { wptouch_activate_theme($wptouch_pro->post['theme']); echo '1'; } else { echo '0'; } break; case 'wizard-extensions': if (isset($wptouch_pro->post['extensions'])) { foreach ($wptouch_pro->post['extensions'] as $extension) { wptouch_activate_addon($extension); } echo '1'; } else { echo '0'; } break; case 'wizard-pages': $settings = $wptouch_pro->get_settings(); if (get_option('show_on_front') == 'page' && isset($wptouch_pro->post['homepage_redirect_wp_target'])) { $settings->homepage_landing = 'select'; $settings->homepage_redirect_wp_target = $wptouch_pro->post['homepage_redirect_wp_target']; } $settings->save(); $settings = $wptouch_pro->get_settings('foundation'); $settings->latest_posts_page = $wptouch_pro->post['latest_posts_page']; $settings->save(); echo '1'; break; case 'wizard-wptouch_message': $settings = $wptouch_pro->get_settings(); if ($wptouch_pro->post['show_wptouch_in_footer'] == 'true') { $wptouch_pro->post['show_wptouch_in_footer'] = 1; } else { $wptouch_pro->post['show_wptouch_in_footer'] = 0; } if (isset($wptouch_pro->post['show_wptouch_in_footer']) && $settings->show_wptouch_in_footer != $wptouch_pro->post['show_wptouch_in_footer']) { $settings->show_wptouch_in_footer = $wptouch_pro->post['show_wptouch_in_footer']; $settings->save(); echo '1'; } else { echo '0'; } break; case 'wizard-scan_for_analytics': $result = wp_remote_get(home_url()); $result_info = array(); if ($result && is_array($result) && isset($result['body'])) { if (preg_match_all('#(<script>.*</script>)#iUs', $result['body'], $match)) { foreach ($match[0] as $possible_analytics) { $search_for = array('GoogleAnalyticsObject'); foreach ($search_for as $search_phrase) { if (preg_match('#' . $search_phrase . '#iU', $possible_analytics, $ga_match)) { // Found Google Analytics code $result_info['code'] = 'found'; $result_info['success'] = sprintf(__('Code found! %s Analytics was automatically configured for you.', 'wptouch-pro'), '<br />'); $result_info['fragment'] = htmlentities($possible_analytics); // If Google, retrieve the site ID if ($search_phrase == 'GoogleAnalyticsObject') { preg_match('/\'(UA-.*?)\'/s', $possible_analytics, $id_match); if (count($id_match) == 2) { $result_info['site_id'] = $id_match[1]; } } break; } } } } } if (is_array($result) && !isset($result_info['code'])) { $result_info['code'] = 'noresult'; $result_info['msg'] = __('Unable to find your Google Analytics code. You can enter it manually in the settings later.', 'wptouch-pro'); } echo json_encode($result_info); break; case 'wizard-analytics': $settings = $wptouch_pro->get_settings(); if ($wptouch_pro->post['analytics_google_id']) { $settings->analytics_google_id = $wptouch_pro->post['analytics_google_id']; $settings->analytics_embed_method = 'simple'; $settings->save(); } break; case 'wizard-multisite': $settings = $wptouch_pro->get_settings('bncid'); if ($wptouch_pro->post['multisite_control'] == 'true') { $wptouch_pro->post['multisite_control'] = 1; } else { $wptouch_pro->post['multisite_control'] = 0; } $settings->multisite_control = $wptouch_pro->post['multisite_control']; $settings->save(); break; case 'network-wizard-complete': $settings = $wptouch_pro->get_settings(); $settings->show_network_wizard = false; $settings->save(); break; case 'wizard-complete': $settings = $wptouch_pro->get_settings(); if (defined('WPTOUCH_IS_FREE')) { $settings->show_free_wizard = false; } else { $settings->show_wizard = false; } $settings->save(); break; case 'activate-license-key': $email = $wptouch_pro->post['email']; $key = $wptouch_pro->post['key']; $settings = wptouch_get_settings('bncid'); $old_settings = $settings; $settings->bncid = $email; $settings->wptouch_license_key = $key; WPTOUCH_DEBUG(WPTOUCH_INFO, "Attempting site activation with email [" . $email . "] and key [" . $key . "]"); $settings->save(); $wptouch_pro->bnc_api = false; $wptouch_pro->setup_bncapi($email, $key, true); // let's try to activate the license $wptouch_pro->activate_license(); // Check to see if the credentials were valid if ($wptouch_pro->bnc_api->response_code >= 406 && $wptouch_pro->bnc_api->response_code <= 408) { WPTOUCH_DEBUG(WPTOUCH_WARNING, "Activation response code was [" . $wptouch_pro->bnc_api->response_code . "]"); echo '2'; } else { if ($wptouch_pro->bnc_api->server_down) { // Server is unreachable for some reason WPTOUCH_DEBUG(WPTOUCH_WARNING, "Activation response code was [SERVER UNREACHABLE]"); echo '4'; } else { if ($wptouch_pro->bnc_api->verify_site_license()) { // Activation successful WPTOUCH_DEBUG(WPTOUCH_WARNING, "Activation successful, response code was [" . $wptouch_pro->bnc_api->response_code . "]"); $settings = wptouch_get_settings('bncid'); $settings->license_accepted = 1; $settings->license_accepted_time = time(); $settings->save(); echo '1'; } else { $bnc_info = $wptouch_pro->bnc_api->check_api(); if (isset($bnc_info['license_expired']) && $bnc_info['license_expired']) { WPTOUCH_DEBUG(WPTOUCH_WARNING, "Failure: license is expired [" . $wptouch_pro->bnc_api->response_code . "]"); echo '5'; } else { // No more licenses - might be triggered another way WPTOUCH_DEBUG(WPTOUCH_WARNING, "Failure: activation response code was [" . $wptouch_pro->bnc_api->response_code . "]"); echo '3'; } } } } break; case 'go-pro': $result = wptouch_free_go_pro(); echo $result; break; case 'multisite_deploy': $source_site = $wptouch_pro->post['source_site']; $current_blog_id = get_current_blog_id(); // Switch to the source site if ($current_blog_id != $source_site) { switch_to_blog($source_site); $wptouch_pro->settings_object = array(); } $main_settings = $wptouch_pro->get_raw_settings('wptouch_pro'); $foundation_settings = $wptouch_pro->get_raw_settings('foundation'); $compat_settings = $wptouch_pro->get_raw_settings('compat'); $colors = foundation_get_theme_colors(); $color_settings = array(); // Deploy color settings foreach ($colors as $color) { if (!isset($color_settings[$color->domain])) { $new_settings = wptouch_get_settings($color->domain); $color_settings[$color->domain] = $new_settings; } } $destination_sites = $wptouch_pro->post['deploy_sites']; foreach ($destination_sites as $site) { $update_customizer = false; $real_site = str_replace('site-', '', $site); restore_current_blog(); switch_to_blog($real_site); $destination_main_settings = $wptouch_pro->get_raw_settings('wptouch_pro'); if (!$destination_main_settings) { $destination_main_settings = $wptouch_pro->get_setting_defaults('wptouch_pro'); $destination_main_settings = 'wptouch_pro'; } $destination_foundation_settings = $wptouch_pro->get_raw_settings('foundation'); if (!$destination_foundation_settings) { $destination_foundation_settings = $wptouch_pro->get_setting_defaults('foundation'); $destination_foundation_settings->domain = 'foundation'; } $destination_compat_settings = $wptouch_pro->get_raw_settings('compat'); if (!$destination_compat_settings) { $destination_compat_settings = $wptouch_pro->get_setting_defaults('compat'); $destination_compat_settings->domain = 'compat'; } if ($wptouch_pro->post['deploy_general']) { // Deploy general settings $destination_main_settings->new_display_mode = $main_settings->new_display_mode; $destination_main_settings->show_switch_link = $main_settings->show_switch_link; $destination_foundation_settings->allow_zoom = $foundation_settings->allow_zoom; $destination_foundation_settings->smart_app_banner = $foundation_settings->smart_app_banner; $destination_main_settings->analytics_embed_method = $main_settings->analytics_embed_method; $destination_main_settings->analytics_google_id = $main_settings->analytics_google_id; $destination_main_settings->custom_stats_code = $main_settings->custom_stats_code; $destination_main_settings->show_wptouch_in_footer = $main_settings->show_wptouch_in_footer; } if ($wptouch_pro->post['deploy_compat']) { // Deploy compatiblitiy settings $destination_main_settings->process_desktop_shortcodes = $main_settings->process_desktop_shortcodes; $destination_main_settings->remove_shortcodes = $main_settings->remove_shortcodes; $destination_compat_settings->plugin_hooks = $compat_settings->plugin_hooks; $destination_compat_settings->enabled_plugins = $compat_settings->enabled_plugins; } if ($wptouch_pro->post['deploy_devices']) { // Deploy device settings $destination_main_settings->enable_ios_phone = $main_settings->enable_ios_phone; $destination_main_settings->enable_android_phone = $main_settings->enable_android_phone; $destination_main_settings->enable_blackberry_phone = $main_settings->enable_blackberry_phone; $destination_main_settings->enable_firefox_phone = $main_settings->enable_firefox_phone; $destination_main_settings->enable_opera_phone = $main_settings->enable_opera_phone; $destination_main_settings->enable_windows_phone = $main_settings->enable_windows_phone; $destination_main_settings->enable_ios_tablet = $main_settings->enable_ios_tablet; $destination_main_settings->enable_android_tablet = $main_settings->enable_android_tablet; $destination_main_settings->enable_windows_tablet = $main_settings->enable_windows_tablet; $destination_main_settings->enable_kindle_tablet = $main_settings->enable_kindle_tablet; $destination_main_settings->enable_blackberry_tablet = $main_settings->enable_blackberry_tablet; $destination_main_settings->enable_webos_tablet = $main_settings->enable_webos_tablet; $destination_main_settings->custom_user_agents = $main_settings->custom_user_agents; } if ($wptouch_pro->post['deploy_menus']) { // Deploy menu settings $destination_main_settings->enable_parent_items = $main_settings->enable_parent_items; $destination_main_settings->enable_menu_icons = $main_settings->enable_menu_icons; } if ($wptouch_pro->post['deploy_themes']) { // Deploy theme settings $destination_main_settings->current_theme_friendly_name = $main_settings->current_theme_friendly_name; $destination_main_settings->current_theme_location = $main_settings->current_theme_location; $destination_main_settings->current_theme_name = $main_settings->current_theme_name; $update_customizer = true; } if ($wptouch_pro->post['deploy_extensions']) { // Deploy extension settings $destination_main_settings->active_addons = $main_settings->active_addons; } if ($wptouch_pro->post['deploy_colors']) { //echo $wptouch_pro->post[ 'deploy_colors' ]; // Deploy color settings $destination_color_settings = array(); foreach ($colors as $color) { if (!isset($destination_color_settings[$color->domain])) { $new_settings = wptouch_get_settings($color->domain); $destination_color_settings[$color->domain] = $new_settings; } } foreach ($colors as $color) { $setting_name = $color->setting; $destination_color_settings[$color->domain]->{$setting_name} = $color_settings[$color->domain]->{$setting_name}; } foreach ($destination_color_settings as $settings_object) { $settings_object->save(); } $update_customizer = true; } if ($wptouch_pro->post['deploy_social_media']) { // Deploy social media settings $destination_foundation_settings->social_facebook_url = $foundation_settings->social_facebook_url; $destination_foundation_settings->social_twitter_url = $foundation_settings->social_twitter_url; $destination_foundation_settings->social_google_url = $foundation_settings->social_google_url; $destination_foundation_settings->social_instagram_url = $foundation_settings->social_instagram_url; $destination_foundation_settings->social_tumblr_url = $foundation_settings->social_tumblr_url; $destination_foundation_settings->social_pinterest_url = $foundation_settings->social_pinterest_url; $destination_foundation_settings->social_vimeo_url = $foundation_settings->social_vimeo_url; $destination_foundation_settings->social_youtube_url = $foundation_settings->social_youtube_url; $destination_foundation_settings->social_linkedin_url = $foundation_settings->social_linkedin_url; $destination_foundation_settings->social_yelp_url = $foundation_settings->social_yelp_url; $destination_foundation_settings->social_email_url = $foundation_settings->social_email_url; $destination_foundation_settings->social_rss_url = $foundation_settings->social_rss_url; $update_customizer = true; } if ($wptouch_pro->post['deploy_social_sharing']) { // Deploy social sharing icons $destination_foundation_settings->show_share = $foundation_settings->show_share; $destination_foundation_settings->share_on_pages = $foundation_settings->share_on_pages; $destination_foundation_settings->share_location = $foundation_settings->share_location; $destination_foundation_settings->share_colour_scheme = $foundation_settings->share_colour_scheme; $update_customizer = true; } $destination_foundation_settings->save(); $destination_main_settings->save(); $destination_compat_settings->save(); if ($update_customizer) { wptouch_initialize_customizer(true); } } // Switch to the original site if ($current_blog_id != $source_site) { restore_current_blog(); } break; default: do_action('wptouch_admin_ajax_' . $ajax_action, $wptouch_pro); do_action('wptouch_admin_ajax_intercept', $ajax_action); break; } }
function foundation_render_theme_settings($page_options) { wptouch_add_sub_page(FOUNDATION_PAGE_GENERAL, 'foundation-page-general', $page_options); wptouch_add_sub_page(FOUNDATION_PAGE_BRANDING, 'foundation-page-branding', $page_options); $foundation_blog_settings = array(wptouch_add_setting('text', 'posts_per_page', __('Number of posts in post listings', 'wptouch-pro'), __('Overrides the WordPress Reading settings for "Blog pages show at most"', 'wptouch-pro'), WPTOUCH_SETTING_BASIC, '1.0'), wptouch_add_setting('text', 'excluded_categories', __('Excluded categories', 'wptouch-pro'), __('Comma separated by category name', 'wptouch-pro'), WPTOUCH_SETTING_BASIC, '1.0'), wptouch_add_setting('text', 'excluded_tags', __('Excluded tags', 'wptouch-pro'), __('Comma separated by tag name', 'wptouch-pro'), WPTOUCH_SETTING_BASIC, '1.0'), wptouch_add_setting('checkbox', 'allow_nested_comment_replies', __('Allow nested comment replies from mobile visitors', 'wptouch-pro'), __('Will show a Reply link after each comment', 'wptouch-pro'), WPTOUCH_SETTING_BASIC, '1.0')); $foundation_blog_settings = apply_filters('foundation_settings_blog', $foundation_blog_settings); wptouch_add_page_section(FOUNDATION_PAGE_GENERAL, __('Blog', 'wptouch-pro'), 'foundation-web-theme-settings', $foundation_blog_settings, $page_options, FOUNDATION_SETTING_DOMAIN); $foundation_page_settings = array(wptouch_add_setting('checkbox', 'show_comments_on_pages', __('Show comments on pages', 'wptouch-pro'), __('Overrides the WordPress settings for showing comments on pages.', 'wptouch-pro'), WPTOUCH_SETTING_BASIC, '1.0')); $foundation_page_settings = apply_filters('foundation_settings_pages', $foundation_page_settings); wptouch_add_page_section(FOUNDATION_PAGE_GENERAL, __('Pages', 'wptouch-pro'), 'foundation-pages', $foundation_page_settings, $page_options, FOUNDATION_SETTING_DOMAIN); wptouch_add_sub_page(FOUNDATION_PAGE_HOMESCREEN_ICONS, 'foundation-page-homescreen-icons', $page_options); /* Homescreen Icon Area */ wptouch_add_page_section(FOUNDATION_PAGE_HOMESCREEN_ICONS, __('Icon Title', 'wptouch-pro'), 'admin_menu_homescreen_icons_options', array(wptouch_add_pro_setting('text', 'homescreen_icon_title', __('Icon title', 'wptouch-pro'), __('When visitors bookmark your website, this will be the title shown.', 'wptouch-pro'), WPTOUCH_SETTING_BASIC, '1.0')), $page_options, FOUNDATION_SETTING_DOMAIN); wptouch_add_page_section(FOUNDATION_PAGE_HOMESCREEN_ICONS, __('Android', 'wptouch-pro'), 'admin_menu_homescreen_android', array(wptouch_add_setting('image-upload', 'android_others_icon', sprintf(__('%d by %d pixels (PNG)', 'wptouch-pro'), 96, 96), '', WPTOUCH_SETTING_BASIC, '2.0')), $page_options, FOUNDATION_SETTING_DOMAIN); wptouch_add_page_section(FOUNDATION_PAGE_HOMESCREEN_ICONS, __('iPhone & iPod touch', 'wptouch-pro'), 'admin_menu_homescreen_iphone_android_retina', array(wptouch_add_setting('image-upload', 'iphone_icon_retina', sprintf(__('%d by %d pixels (PNG)', 'wptouch-pro'), 180, 180), '', WPTOUCH_SETTING_BASIC, '2.0')), $page_options, FOUNDATION_SETTING_DOMAIN); if (foundation_has_theme_colors()) { $color_settings = array(); $colors = foundation_get_theme_colors(); foreach ($colors as $name => $color) { $color_settings[] = wptouch_add_setting('color', $color->setting, $color->desc, '', WPTOUCH_SETTING_BASIC, '1.0', '', $color->domain); } wptouch_add_page_section(FOUNDATION_PAGE_BRANDING, __('Theme Colors', 'wptouch-pro'), 'foundation-colors', $color_settings, $page_options, FOUNDATION_SETTING_DOMAIN); } $foundation_logo_settings = array(wptouch_add_setting('image-upload', 'logo_image', __('(Scaled by themes to fit logo areas as needed)', 'wptouch-pro'), '', WPTOUCH_SETTING_BASIC, '1.0')); $foundation_logo_settings = apply_filters('foundation_settings_logo', $foundation_logo_settings); wptouch_add_page_section(FOUNDATION_PAGE_BRANDING, __('Site Logo', 'wptouch-pro'), 'foundation-logo', $foundation_logo_settings, $page_options, FOUNDATION_SETTING_DOMAIN); wptouch_add_page_section(FOUNDATION_PAGE_BRANDING, __('Smart App Banner', 'wptouch-pro'), 'foundation-smart-app-banner', array(wptouch_add_setting('text', 'smart_app_banner', sprintf(__('Enter your app\'s %sApp Store ID%s', 'wptouch-pro'), '<a href="http://itunes.apple.com/linkmaker/" target="_blank">', '</a>'), __('Your app\'s unique identifier. Find your ID from the iTunes Link Maker: Search for your app. In the link it provides, your app ID is the nine-digit number in between id and ?mt. For example Angry Birds\'s ID is 343200656.', 'wptouch-pro'), WPTOUCH_SETTING_ADVANCED, '1.0')), $page_options, FOUNDATION_SETTING_DOMAIN); wptouch_add_page_section(FOUNDATION_PAGE_BRANDING, __('Theme Footer', 'wptouch-pro'), 'foundation-custom-content', array(wptouch_add_setting('textarea', 'custom_footer_message', __('Custom footer content (HTML is allowed)', 'wptouch-pro'), __('You can add custom footer content that will be displayed below the switch link.', 'wptouch-pro'), WPTOUCH_SETTING_BASIC, '1.0')), $page_options, FOUNDATION_SETTING_DOMAIN); // No settings added to this by Foundation wptouch_add_sub_page(FOUNDATION_PAGE_CUSTOM, 'foundation-page-custom', $page_options); return $page_options; }
function foundation_render_theme_settings($page_options) { wptouch_add_sub_page(FOUNDATION_PAGE_GENERAL, 'foundation-page-theme-settings', $page_options); if (!wptouch_admin_use_customizer()) { if (foundation_has_theme_colors()) { $color_settings = array(); $colors = foundation_get_theme_colors(); foreach ($colors as $name => $color) { $color_settings[] = wptouch_add_setting('color', $color->setting, $color->desc, '', WPTOUCH_SETTING_BASIC, '1.0', '', $color->domain); } wptouch_add_page_section(FOUNDATION_PAGE_BRANDING, __('Theme Colors', 'wptouch-pro'), 'foundation-colors', $color_settings, $page_options, FOUNDATION_SETTING_DOMAIN, false, false, 20); } } $foundation_blog_settings = array(wptouch_add_pro_setting('range', 'posts_per_page', __('Number of posts in post listings', 'wptouch-pro'), __('Overrides the WordPress Reading settings for "Blog pages show at most"', 'wptouch-pro'), WPTOUCH_SETTING_BASIC, '1.0', array('min' => 1, 'max' => 15, 'step' => 1)), wptouch_add_pro_setting('text', 'excluded_categories', __('Excluded categories', 'wptouch-pro'), __('Comma separated by category name', 'wptouch-pro'), WPTOUCH_SETTING_BASIC, '1.0'), wptouch_add_pro_setting('text', 'excluded_tags', __('Excluded tags', 'wptouch-pro'), __('Comma separated by tag name', 'wptouch-pro'), WPTOUCH_SETTING_BASIC, '1.0')); $foundation_blog_settings = apply_filters('foundation_settings_blog', $foundation_blog_settings); $foundation_page_settings = apply_filters('foundation_settings_page', array()); wptouch_add_page_section(FOUNDATION_PAGE_GENERAL, __('Blog', 'wptouch-pro'), 'foundation-web-theme-settings', $foundation_blog_settings, $page_options, FOUNDATION_SETTING_DOMAIN, true); wptouch_add_page_section(FOUNDATION_PAGE_GENERAL, __('Pages', 'wptouch-pro'), 'foundation-page-settings', $foundation_page_settings, $page_options, FOUNDATION_SETTING_DOMAIN, true); if (!function_exists('has_site_icon')) { wptouch_add_page_section(FOUNDATION_PAGE_GENERAL, __('Site Icon', 'wptouch-pro'), 'admin_menu_homescreen_android', array(wptouch_add_setting('image-upload', 'iphone_icon_retina', sprintf(__('%d by %d pixels (PNG)', 'wptouch-pro'), 192, 192), false, WPTOUCH_SETTING_BASIC, '2.0')), $page_options, FOUNDATION_SETTING_DOMAIN, true, false, 30); } $foundation_header_settings = array(wptouch_add_setting('image-upload', 'logo_image', __('Site Logo', 'wptouch-pro'), false, WPTOUCH_SETTING_BASIC, false, '1.0')); $foundation_header_settings = apply_filters('foundation_settings_header', $foundation_header_settings); wptouch_add_page_section(FOUNDATION_PAGE_BRANDING, __('Header', 'wptouch-pro'), 'foundation-header', $foundation_header_settings, $page_options, FOUNDATION_SETTING_DOMAIN, true, false, 10); wptouch_add_page_section(FOUNDATION_PAGE_BRANDING, __('Footer', 'wptouch-pro'), 'foundation-custom-content', array(wptouch_add_setting('textarea', 'custom_footer_message', __('Custom footer content (HTML is allowed)', 'wptouch-pro'), false, WPTOUCH_SETTING_BASIC, '1.0')), $page_options, FOUNDATION_SETTING_DOMAIN, true, false, 70); wptouch_add_page_section(FOUNDATION_PAGE_BRANDING, __('Custom CSS', 'wptouch-pro'), 'foundation-custom-css-declarations', array(wptouch_add_setting('textarea', 'custom_css_declarations', __('Custom CSS Declarations', 'wptouch-pro'), false, WPTOUCH_SETTING_BASIC, '4.0')), $page_options, FOUNDATION_SETTING_DOMAIN, true, false, 80); return $page_options; }
function wptouch_customizer_ajax_callbacks() { ?> <script type="text/javascript"> function wptouchCustomizerGetLuma( hexvalue ) { var c = hexvalue.substring(1); // strip # var rgb = parseInt(c, 16); // convert rrggbb to decimal var r = (rgb >> 16) & 0xff; // extract red var g = (rgb >> 8) & 0xff; // extract green var b = (rgb >> 0) & 0xff; // extract blue return 0.2126 * r + 0.7152 * g + 0.0722 * b; // per ITU-R BT.709' } ( function( jQuery ){ <?php if (foundation_has_theme_colors()) { $colors = foundation_get_theme_colors(); foreach ($colors as $color) { ?> wp.customize('wptouch_<?php echo $color->setting; ?> ',function( value ) { value.bind( function( to ) { <?php if ($color->fg_selectors) { ?> jQuery( '<?php echo $color->fg_selectors; ?> ' ).css('color', to ? to : '' ); <?php } ?> <?php if ($color->bg_selectors) { ?> jQuery( '<?php echo $color->bg_selectors; ?> ' ).css('background-color', to ? to : '' ); <?php } ?> <?php if ($color->luma_threshold) { ?> if ( wptouchCustomizerGetLuma( to ) < <?php echo $color->luma_threshold; ?> ) { jQuery( 'body' ).removeClass( 'light-<?php echo $color->luma_class; ?> ' ); jQuery( 'body' ).addClass( 'dark-<?php echo $color->luma_class; ?> ' ); } else { jQuery( 'body' ).addClass( 'light-<?php echo $color->luma_class; ?> ' ); jQuery( 'body' ).removeClass( 'dark-<?php echo $color->luma_class; ?> ' ); } <?php } ?> }); }); <?php } } ?> } )( jQuery ) </script> <?php }