=== RelayPoint Connect ===
Contributors: relaypoint
Tags: social media, facebook, instagram, linkedin, whatsapp
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 8.0
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Let your team and your users connect their social, Google and WhatsApp accounts through RelayPoint, and compose, schedule and approve posts from WordPress.

== Description ==

RelayPoint Connect adds "Connect" buttons to any page of your site. Your logged-in users (for example your agents) connect their own social and Google accounts in a secure RelayPoint pop-up, and administrators connect the company's pages. You can then post to the company's accounts from the WordPress admin.

* **Shortcode** `[relaypoint_connect]` and a **block** "RelayPoint Connect".
* **Nine connections:** Facebook Pages, Instagram professional accounts, LinkedIn, Google Drive, TikTok, YouTube, Google Business Profile, X and WhatsApp Business. Always on your own accounts.
* **Post to socials** composer (Tools → Post to socials): text, hashtags, an image or a video from the media library, a link, a YouTube title, per-network text and hashtags, the accounts to post to, a schedule with "best time" suggestions, and drafts. "Check" previews the text adapted to each network, with errors and warnings, before anything is published.
* **AI assist:** captions, hashtags, rewrite, translate (English, French, Portuguese) and "property listing → post", billed from your RelayPoint AI credits (free in test mode). It can be switched off in the plugin settings.
* **Approvals:** choose who can draft and who can approve. Drafters' posts wait for an approver when approvals are on in RelayPoint.
* **Recent posts** with the status per network (queued, processing, published, failed), cancel, and a 30-day analytics summary.
* **Social hub:** an "Open Social hub" link (admin bar, composer page, or the `[relaypoint_social_hub]` shortcode) opens RelayPoint's branded hub without a RelayPoint login.
* **Test mode:** test keys simulate connections and posts, free of charge.
* **Secure by design:** the secret key stays on your server, encrypted with your site's security salts. Visitors' browsers only ever get the publishable key and a short-lived session token.
* Translated into French and Portuguese (Portugal and Brazil).

This plugin connects to the RelayPoint service (https://relaypoints.online). It sends requests from your server to the RelayPoint API with your secret key, and loads RelayPoint's browser script (relaypoint-connect.v1.js) on pages that show the connect widget. The RelayPoint terms and privacy policy apply.

== Installation ==

1. In WordPress go to Plugins → Add New → Upload Plugin, choose `relaypoint-connect.zip` and click Install Now, then Activate.
2. Go to Settings → RelayPoint Connect.
3. Paste your test publishable key (`rp_pk_test_…`) and test secret key (`rp_test_…`), keep the mode on Test and save.
4. Click "Check connection". Every line should be green.
5. Add the block or the shortcode to a page and try it. When everything works, add your live keys and switch the mode to Live.

== Frequently Asked Questions ==

= Where do I get my keys? =

In your RelayPoint dashboard: API keys for the secret key (it needs the `connections` and `social` scopes, or `*`), and API keys → Publishable keys for the publishable key. Each mode (test and live) has its own pair of keys.

= What are allowed origins? =

The publishable key only works on the websites listed as its allowed origins. Add your site's origin exactly, without a path, for example `https://blueoceanrealty.co.za`, and add the www variant too (`https://www.blueoceanrealty.co.za`) if visitors can reach your site at both addresses. "Check connection" shows whether your site's origin is allowed and lists the allowed origins.

= Do I need a RelayPoint package? =

Live connections need the "RelayPoint Connections" package on your RelayPoint workspace (Dashboard → Billing). Test mode is free. "Check connection" tells you whether the package is active.

= Who can use "Post to socials"? =

Settings → RelayPoint Connect → "Who can draft" (default: Authors and above, `publish_posts`) and "Who can approve" (default: Administrators, `manage_options`). The plugin tells RelayPoint each user's role ("drafter" or "approver") when they open the composer. Posts are made for the end user `company`, with the WordPress user as author (`wp:<user id>`). When approvals are on in RelayPoint, drafters' posts wait for an approver; when they are off, drafters can only save drafts. Developers can use the `relaypoint_connect_social_capability` and `relaypoint_connect_approver_capability` filters.

= Which media does each network need? =

Instagram needs an image, YouTube needs a video, TikTok needs an image or a video. The file must be publicly reachable over https. TikTok posts stay private until RelayPoint's TikTok audit is complete. WhatsApp is for messaging, not posting, so it never appears in the composer.

= How do I add a Social hub button to a page? =

`[relaypoint_social_hub]` opens the hub for the logged-in user; `[relaypoint_social_hub end_user="company" label="Manage our socials"]` opens it for the company (administrators only).

= What does test mode do? =

Test keys create test sessions. The pop-up shows a "Simulate connection" button instead of the real sign-in, test connections are free, and posts are simulated (nothing is published). Live keys use the real sign-in and each new connection is billed.

= How do I use the shortcode? =

`[relaypoint_connect]` shows all available services for the logged-in user.

`[relaypoint_connect provider="facebook,instagram" end_user="current_user"]` shows only Facebook and Instagram.

`[relaypoint_connect provider="all" end_user="company"]` manages the company's own accounts.

`provider` accepts `all` (the default: every provider available to your account), `facebook`, `instagram`, `linkedin`, `google_drive`, `tiktok`, `youtube`, `google_business`, `x`, `whatsapp`, or a comma-separated list. Providers you list that are not available show the reason instead of a button. The "RelayPoint Connect" block has the same two settings in its sidebar.

= What does end_user mean? =

* `current_user` (the default): each logged-in WordPress user connects their own accounts. They are stored at RelayPoint for the end user `wp:<user id>`. Visitors who are not logged in see a "Log in to connect your accounts" link.
* `company`: the company's own pages and accounts (end user `company`). Only users with the `manage_options` capability see this widget; other visitors see nothing. Developers can change the capability with the `relaypoint_connect_company_capability` filter. "Post to socials" posts to these company accounts.

= Can I point the plugin at a staging server? =

Yes. In wp-config.php define `RELAYPOINT_API_BASE` (API, default `https://api.relaypoints.online`) and `RELAYPOINT_APP_BASE` (browser script and pop-up, default `https://app.relaypoints.online`), or use the `relaypoint_connect_api_base` and `relaypoint_connect_app_base` filters.

= Does it work with page caching? =

The widget is only rendered for logged-in users, who normally bypass page caches. If your cache serves pages to logged-in users, exclude the pages that contain the widget.

== Changelog ==

= 1.1.0 =
* Nine providers: TikTok, YouTube, Google Business Profile, X and WhatsApp join Facebook, Instagram, LinkedIn and Google Drive, with notes and unavailability reasons.
* "Check connection" shows whether the RelayPoint Connections package is active.
* New composer: video, hashtags, YouTube title, per-network overrides, "Check" with per-network previews, AI assist, best times, drafts.
* Approvals: drafter and approver roles mapped from WordPress capabilities, approve and reject.
* Recent posts show queued, processing and failed targets; 30-day analytics.
* "Open Social hub" in the admin bar and composer, and the [relaypoint_social_hub] shortcode.
* Friendlier messages for package_required, validation_failed, feature_disabled and daily_limit_reached.

= 1.0.0 =
* First release: settings with encrypted secret keys and a connection check, shortcode and block, REST routes for sessions and connections, "Post to socials" page and dashboard widget, French and Portuguese translations.
