Changeset 2237967
- Timestamp:
- 02/03/2020 09:55:22 PM (6 years ago)
- Location:
- json-post-type/trunk
- Files:
-
- 3 edited
-
json-post-type.php (modified) (3 diffs)
-
package.json (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
json-post-type/trunk/json-post-type.php
r2237870 r2237967 19 19 */ 20 20 const POST_TYPE = 'json'; 21 22 21 /** 23 22 * Initialize. … … 25 24 public static function init() { 26 25 add_action( 'init', [ __CLASS__, 'register_post_type' ] ); 26 add_action( 'admin_init', [ __CLASS__, 'add_caps' ] ); 27 27 add_filter( sprintf( 'rest_prepare_%s', self::POST_TYPE ), [ __CLASS__, 'prepare_post' ], 99, 3 ); 28 28 } … … 72 72 73 73 /** 74 * Add capabilties to user roles. 75 */ 76 public static function add_caps() { 77 78 /** 79 * Allow roles to be filterable. 80 * 81 * Default to administrator only!. 82 * 83 * @param array $roles The default roles to add caps to. 84 */ 85 $roles = apply_filters( 'json_post_type_roles', [ 'administrator' ] ); 86 87 // Define the capabilities we're using. 88 $capabilities = [ 89 'edit_json', 90 'edit_others_json', 91 'publish_json', 92 'read_private_json' 93 ]; 94 95 // Add capabilities to permitted roles. 96 foreach ( $roles as $role ) { 97 $role = get_role( $role ); 98 if ( count( array_intersect( array_keys( $role->capabilities ), $capabilities ) ) !== count( $capabilities ) ) { 99 foreach ( $capabilities as $capability ) { 100 $role->add_cap( $capability ); 101 } 102 } 103 } 104 } 105 106 /** 74 107 * Register the JSON editor meta box and add JSONEditor assets. 75 108 */ -
json-post-type/trunk/package.json
r2237870 r2237967 1 1 { 2 2 "name": "json-configuration-editor", 3 "version": "1. 0.0",3 "version": "1.1.0", 4 4 "description": "Create a custom post type for the editing and publishing of arbitrary JSON configurations", 5 5 "author": "", -
json-post-type/trunk/readme.txt
r2237870 r2237967 4 4 Requires at least: 4.6 5 5 Tested up to: 5.3 6 Stable tag: 1. 0.06 Stable tag: 1.1.0 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 19 19 == Upgrade Notice == 20 20 21 = 1.0 = 21 = 1.1.0 = 22 * Add default administrator capabilities. 23 24 = 1.0.0 = 22 25 * Initial plugin version.
Note: See TracChangeset
for help on using the changeset viewer.