=== Meguro Writer ===
Tags: ai, news, gemini, automation, publishing
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 3.5.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Automatically discovers, writes, schedules, and publishes AI news to WordPress with Gemini, regional targeting, and multilingual output.

== Description ==

Meguro Writer uses the Google Gemini API and Google Search grounding to discover current information, generate news articles, and publish them to WordPress on a configurable schedule.

The plugin is designed for general-purpose use across different media sites. You can configure the target countries and regions, article language, search language, editorial style, post type, taxonomy, publishing status, author, image generation, and publishing schedule.

Main features:

* Discover current news with Google Search grounding.
* Configure custom search topics such as technology, business, finance, real estate, entertainment, politics, and local news.
* Configure the media name, AI role, target audience, article purpose, tone, and additional instructions.
* Select article language and search language independently.
* Target up to 10 countries or regions at the same time.
* Use regional groups such as Southeast Asia, East Asia, the Middle East, North America, Europe, Russia/CIS, Latin America, Africa, and Oceania.
* Use a global mode that searches worldwide while prioritizing selected countries and regions.
* Target the United States nationally or by state and Washington, D.C.
* Target China nationally or by province, municipality, or autonomous region.
* Treat Taiwan, Hong Kong, and Macao as separate selectable targets in the plugin's news-targeting interface.
* Adjust editorial selection with six 10-level sliders: entertainment, politics, freshness, regional focus, audience gender balance, and tone.
* Configure excluded topics, source preferences, and additional AI prompts.
* Choose a WordPress post type as the publishing destination.
* Enter a custom post type slug manually when it is not listed automatically.
* Auto-detect, select, or manually enter a taxonomy slug.
* Choose Publish, Draft, Pending Review, or Private as the target post status.
* Choose the WordPress author account used for generated posts.
* Configure a separate schedule for each day of the week, with up to 15 publishing times per day.
* Use the Monthly Publishing Plan to override individual date/time slots with a specific topic, an original AI-written column, a skip action, or an extra one-time post.
* Detect duplicate source URLs and similar titles.
* Configure minimum relevance, confidence, and news freshness.
* Configure minimum/maximum article length and repeatable structured H2 sections.
* Create scheduled original columns by specifying a fixed title, theme, writing instructions, optional reference URLs, and category.
* Write Yoast SEO meta description and focus keyphrase data when applicable.
* Enable or disable the summary-points block and source box.
* Optionally embed X posts, Instagram posts/reels, and YouTube videos, with a configurable per-article maximum.
* Optionally add verified official-site and official-social links related to the article.
* Optionally prefer suitable official press/media images over AI-generated images and display image-source attribution.
* Optionally split broad topics into a 2-4 part linked article series when one article would be too dense.
* Generate featured images with Gemini using a configurable exact pixel size or aspect ratio.
* Optionally use up to three reference images for image generation.
* Use a common featured image as a fallback when image generation is unavailable.
* Optionally map data to ACF or postmeta custom fields.
* Export and import the complete plugin configuration and Monthly Publishing Plan as JSON.
* View execution logs, send failure notifications, run a manual post, and test the Gemini API connection.
* Open a dedicated Support page to optionally support development through PayPal or contact the developer by email. All plugin features remain free regardless of contributions.

Support contact: kenget0616@gmail.com

== Installation ==

1. In WordPress, open Plugins > Add New Plugin > Upload Plugin.
2. Upload the Meguro Writer ZIP file and activate the plugin.
3. Open Meguro Writer > Settings.
4. Configure your Gemini API key. The key can be stored in the database, but defining it in `wp-config.php` is recommended:

`define('MEGURO_WRITER_GEMINI_API_KEY', 'YOUR_API_KEY');`

Earlier API-key constants are also supported for backward compatibility:

`define('KT_AI_NEWS_GEMINI_API_KEY', 'YOUR_API_KEY');`

`define('LIVPLUS_GEMINI_API_KEY', 'YOUR_API_KEY');`

5. Configure the article language, search language, target countries or regions, publishing destination, search topics, audience, editorial settings, and schedule.
6. Run the Gemini API connection test.
7. Use the manual single-post generation action before enabling automated publishing.

== Updating from earlier versions ==

