← All changes
|
class/Common/Importer/Template/CommentTemplate.php
+109
-54
2.8.0
→
2.15.0
View file →
| @@ -25,9 +25,9 @@ | ||
| 25 | 25 | { |
| 26 | 26 | |
| 27 | 27 | $post_types = get_post_types(); |
| 28 | 28 | $post_type_options = [ |
| 29 | - ['label' => 'Any', 'value' => ''] | |
| 29 | + ['label' => __('Any', 'jc-importer'), 'value' => ''] | |
| 30 | 30 | ]; |
| 31 | 31 | foreach ($post_types as $post_type => $label) { |
| 32 | 32 | $post_type_options[] = ['label' => $label, 'value' => $post_type]; |
| 33 | 33 | } |
| @@ -32,109 +32,109 @@ | ||
| 32 | 32 | $post_type_options[] = ['label' => $label, 'value' => $post_type]; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | return [ |
| 36 | - $this->register_group('Comment', 'comment', [ | |
| 36 | + $this->register_group(__('Comment', 'jc-importer'), 'comment', [ | |
| 37 | 37 | |
| 38 | 38 | // Comment |
| 39 | - $this->register_field('ID', 'comment_ID', [ | |
| 40 | - 'tooltip' => __('ID is only used to reference existing records', 'importwp') | |
| 39 | + $this->register_field(__('ID', 'jc-importer'), 'comment_ID', [ | |
| 40 | + 'tooltip' => __('ID is only used to reference existing records', 'jc-importer') | |
| 41 | 41 | ]), |
| 42 | - $this->register_field('Content', 'comment_content', [ | |
| 43 | - 'tooltip' => __('The content of the comment.', 'importwp') | |
| 42 | + $this->register_field(__('Content', 'jc-importer'), 'comment_content', [ | |
| 43 | + 'tooltip' => __('The content of the comment.', 'jc-importer') | |
| 44 | 44 | ]), |
| 45 | - $this->register_group('Comment Parent', '_parent', [ | |
| 45 | + $this->register_group(__('Comment Parent', 'jc-importer'), '_parent', [ | |
| 46 | 46 | |
| 47 | - $this->register_field('Comment Parent', 'id', [ | |
| 47 | + $this->register_field(__('Comment Parent', 'jc-importer'), 'id', [ | |
| 48 | 48 | 'default' => '', |
| 49 | 49 | 'options' => 'callback', |
| 50 | - 'tooltip' => __('ID of this comment\'s parent, if any.', 'importwp') | |
| 50 | + 'tooltip' => __('ID of this comment\'s parent, if any.', 'jc-importer') | |
| 51 | 51 | ]), |
| 52 | - $this->register_field('Comment Post Field Type', '_id_type', [ | |
| 52 | + $this->register_field(__('Comment Parent Field Type', 'jc-importer'), '_id_type', [ | |
| 53 | 53 | 'default' => 'id', |
| 54 | 54 | 'options' => [ |
| 55 | - ['value' => 'id', 'label' => 'ID'], | |
| 56 | - ['value' => 'ref', 'label' => 'Comment Ref Field'], | |
| 57 | - ['value' => 'custom_field', 'label' => 'Custom Field'], | |
| 55 | + ['value' => 'id', 'label' => __('ID', 'jc-importer')], | |
| 56 | + ['value' => 'ref', 'label' => __('Comment Ref Field', 'jc-importer')], | |
| 57 | + ['value' => 'custom_field', 'label' => __('Custom Field', 'jc-importer')], | |
| 58 | 58 | ], |
| 59 | 59 | 'type' => 'select', |
| 60 | - 'tooltip' => __('Select how the post ID field should be handled', 'importwp') | |
| 60 | + 'tooltip' => __('Select how the post ID field should be handled', 'jc-importer') | |
| 61 | 61 | ]), |
| 62 | - $this->register_field('Custom Field Key', '_custom_field', [ | |
| 62 | + $this->register_field(__('Custom Field Key', 'jc-importer'), '_custom_field', [ | |
| 63 | 63 | 'condition' => ['_id_type', '==', 'custom_field'], |
| 64 | - 'tooltip' => __('Enter the name of the post\'s custom field.', 'importwp') | |
| 64 | + 'tooltip' => __('Enter the name of the post\'s custom field.', 'jc-importer') | |
| 65 | 65 | ]) |
| 66 | 66 | |
| 67 | 67 | ]), |
| 68 | - $this->register_group('Comment Post', '_post', [ | |
| 69 | - $this->register_field('Comment Post', 'id', [ | |
| 68 | + $this->register_group(__('Comment Post', 'jc-importer'), '_post', [ | |
| 69 | + $this->register_field(__('Comment Post', 'jc-importer'), 'id', [ | |
| 70 | 70 | 'default' => '', |
| 71 | - 'tooltip' => __('ID of the post that relates to the comment, if any.', 'importwp') | |
| 71 | + 'tooltip' => __('ID of the post that relates to the comment, if any.', 'jc-importer') | |
| 72 | 72 | ]), |
| 73 | - $this->register_field('Comment Post Field Type', '_id_type', [ | |
| 73 | + $this->register_field(__('Comment Post Field Type', 'jc-importer'), '_id_type', [ | |
| 74 | 74 | 'default' => 'id', |
| 75 | 75 | 'options' => [ |
| 76 | - ['value' => 'id', 'label' => 'ID'], | |
| 77 | - ['value' => 'slug', 'label' => 'Slug'], | |
| 78 | - ['value' => 'name', 'label' => 'Name'], | |
| 79 | - ['value' => 'custom_field', 'label' => 'Custom Field'], | |
| 76 | + ['value' => 'id', 'label' => __('ID', 'jc-importer')], | |
| 77 | + ['value' => 'slug', 'label' => __('Slug', 'jc-importer')], | |
| 78 | + ['value' => 'name', 'label' => __('Name', 'jc-importer')], | |
| 79 | + ['value' => 'custom_field', 'label' => __('Custom Field', 'jc-importer')], | |
| 80 | 80 | ], |
| 81 | 81 | 'type' => 'select', |
| 82 | - 'tooltip' => __('Select how the post ID field should be handled', 'importwp') | |
| 82 | + 'tooltip' => __('Select how the post ID field should be handled', 'jc-importer') | |
| 83 | 83 | ]), |
| 84 | - $this->register_field('Custom Field Key', '_custom_field', [ | |
| 84 | + $this->register_field(__('Custom Field Key', 'jc-importer'), '_custom_field', [ | |
| 85 | 85 | 'condition' => ['_id_type', '==', 'custom_field'], |
| 86 | - 'tooltip' => __('Enter the name of the post\'s custom field.', 'importwp') | |
| 86 | + 'tooltip' => __('Enter the name of the post\'s custom field.', 'jc-importer') | |
| 87 | 87 | ]) |
| 88 | 88 | ]), |
| 89 | - $this->register_field('Comment Type', 'comment_type', [ | |
| 89 | + $this->register_field(__('Comment Type', 'jc-importer'), 'comment_type', [ | |
| 90 | 90 | 'default' => 'comment', |
| 91 | - 'tooltip' => __('Comment type.', 'importwp') | |
| 91 | + 'tooltip' => __('Comment type.', 'jc-importer') | |
| 92 | 92 | ]), |
| 93 | 93 | |
| 94 | 94 | // Author |
| 95 | - $this->register_field('Author ID', 'user_id', [ | |
| 96 | - 'tooltip' => __('Author user id.', 'importwp') | |
| 95 | + $this->register_field(__('Author ID', 'jc-importer'), 'user_id', [ | |
| 96 | + 'tooltip' => __('Author user id.', 'jc-importer') | |
| 97 | 97 | ]), |
| 98 | - $this->register_field('Author Name', 'comment_author', [ | |
| 99 | - 'tooltip' => __('The name of the author of the comment.', 'importwp') | |
| 98 | + $this->register_field(__('Author Name', 'jc-importer'), 'comment_author', [ | |
| 99 | + 'tooltip' => __('The name of the author of the comment.', 'jc-importer') | |
| 100 | 100 | ]), |
| 101 | - $this->register_field('Author Email', 'comment_author_email', [ | |
| 102 | - 'tooltip' => __('The email address of the Comment Author', 'importwp') | |
| 101 | + $this->register_field(__('Author Email', 'jc-importer'), 'comment_author_email', [ | |
| 102 | + 'tooltip' => __('The email address of the Comment Author', 'jc-importer') | |
| 103 | 103 | ]), |
| 104 | - $this->register_field('Author Url', 'comment_author_url', [ | |
| 105 | - 'tooltip' => __('The URL address of the Comment Author.', 'importwp') | |
| 104 | + $this->register_field(__('Author Url', 'jc-importer'), 'comment_author_url', [ | |
| 105 | + 'tooltip' => __('The URL address of the Comment Author.', 'jc-importer') | |
| 106 | 106 | ]), |
| 107 | - $this->register_field('Comment Author IP', 'comment_author_IP', [ | |
| 108 | - 'tooltip' => __('The IP address of the Comment Author.', 'importwp') | |
| 107 | + $this->register_field(__('Comment Author IP', 'jc-importer'), 'comment_author_IP', [ | |
| 108 | + 'tooltip' => __('The IP address of the Comment Author.', 'jc-importer') | |
| 109 | 109 | ]), |
| 110 | 110 | |
| 111 | 111 | // Meta |
| 112 | - $this->register_field('Ref', '_iwp_ref_id', [ | |
| 113 | - 'tooltip' => __('A custom field to uniquely identify the comment.', 'importwp') | |
| 112 | + $this->register_field(__('Ref', 'jc-importer'), '_iwp_ref_id', [ | |
| 113 | + 'tooltip' => __('A custom field to uniquely identify the comment.', 'jc-importer') | |
| 114 | 114 | ]), |
| 115 | - $this->register_field('Post Type', 'post_type', [ | |
| 115 | + $this->register_field(__('Post Type', 'jc-importer'), 'post_type', [ | |
| 116 | 116 | 'options' => $post_type_options, |
| 117 | 117 | 'default' => '', |
| 118 | - 'tooltip' => __('The post type the comment belongs to.', 'importwp') | |
| 118 | + 'tooltip' => __('The post type the comment belongs to.', 'jc-importer') | |
| 119 | 119 | ]), |
| 120 | - $this->register_field('Comment Approved', 'comment_approved', [ | |
| 120 | + $this->register_field(__('Comment Approved', 'jc-importer'), 'comment_approved', [ | |
| 121 | 121 | 'options' => [ |
| 122 | - ['value' => '0', 'label' => 'Disapproved'], | |
| 123 | - ['value' => '1', 'label' => 'Approved'] | |
| 122 | + ['value' => '0', 'label' => __('Disapproved', 'jc-importer')], | |
| 123 | + ['value' => '1', 'label' => __('Approved', 'jc-importer')] | |
| 124 | 124 | ], |
| 125 | 125 | 'default' => '1', |
| 126 | - 'tooltip' => __('Whether the comment has been approved. 1 = Approved, 0 = Disapproved', 'importwp') | |
| 126 | + 'tooltip' => __('Whether the comment has been approved. 1 = Approved, 0 = Disapproved', 'jc-importer') | |
| 127 | 127 | ]), |
| 128 | - $this->register_field('Comment Karma', 'comment_karma', [ | |
| 128 | + $this->register_field(__('Comment Karma', 'jc-importer'), 'comment_karma', [ | |
| 129 | 129 | 'default' => '0', |
| 130 | - 'tooltip' => __('The karma of the comment.', 'importwp') | |
| 130 | + 'tooltip' => __('The karma of the comment.', 'jc-importer') | |
| 131 | 131 | ]), |
| 132 | - $this->register_field('Comment Agent', 'comment_agent', [ | |
| 133 | - 'tooltip' => __('The HTTP user agent of the Comment Author when the comment was submitted.', 'importwp') | |
| 132 | + $this->register_field(__('Comment Agent', 'jc-importer'), 'comment_agent', [ | |
| 133 | + 'tooltip' => __('The HTTP user agent of the Comment Author when the comment was submitted.', 'jc-importer') | |
| 134 | 134 | ]), |
| 135 | - $this->register_field('Comment Date', 'comment_date', [ | |
| 136 | - 'tooltip' => __('The date the comment was submitted.', 'importwp') | |
| 135 | + $this->register_field(__('Comment Date', 'jc-importer'), 'comment_date', [ | |
| 136 | + 'tooltip' => __('The date the comment was submitted.', 'jc-importer') | |
| 137 | 137 | ]), |
| 138 | 138 | ]) |
| 139 | 139 | ]; |
| 140 | 140 | } |
| @@ -168,9 +168,9 @@ | ||
| 168 | 168 | |
| 169 | 169 | foreach ($results as $result) { |
| 170 | 170 | $vars[] = [ |
| 171 | 171 | 'value' => $result, |
| 172 | - 'label' => 'Comment #' . $result | |
| 172 | + 'label' => sprintf(__('Comment #%s', 'jc-importer'), $result) | |
| 173 | 173 | ]; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | return $vars; |
| @@ -370,6 +370,61 @@ | ||
| 370 | 370 | return $query->comments[0]; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | return false; |
| 374 | + } | |
| 375 | + | |
| 376 | + public function get_permission_fields($importer_model) | |
| 377 | + { | |
| 378 | + $permission_fields = parent::get_permission_fields($importer_model); | |
| 379 | + | |
| 380 | + $permission_fields['core'] = [ | |
| 381 | + 'comment_ID' => __('ID', 'jc-importer'), | |
| 382 | + 'comment_agent' => __('User Agent', 'jc-importer'), | |
| 383 | + 'comment_approved' => __('Approved', 'jc-importer'), | |
| 384 | + 'comment_author' => __('Author', 'jc-importer'), | |
| 385 | + 'comment_author_email' => __('Author Email', 'jc-importer'), | |
| 386 | + 'comment_author_IP' => __('Ip Address', 'jc-importer'), | |
| 387 | + 'comment_author_url' => __('Author Url', 'jc-importer'), | |
| 388 | + 'comment_content' => __('Content', 'jc-importer'), | |
| 389 | + 'comment_date' => __('Date', 'jc-importer'), | |
| 390 | + 'comment_date_gmt' => __('Date GMT', 'jc-importer'), | |
| 391 | + 'comment_karma' => __('Karma', 'jc-importer'), | |
| 392 | + 'comment_parent' => __('Parent', 'jc-importer'), | |
| 393 | + 'comment_post_ID' => __('Post ID', 'jc-importer'), | |
| 394 | + 'comment_type' => __('Comment Type', 'jc-importer'), | |
| 395 | + 'user_id' => __('User ID', 'jc-importer') | |
| 396 | + ]; | |
| 397 | + | |
| 398 | + return $permission_fields; | |
| 399 | + } | |
| 400 | + | |
| 401 | + public function get_unique_identifier_options($importer_model, $unique_fields = []) | |
| 402 | + { | |
| 403 | + $output = parent::get_unique_identifier_options($importer_model, $unique_fields); | |
| 404 | + | |
| 405 | + $field_map = [ | |
| 406 | + 'comment_ID' => 'comment.comment_ID', | |
| 407 | + 'comment_agent' => 'comment.comment_agent', | |
| 408 | + 'comment_approved' => 'comment.comment_approved', | |
| 409 | + 'comment_author' => 'comment.comment_author', | |
| 410 | + 'comment_author_email' => 'comment.comment_author_email', | |
| 411 | + 'comment_author_IP' => 'comment.comment_author_IP', | |
| 412 | + 'comment_author_url' => 'comment.comment_author_url', | |
| 413 | + 'comment_content' => 'comment.comment_content', | |
| 414 | + 'comment_date' => 'comment.comment_date', | |
| 415 | + 'comment_date_gmt' => 'comment.comment_date_gmt', | |
| 416 | + 'comment_karma' => 'comment.comment_karma', | |
| 417 | + 'comment_parent' => 'comment.comment_parent', | |
| 418 | + 'comment_post_ID' => 'comment.comment_post_ID', | |
| 419 | + 'comment_type' => 'comment.comment_type', | |
| 420 | + 'user_id' => 'comment.user_id', | |
| 421 | + '_iwp_ref_id' => 'comment._iwp_ref_id', | |
| 422 | + ]; | |
| 423 | + $optional_fields = array_keys($field_map); | |
| 424 | + | |
| 425 | + return array_merge( | |
| 426 | + $output, | |
| 427 | + $this->get_unique_identifier_options_from_map($importer_model, $unique_fields, $field_map, $optional_fields) | |
| 428 | + ); | |
| 374 | 429 | } |
| 375 | 430 | } |