{"action":"created","issue":{"url":"https://api.github.com/repos/hoppinger/advanced-custom-fields-wpcli/issues/45","repository_url":"https://api.github.com/repos/hoppinger/advanced-custom-fields-wpcli","labels_url":"https://api.github.com/repos/hoppinger/advanced-custom-fields-wpcli/issues/45/labels{/name}","comments_url":"https://api.github.com/repos/hoppinger/advanced-custom-fields-wpcli/issues/45/comments","events_url":"https://api.github.com/repos/hoppinger/advanced-custom-fields-wpcli/issues/45/events","html_url":"https://github.com/hoppinger/advanced-custom-fields-wpcli/issues/45","id":156936524,"node_id":"MDU6SXNzdWUxNTY5MzY1MjQ=","number":45,"title":"Release script for wordpress.org/plugins","user":{"login":"sebastiaandegeus","id":1560127,"node_id":"MDQ6VXNlcjE1NjAxMjc=","avatar_url":"https://avatars2.githubusercontent.com/u/1560127?v=4","gravatar_id":"","url":"https://api.github.com/users/sebastiaandegeus","html_url":"https://github.com/sebastiaandegeus","followers_url":"https://api.github.com/users/sebastiaandegeus/followers","following_url":"https://api.github.com/users/sebastiaandegeus/following{/other_user}","gists_url":"https://api.github.com/users/sebastiaandegeus/gists{/gist_id}","starred_url":"https://api.github.com/users/sebastiaandegeus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebastiaandegeus/subscriptions","organizations_url":"https://api.github.com/users/sebastiaandegeus/orgs","repos_url":"https://api.github.com/users/sebastiaandegeus/repos","events_url":"https://api.github.com/users/sebastiaandegeus/events{/privacy}","received_events_url":"https://api.github.com/users/sebastiaandegeus/received_events","type":"User","site_admin":false},"labels":[{"id":8293468,"node_id":"MDU6TGFiZWw4MjkzNDY4","url":"https://api.github.com/repos/hoppinger/advanced-custom-fields-wpcli/labels/feature","name":"feature","color":"0e8a16","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/hoppinger/advanced-custom-fields-wpcli/milestones/1","html_url":"https://github.com/hoppinger/advanced-custom-fields-wpcli/milestone/1","labels_url":"https://api.github.com/repos/hoppinger/advanced-custom-fields-wpcli/milestones/1/labels","id":1789278,"node_id":"MDk6TWlsZXN0b25lMTc4OTI3OA==","number":1,"title":"Version 3","description":"Complete rewrite of the plugin","creator":{"login":"sebastiaandegeus","id":1560127,"node_id":"MDQ6VXNlcjE1NjAxMjc=","avatar_url":"https://avatars2.githubusercontent.com/u/1560127?v=4","gravatar_id":"","url":"https://api.github.com/users/sebastiaandegeus","html_url":"https://github.com/sebastiaandegeus","followers_url":"https://api.github.com/users/sebastiaandegeus/followers","following_url":"https://api.github.com/users/sebastiaandegeus/following{/other_user}","gists_url":"https://api.github.com/users/sebastiaandegeus/gists{/gist_id}","starred_url":"https://api.github.com/users/sebastiaandegeus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebastiaandegeus/subscriptions","organizations_url":"https://api.github.com/users/sebastiaandegeus/orgs","repos_url":"https://api.github.com/users/sebastiaandegeus/repos","events_url":"https://api.github.com/users/sebastiaandegeus/events{/privacy}","received_events_url":"https://api.github.com/users/sebastiaandegeus/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":1,"state":"open","created_at":"2016-05-26T09:11:10Z","updated_at":"2016-12-04T15:09:41Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2016-05-26T09:01:47Z","updated_at":"2018-07-03T19:02:08Z","closed_at":null,"author_association":"MEMBER","body":"- Add a script to release this plugin to the official wordpress plugins repository.\n- Release the latest versions for major releases.\n"},"comment":{"url":"https://api.github.com/repos/hoppinger/advanced-custom-fields-wpcli/issues/comments/402261200","html_url":"https://github.com/hoppinger/advanced-custom-fields-wpcli/issues/45#issuecomment-402261200","issue_url":"https://api.github.com/repos/hoppinger/advanced-custom-fields-wpcli/issues/45","id":402261200,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMjI2MTIwMA==","user":{"login":"drzraf","id":1169926,"node_id":"MDQ6VXNlcjExNjk5MjY=","avatar_url":"https://avatars0.githubusercontent.com/u/1169926?v=4","gravatar_id":"","url":"https://api.github.com/users/drzraf","html_url":"https://github.com/drzraf","followers_url":"https://api.github.com/users/drzraf/followers","following_url":"https://api.github.com/users/drzraf/following{/other_user}","gists_url":"https://api.github.com/users/drzraf/gists{/gist_id}","starred_url":"https://api.github.com/users/drzraf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drzraf/subscriptions","organizations_url":"https://api.github.com/users/drzraf/orgs","repos_url":"https://api.github.com/users/drzraf/repos","events_url":"https://api.github.com/users/drzraf/events{/privacy}","received_events_url":"https://api.github.com/users/drzraf/received_events","type":"User","site_admin":false},"created_at":"2018-07-03T19:02:08Z","updated_at":"2018-07-03T19:02:08Z","author_association":"NONE","body":"This is the code I used to use (before I switched fully to acf-json/):\r\n```php\r\n<?php\r\n\r\n/**\r\n * ACF_Commands\r\n */\r\nclass ACF_Commands extends WP_CLI_Command {\r\n    /**\r\n     * Sync ACF Fields\r\n     *\r\n     * ## OPTIONS\r\n     *\r\n     * @when init\r\n     * @example\r\n     *  wp acf sync\r\n     *\r\n     */\r\n    function sync ( $args, $assoc_args ) {\r\n        $groups = acf_get_field_groups();\r\n        $sync \t= [];\r\n\r\n        // bail early if no field groups\r\n        if( empty( $groups ) ) {\r\n            return;\r\n        }\r\n\r\n        // find JSON field groups which have not yet been imported\r\n        foreach( $groups as $group ) {\r\n            $local \t\t= acf_maybe_get( $group, 'local', false );\r\n            $modified \t= acf_maybe_get( $group, 'modified', 0 );\r\n            $private \t= acf_maybe_get( $group, 'private', false );\r\n\r\n            // ignore DB / PHP / private field groups\r\n            if( $local !== 'json' || $private ) {\r\n                // do nothing\r\n            } elseif( ! $group[ 'ID' ] ) {\r\n                $sync[ $group[ 'key' ] ] = $group;\r\n            } elseif( $modified ) {\r\n                $db_mod_time = get_post_modified_time( 'U', true, $group[ 'ID' ], true );\r\n                WP_CLI::debug( sprintf( \"%s: %d > %d = %d\",\r\n                                        $group['key'],\r\n                                        $modified,\r\n                                        $db_mod_time,\r\n                                        $modified > $db_mod_time ) );\r\n\r\n                if ( $modified > $db_mod_time ) {\r\n                    $sync[ $group[ 'key' ] ]  = $group;\r\n                }\r\n            }\r\n        }\r\n\r\n        // bail if no sync needed\r\n        if( empty( $sync ) ) {\r\n            WP_CLI::debug( \"No ACF Sync Required\" );\r\n            return;\r\n        }\r\n        else {\r\n            // avoid db field update to trigger a resave that would further modify the json file\r\n            remove_action('acf/update_field_group', [ acf()->json, 'update_field_group' ], 10, 1);\r\n            $new_ids = [];\r\n            foreach( $sync as $key => $v ) {\r\n                // append fields\r\n                if( acf_have_local_fields( $key ) ) {\r\n                    $sync[ $key ][ 'fields' ] = acf_get_local_fields( $key );\r\n                }\r\n                // import\r\n                $field_group = acf_import_field_group( $sync[ $key ] );\r\n                WP_CLI::success( 'ACF sync ' . $key );\r\n            }\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nNote: the call to `remove_action('acf/update_field_group')`.\r\nNote: This did **not synchronize the removal** of a field group."}}
{"actor":{"display_login":"drzraf"}}