DK Post Sync for Google Docs

Description

This plugin is not affiliated with, endorsed by, or sponsored by Google LLC.

DK Post Sync for Google Docs keeps one Google Doc for every published post in a Google Drive folder you choose. The purpose is to give tools such as Gemini or an MCP integration a Google Docs copy of your site’s content to use as a knowledge base, without granting those tools access to the site itself. The Docs stay current as you publish, edit, unpublish, and delete posts, and they remain easy to read, search, and share from Google Drive.

Each Doc contains:

  • A Post Details table: title, URL, post ID, slug, status, published and modified dates, author, categories, tags, excerpt, SEO title, meta description, focus keyword and canonical URL (from Rank Math or Yoast SEO when either is active), the featured image and its alt text, and the word count.
  • The featured image.
  • The post content, rendered the same way your site renders it. Scripts, forms, and styling are removed, and embeds become links.
  • Images in This Post: every image URL with its alt text.

You can also add an optional HTML header at the top of every Doc (Settings DK Post Sync Settings). Leave it blank for no header. The placeholders {post_title}, {permalink}, and {date} are replaced for each post.

How syncing works

  • Post published: a Doc is created, or the existing Doc is restored from the Drive trash.
  • Published post updated (content, title, tags, categories, featured image, or SEO fields): the Doc’s content is replaced.
  • Post unpublished, made private, password-protected, or trashed: the Doc is moved to the Drive trash.
  • Post deleted permanently: the Doc is moved to the Drive trash.

Saving a post never calls Google directly. The post is added to a queue, and WP-Cron sends the queue to Drive about 20 seconds later, then every 5 minutes. Settings DK Post Sync Sync Sync All Posts queues everything and works through the queue while the page is open. Posts that haven’t changed are skipped.

Nothing happens until you connect Google

The plugin uses your own Google Cloud OAuth client, so your Google data goes only between your site and Google. Until an administrator saves a client and connects a Google account:

  • A notice on the plugin’s screen and on the Plugins screen links to the setup tab.
  • Every sync control is greyed out and disabled.
  • The server refuses every sync request, nothing is queued or scheduled, and no request is sent to Google.

Once you’re connected, the Google Connection tab shows the connected account’s email address and the connection status. If Google revokes or expires the connection, syncing stops, post changes keep queueing, and a notice asks you to reconnect.

Drive access

By default the plugin asks only for the drive.file scope. With it, the plugin can see and change only the files and folders it creates, so it creates its own folder for your Docs. If you need Docs written into a folder you made yourself, or one in a shared drive, you can switch to full Google Drive access (the drive scope) on the Google Connection tab.

Privacy and external services

This plugin connects to Google services, and only after an administrator sets up the connection. It does not contact any other service, and it never sends data to DK New Media.

  • Google OAuth 2.0 (accounts.google.com, oauth2.googleapis.com): used to sign in, get and refresh access tokens, and revoke access when you disconnect or uninstall. Sent: your OAuth client ID and secret, the authorization code, and the refresh token.
  • Google Drive API (www.googleapis.com): used to read the connected account’s email address and name, create the folder, and create, update, find, and trash the Docs. Sent: each published post’s title, content, URL, dates, author display name, categories, tags, excerpt, SEO fields, image URLs, and alt text. Posts that are not published, private, or password-protected are never sent.

Requests happen when an administrator connects, disconnects, saves or creates a folder, or runs a sync, and when WP-Cron processes the queue in the background.

Google’s terms and privacy policy apply:

  • Google Terms of Service: https://policies.google.com/terms
  • Google Privacy Policy: https://policies.google.com/privacy
  • Google APIs Terms of Service: https://developers.google.com/terms
  • Google API Services User Data Policy: https://developers.google.com/terms/api-services-user-data-policy

The OAuth client secret and the Google token are stored in your WordPress database (in options that are not autoloaded) and are never shown on a page. You can keep the client ID and secret out of the database by defining them in wp-config.php (see the FAQ).

Google, Google Docs, Google Drive, and Gemini are trademarks of Google LLC.

This plugin is developed by DK New Media. Documentation and updates are published on Martech Zone.

Screenshots

Installation

1. Install the plugin

Install and activate the plugin from Plugins Add New, or upload the dk-post-sync-for-google-docs folder to /wp-content/plugins/. Then go to Settings DK Post Sync Google Connection and copy the Authorized redirect URI. It looks like this:

https://example.com/wp-admin/admin-post.php?action=dknm_gdocs_oauth