Starting with version 3.2.2, the official distribution folder and main plugin file are `meguro-writer/meguro-writer.php`.

When Meguro Writer is activated while an earlier `kt-ai-news` or `livplus-ai-news` plugin is active, Meguro Writer deactivates the earlier plugin. Existing settings, monthly-plan data, log tables, and generated-post metadata are retained.

After confirming that the new plugin works correctly, the old `kt-ai-news` and/or `livplus-ai-news` folder can be removed.

Some internal option names, database table names, legacy metadata keys, and compatibility aliases remain available to avoid breaking existing installations.

== Settings backup and restore ==

Open Meguro Writer > Settings Backup to export or import the plugin configuration in JSON format.

The backup includes:

* General settings and publishing destination.
* AI editorial rules and slider values.
* Article language, search language, target countries and regions, and United States/China subregion settings.
* Search topics, image settings, SEO settings, and notifications.
* Social embeds, official links, official-image preference, image credit, and series settings.
* Weekly publishing schedule.
* Monthly Publishing Plan.
* Custom-field mappings.

The Gemini API key is excluded by default. It is included only when the administrator explicitly enables the option to export it.

When importing settings into another site, WordPress user IDs, media attachment IDs, post types, taxonomies, and custom-field structures may differ. Review the settings after import.

== Support and optional contributions ==

Meguro Writer is fully functional and free to use. Contributions are optional and do not unlock or restrict any plugin features.

The Meguro Writer > Support page includes a PayPal.Me amount builder and displays the developer contact email address. Enter a support amount, choose USD, JPY, or EUR, and Meguro Writer creates the corresponding PayPal.Me payment URL in the browser. Clicking the email button opens the administrator's local mail application; Meguro Writer does not submit feedback through the WordPress mail configuration.

For example, an amount of `5000` with `JPY` opens `https://www.paypal.com/paypalme/meguroplugin/5000JPY`. Japanese yen is validated as a whole-number currency with a minimum support amount of JPY 1,000. USD and EUR accept up to two decimal places with a minimum support amount of 10. Site owners building a customized distribution can override the PayPal.Me base URL with the `MEGURO_WRITER_PAYPAL_ME_URL` constant, and can override the displayed support email with `MEGURO_WRITER_SUPPORT_EMAIL`.

== External services ==

Meguro Writer uses Google Gemini API / Google AI services for news discovery, article generation, image generation, and API connection tests.

Activating the plugin alone does not send requests to Google. Requests are made when an administrator configures an API key and runs a connection test, manual generation, or scheduled generation.

Data that may be sent to Google includes administrator-configured search topics, prompts and editorial instructions, selected language and geographic targeting, news information gathered for article generation, optional reference URLs, image-generation instructions, and reference images when the reference-image feature is enabled.

Meguro Writer is not designed to collect ordinary site visitors' personal information and send it to Gemini.

Service: Google AI for Developers / Gemini API
https://ai.google.dev/

Gemini API Additional Terms of Service:
https://ai.google.dev/gemini-api/terms

Google Privacy Policy:
https://policies.google.com/privacy

If X, Instagram, or YouTube embedding is enabled and a generated article contains one of those embeds, the visitor's browser connects directly to the corresponding third-party service when the article is viewed. Those providers may receive technical information such as the visitor's IP address, browser information, cookies, or account-related data according to their own policies.

YouTube:
https://www.youtube.com/
YouTube Terms of Service:
https://www.youtube.com/t/terms
Google Privacy Policy:
https://policies.google.com/privacy

X:
https://x.com/
X Privacy Policy:
https://x.com/en/privacy

Instagram:
https://www.instagram.com/
Meta Privacy Policy:
https://www.facebook.com/privacy/policy/

Social embedding is optional and disabled by default for each provider.

When the official-image preference is enabled, Meguro Writer may retrieve an image file from an official source URL selected during news discovery and store it in the WordPress Media Library. The plugin instructs Gemini to prefer official press/media assets that appear suitable for attributed use, but site administrators remain responsible for confirming image rights and usage conditions.

Google may apply different data-handling terms depending on the Gemini API plan or service tier. Review the current terms and privacy policy before using the service with confidential or personal information.

