diff --git a/includes/class-platform.php b/includes/class-platform.php index 96b5a05a..80f43263 100644 --- a/includes/class-platform.php +++ b/includes/class-platform.php @@ -134,6 +134,7 @@ private function load_dependencies() { $this->include('post-report-package/class-post-report-package.php'); $this->include('post-visibility/class-post-visibility.php'); $this->include('press-releases/class-press-releases.php'); + $this->include('decoded/class-decoded.php'); $this->include('related-posts/class-related-posts.php'); $this->include('rest-api/class-rest-api.php'); $this->include('rss/class-rss.php'); @@ -188,6 +189,7 @@ function() { new Post_Report_Package( $this->get_version(), $this->get_loader() ); new Post_Visibility( $this->get_version(), $this->get_loader() ); new Press_Releases( $this->get_version(), $this->get_loader() ); + new Decoded( $this->get_version(), $this->get_loader() ); new Related_Posts( $this->get_version(), $this->get_loader() ); new Rest_API( $this->get_version(), $this->get_loader() ); new RSS_Feeds( $this->get_version(), $this->get_loader() ); diff --git a/includes/decoded/README.md b/includes/decoded/README.md new file mode 100644 index 00000000..8520688d --- /dev/null +++ b/includes/decoded/README.md @@ -0,0 +1 @@ +## Decoded Blog diff --git a/includes/decoded/class-decoded.php b/includes/decoded/class-decoded.php new file mode 100644 index 00000000..82b07a38 --- /dev/null +++ b/includes/decoded/class-decoded.php @@ -0,0 +1,117 @@ +version = $version; + $this->init($loader); + } + + public function init($loader) { + if ( null !== $loader ) { + $loader->add_action( 'init', $this, 'register_type' ); + $loader->add_filter( 'prc_load_gutenberg', $this, 'enable_gutenberg_ramp' ); + $loader->add_filter( 'post_type_link', $this, 'get_decoded_permalink', 10, 3); + } + } + + public function register_type() { + $labels = array( + 'name' => _x( 'Decoded Posts', 'Post Type General Name', 'text_domain' ), + 'singular_name' => _x( 'Decoded Post', 'Post Type Singular Name', 'text_domain' ), + 'menu_name' => __( 'Decoded', 'text_domain' ), + 'name_admin_bar' => __( 'Decoded', 'text_domain' ), + 'archives' => __( 'Decoded Archives', 'text_domain' ), + 'parent_item_colon' => __( 'Parent Decoded Post:', 'text_domain' ), + 'all_items' => __( 'All Decoded Posts', 'text_domain' ), + 'add_new_item' => __( 'Add New Decoded Post', 'text_domain' ), + 'add_new' => __( 'Add New', 'text_domain' ), + 'new_item' => __( 'New Decoded Post', 'text_domain' ), + 'edit_item' => __( 'Edit Decoded Post', 'text_domain' ), + 'update_item' => __( 'Update Decoded Post', 'text_domain' ), + 'view_item' => __( 'View Decoded Post', 'text_domain' ), + 'search_items' => __( 'Search Decoded Posts', 'text_domain' ), + 'not_found' => __( 'Not found', 'text_domain' ), + 'not_found_in_trash' => __( 'Not found in Trash', 'text_domain' ), + 'featured_image' => __( 'Featured Image', 'text_domain' ), + 'set_featured_image' => __( 'Set featured image', 'text_domain' ), + 'remove_featured_image' => __( 'Remove featured image', 'text_domain' ), + 'use_featured_image' => __( 'Use as featured image', 'text_domain' ), + 'insert_into_item' => __( 'Insert into Decoded Post', 'text_domain' ), + 'uploaded_to_this_item' => __( 'Uploaded to this Decoded Post', 'text_domain' ), + 'items_list' => __( 'Decoded Posts List', 'text_domain' ), + 'items_list_navigation' => __( 'Decoded Posts List Navigation', 'text_domain' ), + 'filter_items_list' => __( 'Filter Decoded Posts List', 'text_domain' ), + ); + + $rewrite = array( + 'slug' => 'decoded/%year%/%monthnum%', + 'with_front' => true, + 'pages' => true, + 'feeds' => true, + ); + + $args = array( + 'label' => __( 'Decoded', 'text_domain' ), + 'description' => __( 'A post type for Decoded blog posts.', 'text_domain' ), + 'labels' => $labels, + 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'revisions' ), + 'taxonomies' => array( 'formats' ), + 'hierarchical' => false, + 'public' => true, + 'show_ui' => true, + 'show_in_menu' => true, + 'menu_position' => 5, + 'show_in_admin_bar' => true, + 'show_in_nav_menus' => true, + 'show_in_rest' => true, + 'can_export' => true, + 'has_archive' => true, + 'exclude_from_search' => false, + 'publicly_queryable' => true, + 'rewrite' => $rewrite, + 'capability_type' => 'post', + ); + + register_post_type( self::$post_type, $args ); + } + + public function enable_gutenberg_ramp($post_types) { + array_push($post_types, self::$post_type); + return $post_types; + } + + // Convert the %year% and %monthnum% placeholders in the post type's rewrite slug to the actual year and month. + public function get_decoded_permalink($url, $post) { + if ( self::$post_type == get_post_type($post) ) { + $url = str_replace( "%year%", get_the_date('Y'), $url ); + $url = str_replace( "%monthnum%", get_the_date('m'), $url ); + } + return $url; + } +} diff --git a/includes/user-permissions/class-user-permissions.php b/includes/user-permissions/class-user-permissions.php index 8a91eec3..a78f125a 100644 --- a/includes/user-permissions/class-user-permissions.php +++ b/includes/user-permissions/class-user-permissions.php @@ -31,8 +31,6 @@ public function init($loader = null) { if ( null !== $loader ) { $loader->add_filter( 'wpcom_vip_enable_two_factor', $this, 'enforce_two_factor', 10, 1 ); $loader->add_action( 'admin_init', $this, 'autoload_user_roles' ); - $loader->add_action( 'init', $this, 'register_common_user_meta' ); - $loader->add_action( 'register_new_user', $this, 'set_default_meta_on_new_user_creation', 10, 1 ); } } @@ -80,66 +78,4 @@ public function autoload_user_roles() { public function enforce_two_factor($value) { return defined('VIP_GO_APP_ENVIRONMENT') && 'production' === \VIP_GO_APP_ENVIRONMENT; } - - /** - * @hook init - * @return void - */ - public function register_common_user_meta() { - register_meta( - 'user', - 'prc_copilot_settings', - array( - 'type' => 'object', - 'description' => 'Settings for PRC Copilot plugin', - 'single' => true, - 'show_in_rest' => true, - ) - ); - register_meta( - 'user', - 'prc_staff_id', - array( - 'type' => 'number', - 'description' => 'Links a staff record to a user record. When a name is updated for a user the staff name is updated as well and vice versa.', - 'single' => true, - 'show_in_rest' => true, - ) - ); - register_meta( - 'user', - 'prc_user_beneficiary_id', - array( - 'type' => 'number', - 'description' => 'When a user is deleted this user is the benefeciary of their db records', - 'single' => true, - 'show_in_rest' => true, - ) - ); - } - - /** - * Fires after a new user has been registered, checks for the existence of default meta and if none - * sets accordingly. - * - * @hook register_new_user - * @return void - */ - public function set_default_meta_on_new_user_creation($user_id) { - if ( ! $user_id ) { - return; - } - $copilot_defaults = array( - 'allowed' => true, - 'tokenBudget' => 1000, - 'allowances' => array( - 'excerpt' => true, // Do we allow the user to use the copilot excerpt generation function - 'title' => true, // Do we allow the user to use the copilot title generation function - 'content' => false, // Do we allow the user to use the copilot content generation function - ) - ); - if ( ! get_user_meta( $user_id, 'prc_copilot_settings', true ) ) { - add_user_meta( $user_id, 'prc_copilot_settings', $copilot_defaults, true ); - } - } } diff --git a/includes/user-permissions/user-roles.json b/includes/user-permissions/user-roles.json index 85aafa6b..662c1b86 100644 --- a/includes/user-permissions/user-roles.json +++ b/includes/user-permissions/user-roles.json @@ -24,22 +24,6 @@ "wpseo_edit_advanced_metadata": true, "wpseo_bulk_edit": true } - }, - "comms-editor": { - "name": "Communications Editor", - "inherits": "editor", - "capabilities": { - "wpseo_manage_options": true, - "wpseo_edit_advanced_metadata": true, - "wpseo_bulk_edit": true - } - }, - "designer": { - "name": "Designer", - "inherits": "editor", - "capabilities": { - "edit_theme_options": true - } } } }