Skip to content

OG Social Engine: developer's guide

This page lists the hooks, routes, tools and data that OG Social Engine uses. For the screens, see the user guide.

Actions

OG Social Engine does not fire actions of its own for you to hook into. It listens to these WordPress actions:

Action What Social Engine does
transition_post_status When a social_post moves to publish (for example when WordPress publishes a scheduled post), it sends that post to its network.
wp_after_insert_post When any other post is first published, it runs every automatic schedule against it.
delete_attachment Deletes the saved video preview frame for that attachment.

Filters

Access

Filter Arguments Default Use
ogscle_allow_setup $allowed current_user_can( 'manage_options' ) Who can open settings and connect networks
ogscle_allow_usage $allowed Administrators, editors and authors Who can use the Social Posts dashboard
ogscle_allow_moderation $allowed Administrators and editors Who can change photos on social posts
ogscle_allow_public_api $allowed, $action, $request is_user_logged_in() Who can call the Public API. $action is post, accounts or account. When a bearer token is set, Social Engine hooks this filter itself to accept the token.
// Let shop managers use the Social Posts dashboard.
add_filter( 'ogscle_allow_usage', function ( $allowed ) {
    return $allowed || current_user_can( 'manage_woocommerce' );
} );

Posts and scheduling

Filter Arguments Use
ogscle_post_data $post_data, $wp_post_id Change a social post made by an automatic schedule or Revive Posts before it is saved. Keys: date (DateTime), content, status, thumbnail_ids, service_id, account_id, account_type.
ogscle_modules $modules The list of network handlers. Each item is [ 'type' => 'twitter', 'instance' => $handler ].
ogscle_accounts $accounts The list of connected accounts. Each item has type, name, serviceId, accountId and instance.
// Add a hashtag to every automatic social post.
add_filter( 'ogscle_post_data', function ( $data, $wp_post_id ) {
    $data['content'] .= ' #news';
    return $data;
}, 10, 2 );

Video

Filter Arguments Default Use
ogscle_allowed_video_mimes $mimes MP4, M4V, MOV, WebM, AVI, MPEG, WMV, MKV, 3GP Video types a social post may carry
ogscle_video_services $types [ 'facebook', 'instagram' ] Networks that accept video
ogscle_video_poster_url $url, $attachment_id null Return a URL to use your own preview picture for a video
ogscle_facebook_video_params $params, $social_post title, description, published Fields sent with a Facebook Page video
ogscle_facebook_video_title $title, $social_post Text start or site name, up to 100 characters Facebook video title
ogscle_facebook_video_single_request_max $bytes 26214400 (25 MB) Videos larger than this are uploaded in parts
ogscle_instagram_video_url $url, $social_post The attachment URL Public URL Instagram downloads the Reel from
ogscle_instagram_video_params $params, $social_post media_type, video_url, caption, share_to_feed, thumb_offset Fields sent when creating a Reel
ogscle_instagram_video_wait $seconds 300 (minimum 30) Longest wait for Instagram to process a Reel
ogscle_instagram_image_wait $seconds 60 (minimum 10) Longest wait for Instagram to process a picture

REST API

Public API

Namespace og-social-engine/api/v1. These routes exist only while Enable Public API is on.

Method Route Parameters Returns
POST /post content (required), media (array of attachment IDs; images also works), status (publish or draft, default publish), use_default_account (default true), service_id, account_id, service_type { "post_id": 123 }
GET /accounts name (partial match), type (twitter, facebook, instagram, mastodon, linkedin, pinterest) List of name, type, serviceId, accountId
GET /account none The default account

Authentication: send Authorization: Bearer <token> with the token from the Public API tab. A valid token runs the request as the site's first administrator. A logged-in user with a REST nonce also passes.

curl -X POST https://example.com/wp-json/og-social-engine/api/v1/post \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"content":"Hello from the API!"}'

With use_default_account set to false, pass service_id, account_id and service_type from /accounts. A post with status: publish is sent straight away.

The same routes also answer under the older namespace social-engine/api/v1.

Admin routes

Namespace og-social-engine/v1. The plugin's own screens use these. They need a logged-in user with a REST nonce. "Setup" means ogscle_allow_setup, "Usage" means ogscle_allow_usage.

Method Route Access
POST /update_option, /request_service, /reset_all_data, /delete_all_drafts, /add_posting_time, /quick_test Setup
GET /all_settings, /stats, /post_stats, /social_posts, /latest_photos, /recent_photos, /is_moderator, /published_post_ids, /get_logs, /clear_logs Usage
POST /upload_image, /create_social_post, /update_social_post, /delete_social_posts, /publish_now, /revive_post, /enhance_post, /ai_suggestions, /ai_format_suggestion Usage
GET, POST /video_poster (video_id) Usage

These routes are internal and may change between versions. Use the Public API or the PHP API below for your own code.

MCP tools

The tools are added to OG AI Core's MCP server when OG AI Core is active and MCP is on in Social Engine's settings. Only administrators (manage_options) can run them, and they are never part of the public MCP.

