Wordapp Help Center

How can we help?

Home  /  Output  /  Wordapp WordPress Plugin

Wordapp WordPress Plugin

Version 1.0.2

The Wordapp Plugin connects your site to the Wordapp Platform to allow you to create, translate and optimize online content easily and seamlessly. The Wordapp Plugin is published to the WordPress Plugin Directory and can be installed from: https://wordpress.org/plugins/wordapp/

  • Wordapp Plugin for WordPress
  • Installation instructions:
  • Wordapp Plugin’s directory structure:
  • Plugin Functions:

Installation instructions:

For an automatic installation through WordPress:

  1. Go to the ‘Add New’ plugins screen in your WordPress admin area.
  2. Search for ‘Wordapp’.
  3. Click ‘Install Now’ and activate the plugin.

 

For a manual installation via FTP:

  1. Upload the wordapp directory to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ screen in your WordPress admin area

 

To upload the plugin through WordPress, instead of FTP:

  1. Upload the downloaded zip file on the ‘Add New’ plugins screen (see the ‘Upload’ tab) in your WordPress admin area and activate.

 

The Wordapp Plugin does not have a settings page within WordPress. All settings and configuration are done directly from within the Wordapp Platform. Plugin source code is available through public Subversion (SVN) repository at: https://plugins.svn.wordpress.org/wordapp

Developers can customize default operations by extending the plugin’s functionality according to their required business needs. The plugin communicates with the Wordapp platform through HTTP based API. Operations are always initiated from the Wordapp API. Each operation is a HTTP POST request.

Plugin responses in JSON format as:

successOperation result:

 

– true, if operation was completed successfully and operation results are given in data field.

– false, if operation failed and error message given in error field.

dataResponse data, the exact structure depends on the operation type
errorError message in text format

Wordapp plugin version 1.0.2 supports following operations:

Operation CodeDescription
PDX_OP_WP_CONFIG_CHECKChecks if plugin has configured to securely communicate with Wordapp Platform.
PDX_OP_WP_CONFIG_SETStarts a plugin configuration process. Used internally by Wordapp Platform.
PDX_OP_WP_POST_LISTRetrieves list of posts by query criteria.
PDX_OP_WP_POST_ADDAdds a new post
PDX_OP_WP_POST_GETGets post by url or id
PDX_OP_WP_POST_UPDATEUpdates post
PDX_OP_WP_MEDIA_LISTRetrieves list of items in media library by query criteria.
PDX_OP_WP_MEDIA_ADDAdds a new item to the media library
PDX_OP_WP_MEDIA_ADD_FROM_URLDownloads a new item (image) to the media library from external url
PDX_OP_WP_POST_META_UPDATEUpdates post meta
PDX_OP_WP_POST_META_GETGets post meta
PDX_OP_WP_POST_TYPE_LISTRetrieves registered types for posts
PDX_OP_WP_POST_STATUS_LISTRetrieves registered statuses for posts
PDX_OP_WP_POST_TEMPLATE_LISTRetrieves template names
PDX_OP_WP_MEDIA_UPDATEUpdates meta
PDX_OP_WP_PREPARE_PREVIEWPrepares unpublished post for preview and returns temporary preview url

Wordapp Plugin’s directory structure:

├── includes

│ ├── common.php

│ ├── config.php

│ ├── constants.php

│ ├── hello.php

│ ├── index.php

│ ├── integrations.php

│ ├── media.php

│ ├── meta.php

│ ├── pdx.php

│ ├── post.php

│ └── preview.php

├── LICENSE

├── LICENSE.txt

├── README.txt

├── index.php

├── uninstall.php

└── wordapp.php

Plugin Functions:

FunctionDescription
ajax_wa_pdx()

 

File: includes/pdx.php

The AJAX entry point.

Parses AJAX requests and calls appropriate functions. Used internally by plugin.

Parameters:

$_POST

HTTP POST parameters passed from Wordapp Platform.

Returns:

mixed

JSON that indicates success/failure status of the operation in ‘success’ field, and an appropriate ‘data’ or ‘error’ fields.

wa_pdx_op_config_set ($params)

 

File: includes/config.php

PDX API Operation : PDX_OP_WP_CONFIG_SET

 

Sets plugin configuration.

This operation is initiated from Wordapp Platform to configure plugin for further data exchange operations.

Parameters:

array $params

The operation parameters passed from Wordapp Platform.

Returns:

mixed

JSON that indicates success/failure status of the operation in ‘success’ field, and an appropriate ‘data’ or ‘error’ fields.

wa_pdx_config_clear()

 

File: includes/config.php

