Changeset 3845669
- Timestamp:
- 12/05/2026 06:28:10 AM (114 minutes ago)
- Location:
- editnday
- Files:
-
- 16 edited
- 1 copied
-
tags/1.0.98 (copied) (copied from editnday/trunk )
-
tags/1.0.98/CHANGELOG.md (modified) (1 diff)
-
tags/1.0.98/editnday.php (modified) (2 diffs)
-
tags/1.0.98/includes/class-ai-ready.php (modified) (3 diffs)
-
tags/1.0.98/includes/class-reach.php (modified) (8 diffs)
-
tags/1.0.98/includes/class-seo-head.php (modified) (1 diff)
-
tags/1.0.98/includes/class-site-audit.php (modified) (8 diffs)
-
tags/1.0.98/readme.txt (modified) (4 diffs)
-
tags/1.0.98/uninstall.php (modified) (2 diffs)
-
trunk/CHANGELOG.md (modified) (1 diff)
-
trunk/editnday.php (modified) (2 diffs)
-
trunk/includes/class-ai-ready.php (modified) (3 diffs)
-
trunk/includes/class-reach.php (modified) (8 diffs)
-
trunk/includes/class-seo-head.php (modified) (1 diff)
-
trunk/includes/class-site-audit.php (modified) (8 diffs)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/uninstall.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
editnday/tags/1.0.98/CHANGELOG.md
r3834533 r3845669 3 3 > 이 파일은 `apps/site/src/content/updates/`에서 만들어진다 (`pnpm release:plugin`). 직접 고치지 않는다. 4 4 > 웹에서 보기: https://editn.day/updates 5 6 ## 1.0.98 (2026-12-05) — CDN 사이트의 읽힘 세기 · 콘텐츠 점검 빨라짐 · 질문답 구조화 데이터 고침 7 8 - **CDN 사이트의 읽힘 세기** 9 - 설정 › 읽힘 세기 카드에 「방문자 주소 읽는 곳」을 넣었어요. 접속 주소 그대로(기본) · Cloudflare · 그 밖의 CDN 중에서 골라요. 10 - CDN 뒤에 있는 사이트는 방문자가 모두 CDN 주소로 보여 횟수 제한에 금방 걸렸어요. 쓰는 CDN을 고르면 방문자마다 따로 세요. 11 - Cloudflare를 거쳐 열리는 사이트로 보이면 카드에 알려 줘요. 최근 하루 안에 횟수 제한에 걸린 요청이 있었을 때도 알려 줘요. 12 - **콘텐츠 점검이 빨라졌어요** 13 - 점검 결과를 1시간 기억해 두고, 글·대표 이미지·ALT·검색 설명·카테고리가 바뀌면 바로 새로 점검해요. 화면에 「n분 전에 점검한 결과예요 · 다시 점검」이 보여요. 14 - 오래된 내 글을 가리키는 링크를 한 번에 확인해서, 글이 많은 사이트에서도 깨진 링크 점검이 빨라요. 15 - CSV 내려받기는 점검 화면과 같이 관리자만 할 수 있어요. 16 - **AI 답변 방문 세기** 17 - 방문이 거의 동시에 들어와도 빠짐없이 세요. 지금까지 쌓인 숫자는 업데이트할 때 그대로 옮겨요. 18 - **고침** 19 - 질문이나 답을 비워 둔 질문답 항목은 구조화 데이터(FAQPage)에 나가지 않아요. 20 - 읽힘 깊이를 고쳐 셀 때 지난 날의 숫자가 줄어들던 문제를 고쳤어요. 21 - 에디튼을 지우면 읽힘 세기 기록과 가게 정보 등 남아 있던 설정도 함께 지워요. 요약·질문답·SEO 값은 글의 일부라 그대로 남아요. 5 22 6 23 ## 1.0.97 (2026-11-30) — 읽힘 세기 횟수 제한 켜기·끄기 -
editnday/tags/1.0.98/editnday.php
r3834533 r3845669 4 4 * Plugin URI: https://editn.day 5 5 * Description: Korean writing check and publishing assistant: spelling, AI-sounding phrases, SEO and Naver previews, summary and FAQ boxes, search engine registration. Runs entirely on your site. 6 * Version: 1.0.9 76 * Version: 1.0.98 7 7 * Requires at least: 6.6 8 8 * Requires PHP: 8.1 … … 16 16 defined( 'ABSPATH' ) || exit; 17 17 18 define( 'EDITNDAY_VERSION', '1.0.9 7' );18 define( 'EDITNDAY_VERSION', '1.0.98' ); 19 19 define( 'EDITNDAY_FILE', __FILE__ ); 20 20 define( 'EDITNDAY_DIR', plugin_dir_path( __FILE__ ) ); -
editnday/tags/1.0.98/includes/class-ai-ready.php
r3834533 r3845669 19 19 20 20 const IDENTITY = 'editnday_identity'; // {kind: person|org, name, intro, links[]} 21 const VISITS = 'editnday_ai_visits'; // {Y-m-d: {post_id: {src: n}}} 90일 21 const VISITS = 'editnday_ai_visits'; // 옛 저장 {Y-m-d: {post_id: {src: n}}}. 1.0.98부터 읽힘 세기 표로 옮기고 지운다 (migrate) 22 const KEY = 'ai:'; // 읽힘 세기 표({prefix}editnday_reach)의 항목 이름 앞머리: ai:ChatGPT … 22 23 const COUNT_ON = 'editnday_ai_count'; // '0'이면 세지 않음 (기본 켬) 23 24 const FW_CACHE = 'editnday_crawl_ai'; // 방화벽 점검 결과 (12시간) … … 497 498 } 498 499 499 /** 하루·글·출처 숫자 하나 올리기 (90일 넘은 날은 지움) */ 500 /** 501 * 하루·글·출처 숫자 하나 올리기 (12-05: 옵션 하나를 읽고 고쳐 쓰던 것을 읽힘 세기 표로). 502 * 더하기를 데이터베이스가 한 번에 하므로 동시에 들어온 방문을 잃지 않는다. 상한은 전과 같다 503 */ 500 504 public static function bump( int $post, string $src, string $day ): void { 501 $all = get_option( self::VISITS, array() ); 502 $all = is_array( $all ) ? $all : array(); 503 $n = (int) ( $all[ $day ][ $post ][ $src ] ?? 0 ); 504 $sum = array_sum( (array) ( $all[ $day ][ $post ] ?? array() ) ); 505 if ( $sum >= self::DAY_CAP ) { 505 global $wpdb; 506 $table = Reach::table(); 507 $like = $wpdb->esc_like( self::KEY ) . '%'; 508 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- 표 이름은 우리 것 509 $mine = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COALESCE(SUM(n), 0) FROM {$table} WHERE day = %s AND post_id = %d AND k LIKE %s", $day, $post, $like ) ); 510 if ( $mine >= self::DAY_CAP ) { 506 511 return; 507 512 } 508 // 하루 전체 상한 (10-25 보안 점검): 누구나 부를 수 있는 기록이라, 글 번호를 돌려 가며 보내 설정값 하나를끝없이 키우지 못하게.513 // 하루 전체 상한 (10-25 보안 점검): 누구나 부를 수 있는 기록이라, 글 번호를 돌려 가며 보내 끝없이 키우지 못하게. 509 514 // 글 수·방문 합 둘 다 — AI 검색에서 오는 실제 방문은 이보다 훨씬 적다 510 $today = (array) ( $all[ $day ] ?? array() ); 511 if ( ( ! isset( $today[ $post ] ) && count( $today ) >= self::DAY_POSTS ) || array_sum( array_map( 'array_sum', $today ) ) >= self::DAY_TOTAL ) { 515 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared 516 $today = $wpdb->get_row( $wpdb->prepare( "SELECT COUNT(DISTINCT post_id) AS posts, COALESCE(SUM(n), 0) AS total FROM {$table} WHERE day = %s AND k LIKE %s", $day, $like ) ); 517 if ( ( 0 === $mine && (int) ( $today->posts ?? 0 ) >= self::DAY_POSTS ) || (int) ( $today->total ?? 0 ) >= self::DAY_TOTAL ) { 512 518 return; 513 519 } 514 $all[ $day ][ $post ][ $src ] = $n + 1; 515 $cut = wp_date( 'Y-m-d', time() - 90 * DAY_IN_SECONDS ); 516 foreach ( array_keys( $all ) as $d ) { 517 if ( $d < $cut ) { 518 unset( $all[ $d ] ); 519 } 520 } 521 update_option( self::VISITS, $all, false ); 520 Reach::bump( $post, self::KEY . $src, 1, $day ); 521 // 90일 넘은 날 지우기 (읽힘 세기를 꺼 두어도 AI 방문 줄이 쌓이지 않게) 522 if ( 1 === wp_rand( 1, 50 ) ) { 523 Reach::prune(); 524 } 525 } 526 527 /** 528 * 최근 n일 줄: [day, post_id, src, n] 529 * 530 * @return array<int, array{0:string, 1:int, 2:string, 3:int}> 531 */ 532 private static function rows( int $days, int $post = 0 ): array { 533 global $wpdb; 534 $table = Reach::table(); 535 $cut = wp_date( 'Y-m-d', time() - ( $days - 1 ) * DAY_IN_SECONDS ); 536 $like = $wpdb->esc_like( self::KEY ) . '%'; 537 $where = $post ? $wpdb->prepare( ' AND post_id = %d', $post ) : ''; 538 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQL.NotPrepared -- $where는 위에서 prepare 539 $res = $wpdb->get_results( $wpdb->prepare( "SELECT day, post_id, k, SUM(n) AS n FROM {$table} WHERE day >= %s AND k LIKE %s{$where} GROUP BY day, post_id, k", $cut, $like ), ARRAY_A ); 540 $out = array(); 541 foreach ( (array) $res as $r ) { 542 $out[] = array( (string) $r['day'], (int) $r['post_id'], substr( (string) $r['k'], strlen( self::KEY ) ), (int) $r['n'] ); 543 } 544 return $out; 522 545 } 523 546 524 547 /** 최근 n일: 합계 · 출처별 · 글별(많은 순 10개) · 날짜별 */ 525 548 public static function summary( int $days = 30 ): array { 526 $all = get_option( self::VISITS, array() );527 $all = is_array( $all ) ? $all : array();528 $cut = wp_date( 'Y-m-d', time() - ( $days - 1 ) * DAY_IN_SECONDS );529 549 $total = 0; 530 550 $by_src = array(); 531 551 $by_pid = array(); 532 552 $by_day = array(); 533 foreach ( $all as $d => $posts ) { 534 if ( $d < $cut ) { 535 continue; 536 } 537 foreach ( (array) $posts as $pid => $srcs ) { 538 foreach ( (array) $srcs as $s => $n ) { 539 $n = (int) $n; 540 $total += $n; 541 $by_src[ $s ] = ( $by_src[ $s ] ?? 0 ) + $n; 542 $by_pid[ $pid ] = ( $by_pid[ $pid ] ?? 0 ) + $n; 543 $by_day[ $d ] = ( $by_day[ $d ] ?? 0 ) + $n; 544 } 545 } 553 foreach ( self::rows( $days ) as list( $d, $pid, $s, $n ) ) { 554 $total += $n; 555 $by_src[ $s ] = ( $by_src[ $s ] ?? 0 ) + $n; 556 $by_pid[ $pid ] = ( $by_pid[ $pid ] ?? 0 ) + $n; 557 $by_day[ $d ] = ( $by_day[ $d ] ?? 0 ) + $n; 546 558 } 547 559 arsort( $by_src ); … … 557 569 /** 글 하나의 최근 n일 (작성 기록·확장에서) */ 558 570 public static function for_post( int $post, int $days = 30 ): array { 559 $all = get_option( self::VISITS, array() );560 $cut = wp_date( 'Y-m-d', time() - ( $days - 1 ) * DAY_IN_SECONDS );561 571 $out = array(); 562 foreach ( is_array( $all ) ? $all : array() as $d => $posts ) { 563 if ( $d >= $cut ) { 564 foreach ( (array) ( $posts[ $post ] ?? array() ) as $s => $n ) { 565 $out[ $s ] = ( $out[ $s ] ?? 0 ) + (int) $n; 566 } 567 } 572 foreach ( self::rows( $days, $post ) as list( , , $s, $n ) ) { 573 $out[ $s ] = ( $out[ $s ] ?? 0 ) + $n; 568 574 } 569 575 arsort( $out ); 570 576 return $out; 577 } 578 579 /** 580 * 옛 저장(옵션 editnday_ai_visits)을 읽힘 세기 표로 옮긴다 (1.0.98, 표 판 2에서 한 번). 581 * 다 옮긴 뒤에만 옵션을 지운다 (옮기다 오류가 나면 다음에 다시) 582 */ 583 public static function migrate(): void { 584 global $wpdb; 585 $all = get_option( self::VISITS, null ); 586 if ( null === $all ) { 587 return; 588 } 589 $cut = wp_date( 'Y-m-d', time() - Reach::KEEP * DAY_IN_SECONDS ); 590 foreach ( is_array( $all ) ? $all : array() as $d => $posts ) { 591 if ( ! preg_match( '/^\d{4}-\d{2}-\d{2}$/', (string) $d ) || $d < $cut ) { 592 continue; 593 } 594 foreach ( (array) $posts as $pid => $srcs ) { 595 foreach ( (array) $srcs as $src => $n ) { 596 $src = substr( preg_replace( '/[^A-Za-z0-9 .\-]/', '', (string) $src ), 0, 29 ); 597 if ( (int) $pid > 0 && '' !== $src && (int) $n > 0 ) { 598 Reach::bump( (int) $pid, self::KEY . $src, (int) $n, (string) $d ); 599 } 600 } 601 } 602 } 603 if ( '' === $wpdb->last_error ) { 604 delete_option( self::VISITS ); 605 } 571 606 } 572 607 -
editnday/tags/1.0.98/includes/class-reach.php
r3834533 r3845669 6 6 * - 연락: 전화·메일·지도 링크 누름, 폼 보냄 7 7 * 브라우저가 떠날 때 한 번 보낸다(캐시된 페이지에서도 동작). 쿠키·IP·사용자 식별값은 저장하지 않고, 로그인한 사람(작가 본인)은 세지 않는다. 8 * 저장: 표 {prefix}editnday_reach (day, post_id, k, n). 90일 지나면 지운다. 프로 [성과] 탭이 읽고, AI 답변 방문(AiReady)은 그대로 둔다. 8 * 저장: 표 {prefix}editnday_reach (day, post_id, k, n). 90일 지나면 지운다. 프로 [성과] 탭이 읽는다. 9 * AI 답변 방문(AiReady)도 같은 표에 ai:출처 이름으로 센다 (1.0.98~). summary()는 ai: 줄을 읽지 않는다. 9 10 * 10 11 * @package Editnday … … 19 20 const ON = 'editnday_reach_on'; // '0'이면 세지 않음 (기본 켬) 20 21 const DB_VER = 'editnday_reach_db'; // 표 판 21 const VERSION = 1;22 const VERSION = 2; // 2: AI 답변 방문(ai:출처)도 이 표에 (12-05) 22 23 const DAY_CAP = 2000; // 글 하나·하루·항목 하나 최대 (부풀리기 방지) 23 24 const KEEP = 90; // 보관 일수 … … 25 26 const LIMIT = 'editnday_visit_limit'; // '0'이면 방문 세기 횟수 제한 끔 (기본 켬) 26 27 const PER_IP = 60; // 횟수 제한: 한 주소·10분 (읽힘 세기는 한 번 볼 때 두 번까지 보낸다) 28 const PROXY = 'editnday_proxy_ip'; // 방문자 주소를 어디서 읽나: '' 접속 주소 · 'cf' Cloudflare · 'xff' 그 밖의 프록시 (12-05) 29 const LIMIT_HIT = 'editnday_limit_hit'; // 하루 안에 횟수 제한에 걸린 때 (설정 카드 안내용) 27 30 28 31 public static function init(): void { … … 58 61 ) {$charset};" 59 62 ); 63 AiReady::migrate(); // 판 2: 옵션에 있던 AI 답변 방문을 이 표로 60 64 update_option( self::DB_VER, self::VERSION ); 61 65 } … … 64 68 register_setting( 'editnday', self::ON, array( 'type' => 'string', 'sanitize_callback' => static fn( $v ) => $v ? '1' : '0' ) ); 65 69 register_setting( 'editnday', self::LIMIT, array( 'type' => 'string', 'sanitize_callback' => static fn( $v ) => $v ? '1' : '0' ) ); 70 register_setting( 'editnday', self::PROXY, array( 'type' => 'string', 'sanitize_callback' => static fn( $v ) => in_array( (string) $v, array( 'cf', 'xff' ), true ) ? (string) $v : '' ) ); 66 71 } 67 72 … … 91 96 return true; 92 97 } 93 $ip = isset( $_SERVER['REMOTE_ADDR'] ) ? (string) $_SERVER['REMOTE_ADDR'] : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- 저장하지 않고 해시 열쇠로만 94 $slot = 'editnday_hit_' . $kind . '_' . md5( $ip ); 98 $slot = 'editnday_hit_' . $kind . '_' . md5( self::client_ip() ); 95 99 $used = (int) get_transient( $slot ); 96 100 if ( ! self::within( $used, $cap ) ) { 101 set_transient( self::LIMIT_HIT, time(), DAY_IN_SECONDS ); 97 102 return false; 98 103 } 99 104 set_transient( $slot, $used + 1, 10 * MINUTE_IN_SECONDS ); 100 105 return true; 106 } 107 108 /** 109 * 방문자 주소 (횟수 제한의 열쇠로만 쓰고 저장하지 않는다, 12-05). 110 * CDN·프록시 뒤에서는 접속 주소가 CDN 서버라 모든 방문자가 한 주소로 묶인다 → 설정에서 고른 머리말을 읽는다. 111 * 머리말은 누구나 꾸며 보낼 수 있어서 기본은 접속 주소만 믿고, 작가가 고른 때만 읽는다 112 */ 113 public static function client_ip(): string { 114 $remote = isset( $_SERVER['REMOTE_ADDR'] ) ? (string) $_SERVER['REMOTE_ADDR'] : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- 해시 열쇠로만 115 $ip = self::pick_ip( (string) get_option( self::PROXY, '' ), $remote, (string) ( $_SERVER['HTTP_CF_CONNECTING_IP'] ?? '' ), (string) ( $_SERVER['HTTP_X_FORWARDED_FOR'] ?? '' ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- pick_ip가 IP 모양 확인 116 /** 117 * 방문자 주소를 직접 정한다 (다른 CDN·호스팅의 머리말 등) 118 * 119 * @param string $ip 에디튼이 고른 주소. 120 * @param string $remote 접속 주소 (REMOTE_ADDR). 121 */ 122 return (string) apply_filters( 'editnday_client_ip', $ip, $remote ); 123 } 124 125 /** 설정·머리말로 주소 고르기 (순수). IP 모양이 아니면 접속 주소 */ 126 public static function pick_ip( string $mode, string $remote, string $cf, string $xff ): string { 127 $cand = ''; 128 if ( 'cf' === $mode ) { 129 $cand = trim( $cf ); 130 } elseif ( 'xff' === $mode ) { 131 $cand = trim( explode( ',', $xff )[0] ); 132 } 133 return ( '' !== $cand && false !== filter_var( $cand, FILTER_VALIDATE_IP ) ) ? $cand : $remote; 134 } 135 136 /** 지금 요청 머리말로 본 CDN 추정: 'cf' · 'xff' · '' (설정 카드 안내용) */ 137 public static function detect_proxy(): string { 138 if ( ! empty( $_SERVER['HTTP_CF_CONNECTING_IP'] ) ) { 139 return 'cf'; 140 } 141 return ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ? 'xff' : ''; 101 142 } 102 143 … … 273 314 } 274 315 275 /** 숫자 하나 내리기 (깊이 버킷을 옮길 때). 오늘 줄이 없으면 가장 최근 날에서 */ 316 /** 317 * 숫자 하나 내리기 (깊이 버킷을 옮길 때). 그날 줄에서만 뺀다. 318 * 자정을 넘겨 보정이 오면 그날 줄이 없을 수 있는데, 이때 지난 날에서 빼면 그날 통계가 틀어지므로 아무것도 하지 않는다 (12-05) 319 */ 276 320 public static function unbump( int $post, string $k, string $day ): void { 277 321 global $wpdb; 278 322 $table = self::table(); 279 323 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared 280 $n = (int) $wpdb->query( $wpdb->prepare( "UPDATE {$table} SET n = n - 1 WHERE day = %s AND post_id = %d AND k = %s AND n > 0", $day, $post, $k ) ); 281 if ( ! $n ) { 282 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared 283 $wpdb->query( $wpdb->prepare( "UPDATE {$table} SET n = n - 1 WHERE post_id = %d AND k = %s AND n > 0 ORDER BY day DESC LIMIT 1", $post, $k ) ); 284 } 324 $wpdb->query( $wpdb->prepare( "UPDATE {$table} SET n = n - 1 WHERE day = %s AND post_id = %d AND k = %s AND n > 0", $day, $post, $k ) ); 285 325 } 286 326 … … 344 384 <input type="hidden" name="<?php echo esc_attr( self::LIMIT ); ?>" value="0"> 345 385 <p><label><input type="checkbox" name="<?php echo esc_attr( self::LIMIT ); ?>" value="1" <?php checked( self::limited() ); ?>> <?php esc_html_e( '횟수 제한: 한 주소에서 10분에 60번까지만 세요 (누가 숫자를 부풀리거나 서버를 바쁘게 하지 못하게). AI 답변 방문 세기에도 같이 적용돼요.', 'editnday' ); ?></label></p> 386 <?php 387 $mode = (string) get_option( self::PROXY, '' ); 388 $seen = self::detect_proxy(); 389 $modes = array( 390 '' => __( '접속 주소 그대로 (CDN·프록시를 쓰지 않아요)', 'editnday' ), 391 'cf' => __( 'Cloudflare를 써요 (CF-Connecting-IP)', 'editnday' ), 392 'xff' => __( '그 밖의 CDN·프록시를 써요 (X-Forwarded-For 첫 주소)', 'editnday' ), 393 ); 394 ?> 395 <p><label for="editnday-proxy-ip"><?php esc_html_e( '방문자 주소 읽는 곳', 'editnday' ); ?></label><br> 396 <select id="editnday-proxy-ip" name="<?php echo esc_attr( self::PROXY ); ?>"> 397 <?php foreach ( $modes as $v => $label ) : ?> 398 <option value="<?php echo esc_attr( $v ); ?>" <?php selected( $mode, $v ); ?>><?php echo esc_html( $label ); ?></option> 399 <?php endforeach; ?> 400 </select> 401 </p> 402 <p class="description"><?php esc_html_e( 'CDN 뒤에 있는 사이트는 방문자가 모두 CDN 서버 주소로 보여서 횟수 제한에 금방 걸려요. 쓰는 CDN을 고르면 방문자마다 따로 세요. CDN을 쓰지 않는데 고르면 누구나 주소를 꾸며 제한을 피할 수 있으니 쓰는 것만 골라 주세요.', 'editnday' ); ?></p> 403 <?php if ( $seen && $seen !== $mode ) : ?> 404 <p class="description"><strong><?php echo 'cf' === $seen ? esc_html__( '이 사이트는 Cloudflare를 거쳐 열리는 것 같아요. 위에서 "Cloudflare를 써요"를 골라 주세요.', 'editnday' ) : esc_html__( '이 사이트는 CDN이나 프록시를 거쳐 열리는 것 같아요. 호스팅이나 CDN 설정을 확인하고 맞는 것을 골라 주세요.', 'editnday' ); ?></strong></p> 405 <?php endif; ?> 406 <?php if ( self::limited() && get_transient( self::LIMIT_HIT ) ) : ?> 407 <p class="description"><?php esc_html_e( '최근 하루 안에 횟수 제한에 걸린 요청이 있었어요. 방문이 많은 날이 아니었다면 위의 주소 읽는 곳을 확인해 주세요.', 'editnday' ); ?></p> 408 <?php endif; ?> 346 409 <p class="description"><?php esc_html_e( '브라우저가 글을 떠날 때 한 번, 이 사이트의 워드프레스에만 보내요. 쿠키·IP·방문자 식별값·리퍼러 주소는 저장하지 않고 분류한 이름과 숫자만 남아요. 로그인한 사람(작가)은 세지 않아요. 90일 지나면 지워요. 에디튼 서버로는 가지 않아요. 프로 [성과] 탭에서 봐요.', 'editnday' ); ?></p> 347 410 </div> -
editnday/tags/1.0.98/includes/class-seo-head.php
r3789451 r3845669 233 233 'acceptedAnswer' => array( '@type' => 'Answer', 'text' => wp_strip_all_tags( (string) ( $q['answer'] ?? '' ) ) ), 234 234 ), 235 array_slice( $ schema['faq'], 0, 6 )235 array_slice( $faq, 0, 6 ) 236 236 ), 237 237 ) -
editnday/tags/1.0.98/includes/class-site-audit.php
r3789451 r3845669 24 24 add_action( 'admin_post_editnday_audit_undo', array( __CLASS__, 'undo' ) ); 25 25 add_action( 'admin_post_editnday_audit_csv', array( __CLASS__, 'csv' ) ); 26 add_action( 'admin_post_editnday_audit_refresh', array( __CLASS__, 'refresh' ) ); 27 // 점검 결과가 달라질 수 있는 일: 글 저장·지움·상태 바뀜, 글·첨부 메타(대표 이미지·ALT·SEO 값·뺀 항목), 카테고리·태그, 고유주소 형식, 뺄 카테고리 28 foreach ( array( 'save_post', 'deleted_post', 'trashed_post', 'untrashed_post' ) as $hook ) { 29 add_action( $hook, array( __CLASS__, 'forget_post' ) ); 30 } 31 foreach ( array( 'added_post_meta', 'updated_post_meta', 'deleted_post_meta' ) as $hook ) { 32 add_action( $hook, array( __CLASS__, 'forget_meta' ), 10, 3 ); 33 } 34 foreach ( array( 'created_term', 'edited_term', 'delete_term' ) as $hook ) { 35 add_action( $hook, array( __CLASS__, 'forget' ) ); 36 } 37 add_action( 'update_option_permalink_structure', array( __CLASS__, 'forget' ) ); 38 add_action( 'update_option_' . self::CATS_OPTION, array( __CLASS__, 'forget' ) ); 39 add_action( 'add_option_' . self::CATS_OPTION, array( __CLASS__, 'forget' ) ); 40 } 41 42 /** 저장해 둔 점검 결과 지우기 (다음에 화면을 열 때 새로 점검) */ 43 public static function forget(): void { 44 if ( self::$forgotten ) { 45 return; 46 } 47 self::$forgotten = true; 48 delete_transient( self::SCAN_CACHE ); 49 } 50 51 /** 글이 바뀜: 자동 저장·판(revision)은 공개 글이 아니라 점검 결과와 상관없다 */ 52 public static function forget_post( $post_id ): void { 53 $post_id = (int) $post_id; 54 if ( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) { 55 return; 56 } 57 self::forget(); 58 } 59 60 /** 61 * 메타가 바뀜 (에디튼 프로의 AI 채우기·SEO 플러그인 칸·미디어 보관함의 ALT 포함) 62 * 63 * @param mixed $meta_ids 메타 번호(들). 64 * @param int $post_id 글 번호. 65 * @param string $key 메타 이름. 66 */ 67 public static function forget_meta( $meta_ids, $post_id, $key ): void { 68 if ( in_array( (string) $key, self::META_IGNORE, true ) ) { 69 return; 70 } 71 self::forget(); 72 } 73 74 /** [다시 점검] (admin-post) */ 75 public static function refresh(): void { 76 check_admin_referer( 'editnday_audit_refresh' ); 77 if ( ! current_user_can( 'manage_options' ) ) { 78 wp_die( esc_html__( '권한이 없어요.', 'editnday' ) ); 79 } 80 self::forget(); 81 wp_safe_redirect( Settings::url( 'audit' ) ); 82 exit; 83 } 84 85 /** 86 * 점검 결과: 저장해 둔 것이 있으면 그것을, 없으면 새로 점검해서 1시간 저장 (12-05). 87 * 글 1000편·내부 주소 확인을 화면을 열 때마다 다시 하지 않으려고. 저장은 글 번호로만 하고 꺼낼 때 글을 한 번에 불러온다 88 * 89 * @return array scan()과 같은 모양 + at(점검한 때) · cached(저장해 둔 결과인가) 90 */ 91 public static function cached(): array { 92 $c = get_transient( self::SCAN_CACHE ); 93 if ( is_array( $c ) && self::SCAN_VER === ( $c['v'] ?? 0 ) ) { 94 $scan = self::hydrate( $c ); 95 if ( null !== $scan ) { 96 $scan['cached'] = true; 97 return $scan; 98 } 99 } 100 $scan = self::scan(); 101 $scan['at'] = time(); 102 set_transient( self::SCAN_CACHE, self::dehydrate( $scan ), self::SCAN_TTL ); 103 self::$forgotten = false; // 새로 저장했으니 이 요청에서 다시 바뀌면 다시 지운다 104 $scan['cached'] = false; 105 return $scan; 106 } 107 108 /** 저장용: 글 객체(본문 포함)를 번호로 바꾼다 */ 109 private static function dehydrate( array $scan ): array { 110 foreach ( array( 'rows', 'excluded' ) as $part ) { 111 foreach ( $scan[ $part ] as $i => $r ) { 112 $scan[ $part ][ $i ]['post'] = (int) $r['post']->ID; 113 } 114 } 115 $scan['v'] = self::SCAN_VER; 116 return $scan; 117 } 118 119 /** 꺼낼 때: 번호를 글 객체로 (한 번에). 그사이 공개가 아니게 된 글이 있으면 null → 새로 점검 */ 120 private static function hydrate( array $c ): ?array { 121 $ids = array(); 122 foreach ( array( 'rows', 'excluded' ) as $part ) { 123 if ( ! isset( $c[ $part ] ) || ! is_array( $c[ $part ] ) ) { 124 return null; 125 } 126 foreach ( $c[ $part ] as $r ) { 127 $ids[] = (int) ( $r['post'] ?? 0 ); 128 } 129 } 130 if ( $ids ) { 131 _prime_post_caches( $ids, false, true ); 132 } 133 foreach ( array( 'rows', 'excluded' ) as $part ) { 134 foreach ( $c[ $part ] as $i => $r ) { 135 $post = get_post( (int) $r['post'] ); 136 if ( ! $post || 'publish' !== $post->post_status ) { 137 return null; 138 } 139 $c[ $part ][ $i ]['post'] = $post; 140 } 141 } 142 unset( $c['v'] ); 143 return $c; 26 144 } 27 145 … … 31 149 */ 32 150 public static function csv(): void { 33 if ( ! current_user_can( 'edit_posts' ) || ! check_admin_referer( 'editnday_audit_csv' ) ) { 151 // 점검 화면과 같은 권한 (화면은 manage_options라 글쓴이는 목록을 볼 수 없다, 12-05) 152 if ( ! current_user_can( 'manage_options' ) || ! check_admin_referer( 'editnday_audit_csv' ) ) { 34 153 wp_die( esc_html__( '권한이 없어요.', 'editnday' ) ); 35 154 } 36 155 $filter = sanitize_key( $_GET['missing'] ?? '' ); 37 $rows = self:: scan()['rows'];156 $rows = self::cached()['rows']; 38 157 if ( $filter ) { 39 158 $rows = array_values( array_filter( $rows, static fn( $r ) => in_array( $filter, $r['missing'], true ) ) ); … … 78 197 const CATS_OPTION = 'editnday_audit_exclude_cats'; 79 198 const HISTORY = 'editnday_audit_history'; // 날짜 => {t: 점검한 글 수, c: 항목별 걸린 글 수} (하루 하나, 최근 120일) 199 const SCAN_CACHE = 'editnday_audit_scan'; // 점검 결과 (글은 번호로만). 글·메타·카테고리가 바뀌면 지운다 (12-05) 200 const SCAN_VER = 1; // 담는 모양이 바뀌면 올린다 201 const SCAN_TTL = HOUR_IN_SECONDS; 202 // 이 메타가 바뀌어도 점검 결과는 같다 (편집 중 몇 초마다 바뀌는 잠금 등): 결과를 지우지 않는다 203 const META_IGNORE = array( '_edit_lock', '_edit_last', '_encloseme', '_pingme', '_wp_old_date', '_wp_old_slug', '_editnday_indexed', '_editnday_audit_prev' ); 204 205 /** 이번 요청에서 이미 지웠나 (메타가 여러 번 바뀌어도 한 번만) */ 206 private static bool $forgotten = false; 80 207 81 208 /** @return int[] 점검에서 뺀 카테고리 */ … … 610 737 } 611 738 $known[ self::path_key( (string) wp_parse_url( home_url( '/' ), PHP_URL_PATH ) ) ] = true; 739 // 최근 1000편 밖의 옛 글: 주소 끝 부분(slug)으로 한 번에 찾아 지금 주소와 같으면 있는 글 (url_to_postid를 주소마다 부르지 않게, 12-05) 740 self::$by_slug = self::slug_map( $unknown, $known ); 741 foreach ( self::$by_slug as $slug => $pid ) { 742 $known[ self::path_key( (string) wp_parse_url( (string) get_permalink( $pid ), PHP_URL_PATH ) ) ] = true; 743 } 612 744 $checked = array(); 613 745 $out = array(); … … 631 763 } 632 764 765 /** @var array<string,int> slug => 공개 글·페이지 번호 (broken_links에서 한 번에 찾은 것) */ 766 private static array $by_slug = array(); 767 768 /** 주소 끝 부분 후보 (그대로·워드프레스가 저장하는 모양) */ 769 private static function slug_candidates( string $key ): array { 770 if ( str_starts_with( $key, '#' ) ) { 771 return array(); 772 } 773 $parts = array_values( array_filter( explode( '/', $key ), 'strlen' ) ); 774 $last = (string) end( $parts ); 775 if ( '' === $last || preg_match( '/^\d+$/', $last ) ) { 776 return array(); 777 } 778 return array_values( array_unique( array( $last, sanitize_title( $last ) ) ) ); 779 } 780 781 /** 782 * 모르는 내부 주소들의 끝 부분과 같은 slug의 공개 글·페이지를 한 번에 (500개씩) 783 * 784 * @param array<int, array<string, true>> $unknown 글 id => 주소 키들. 785 * @param array<string, true> $known 이미 아는 주소. 786 * @return array<string,int> 787 */ 788 private static function slug_map( array $unknown, array $known ): array { 789 global $wpdb; 790 $slugs = array(); 791 foreach ( $unknown as $keys ) { 792 foreach ( array_keys( $keys ) as $key ) { 793 if ( ! isset( $known[ $key ] ) ) { 794 foreach ( self::slug_candidates( $key ) as $slug ) { 795 $slugs[ $slug ] = true; 796 } 797 } 798 } 799 } 800 $out = array(); 801 foreach ( array_chunk( array_keys( $slugs ), 500 ) as $chunk ) { 802 $in = implode( ',', array_fill( 0, count( $chunk ), '%s' ) ); 803 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- 자리 수는 위에서 맞춤 804 $rows = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name FROM {$wpdb->posts} WHERE post_type IN ('post','page') AND post_status = 'publish' AND post_name IN ({$in}) ORDER BY post_date DESC", $chunk ) ); 805 foreach ( (array) $rows as $r ) { 806 $out[ (string) $r->post_name ] ??= (int) $r->ID; 807 } 808 } 809 return $out; 810 } 811 633 812 /** 634 813 * 깨진 주소가 "주소만 바뀐 글"인가 (고유주소 형식을 바꿨거나 글 주소를 고친 경우, 10-07 blography 실측: /2026/06/20/글/ → /글/). … … 645 824 } 646 825 foreach ( array_unique( array( $last, sanitize_title( $last ) ) ) as $slug ) { 826 if ( isset( self::$by_slug[ $slug ] ) ) { 827 return self::$by_slug[ $slug ]; 828 } 647 829 $ids = get_posts( array( 'name' => $slug, 'post_type' => array( 'post', 'page' ), 'post_status' => 'publish', 'numberposts' => 1, 'fields' => 'ids' ) ); 648 830 if ( $ids ) { … … 674 856 675 857 public static function render(): void { 676 $scan = self::scan(); 677 $hist = self::record( $scan ); 858 $scan = self::cached(); 859 // 진행 기록은 새로 점검했을 때만 (저장해 둔 결과는 이미 기록됨) 860 $hist = $scan['cached'] ? (array) get_option( self::HISTORY, array() ) : self::record( $scan ); 678 861 $filter = sanitize_key( $_GET['missing'] ?? '' ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- 보기 거르기만 679 862 $filter = isset( self::items()[ $filter ] ) ? $filter : ''; … … 712 895 esc_html( number_format_i18n( count( $scan['rows'] ) ) ), 713 896 esc_html( number_format_i18n( $scan['ms'] / 1000, 1 ) ) 897 ); 898 if ( $scan['cached'] ) { 899 /* translators: %s: 지난 시간 (예: 5분) */ 900 printf( ' ' . esc_html__( '%s 전에 점검한 결과예요.', 'editnday' ), esc_html( human_time_diff( (int) $scan['at'] ) ) ); 901 } 902 printf( 903 ' <a href="%s">%s</a>', 904 esc_url( wp_nonce_url( add_query_arg( 'action', 'editnday_audit_refresh', admin_url( 'admin-post.php' ) ), 'editnday_audit_refresh' ) ), 905 esc_html__( '다시 점검', 'editnday' ) 714 906 ); 715 907 if ( self::MAX === $scan['total'] ) { -
editnday/tags/1.0.98/readme.txt
r3834533 r3845669 5 5 Tested up to: 7.1 6 6 Requires PHP: 8.1 7 Stable tag: 1.0.9 77 Stable tag: 1.0.98 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 47 47 = Does Editn send my posts anywhere? = 48 48 49 No. All checks run in your browser and on your own server. The only outgoing request isthe optional IndexNow ping described under External services.49 No. All checks run in your browser and on your own server. Site Open opens your own site's addresses (homepage, sitemap, robots.txt and the www or non-www version of your address) to check them, and nothing else is requested from other servers except the optional IndexNow ping described under External services. 50 50 51 51 = Is it a full Korean spell checker? = … … 83 83 == Changelog == 84 84 85 = 1.0.98 = 86 * New: Count visitors correctly behind Cloudflare or a CDN (Settings › Reads). Improved: Faster Content Audit. Fixed: Empty Q&A in schema. 87 85 88 = 1.0.97 = 86 89 * New: Turn the visit-count limit on or off (Settings › Reads). Improved: Only published, public posts and pages are counted. … … 95 98 * New: Recently used colors appear as swatches, so your brand colors are one click away. 96 99 97 = 1.0.89 =98 * New: Admin cards can be folded to keep the screen tidy; your choice is remembered.99 100 100 Full history (Korean): https://editn.day/updates -
editnday/tags/1.0.98/uninstall.php
r3740496 r3845669 9 9 defined( 'WP_UNINSTALL_PLUGIN' ) || exit; 10 10 11 foreach ( array( 'editnday_indexnow', 'editnday_indexnow_v2', 'editnday_indexnow_key', 'editnday_content_style', 'editnday_verify', 'editnday_audit_exclude_cats', 'editnday_audit_history', 'editnday_identity', 'editnday_ai_visits', 'editnday_ai_count' ) as $editnday_option ) {11 foreach ( array( 'editnday_indexnow', 'editnday_indexnow_v2', 'editnday_indexnow_key', 'editnday_content_style', 'editnday_verify', 'editnday_audit_exclude_cats', 'editnday_audit_history', 'editnday_identity', 'editnday_ai_visits', 'editnday_ai_count', 'editnday_business', 'editnday_reach_on', 'editnday_visit_limit', 'editnday_reach_db', 'editnday_proxy_ip' ) as $editnday_option ) { 12 12 delete_option( $editnday_option ); 13 13 } … … 16 16 delete_transient( 'editnday_crawl_seen' ); 17 17 delete_transient( 'editnday_crawl_ai' ); 18 // 콘텐츠 점검 결과(1시간)·횟수 제한 안내(하루) 19 delete_transient( 'editnday_audit_scan' ); 20 delete_transient( 'editnday_limit_hit' ); 18 21 // 콘텐츠 점검에서 뺀 항목 표시 (글 내용이 아니라 점검 설정) 19 22 delete_post_meta_by_key( '_editnday_audit_skip' ); 20 23 delete_post_meta_by_key( '_editnday_audit_prev' ); 24 // 읽힘 세기 표 (방문 집계만 담김, 글 내용 아님) 25 global $wpdb; 26 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}editnday_reach" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery,WordPress.DB.PreparedSQL.InterpolatedNotPrepared -
editnday/trunk/CHANGELOG.md
r3834533 r3845669 3 3 > 이 파일은 `apps/site/src/content/updates/`에서 만들어진다 (`pnpm release:plugin`). 직접 고치지 않는다. 4 4 > 웹에서 보기: https://editn.day/updates 5 6 ## 1.0.98 (2026-12-05) — CDN 사이트의 읽힘 세기 · 콘텐츠 점검 빨라짐 · 질문답 구조화 데이터 고침 7 8 - **CDN 사이트의 읽힘 세기** 9 - 설정 › 읽힘 세기 카드에 「방문자 주소 읽는 곳」을 넣었어요. 접속 주소 그대로(기본) · Cloudflare · 그 밖의 CDN 중에서 골라요. 10 - CDN 뒤에 있는 사이트는 방문자가 모두 CDN 주소로 보여 횟수 제한에 금방 걸렸어요. 쓰는 CDN을 고르면 방문자마다 따로 세요. 11 - Cloudflare를 거쳐 열리는 사이트로 보이면 카드에 알려 줘요. 최근 하루 안에 횟수 제한에 걸린 요청이 있었을 때도 알려 줘요. 12 - **콘텐츠 점검이 빨라졌어요** 13 - 점검 결과를 1시간 기억해 두고, 글·대표 이미지·ALT·검색 설명·카테고리가 바뀌면 바로 새로 점검해요. 화면에 「n분 전에 점검한 결과예요 · 다시 점검」이 보여요. 14 - 오래된 내 글을 가리키는 링크를 한 번에 확인해서, 글이 많은 사이트에서도 깨진 링크 점검이 빨라요. 15 - CSV 내려받기는 점검 화면과 같이 관리자만 할 수 있어요. 16 - **AI 답변 방문 세기** 17 - 방문이 거의 동시에 들어와도 빠짐없이 세요. 지금까지 쌓인 숫자는 업데이트할 때 그대로 옮겨요. 18 - **고침** 19 - 질문이나 답을 비워 둔 질문답 항목은 구조화 데이터(FAQPage)에 나가지 않아요. 20 - 읽힘 깊이를 고쳐 셀 때 지난 날의 숫자가 줄어들던 문제를 고쳤어요. 21 - 에디튼을 지우면 읽힘 세기 기록과 가게 정보 등 남아 있던 설정도 함께 지워요. 요약·질문답·SEO 값은 글의 일부라 그대로 남아요. 5 22 6 23 ## 1.0.97 (2026-11-30) — 읽힘 세기 횟수 제한 켜기·끄기 -
editnday/trunk/editnday.php
r3834533 r3845669 4 4 * Plugin URI: https://editn.day 5 5 * Description: Korean writing check and publishing assistant: spelling, AI-sounding phrases, SEO and Naver previews, summary and FAQ boxes, search engine registration. Runs entirely on your site. 6 * Version: 1.0.9 76 * Version: 1.0.98 7 7 * Requires at least: 6.6 8 8 * Requires PHP: 8.1 … … 16 16 defined( 'ABSPATH' ) || exit; 17 17 18 define( 'EDITNDAY_VERSION', '1.0.9 7' );18 define( 'EDITNDAY_VERSION', '1.0.98' ); 19 19 define( 'EDITNDAY_FILE', __FILE__ ); 20 20 define( 'EDITNDAY_DIR', plugin_dir_path( __FILE__ ) ); -
editnday/trunk/includes/class-ai-ready.php
r3834533 r3845669 19 19 20 20 const IDENTITY = 'editnday_identity'; // {kind: person|org, name, intro, links[]} 21 const VISITS = 'editnday_ai_visits'; // {Y-m-d: {post_id: {src: n}}} 90일 21 const VISITS = 'editnday_ai_visits'; // 옛 저장 {Y-m-d: {post_id: {src: n}}}. 1.0.98부터 읽힘 세기 표로 옮기고 지운다 (migrate) 22 const KEY = 'ai:'; // 읽힘 세기 표({prefix}editnday_reach)의 항목 이름 앞머리: ai:ChatGPT … 22 23 const COUNT_ON = 'editnday_ai_count'; // '0'이면 세지 않음 (기본 켬) 23 24 const FW_CACHE = 'editnday_crawl_ai'; // 방화벽 점검 결과 (12시간) … … 497 498 } 498 499 499 /** 하루·글·출처 숫자 하나 올리기 (90일 넘은 날은 지움) */ 500 /** 501 * 하루·글·출처 숫자 하나 올리기 (12-05: 옵션 하나를 읽고 고쳐 쓰던 것을 읽힘 세기 표로). 502 * 더하기를 데이터베이스가 한 번에 하므로 동시에 들어온 방문을 잃지 않는다. 상한은 전과 같다 503 */ 500 504 public static function bump( int $post, string $src, string $day ): void { 501 $all = get_option( self::VISITS, array() ); 502 $all = is_array( $all ) ? $all : array(); 503 $n = (int) ( $all[ $day ][ $post ][ $src ] ?? 0 ); 504 $sum = array_sum( (array) ( $all[ $day ][ $post ] ?? array() ) ); 505 if ( $sum >= self::DAY_CAP ) { 505 global $wpdb; 506 $table = Reach::table(); 507 $like = $wpdb->esc_like( self::KEY ) . '%'; 508 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- 표 이름은 우리 것 509 $mine = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COALESCE(SUM(n), 0) FROM {$table} WHERE day = %s AND post_id = %d AND k LIKE %s", $day, $post, $like ) ); 510 if ( $mine >= self::DAY_CAP ) { 506 511 return; 507 512 } 508 // 하루 전체 상한 (10-25 보안 점검): 누구나 부를 수 있는 기록이라, 글 번호를 돌려 가며 보내 설정값 하나를끝없이 키우지 못하게.513 // 하루 전체 상한 (10-25 보안 점검): 누구나 부를 수 있는 기록이라, 글 번호를 돌려 가며 보내 끝없이 키우지 못하게. 509 514 // 글 수·방문 합 둘 다 — AI 검색에서 오는 실제 방문은 이보다 훨씬 적다 510 $today = (array) ( $all[ $day ] ?? array() ); 511 if ( ( ! isset( $today[ $post ] ) && count( $today ) >= self::DAY_POSTS ) || array_sum( array_map( 'array_sum', $today ) ) >= self::DAY_TOTAL ) { 515 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared 516 $today = $wpdb->get_row( $wpdb->prepare( "SELECT COUNT(DISTINCT post_id) AS posts, COALESCE(SUM(n), 0) AS total FROM {$table} WHERE day = %s AND k LIKE %s", $day, $like ) ); 517 if ( ( 0 === $mine && (int) ( $today->posts ?? 0 ) >= self::DAY_POSTS ) || (int) ( $today->total ?? 0 ) >= self::DAY_TOTAL ) { 512 518 return; 513 519 } 514 $all[ $day ][ $post ][ $src ] = $n + 1; 515 $cut = wp_date( 'Y-m-d', time() - 90 * DAY_IN_SECONDS ); 516 foreach ( array_keys( $all ) as $d ) { 517 if ( $d < $cut ) { 518 unset( $all[ $d ] ); 519 } 520 } 521 update_option( self::VISITS, $all, false ); 520 Reach::bump( $post, self::KEY . $src, 1, $day ); 521 // 90일 넘은 날 지우기 (읽힘 세기를 꺼 두어도 AI 방문 줄이 쌓이지 않게) 522 if ( 1 === wp_rand( 1, 50 ) ) { 523 Reach::prune(); 524 } 525 } 526 527 /** 528 * 최근 n일 줄: [day, post_id, src, n] 529 * 530 * @return array<int, array{0:string, 1:int, 2:string, 3:int}> 531 */ 532 private static function rows( int $days, int $post = 0 ): array { 533 global $wpdb; 534 $table = Reach::table(); 535 $cut = wp_date( 'Y-m-d', time() - ( $days - 1 ) * DAY_IN_SECONDS ); 536 $like = $wpdb->esc_like( self::KEY ) . '%'; 537 $where = $post ? $wpdb->prepare( ' AND post_id = %d', $post ) : ''; 538 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQL.NotPrepared -- $where는 위에서 prepare 539 $res = $wpdb->get_results( $wpdb->prepare( "SELECT day, post_id, k, SUM(n) AS n FROM {$table} WHERE day >= %s AND k LIKE %s{$where} GROUP BY day, post_id, k", $cut, $like ), ARRAY_A ); 540 $out = array(); 541 foreach ( (array) $res as $r ) { 542 $out[] = array( (string) $r['day'], (int) $r['post_id'], substr( (string) $r['k'], strlen( self::KEY ) ), (int) $r['n'] ); 543 } 544 return $out; 522 545 } 523 546 524 547 /** 최근 n일: 합계 · 출처별 · 글별(많은 순 10개) · 날짜별 */ 525 548 public static function summary( int $days = 30 ): array { 526 $all = get_option( self::VISITS, array() );527 $all = is_array( $all ) ? $all : array();528 $cut = wp_date( 'Y-m-d', time() - ( $days - 1 ) * DAY_IN_SECONDS );529 549 $total = 0; 530 550 $by_src = array(); 531 551 $by_pid = array(); 532 552 $by_day = array(); 533 foreach ( $all as $d => $posts ) { 534 if ( $d < $cut ) { 535 continue; 536 } 537 foreach ( (array) $posts as $pid => $srcs ) { 538 foreach ( (array) $srcs as $s => $n ) { 539 $n = (int) $n; 540 $total += $n; 541 $by_src[ $s ] = ( $by_src[ $s ] ?? 0 ) + $n; 542 $by_pid[ $pid ] = ( $by_pid[ $pid ] ?? 0 ) + $n; 543 $by_day[ $d ] = ( $by_day[ $d ] ?? 0 ) + $n; 544 } 545 } 553 foreach ( self::rows( $days ) as list( $d, $pid, $s, $n ) ) { 554 $total += $n; 555 $by_src[ $s ] = ( $by_src[ $s ] ?? 0 ) + $n; 556 $by_pid[ $pid ] = ( $by_pid[ $pid ] ?? 0 ) + $n; 557 $by_day[ $d ] = ( $by_day[ $d ] ?? 0 ) + $n; 546 558 } 547 559 arsort( $by_src ); … … 557 569 /** 글 하나의 최근 n일 (작성 기록·확장에서) */ 558 570 public static function for_post( int $post, int $days = 30 ): array { 559 $all = get_option( self::VISITS, array() );560 $cut = wp_date( 'Y-m-d', time() - ( $days - 1 ) * DAY_IN_SECONDS );561 571 $out = array(); 562 foreach ( is_array( $all ) ? $all : array() as $d => $posts ) { 563 if ( $d >= $cut ) { 564 foreach ( (array) ( $posts[ $post ] ?? array() ) as $s => $n ) { 565 $out[ $s ] = ( $out[ $s ] ?? 0 ) + (int) $n; 566 } 567 } 572 foreach ( self::rows( $days, $post ) as list( , , $s, $n ) ) { 573 $out[ $s ] = ( $out[ $s ] ?? 0 ) + $n; 568 574 } 569 575 arsort( $out ); 570 576 return $out; 577 } 578 579 /** 580 * 옛 저장(옵션 editnday_ai_visits)을 읽힘 세기 표로 옮긴다 (1.0.98, 표 판 2에서 한 번). 581 * 다 옮긴 뒤에만 옵션을 지운다 (옮기다 오류가 나면 다음에 다시) 582 */ 583 public static function migrate(): void { 584 global $wpdb; 585 $all = get_option( self::VISITS, null ); 586 if ( null === $all ) { 587 return; 588 } 589 $cut = wp_date( 'Y-m-d', time() - Reach::KEEP * DAY_IN_SECONDS ); 590 foreach ( is_array( $all ) ? $all : array() as $d => $posts ) { 591 if ( ! preg_match( '/^\d{4}-\d{2}-\d{2}$/', (string) $d ) || $d < $cut ) { 592 continue; 593 } 594 foreach ( (array) $posts as $pid => $srcs ) { 595 foreach ( (array) $srcs as $src => $n ) { 596 $src = substr( preg_replace( '/[^A-Za-z0-9 .\-]/', '', (string) $src ), 0, 29 ); 597 if ( (int) $pid > 0 && '' !== $src && (int) $n > 0 ) { 598 Reach::bump( (int) $pid, self::KEY . $src, (int) $n, (string) $d ); 599 } 600 } 601 } 602 } 603 if ( '' === $wpdb->last_error ) { 604 delete_option( self::VISITS ); 605 } 571 606 } 572 607 -
editnday/trunk/includes/class-reach.php
r3834533 r3845669 6 6 * - 연락: 전화·메일·지도 링크 누름, 폼 보냄 7 7 * 브라우저가 떠날 때 한 번 보낸다(캐시된 페이지에서도 동작). 쿠키·IP·사용자 식별값은 저장하지 않고, 로그인한 사람(작가 본인)은 세지 않는다. 8 * 저장: 표 {prefix}editnday_reach (day, post_id, k, n). 90일 지나면 지운다. 프로 [성과] 탭이 읽고, AI 답변 방문(AiReady)은 그대로 둔다. 8 * 저장: 표 {prefix}editnday_reach (day, post_id, k, n). 90일 지나면 지운다. 프로 [성과] 탭이 읽는다. 9 * AI 답변 방문(AiReady)도 같은 표에 ai:출처 이름으로 센다 (1.0.98~). summary()는 ai: 줄을 읽지 않는다. 9 10 * 10 11 * @package Editnday … … 19 20 const ON = 'editnday_reach_on'; // '0'이면 세지 않음 (기본 켬) 20 21 const DB_VER = 'editnday_reach_db'; // 표 판 21 const VERSION = 1;22 const VERSION = 2; // 2: AI 답변 방문(ai:출처)도 이 표에 (12-05) 22 23 const DAY_CAP = 2000; // 글 하나·하루·항목 하나 최대 (부풀리기 방지) 23 24 const KEEP = 90; // 보관 일수 … … 25 26 const LIMIT = 'editnday_visit_limit'; // '0'이면 방문 세기 횟수 제한 끔 (기본 켬) 26 27 const PER_IP = 60; // 횟수 제한: 한 주소·10분 (읽힘 세기는 한 번 볼 때 두 번까지 보낸다) 28 const PROXY = 'editnday_proxy_ip'; // 방문자 주소를 어디서 읽나: '' 접속 주소 · 'cf' Cloudflare · 'xff' 그 밖의 프록시 (12-05) 29 const LIMIT_HIT = 'editnday_limit_hit'; // 하루 안에 횟수 제한에 걸린 때 (설정 카드 안내용) 27 30 28 31 public static function init(): void { … … 58 61 ) {$charset};" 59 62 ); 63 AiReady::migrate(); // 판 2: 옵션에 있던 AI 답변 방문을 이 표로 60 64 update_option( self::DB_VER, self::VERSION ); 61 65 } … … 64 68 register_setting( 'editnday', self::ON, array( 'type' => 'string', 'sanitize_callback' => static fn( $v ) => $v ? '1' : '0' ) ); 65 69 register_setting( 'editnday', self::LIMIT, array( 'type' => 'string', 'sanitize_callback' => static fn( $v ) => $v ? '1' : '0' ) ); 70 register_setting( 'editnday', self::PROXY, array( 'type' => 'string', 'sanitize_callback' => static fn( $v ) => in_array( (string) $v, array( 'cf', 'xff' ), true ) ? (string) $v : '' ) ); 66 71 } 67 72 … … 91 96 return true; 92 97 } 93 $ip = isset( $_SERVER['REMOTE_ADDR'] ) ? (string) $_SERVER['REMOTE_ADDR'] : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- 저장하지 않고 해시 열쇠로만 94 $slot = 'editnday_hit_' . $kind . '_' . md5( $ip ); 98 $slot = 'editnday_hit_' . $kind . '_' . md5( self::client_ip() ); 95 99 $used = (int) get_transient( $slot ); 96 100 if ( ! self::within( $used, $cap ) ) { 101 set_transient( self::LIMIT_HIT, time(), DAY_IN_SECONDS ); 97 102 return false; 98 103 } 99 104 set_transient( $slot, $used + 1, 10 * MINUTE_IN_SECONDS ); 100 105 return true; 106 } 107 108 /** 109 * 방문자 주소 (횟수 제한의 열쇠로만 쓰고 저장하지 않는다, 12-05). 110 * CDN·프록시 뒤에서는 접속 주소가 CDN 서버라 모든 방문자가 한 주소로 묶인다 → 설정에서 고른 머리말을 읽는다. 111 * 머리말은 누구나 꾸며 보낼 수 있어서 기본은 접속 주소만 믿고, 작가가 고른 때만 읽는다 112 */ 113 public static function client_ip(): string { 114 $remote = isset( $_SERVER['REMOTE_ADDR'] ) ? (string) $_SERVER['REMOTE_ADDR'] : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- 해시 열쇠로만 115 $ip = self::pick_ip( (string) get_option( self::PROXY, '' ), $remote, (string) ( $_SERVER['HTTP_CF_CONNECTING_IP'] ?? '' ), (string) ( $_SERVER['HTTP_X_FORWARDED_FOR'] ?? '' ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- pick_ip가 IP 모양 확인 116 /** 117 * 방문자 주소를 직접 정한다 (다른 CDN·호스팅의 머리말 등) 118 * 119 * @param string $ip 에디튼이 고른 주소. 120 * @param string $remote 접속 주소 (REMOTE_ADDR). 121 */ 122 return (string) apply_filters( 'editnday_client_ip', $ip, $remote ); 123 } 124 125 /** 설정·머리말로 주소 고르기 (순수). IP 모양이 아니면 접속 주소 */ 126 public static function pick_ip( string $mode, string $remote, string $cf, string $xff ): string { 127 $cand = ''; 128 if ( 'cf' === $mode ) { 129 $cand = trim( $cf ); 130 } elseif ( 'xff' === $mode ) { 131 $cand = trim( explode( ',', $xff )[0] ); 132 } 133 return ( '' !== $cand && false !== filter_var( $cand, FILTER_VALIDATE_IP ) ) ? $cand : $remote; 134 } 135 136 /** 지금 요청 머리말로 본 CDN 추정: 'cf' · 'xff' · '' (설정 카드 안내용) */ 137 public static function detect_proxy(): string { 138 if ( ! empty( $_SERVER['HTTP_CF_CONNECTING_IP'] ) ) { 139 return 'cf'; 140 } 141 return ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ? 'xff' : ''; 101 142 } 102 143 … … 273 314 } 274 315 275 /** 숫자 하나 내리기 (깊이 버킷을 옮길 때). 오늘 줄이 없으면 가장 최근 날에서 */ 316 /** 317 * 숫자 하나 내리기 (깊이 버킷을 옮길 때). 그날 줄에서만 뺀다. 318 * 자정을 넘겨 보정이 오면 그날 줄이 없을 수 있는데, 이때 지난 날에서 빼면 그날 통계가 틀어지므로 아무것도 하지 않는다 (12-05) 319 */ 276 320 public static function unbump( int $post, string $k, string $day ): void { 277 321 global $wpdb; 278 322 $table = self::table(); 279 323 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared 280 $n = (int) $wpdb->query( $wpdb->prepare( "UPDATE {$table} SET n = n - 1 WHERE day = %s AND post_id = %d AND k = %s AND n > 0", $day, $post, $k ) ); 281 if ( ! $n ) { 282 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared 283 $wpdb->query( $wpdb->prepare( "UPDATE {$table} SET n = n - 1 WHERE post_id = %d AND k = %s AND n > 0 ORDER BY day DESC LIMIT 1", $post, $k ) ); 284 } 324 $wpdb->query( $wpdb->prepare( "UPDATE {$table} SET n = n - 1 WHERE day = %s AND post_id = %d AND k = %s AND n > 0", $day, $post, $k ) ); 285 325 } 286 326 … … 344 384 <input type="hidden" name="<?php echo esc_attr( self::LIMIT ); ?>" value="0"> 345 385 <p><label><input type="checkbox" name="<?php echo esc_attr( self::LIMIT ); ?>" value="1" <?php checked( self::limited() ); ?>> <?php esc_html_e( '횟수 제한: 한 주소에서 10분에 60번까지만 세요 (누가 숫자를 부풀리거나 서버를 바쁘게 하지 못하게). AI 답변 방문 세기에도 같이 적용돼요.', 'editnday' ); ?></label></p> 386 <?php 387 $mode = (string) get_option( self::PROXY, '' ); 388 $seen = self::detect_proxy(); 389 $modes = array( 390 '' => __( '접속 주소 그대로 (CDN·프록시를 쓰지 않아요)', 'editnday' ), 391 'cf' => __( 'Cloudflare를 써요 (CF-Connecting-IP)', 'editnday' ), 392 'xff' => __( '그 밖의 CDN·프록시를 써요 (X-Forwarded-For 첫 주소)', 'editnday' ), 393 ); 394 ?> 395 <p><label for="editnday-proxy-ip"><?php esc_html_e( '방문자 주소 읽는 곳', 'editnday' ); ?></label><br> 396 <select id="editnday-proxy-ip" name="<?php echo esc_attr( self::PROXY ); ?>"> 397 <?php foreach ( $modes as $v => $label ) : ?> 398 <option value="<?php echo esc_attr( $v ); ?>" <?php selected( $mode, $v ); ?>><?php echo esc_html( $label ); ?></option> 399 <?php endforeach; ?> 400 </select> 401 </p> 402 <p class="description"><?php esc_html_e( 'CDN 뒤에 있는 사이트는 방문자가 모두 CDN 서버 주소로 보여서 횟수 제한에 금방 걸려요. 쓰는 CDN을 고르면 방문자마다 따로 세요. CDN을 쓰지 않는데 고르면 누구나 주소를 꾸며 제한을 피할 수 있으니 쓰는 것만 골라 주세요.', 'editnday' ); ?></p> 403 <?php if ( $seen && $seen !== $mode ) : ?> 404 <p class="description"><strong><?php echo 'cf' === $seen ? esc_html__( '이 사이트는 Cloudflare를 거쳐 열리는 것 같아요. 위에서 "Cloudflare를 써요"를 골라 주세요.', 'editnday' ) : esc_html__( '이 사이트는 CDN이나 프록시를 거쳐 열리는 것 같아요. 호스팅이나 CDN 설정을 확인하고 맞는 것을 골라 주세요.', 'editnday' ); ?></strong></p> 405 <?php endif; ?> 406 <?php if ( self::limited() && get_transient( self::LIMIT_HIT ) ) : ?> 407 <p class="description"><?php esc_html_e( '최근 하루 안에 횟수 제한에 걸린 요청이 있었어요. 방문이 많은 날이 아니었다면 위의 주소 읽는 곳을 확인해 주세요.', 'editnday' ); ?></p> 408 <?php endif; ?> 346 409 <p class="description"><?php esc_html_e( '브라우저가 글을 떠날 때 한 번, 이 사이트의 워드프레스에만 보내요. 쿠키·IP·방문자 식별값·리퍼러 주소는 저장하지 않고 분류한 이름과 숫자만 남아요. 로그인한 사람(작가)은 세지 않아요. 90일 지나면 지워요. 에디튼 서버로는 가지 않아요. 프로 [성과] 탭에서 봐요.', 'editnday' ); ?></p> 347 410 </div> -
editnday/trunk/includes/class-seo-head.php
r3789451 r3845669 233 233 'acceptedAnswer' => array( '@type' => 'Answer', 'text' => wp_strip_all_tags( (string) ( $q['answer'] ?? '' ) ) ), 234 234 ), 235 array_slice( $ schema['faq'], 0, 6 )235 array_slice( $faq, 0, 6 ) 236 236 ), 237 237 ) -
editnday/trunk/includes/class-site-audit.php
r3789451 r3845669 24 24 add_action( 'admin_post_editnday_audit_undo', array( __CLASS__, 'undo' ) ); 25 25 add_action( 'admin_post_editnday_audit_csv', array( __CLASS__, 'csv' ) ); 26 add_action( 'admin_post_editnday_audit_refresh', array( __CLASS__, 'refresh' ) ); 27 // 점검 결과가 달라질 수 있는 일: 글 저장·지움·상태 바뀜, 글·첨부 메타(대표 이미지·ALT·SEO 값·뺀 항목), 카테고리·태그, 고유주소 형식, 뺄 카테고리 28 foreach ( array( 'save_post', 'deleted_post', 'trashed_post', 'untrashed_post' ) as $hook ) { 29 add_action( $hook, array( __CLASS__, 'forget_post' ) ); 30 } 31 foreach ( array( 'added_post_meta', 'updated_post_meta', 'deleted_post_meta' ) as $hook ) { 32 add_action( $hook, array( __CLASS__, 'forget_meta' ), 10, 3 ); 33 } 34 foreach ( array( 'created_term', 'edited_term', 'delete_term' ) as $hook ) { 35 add_action( $hook, array( __CLASS__, 'forget' ) ); 36 } 37 add_action( 'update_option_permalink_structure', array( __CLASS__, 'forget' ) ); 38 add_action( 'update_option_' . self::CATS_OPTION, array( __CLASS__, 'forget' ) ); 39 add_action( 'add_option_' . self::CATS_OPTION, array( __CLASS__, 'forget' ) ); 40 } 41 42 /** 저장해 둔 점검 결과 지우기 (다음에 화면을 열 때 새로 점검) */ 43 public static function forget(): void { 44 if ( self::$forgotten ) { 45 return; 46 } 47 self::$forgotten = true; 48 delete_transient( self::SCAN_CACHE ); 49 } 50 51 /** 글이 바뀜: 자동 저장·판(revision)은 공개 글이 아니라 점검 결과와 상관없다 */ 52 public static function forget_post( $post_id ): void { 53 $post_id = (int) $post_id; 54 if ( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) { 55 return; 56 } 57 self::forget(); 58 } 59 60 /** 61 * 메타가 바뀜 (에디튼 프로의 AI 채우기·SEO 플러그인 칸·미디어 보관함의 ALT 포함) 62 * 63 * @param mixed $meta_ids 메타 번호(들). 64 * @param int $post_id 글 번호. 65 * @param string $key 메타 이름. 66 */ 67 public static function forget_meta( $meta_ids, $post_id, $key ): void { 68 if ( in_array( (string) $key, self::META_IGNORE, true ) ) { 69 return; 70 } 71 self::forget(); 72 } 73 74 /** [다시 점검] (admin-post) */ 75 public static function refresh(): void { 76 check_admin_referer( 'editnday_audit_refresh' ); 77 if ( ! current_user_can( 'manage_options' ) ) { 78 wp_die( esc_html__( '권한이 없어요.', 'editnday' ) ); 79 } 80 self::forget(); 81 wp_safe_redirect( Settings::url( 'audit' ) ); 82 exit; 83 } 84 85 /** 86 * 점검 결과: 저장해 둔 것이 있으면 그것을, 없으면 새로 점검해서 1시간 저장 (12-05). 87 * 글 1000편·내부 주소 확인을 화면을 열 때마다 다시 하지 않으려고. 저장은 글 번호로만 하고 꺼낼 때 글을 한 번에 불러온다 88 * 89 * @return array scan()과 같은 모양 + at(점검한 때) · cached(저장해 둔 결과인가) 90 */ 91 public static function cached(): array { 92 $c = get_transient( self::SCAN_CACHE ); 93 if ( is_array( $c ) && self::SCAN_VER === ( $c['v'] ?? 0 ) ) { 94 $scan = self::hydrate( $c ); 95 if ( null !== $scan ) { 96 $scan['cached'] = true; 97 return $scan; 98 } 99 } 100 $scan = self::scan(); 101 $scan['at'] = time(); 102 set_transient( self::SCAN_CACHE, self::dehydrate( $scan ), self::SCAN_TTL ); 103 self::$forgotten = false; // 새로 저장했으니 이 요청에서 다시 바뀌면 다시 지운다 104 $scan['cached'] = false; 105 return $scan; 106 } 107 108 /** 저장용: 글 객체(본문 포함)를 번호로 바꾼다 */ 109 private static function dehydrate( array $scan ): array { 110 foreach ( array( 'rows', 'excluded' ) as $part ) { 111 foreach ( $scan[ $part ] as $i => $r ) { 112 $scan[ $part ][ $i ]['post'] = (int) $r['post']->ID; 113 } 114 } 115 $scan['v'] = self::SCAN_VER; 116 return $scan; 117 } 118 119 /** 꺼낼 때: 번호를 글 객체로 (한 번에). 그사이 공개가 아니게 된 글이 있으면 null → 새로 점검 */ 120 private static function hydrate( array $c ): ?array { 121 $ids = array(); 122 foreach ( array( 'rows', 'excluded' ) as $part ) { 123 if ( ! isset( $c[ $part ] ) || ! is_array( $c[ $part ] ) ) { 124 return null; 125 } 126 foreach ( $c[ $part ] as $r ) { 127 $ids[] = (int) ( $r['post'] ?? 0 ); 128 } 129 } 130 if ( $ids ) { 131 _prime_post_caches( $ids, false, true ); 132 } 133 foreach ( array( 'rows', 'excluded' ) as $part ) { 134 foreach ( $c[ $part ] as $i => $r ) { 135 $post = get_post( (int) $r['post'] ); 136 if ( ! $post || 'publish' !== $post->post_status ) { 137 return null; 138 } 139 $c[ $part ][ $i ]['post'] = $post; 140 } 141 } 142 unset( $c['v'] ); 143 return $c; 26 144 } 27 145 … … 31 149 */ 32 150 public static function csv(): void { 33 if ( ! current_user_can( 'edit_posts' ) || ! check_admin_referer( 'editnday_audit_csv' ) ) { 151 // 점검 화면과 같은 권한 (화면은 manage_options라 글쓴이는 목록을 볼 수 없다, 12-05) 152 if ( ! current_user_can( 'manage_options' ) || ! check_admin_referer( 'editnday_audit_csv' ) ) { 34 153 wp_die( esc_html__( '권한이 없어요.', 'editnday' ) ); 35 154 } 36 155 $filter = sanitize_key( $_GET['missing'] ?? '' ); 37 $rows = self:: scan()['rows'];156 $rows = self::cached()['rows']; 38 157 if ( $filter ) { 39 158 $rows = array_values( array_filter( $rows, static fn( $r ) => in_array( $filter, $r['missing'], true ) ) ); … … 78 197 const CATS_OPTION = 'editnday_audit_exclude_cats'; 79 198 const HISTORY = 'editnday_audit_history'; // 날짜 => {t: 점검한 글 수, c: 항목별 걸린 글 수} (하루 하나, 최근 120일) 199 const SCAN_CACHE = 'editnday_audit_scan'; // 점검 결과 (글은 번호로만). 글·메타·카테고리가 바뀌면 지운다 (12-05) 200 const SCAN_VER = 1; // 담는 모양이 바뀌면 올린다 201 const SCAN_TTL = HOUR_IN_SECONDS; 202 // 이 메타가 바뀌어도 점검 결과는 같다 (편집 중 몇 초마다 바뀌는 잠금 등): 결과를 지우지 않는다 203 const META_IGNORE = array( '_edit_lock', '_edit_last', '_encloseme', '_pingme', '_wp_old_date', '_wp_old_slug', '_editnday_indexed', '_editnday_audit_prev' ); 204 205 /** 이번 요청에서 이미 지웠나 (메타가 여러 번 바뀌어도 한 번만) */ 206 private static bool $forgotten = false; 80 207 81 208 /** @return int[] 점검에서 뺀 카테고리 */ … … 610 737 } 611 738 $known[ self::path_key( (string) wp_parse_url( home_url( '/' ), PHP_URL_PATH ) ) ] = true; 739 // 최근 1000편 밖의 옛 글: 주소 끝 부분(slug)으로 한 번에 찾아 지금 주소와 같으면 있는 글 (url_to_postid를 주소마다 부르지 않게, 12-05) 740 self::$by_slug = self::slug_map( $unknown, $known ); 741 foreach ( self::$by_slug as $slug => $pid ) { 742 $known[ self::path_key( (string) wp_parse_url( (string) get_permalink( $pid ), PHP_URL_PATH ) ) ] = true; 743 } 612 744 $checked = array(); 613 745 $out = array(); … … 631 763 } 632 764 765 /** @var array<string,int> slug => 공개 글·페이지 번호 (broken_links에서 한 번에 찾은 것) */ 766 private static array $by_slug = array(); 767 768 /** 주소 끝 부분 후보 (그대로·워드프레스가 저장하는 모양) */ 769 private static function slug_candidates( string $key ): array { 770 if ( str_starts_with( $key, '#' ) ) { 771 return array(); 772 } 773 $parts = array_values( array_filter( explode( '/', $key ), 'strlen' ) ); 774 $last = (string) end( $parts ); 775 if ( '' === $last || preg_match( '/^\d+$/', $last ) ) { 776 return array(); 777 } 778 return array_values( array_unique( array( $last, sanitize_title( $last ) ) ) ); 779 } 780 781 /** 782 * 모르는 내부 주소들의 끝 부분과 같은 slug의 공개 글·페이지를 한 번에 (500개씩) 783 * 784 * @param array<int, array<string, true>> $unknown 글 id => 주소 키들. 785 * @param array<string, true> $known 이미 아는 주소. 786 * @return array<string,int> 787 */ 788 private static function slug_map( array $unknown, array $known ): array { 789 global $wpdb; 790 $slugs = array(); 791 foreach ( $unknown as $keys ) { 792 foreach ( array_keys( $keys ) as $key ) { 793 if ( ! isset( $known[ $key ] ) ) { 794 foreach ( self::slug_candidates( $key ) as $slug ) { 795 $slugs[ $slug ] = true; 796 } 797 } 798 } 799 } 800 $out = array(); 801 foreach ( array_chunk( array_keys( $slugs ), 500 ) as $chunk ) { 802 $in = implode( ',', array_fill( 0, count( $chunk ), '%s' ) ); 803 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- 자리 수는 위에서 맞춤 804 $rows = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name FROM {$wpdb->posts} WHERE post_type IN ('post','page') AND post_status = 'publish' AND post_name IN ({$in}) ORDER BY post_date DESC", $chunk ) ); 805 foreach ( (array) $rows as $r ) { 806 $out[ (string) $r->post_name ] ??= (int) $r->ID; 807 } 808 } 809 return $out; 810 } 811 633 812 /** 634 813 * 깨진 주소가 "주소만 바뀐 글"인가 (고유주소 형식을 바꿨거나 글 주소를 고친 경우, 10-07 blography 실측: /2026/06/20/글/ → /글/). … … 645 824 } 646 825 foreach ( array_unique( array( $last, sanitize_title( $last ) ) ) as $slug ) { 826 if ( isset( self::$by_slug[ $slug ] ) ) { 827 return self::$by_slug[ $slug ]; 828 } 647 829 $ids = get_posts( array( 'name' => $slug, 'post_type' => array( 'post', 'page' ), 'post_status' => 'publish', 'numberposts' => 1, 'fields' => 'ids' ) ); 648 830 if ( $ids ) { … … 674 856 675 857 public static function render(): void { 676 $scan = self::scan(); 677 $hist = self::record( $scan ); 858 $scan = self::cached(); 859 // 진행 기록은 새로 점검했을 때만 (저장해 둔 결과는 이미 기록됨) 860 $hist = $scan['cached'] ? (array) get_option( self::HISTORY, array() ) : self::record( $scan ); 678 861 $filter = sanitize_key( $_GET['missing'] ?? '' ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- 보기 거르기만 679 862 $filter = isset( self::items()[ $filter ] ) ? $filter : ''; … … 712 895 esc_html( number_format_i18n( count( $scan['rows'] ) ) ), 713 896 esc_html( number_format_i18n( $scan['ms'] / 1000, 1 ) ) 897 ); 898 if ( $scan['cached'] ) { 899 /* translators: %s: 지난 시간 (예: 5분) */ 900 printf( ' ' . esc_html__( '%s 전에 점검한 결과예요.', 'editnday' ), esc_html( human_time_diff( (int) $scan['at'] ) ) ); 901 } 902 printf( 903 ' <a href="%s">%s</a>', 904 esc_url( wp_nonce_url( add_query_arg( 'action', 'editnday_audit_refresh', admin_url( 'admin-post.php' ) ), 'editnday_audit_refresh' ) ), 905 esc_html__( '다시 점검', 'editnday' ) 714 906 ); 715 907 if ( self::MAX === $scan['total'] ) { -
editnday/trunk/readme.txt
r3834533 r3845669 5 5 Tested up to: 7.1 6 6 Requires PHP: 8.1 7 Stable tag: 1.0.9 77 Stable tag: 1.0.98 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 47 47 = Does Editn send my posts anywhere? = 48 48 49 No. All checks run in your browser and on your own server. The only outgoing request isthe optional IndexNow ping described under External services.49 No. All checks run in your browser and on your own server. Site Open opens your own site's addresses (homepage, sitemap, robots.txt and the www or non-www version of your address) to check them, and nothing else is requested from other servers except the optional IndexNow ping described under External services. 50 50 51 51 = Is it a full Korean spell checker? = … … 83 83 == Changelog == 84 84 85 = 1.0.98 = 86 * New: Count visitors correctly behind Cloudflare or a CDN (Settings › Reads). Improved: Faster Content Audit. Fixed: Empty Q&A in schema. 87 85 88 = 1.0.97 = 86 89 * New: Turn the visit-count limit on or off (Settings › Reads). Improved: Only published, public posts and pages are counted. … … 95 98 * New: Recently used colors appear as swatches, so your brand colors are one click away. 96 99 97 = 1.0.89 =98 * New: Admin cards can be folded to keep the screen tidy; your choice is remembered.99 100 100 Full history (Korean): https://editn.day/updates -
editnday/trunk/uninstall.php
r3740496 r3845669 9 9 defined( 'WP_UNINSTALL_PLUGIN' ) || exit; 10 10 11 foreach ( array( 'editnday_indexnow', 'editnday_indexnow_v2', 'editnday_indexnow_key', 'editnday_content_style', 'editnday_verify', 'editnday_audit_exclude_cats', 'editnday_audit_history', 'editnday_identity', 'editnday_ai_visits', 'editnday_ai_count' ) as $editnday_option ) {11 foreach ( array( 'editnday_indexnow', 'editnday_indexnow_v2', 'editnday_indexnow_key', 'editnday_content_style', 'editnday_verify', 'editnday_audit_exclude_cats', 'editnday_audit_history', 'editnday_identity', 'editnday_ai_visits', 'editnday_ai_count', 'editnday_business', 'editnday_reach_on', 'editnday_visit_limit', 'editnday_reach_db', 'editnday_proxy_ip' ) as $editnday_option ) { 12 12 delete_option( $editnday_option ); 13 13 } … … 16 16 delete_transient( 'editnday_crawl_seen' ); 17 17 delete_transient( 'editnday_crawl_ai' ); 18 // 콘텐츠 점검 결과(1시간)·횟수 제한 안내(하루) 19 delete_transient( 'editnday_audit_scan' ); 20 delete_transient( 'editnday_limit_hit' ); 18 21 // 콘텐츠 점검에서 뺀 항목 표시 (글 내용이 아니라 점검 설정) 19 22 delete_post_meta_by_key( '_editnday_audit_skip' ); 20 23 delete_post_meta_by_key( '_editnday_audit_prev' ); 24 // 읽힘 세기 표 (방문 집계만 담김, 글 내용 아님) 25 global $wpdb; 26 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}editnday_reach" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery,WordPress.DB.PreparedSQL.InterpolatedNotPrepared
Note:
See TracChangeset
for help on using the changeset viewer.