Skip to content

Commit

Permalink
Update code following PHPCS.
Browse files Browse the repository at this point in the history
  • Loading branch information
ve3 committed Nov 23, 2023
1 parent 79197b2 commit d600c5d
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 27 deletions.
31 changes: 21 additions & 10 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<!-- What to scan -->
<file>.</file>
<exclude-pattern>/.dev-notes/</exclude-pattern>
<exclude-pattern>/blocks/</exclude-pattern>
<exclude-pattern>/tests/</exclude-pattern>
<exclude-pattern>/vendor/</exclude-pattern>
<exclude-pattern>/node_modules/</exclude-pattern>
Expand Down Expand Up @@ -34,48 +35,60 @@
<!-- exclude name="WordPress.VIP"/ --><!-- removed as error Referenced sniff "WordPress.VIP" does not exist and can't find the fix or additional installation anywhere. -->
<exclude name="Generic.Classes.OpeningBraceSameLine.BraceOnNewLine"></exclude>
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedIf"></exclude>
<exclude name="Generic.Files.EndFileNewline.NotFound"></exclude>
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.Found"></exclude>
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed"></exclude>
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning"></exclude>
<exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine"></exclude>
<exclude name="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceAfterOpen"></exclude>
<exclude name="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceBeforeClose"></exclude>
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed"></exclude>
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect"></exclude>
<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact"></exclude>
<exclude name="NormalizedArrays.Arrays.ArrayBraceSpacing.SpaceAfterArrayOpenerSingleLine"></exclude>
<exclude name="NormalizedArrays.Arrays.ArrayBraceSpacing.SpaceBeforeArrayCloserSingleLine"></exclude>
<exclude name="NormalizedArrays.Arrays.ArrayBraceSpacing.NoSpaceAfterArrayOpener"></exclude>
<exclude name="NormalizedArrays.Arrays.ArrayBraceSpacing.NoSpaceBeforeArrayCloser"></exclude>
<exclude name="NormalizedArrays.Arrays.CommaAfterLast.NoComma"></exclude>
<exclude name="NormalizedArrays.Arrays.CommaAfterLast.NoSpaceAfterComma"></exclude>
<exclude name="PEAR"></exclude>
<exclude name="PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.Changed"></exclude>
<exclude name="PHPCompatibility.Variables.ForbiddenGlobalVariableVariable.NonBareVariableFound"></exclude>
<exclude name="PSR2.Classes.ClassDeclaration.CloseBraceAfterBody"></exclude>
<exclude name="PSR2.Files.EndFileNewline.NotFound"></exclude>
<exclude name="PSR2.Files.EndFileNewline.NoneFound"></exclude>
<exclude name="PSR2.Files.EndFileNewline.TooMany"></exclude>
<exclude name="PSR2.Namespaces.NamespaceDeclaration.BlankLineAfter"></exclude>
<exclude name="Squiz.Commenting.ClassComment.Missing"></exclude>
<exclude name="Squiz.Commenting.ClosingDeclarationComment.Incorrect"></exclude>
<exclude name="Squiz.Commenting.FileComment.Missing"></exclude>
<exclude name="Squiz.Commenting.FileComment.SpacingAfterComment"></exclude>
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop"></exclude>
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"></exclude>
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop"></exclude>
<exclude name="Squiz.Commenting.FunctionComment.SpacingAfterParamType"></exclude>
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar"></exclude>
<exclude name="Squiz.Commenting.VariableComment.Missing"></exclude>
<exclude name="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace"></exclude>
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterOpen"></exclude>
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingBeforeClose"></exclude>
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction"></exclude>
<exclude name="Squiz.PHP.CommentedOutCode.Found"></exclude>
<exclude name="Squiz.PHP.EmbeddedPhp.ContentAfterEnd"></exclude>
<exclude name="Squiz.PHP.EmbeddedPhp.ContentBeforeOpen"></exclude>
<exclude name="Squiz.PHP.NonExecutableCode.ReturnNotRequired"></exclude>
<exclude name="Squiz.Strings.ConcatenationSpacing.PaddingFound"></exclude>
<exclude name="Squiz.WhiteSpace.SemicolonSpacing.Incorrect"></exclude>
<exclude name="Squiz.WhiteSpace.SuperfluousWhitespace.EndLine"></exclude>
<exclude name="Universal.Arrays.DisallowShortArraySyntax.Found"></exclude>
<exclude name="Universal.ControlStructures.DisallowLonelyIf.Found"></exclude>
<exclude name="WordPress.Arrays.ArrayDeclarationSpacing.NoSpaceAfterArrayOpener"></exclude>
<exclude name="WordPress.Arrays.ArrayDeclarationSpacing.NoSpaceBeforeArrayCloser"></exclude>
<exclude name="WordPress.Arrays.ArrayKeySpacingRestrictions.NoSpacesAroundArrayKeys"></exclude>
<exclude name="WordPress.Arrays.CommaAfterArrayItem.NoComma"></exclude>
<exclude name="WordPress.Arrays.CommaAfterArrayItem.NoSpaceAfterComma"></exclude>
<exclude name="WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned"></exclude>
<exclude name="WordPress.Files.FileName.InvalidClassFileName"></exclude>
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"></exclude>
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound"></exclude>
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound"></exclude>
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedNamespaceFound"></exclude>
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound"></exclude>
<exclude name="WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid"></exclude>
<exclude name="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid"></exclude>
<exclude name="WordPress.NamingConventions.ValidVariableName.PropertyNotSnakeCase"></exclude>
<exclude name="WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase"></exclude>
Expand All @@ -93,13 +106,11 @@
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing"></exclude>
<exclude name="WordPress.WhiteSpace.OperatorSpacing.NoSpaceBefore"></exclude>
<exclude name="WordPress.WhiteSpace.OperatorSpacing.NoSpaceAfter"></exclude>
<exclude name="WordPress.WP.AlternativeFunctions.curl_curl_close"></exclude>
<exclude name="WordPress.WP.AlternativeFunctions.curl_curl_exec"></exclude>
<exclude name="WordPress.WP.AlternativeFunctions.curl_curl_init"></exclude>
<exclude name="WordPress.WP.AlternativeFunctions.curl_curl_setopt"></exclude>
<exclude name="WordPress.WP.AlternativeFunctions.curl_curl_exec"></exclude>
<exclude name="WordPress.WP.AlternativeFunctions.curl_curl_close"></exclude>
<exclude name="WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents"></exclude>
<exclude name="WordPress.WP.AlternativeFunctions.json_encode_json_encode"></exclude><!-- The function `wp_json_encode()` does not support PHP less than 5.6. -->
<exclude name="WordPress.WP.AlternativeFunctions.strip_tags_strip_tags"></exclude>
<exclude name="WordPress.WP.EnqueuedResourceParameters.MissingVersion"></exclude>
<exclude name="WordPress.WP.EnqueuedResourceParameters.NoExplicitVersion"></exclude>
<exclude name="WordPress.WP.I18n.MissingArgDomain"></exclude>
Expand Down
1 change: 0 additions & 1 deletion App/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace RundizOauth\App;