Internal function.

 

Clears configuration data.

Removes Wordapp plugin related configuration data from the WordPress option storage. Called internally when plugin activated, deactivated or uninstalled.

wa_pdx_hello()

 

File: includes/hello.php

Processes HTTP HEAD ‘Hello’ message.

 

This message is used by Wordapp Platform to discover if Wordapp plugin is installed

Parameters:

HTTP REQUEST HEADER: X_WA_PDX_HELLO

Hello Message Identifier

Returns:

HTTP RESPONSE HEADER: X-WA-PDX-VERSION

Plugin version

HTTP RESPONSE HEADER: X-WA-PDX-AJAX-URL

Plugin AJAX entry point url

HTTP RESPONSE HEADER: X-WA-PDX-WP-VERSION

WordPress Version

wa_pdx_find_post_by_url($post_url)

 

File: includes/post.php

Internal function.

 

Finds post by url.

Parameters:

string $post_url

The url to find.

Returns:

integer|null

The post id found.

wa_pdx_post_add ($params)

 

File: includes/post.php

Internal function.

 

Adds a new post.
Parameters:
array $params

post parameters.
Returns:
Int|null

post id of the added post

wa_pdx_post_update ($params)

 

File: includes/post.php

Internal function.

 

Updates a post by post id or url.
Parameters:
array $params

post parameters.
Returns:
Int|null

post id of the updated post

wa_pdx_op_post_add ($params)

 

File: includes/post.php

PDX API Operation : PDX_OP_WP_POST_ADD
Adds new post.
Parameters:
array $params

The parameters passed from Wordapp.
Returns:
mixed

JSON that indicates success/failure status of the operation in ‘success’ field, and an appropriate ‘data’ or ‘error’ fields.
wa_pdx_op_post_update ($params)

 

File: includes/post.php

PDX API Operation : PDX_OP_WP_POST_UPDATE

 

Updates post by post id or url.

Parameters:

array $params

Parameters passed from Wordapp.

Returns:

mixed

JSON that indicates success/failure status of the operation in ‘success’ field, and an appropriate ‘data’ or ‘error’ fields.

wa_pdx_op_post_get ($params)

 

File: includes/post.php

PDX API Operation : PDX_OP_WP_POST_GET

 

Gets a post by id.

Parameters:

array $params

Parameters passed from Wordapp. The post id must be given in ‘id’ field.

Returns:

mixed

JSON that indicates success/failure status of the operation in ‘success’ field, and an appropriate ‘data’ or ‘error’ fields.

wa_pdx_op_post_list ($params)

 

File: includes/post.php

PDX API Operation : PDX_OP_WP_POST_LIST

 

Retrieves list of posts by query criteria.

Parameters:

array $params

Parameters passed from Wordapp.

Returns:

mixed

JSON that indicates success/failure status of the operation in ‘success’ field, and an appropriate ‘data’ or ‘error’ fields.

wa_pdx_op_post_type_list()

 

File: includes/post.php

PDX API Operation : PDX_OP_WP_POST_TYPE_LIST

 

Retrieves list of all post types.

Returns:

mixed

JSON that indicates success/failure status of the operation in ‘success’ field, and an appropriate ‘data’ or ‘error’ fields.

wa_pdx_op_post_status_list()

 

File: includes/post.php

PDX API Operation : PDX_OP_WP_POST_STATUS_LIST

 

Retrieves list of all post statuses.

Returns:

mixed

JSON that indicates success/failure status of the operation in ‘success’ field, and an appropriate ‘data’ or ‘error’ fields.

wa_pdx_op_post_template_list()

 

File: includes/post.php

PDX API Operation : PDX_OP_WP_POST_TEMPLATE_LIST

 

Retrieves list of all templates of active theme.

Returns:

mixed

JSON that indicates success/failure status of the operation in ‘success’ field, and an appropriate ‘data’ or ‘error’ fields.

wa_pdx_post_update_template($post_id, $name)

 

File: includes/post.php

Internal function.

 

Updates post template option.
Parameters:

string $name

The template name to assign.
int $post_id

The post id to assign.

wa_pdx_post_process_params ($post, $params, $add = false)

 

File: includes/post.php

Internal function.

 

Processes post parameters.

Parameters:

array $post

post Initial post parameters.
array $params

Parameters to parse.
bool $add

Add defaults for missed parameters.
Returns:
Array

The altered post parameters.

wa_pdx_op_media_add($params)

 

File: includes/media.php

PDX API Operation : PDX_OP_WP_MEDIA_ADD

 

Adds media file to the media library.

Parameters:

array $params