Tool Arguments What it does
ogscle_get_account none The default account
ogscle_list_accounts name, type Connected accounts, filtered by partial name or type
ogscle_get_posts status (future, publish, draft, trash, failed, all), account_id, service_type, after, before (YYYY-MM-DD), wp_post_id, limit (default 10), offset The social post queue. Check is_published: sent posts can keep the future status.
ogscle_get_post post_id (required) One social post with media, account, posted ID, error and related WordPress post
ogscle_post content (required), media, images, status (publish, draft, future), date (YYYY-MM-DD HH:MM:SS, site time), post_link, use_default_account, service_id, account_id, service_type Creates a social post. publish sends it now.
ogscle_update_post post_id (required), content, media, images, date, status, service_id, account_id, service_type Edits, reschedules or moves a social post
ogscle_delete_post post_id (required), force (default false = trash) Deletes a social post
ogscle_publish_now post_id (required) Sends a draft or scheduled post now
ogscle_get_stats account_id Counts of all, draft, ready and published posts
ogscle_get_post_stats post_id (required) Engagement numbers from the network for a sent post
ogscle_get_schedule none Scheduling setup: slots, filters, template, hashtag groups, draft and enhancer state, default service. No credentials.
ogscle_get_logs lines (default 100, max 1000) Newest log lines, with token values hidden
ogscle_revive_post post_id, account_id, confirm (all required), use_post_enhancer Makes a social post from an existing WordPress post. confirm must be true.

Media rules: pictures (JPEG, PNG, GIF), or one video on its own. Videos go to Facebook and Instagram only.

PHP API

The global $ogscle_api gives you a simple way to post from your own code.

Method Returns
$ogscle_api->post( $account = [], $content = [], $publish = true ) The social post ID, or a WP_Error. $account needs serviceId, accountId and type; leave it empty for the default account. $content takes text and media (attachment IDs).
$ogscle_api->list_accounts( $type = null, $name = null ) Connected accounts
$ogscle_api->get_account() The default account
global $ogscle_api;
if ( $ogscle_api ) {
    $result = $ogscle_api->post( [], [ 'text' => 'New article is live!', 'media' => [ 42 ] ] );
    if ( is_wp_error( $result ) ) {
        error_log( $result->get_error_message() );
    }
}

The main plugin object is in the globals $ogscle_core and $ogscle.

Cron events

Scheduled social posts are normal WordPress posts with the future status. WordPress publishes them with its own publish_future_post event, and Social Engine sends them on the status change. A server cron job that runs WordPress cron keeps the timing accurate.

Event When
ogscle_pack_fetch One-off event that downloads the Pro features after a licence is saved

Data stored

Options

Option Holds
ogscle_options All settings in one array: services (connections and their tokens), defaults (posting times per account), auto_schedules, template, default_service, public_api, api_token, draft_enabled, use_featured_image, use_post_link, ai_suggestions, post_enhancer_enabled, post_enhancer_prompt, mcp_support, hashtags_groups, locked_dates, logs_enabled, logs_path and others
ogscle_license Licence record
ogscle_pack_error Last Pro download error
ogscle_rating_date When to ask for a rating

Older single options named ogscle_<setting> are moved into ogscle_options and deleted automatically.

Transients

Transient Holds
ogscle_stats_<post ID> Network statistics for a sent post, kept for a day
ogscle_pack_wait Pause between Pro download attempts

Post type and meta

Social posts are the private post type social_post. Status draft is a draft, future is ready, publish is sent.

Meta key On Holds
ogscle_service_id Social post Connection ID
ogscle_account_id Social post Account ID
ogscle_service_type Social post Network type
ogscle_thumbnails Social post JSON list of attachment IDs
ogscle_post_link Social post Link to embed
ogscle_posted_id Social post ID on the network once sent. If set, the post is never sent again.
ogscle_post_error Social post Last error message
ogscle_related_postId Social post WordPress post it was made from
ogscle_auto_schedule_id Social post Automatic schedule that made it
ogscle_posts Attachment Social posts that use this media item
_ogscle_video_poster Attachment Version stamp of the saved video preview frame

Files

Path Holds
wp-content/uploads/ogscle_<random>.log The log, when Logs is on
wp-content/uploads/ogscle-posters/<video ID>.jpg Video preview frames
wp-content/og-pro/og-social-engine/ The Pro features downloaded for a licensed site

No custom database tables are created. Nothing is removed on uninstall; Reset all data deletes ogscle_options and every social post.

Constants

Defined by the plugin. Read them, don't define them.

Constant Value
OGSCLE_VERSION Plugin version
OGSCLE_PREFIX ogscle
OGSCLE_DOMAIN og-social-engine (text domain)
OGSCLE_PATH, OGSCLE_URL, OGSCLE_ENTRY Plugin folder, URL and main file

JavaScript

Name What it is
window.ogscle_social_engine Settings passed to the admin app: api_url, rest_url, rest_nonce, is_pro, post_types, post_tags, languages, options
window.ogscleProps and the ogsclePropsChange event Set by the Create Social Post row link. The event's detail has postContent, postThumbnails, postThumbnailIds and postThumbnailUrls, and opens the composer.
window.ogscleVideo Data for the video helpers (preview frames and the Send to Social Engine button)
// Open the composer with your own text on a screen where the Social Engine app is loaded.
window.ogscleProps = { postContent: 'Hello', postThumbnails: '[]', postThumbnailIds: '[]', postThumbnailUrls: '[]' };
window.dispatchEvent( new CustomEvent( 'ogsclePropsChange', { detail: window.ogscleProps } ) );