Skip to content

Customizing WordPress GitHub Sync with Filters

James DiGioia edited this page Jan 18, 2016 · 4 revisions

wpghs_commit_msg_full

Params

string $msg Full export commit message.

Description

This is the commit message for doing a full site export. The filter passes in the current commit message. You should return a string with your custom commit message.

wpghs_commit_msg_delete

Params

WordPress_GitHub_Sync_Post $post Post object being deleted.

Description

This is the commit message when deleting a single post. The filter passes in the current commit message and the WordPress_GitHub_Sync_Post object currently being exported. You should return a string with your custom commit message.

wpghs_directory_unpublished

Params

WordPress_GitHub_Sync_Post $post Unpublished post object directory source.

Description

This is the directory for exporting unpublished posts. The filter passes in the current directory (_drafts) and the WordPress_GitHub_Sync_Post object currently being exported. You should return a string with your custom drafts folder name.

wpghs_directory_published

Params

WordPress_GitHub_Sync_Post $post Published post object directory source.

This is the directory for exporting published posts. The filter passes in the current directory, which is based on the post_type, and the WordPress_GitHub_Sync_Post object currently being exported. You should return a string with your custom published folder name.

wpghs_filename

Params

WordPress_GitHub_Sync_Post $post Post object filename source.

This is the filename for exporting posts. The filter passes in the current filename, which is post_name (i.e. the slug), and the WordPress_GitHub_Sync_Post object currently being exported. You should return a string with your custom filename.

wpghs_post_meta

Params

array $meta Post export meta.
WordPress_GitHub_Sync_Post $post Post meta source.

Description

This is the meta array which gets converted to the YAML frontmatter on export. The filter passes in the current meta array and the WordPress_GitHub_Sync_Post object currently being exported.

By default the YAML frontmatter catches all the post's meta, but exclude any that begin with _, as that is considered private. If you'd like to export that data, you should merge any additional meta into the array and return the new array.

Make sure the array key for your new meta matches the meta_key of the post_meta. Do NOT modify or remove any of the default keys in the array, as they are required by WordPress<-->GitHub Sync. These are listed below: * 'ID' * 'post_title' * 'author' * 'post_date' * 'post_excerpt' * 'layout' * 'permalink' * 'published'

wpghs_content_export

Params

string $content Post export content.
WordPress_GitHub_Sync_Post $post Post content source.

Description

This filter is fired before the post content is exported from WordPress. Use it to make any last conversions before the content is exported. Make sure you reverse the conversion on the import hook.

wpghs_content_import

Params

string $content Post export content.
WordPress_GitHub_Sync_Post $post Post content source.

Description

This filter is fired before the post content is imported from GitHub. Use it to reverse any conversions made on export to GitHub.

wpghs_line_endings

Params

string $line_ending Line ending to normalize export with. Defaults to "\n".

Description

This filter returns the line ending the posts exported to GitHub are normalized to. Use it to set your preferred default line ending.

wpghs_pre_import_args

Params

array $args Post save args.
WordPress_GitHub_Sync_Post $post Post args source.

Description

This filter is fired before imported posts are are saved to the database. Use it to add arguments to the update/insert calls.

wpghs_pre_import_meta

Params

array $meta Post export meta.
WordPress_GitHub_Sync_Post $post Post meta source.

Description

This filter is called before the post meta is saved to the object. Use it to save the post meta to another location and return only the data you want to save to the post's meta.

wpghs_sync_branch

Params

string $branch Branch to sync. Defaults to "master".

Description

The branch the WordPress install should sync itself with.

wpghs_commit_msg_tag

Params

string $tag Tag to append. Defaults to "wpghs".

Description

A tag appended to the end of the commit message which is appended with a -. The tag is used to validate whether the commit has been synced to this WordPress install yet.