The optional Support page can also communicate with third-party or external services only when an administrator explicitly takes an action:

* PayPal: The optional Support page lets an administrator enter an amount and choose USD, JPY, or EUR. Meguro Writer builds a PayPal.Me URL from that selection. Submitting the form opens a new tab through a WordPress admin-post redirect, so the payment action still works even when the page JavaScript is blocked or cached. PayPal may process the administrator's IP address, account details, payment details, cookies, and other information under PayPal's own terms and privacy policy. Simply opening the Meguro Writer Support page does not contact PayPal.

PayPal:
https://www.paypal.com/

PayPal Privacy Statement:
https://www.paypal.com/us/legalhub/paypal/privacy-full

== Privacy ==

Meguro Writer does not include its own analytics, telemetry, or usage tracking.

When Gemini API features are used, data described in the External services section is sent to Google for generation or search-related processing.

When social embeds are enabled and present in an article, visitors viewing that article may connect directly to YouTube, X, or Instagram. Review the relevant provider privacy policies and update your site's privacy notice as appropriate.

If a settings backup is exported with the Gemini API key included, the resulting JSON file contains confidential credentials and must be stored securely.

== Frequently Asked Questions ==

= Does Meguro Writer automatically create new categories? =

No. The plugin selects from existing terms in the configured taxonomy. A configured fallback term can be used when no suitable existing term is returned.

= Will WordPress Cron always run at the exact configured time? =

WP-Cron is triggered by site traffic and may not execute at an exact time. For production sites that require predictable schedules, use a server cron job or another scheduler to call `wp-cron.php` regularly.

= Is the Gemini API key included in configuration backups? =

Not by default. It is included only when the administrator explicitly enables the API-key export option.

= Can I publish international news in Japanese? =

Yes. Geographic targeting and article language are independent. For example, you can target the United States, United Kingdom, and Canada while generating the final articles in Japanese.

= How are Taiwan, Hong Kong, and Macao handled? =

In the Meguro Writer targeting interface, Taiwan, Hong Kong, and Macao are separate selectable targets and are not included in the China province/subregion selector.

= Can I prioritize several countries while still searching globally? =

Yes. Use Global mode and select up to 10 priority countries or regions. The regional-focus slider controls how strongly those selected targets are prioritized relative to worldwide news.

= How do social embeds work? =

You can enable X, Instagram, and YouTube independently and set a combined per-article maximum. Meguro Writer asks Gemini to return directly relevant official or primary-source post/video URLs. Embeds are rendered only for enabled providers. Viewing an embedded item connects the visitor's browser to the corresponding provider.

= Does the plugin automatically reuse any image it finds online? =

No. The official-image preference is optional. When enabled, Gemini is instructed to return an official press/media image only when it appears suitable for attributed use. If retrieval fails, Meguro Writer falls back to AI image generation or the configured common featured image. Administrators remain responsible for checking image rights.

== Changelog ==

= 3.5.3 =
* Moved extra one-time posts from the monthly summary block to the corresponding calendar date row.
* Added a per-day extra-post count badge so dates with extra posts are immediately identifiable.
* Extra posts are collapsed by default and can be expanded/collapsed under each date without adding time columns to the weekly schedule matrix.

= 3.5.2 =
* Added image output settings: exact pixel size or vertical:horizontal ratio.
* Final featured images are resized/cropped to the configured dimensions before logo overlay.
* Fixed logo and tone/manner option panels so they show/hide immediately when toggled.
* Added a direct link to the Support page from the Backup / Support panel.

= 3.5.1 =
* Removed remaining legacy product-name wording from the visible admin UI.
* Kept legacy option/meta identifiers internally for backward compatibility.

= 3.4.5 =
* Reworked the PayPal.Me support controls into two stacked actions: “Support with the amount above” and an orange “Support with a specified amount” link that opens the generic PayPal.Me page.
* Added live visual validation to the amount field: values below JPY 1,000 or USD/EUR 10 are highlighted in red and return to white at the valid threshold.
* Kept server-side minimum-amount validation for the preset-amount support action.

= 3.4.4 =
* Added minimum support amounts to the PayPal.Me support form: JPY 1,000 and USD/EUR 10.
* Minimum amounts are enforced both in the browser and again on the server before redirecting to PayPal.
* Restored the explicit “Support with specified amount” button label across all 10 supported admin UI languages.

