Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: translate strings on various pages #1478

Merged
merged 4 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/WeDevs_Settings_API.php
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ function get_option( $option, $section, $default = '' ) {
function show_navigation() {
$html = '<h2 class="nav-tab-wrapper">';
$html .= '<div id="wpuf-search-section">
<input type="text" id="wpuf-settings-search" placeholder="Search in settings">
<input type="text" id="wpuf-settings-search" placeholder="'. esc_attr__( 'Search in settings', 'wp-user-frontend' ) .'">
<span class="dashicons dashicons-no-alt"></span>
</div>';
$count = count( $this->settings_sections );
Expand Down
3 changes: 1 addition & 2 deletions admin/html/form-settings-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@
'selected' => $default_category,
'taxonomy' => $tax->name,
];

$tax = '<tr class="wpuf_settings_taxonomy"> <th> Default '. $post_type_selected . ' '. $tax->name .'</th> <td>
$tax = '<tr class="wpuf_settings_taxonomy"> <th>' . __( 'Default ', 'wp-user-frontend' ) . $post_type_selected . ' '. $tax->name .'</th> <td>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using sprintf() for dynamic string translation.

The current implementation concatenates translated text with variables, which might not translate well in languages where the order of words is different. Consider using sprintf() to allow translators to control the placement of the variables within the translated string:

$tax = '<tr class="wpuf_settings_taxonomy"> <th>' . sprintf( __( 'Default %s %s', 'wp-user-frontend' ), $post_type_selected, $tax->name ) . '</th> <td>
<select multiple name="wpuf_settings[default_'.$tax->name.'][]">';

<select multiple name="wpuf_settings[default_'.$tax->name.'][]">';
$categories = get_terms( $args );

Expand Down
16 changes: 15 additions & 1 deletion includes/Admin/Admin_Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,21 @@ public function subs_meta_box() {
<th><?php esc_html_e( 'Expiration Message', 'wp-user-frontend' ); ?></th>
<td>
<textarea name="post_expiration_settings[post_expiration_message]" id="wpuf-post_expiration_message" cols="50" rows="5"><?php echo esc_attr( $post_expiration_message ); ?></textarea>
<p class="description"><strong><?php echo esc_html( __( 'You may use: {post_author} {post_url} {blogname} {post_title} {post_status}', 'wp-user-frontend' ) ); ?></strong></p>
<p class="description">
<strong>
<?php
printf(
// translators: %1$s: {post_author}, %2$s: {post_url}, %3$s: {blogname}, %4$s: {post_title}, %5$s: {post_status}
__( 'You may use: %1$s %2$s %3$s %4$s %5$s', 'wp-user-frontend' ),
'{post_author}',
'{post_url}',
'{blogname}',
'{post_title}',
'{post_status}'
)
?>
</strong>
</p>
</td>
</tr>

Expand Down
368 changes: 254 additions & 114 deletions includes/Admin/views/support.php

Large diffs are not rendered by default.

39 changes: 24 additions & 15 deletions includes/Ajax/Admin_Form_Builder_Ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ class Admin_Form_Builder_Ajax {
* @return void
*/
public function save_form() {
$post_data = wp_unslash($_POST);
$post_data = wp_unslash( $_POST );
if ( isset( $post_data['form_data'] ) ) {
parse_str( $post_data['form_data'], $form_data );
parse_str( $post_data['form_data'], $form_data );
} else {
wp_send_json_error( __( 'form data is missing', 'wp-user-frontend'));
wp_send_json_error( __( 'form data is missing', 'wp-user-frontend' ) );
}

if ( !wp_verify_nonce( $form_data['wpuf_form_builder_nonce'], 'wpuf_form_builder_save_form' ) ) {
if ( ! wp_verify_nonce( $form_data['wpuf_form_builder_nonce'], 'wpuf_form_builder_save_form' ) ) {
wp_send_json_error( __( 'Unauthorized operation', 'wp-user-frontend' ) );
}

Expand All @@ -50,7 +50,6 @@ public function save_form() {
$integrations = (array) json_decode( $post_data['integrations'] );
}


$form_fields = json_decode( $form_fields, true );
$notifications = json_decode( $notifications, true );

Expand All @@ -66,15 +65,20 @@ public function save_form() {

$form_fields = Admin_Form_Builder::save_form( $data );

wp_send_json_success( [ 'form_fields' => $form_fields, 'form_settings' => $settings ] );
wp_send_json_success(
[
'form_fields' => $form_fields,
'form_settings' => $settings,
]
);
}

public function wpuf_get_post_taxonomies() {
$post_data = wp_unslash($_POST);
$post_data = wp_unslash( $_POST );
$post_type = $post_data['post_type'];
$nonce = $post_data['wpuf_form_builder_setting_nonce'];

if ( isset( $nonce ) && !wp_verify_nonce( $post_data['wpuf_form_builder_setting_nonce'], 'form-builder-setting-nonce' ) ) {
if ( isset( $nonce ) && ! wp_verify_nonce( $post_data['wpuf_form_builder_setting_nonce'], 'form-builder-setting-nonce' ) ) {
wp_send_json_error( __( 'Unauthorized operation', 'wp-user-frontend' ) );
}

Expand All @@ -91,23 +95,28 @@ public function wpuf_get_post_taxonomies() {
foreach ( $post_taxonomies as $tax ) {
if ( $tax->hierarchical ) {
$args = [
'hide_empty' => false,
'hierarchical' => true,
'taxonomy' => $tax->name,
'hide_empty' => false,
'hierarchical' => true,
'taxonomy' => $tax->name,
];

$cat .= '<tr class="wpuf_settings_taxonomy"> <th> Default '. $post_type . ' '. $tax->name .'</th> <td>
<select multiple name="wpuf_settings[default_'.$tax->name.'][]">';
$cat .= '<tr class="wpuf_settings_taxonomy"> <th>' . __( 'Default ', 'wp-user-frontend' ) . $post_type . ' ' . $tax->name . '</th> <td>
<select multiple name="wpuf_settings[default_' . $tax->name . '][]">';
$categories = get_terms( $args );

foreach ( $categories as $category ) {
$cat .= '<option value="' . $category->term_id . '">' . $category->name . '</option>';
}

$cat .='</select></td>';
$cat .= '</select></td>';
}
}

wp_send_json_success( [ 'success' => 'true' , 'data' => $cat ] );
wp_send_json_success(
[
'success' => 'true',
'data' => $cat,
]
);
}
}
45 changes: 33 additions & 12 deletions includes/Free/Form_Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

namespace WeDevs\Wpuf\Free;

// @codingStandardsIgnoreStart
use WeDevs\Wpuf\Pro\Admin\FormBuilder\Template_Profile;

class Form_Element extends Pro_Prompt {
// @codingStandardsIgnoreEnd

public static function add_form_custom_buttons() {
$title = esc_attr( __( 'Click to add to the editor', 'wp-user-frontend' ) ); ?>
Expand Down Expand Up @@ -65,7 +63,16 @@
<?php esc_html_e( 'Enable Post Expiration', 'wp-user-frontend' ); ?>
</label>
</td>
<p class="description"><a target="_blank" href="https://wedevs.com/docs/wp-user-frontend-pro/posting-forms/using-post-expiration-wp-user-frontend/"><?php esc_html_e( 'Learn more about Automatic Post Expiration', 'wp-user-frontend' ); ?></a></p>
<p class="description">
<a target="_blank"
href="https://wedevs.com/docs/wp-user-frontend-pro/posting-forms/using-post-expiration-wp-user-frontend/">
<?php
esc_html_e(
'Learn more about Automatic Post Expiration', 'wp-user-frontend'
);
?>
</a>
</p>
</tr>
<tr class="wpuf_expiration_field">
<th><?php esc_html_e( 'Post Expiration Time', 'wp-user-frontend' ); ?></th>
Expand Down Expand Up @@ -99,9 +106,7 @@
</tr>

<tr class="wpuf_expiration_field">
<th>
Post Status :
</th>
<th><?php esc_html_e( 'Post Status', 'wp-user-frontend' ); ?></th>
<td>
<?php $post_statuses = get_post_statuses(); ?>
<select disabled name="" id="wpuf-expired_post_status">
Expand All @@ -124,9 +129,7 @@
</td>
</tr>
<tr class="wpuf_expiration_field">
<th>
Send Mail :
</th>
<th><?php esc_html_e( 'Send Mail', 'wp-user-frontend' ); ?></th>
sapayth marked this conversation as resolved.
Show resolved Hide resolved
<td>
<label>
<input disabled type="checkbox" name="" value="on" <?php echo esc_attr( $is_enable_mail_after_expired ); ?> />
Expand All @@ -135,10 +138,24 @@
</td>
</tr>
<tr class="wpuf_expiration_field">
<th>Post Expiration Message</th>
<th><?php esc_html_e( 'Post Expiration Message', 'wp-user-frontend' ); ?></th>
<td>
<textarea disabled name="" id="wpuf-post_expiration_message" cols="50" rows="5"><?php echo esc_html( $post_expiration_message ); ?></textarea>
<p class="description"><strong><?php echo esc_html( __( 'You may use: {post_author} {post_url} {blogname} {post_title} {post_status}', 'wp-user-frontend' ) ); ?></strong></p>
<p class="description">
<strong>
<?php
printf(
// translators: %1$s: {post_author}, %2$s: {post_url}, %3$s: {blogname}, %4$s: {post_title}, %5$s: {post_status}

Check warning on line 148 in includes/Free/Form_Element.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

This comment is 54% valid code; is this commented out code?
__( 'You may use: %1$s %2$s %3$s %4$s %5$s', 'wp-user-frontend' ),
'{post_author}',
'{post_url}',
'{blogname}',
'{post_title}',
'{post_status}'
)
?>
</strong>
</p>
</td>
</tr>
</table>
Expand Down Expand Up @@ -227,7 +244,11 @@
<?php esc_html_e( 'Enable post notification', 'wp-user-frontend' ); ?>
</label>
</td>
<p class="description"><a target="_blank" href="https://wedevs.com/docs/wp-user-frontend-pro/posting-forms/how-to-set-up-submission-email-notification/"><?php esc_html_e( 'Learn more about Email Notification', 'wp-user-frontend' ); ?></a></p>
<p class="description">
<a target="_blank" href="https://wedevs.com/docs/wp-user-frontend-pro/posting-forms/how-to-set-up-submission-email-notification/">
<?php esc_html_e( 'Learn more about Email Notification', 'wp-user-frontend' ); ?>
</a>
</p>
</tr>

<tr>
Expand Down Expand Up @@ -333,7 +354,7 @@

// @codingStandardsIgnoreEnd

$count++;

Check warning on line 357 in includes/Free/Form_Element.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Stand-alone post-increment statement found. Use pre-increment instead: ++$count.
}
}
?>
Expand Down Expand Up @@ -432,10 +453,10 @@
<td>
<select disabled name="">
<?php
$pages = get_posts( [

Check failure on line 456 in includes/Free/Form_Element.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Opening parenthesis of a multi-line function call must be the last content on the line
'numberposts' => -1,
'post_type' => 'page',
]);

Check failure on line 459 in includes/Free/Form_Element.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Closing parenthesis of a multi-line function call must be on a line by itself

foreach ( $pages as $page ) {
printf(
Expand Down Expand Up @@ -479,7 +500,7 @@
public static function check_post_type( $post, $update ) {
if ( get_post_type( $post->ID ) === 'wpuf_profile' && $update ) {
$http_referer = isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '';
wp_redirect( $http_referer );

Check warning on line 503 in includes/Free/Form_Element.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

wp_redirect() found. Using wp_safe_redirect(), along with the "allowed_redirect_hosts" filter if needed, can help avoid any chances of malicious redirects within code. It is also important to remember to call exit() after a redirect so that no other unwanted code is executed.
die();
}
}
Expand Down
7 changes: 5 additions & 2 deletions includes/Free/Free_Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,11 @@ public function pro_settings( $settings_fields ) {
'name' => 'ipstack_key',
'label' => __( 'Ipstack API Key',
'wp-user-frontend' ) . '<span class="pro-icon"> ' . file_get_contents( $crown_icon_path ) . '</span>',
'desc' => __( '<a target="_blank" href="https://ipstack.com/dashboard">Register here</a> to get your Free ipstack api key',
'wp-user-frontend' ),
'desc' => sprintf(
// translators: %1$s: opening anchor tag, %2$s: closing anchor tag
__( '%1$sRegister here%2$s to get your free ipstack api key', 'wp-user-frontend' ),
'<a target="_blank" href="https://ipstack.com/dashboard">', '</a>'
),
'class' => 'pro-preview',
'is_pro_preview' => true,
];
Expand Down
11 changes: 9 additions & 2 deletions includes/functions/settings-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
}

$settings_fields = [
'wpuf_general' => apply_filters( 'wpuf_options_others', [

Check failure on line 85 in includes/functions/settings-options.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Opening parenthesis of a multi-line function call must be the last content on the line
[
'name' => 'show_admin_bar',
'label' => __( 'Show Admin Bar', 'wp-user-frontend' ),
Expand All @@ -99,8 +99,8 @@
[
'name' => 'admin_access',
'label' => __( 'Admin area access', 'wp-user-frontend' ),
'desc' => __( 'Allow you to block specific user role to Ajax request and Media upload.',

Check failure on line 102 in includes/functions/settings-options.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Opening parenthesis of a multi-line function call must be the last content on the line
'wp-user-frontend' ),

Check warning on line 103 in includes/functions/settings-options.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.

Check failure on line 103 in includes/functions/settings-options.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Multi-line function call not indented correctly; expected 16 spaces but found 33

Check failure on line 103 in includes/functions/settings-options.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Closing parenthesis of a multi-line function call must be on a line by itself
'type' => 'select',
'default' => 'read',
'options' => [
Expand All @@ -114,8 +114,8 @@
[
'name' => 'override_editlink',
'label' => __( 'Override the post edit link', 'wp-user-frontend' ),
'desc' => __( 'Users see the edit link in post if s/he is capable to edit the post/page. Selecting <strong>Yes</strong> will override the default WordPress edit post link in frontend',

Check failure on line 117 in includes/functions/settings-options.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Opening parenthesis of a multi-line function call must be the last content on the line
'wp-user-frontend' ),

Check warning on line 118 in includes/functions/settings-options.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.

Check failure on line 118 in includes/functions/settings-options.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Multi-line function call not indented correctly; expected 16 spaces but found 33

Check failure on line 118 in includes/functions/settings-options.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Closing parenthesis of a multi-line function call must be on a line by itself
'type' => 'select',
'default' => 'no',
'options' => [
Expand All @@ -126,8 +126,15 @@
[
'name' => 'wpuf_compatibility_acf',
'label' => __( 'ACF Compatibility', 'wp-user-frontend' ),
'desc' => __( 'Select <strong>Yes</strong> if you want to make compatible WPUF custom fields data with advanced custom fields.',
'wp-user-frontend' ),
'desc' => sprintf(
// translators: %1$s and %2$s are strong tags
__(
'Select %1$sYes%2$s if you want to make compatible WPUF custom fields data with advanced custom fields.',
'wp-user-frontend'
),
'<strong>',
'</strong>'
),
'type' => 'select',
'default' => 'no',
'options' => [
Expand All @@ -149,14 +156,14 @@
[
'name' => 'recaptcha_private',
'label' => __( 'reCAPTCHA Secret Key', 'wp-user-frontend' ),
'desc' => __( '<a target="_blank" href="https://www.google.com/recaptcha/">Register here</a> to get reCaptcha Site and Secret keys.',

Check failure on line 159 in includes/functions/settings-options.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Opening parenthesis of a multi-line function call must be the last content on the line
'wp-user-frontend' ),

Check warning on line 160 in includes/functions/settings-options.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 3 spaces.
],
[
'name' => 'custom_css',
'label' => __( 'Custom CSS codes', 'wp-user-frontend' ),
'desc' => __( 'If you want to add your custom CSS code, it will be added on page header wrapped with style tag',
'wp-user-frontend' ),

Check warning on line 166 in includes/functions/settings-options.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 3 spaces.
'type' => 'textarea',
],
] ),
Expand All @@ -172,7 +179,7 @@
'name' => 'default_post_owner',
'label' => __( 'Default Post Owner', 'wp-user-frontend' ),
'desc' => __( 'If guest post is enabled and user details are OFF, the posts are assigned to this user',
'wp-user-frontend' ),

Check warning on line 182 in includes/functions/settings-options.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
'type' => 'select',
'options' => $users,
'default' => '1',
Expand All @@ -188,7 +195,7 @@
'name' => 'insert_photo_size',
'label' => __( 'Insert Photo image size', 'wp-user-frontend' ),
'desc' => __( 'Default image size of "<strong>Insert Photo</strong>" button in post content area',
'wp-user-frontend' ),

Check warning on line 198 in includes/functions/settings-options.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
'type' => 'select',
'options' => wpuf_get_image_sizes(),
'default' => 'thumbnail',
Expand All @@ -197,7 +204,7 @@
'name' => 'insert_photo_type',
'label' => __( 'Insert Photo image type', 'wp-user-frontend' ),
'desc' => __( 'Default image type of "<strong>Insert Photo</strong>" button in post content area',
'wp-user-frontend' ),

Check warning on line 207 in includes/functions/settings-options.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
'type' => 'select',
'options' => [
'image' => __( 'Image only', 'wp-user-frontend' ),
Expand Down
Loading
Loading