diff --git a/includes/class-platform.php b/includes/class-platform.php index 80f43263..96b5a05a 100644 --- a/includes/class-platform.php +++ b/includes/class-platform.php @@ -134,7 +134,6 @@ 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'); @@ -189,7 +188,6 @@ 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 deleted file mode 100644 index 8520688d..00000000 --- a/includes/decoded/README.md +++ /dev/null @@ -1 +0,0 @@ -## Decoded Blog diff --git a/includes/decoded/class-decoded.php b/includes/decoded/class-decoded.php deleted file mode 100644 index 82b07a38..00000000 --- a/includes/decoded/class-decoded.php +++ /dev/null @@ -1,117 +0,0 @@ -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/interactives/blocks/loader-block/loader-block.php b/includes/interactives/blocks/loader-block/loader-block.php index e346739b..59bce41c 100644 --- a/includes/interactives/blocks/loader-block/loader-block.php +++ b/includes/interactives/blocks/loader-block/loader-block.php @@ -39,15 +39,12 @@ public function render_interactive_loader_callback($attributes, $content, $block )); $is_legacy_wpackio = array_key_exists('legacyWpackIo', $attributes) && $attributes['legacyWpackIo']; - $is_legacy_s3 = array_key_exists('legacyAssetsS3', $attributes) && $attributes['legacyAssetsS3']; + // We are purposefully not looking for s3 legacy interactives. We're going to let those break. $enqueued_handles = array(); if ( $is_legacy_wpackio ) { wp_enqueue_script('firebase'); $enqueued_handles = $this->load_legacy_wpackIO($attributes['legacyWpackIo']); - } else if ( $is_legacy_s3 ) { - // Do nothing for now... - // @TODO: Build out the legacy assets S3 loader. } else { $enqueued_handles = $this->load($attributes['slug']); } diff --git a/includes/interactives/blocks/loader-block/src/block.json b/includes/interactives/blocks/loader-block/src/block.json index 2d85b985..890af522 100644 --- a/includes/interactives/blocks/loader-block/src/block.json +++ b/includes/interactives/blocks/loader-block/src/block.json @@ -30,26 +30,6 @@ "type": "string" }, "deps":{ - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "legacyAssetsS3": { - "type": "object", - "properties": { - "path": { - "type": "string" - }, - "react": { - "type": "string" - }, - "libraries": { - "type": "string" - }, - "styles": { "type": "string" } } diff --git a/includes/interactives/class-interactives.php b/includes/interactives/class-interactives.php index 84296838..1eab1b80 100644 --- a/includes/interactives/class-interactives.php +++ b/includes/interactives/class-interactives.php @@ -420,13 +420,14 @@ public function load_legacy_wpackIO($args) { 'version' => '1.0', ) ); + $args = \array_change_key_case($args, CASE_LOWER); $enqueued = array(); if ( is_admin() ) { return; } - $app_name = array_key_exists( 'appname', $args ) ? $args['appname'] : $args['appName']; + $app_name = array_key_exists( 'appname', $args ) ? $args['appname'] : false; if ( ! $app_name ) { return false; diff --git a/includes/user-permissions/class-user-permissions.php b/includes/user-permissions/class-user-permissions.php index a78f125a..8a91eec3 100644 --- a/includes/user-permissions/class-user-permissions.php +++ b/includes/user-permissions/class-user-permissions.php @@ -31,6 +31,8 @@ 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 ); } } @@ -78,4 +80,66 @@ 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 662c1b86..85aafa6b 100644 --- a/includes/user-permissions/user-roles.json +++ b/includes/user-permissions/user-roles.json @@ -24,6 +24,22 @@ "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 + } } } }