diff --git a/plugins/wporg-5ftf/includes/contributor.php b/plugins/wporg-5ftf/includes/contributor.php
index 75c6df8..a7eacae 100644
--- a/plugins/wporg-5ftf/includes/contributor.php
+++ b/plugins/wporg-5ftf/includes/contributor.php
@@ -66,7 +66,7 @@ function register_custom_post_type() {
'publicly_queryable' => false,
'capability_type' => 'page',
'capabilities' => array(
- 'create_posts' => 'do_not_allow'
+ 'create_posts' => 'do_not_allow',
),
'map_meta_cap' => true,
'show_in_rest' => false, // todo Maybe turn this on later.
@@ -317,7 +317,7 @@ function process_my_pledges_form() {
}
$contributor_post = get_post( $contributor_post_id );
- if ( ! isset( $contributor_post->post_type ) || $contributor_post->post_type !== CPT_ID ) {
+ if ( ! isset( $contributor_post->post_type ) || CPT_ID !== $contributor_post->post_type ) {
return ''; // Return early, the form was submitted incorrectly.
}
@@ -326,8 +326,8 @@ function process_my_pledges_form() {
return ''; // User doesn't have permission to update this.
}
- $pledge = get_post( $contributor_post->post_parent );
- $message = '';
+ $pledge = get_post( $contributor_post->post_parent );
+ $message = '';
$new_status = false;
if ( filter_input( INPUT_POST, 'join_organization' ) ) {
@@ -335,21 +335,21 @@ function process_my_pledges_form() {
wp_verify_nonce( $unverified_nonce, $nonce_action ) || wp_nonce_ays( $nonce_action );
$new_status = 'publish';
- $message = "You have joined the pledge from {$pledge->post_title}.";
+ $message = "You have joined the pledge from {$pledge->post_title}.";
} elseif ( filter_input( INPUT_POST, 'decline_invitation' ) ) {
$nonce_action = 'join_decline_organization_' . $contributor_post_id;
wp_verify_nonce( $unverified_nonce, $nonce_action ) || wp_nonce_ays( $nonce_action );
$new_status = 'trash';
- $message = "You have declined the pledge invitation from {$pledge->post_title}.";
+ $message = "You have declined the pledge invitation from {$pledge->post_title}.";
} elseif ( filter_input( INPUT_POST, 'leave_organization' ) ) {
$nonce_action = 'leave_organization_' . $contributor_post_id;
wp_verify_nonce( $unverified_nonce, $nonce_action ) || wp_nonce_ays( $nonce_action );
$new_status = 'trash';
- $message = "You have left the {$pledge->post_title} pledge.";
+ $message = "You have left the {$pledge->post_title} pledge.";
}
if ( 'publish' === $new_status && 'publish' !== $contributor_post->post_status ) {
diff --git a/plugins/wporg-5ftf/includes/email.php b/plugins/wporg-5ftf/includes/email.php
index 20ed688..9a4c1d9 100644
--- a/plugins/wporg-5ftf/includes/email.php
+++ b/plugins/wporg-5ftf/includes/email.php
@@ -34,7 +34,8 @@ defined( 'WPINC' ) || die();
const TOKEN_PREFIX = '5ftf_auth_token_';
-// Longer than `get_password_reset_key()` just to be safe. See https://core.trac.wordpress.org/ticket/43546#comment:34
+// Longer than `get_password_reset_key()` just to be safe.
+// See https://core.trac.wordpress.org/ticket/43546#comment:34.
const TOKEN_LENGTH = 32;
add_action( 'wp_head', __NAMESPACE__ . '\prevent_caching_auth_tokens', 99 );
@@ -46,8 +47,9 @@ add_action( 'wp_head', __NAMESPACE__ . '\prevent_caching_auth_tokens', 99 );
* etc could create situations where they're leaked to others.
*/
function prevent_caching_auth_tokens() {
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Nonce not required, not processing form data.
if ( isset( $_GET['auth_token'] ) || isset( $_POST['auth_token'] ) ) {
- nocache_headers();
+ nocache_headers();
}
}
@@ -65,7 +67,6 @@ function send_email( $to, $subject, $message, $pledge_id ) {
$headers = array(
'From: WordPress - Five for the Future
%s', esc_html( $confirmed ), esc_html( $unconfirmed ) );
break;
case 'domain':
$domain = get_post_meta( $post_id, META_PREFIX . 'org-domain', true );
@@ -181,7 +185,6 @@ function create_new_pledge( $name ) {
'post_status' => 'draft',
);
-
$pledge_id = wp_insert_post( $args, true );
// The pledge's meta data is saved at this point via `save_pledge_meta()`, which is a `save_post` callback.
@@ -204,11 +207,10 @@ function create_new_pledge( $name ) {
function send_pledge_confirmation_email( $pledge_id, $action_page_id ) {
$pledge = get_post( $pledge_id );
- $message =
- "Thanks for pledging your organization's time to contribute to the WordPress open source project! Please confirm this email address in order to publish your pledge:" . "\n\n" .
-
+ $message = sprintf(
+ "Thanks for pledging your organization's time to contribute to the WordPress open source project! Please confirm this email address in order to publish your pledge:\n\n%s",
Email\get_authentication_url( $pledge_id, 'confirm_pledge_email', $action_page_id )
- ;
+ );
return Email\send_email(
$pledge->{'5ftf_org-pledge-email'},
@@ -233,12 +235,12 @@ function filter_query( $query ) {
$hours_count_key = META_PREFIX . 'pledge-total-hours';
// Set up meta queries to include the "valid pledge" check, added to both search and pledge archive requests.
- $meta_queries = (array) $query->get( 'meta_query' );
+ $meta_queries = (array) $query->get( 'meta_query' );
$meta_queries[] = array(
- 'key' => $contributor_count_key,
- 'value' => 0,
+ 'key' => $contributor_count_key,
+ 'value' => 0,
'compare' => '>',
- 'type' => 'NUMERIC',
+ 'type' => 'NUMERIC',
);
// Searching is restricted to pledges with contributors only.
@@ -271,6 +273,7 @@ function filter_query( $query ) {
}
}
- // todo remove this when `rand` pagination fixed, see https://github.com/WordPress/five-for-the-future/issues/70#issuecomment-549066883
+ // todo remove this when `rand` pagination fixed
+ // see https://github.com/WordPress/five-for-the-future/issues/70#issuecomment-549066883.
$query->set( 'posts_per_page', 100 );
}
diff --git a/plugins/wporg-5ftf/tests/test-email.php b/plugins/wporg-5ftf/tests/test-email.php
index ba2fc51..eb18051 100644
--- a/plugins/wporg-5ftf/tests/test-email.php
+++ b/plugins/wporg-5ftf/tests/test-email.php
@@ -7,6 +7,7 @@ use const WordPressDotOrg\FiveForTheFuture\Pledge\CPT_ID as PLEDGE_POST_TYPE;
defined( 'WPINC' ) || die();
class Test_Email extends WP_UnitTestCase {
+ // phpcs:ignore PSR2.Classes.PropertyDeclaration.Multiple
protected static $valid_pledge, $valid_action, $valid_action_page, $valid_action_url, $valid_token;
/**
@@ -29,8 +30,7 @@ class Test_Email extends WP_UnitTestCase {
self::$valid_pledge = get_post( $valid_pledge_id );
-
- $valid_action_page_id = self::factory()->post->create( $valid_action_page_params );
+ $valid_action_page_id = self::factory()->post->create( $valid_action_page_params );
self::$valid_action_page = get_post( $valid_action_page_id );
self::$valid_action = 'confirm_pledge_email';
@@ -44,7 +44,7 @@ class Test_Email extends WP_UnitTestCase {
/**
* Verify whether or not the fixtures were setup correctly.
*
- * @return bool
+ * @return void
*/
protected static function verify_before_class_fixtures() {
self::assertSame( 'object', gettype( self::$valid_action_page ) );
@@ -85,7 +85,7 @@ class Test_Email extends WP_UnitTestCase {
$this->assertTrue( $verified );
// todo test that `view` and `update` contexts work as well, when those are added
- // maybe need to test some failures for that too
+ // maybe need to test some failures for that too.
}
/**
@@ -118,11 +118,11 @@ class Test_Email extends WP_UnitTestCase {
'wrong-data-type' => array( 'this string is not an array' ),
'wrong-array-items' => array( 'this' => "doesn't have `value` and `expiration` items" ),
- 'invalid-value' => array(
+ 'invalid-value' => array(
array(
'value' => 'Valid tokens will never contain special characters like !@#$%^&*()',
'expiration' => time() + HOUR_IN_SECONDS,
- )
+ ),
),
);
}
@@ -167,8 +167,8 @@ class Test_Email extends WP_UnitTestCase {
*/
public function test_valid_token_rejected_for_other_actions() {
// Setup another valid token for the other action.
- $other_valid_action = 'confirm_contributor_participation';
- // todo update this when the action for that step is created, so that they match and show that valid actions
+ $other_valid_action = 'confirm_contributor_participation';
+ // todo update this when the action for that step is created, so that they match and show that valid actions.
$other_valid_action_url = get_authentication_url( self::$valid_pledge->ID, $other_valid_action, self::$valid_action_page->ID );
// Intentionally mismatch the token and action.
diff --git a/plugins/wporg-5ftf/views/form-pledge-confirm-email.php b/plugins/wporg-5ftf/views/form-pledge-confirm-email.php
index a603687..8163539 100755
--- a/plugins/wporg-5ftf/views/form-pledge-confirm-email.php
+++ b/plugins/wporg-5ftf/views/form-pledge-confirm-email.php
@@ -18,7 +18,7 @@ use WP_Post;
the directory once one contributor confirms their participation.", 'wporg' ) ),
- esc_url( $directory_url )
+ esc_url( $directory_url )
);
?>
- Your confirmation link has expired, please obtain a new one:
- +