function foundation_advertising_init() { if (!foundation_advertising_enabled()) { return; } $settings = foundation_get_settings(); // Can't use WP is_single(), etc. functions here if ($settings->advertising_blog_listings || $settings->advertising_single || $settings->advertising_pages || $settings->advertising_taxonomy || $settings->advertising_search) { switch ($settings->advertising_location) { case 'footer': add_action('wptouch_advertising_bottom', 'foundation_handle_advertising'); break; case 'header': add_action('wptouch_advertising_top', 'foundation_handle_advertising'); break; case 'top-content': add_filter('the_content', 'foundation_handle_advertising_content_top'); break; case 'bottom-content': add_filter('the_content', 'foundation_handle_advertising_content_bottom'); break; default: WPTOUCH_DEBUG(WPTOUCH_WARNING, 'Unknown advertising location: ' . $settings->advertising_location); break; } } }
function do_api_request($method, $command, $params = array(), $do_auth = false) { $url = BNC_API_URL . "/{$method}/{$command}/"; // Always use the PHP serialization method for data $params['format'] = 'php'; if (is_multisite()) { $params['multisite'] = 1; $params['site_id'] = get_current_blog_id(); $params['network_activated'] = is_plugin_active_for_network(WPTOUCH_PLUGIN_SLUG) ? '1' : '0'; $params['network_controlled'] = wptouch_is_controlled_network() ? '1' : '0'; } else { $params['multisite'] = 0; } if ($do_auth && $this->might_have_license) { // Sort the parameters ksort($params); // Generate a string to use for authorization $auth_string = ''; foreach ($params as $key => $value) { $auth_string = $auth_string . $key . $value; } WPTOUCH_DEBUG(WPTOUCH_INFO, 'Auth string [' . $auth_string . '], Key [' . $this->license_key . ']'); // Create the authorization hash using the server nonce and the license key $params['auth'] = md5($auth_string . $this->license_key); } $body_params = array(); foreach ($params as $key => $value) { $body_params[] = $key . '=' . urlencode($value); } $body = implode('&', $body_params); $options = array('method' => 'POST', 'timeout' => BNC_API_TIMEOUT, 'body' => $body); $options['headers'] = array('Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'), 'Content-Length' => strlen($body), 'User-Agent' => 'WordPress/' . get_bloginfo("version") . '/WPtouch-Pro/' . WPTOUCH_VERSION, 'Referer' => get_bloginfo("url")); $this->attempts++; WPTOUCH_DEBUG(WPTOUCH_INFO, 'Attempting to connect to URL: ' . $url); $raw_response = wp_remote_request($url, $options); if (!is_wp_error($raw_response)) { if ($raw_response['response']['code'] == 200) { // echo "\n\n" . $raw_response[ 'body' ] . "\n\n"; die; $result = unserialize($raw_response['body']); $this->response_code = $result['code']; return $result; } else { WPTOUCH_DEBUG(WPTOUCH_WARNING, "Unable to connect to server. Response code is " . $raw_response['response']['code']); return false; } } else { $this->server_down = true; return false; } }
function do_api_request($method, $command, $params = array(), $do_auth = false) { $url = BNC_API_URL . "/{$method}/{$command}/"; // Always use the PHP serialization method for data $params['format'] = 'php'; /* if ( !$this->bncid || !$this->license_key ) { return false; } */ if ($do_auth && $this->might_have_license) { // Add the timestamp into the request, offseting it by the difference between this server's time and the BNC server's time $params['timestamp'] = time() + $this->time_variance; // Sort the parameters ksort($params); // Generate a string to use for authorization $auth_string = ''; foreach ($params as $key => $value) { $auth_string = $auth_string . $key . $value; } WPTOUCH_DEBUG(WPTOUCH_INFO, 'Auth string [' . $auth_string . '], Key [' . $this->license_key . ']'); // Create the authorization hash using the server nonce and the license key $params['auth'] = md5($auth_string . $this->license_key); } $body_params = array(); foreach ($params as $key => $value) { $body_params[] = $key . '=' . urlencode($value); } $body = implode('&', $body_params); $options = array('method' => 'POST', 'timeout' => BNC_API_TIMEOUT, 'body' => $body); $options['headers'] = array('Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'), 'Content-Length' => strlen($body), 'User-Agent' => 'WordPress/' . get_bloginfo("version") . '/WPtouch-Pro', 'Referer' => get_bloginfo("url")); $this->attempts++; $raw_response = wp_remote_request($url, $options); if (!is_wp_error($raw_response)) { if ($raw_response['response']['code'] == 200) { $result = unserialize($raw_response['body']); $this->response_code = $result['code']; return $result; } else { WPTOUCH_DEBUG(WPTOUCH_WARNING, "Unable to connect to server. Response code is " . $raw_response['response']['code']); return false; } } else { $this->server_down = true; return false; } }
function wptouch_check_api() { global $wptouch_pro; $wptouch_pro->setup_bncapi(); $bnc_settings = wptouch_get_settings('bncid'); WPTOUCH_DEBUG(WPTOUCH_INFO, 'Checking BNC API to make sure it is working properly'); $now = time(); if ($now > $bnc_settings->next_update_check_time) { WPTOUCH_DEBUG(WPTOUCH_INFO, '...performing update'); $result = $wptouch_pro->bnc_api->check_api(); if (isset($result['has_valid_license'])) { if (!$result['has_valid_license']) { WPTOUCH_DEBUG(WPTOUCH_INFO, '...DOES NOT appear to have a valid license'); if ($bnc_settings->license_accepted) { $bnc_settings->failures = $bnc_settings->failures + 1; WPTOUCH_DEBUG(WPTOUCH_INFO, '......this is failure #' . $bnc_settings->failures); if ($bnc_settings->failures >= WPTOUCH_API_CHECK_FAILURES) { $bnc_settings->failures = 0; $bnc_settings->license_accepted = false; $bnc_settings->license_accepted_time = 0; $bnc_settings->save(); } } } else { WPTOUCH_DEBUG(WPTOUCH_INFO, '...user DOES HAVE a valid license'); $bnc_settings->failures = 0; $bnc_settings->license_accepted = true; $bnc_settings->license_accepted_time = $now; } } else { WPTOUCH_DEBUG(WPTOUCH_INFO, '...no info? ' . print_r($result, true)); } WPTOUCH_DEBUG(WPTOUCH_INFO, '...saving updated BNCID settings' . print_r($bnc_settings, true)); $bnc_settings->next_update_check_time = $now + WPTOUCH_API_CHECK_INTERVAL; $bnc_settings->save(); } }
function wptouch_free_upgrade_plugin() { global $wptouch_pro; $wptouch_pro->bnc_api = false; $settings = wptouch_get_settings('bncid'); $wptouch_pro->setup_bncapi($settings->bncid, $settings->wptouch_license_key, true); $bnc_api = $wptouch_pro->get_bnc_api(); $plugin_name = 'wptouch/wptouch.php'; // Check for WordPress 3.0 function if (function_exists('is_super_admin')) { $option = get_site_transient('update_plugins'); } else { $option = function_exists('get_transient') ? get_transient('update_plugins') : get_option('update_plugins'); } $version_available = false; $latest_info = $bnc_api->get_product_version(); if ($latest_info && $latest_info['version'] != WPTOUCH_VERSION) { WPTOUCH_DEBUG(WPTOUCH_INFO, 'A new product update is available [' . $latest_info['version'] . ']'); if (isset($latest_info['upgrade_url']) && wptouch_has_license()) { if (!isset($option->response[$plugin_name])) { $option->response[$plugin_name] = new stdClass(); } // Update upgrade options $option->response[$plugin_name]->url = 'http://www.wptouch.com/'; $option->response[$plugin_name]->package = $latest_info['upgrade_url']; $option->response[$plugin_name]->new_version = $latest_info['version']; $option->response[$plugin_name]->id = '0'; $option->response[$plugin_name]->slug = WPTOUCH_ROOT_NAME; } else { if (is_object($option) && isset($option->response)) { unset($option->response[$plugin_name]); } } $wptouch_pro->latest_version_info = $latest_info; $upgrade_available = $latest_info['version']; } else { if (is_object($option) && isset($option->response)) { unset($option->response[$plugin_name]); } } if (isset($option->response[$plugin_name])) { // WordPress 3.0 changed some stuff, so we check for a WP 3.0 function if (function_exists('is_super_admin')) { set_site_transient('update_plugins', $option); } else { if (function_exists('set_transient')) { set_transient('update_plugins', $option); } } // Do Upgrade include_once ABSPATH . 'wp-admin/includes/admin.php'; include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin()); $upgrader->upgrade('wptouch/wptouch.php'); if (is_array($upgrader->skin->result)) { deactivate_plugins('wptouch/wptouch.php'); $new_plugin_identifier = 'wptouch-pro/wptouch-pro.php'; $active_plugins = get_option('active_plugins', array()); if (!in_array($new_plugin_identifier, $active_plugins)) { $active_plugins[] = $new_plugin_identifier; update_option('active_plugins', $active_plugins); } return '1'; } else { return '0'; } } else { return '0'; } }
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 wptouch_recursive_copy($source_dir, $dest_dir) { $src_dir = @opendir($source_dir); if ($src_dir) { while (($f = readdir($src_dir)) !== false) { if ($f == '.' || $f == '..') { continue; } $cur_file = $source_dir . '/' . $f; if (is_dir($cur_file)) { if (!wp_mkdir_p($dest_dir . '/' . $f)) { WPTOUCH_DEBUG(WPTOUCH_WARNING, "Unable to create directory " . $dest_dir . '/' . $f); } wptouch_recursive_copy($source_dir . '/' . $f, $dest_dir . '/' . $f); } else { $dest_file = $dest_dir . '/' . $f; $src = @fopen($cur_file, 'rb'); if ($src) { $dst = fopen($dest_file, 'w+b'); if ($dst) { while (!feof($src)) { $contents = fread($src, 8192); fwrite($dst, $contents); } fclose($dst); } else { WPTOUCH_DEBUG(WPTOUCH_ERROR, 'Unable to open ' . $dest_file . ' for writing'); } fclose($src); } else { WPTOUCH_DEBUG(WPTOUCH_ERROR, 'Unable to open ' . $cur_file . ' for reading'); } } } closedir($src_dir); } }
function wptouch_plugins_disable($wptouch_pro, $settings) { foreach ($settings->plugin_hooks as $name => $hook_info) { if ($name == 'ignore') { continue; } if (isset($settings->enabled_plugins[$name]) && !$settings->enabled_plugins[$name]) { if ($name == 'jetpack') { // Likes remove_filter('the_content', array('Jetpack_Likes', 'post_likes'), 30, 1); remove_filter('post_flair', array('Jetpack_Likes', 'post_likes'), 30, 1); remove_filter('wp_footer', array('Jetpack_Likes', 'likes_master')); remove_action('init', array('Jetpack_Likes', 'action_init')); // Sharing remove_filter('the_content', 'sharing_display', 19); remove_filter('the_excerpt', 'sharing_display', 19); add_filter('option_sharedaddy_disable_resources', 'wptouch_return_false'); add_filter('sharing_show', 'wptouch_return_false'); // Related Posts add_action('wp', 'wptouch_remove_jetpack_related'); } if (isset($hook_info->filters) && count($hook_info->filters)) { foreach ($hook_info->filters as $hooks) { WPTOUCH_DEBUG(WPTOUCH_VERBOSE, "Disable filter [" . $hooks->hook . "] with function [" . $hooks->hook_function . "]"); if ($hooks->priority) { remove_filter($hooks->hook, $hooks->hook_function, $hooks->priority); } else { remove_filter($hooks->hook, $hooks->hook_function); } } } if (isset($hook_info->actions) && count($hook_info->actions)) { foreach ($hook_info->actions as $hooks) { WPTOUCH_DEBUG(WPTOUCH_VERBOSE, "Disable action [" . $hooks->hook . "] with function [" . $hooks->hook_function . "]"); if ($hooks->priority) { remove_action($hooks->hook, $hooks->hook_function, $hooks->priority); } else { remove_action($hooks->hook, $hooks->hook_function); } } } } } }
function save_settings($settings, $domain = 'wptouch_pro') { if ($domain == 'wptouch_pro') { $settings = apply_filters('wptouch_update_settings', $settings); } // 3.0 domain specific filtering $settings = apply_filters('wptouch_update_settings_domain', $settings, $domain); if ($domain == 'bncid') { WPTOUCH_DEBUG(WPTOUCH_VERBOSE, 'Saving settings to database with domain ' . $domain . " " . print_r($settings, true)); } // Save the old domain $old_domain = $settings->domain; unset($settings->domain); // From development if (isset($settings->site_wide)) { unset($settings->site_wide); } $setting_name = $this->get_wp_setting_name_for_domain($domain); if ($this->is_domain_site_wide($domain)) { WPTOUCH_DEBUG(WPTOUCH_VERBOSE, 'Saving site wide option for domain ' . $domain); update_site_option($setting_name, $settings); } else { WPTOUCH_DEBUG(WPTOUCH_VERBOSE, 'Saving non-site wide option for domain ' . $domain); update_option($setting_name, $settings); } // Restore old domain $settings->domain = $old_domain; require_once WPTOUCH_DIR . '/core/menu.php'; $this->settings_objects[$domain] = $settings; do_action('wptouch_update_settings_domain_' . $domain); }
function wptouch_settings_process($wptouch_pro) { if (isset($wptouch_pro->post['wptouch-reset-3'])) { $wptouch_pro->verify_post_nonce(); // Clear the cookie setcookie('wptouch-admin-menu', 0, time() - 3600); WPTOUCH_DEBUG(WPTOUCH_INFO, "Settings are being reset"); $wptouch_pro->erase_all_settings(); $wptouch_pro->reset_icon_states(); $wptouch_pro->reload_settings(); require_once WPTOUCH_DIR . '/core/menu.php'; // Check for multisite reset if (wptouch_is_multisite_enabled() && wptouch_is_multisite_primary()) { delete_site_option(WPTOUCH_MULTISITE_LICENSED); } $wptouch_pro->redirect_to_page(admin_url('admin.php?page=wptouch-admin-touchboard')); wptouch_delete_all_transients(); } else { if (isset($wptouch_pro->post['wptouch-submit-3'])) { $wptouch_pro->verify_post_nonce(); if (isset($wptouch_pro->post['wptouch_restore_settings']) && strlen($wptouch_pro->post['wptouch_restore_settings'])) { require_once 'admin-backup-restore.php'; wptouch_restore_settings($wptouch_pro->post['wptouch_restore_settings']); return; } $new_settings = array(); $modified_domains = array(); // Search for all the settings to update foreach ($wptouch_pro->post as $key => $content) { if (preg_match('#^wptouch__(.*)__(.*)#', $key, $match)) { $setting_domain = $match[1]; $setting_name = $match[2]; // Decode slashes on strings if (is_string($content)) { $content = htmlspecialchars_decode($content); } $new_settings[$setting_domain][$setting_name] = apply_filters('wptouch_modify_setting__' . $setting_domain . '__' . $setting_name, $content); // Flag which domains have been modified $modified_domains[$setting_domain] = 1; if (isset($wptouch_pro->post['hid-wptouch__' . $match[1] . '__' . $match[2]])) { // This is a checkbox $new_settings[$setting_domain][$setting_name] = 1; } } } // Do a loop and find all the checkboxes that should be disabled foreach ($wptouch_pro->post as $key => $content) { if (preg_match('#^hid-wptouch__(.*)__(.*)#', $key, $match)) { $setting_domain = $match[1]; $setting_name = $match[2]; $new_settings[$setting_domain][$setting_name] = isset($new_settings[$setting_domain][$setting_name]) ? 1 : 0; $modified_domains[$setting_domain] = 1; } } // Update all the domains that have been modified foreach ($modified_domains as $domain => $ignored_value) { $settings = $wptouch_pro->get_settings($domain); // Update settings with new values foreach ($new_settings[$domain] as $key => $value) { if (isset($settings->{$key})) { $settings->{$key} = $value; } } $settings->save(); } // Handle automatic backup $settings = wptouch_get_settings(); if ($settings->automatically_backup_settings) { require_once 'admin-backup-restore.php'; wptouch_backup_settings(); } wptouch_delete_all_transients(); } } }
function get_license_reset_info($product_name) { if ($this->internal_check_token()) { $params = array(); $params['bncid'] = $this->bncid; $params['product_name'] = $product_name; WPTOUCH_DEBUG(WPTOUCH_INFO, "Getting license reset information"); $result = $this->do_api_request('user', 'get_license_reset_info', $params, true); if ($result) { if ($result['status'] == 'ok') { return $result['result']; } } } return false; }
function wptouch_pro_check_for_update() { global $wptouch_pro; $upgrade_available = WPTOUCH_VERSION; $wptouch_pro->setup_bncapi(); $bnc_api = $wptouch_pro->get_bnc_api(); $plugin_name = WPTOUCH_ROOT_NAME . '/wptouch-pro.php'; WPTOUCH_DEBUG(WPTOUCH_INFO, 'Checking BNC server for a new product update'); // Check for WordPress 3.0 function if (function_exists('is_super_admin')) { $option = get_site_transient('update_plugins'); } else { $option = function_exists('get_transient') ? get_transient('update_plugins') : get_option('update_plugins'); } $version_available = false; if (false === ($latest_info = get_site_transient('_wptouch_bncid_latest_version'))) { $latest_info = $bnc_api->get_product_version(); set_site_transient('_wptouch_bncid_latest_version', $latest_info, WPTOUCH_API_GENERAL_CACHE_TIME); } if ($latest_info && $latest_info['version'] != WPTOUCH_VERSION) { WPTOUCH_DEBUG(WPTOUCH_INFO, 'A new product update is available [' . $latest_info['version'] . ']'); if (isset($latest_info['upgrade_url']) && wptouch_has_license()) { if (!isset($option->response[$plugin_name])) { $option->response[$plugin_name] = new stdClass(); } // Update upgrade options $option->response[$plugin_name]->url = 'http://www.wptouch.com/'; $option->response[$plugin_name]->package = $latest_info['upgrade_url']; $option->response[$plugin_name]->new_version = $latest_info['version']; $option->response[$plugin_name]->id = '0'; $option->response[$plugin_name]->slug = WPTOUCH_ROOT_NAME; } else { if (is_object($option) && isset($option->response)) { unset($option->response[$plugin_name]); } } $wptouch_pro->latest_version_info = $latest_info; $upgrade_available = $latest_info['version']; } else { if (is_object($option) && isset($option->response)) { unset($option->response[$plugin_name]); } } // WordPress 3.0 changed some stuff, so we check for a WP 3.0 function if (function_exists('is_super_admin')) { set_site_transient('update_plugins', $option); } else { if (function_exists('set_transient')) { set_transient('update_plugins', $option); } } return $upgrade_available; }
function wptouch_plugins_disable($wptouch_pro, $settings) { foreach ($settings->plugin_hooks as $name => $hook_info) { if ($name == 'ignore') { continue; } if (isset($settings->enabled_plugins[$name]) && !$settings->enabled_plugins[$name]) { if (isset($hook_info->filters) && count($hook_info->filters)) { foreach ($hook_info->filters as $hooks) { WPTOUCH_DEBUG(WPTOUCH_VERBOSE, "Disable filter [" . $hooks->hook . "] with function [" . $hooks->hook_function . "]"); if ($hooks->priority) { remove_filter($hooks->hook, $hooks->hook_function, $hooks->priority); } else { remove_filter($hooks->hook, $hooks->hook_function); } } } if (isset($hook_info->actions) && count($hook_info->actions)) { foreach ($hook_info->actions as $hooks) { WPTOUCH_DEBUG(WPTOUCH_VERBOSE, "Disable action [" . $hooks->hook . "] with function [" . $hooks->hook_function . "]"); if ($hooks->priority) { remove_action($hooks->hook, $hooks->hook_function, $hooks->priority); } else { remove_action($hooks->hook, $hooks->hook_function); } } } } } }
function recursive_delete($source_dir) { // Only allow a delete to occur for directories in the main WPtouch data directory if (strpos($source_dir, '..') !== false || strpos($source_dir, WPTOUCH_BASE_CONTENT_DIR) === false) { WPTOUCH_DEBUG(WPTOUCH_SECURITY, 'Not deleting directory ' . $source_dir . ' due to possibly security risk'); return; } $src_dir = @opendir($source_dir); if ($src_dir) { while (($f = readdir($src_dir)) !== false) { if ($f == '.' || $f == '..') { continue; } $cur_file = $source_dir . '/' . $f; if (is_dir($cur_file)) { $this->recursive_delete($cur_file); @rmdir($cur_file); } else { @unlink($cur_file); } } closedir($src_dir); @rmdir($src_dir); } }