{"action":"created","comment":{"url":"https://api.github.com/repos/xwp/wp-customize-snapshots/pulls/comments/71947851","id":71947851,"diff_hunk":"@@ -549,4 +552,86 @@ public function filter_user_has_cap( $allcaps, $caps ) {\n \n \t\treturn $allcaps;\n \t}\n+\n+\t/**\n+\t * Publish snapshot changes when snapshot post is being published.\n+\t *\n+\t * @param int      $post_id Post id.\n+\t * @param \\WP_Post $post Post object.\n+\t */\n+\tpublic function publish_snapshot( $post_id, $post ) {\n+\t\tif ( did_action( 'customize_save' ) ) {\n+\t\t\t// Short circuit because customize_save ajax call is changing status.\n+\t\t\treturn;\n+\t\t}\n+\t\t$snapshot_theme = get_post_meta( get_the_ID(), '_snapshot_theme', true );\n+\t\tif ( ! empty( $snapshot_theme ) && get_stylesheet() !== $snapshot_theme ) {\n+\t\t\t// Theme mismatch.\n+\t\t\tif ( defined( 'DOING_CRON' ) && DOING_CRON ) {\n+\t\t\t\twp_update_post( array(\n+\t\t\t\t\t'ID' => $post->ID,\n+\t\t\t\t\t'post_status' => 'pending',\n+\t\t\t\t) );\n+\t\t\t}\n+\t\t}\n+\t\t$this->snapshot_manager->ensure_customize_manager();\n+\n+\t\tif ( ! did_action( 'customize_register' ) ) {\n+\t\t\t/*\n+\t\t\t * When running from CLI or Cron, we have to remove the action because\n+\t\t\t * it will get added with a default priority of 10, after themes and plugins\n+\t\t\t * have already done add_action( 'customize_register' ), resulting in them\n+\t\t\t * being called first at the priority 10. So we manually call the\n+\t\t\t * prerequisite function WP_Customize_Manager::register_controls() and\n+\t\t\t * remove it from being called when the customize_register action fires.\n+\t\t\t */\n+\t\t\tremove_action( 'customize_register', array( $this->snapshot_manager->customize_manager, 'register_controls' ) );\n+\t\t\t$this->snapshot_manager->customize_manager->register_controls();\n+\n+\t\t\t/** This action is documented in wp-includes/class-wp-customize-manager.php */\n+\t\t\tdo_action( 'customize_register', $this->snapshot_manager->customize_manager );\n+\t\t}\n+\t\t$snapshot_content = $this->get_post_content( $post );\n+\t\t$snapshot_values = array_filter(\n+\t\t\twp_list_pluck( $snapshot_content, 'value' ),\n+\t\t\tfunction( $value ) {\n+\t\t\t\treturn ! is_null( $value );\n+\t\t\t}\n+\t\t);\n+\n+\t\tif ( method_exists( $this->snapshot_manager->customize_manager, 'validate_setting_values' ) ) {\n+\t\t\t/** This action is documented in wp-includes/class-wp-customize-manager.php */\n+\t\t\tdo_action( 'customize_save_validation_before', $this->snapshot_manager->customize_manager );\n+\t\t}\n+\n+\t\t$this->snapshot_manager->customize_manager->add_dynamic_settings( array_keys( $snapshot_values ) );\n+\t\t$setting_objs = array();\n+\t\tforeach ( $snapshot_values as $setting_id => $setting_params ) {\n+\t\t\t$this->snapshot_manager->customize_manager->set_post_value( $setting_id, $setting_params );\n+\t\t\t$setting_objs[] = $this->snapshot_manager->customize_manager->get_setting( $setting_id );\n+\t\t}\n+\n+\t\t$filtered_setting_objs = array_filter( $setting_objs, function( $setting_obj ) {\n+\t\t\treturn is_a( $setting_obj, '\\WP_Customize_Setting' );","path":"php/class-post-type.php","position":92,"original_position":92,"commit_id":"2742e57d5f329dd940e655597f8c80193d6832e3","original_commit_id":"2742e57d5f329dd940e655597f8c80193d6832e3","user":{"login":"westonruter","id":134745,"avatar_url":"https://avatars.githubusercontent.com/u/134745?v=3","gravatar_id":"","url":"https://api.github.com/users/westonruter","html_url":"https://github.com/westonruter","followers_url":"https://api.github.com/users/westonruter/followers","following_url":"https://api.github.com/users/westonruter/following{/other_user}","gists_url":"https://api.github.com/users/westonruter/gists{/gist_id}","starred_url":"https://api.github.com/users/westonruter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/westonruter/subscriptions","organizations_url":"https://api.github.com/users/westonruter/orgs","repos_url":"https://api.github.com/users/westonruter/repos","events_url":"https://api.github.com/users/westonruter/events{/privacy}","received_events_url":"https://api.github.com/users/westonruter/received_events","type":"User","site_admin":false},"body":"I think it's better to do `return $setting_obj instanceof \\WP_Customize_Setting`. It's more modern.","created_at":"2016-07-22T21:20:13Z","updated_at":"2016-07-22T21:20:13Z","html_url":"https://github.com/xwp/wp-customize-snapshots/pull/62#discussion_r71947851","pull_request_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/pulls/62","_links":{"self":{"href":"https://api.github.com/repos/xwp/wp-customize-snapshots/pulls/comments/71947851"},"html":{"href":"https://github.com/xwp/wp-customize-snapshots/pull/62#discussion_r71947851"},"pull_request":{"href":"https://api.github.com/repos/xwp/wp-customize-snapshots/pulls/62"}}},"pull_request":{"url":"https://api.github.com/repos/xwp/wp-customize-snapshots/pulls/62","id":78141089,"html_url":"https://github.com/xwp/wp-customize-snapshots/pull/62","diff_url":"https://github.com/xwp/wp-customize-snapshots/pull/62.diff","patch_url":"https://github.com/xwp/wp-customize-snapshots/pull/62.patch","issue_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/issues/62","number":62,"state":"open","locked":false,"title":"[WIP] Allow snapshot to publish","user":{"login":"PatelUtkarsh","id":5015489,"avatar_url":"https://avatars.githubusercontent.com/u/5015489?v=3","gravatar_id":"","url":"https://api.github.com/users/PatelUtkarsh","html_url":"https://github.com/PatelUtkarsh","followers_url":"https://api.github.com/users/PatelUtkarsh/followers","following_url":"https://api.github.com/users/PatelUtkarsh/following{/other_user}","gists_url":"https://api.github.com/users/PatelUtkarsh/gists{/gist_id}","starred_url":"https://api.github.com/users/PatelUtkarsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PatelUtkarsh/subscriptions","organizations_url":"https://api.github.com/users/PatelUtkarsh/orgs","repos_url":"https://api.github.com/users/PatelUtkarsh/repos","events_url":"https://api.github.com/users/PatelUtkarsh/events{/privacy}","received_events_url":"https://api.github.com/users/PatelUtkarsh/received_events","type":"User","site_admin":false},"body":"This allows snapshot changes to be published, On publish it will save snapshot changes in database.\r\n\r\nFixes #15.","created_at":"2016-07-20T12:51:34Z","updated_at":"2016-07-22T21:20:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4a71bbadd5882d56f0e1eeaf7a4b5cd75b4cb92f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/pulls/62/commits","review_comments_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/pulls/62/comments","review_comment_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/issues/62/comments","statuses_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/statuses/2742e57d5f329dd940e655597f8c80193d6832e3","head":{"label":"xwp:feature/publish-snapshot","ref":"feature/publish-snapshot","sha":"2742e57d5f329dd940e655597f8c80193d6832e3","user":{"login":"xwp","id":9003139,"avatar_url":"https://avatars.githubusercontent.com/u/9003139?v=3","gravatar_id":"","url":"https://api.github.com/users/xwp","html_url":"https://github.com/xwp","followers_url":"https://api.github.com/users/xwp/followers","following_url":"https://api.github.com/users/xwp/following{/other_user}","gists_url":"https://api.github.com/users/xwp/gists{/gist_id}","starred_url":"https://api.github.com/users/xwp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xwp/subscriptions","organizations_url":"https://api.github.com/users/xwp/orgs","repos_url":"https://api.github.com/users/xwp/repos","events_url":"https://api.github.com/users/xwp/events{/privacy}","received_events_url":"https://api.github.com/users/xwp/received_events","type":"Organization","site_admin":false},"repo":{"id":45574788,"name":"wp-customize-snapshots","full_name":"xwp/wp-customize-snapshots","owner":{"login":"xwp","id":9003139,"avatar_url":"https://avatars.githubusercontent.com/u/9003139?v=3","gravatar_id":"","url":"https://api.github.com/users/xwp","html_url":"https://github.com/xwp","followers_url":"https://api.github.com/users/xwp/followers","following_url":"https://api.github.com/users/xwp/following{/other_user}","gists_url":"https://api.github.com/users/xwp/gists{/gist_id}","starred_url":"https://api.github.com/users/xwp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xwp/subscriptions","organizations_url":"https://api.github.com/users/xwp/orgs","repos_url":"https://api.github.com/users/xwp/repos","events_url":"https://api.github.com/users/xwp/events{/privacy}","received_events_url":"https://api.github.com/users/xwp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xwp/wp-customize-snapshots","description":"Customize Snapshots WordPress Plugin","fork":false,"url":"https://api.github.com/repos/xwp/wp-customize-snapshots","forks_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/forks","keys_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/teams","hooks_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/hooks","issue_events_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/issues/events{/number}","events_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/events","assignees_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/assignees{/user}","branches_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/branches{/branch}","tags_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/tags","blobs_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/git/refs{/sha}","trees_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/statuses/{sha}","languages_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/languages","stargazers_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/stargazers","contributors_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/contributors","subscribers_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/subscribers","subscription_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/subscription","commits_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/commits{/sha}","git_commits_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/git/commits{/sha}","comments_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/comments{/number}","issue_comment_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/issues/comments{/number}","contents_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/contents/{+path}","compare_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/merges","archive_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/downloads","issues_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/issues{/number}","pulls_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/pulls{/number}","milestones_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/milestones{/number}","notifications_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/labels{/name}","releases_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/releases{/id}","deployments_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/deployments","created_at":"2015-11-04T23:42:20Z","updated_at":"2016-06-21T21:39:25Z","pushed_at":"2016-07-22T18:39:06Z","git_url":"git://github.com/xwp/wp-customize-snapshots.git","ssh_url":"git@github.com:xwp/wp-customize-snapshots.git","clone_url":"https://github.com/xwp/wp-customize-snapshots.git","svn_url":"https://github.com/xwp/wp-customize-snapshots","homepage":"https://wordpress.org/plugins/customize-snapshots/","size":1035,"stargazers_count":8,"watchers_count":8,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":20,"forks":1,"open_issues":20,"watchers":8,"default_branch":"develop"}},"base":{"label":"xwp:feature/refactor","ref":"feature/refactor","sha":"f69b32592021cef7ffa5d34419f67f70950f7ec3","user":{"login":"xwp","id":9003139,"avatar_url":"https://avatars.githubusercontent.com/u/9003139?v=3","gravatar_id":"","url":"https://api.github.com/users/xwp","html_url":"https://github.com/xwp","followers_url":"https://api.github.com/users/xwp/followers","following_url":"https://api.github.com/users/xwp/following{/other_user}","gists_url":"https://api.github.com/users/xwp/gists{/gist_id}","starred_url":"https://api.github.com/users/xwp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xwp/subscriptions","organizations_url":"https://api.github.com/users/xwp/orgs","repos_url":"https://api.github.com/users/xwp/repos","events_url":"https://api.github.com/users/xwp/events{/privacy}","received_events_url":"https://api.github.com/users/xwp/received_events","type":"Organization","site_admin":false},"repo":{"id":45574788,"name":"wp-customize-snapshots","full_name":"xwp/wp-customize-snapshots","owner":{"login":"xwp","id":9003139,"avatar_url":"https://avatars.githubusercontent.com/u/9003139?v=3","gravatar_id":"","url":"https://api.github.com/users/xwp","html_url":"https://github.com/xwp","followers_url":"https://api.github.com/users/xwp/followers","following_url":"https://api.github.com/users/xwp/following{/other_user}","gists_url":"https://api.github.com/users/xwp/gists{/gist_id}","starred_url":"https://api.github.com/users/xwp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xwp/subscriptions","organizations_url":"https://api.github.com/users/xwp/orgs","repos_url":"https://api.github.com/users/xwp/repos","events_url":"https://api.github.com/users/xwp/events{/privacy}","received_events_url":"https://api.github.com/users/xwp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xwp/wp-customize-snapshots","description":"Customize Snapshots WordPress Plugin","fork":false,"url":"https://api.github.com/repos/xwp/wp-customize-snapshots","forks_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/forks","keys_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/teams","hooks_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/hooks","issue_events_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/issues/events{/number}","events_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/events","assignees_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/assignees{/user}","branches_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/branches{/branch}","tags_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/tags","blobs_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/git/refs{/sha}","trees_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/statuses/{sha}","languages_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/languages","stargazers_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/stargazers","contributors_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/contributors","subscribers_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/subscribers","subscription_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/subscription","commits_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/commits{/sha}","git_commits_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/git/commits{/sha}","comments_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/comments{/number}","issue_comment_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/issues/comments{/number}","contents_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/contents/{+path}","compare_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/merges","archive_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/downloads","issues_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/issues{/number}","pulls_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/pulls{/number}","milestones_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/milestones{/number}","notifications_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/labels{/name}","releases_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/releases{/id}","deployments_url":"https://api.github.com/repos/xwp/wp-customize-snapshots/deployments","created_at":"2015-11-04T23:42:20Z","updated_at":"2016-06-21T21:39:25Z","pushed_at":"2016-07-22T18:39:06Z","git_url":"git://github.com/xwp/wp-customize-snapshots.git","ssh_url":"git@github.com:xwp/wp-customize-snapshots.git","clone_url":"https://github.com/xwp/wp-customize-snapshots.git","svn_url":"https://github.com/xwp/wp-customize-snapshots","homepage":"https://wordpress.org/plugins/customize-snapshots/","size":1035,"stargazers_count":8,"watchers_count":8,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":20,"forks":1,"open_issues":20,"watchers":8,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/xwp/wp-customize-snapshots/pulls/62"},"html":{"href":"https://github.com/xwp/wp-customize-snapshots/pull/62"},"issue":{"href":"https://api.github.com/repos/xwp/wp-customize-snapshots/issues/62"},"comments":{"href":"https://api.github.com/repos/xwp/wp-customize-snapshots/issues/62/comments"},"review_comments":{"href":"https://api.github.com/repos/xwp/wp-customize-snapshots/pulls/62/comments"},"review_comment":{"href":"https://api.github.com/repos/xwp/wp-customize-snapshots/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xwp/wp-customize-snapshots/pulls/62/commits"},"statuses":{"href":"https://api.github.com/repos/xwp/wp-customize-snapshots/statuses/2742e57d5f329dd940e655597f8c80193d6832e3"}}}}
{"actor":{"display_login":"westonruter"}}