use RundizOauth\App\Controllers as Controllers;

if (!class_exists('\\RundizOauth\\App\\App')) {
class App
Expand Down
6 changes: 3 additions & 3 deletions App/Controllers/Front/HookLoginPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public function loadProfile()
$user = get_user_by('ID', $user_id);
wp_update_user([
'ID' => $user->ID,
'user_email' => $email
'user_email' => $email,
]);
do_action('rundiz_oauth_changeemail_success', $user->ID, $email);
unset($email, $user, $user_id);
Expand All @@ -226,15 +226,15 @@ public function loadProfile()
'rundiz-oauth-error',
maybe_serialize([
'class' => 'notice-success',
'message' => __('Your email has been changed.', 'okv-oauth')
'message' => __('Your email has been changed.', 'okv-oauth'),
])
);
} elseif (is_wp_error($email)) {
set_transient(
'rundiz-oauth-error',
maybe_serialize([
'class' => 'notice-error',
'message' => $email->get_error_message()
'message' => $email->get_error_message(),
])
);
}
Expand Down
2 changes: 1 addition & 1 deletion App/Libraries/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function loadTemplate($view_name, array $data = [])
// if not found the template file in plugin itself.
// throw the error to notice the developers.
/* translators: %s: Template path. */
throw new \Exception(sprintf(__('The template file was not found. (%s)', 'okv-oauth'), $template_path));
throw new \Exception(esc_html(sprintf(__('The template file was not found. (%s)', 'okv-oauth'), $template_path)));
}
}

Expand Down
1 change: 1 addition & 0 deletions App/Libraries/MyOauth/Facebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Facebook login
*
* @package rundiz-oauth
* // phpcs:ignoreFile -- no longer supported.
*/