Your site must use HTTPS, because Google accepts plain http redirect URIs only for localhost.

2. Set up Google Cloud

  1. Open the Google Cloud Console (https://console.cloud.google.com/) and create a project, or pick an existing one.
  2. Enable the Google Drive API for the project (APIs & Services Library Google Drive API Enable).
  3. Configure the OAuth consent screen (Google Auth Platform Branding and Audience). Choose Internal if you use Google Workspace and only people in your organization will connect. Otherwise choose External and add your Google account as a test user.
  4. Under Data Access, add the scope https://www.googleapis.com/auth/drive.file, or https://www.googleapis.com/auth/drive if you choose full Drive access.
  5. Under Clients, click Create client, choose Web application, add the redirect URI you copied under Authorized redirect URIs, and click Create.
  6. Copy the Client ID and Client secret.

3. Connect and sync

  1. On the Google Connection tab, paste the client ID and secret and click Save Google Settings.
  2. Click Connect with Google, sign in, and allow access.
  3. On the Settings tab, click Create Folder in Google Drive, or paste an existing folder’s link if you chose full Drive access.
  4. On the Sync tab, click Sync All Posts.

FAQ

Why do I need my own Google Cloud OAuth client?

Your site talks to Google directly, with credentials you control. No third-party server sits in between, and you can revoke access at any time from your Google account or by clicking Disconnect.

Can I keep the client ID and secret out of the database?

Yes. Add these lines to wp-config.php, above the “That’s all, stop editing!” line:

define( 'DKNM_GDOCS_CLIENT_ID', 'your-client-id.apps.googleusercontent.com' );
define( 'DKNM_GDOCS_CLIENT_SECRET', 'your-client-secret' );

When they are defined, the matching fields on the Google Connection tab are locked.

Why does my connection stop working after 7 days?

When a consent screen is External and its publishing status is Testing, Google expires refresh tokens after 7 days. Use an Internal consent screen (Google Workspace) or publish the app, then reconnect.

Why can’t the plugin use the folder I pasted?

With the recommended drive.file access, Google lets the plugin use only folders it created. Create the folder from the Settings tab, or switch to full Drive access on the Google Connection tab and reconnect.

Can I rename, move, or share the folder?

Yes. The plugin tracks the folder by its ID, so renaming or moving it in Drive doesn’t break syncing. To share the Docs, share the folder in Google Drive.

Which posts are synced?

Published posts of the post type that are not password-protected. Drafts, private posts, and password-protected posts are never sent. If a post that has a Doc stops being public, its Doc moves to the Drive trash.

Does disconnecting or uninstalling delete my Docs?

No. Disconnecting revokes the plugin’s access at Google and stops syncing. Uninstalling also revokes access and removes the plugin’s settings, the stored secret and token, the queue, and its post meta. Your Docs stay in Drive. If you reinstall and connect with the same OAuth client, the plugin finds each post’s existing Doc again instead of creating a duplicate.

Does it slow down saving posts?

No. Saving a post only adds it to a queue. The Google requests run in the background through WP-Cron, or on the Sync tab while you have it open.

Can I add a header to every Google Doc?

Yes. On Settings DK Post Sync Settings there is an optional HTML field prepended to the top of every synced Doc. Leave it blank if you do not want a header. Allowed tags are the same as in posts. You can include these placeholders, which are replaced for each post:

{post_title}
{permalink}
{date}

{date} uses the date format from Settings → General and the post's published date. After you change the header, click **Sync All Posts** on the Sync tab to update Docs that already exist.

Reviews

There are no reviews for this plugin.

Contributors & Developers

“DK Post Sync for Google Docs” is open source software. The following people have contributed to this plugin.

Contributors

Changelog

1.0.1

  • Describes the plugin’s purpose: syncing posts to Google Docs so Gemini or an MCP integration can use the content as a knowledge base, without access to the site.
  • Optional HTML header prepended to every synced Doc, with {post_title}, {permalink}, and {date} placeholders.
  • Adds DK New Media and Martech Zone credit links.

1.0.0

  • First public release.
  • Google OAuth 2.0 connection with your own client (authorization code flow with state and PKCE, offline access with token refresh, revocation on disconnect).
  • A Google Connection tab with setup steps, the redirect URI and a Copy button, and the connected account and status.
  • Every sync feature stays disabled, with a notice, until the connection is set up and working.
  • Uses the drive.file scope by default, with optional full Drive access.
  • Creates its own Drive folder, or uses an existing one with full access.
  • Reads SEO fields from Rank Math or Yoast SEO.