Skip to content

Commit 938ba4d

Browse files
committed
extract other brandnames out from being hardcoded into strings
1 parent 1807f90 commit 938ba4d

File tree

34 files changed

+171
-136
lines changed

34 files changed

+171
-136
lines changed

plugin-spec/16_labels.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,11 @@
1212
"icon_url_16x16": "pluginlogo_16x16.png",
1313
"icon_url_16x16_grey": "pluginlogo_16x16_grey.png",
1414
"icon_url_32x32": "pluginlogo_32x32.png",
15-
"icon_url_128x128": "pluginlogo_128x128.png"
15+
"icon_url_128x128": "pluginlogo_128x128.png",
16+
"brand_names": {
17+
"silentcaptcha": "silentCAPTCHA",
18+
"shieldnet": "ShieldNET",
19+
"shieldbackups": "ShieldBACKUPS",
20+
"suresend": "SureSend"
21+
}
1622
}

src/lib/src/ActionRouter/Actions/IpAnalyseAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected function exec() {
101101
$success = ( new BotSignalsRecord() )
102102
->setIP( $ip )
103103
->delete();
104-
$msg = $success ? __( 'IP silentCAPTCHA Score Reset.', 'wp-simple-firewall' )
104+
$msg = $success ? sprintf( __( 'IP %s Score Reset.', 'wp-simple-firewall' ), self::con()->labels->getBrandName( 'silentcaptcha' ) )
105105
: __( "IP NotBot Score couldn't be reset at this time.", 'wp-simple-firewall' );
106106
break;
107107

src/lib/src/ActionRouter/Actions/Render/Components/IpAnalyse/General.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected function getRenderData() :array {
7575
'is_blocked' => __( 'IP Blocked', 'wp-simple-firewall' ),
7676
'is_bypass' => __( 'Bypass IP', 'wp-simple-firewall' ),
7777
'ip_reputation' => __( 'IP Reputation Score', 'wp-simple-firewall' ),
78-
'snapi_ip_reputation' => __( 'ShieldNET IP Reputation Score', 'wp-simple-firewall' ),
78+
'snapi_ip_reputation' => sprintf( __( '%s IP Reputation Score', 'wp-simple-firewall' ), self::con()->labels->getBrandName( 'shieldnet' ) ),
7979
'block_type' => $ruleStatus->isBlocked() ? Handler::GetTypeName( $ruleStatus->getBlockType() ) : ''
8080
],
8181

src/lib/src/ActionRouter/Actions/Render/Components/Merlin/MerlinStep.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ protected function checkAvailableData() {
2525

2626
protected function getRenderData() :array {
2727
$pluginName = self::con()->labels->Name;
28+
$silentCaptcha = self::con()->labels->getBrandName( 'silentcaptcha' );
2829
$stepSlug = $this->action_data[ 'vars' ][ 'step_slug' ] ?? '';
2930
$strings = [];
3031

@@ -83,8 +84,13 @@ protected function getRenderData() :array {
8384
}
8485

8586
if ( $stepSlug === 'comment_spam' ) {
86-
/* translators: %1$s: Shield Security name, %2$s: silentCAPTCHA */
87-
$strings[ 'comment_spam_text' ] = sprintf( __( '%1$s blocks all automated bot SPAM using our %2$s, our exclusive, invisible, GDPR-compliant bot-detection technology.', 'wp-simple-firewall' ), $pluginName, 'silentCAPTCHA' );
87+
/* translators: %1$s: Shield Security name, %2$s: bot detection technology name */
88+
$strings[ 'comment_spam_text' ] = sprintf( __( '%1$s blocks all automated bot SPAM using our %2$s, our exclusive, invisible, GDPR-compliant bot-detection technology.', 'wp-simple-firewall' ), $pluginName, $silentCaptcha );
89+
$strings[ 'silentcaptcha_detect_bots' ] = sprintf( __( '%s will detect bots that attempt to post comment SPAM to your site, without challenging your legitimate visitors.', 'wp-simple-firewall' ), $silentCaptcha );
90+
}
91+
92+
if ( $stepSlug === 'login_protection' ) {
93+
$strings[ 'silentcaptcha_detect_login_bots' ] = sprintf( __( '%s will detect bots that attempt to login to your site, without challenging your legitimate users.', 'wp-simple-firewall' ), $silentCaptcha );
8894
}
8995

9096
$videoId = $this->action_data[ 'vars' ][ 'video_id' ] ?? '';

src/lib/src/ActionRouter/Actions/Render/PluginAdminPages/PageLicense.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private function getProFeatureStrings() :array {
158158
'href' => 'https://clk.shldscrty.com/km'
159159
],
160160
[
161-
'title' => sprintf( '%s: %s', __( 'Intelligence From The Collective', 'wp-simple-firewall' ), 'ShieldNET' ),
161+
'title' => sprintf( '%s: %s', __( 'Intelligence From The Collective', 'wp-simple-firewall' ), $con->labels->getBrandName( 'shieldnet' ) ),
162162
'lines' => [
163163
sprintf( __( 'Take advantage of the intelligence gathered throughout the entire %s network to better protect your WordPress sites', 'wp-simple-firewall' ), $con->labels->Name ),
164164
],

src/lib/src/Controller/Config/Labels.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*/
2626
class Labels extends DynPropertiesClass {
2727

28+
private array $brandNames = [];
29+
2830
public function __get( string $key ) {
2931
$value = parent::__get( $key );
3032

@@ -38,4 +40,13 @@ public function __get( string $key ) {
3840

3941
return $value;
4042
}
43+
44+
public function getBrandName( string $key ) :string {
45+
return $this->brandNames[ \strtolower( $key ) ] ?? $key;
46+
}
47+
48+
public function setBrandNames( array $names ) :self {
49+
$this->brandNames = \array_change_key_case( $names, \CASE_LOWER );
50+
return $this;
51+
}
4152
}

src/lib/src/Controller/Config/Modules/StringsOptions.php

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function getFor( string $key ) :array {
2121
$caps = $con->caps;
2222
$opts = $con->comps->opts_lookup;
2323
$pluginName = $con->labels->Name;
24+
$silentCaptcha = $con->labels->getBrandName( 'silentcaptcha' );
2425
$modStrings = new StringsModules();
2526

2627
switch ( $key ) {
@@ -109,10 +110,10 @@ public function getFor( string $key ) :array {
109110
break;
110111
case 'enable_antibot_comments':
111112
$name = __( 'Block Bot SPAM', 'wp-simple-firewall' );
112-
$summary = __( 'Use silentCAPTCHA To Block Bot Comment SPAM', 'wp-simple-firewall' );
113+
$summary = sprintf( __( 'Use %s To Block Bot Comment SPAM', 'wp-simple-firewall' ), $silentCaptcha );
113114
$desc = [
114-
sprintf( __( 'Block 99.9%% of all WordPress comment SPAM using silentCAPTCHA.', 'wp-simple-firewall' ), $pluginName ),
115-
sprintf( __( "silentCAPTCHA is %s's exclusive bot-detection technology that removes the needs for visible CAPTCHAs and similar visitor challenges.", 'wp-simple-firewall' ), $pluginName ),
115+
sprintf( __( 'Block 99.9%% of all WordPress comment SPAM using %s.', 'wp-simple-firewall' ), $silentCaptcha ),
116+
sprintf( __( "%s is %s's exclusive bot-detection technology that removes the needs for visible CAPTCHAs and similar visitor challenges.", 'wp-simple-firewall' ), $silentCaptcha, $pluginName ),
116117
];
117118
break;
118119
case 'enable_comments_human_spam_filter':
@@ -474,23 +475,23 @@ public function getFor( string $key ) :array {
474475

475476
break;
476477
case 'silentcaptcha_complexity':
477-
$name = __( 'silentCAPTCHA Complexity', 'wp-simple-firewall' );
478-
$summary = __( 'Adjust silentCAPTCHA Challenge Complexity', 'wp-simple-firewall' );
478+
$name = sprintf( __( '%s Complexity', 'wp-simple-firewall' ), $silentCaptcha );
479+
$summary = sprintf( __( 'Adjust %s Challenge Complexity', 'wp-simple-firewall' ), $silentCaptcha );
479480
$desc = [
480-
sprintf( __( "%s's silentCAPTCHA system uses ALTCHA, that challenges bots to perform complex work.", 'wp-simple-firewall' ), $pluginName ),
481+
sprintf( __( "%s's %s system uses ALTCHA, that challenges bots to perform complex work.", 'wp-simple-firewall' ), $pluginName, $silentCaptcha ),
481482
__( "This complex work is compute intensive and inflicts a processing cost on bots. Bots typically won't do the work, and this helps to discriminate between bots and humans.", 'wp-simple-firewall' ),
482483
__( "More complexity in the challenge is a bigger cost to bots, but may present a burden for legitimate visitors that use slower devices.", 'wp-simple-firewall' ),
483484
__( "Adaptive complexity will try to present the most suitable challenge depending on the type of visitor.", 'wp-simple-firewall' ),
484485
];
485486
break;
486487
case 'antibot_minimum':
487-
$name = __( 'silentCAPTCHA Bot Minimum Score', 'wp-simple-firewall' );
488-
$summary = __( 'silentCAPTCHA Bot Score (Percentage)', 'wp-simple-firewall' );
488+
$name = sprintf( __( '%s Bot Minimum Score', 'wp-simple-firewall' ), $silentCaptcha );
489+
$summary = sprintf( __( '%s Bot Score (Percentage)', 'wp-simple-firewall' ), $silentCaptcha );
489490
$desc = [
490491
__( "Every IP address accessing your site gets its own unique visitor score - the higher the score, the better the visitor i.e. the more likely it's human.", 'wp-simple-firewall' ),
491492
__( "A score of '100' would mean it's almost certainly good, a score of '0' means it's highly likely to be a bad bot.", 'wp-simple-firewall' ),
492493
__( 'When a bot tries to login, or post a comment, we test its visitor score.', 'wp-simple-firewall' )
493-
.' '.__( 'If the visitor score fails to meet your Minimum silentCAPTCHA Score, we may prevent the request (such as login, WP comment etc.). If its higher, we allow it.', 'wp-simple-firewall' ),
494+
.' '.sprintf( __( 'If the visitor score fails to meet your Minimum %s Score, we may prevent the request (such as login, WP comment etc.). If its higher, we allow it.', 'wp-simple-firewall' ), $silentCaptcha ),
494495
__( "This means: choose a higher minimum score to be more strict and capture more bots (but potentially block someone that appears to be a bot, but isn't).", 'wp-simple-firewall' )
495496
.' '.__( "Or choose a lower minimum score to perhaps allow through more bots (but reduce the chances of accidentally blocking legitimate visitors).", 'wp-simple-firewall' ),
496497
];
@@ -673,14 +674,15 @@ public function getFor( string $key ) :array {
673674
}
674675
break;
675676
case 'suresend_emails':
676-
$name = sprintf( __( '%s Emails', 'wp-simple-firewall' ), 'SureSend' );
677-
/* translators: %1$s: security plugin name, %2$s: SureSend brand name */
678-
$summary = sprintf( __( 'Select Which %1$s Emails Should Be Sent Using %2$s', 'wp-simple-firewall' ), $pluginName, 'SureSend' );
677+
$sureSend = $con->labels->getBrandName( 'suresend' );
678+
$name = sprintf( __( '%s Emails', 'wp-simple-firewall' ), $sureSend );
679+
/* translators: %1$s: security plugin name, %2$s: email service brand name */
680+
$summary = sprintf( __( 'Select Which %1$s Emails Should Be Sent Using %2$s', 'wp-simple-firewall' ), $pluginName, $sureSend );
679681
$desc = [
680-
/* translators: %1$s: SureSend brand name, %2$s: security plugin name */
681-
sprintf( __( '%1$s is a dedicated email delivery service from %2$s.', 'wp-simple-firewall' ), 'SureSend', $pluginName ),
682+
/* translators: %1$s: email service brand name, %2$s: security plugin name */
683+
sprintf( __( '%1$s is a dedicated email delivery service from %2$s.', 'wp-simple-firewall' ), $sureSend, $pluginName ),
682684
__( 'The purpose is to improve WordPress email reliability for critical emails.', 'wp-simple-firewall' ),
683-
sprintf( __( "If you're not using a dedicated email service provider to send WordPress emails, you should enable %s for these important emails.", 'wp-simple-firewall' ), 'SureSend' ),
685+
sprintf( __( "If you're not using a dedicated email service provider to send WordPress emails, you should enable %s for these important emails.", 'wp-simple-firewall' ), $sureSend ),
684686
__( "This isn't a replacement for a dedicated email service.", 'wp-simple-firewall' ),
685687
__( "Please read the information and blog links below to fully understand this service and its limitations.", 'wp-simple-firewall' ),
686688
];
@@ -1503,11 +1505,12 @@ public function getFor( string $key ) :array {
15031505
];
15041506
break;
15051507
case 'reg_email_validate':
1508+
$shieldNet = $con->labels->getBrandName( 'shieldnet' );
15061509
$name = __( 'Validate Email Addresses', 'wp-simple-firewall' );
15071510
$summary = __( 'Validate Email Addresses When User Attempts To Register', 'wp-simple-firewall' );
15081511
$desc = [
15091512
__( 'Validate Email Addresses When User Attempts To Register.', 'wp-simple-firewall' ),
1510-
__( 'To validate an email your site sends a request to the ShieldNET API and may cause a small delay during the user registration request.', 'wp-simple-firewall' ),
1513+
sprintf( __( 'To validate an email your site sends a request to the %s API and may cause a small delay during the user registration request.', 'wp-simple-firewall' ), $shieldNet ),
15111514
];
15121515
break;
15131516
case 'email_checks':

0 commit comments

Comments
 (0)