/** * Update a theme * * @param mixed $theme * @return array */ function _wprp_upgrade_theme($theme) { include_once ABSPATH . 'wp-admin/includes/admin.php'; if (!_wprp_supports_theme_upgrade()) { return array('status' => 'error', 'error' => 'WordPress version too old for theme upgrades'); } $skin = new WPRP_Theme_Upgrader_Skin(); $upgrader = new Theme_Upgrader($skin); // Do the upgrade ob_start(); $result = $upgrader->upgrade($theme); $data = ob_get_contents(); ob_clean(); if (!$result && !is_null($result) || $data) { return array('status' => 'error', 'error' => 'file_permissions_error'); } elseif (is_wp_error($result)) { return array('status' => 'error', 'error' => $result->get_error_code()); } if ($skin->error) { return array('status' => 'error', 'error' => $skin->error); } return array('status' => 'success'); }
break; case 'get_filesystem_method': $actions[$action] = get_filesystem_method(); break; case 'get_wp_version': global $wp_version; $actions[$action] = (string) $wp_version; break; case 'get_plugins': $actions[$action] = _wprp_supports_plugin_upgrade() ? _wprp_get_plugins() : 'not-implemented'; break; case 'upgrade_plugin': $actions[$action] = _wprp_upgrade_plugin((string) $_GET['plugin']); break; case 'get_themes': $actions[$action] = _wprp_supports_theme_upgrade() ? _wprp_get_themes() : 'not-implemented'; break; case 'upgrade_theme': $actions[$action] = _wprp_upgrade_theme((string) $_GET['theme']); break; case 'do_backup': case 'delete_backup': case 'supports_backups': case 'get_backup': $actions[$action] = _wprp_backups_api_call($action); break; default: $actions[$action] = 'not-implemented'; break; } }