= 3.4.3 =
* Updated the built-in PayPal.Me support destination to `https://www.paypal.com/paypalme/meguroplugin`.
* The dynamic USD / JPY / EUR support amount builder and server-side redirect now use the new PayPal.Me profile by default.

= 3.4.2 =
* Added a “Current time +10 min” helper beside the time field in the monthly publishing-plan modal.
* The quick-time helper uses the WordPress site time basis and safely handles date rollover when scheduling an extra post near midnight.
* Added translations for the helper across all 10 supported admin UI languages.

= 3.4.1 =
* Fixed the Monthly Publishing Plan modal so Column-only fields are shown only when the Column publishing method is selected.
* Added a page-local display fallback so Topic, Column, reference URL, and category rows remain correctly hidden/shown even when an older cached admin asset is present.

= 3.4.0 =
* Fixed the Monthly Publishing Plan reference-URL add/remove control and added a page-local fallback so URL rows can still be added when the shared admin JavaScript is affected by another admin script.
* Added a new Column publishing method for any monthly-plan time slot, including regular and extra one-time slots.
* Column posts use a user-specified title, theme, content instructions, optional reference URLs, and category instead of automatically selecting a news candidate.
* Column reference URLs can use Google Search grounding for fact/background verification, while the planned title remains authoritative.
* Added Column UI text and help in all 10 built-in admin languages.
* Monthly-plan backup/import now preserves Column settings.

= 3.3.6 =
* Fixed the Support page when the PayPal amount/currency preview JavaScript did not run on some admin environments.
* The support form now has a server-side WordPress fallback that validates the amount/currency and opens the correct PayPal.Me URL in a new tab.
* The payment URL preview now uses a small page-local script and no longer depends on the shared admin.js bundle.
* Corrected the previous changelog label for version 3.3.4.

= 3.3.5 =
* Replaced the fixed PayPal.Me amount buttons with a dynamic support amount form.
* Administrators can enter an amount, choose USD, JPY, or EUR, and open the generated PayPal.Me URL.
* Added currency-aware validation: JPY uses whole numbers, while USD and EUR support up to two decimal places.
* Added the new support amount and currency controls in all 10 built-in admin languages.

= 3.3.4 =
* Removed the built-in feedback submission form because WordPress mail delivery depends on each site's mail/SMTP environment.
* The Support page now shows a direct developer email address and a mailto button instead of sending feedback with `wp_mail()`.
* Added the direct-email support text and button in all 10 built-in admin languages.

= 3.3.3 =
* Replaced the legacy PayPal donation form with PayPal.Me support links.
* Added $10, $20, $50, and custom-amount support buttons.
* Added the new PayPal support controls in all 10 built-in admin languages.
* Contributions remain fully optional and never unlock or restrict plugin features.

= 3.3.2 =
* Added a dedicated Support page under the Meguro Writer admin menu.
* Added an optional PayPal contribution button; contributions never unlock or restrict features.
* Added an administrator feedback form that sends comments to the developer with WordPress `wp_mail()` without storing message content in the plugin database.
* Added the new Support page UI in all 10 built-in admin languages.

= 3.3.1 =
* Added multiple reference URLs (up to 10) for monthly-plan topic posts.
* Added repeatable H2 headings with add/remove controls.
* Added optional maximum article body length and generation-time range enforcement.
* Added translations for the new controls across all 10 supported admin languages.

= 3.3.0 =
* Added automatic WordPress-user-locale detection for the Meguro Writer admin UI.
* Added built-in support for Japanese, English, Simplified Chinese, Traditional Chinese, Korean, German, French, Italian, Spanish, and Portuguese.
* Non-Japanese locales use English fallback for any helper text that does not yet have a native translation.
* Localized monthly-plan modal JavaScript and major admin notices.
* Country/region names fall back to the existing English labels outside Japanese.


= 3.2.4 =
* Locked past dates and elapsed times in the Monthly Publishing Plan and displayed them in gray.
* Kept past topic overrides and skip settings available for read-only inspection while preventing edits or deletion.
* Added server-side protection so past monthly-plan slots cannot be modified through direct requests.
* Applied the same read-only behavior to past one-time posts in the monthly one-time-post list.

