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 all commits
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
5 changes: 3 additions & 2 deletions admin/html/form-settings-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@
'taxonomy' => $tax->name,
];

$tax = '<tr class="wpuf_settings_taxonomy"> <th> Default '. $post_type_selected . ' '. $tax->name .'</th> <td>
<select multiple name="wpuf_settings[default_'.$tax->name.'][]">';
// translators: %s: post type name and taxonomy name
$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.'][]">';
$categories = get_terms( $args );

foreach ( $categories as $category ) {
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 @@ -583,7 +583,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
501 changes: 361 additions & 140 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,
]
);
}
}
47 changes: 34 additions & 13 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,21 +129,33 @@
</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 ); ?> />
<?php echo esc_html( __( 'Send Email to Author After Exceeding Post Expiration Time', 'wp-user-frontend' ) ); ?>
<?php esc_html_e( 'Send Email to Author After Exceeding Post Expiration Time', 'wp-user-frontend' ); ?>
</label>
</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
16 changes: 11 additions & 5 deletions includes/Free/Free_Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,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 Expand Up @@ -732,7 +735,11 @@ public function pro_settings( $settings_fields ) {
[
'name' => 'tax_help',
'label' => __( 'Need help?', 'wp-user-frontend' ),
'desc' => sprintf( __( 'Visit the <a href="%s" target="_blank">Tax setup documentation</a> for guidance on how to setup tax.', 'wp-user-frontend' ), 'https://wedevs.com/docs/wp-user-frontend-pro/settings/tax/' ),
'desc' => sprintf(
// translators: %1$s: opening anchor tag, %2$s: closing anchor tag
__( 'Visit the %1$sTax setup documentation%2$s for guidance on how to setup tax.', 'wp-user-frontend' ), '<a href="https://wedevs.com/docs/wp-user-frontend-pro/settings/tax/" target="_blank">',
'</a>'
),
'callback' => 'wpuf_descriptive_text',
],
[
Expand Down Expand Up @@ -790,8 +797,7 @@ public function pro_settings( $settings_fields ) {
[
'name' => 'keyword_dictionary',
'label' => __( 'Keyword Dictionary', 'wp-user-frontend' ),
'desc' => __( 'Enter Keywords to Remove. Separate keywords with commas.',
'wp-user-frontend' ),
'desc' => __( 'Enter Keywords to Remove. Separate keywords with commas.', 'wp-user-frontend' ),
'type' => 'textarea',
'is_pro_preview' => true,
],
Expand Down
Loading
Loading