Expand Down
4 changes: 2 additions & 2 deletions App/Libraries/MyOauth/Google.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public function wpLoginWithGoogle($user)
// found user by this email.
// keep $user because we will use it as return value.
// set token cookie.
setcookie('rundiz_oauth_google_tokens', json_encode([$access_token, $id_token]), time()+(2 * DAY_IN_SECONDS), '/', defined(COOKIE_DOMAIN) ? COOKIE_DOMAIN : '');
setcookie('rundiz_oauth_google_tokens', wp_json_encode([$access_token, $id_token]), time()+(2 * DAY_IN_SECONDS), '/', defined(COOKIE_DOMAIN) ? COOKIE_DOMAIN : '');
// complete.
} else {
// user was not found.
Expand Down Expand Up @@ -349,7 +349,7 @@ public function wpRegisterWithGoogle()
// got user profile and email was verified.
if (email_exists($result['data']->email) === false && username_exists($result['data']->email) === false) {
// if user that is using this email is NOT already exists (yay).
setcookie('rundiz_oauth_google_tokens', json_encode([$access_token, $id_token]), time()+(2 * DAY_IN_SECONDS), '/', defined(COOKIE_DOMAIN) ? COOKIE_DOMAIN : '');
setcookie('rundiz_oauth_google_tokens', wp_json_encode([$access_token, $id_token]), time()+(2 * DAY_IN_SECONDS), '/', defined(COOKIE_DOMAIN) ? COOKIE_DOMAIN : '');
$output['access_token'] = $access_token;
$output['id_token'] = $id_token;
$output['email'] = $result['data']->email;
Expand Down
2 changes: 1 addition & 1 deletion App/Libraries/RundizOauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function loggedinRedirect($user)
$redirect_to = admin_url();
}

$requested_redirect_to = (isset($_SESSION['okv-oauth_redirect_to']) ? $_SESSION['okv-oauth_redirect_to'] : '');
$requested_redirect_to = (isset($_SESSION['okv-oauth_redirect_to']) ? sanitize_url($_SESSION['okv-oauth_redirect_to']) : '');
$redirect_to = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user);
unset($requested_redirect_to);

Expand Down
10 changes: 5 additions & 5 deletions App/config/settings_rdoauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@


return [
'tab_style' => 'vertical',// vertical or horizontal
'tab_style' => 'vertical', // vertical or horizontal
'setting_tabs' => [
[
'icon' => 'fa fa-sign-in fa-fw',
Expand Down Expand Up @@ -181,7 +181,7 @@
'type' => 'select',
],
],
],// end login settings tab.
], // end login settings tab.
[
'icon' => 'fa fa-google fa-fw',
'title' => __('Google login', 'okv-oauth'),
Expand Down Expand Up @@ -251,7 +251,7 @@
'type' => 'html_full',
],
],
],// end google login settings tab.
], // end google login settings tab.
[
'icon' => 'fa fa-facebook fa-fw',
'title' => __('Facebook login', 'okv-oauth'),
Expand Down Expand Up @@ -287,7 +287,7 @@
'type' => 'html_full',
],
],
],// end facebook login settings tab.
], // end facebook login settings tab.
[
'icon' => 'fa fa-paint-brush fa-fw',
'title' => __('Design pages', 'okv-oauth'),
Expand All @@ -298,6 +298,6 @@
'type' => 'html_full',
],
],
],// end design help tab.
], // end design help tab.
],
];
6 changes: 4 additions & 2 deletions blocks-src/loginlinks/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
*/


$currentUrl = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$currentUrl = ( is_ssl() ? 'https://' : 'http://' ) .
(isset($_SERVER['HTTP_HOST']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST'])) : '') .
(isset($_SERVER['REQUEST_URI']) ? sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI'])) : '');
$isUserLoggedIn = is_user_logged_in();
$classes = ($isUserLoggedIn ? 'logged-in' : 'logged-out');
$contents = '';

if (!$isUserLoggedIn && get_option('users_can_register')) {
$contents .= '<li><a href="' . esc_url( wp_registration_url() ) . '">' . __( 'Register' ) . '</a></li>' . PHP_EOL;
} elseif ($isUserLoggedIn && isset($attributes) && is_array($attributes) && array_key_exists('displayLinkToAdmin', $attributes) && $attributes['displayLinkToAdmin'] === true) {
} elseif ($isUserLoggedIn && isset($attributes) && is_array($attributes) && array_key_exists('displayLinkToAdmin', $attributes) && true === $attributes['displayLinkToAdmin']) {
$contents .= '<li><a href="' . admin_url() . '">' . __( 'Site Admin' ) . '</a></li>' . PHP_EOL;
}
unset($isUserLoggedIn);
Expand Down
6 changes: 4 additions & 2 deletions blocks/loginlinks/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
*/


$currentUrl = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$currentUrl = ( is_ssl() ? 'https://' : 'http://' ) .
(isset($_SERVER['HTTP_HOST']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST'])) : '') .
(isset($_SERVER['REQUEST_URI']) ? sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI'])) : '');
$isUserLoggedIn = is_user_logged_in();
$classes = ($isUserLoggedIn ? 'logged-in' : 'logged-out');
$contents = '';

if (!$isUserLoggedIn && get_option('users_can_register')) {
$contents .= '<li><a href="' . esc_url( wp_registration_url() ) . '">' . __( 'Register' ) . '</a></li>' . PHP_EOL;
} elseif ($isUserLoggedIn && isset($attributes) && is_array($attributes) && array_key_exists('displayLinkToAdmin', $attributes) && $attributes['displayLinkToAdmin'] === true) {
} elseif ($isUserLoggedIn && isset($attributes) && is_array($attributes) && array_key_exists('displayLinkToAdmin', $attributes) && true === $attributes['displayLinkToAdmin']) {
$contents .= '<li><a href="' . admin_url() . '">' . __( 'Site Admin' ) . '</a></li>' . PHP_EOL;
}
unset($isUserLoggedIn);
Expand Down

0 comments on commit d600c5d

Please sign in to comment.