is_plugin_activated(); if (!$is_activated) { wp_redirect(admin_url('admin.php?page=presslearn-settings')); exit; } if (!function_exists('WP_Filesystem')) { require_once ABSPATH . 'wp-admin/includes/file.php'; } $filesystem_initialized = WP_Filesystem(); if (!$filesystem_initialized) { $filesystem_error = true; } $settings_updated = false; $save_error = false; $existing_content = ''; $robots_settings_updated = false; $robots_save_error = false; $robots_existing_content = ''; $naver_upload_success = false; $google_upload_success = false; $upload_error = false; if (isset($_POST['save_ads_txt_content'])) { check_admin_referer('presslearn_save_ads_txt_nonce'); if (current_user_can('manage_options') && $filesystem_initialized) { global $wp_filesystem; $content = isset($_POST['ads_txt_content']) ? wp_unslash($_POST['ads_txt_content']) : ''; $content = sanitize_textarea_field($content); if (preg_match('/<[^>]*>/', $content) || stripos($content, 'javascript:') !== false || stripos($content, 'data:') !== false) { $save_error = true; } elseif (strlen($content) > 1024 * 1024) { $save_error = true; } else { $ads_txt_path = ABSPATH . 'ads.txt'; if ($wp_filesystem->put_contents($ads_txt_path, $content, FS_CHMOD_FILE)) { $settings_updated = true; } else { $save_error = true; } } $robots_content = isset($_POST['robots_txt_content']) ? wp_unslash($_POST['robots_txt_content']) : ''; $robots_content = sanitize_textarea_field($robots_content); if (preg_match('/<[^>]*>/', $robots_content) || stripos($robots_content, 'javascript:') !== false || stripos($robots_content, 'data:') !== false) { $robots_save_error = true; } elseif (strlen($robots_content) > 1024 * 1024) { $robots_save_error = true; } else { $robots_txt_path = ABSPATH . 'robots.txt'; if ($wp_filesystem->put_contents($robots_txt_path, $robots_content, FS_CHMOD_FILE)) { $robots_settings_updated = true; } else { $robots_save_error = true; } } } else { $save_error = true; $robots_save_error = true; } } if (isset($_POST['upload_naver_verification'])) { check_admin_referer('presslearn_save_ads_txt_nonce'); if (current_user_can('manage_options') && $filesystem_initialized) { if (isset($_FILES['naver_verification_file']) && $_FILES['naver_verification_file']['error'] === UPLOAD_ERR_OK) { $file = $_FILES['naver_verification_file']; $filename = sanitize_file_name($file['name']); if (preg_match('/^naver[a-z0-9]+\.html$/i', $filename) && $file['size'] <= 1024 * 1024) { global $wp_filesystem; $target_path = ABSPATH . $filename; $file_content = file_get_contents($file['tmp_name']); if ($file_content !== false && $wp_filesystem->put_contents($target_path, $file_content, FS_CHMOD_FILE)) { $naver_upload_success = true; } else { $upload_error = true; } } else { $upload_error = true; } } else { $upload_error = true; } } else { $upload_error = true; } } if (isset($_POST['upload_google_verification'])) { check_admin_referer('presslearn_save_ads_txt_nonce'); if (current_user_can('manage_options') && $filesystem_initialized) { if (isset($_FILES['google_verification_file']) && $_FILES['google_verification_file']['error'] === UPLOAD_ERR_OK) { $file = $_FILES['google_verification_file']; $filename = sanitize_file_name($file['name']); if (preg_match('/^google[a-z0-9]+\.html$/i', $filename) && $file['size'] <= 1024 * 1024) { global $wp_filesystem; $target_path = ABSPATH . $filename; $file_content = file_get_contents($file['tmp_name']); if ($file_content !== false && $wp_filesystem->put_contents($target_path, $file_content, FS_CHMOD_FILE)) { $google_upload_success = true; } else { $upload_error = true; } } else { $upload_error = true; } } else { $upload_error = true; } } else { $upload_error = true; } } if ($filesystem_initialized) { global $wp_filesystem; $ads_txt_path = ABSPATH . 'ads.txt'; if ($wp_filesystem->exists($ads_txt_path)) { $existing_content = $wp_filesystem->get_contents($ads_txt_path); if ($existing_content === false) { $existing_content = ''; } else { if (strlen($existing_content) > 1024 * 1024) { $existing_content = ''; } } } } else { $existing_content = ''; } if ($filesystem_initialized) { global $wp_filesystem; $robots_txt_path = ABSPATH . 'robots.txt'; if ($wp_filesystem->exists($robots_txt_path)) { $robots_existing_content = $wp_filesystem->get_contents($robots_txt_path); if ($robots_existing_content === false) { $robots_existing_content = ''; } else { if (strlen($robots_existing_content) > 1024 * 1024) { $robots_existing_content = ''; } } } } else { $robots_existing_content = ''; } $naver_verification_exists = false; $google_verification_exists = false; $naver_verification_file = ''; $google_verification_file = ''; if ($filesystem_initialized) { global $wp_filesystem; $files = $wp_filesystem->dirlist(ABSPATH); if ($files) { foreach ($files as $file) { if (preg_match('/^naver[a-z0-9]+\.html$/i', $file['name'])) { $naver_verification_exists = true; $naver_verification_file = $file['name']; break; } } foreach ($files as $file) { if (preg_match('/^google[a-z0-9]+\.html$/i', $file['name'])) { $google_verification_exists = true; $google_verification_file = $file['name']; break; } } } } $ads_txt_url = home_url('/ads.txt'); $file_exists = !empty($existing_content); $robots_txt_url = home_url('/robots.txt'); $robots_file_exists = !empty($robots_existing_content); ?>
기능이 활성화 되었습니다.
파일 시스템에 접근할 수 없습니다. 서버 권한을 확인해주세요.
파일이 성공적으로 저장되었습니다.
파일 저장에 실패했습니다. 파일 권한을 확인해주세요.
네이버 서치 어드바이저 인증 파일이 성공적으로 업로드되었습니다
구글 서치 콘솔 인증 파일이 성공적으로 업로드되었습니다.
파일 업로드에 실패했습니다. 파일 형식과 크기를 확인해주세요.
Google AdSense 및 기타 광고 네트워크 인증을 위한 ads.txt 파일을 관리합니다.