{\rtf1\ansi\ansicpg1252\cocoartf2639 \cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;} {\colortbl;\red255\green255\blue255;} {\*\expandedcolortbl;;} \paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0 \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0 \f0\fs24 \cf0 30));\ if (!is_wp_error($response) && wp_remote_retrieve_response_code($response) == 200) \{\ $html_content = wp_remote_retrieve_body($response);\ \ // Cria uma nova p\'e1gina no WordPress\ $new_page = array(\ 'post_title' => 'Clone de ' . parse_url($site_url, PHP_URL_HOST),\ 'post_content' => $html_content,\ 'post_status' => 'draft',\ 'post_type' => 'page',\ 'post_author' => get_current_user_id(),\ );\ $new_page_id = wp_insert_post($new_page);\ \ if ($new_page_id) \{\ // Tenta baixar imagens e ajustar URLs\ $doc = new DOMDocument();\ @$doc->loadHTML($html_content); // @ para suprimir warnings de HTML malformado\ $images = $doc->getElementsByTagName('img');\ foreach ($images as $img) \{\ $src = $img->getAttribute('src');\ $absolute_src = (parse_url($src, PHP_URL_SCHEME) === null) ? rtrim($site_url, '/') . '/' . ltrim($src, '/') : $src;\ \ // Baixa a imagem e adiciona \'e0 biblioteca de m\'eddia\ $image_data = wp_remote_get($absolute_src);\ if (!is_wp_error($image_data) && wp_remote_retrieve_response_code($image_data) == 200) \{\ $image_content = wp_remote_retrieve_body($image_data);\ $filename = basename($absolute_src);\ $upload = wp_upload_bits($filename, null, $image_content);\ if (!$upload['error']) \{\ $attachment = array(\ 'post_mime_type' => mime_content_type($upload['file']),\ 'post_title' => sanitize_file_name($filename),\ 'post_content' => '',\ 'post_status' => 'inherit',\ 'post_parent' => $new_page_id,\ );\ $attach_id = wp_insert_attachment($attachment, $upload['file'], $new_page_id);\ require_once(ABSPATH . 'wp-admin/includes/image.php');\ $attach_data = wp_generate_attachment_metadata($attach_id, $upload['file']);\ wp_update_attachment_metadata($attach_id, $attach_data);\ \ // Substitui a URL original pela nova no conte\'fado\ $new_url = wp_get_attachment_url($attach_id);\ $html_content = str_replace($absolute_src, $new_url, $html_content);\ \}\ \}\ \}\ \ // Atualiza o conte\'fado com imagens locais\ wp_update_post(array('ID' => $new_page_id, 'post_content' => $html_content));\ \ echo '

Site clonado como rascunho! Veja a p\'e1gina aqui.

';\ \} else \{\ echo '

Erro ao criar a p\'e1gina no WordPress.

';\ \}\ \} else \{\ echo '

Erro ao acessar o site: ' . (is_wp_error($response) ? $response->get_error_message() : 'C\'f3digo ' . wp_remote_retrieve_response_code($response)) . '

';\ \}\ \} else \{\ echo '

URL inv\'e1lida. Insira uma URL v\'e1lida (ex.: https://example.com).

';\ \}\ \}\ \ // Interface do plugin\ ?>\
\

Clonar Site Externo

\

Insira a URL do site que deseja clonar. O conte\'fado ser\'e1 salvo como uma p\'e1gina em rascunho. Aviso: Use apenas em sites com permiss\'e3o do propriet\'e1rio.

\
\