Skip to content

Commit

Permalink
See pewresearch/pewresearch-org@3ebb881 from refs/heads/release/5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
prcdevgitbot committed Feb 28, 2024
1 parent 5336951 commit ea29c91
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 145 deletions.
2 changes: 0 additions & 2 deletions includes/class-platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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() );
Expand Down
1 change: 0 additions & 1 deletion includes/decoded/README.md

This file was deleted.

117 changes: 0 additions & 117 deletions includes/decoded/class-decoded.php

This file was deleted.

5 changes: 1 addition & 4 deletions includes/interactives/blocks/loader-block/loader-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
Expand Down
20 changes: 0 additions & 20 deletions includes/interactives/blocks/loader-block/src/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
3 changes: 2 additions & 1 deletion includes/interactives/class-interactives.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
64 changes: 64 additions & 0 deletions includes/user-permissions/class-user-permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}

Expand Down Expand Up @@ -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 );
}
}
}
16 changes: 16 additions & 0 deletions includes/user-permissions/user-roles.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}

0 comments on commit ea29c91

Please sign in to comment.