Parameters passed from Wordapp.

Returns:

mixed

JSON that indicates success/failure status of the operation in ‘success’ field, and an appropriate ‘data’ or ‘error’ fields.

wa_pdx_op_media_add_from_url ($params)

 

File: includes/media.php

PDX API Operation : PDX_OP_WP_MEDIA_ADD_FROM_URL

 

Downloads media file from url and add to the media library.

Parameters:

array $params

Parameters passed from Wordapp.

Returns:

mixed

JSON that indicates success/failure status of the operation in ‘success’ field, and an appropriate ‘data’ or ‘error’ fields.

wa_pdx_op_media_list($params)

 

File: includes/media.php

PDX API Operation : PDX_OP_WP_MEDIA_LIST

 

Retrieves list of items in media library by query criteria.

Parameters

array $params

The query criteria.

Returns:

mixed

JSON that indicates success/failure status of the operation in ‘success’ field, and an appropriate ‘data’ or ‘error’ fields.

wa_pdx_op_meta_get ($params)

 

File: includes/meta.php

PDX API Operation : PDX_OP_WP_POST_META_GET

 

Post meta get operation.

Parameters:

array $params

Operation parameters passed from Wordapp Platform.

Returns:

mixed

JSON that indicates success/failure status of the operation in ‘success’ field, and an appropriate ‘data’ or ‘error’ fields.

wa_pdx_op_meta_update ($params)

 

File: includes/meta.php

PDX API Operation : PDX_OP_WP_POST_META_UPDATE

 

Post meta update operation.

Parameters:

array $params

Operation parameters passed from Wordapp Platform.

Returns:

mixed

JSON that indicates success/failure of the operation, or JSON that indicates an error occurred.

wa_pdx_op_prepare_preview ($params)

 

File: includes/preview.php

PDX API Operation : PDX_OP_WP_PREPARE_PREVIEW

 

Prepares unpublished post for preview

Parameters:

array $params

Operation parameters passed from Wordapp Platform.

Returns:

string

Preview URL.

wa_pdx_filter_pre_get_posts( $query )

 

File: includes/preview.php

Internal function.

 

Filter function for preview hook.
This hook function is called after the query variable object is created, but before the actual query is run.

Parameters:

Object $query

The WP_Query object by reference.
Returns:

Object

Returns the passed query object.

wa_pdx_filter_posts_results( $posts )

 

File: includes/preview.php

Internal function.

 

Filter function for preview hook.
Filters the raw post results array, prior to status checks.

Parameters:
array $posts

The post results array.
Returns:

Array

The altered posts array.

wa_pdx_generate_preview_access_token ($post_id, $preview_token)

 

File: includes/preview.php

Internal function.

 

Generates preview access token.

Parameters:
int $post_id

The post id to generate preview access token.
string $preview_token

The security token for preview. This token sets up by configuration process.
Returns:

string

Generated preview access token.

wa_pdx_check_preview_access_token ($post_id, $wa_pat, $preview_token)

 

File: includes/preview.php

Internal function.

 

Checks if provided token gives access for preview.
Parameters:

int $post_id

The post id to check access for preview.
string $wa_pat

The preview access token.
string $preview_token

The security token for preview. This token sets up by configuration process.
Returns:

bool

Whether preview access is allowed.

wa_pdx_generate_preview_url ($post_id)

 

File: includes/preview.php

Internal function.

 

Generates preview url.

Parameters:
int $post_id

The post id to generate preview url.
Returns:

string

Preview url.

wa_pdx_seo_plugins_integrate ($post_id, $title, $description,  $focus_keyword)

 

File: includes/integrations.php

Internal function.

 

Integration with SEO related plugins.

Supported plugins: Yoast SEO, All in One SEO Pack

Parameters:

integer $post_id

Post id.

string $title

Meta title.

string $description

Meta description.

string $focus_keyword

Focus keyword.

wa_pdx_random_hex_string ($len)

 

File: includes/common.php

Internal function.

 

Generates random hex string by given length.

Parameters:

integer $len

Required random string length.

Returns:

string

Random hex string.

wa_pdx_send_response ($msg, $success = false)

 

File: includes/common.php

Internal function.

 

Sends JSON response and closes HTTP request.

Parameters:

mixed $msg

Value of the ‘data’ or ‘error’ fields in JSON response. When $success = true then ‘data’ = $msg. When $success = false then ‘error’ = $msg.

boolean $success

The ‘success’ field in JSON response.

SHARE THE KNOWLEDGE

Not using Wordapp yet?

Sign up to revolutionize your content creation!

Want to learn the benefits of Wordapp the easy way?