Changeset 3098877
- Timestamp:
- 06/06/2024 06:15:11 PM (22 months ago)
- Location:
- wpglobus-multilingual-comments
- Files:
-
- 9 added
- 2 deleted
- 4 edited
- 1 copied
-
assets/screenshot-1.png (added)
-
tags/1.5 (copied) (copied from wpglobus-multilingual-comments/trunk)
-
tags/1.5/FUNDING.yml (deleted)
-
tags/1.5/languages (added)
-
tags/1.5/languages/wpglobus-multilingual-comments-ru_RU.mo (added)
-
tags/1.5/languages/wpglobus-multilingual-comments-ru_RU.po (added)
-
tags/1.5/languages/wpglobus-multilingual-comments.pot (added)
-
tags/1.5/readme.txt (modified) (2 diffs)
-
tags/1.5/wpglobus-multilingual-comments.php (modified) (4 diffs)
-
trunk/FUNDING.yml (deleted)
-
trunk/languages (added)
-
trunk/languages/wpglobus-multilingual-comments-ru_RU.mo (added)
-
trunk/languages/wpglobus-multilingual-comments-ru_RU.po (added)
-
trunk/languages/wpglobus-multilingual-comments.pot (added)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/wpglobus-multilingual-comments.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wpglobus-multilingual-comments/tags/1.5/readme.txt
r3086829 r3098877 5 5 Tested up to: 6.5 6 6 Requires PHP: 7.4 7 Stable tag: 1. 47 Stable tag: 1.5 8 8 License: GPL-3.0-or-later 9 9 License URI: https://spdx.org/licenses/GPL-3.0-or-later.html … … 32 32 == Frequently Asked Questions == 33 33 34 = What languages does this WordPress plugin support? =35 Unfortunately, it currently supports multilingual comments only for English and Russian.34 = What does the Multilingual Comments for WPGlobus plugin do? 35 The Multilingual Comments for WPGlobus plugin allows you to create multilingual comments using the WPGlobus plugin. It filters comments based on the language of the current post, adds a language selection field to the comment form, and allows bulk editing of comment languages in the admin panel. 36 36 37 = How to extend language support in this plugin? = 38 Contact this [plugin's support](https://wordpress.org/support/plugin/wpglobus-multilingual-comments/). 37 = How do I add a language to a comment? 38 When a user leaves a comment, the plugin automatically adds a hidden field with the current post's language. This language is saved with the comment. 39 40 = How do I filter comments by language? 41 The plugin automatically filters comments based on the current post's language. You will only see comments that match the post's language. 42 43 = How do I bulk change the language of comments? 44 In the WordPress admin panel, go to the "Comments" section. Select the comments you want to edit, and in the bulk actions menu, choose the desired language (e.g., "Assign en" or "Assign ru"). The plugin will automatically change the language of the selected comments. 45 46 = Does the plugin support other multilingual plugins? 47 The Multilingual Comments for WPGlobus plugin is designed only to work with WPGlobus. 48 39 49 40 50 == Changelog == 51 = 1.5 - 06.06.2024 = 52 * Changed Description 53 * Expanded language support 54 * Checked WordPress Security Standards 55 41 56 = 1.4 - 15.05.2024 = 42 57 * Changed Description -
wpglobus-multilingual-comments/tags/1.5/wpglobus-multilingual-comments.php
r3086829 r3098877 3 3 * Plugin Name: Multilingual Comments for WPGlobus 4 4 * Description: Multilingual Comments for WPGlobus - an unofficial plugin for creating multilingual comments using the WPGlobus plugin. 5 * Version: 1. 45 * Version: 1.5 6 6 * Author: seojacky 7 7 * Author URI: https://t.me/big_jacky … … 12 12 * Text Domain: wpglobus-multilingual-comments 13 13 * Domain Path: /languages 14 */14 */ 15 15 16 16 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly 17 17 18 // Load plugin text domain for translations 19 function wpglobus_multilingual_comments_load_textdomain() { 20 load_plugin_textdomain( 'wpglobus-multilingual-comments', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); 21 } 22 add_action( 'plugins_loaded', 'wpglobus_multilingual_comments_load_textdomain' ); 23 18 24 // Function for filtering comments based on the language of the current post 19 25 function comment_language_filter_comments_by_post_language($comments) { 20 // Get the language of the current post 21 $post_language = get_locale() === 'ru_RU' ? 'ru_RU' : 'en_US';26 // Get the language of the current post 27 $post_language = WPGlobus::Config()->language; 22 28 23 29 // Filter comments by the language of the current post … … 29 35 return $filtered_comments; 30 36 } 31 32 // Переопределяем функцию, отвечающую за вывод комментариев33 37 add_filter('comments_array', 'comment_language_filter_comments_by_post_language', 10, 2); 34 38 35 // Override the function responsible for displaying comments36 add_filter('comment_form_default_fields', function($fields) {37 // Получаем текущий язык38 $current_language = get_locale();39 // Add language selection field to the comment form 40 function comment_language_add_language_field($fields) { 41 // Get the current language 42 $current_language = WPGlobus::Config()->language; 39 43 40 44 // Add language selection field if language is defined 41 45 if (!empty($current_language)) { 42 46 $fields['comment_language'] = '<p class="comment-form-language" style="display:none"><label for="comment_language">' . esc_html__('Language', 'wpglobus-multilingual-comments') . '</label>' . 43 '< select id="comment_language" name="comment_language">' .44 '<option value="' . esc_attr($current_language) . '" selected>' . esc_html($current_language) . '</option>' .45 '</ select></p>';47 '<input id="comment_language" name="comment_language" type="hidden" value="' . esc_attr($current_language) . '">' . 48 wp_nonce_field('save_comment_language', 'comment_language_nonce', true, false) . // Add nonce field 49 '</p>'; 46 50 } 47 51 48 52 return $fields; 49 }, 20); 53 } 54 add_filter('comment_form_default_fields', 'comment_language_add_language_field', 20); 50 55 51 56 // Save the selected language when sending a comment 52 // Add nonce field to the comment form 53 57 function comment_language_save_comment_meta($comment_id) { 58 if (isset($_POST['comment_language_nonce']) && wp_verify_nonce($_POST['comment_language_nonce'], 'save_comment_language')) { 59 if (isset($_POST['comment_language'])) { 60 $comment_language = sanitize_text_field($_POST['comment_language']); 61 add_comment_meta($comment_id, 'comment_language', $comment_language, true); 62 } 63 } 64 } 65 add_action('comment_post', 'comment_language_save_comment_meta'); 54 66 55 67 // Add the "Language" column to the comments admin panel 56 add_filter('manage_edit-comments_columns', 'comment_language_add_language_column');57 68 function comment_language_add_language_column($columns) { 58 69 $columns['language'] = __('Language', 'wpglobus-multilingual-comments'); 59 70 return $columns; 60 71 } 72 add_filter('manage_edit-comments_columns', 'comment_language_add_language_column'); 61 73 62 74 // Output the language data in the "Language" column 63 add_action('manage_comments_custom_column', 'comment_language_display_language_column_data', 10, 2);64 75 function comment_language_display_language_column_data($column, $comment_id) { 65 76 if ($column === 'language') { … … 73 84 } 74 85 } 86 add_action('manage_comments_custom_column', 'comment_language_display_language_column_data', 10, 2); 75 87 76 88 // Add actions for mass editing of comments 77 add_filter('bulk_actions-edit-comments', 'comment_language_add_language_bulk_actions');78 89 function comment_language_add_language_bulk_actions($actions) { 79 $actions['assign_en_US'] = __('Assign en_US', 'wpglobus-multilingual-comments'); 80 $actions['assign_ru_RU'] = __('Assign ru_RU', 'wpglobus-multilingual-comments'); 90 $languages = WPGlobus::Config()->enabled_languages; 91 foreach ($languages as $language) { 92 $assign = esc_html__('Assign', 'wpglobus-multilingual-comments') . ' ' . strtoupper($language); 93 $actions['assign_' . $language] = $assign; 94 } 81 95 return $actions; 82 96 } 97 add_filter('bulk_actions-edit-comments', 'comment_language_add_language_bulk_actions'); 83 98 84 99 // Handling actions for bulk editing of comments 85 add_filter('handle_bulk_actions-edit-comments', 'comment_language_handle_language_bulk_actions', 10, 3);86 100 function comment_language_handle_language_bulk_actions($redirect_to, $action, $comment_ids) { 87 if ($action == 'assign_en_US' || $action == 'assign_ru_RU') { 88 $language = str_replace('assign_', '', $action); 89 foreach ($comment_ids as $comment_id) { 90 update_comment_meta($comment_id, 'comment_language', $language); 101 $languages = WPGlobus::Config()->enabled_languages; 102 foreach ($languages as $language) { 103 if ($action == 'assign_' . $language) { 104 foreach ($comment_ids as $comment_id) { 105 update_comment_meta($comment_id, 'comment_language', $language); 106 } 107 $redirect_to = add_query_arg('bulk_language_updated', count($comment_ids), $redirect_to); 108 break; 91 109 } 92 $redirect_to = add_query_arg('bulk_language_updated', count($comment_ids), $redirect_to);93 110 } 94 111 return $redirect_to; 95 112 } 113 add_filter('handle_bulk_actions-edit-comments', 'comment_language_handle_language_bulk_actions', 10, 3); 114 ?> -
wpglobus-multilingual-comments/trunk/readme.txt
r3086829 r3098877 5 5 Tested up to: 6.5 6 6 Requires PHP: 7.4 7 Stable tag: 1. 47 Stable tag: 1.5 8 8 License: GPL-3.0-or-later 9 9 License URI: https://spdx.org/licenses/GPL-3.0-or-later.html … … 32 32 == Frequently Asked Questions == 33 33 34 = What languages does this WordPress plugin support? =35 Unfortunately, it currently supports multilingual comments only for English and Russian.34 = What does the Multilingual Comments for WPGlobus plugin do? 35 The Multilingual Comments for WPGlobus plugin allows you to create multilingual comments using the WPGlobus plugin. It filters comments based on the language of the current post, adds a language selection field to the comment form, and allows bulk editing of comment languages in the admin panel. 36 36 37 = How to extend language support in this plugin? = 38 Contact this [plugin's support](https://wordpress.org/support/plugin/wpglobus-multilingual-comments/). 37 = How do I add a language to a comment? 38 When a user leaves a comment, the plugin automatically adds a hidden field with the current post's language. This language is saved with the comment. 39 40 = How do I filter comments by language? 41 The plugin automatically filters comments based on the current post's language. You will only see comments that match the post's language. 42 43 = How do I bulk change the language of comments? 44 In the WordPress admin panel, go to the "Comments" section. Select the comments you want to edit, and in the bulk actions menu, choose the desired language (e.g., "Assign en" or "Assign ru"). The plugin will automatically change the language of the selected comments. 45 46 = Does the plugin support other multilingual plugins? 47 The Multilingual Comments for WPGlobus plugin is designed only to work with WPGlobus. 48 39 49 40 50 == Changelog == 51 = 1.5 - 06.06.2024 = 52 * Changed Description 53 * Expanded language support 54 * Checked WordPress Security Standards 55 41 56 = 1.4 - 15.05.2024 = 42 57 * Changed Description -
wpglobus-multilingual-comments/trunk/wpglobus-multilingual-comments.php
r3086829 r3098877 3 3 * Plugin Name: Multilingual Comments for WPGlobus 4 4 * Description: Multilingual Comments for WPGlobus - an unofficial plugin for creating multilingual comments using the WPGlobus plugin. 5 * Version: 1. 45 * Version: 1.5 6 6 * Author: seojacky 7 7 * Author URI: https://t.me/big_jacky … … 12 12 * Text Domain: wpglobus-multilingual-comments 13 13 * Domain Path: /languages 14 */14 */ 15 15 16 16 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly 17 17 18 // Load plugin text domain for translations 19 function wpglobus_multilingual_comments_load_textdomain() { 20 load_plugin_textdomain( 'wpglobus-multilingual-comments', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); 21 } 22 add_action( 'plugins_loaded', 'wpglobus_multilingual_comments_load_textdomain' ); 23 18 24 // Function for filtering comments based on the language of the current post 19 25 function comment_language_filter_comments_by_post_language($comments) { 20 // Get the language of the current post 21 $post_language = get_locale() === 'ru_RU' ? 'ru_RU' : 'en_US';26 // Get the language of the current post 27 $post_language = WPGlobus::Config()->language; 22 28 23 29 // Filter comments by the language of the current post … … 29 35 return $filtered_comments; 30 36 } 31 32 // Переопределяем функцию, отвечающую за вывод комментариев33 37 add_filter('comments_array', 'comment_language_filter_comments_by_post_language', 10, 2); 34 38 35 // Override the function responsible for displaying comments36 add_filter('comment_form_default_fields', function($fields) {37 // Получаем текущий язык38 $current_language = get_locale();39 // Add language selection field to the comment form 40 function comment_language_add_language_field($fields) { 41 // Get the current language 42 $current_language = WPGlobus::Config()->language; 39 43 40 44 // Add language selection field if language is defined 41 45 if (!empty($current_language)) { 42 46 $fields['comment_language'] = '<p class="comment-form-language" style="display:none"><label for="comment_language">' . esc_html__('Language', 'wpglobus-multilingual-comments') . '</label>' . 43 '< select id="comment_language" name="comment_language">' .44 '<option value="' . esc_attr($current_language) . '" selected>' . esc_html($current_language) . '</option>' .45 '</ select></p>';47 '<input id="comment_language" name="comment_language" type="hidden" value="' . esc_attr($current_language) . '">' . 48 wp_nonce_field('save_comment_language', 'comment_language_nonce', true, false) . // Add nonce field 49 '</p>'; 46 50 } 47 51 48 52 return $fields; 49 }, 20); 53 } 54 add_filter('comment_form_default_fields', 'comment_language_add_language_field', 20); 50 55 51 56 // Save the selected language when sending a comment 52 // Add nonce field to the comment form 53 57 function comment_language_save_comment_meta($comment_id) { 58 if (isset($_POST['comment_language_nonce']) && wp_verify_nonce($_POST['comment_language_nonce'], 'save_comment_language')) { 59 if (isset($_POST['comment_language'])) { 60 $comment_language = sanitize_text_field($_POST['comment_language']); 61 add_comment_meta($comment_id, 'comment_language', $comment_language, true); 62 } 63 } 64 } 65 add_action('comment_post', 'comment_language_save_comment_meta'); 54 66 55 67 // Add the "Language" column to the comments admin panel 56 add_filter('manage_edit-comments_columns', 'comment_language_add_language_column');57 68 function comment_language_add_language_column($columns) { 58 69 $columns['language'] = __('Language', 'wpglobus-multilingual-comments'); 59 70 return $columns; 60 71 } 72 add_filter('manage_edit-comments_columns', 'comment_language_add_language_column'); 61 73 62 74 // Output the language data in the "Language" column 63 add_action('manage_comments_custom_column', 'comment_language_display_language_column_data', 10, 2);64 75 function comment_language_display_language_column_data($column, $comment_id) { 65 76 if ($column === 'language') { … … 73 84 } 74 85 } 86 add_action('manage_comments_custom_column', 'comment_language_display_language_column_data', 10, 2); 75 87 76 88 // Add actions for mass editing of comments 77 add_filter('bulk_actions-edit-comments', 'comment_language_add_language_bulk_actions');78 89 function comment_language_add_language_bulk_actions($actions) { 79 $actions['assign_en_US'] = __('Assign en_US', 'wpglobus-multilingual-comments'); 80 $actions['assign_ru_RU'] = __('Assign ru_RU', 'wpglobus-multilingual-comments'); 90 $languages = WPGlobus::Config()->enabled_languages; 91 foreach ($languages as $language) { 92 $assign = esc_html__('Assign', 'wpglobus-multilingual-comments') . ' ' . strtoupper($language); 93 $actions['assign_' . $language] = $assign; 94 } 81 95 return $actions; 82 96 } 97 add_filter('bulk_actions-edit-comments', 'comment_language_add_language_bulk_actions'); 83 98 84 99 // Handling actions for bulk editing of comments 85 add_filter('handle_bulk_actions-edit-comments', 'comment_language_handle_language_bulk_actions', 10, 3);86 100 function comment_language_handle_language_bulk_actions($redirect_to, $action, $comment_ids) { 87 if ($action == 'assign_en_US' || $action == 'assign_ru_RU') { 88 $language = str_replace('assign_', '', $action); 89 foreach ($comment_ids as $comment_id) { 90 update_comment_meta($comment_id, 'comment_language', $language); 101 $languages = WPGlobus::Config()->enabled_languages; 102 foreach ($languages as $language) { 103 if ($action == 'assign_' . $language) { 104 foreach ($comment_ids as $comment_id) { 105 update_comment_meta($comment_id, 'comment_language', $language); 106 } 107 $redirect_to = add_query_arg('bulk_language_updated', count($comment_ids), $redirect_to); 108 break; 91 109 } 92 $redirect_to = add_query_arg('bulk_language_updated', count($comment_ids), $redirect_to);93 110 } 94 111 return $redirect_to; 95 112 } 113 add_filter('handle_bulk_actions-edit-comments', 'comment_language_handle_language_bulk_actions', 10, 3); 114 ?>
Note: See TracChangeset
for help on using the changeset viewer.