On each request this plugin is instantiated as a global object, you do not need to instantiate it again:
$AudiencePlayerWordpressPlugin
The AudiencePlayer API is based on GraphQL. The integrated AudiencePlayer API client for PHP offers convenient shorthand wrapper methods for the most commonly used queries and mutations but also provides the possibility to directly execute a "raw" GraphQL operation.
# Fetch user details $AudiencePlayerWordpressPlugin->api()->query ->ArticleList() ->paginate(25, 0) ->properties(['id', 'name', 'metas' => ['key', 'value']]) ->sort('published_at', 'desc') ->execute(); # Same query conducted as a "raw" operation $AudiencePlayerWordpressPlugin->api()->executeRawGraphQLCall( AudiencePlayerApiClient::OAUTH_SCOPE_USER, # the oauth-scope you wish to address the api with 'query { ArticleList (limit:25 offset:0) # raw GraphQL operation (query/mutation) {id name metas{key value}}}' );
The API-client can also easily be addressed using the ajax-endpoint "audienceplayer_api_call" provided by the plugin. It takes raw GraphQL operations.
var operation = 'query { ArticleList (category_id:123) { id name metas{key value} } }'; $.post('/wp-admin/admin-ajax.php', { action: 'audienceplayer_api_call', operation: operation variables: [] }).done(function (response) { console.log('success', response); }).fail(function (response) { console.log('fail', response); });
You can open the modal player by using the instantiated global javscript helper window.AudiencePlayerCore:
window.AudiencePlayerCore.openModalPlayer( event, articleId, assetId, callbackAuthenticationError, callbackAuthorisationError, callbackGeneralError );