{"id":16904093,"url":"https://github.com/maadhattah/wordpress-github-sync","last_synced_at":"2025-12-17T23:51:05.460Z","repository":{"id":17577599,"uuid":"20381054","full_name":"mAAdhaTTah/wordpress-github-sync","owner":"mAAdhaTTah","description":"A WordPress plugin to sync content with a GitHub repository (or Jekyll site)","archived":false,"fork":false,"pushed_at":"2021-01-04T11:53:52.000Z","size":538,"stargazers_count":614,"open_issues_count":25,"forks_count":99,"subscribers_count":35,"default_branch":"master","last_synced_at":"2024-10-14T18:31:33.261Z","etag":null,"topics":["wordpress-plugin"],"latest_commit_sha":null,"homepage":"https://wordpress.org/plugins/wp-github-sync/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mAAdhaTTah.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-01T16:23:29.000Z","updated_at":"2024-10-07T04:24:22.000Z","dependencies_parsed_at":"2022-09-11T03:40:35.436Z","dependency_job_id":null,"html_url":"https://github.com/mAAdhaTTah/wordpress-github-sync","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mAAdhaTTah%2Fwordpress-github-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mAAdhaTTah%2Fwordpress-github-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mAAdhaTTah%2Fwordpress-github-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mAAdhaTTah%2Fwordpress-github-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mAAdhaTTah","download_url":"https://codeload.github.com/mAAdhaTTah/wordpress-github-sync/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247198461,"owners_count":20900080,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["wordpress-plugin"],"created_at":"2024-10-13T18:31:37.816Z","updated_at":"2025-12-17T23:51:05.418Z","avatar_url":"https://github.com/mAAdhaTTah.png","language":"PHP","readme":"# WordPress \u003c--\u003e GitHub Sync #\n**Contributors:** JamesDiGioia, benbalter  \n**Tags:** github, git, version control, content, collaboration, publishing  \n**Requires at least:** 3.9  \n**Tested up to:** 4.8  \n**Stable tag:** 2.0.1  \n**License:** GPLv2  \n**License URI:** http://www.gnu.org/licenses/gpl-2.0.html  \n\n## Description ##\n\n*A WordPress plugin to sync content with a GitHub repository (or Jekyll site)*\n\n[![Build Status](https://scrutinizer-ci.com/g/mAAdhaTTah/wordpress-github-sync/badges/build.png?b=master)](https://scrutinizer-ci.com/g/mAAdhaTTah/wordpress-github-sync/build-status/master) [![Code Coverage](https://scrutinizer-ci.com/g/mAAdhaTTah/wordpress-github-sync/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/mAAdhaTTah/wordpress-github-sync/?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mAAdhaTTah/wordpress-github-sync/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mAAdhaTTah/wordpress-github-sync/?branch=master)\n\nEver wish you could collaboratively author content for your WordPress site (or expose change history publicly and accept pull requests from your readers)?\n\nLooking to tinker with Jekyll, but wish you could use WordPress's best-of-breed web editing interface instead of Atom? (gasp!)\n\nWell, now you can! Introducing [WordPress \u003c--\u003e GitHub Sync](https://github.com/mAAdhaTTah/wordpress-github-sync)!\n\n### WordPress \u003c--\u003e GitHub Sync does three things: ###\n\n1.  Allows content publishers to version their content in GitHub, exposing \"who made what change when\" to readers\n2.  Allows readers to submit proposed improvements to WordPress-served content via GitHub's Pull Request model\n3.  Allows non-technical writers to draft and edit a Jekyll site in WordPress's best-of-breed editing interface\n\n### WordPress \u003c--\u003e GitHub sync might be able to do some other cool things: ###\n\n* Allow teams to collaboratively write and edit posts using GitHub (e.g., pull requests, issues, comments)\n* Allow you to sync the content of two different WordPress installations via GitHub\n* Allow you to stage and preview content before \"deploying\" to your production server\n\n### How it works ###\n\nThe sync action is based on two hooks:\n\n1. A per-post sync fired in response to WordPress's `save_post` hook which pushes content to GitHub\n2. A sync of all changed files triggered by GitHub's `push` webhook (outbound API call)\n\n## Installation ##\n\n### Using the WordPress Dashboard ###\n\n1. Navigate to the 'Add New' in the plugins dashboard\n2. Search for 'WordPress GitHub Sync'\n3. Click 'Install Now'\n4. Activate the plugin on the Plugin dashboard\n\n### Uploading in WordPress Dashboard ###\n\n1. Download `wordpress-github-sync.zip` from the WordPress plugins repository.\n2. Navigate to the 'Add New' in the plugins dashboard\n3. Navigate to the 'Upload' area\n4. Select `wordpress-github-sync.zip` from your computer\n5. Click 'Install Now'\n6. Activate the plugin in the Plugin dashboard\n\n### Using FTP ###\n\n1. Download `wordpress-github-sync.zip`\n2. Extract the `wordpress-github-sync` directory to your computer\n3. Upload the `wordpress-github-sync` directory to the `/wp-content/plugins/` directory\n4. Activate the plugin in the Plugin dashboard\n\n### Installing from Source ###\n\nInstall the plugin and activate it via WordPress's plugin settings page.\n\n  1. `cd wp-content/plugins`\n  2. `git clone https://github.com/benbalter/wordpress-github-sync.git`\n  3. `cd wordpress-github-sync \u0026\u0026 composer install`\n  4. Activate the plugin in Wordpress' Dashboard \u003e Plugins \u003e Installed Plugins\n\n### Configuring the plugin ###\n\n1. [Create a personal oauth token](https://github.com/settings/tokens/new) with the `public_repo` scope. If you'd prefer not to use your account, you can create another GitHub account for this.\n2. Configure your GitHub host, repository, secret (defined in the next step),  and OAuth Token on the WordPress \u003c--\u003e GitHub sync settings page within WordPress's administrative interface. Make sure the repository has an initial commit or the export will fail.\n3. Create a WebHook within your repository with the provided callback URL and callback secret, using `application/json` as the content type. To set up a webhook on GitHub, head over to the **Settings** page of your repository, and click on **Webhooks \u0026 services**. After that, click on **Add webhook**.\n4. Click `Export to GitHub` or if you use WP-CLI, run `wp wpghs export all #` from the command line, where # = the user ID you'd like to commit as.\n\n## Frequently Asked Questions ##\n\n### Markdown Support ###\n\nWordPress \u003c--\u003e GitHub Sync exports all posts as `.md` files for better display on GitHub, but all content is exported and imported as its original HTML. To enable writing, importing, and exporting in Markdown, please install and enable [WP-Markdown](https://wordpress.org/plugins/wp-markdown/), and WordPress \u003c--\u003e GitHub Sync will use it to convert your posts to and from Markdown.\n\nYou can also activate the Markdown module from [Jetpack](https://wordpress.org/plugins/jetpack/) or the standalone [JP Markdown](https://wordpress.org/plugins/jetpack-markdown/) to save in Markdown and export that version to GitHub.\n\n### Importing from GitHub ###\n\nWordPress \u003c--\u003e GitHub Sync is also capable of importing posts directly from GitHub, without creating them in WordPress before hand. In order to have your post imported into GitHub, add this YAML Frontmatter to the top of your .md document:\n\n    ---\n    post_title: 'Post Title'\n    layout: post_type_probably_post\n    published: true_or_false\n    ---\n    Post goes here.\n\nand fill it out with the data related to the post you're writing. Save the post and commit it directly to the repository. After the post is added to WordPress, an additional commit will be added to the repository, updating the new post with the new information from the database.\n\nNote that WordPress \u003c--\u003e GitHub Sync will *only* import posts from the `master` branch. Changes on other branches will be ignored.\n\nIf WordPress \u003c--\u003e GitHub Sync cannot find the author for a given import, it will fallback to the default user as set on the settings page. **Make sure you set this user before you begin importing posts from GitHub.** Without it set, WordPress \u003c--\u003e GitHub Sync will default to no user being set for the author as well as unknown-author revisions.\n\n### Custom Post Type \u0026 Status Support ###\n\nBy default, WordPress \u003c--\u003e GitHub Sync only exports published posts and pages. However, it provides a number of [hooks](https://codex.wordpress.org/Plugin_API) in order to customize its functionality. Check out the [wiki](https://github.com/mAAdhaTTah/wordpress-github-sync/wiki) for complete documentation for these actions and filters.\n\nIf you want to export additional post types or draft posts, you'll have to hook into the filters `wpghs_whitelisted_post_types` or `wpghs_whitelisted_post_statuses` respectively.\n\nIn `wp-content`, create or open the `mu-plugins` folder and create a plugin file there called `wpghs-custom-filters.php`. In it, paste and modify the below code:\n\n    \u003c?php\n    /**\n     * Plugin Name:  WordPress-GitHub Sync Custom Filters\n     * Plugin URI:   https://github.com/benbalter/wordpress-github-sync\n     * Description:  Adds support for custom post types and statuses\n     * Version:      1.0.0\n     * Author:       James DiGioia\n     * Author URI:   https://jamesdigioia.com/\n     * License:      GPL2\n     */\n\n    add_filter('wpghs_whitelisted_post_types', function ($supported_post_types) {\n      return array_merge($supported_post_types, array(\n        // add your custom post types here\n        'gistpen'\n      ));\n    });\n\n    add_filter('wpghs_whitelisted_post_statuses', function ($supported_post_statuses) {\n      return array_merge($supported_post_statuses, array(\n        // additional statuses available: https://codex.wordpress.org/Post_Status\n        'draft'\n      ));\n    });\n\n### Add \"Edit|View on GitHub\" Link ###\n\nIf you want to add a link to your posts on GitHub, there are 4 functions WordPress\u003c--\u003eGitHub Sync makes available for you to use in your themes or as part of `the_content` filter:\n\n* `get_the_github_view_url` - returns the URL on GitHub to view the current post\n* `get_the_github_view_link` - returns an anchor tag (`\u003ca\u003e`) with its href set the the view url\n* `get_the_github_edit_url` - returns the URL on GitHub to edit the current post\n* `get_the_github_edit_link` - returns an anchor tag (`\u003ca\u003e`) with its href set the the edit url\n\nAll four of these functions must be used in the loop. If you'd like to retrieve these URLs outside of the loop, instantiate a new `WordPress_GitHub_Sync_Post` object and call `github_edit_url` or `github_view_url` respectively on it:\n\n    // $id can be retrieved from a query or elsewhere\n    $wpghs_post = new WordPress_GitHub_Sync_Post( $id );\n    $url = $wpghs_post-\u003egithub_view_url();\n\nIf you'd like to include an edit link without modifying your theme directly, you can add one of these functions to `the_content` like so:\n\n    add_filter( 'the_content', function( $content ) {\n      if( is_page() || is_single() ) {\n        $content .= get_the_github_edit_link();\n      }\n      return $content;\n    }, 1000 );\n\n#### Shortcodes (v \u003e= XXXX) ####\n\nIf you wish to add either the bare URL or a link referencing the URL to an individual post, without editing themes, you can add a [shortcode](https://codex.wordpress.org/Shortcode_API) anywhere in your post;\n\n`[wpghs]`\n\nThe following optional attributes can also be included in the shortcode\n* `target=`\n   + `'view'` (default)  the url used will be the *view* URL (`/blob/`).\n   + `'edit'`            the url used will be the *edit* URL (`/edit/`).\n* `type=`\n   + `'link'` (default)  an anchor tag (`\u003ca\u003e`) with href set to the requested URL will be inserted.\n   + `'url'`             the the bare requested URL will be inserted.\n* `text=`\n   + `''` (default)      link text (where `type='link'`, ignored otherwise) will be set to 'View this post on GitHub'.\n   + `'text'`          link text (where `type='link'`, ignored otherwise) will be set to 'text' (the supplied text).\n\nFor example,\n\n`[wpghs target='view' type='link' text='Here is my post on GitHub']` will produce a HTML anchor tag with href set to the 'view' URL of the post on GitHub, and the link text set to 'Here is my post on GitHub', i.e.\n\n`\u003ca href=\"https://github.com/USERNAME/REPO/blob/master/_posts/YOURPOST.md\"\u003eHere is my post on GitHub\u003c/a\u003e`\n\nAny or all of the attributes can be left out; defaults will take their place.\n\n### Additional Customizations ###\n\nThere are a number of other customizations available in WordPress \u003c--\u003e GitHub Sync, including the commit message and YAML front-matter. Want more detail? Check out the [wiki](https://github.com/mAAdhaTTah/wordpress-github-sync/wiki).\n\n### Contributing ###\n\nFound a bug? Want to take a stab at [one of the open issues](https://github.com/mAAdhaTTah/wordpress-github-sync/issues)? We'd love your help!\n\nSee [the contributing documentation](CONTRIBUTING.md) for details.\n\n### Prior Art ###\n\n* [WordPress Post Forking](https://github.com/post-forking/post-forking)\n* [WordPress to Jekyll exporter](https://github.com/benbalter/wordpress-to-jekyll-exporter)\n* [Writing in public, syncing with GitHub](https://konklone.com/post/writing-in-public-syncing-with-github)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaadhattah%2Fwordpress-github-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaadhattah%2Fwordpress-github-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaadhattah%2Fwordpress-github-sync/lists"}