Skip to content

Commit ee0d0f7

Browse files
refactor: update translation strings
1 parent be0a9bd commit ee0d0f7

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

assets/apps/dashboard/src/Components/Content/AvailableModule.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* global neveDash */
2-
import { __ } from '@wordpress/i18n';
2+
import { __, sprintf } from '@wordpress/i18n';
33
import {
4-
NEVE_AVAIABLE_MODULES_ICON_MAP,
4+
NEVE_AVAILABLE_MODULES_ICON_MAP,
55
NEVE_STORE,
66
} from '../../utils/constants';
77
import { ArrowRight, LoaderCircle, LucideSettings } from 'lucide-react';
@@ -42,8 +42,10 @@ const ModuleToggle = ({
4242
const { api } = neveDash;
4343
const { title } = moduleData;
4444
const toastMessage = {
45-
installing: __('Installing Orbix Fox Plugin', 'neve'),
46-
activating: __('Activating Orbix Fox Plugin', 'neve'),
45+
//translators: %s - Plugin name
46+
installing: sprintf(__('Installing %s', 'neve'), 'Orbit Fox Plugin'),
47+
//translators: %s - Plugin name
48+
activating: sprintf(__('Activating %s', 'neve'), 'Orbit Fox Plugin'),
4749
};
4850

4951
const handleToggle = async (value) => {
@@ -117,7 +119,7 @@ const AvailableModuleCard = ({
117119
setIsInstalled,
118120
}) => {
119121
const { title, description } = moduleData;
120-
const CardIcon = NEVE_AVAIABLE_MODULES_ICON_MAP[slug] || LucideSettings;
122+
const CardIcon = NEVE_AVAILABLE_MODULES_ICON_MAP[slug] || LucideSettings;
121123

122124
return (
123125
<Card
@@ -152,7 +154,7 @@ const AvailableModuleCard = ({
152154
className="flex mt-2 text-blue-600 gap-2 align-middle"
153155
href="admin.php?page=obfx_companion"
154156
>
155-
{__('Go to Settings to Edit')}
157+
{__('Go to Settings to Edit', 'neve')}
156158
<ArrowRight size={18} />
157159
</a>
158160
)}

assets/apps/dashboard/src/utils/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const NEVE_PLUGIN_ICON_MAP = {
7171
// 'sparks'
7272
};
7373

74-
export const NEVE_AVAIABLE_MODULES_ICON_MAP = {
74+
export const NEVE_AVAILABLE_MODULES_ICON_MAP = {
7575
'login-customizer': LucideLock,
7676
'custom-fonts': LucideType,
7777
'policy-notice': LucideShield,

inc/admin/dashboard/main.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ private function get_localization() {
367367
'api' => esc_url( rest_url( '/nv/v1/dashboard/' ) ),
368368
'availableModules' => $this->get_available_modules(),
369369
'orbitFox' => array(
370-
'isInstalled' => file_exists( ABSPATH . 'wp-content/plugins/themeisle-companion/themeisle-companion.php' ),
370+
'isInstalled' => file_exists( WP_PLUGIN_DIR . '/themeisle-companion/themeisle-companion.php' ),
371371
'isActive' => class_exists( 'Orbit_Fox' ),
372372
'activationUrl' => $this->plugin_helper->get_plugin_action_link( 'themeisle-companion' ),
373373
'data' => class_exists( 'Orbit_Fox' ) ? get_option( 'obfx_data' ) : array(),

inc/core/admin.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,19 @@ public function register_rest_routes() {
329329
'methods' => \WP_REST_Server::EDITABLE,
330330
'callback' => [ $this, 'activate_module' ],
331331
'permission_callback' => function() {
332-
return ( current_user_can( 'manage_options' ) );
332+
return current_user_can( 'manage_options' );
333333
},
334+
'args' => array(
335+
'slug' => array(
336+
'required' => true,
337+
'sanitize_callback' => 'sanitize_key',
338+
),
339+
'value' => array(
340+
'required' => true,
341+
'sanitize_callback' => 'rest_sanitize_boolean',
342+
'validate_callback' => 'rest_validate_request_arg',
343+
),
344+
),
334345
]
335346
);
336347
}
@@ -365,7 +376,7 @@ public function activate_plugin( $request ) {
365376
$slug = $request->get_param( 'slug' );
366377

367378
if ( empty( $slug ) ) {
368-
wp_send_json_error( array( 'message' => __( 'Missing plugin slug.', 'neve' ) ) );
379+
return;
369380
}
370381

371382
$plugin_helper = new Plugin_Helper();
@@ -412,7 +423,7 @@ public function activate_plugin( $request ) {
412423
global $wp_filesystem;
413424

414425
$status = [
415-
'message' => __( 'Unable to connect to the filesystem. Please confirm your credentials.', 'neve' ),
426+
'message' => __( 'Invalid plugin information.', 'neve' ),
416427
];
417428

418429
if ( $wp_filesystem instanceof \WP_Filesystem_Base && $wp_filesystem->errors->has_errors() ) {
@@ -448,6 +459,11 @@ public function activate_module( $request ) {
448459

449460
$settings = new \Orbit_Fox_Global_Settings();
450461
$modules = $settings::$instance->module_objects;
462+
463+
if ( ! isset( $modules[ $module_slug ] ) ) {
464+
wp_send_json_error( __( 'Invalid module slug.', 'neve' ) );
465+
}
466+
451467
$response = $modules[ $module_slug ]->set_status( 'active', $module_value );
452468

453469
wp_send_json_success( __( 'Module status changed.', 'neve' ) );

0 commit comments

Comments
 (0)