= 3.2.3 =
* Fixed Monthly Publishing Plan one-time posts so an extra time no longer creates an empty time column for every date in the month.
* Added a dedicated monthly one-time-post list with direct editing for each extra post.
* Fixed malformed weekday markup in the monthly plan date column.
* Restored the current-day row highlight and Today badge that regressed during the 3.2.2 rename build.

= 3.2.2 =
* Renamed the plugin to Meguro Writer and changed the distribution slug/text domain to `meguro-writer`.
* Added migration compatibility for earlier plugin installations.
* Made scheduled-slot and process locking atomic to prevent duplicate posts during concurrent cron requests.

= 3.2.1 =
* Highlighted the current date row in the Monthly Publishing Plan with a distinct background, border, and Today badge for easier navigation.

= 3.2.0 =
* Added independent X, Instagram, and YouTube embed settings with a configurable combined embed limit per article.
* Added verified official-site and official-social link enrichment.
* Added optional official-image preference with source attribution and AI-image fallback.
* Added optional automatic 2-4 part series generation for topics that should not be forced into a single article.
* Added linked series navigation and series metadata.
* Added privacy and external-service documentation for social embeds and official-image retrieval.

= 3.1.2 =
* Fixed WordPress Plugin Check database-preparation errors by using identifier placeholders for custom log-table queries.
* Replaced the duplicate-source direct SQL query with the WordPress post query API.
* Rewrote the WordPress.org readme in standard English.
* Updated internal PHP class names to use the Meguro Writer prefix while retaining legacy class aliases for backward compatibility.
* Removed the manual `load_plugin_textdomain()` call because WordPress.org loads plugin translations automatically.
* Improved settings import file validation and read-only monthly-plan request handling.

= 3.1.1 =
* Replaced heredoc strings to satisfy WordPress.org Plugin Check requirements.
* Added the `Tested up to` readme header.
* Removed unexpected root Markdown documentation from the WordPress.org distribution ZIP.

= 3.1.0 =
* Added independent article-language and search-language settings.
* Added up to 10 selectable target countries or regions.
* Added regional groups for Southeast Asia, the Middle East, East Asia, South Asia, Central Asia, North America, Europe, Russia/CIS, Latin America, Africa, and Oceania.
* Added Selected Targets mode and Global + Priority Targets mode.
* Added United States national/state/Washington, D.C. targeting.
* Added China national/province/municipality/autonomous-region targeting.
* Added Taiwan, Hong Kong, and Macao as separate targeting entries in the plugin interface.
* Reworked the former Japan-specific location slider into a dynamic regional-focus slider.
* Applied language and geographic targeting to news discovery, article generation, and image generation.
* Added localized standard content labels for major article languages.
* Included the new language and geographic settings in configuration backup and restore.

= 3.0.0 =
* Changed the official distribution slug to `kt-ai-news` and the main file to `kt-ai-news.php`.
* Added migration handling for the legacy `livplus-ai-news` plugin.
* Added complete settings and Monthly Publishing Plan JSON export/import.
* Added optional API-key export.
* Added a Settings Backup admin screen and support contact information.
* Added GPLv2-or-later licensing metadata.
* Documented Gemini API usage as an external service.

= 2.1.0 =
* Added the Monthly Publishing Plan as a separate admin screen.
* Added a date-by-time monthly matrix based on the weekly schedule.
* Added per-slot topic overrides and skip actions.
* Added extra one-time publishing slots outside the normal weekly schedule.
* Stored only monthly exceptions so untouched slots continue to follow weekly schedule changes.
* Added per-slot topic, instruction, reference URL, and category settings.

= 2.0.1 =
* Added six 10-level editorial preference sliders.
* Applied editorial slider values to news selection, article generation, and image direction.

= 2.0.0 =
* Renamed the plugin to Meguro Writer.
* Generalized the original real-estate-specific prompts for arbitrary topics.
* Added configurable post type, taxonomy, post status, and author.
* Added `KT_AI_NEWS_GEMINI_API_KEY` while retaining the legacy constant for compatibility.
