function wptouch_pro_handle_admin_command() { global $wptouch_pro; if (isset($wptouch_pro->get['admin_command'])) { $admin_menu_nonce = $wptouch_pro->get['admin_menu_nonce']; if (wptouch_admin_menu_nonce_is_valid($admin_menu_nonce)) { // check user permissions if (current_user_can('switch_themes')) { switch ($wptouch_pro->get['admin_command']) { case 'activate_theme': WPTOUCH_DEBUG(WPTOUCH_INFO, 'Activating theme [' . $wptouch_pro->get['theme_name'] . ']'); wptouch_pro_activate_theme($wptouch_pro->get['theme_name'], $wptouch_pro->get['theme_location']); break; case 'activate_addon': WPTOUCH_DEBUG(WPTOUCH_INFO, 'Activating add-on [' . $wptouch_pro->get['addon_name'] . ']'); $addon_to_activate = $wptouch_pro->get['addon_name']; if ($addon_to_activate) { $settings = $wptouch_pro->get_settings(); if (!isset($settings->active_addons[$addon_to_activate])) { $paths = explode('/', ltrim(rtrim($wptouch_pro->get['addon_location'], DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR)); $addon_info = new stdClass(); $addon_info->addon_name = $paths[count($paths) - 1]; unset($paths[count($paths) - 1]); $addon_info->location = '/' . implode('/', $paths); $settings->active_addons[$addon_to_activate] = $addon_info; $settings->save(); } } break; case 'deactivate_addon': WPTOUCH_DEBUG(WPTOUCH_INFO, 'Deactivating add-on [' . $wptouch_pro->get['addon_name'] . ']'); $addon_to_deactivate = $wptouch_pro->get['addon_name']; if ($addon_to_deactivate) { $settings = $wptouch_pro->get_settings(); if (isset($settings->active_addons[$addon_to_deactivate])) { unset($settings->active_addons[$addon_to_deactivate]); $settings->save(); } } break; case 'copy_theme': WPTOUCH_DEBUG(WPTOUCH_INFO, 'Copying theme [' . $wptouch_pro->get['theme_name'] . ']'); wptouch_pro_copy_theme($wptouch_pro->get['theme_name'], $wptouch_pro->get['theme_location']); break; case 'delete_theme': WPTOUCH_DEBUG(WPTOUCH_INFO, 'Deleting theme [' . $wptouch_pro->get['theme_location'] . ']'); require_once WPTOUCH_DIR . '/core/file-operations.php'; $theme_location = WP_CONTENT_DIR . $wptouch_pro->get['theme_location']; $wptouch_pro->recursive_delete($theme_location); break; } } } $used_query_args = array('admin_menu_nonce', 'admin_command', 'theme_name', 'theme_location'); header('Location: ' . esc_url(remove_query_arg($used_query_args))); die; } }
function wptouch_pro_handle_admin_command() { global $wptouch_pro; if (isset($wptouch_pro->get['admin_command'])) { $admin_menu_nonce = $wptouch_pro->get['admin_menu_nonce']; if (wptouch_admin_menu_nonce_is_valid($admin_menu_nonce)) { // check user permissions if (current_user_can('switch_themes')) { switch ($wptouch_pro->get['admin_command']) { case 'activate_theme': WPTOUCH_DEBUG(WPTOUCH_INFO, 'Activating theme [' . $wptouch_pro->get['theme_name'] . ']'); wptouch_activate_theme($wptouch_pro->get['theme_name']); delete_transient('wptouch_customizer_settings'); break; case 'activate_addon': WPTOUCH_DEBUG(WPTOUCH_INFO, 'Activating add-on [' . $wptouch_pro->get['addon_name'] . ']'); $addon_to_activate = $wptouch_pro->get['addon_name']; wptouch_activate_addon($addon_to_activate); delete_transient('wptouch_customizer_settings'); break; case 'deactivate_addon': WPTOUCH_DEBUG(WPTOUCH_INFO, 'Deactivating add-on [' . $wptouch_pro->get['addon_name'] . ']'); $addon_to_deactivate = $wptouch_pro->get['addon_name']; wptouch_deactivate_addon($addon_to_deactivate); break; case 'copy_theme': WPTOUCH_DEBUG(WPTOUCH_INFO, 'Copying theme [' . $wptouch_pro->get['theme_name'] . ']'); wptouch_pro_copy_theme($wptouch_pro->get['theme_name'], $wptouch_pro->get['theme_location']); break; case 'delete_theme': WPTOUCH_DEBUG(WPTOUCH_INFO, 'Deleting theme [' . $wptouch_pro->get['theme_location'] . ']'); require_once WPTOUCH_DIR . '/core/file-operations.php'; $theme_location = WP_CONTENT_DIR . $wptouch_pro->get['theme_location']; $wptouch_pro->recursive_delete($theme_location); break; } } } $used_query_args = array('admin_menu_nonce', 'admin_command', 'theme_name', 'theme_location', 'addon_name', 'addon_location'); header('Location: ' . esc_url(remove_query_arg($used_query_args))); die; } }
function wptouch_pro_handle_admin_command() { global $wptouch_pro; if (isset($wptouch_pro->get['admin_command'])) { $admin_menu_nonce = $wptouch_pro->get['admin_menu_nonce']; if (wptouch_admin_menu_nonce_is_valid($admin_menu_nonce)) { // check user permissions if (current_user_can('switch_themes')) { switch ($wptouch_pro->get['admin_command']) { case 'activate_theme': WPTOUCH_DEBUG(WPTOUCH_INFO, 'Activating theme [' . $wptouch_pro->get['theme_name'] . ']'); $theme_to_activate = $wptouch_pro->get['theme_name']; if ($theme_to_activate) { $settings = $wptouch_pro->get_settings(); $paths = explode('/', ltrim(rtrim($wptouch_pro->get['theme_location'], '/'), '/')); $settings->current_theme_name = $paths[count($paths) - 1]; unset($paths[count($paths) - 1]); $settings->current_theme_location = '/' . implode('/', $paths); $settings->current_theme_friendly_name = $wptouch_pro->get['theme_name']; $settings->save(); } break; case 'activate_addon': WPTOUCH_DEBUG(WPTOUCH_INFO, 'Activating add-on [' . $wptouch_pro->get['addon_name'] . ']'); $addon_to_activate = $wptouch_pro->get['addon_name']; if ($addon_to_activate) { $settings = $wptouch_pro->get_settings(); if (!isset($settings->active_addons[$addon_to_activate])) { $paths = explode('/', ltrim(rtrim($wptouch_pro->get['addon_location'], DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR)); $addon_info = new stdClass(); $addon_info->addon_name = $paths[count($paths) - 1]; unset($paths[count($paths) - 1]); $addon_info->location = '/' . implode('/', $paths); $settings->active_addons[$addon_to_activate] = $addon_info; $settings->save(); } } break; case 'deactivate_addon': WPTOUCH_DEBUG(WPTOUCH_INFO, 'Deactivating add-on [' . $wptouch_pro->get['addon_name'] . ']'); $addon_to_deactivate = $wptouch_pro->get['addon_name']; if ($addon_to_deactivate) { $settings = $wptouch_pro->get_settings(); if (isset($settings->active_addons[$addon_to_deactivate])) { unset($settings->active_addons[$addon_to_deactivate]); $settings->save(); } } break; case 'copy_theme': WPTOUCH_DEBUG(WPTOUCH_INFO, 'Copying theme [' . $wptouch_pro->get['theme_name'] . ']'); require_once WPTOUCH_DIR . '/core/file-operations.php'; $copy_src = WP_CONTENT_DIR . $wptouch_pro->get['theme_location']; $theme_name = wptouch_convert_to_class_name($wptouch_pro->get['theme_name']); $num = $wptouch_pro->get_theme_copy_num($theme_name); $copy_dest = WPTOUCH_CUSTOM_THEME_DIRECTORY . '/' . $theme_name . '-copy-' . $num; wptouch_create_directory_if_not_exist($copy_dest); $wptouch_pro->recursive_copy($copy_src, $copy_dest); $readme_file = $copy_dest . '/readme.txt'; $readme_info = $wptouch_pro->load_file($readme_file); if ($readme_info) { if (preg_match('#Theme Name: (.*)#', $readme_info, $matches)) { $readme_info = str_replace($matches[0], 'Theme Name: ' . $matches[1] . ' Copy #' . $num, $readme_info); $f = fopen($readme_file, "w+t"); if ($f) { fwrite($f, $readme_info); fclose($f); } } } else { WPTOUCH_DEBUG(WPTOUCH_ERROR, "Unable to modify readme.txt file after copy"); } break; case 'delete_theme': WPTOUCH_DEBUG(WPTOUCH_INFO, 'Deleting theme [' . $wptouch_pro->get['theme_location'] . ']'); require_once WPTOUCH_DIR . '/core/file-operations.php'; $theme_location = WP_CONTENT_DIR . $wptouch_pro->get['theme_location']; $wptouch_pro->recursive_delete($theme_location); break; } } } $used_query_args = array('admin_menu_nonce', 'admin_command', 'theme_name', 'theme_location'); header('Location: ' . remove_query_arg($used_query_args)); die; } }