first commit

This commit is contained in:
2023-09-12 21:41:04 +02:00
commit 3361a7f053
13284 changed files with 2116755 additions and 0 deletions

View File

@@ -0,0 +1,222 @@
<?php
use WPML\API\Sanitize;
/**
* Class WPML_TF_Backend_Feedback_List_View
*
* @author OnTheGoSystems
*/
class WPML_TF_Backend_Feedback_List_View {
const TEMPLATE_FOLDER = '/templates/translation-feedback/backend/';
const TEMPLATE_NAME = 'feedback-list-page.twig';
const ITEMS_PER_PAGE = 20;
/** @var IWPML_Template_Service $template_service */
private $template_service;
/** @var WPML_TF_Feedback_Query $feedback_query */
private $feedback_query;
/** @var WPML_Admin_Pagination $pagination */
private $pagination;
/** @var WPML_Admin_Table_Sort $table_sort */
private $table_sort;
/** @var WPML_TF_Feedback_Page_Filter $page_filter */
private $page_filter;
/**
* WPML_TF_Backend_Feedback_List_View constructor.
*
* @param IWPML_Template_Service $template_service
* @param WPML_TF_Feedback_Query $feedback_query
* @param WPML_Admin_Pagination $pagination
* @param WPML_Admin_Table_Sort $table_sort
* @param WPML_TF_Feedback_Page_Filter $page_filter
*/
public function __construct(
IWPML_Template_Service $template_service,
WPML_TF_Feedback_Query $feedback_query,
WPML_Admin_Pagination $pagination,
WPML_Admin_Table_Sort $table_sort,
WPML_TF_Feedback_Page_Filter $page_filter
) {
$this->template_service = $template_service;
$this->feedback_query = $feedback_query;
$this->pagination = $pagination;
$this->table_sort = $table_sort;
$this->page_filter = $page_filter;
}
/** @return string */
public function render_page() {
$args = $this->parse_request_args();
$feedback_collection = $this->feedback_query->get( $args );
$model = array(
'strings' => $this->get_strings(),
'columns' => $this->get_columns(),
'pagination' => $this->get_pagination( $args ),
'page_filters' => $this->get_page_filters(),
'admin_page_hook' => WPML_TF_Backend_Hooks::PAGE_HOOK,
'current_query' => $this->get_current_query(),
'nonce' => wp_create_nonce( WPML_TF_Backend_Hooks::PAGE_HOOK ),
'ajax_action' => WPML_TF_Backend_AJAX_Feedback_Edit_Hooks_Factory::AJAX_ACTION,
'ajax_nonce' => wp_create_nonce( WPML_TF_Backend_AJAX_Feedback_Edit_Hooks_Factory::AJAX_ACTION ),
'has_admin_capabilities' => current_user_can( 'manage_options' ),
'is_in_trash' => $this->feedback_query->is_in_trash(),
'feedback_collection' => $feedback_collection,
);
return $this->template_service->show( $model, self::TEMPLATE_NAME );
}
/** @return array */
private function parse_request_args() {
$args = array(
'paged' => 1,
'items_per_page' => self::ITEMS_PER_PAGE,
);
if ( isset( $_GET['paged'] ) ) {
$args['paged'] = filter_var( $_GET['paged'], FILTER_SANITIZE_NUMBER_INT );
}
if ( isset( $_GET['order'], $_GET['orderby'] ) ) {
$args['order'] = Sanitize::stringProp( 'order', $_GET );
$args['orderby'] = Sanitize::stringProp( 'orderby', $_GET );
}
if ( isset( $_GET['status'] ) ) {
$args['status'] = Sanitize::stringProp( 'status', $_GET );
} elseif ( isset( $_GET['language'] ) ) {
$args['language'] = Sanitize::stringProp( 'language', $_GET );
}
if ( isset( $_GET['post_id'] ) ) {
$args['post_id'] = filter_var( $_GET['post_id'], FILTER_SANITIZE_NUMBER_INT );
}
return $args;
}
/** @return array */
private function get_strings() {
$strings = array(
'page_title' => __( 'Translation Feedback', 'sitepress' ),
'page_subtitle' => __( 'Issues with translations', 'sitepress' ),
'table_header' => WPML_TF_Backend_Feedback_Row_View::get_columns_strings(),
'screen_reader' => array(
'select_all' => __( 'Select All', 'sitepress' ),
),
'pagination' => array(
'list_navigation' => __( 'Feedback list navigation', 'sitepress' ),
'first_page' => __( 'First page', 'sitepress' ),
'previous_page' => __( 'Previous page', 'sitepress' ),
'next_page' => __( 'Next page', 'sitepress' ),
'last_page' => __( 'Last page', 'sitepress' ),
'current_page' => __( 'Current page', 'sitepress' ),
'of' => __( 'of', 'sitepress' ),
),
'bulk_actions' => array(
'select' => __( 'Select bulk action', 'sitepress' ),
'apply_button' => __( 'Apply', 'sitepress' ),
'options' => array(
'-1' => __( 'Bulk Actions', 'sitepress' ),
'fixed' => __( 'Mark as fixed', 'sitepress' ),
'pending' => __( 'Mark as new', 'sitepress' ),
'trash' => __( 'Move to trash', 'sitepress' ),
),
),
'row_summary' => WPML_TF_Backend_Feedback_Row_View::get_summary_strings(),
'row_details' => WPML_TF_Backend_Feedback_Row_View::get_details_strings(),
'no_feedback' => __( 'No feedback found.', 'sitepress' ),
);
if ( $this->feedback_query->is_in_trash() ) {
$strings['bulk_actions']['options'] = array(
'-1' => __( 'Bulk Actions', 'sitepress' ),
'untrash' => __( 'Restore', 'sitepress' ),
'delete' => __( 'Delete permanently', 'sitepress' ),
);
}
return $strings;
}
/** @return array */
private function get_columns() {
$this->table_sort->set_primary_column( 'feedback' );
return array(
'feedback' => array(
'url' => $this->table_sort->get_column_url( 'feedback' ),
'classes' => $this->table_sort->get_column_classes( 'feedback' ),
),
'rating' => array(
'url' => $this->table_sort->get_column_url( 'rating' ),
'classes' => $this->table_sort->get_column_classes( 'rating' ),
),
'status' => array(
'url' => $this->table_sort->get_column_url( 'status' ),
'classes' => $this->table_sort->get_column_classes( 'status' ),
),
'document_url' => array(
'url' => $this->table_sort->get_column_url( 'document_title' ),
'classes' => $this->table_sort->get_column_classes( 'document_title' ),
),
'date' => array(
'url' => $this->table_sort->get_column_url( 'date' ),
'classes' => $this->table_sort->get_column_classes( 'date' ),
),
);
}
/**
* @param array $args
*
* @return array
*/
private function get_pagination( array $args ) {
$this->pagination->set_total_items( $this->feedback_query->get_filtered_items_count() );
$this->pagination->set_items_per_page( $args['items_per_page'] );
$this->pagination->set_current_page( $args['paged'] );
return array(
'first_page' => $this->pagination->get_first_page_url(),
'previous_page' => $this->pagination->get_previous_page_url(),
'next_page' => $this->pagination->get_next_page_url(),
'last_page' => $this->pagination->get_last_page_url(),
'current_page' => $this->pagination->get_current_page(),
'total_pages' => $this->pagination->get_total_pages(),
'total_items' => sprintf(
_n( '%s item', '%s items', $this->pagination->get_total_items() ),
$this->pagination->get_total_items()
),
);
}
/** @return array */
private function get_page_filters() {
$this->page_filter->populate_counters_and_labels();
return array(
'all_and_trash' => $this->page_filter->get_all_and_trash_data(),
'statuses' => $this->page_filter->get_statuses_data(),
'languages' => $this->page_filter->get_languages_data(),
);
}
/** @return array */
private function get_current_query() {
return array(
'filters' => $this->page_filter->get_current_filters(),
'sorters' => $this->table_sort->get_current_sorters(),
);
}
}

View File

@@ -0,0 +1,98 @@
<?php
/**
* Class WPML_TF_Backend_Feedback_Row_View
*/
class WPML_TF_Backend_Feedback_Row_View {
const TEMPLATE_FOLDER = '/templates/translation-feedback/backend/';
const SUMMARY_TEMPLATE = 'feedback-list-page-table-row.twig';
const DETAILS_TEMPLATE = 'feedback-list-page-table-row-details.twig';
/** @var IWPML_Template_Service $template_service */
private $template_service;
/**
* WPML_TF_Backend_Feedback_Row_View constructor.
*
* @param IWPML_Template_Service $template_service
*/
public function __construct( IWPML_Template_Service $template_service ) {
$this->template_service = $template_service;
}
/** @param WPML_TF_Feedback $feedback */
public function render_summary_row( WPML_TF_Feedback $feedback ) {
$model = array(
'strings' => self::get_summary_strings(),
'has_admin_capabilities' => current_user_can( 'manage_options' ),
'feedback' => $feedback,
);
return $this->template_service->show( $model, self::SUMMARY_TEMPLATE );
}
/** @param WPML_TF_Feedback $feedback */
public function render_details_row( WPML_TF_Feedback $feedback ) {
$model = array(
'strings' => self::get_details_strings(),
'has_admin_capabilities' => current_user_can( 'manage_options' ),
'feedback' => $feedback,
);
return $this->template_service->show( $model, self::DETAILS_TEMPLATE );
}
/** @return array */
public static function get_columns_strings() {
return array(
'feedback' => __( 'Feedback', 'sitepress' ),
'rating' => __( 'Rating', 'sitepress' ),
'status' => __( 'Status', 'sitepress' ),
'document' => __( 'Translated post', 'sitepress' ),
'date' => __( 'Date', 'sitepress' ),
);
}
/** @return array */
public static function get_summary_strings() {
return array(
'select_validation' => __( 'Select Validation', 'sitepress' ),
'inline_actions' => array(
'review' => __( 'Review', 'sitepress' ),
'trash' => __( 'Trash', 'sitepress' ),
'view_post' => __( 'View post', 'sitepress' ),
'untrash' => __( 'Restore', 'sitepress' ),
'delete' => __( 'Delete permanently', 'sitepress' ),
),
'columns' => self::get_columns_strings(),
);
}
/** @return array */
public static function get_details_strings() {
return array(
'title' => __( 'Translation Feedback', 'sitepress' ),
'translation' => __( 'Translation:', 'sitepress' ),
'edit_translation' => __( 'Edit translation', 'sitepress' ),
'original_post' => __( 'Original post:', 'sitepress' ),
'rating' => __( 'Rating:', 'sitepress' ),
'feedback' => __( 'Feedback:', 'sitepress' ),
'edit_feedback' => __( 'Edit feedback', 'sitepress' ),
'status' => __( 'Status:', 'sitepress' ),
'refresh_status' => __( 'Check for updates', 'sitepress' ),
'translated_by' => __( 'Translated by:', 'sitepress' ),
'corrected_by' => __( 'Corrected by:', 'sitepress' ),
'reviewed_by' => __( 'Reviewed by:', 'sitepress' ),
'add_note_to_translator' => __( 'Add a note to the translator', 'sitepress' ),
'add_note_to_admin' => __( 'Add a note to the administrator', 'sitepress' ),
'communication' => __( 'Communication:', 'sitepress' ),
'reply_to_translator_label' => __( 'Reply to translator:', 'sitepress' ),
'reply_to_admin_label' => __( 'Reply to admin:', 'sitepress' ),
'cancel_button' => __( 'Cancel', 'sitepress' ),
'trash_button' => __( 'Trash', 'sitepress' ),
'translation_fixed_button' => __( 'Mark as fixed', 'sitepress' ),
'no_translator_available' => __( 'No translator available for this language pair.', 'sitepress' ),
);
}
}

View File

@@ -0,0 +1,292 @@
<?php
/**
* Class WPML_TF_Backend_Options_View
*
* @author OnTheGoSystems
*/
class WPML_TF_Backend_Options_View {
const TEMPLATE_FOLDER = '/templates/translation-feedback/backend/';
const TEMPLATE = 'options-ui.twig';
const MAX_EXPIRATION_QUANTITY = 10;
/** @var IWPML_Template_Service $template_service */
private $template_service;
/** @var WPML_TF_Settings $settings */
private $settings;
/** @var SitePress $sitepress */
private $sitepress;
/**
* WPML_TF_Frontend_Hooks constructor.
*
* @param IWPML_Template_Service $template_service
* @param WPML_TF_Settings $settings
* @param SitePress $sitepress
*/
public function __construct(
IWPML_Template_Service $template_service,
WPML_TF_Settings $settings,
SitePress $sitepress
) {
$this->template_service = $template_service;
$this->settings = $settings;
$this->sitepress = $sitepress;
}
/**
* @return string
*/
public function render() {
$model = array(
'strings' => self::get_strings(),
'action' => WPML_TF_Backend_Options_AJAX_Hooks_Factory::AJAX_ACTION,
'nonce' => wp_create_nonce( WPML_TF_Backend_Options_AJAX_Hooks_Factory::AJAX_ACTION ),
'module_toggle' => $this->get_module_toggle(),
'button_modes' => $this->get_button_modes(),
'icon_styles' => $this->get_icon_styles(),
'languages_to' => $this->get_languages_to(),
'display_modes' => $this->get_display_modes(),
'expiration_modes' => $this->get_expiration_modes(),
'expiration_quantities' => $this->get_expiration_quantities(),
'expiration_units' => $this->get_expiration_units(),
);
return $this->template_service->show( $model, self::TEMPLATE );
}
/**
* @return array
*/
public static function get_strings() {
return array(
'section_title' => __( 'Translation Feedback', 'sitepress' ),
'button_mode_section_title' => __( 'Translation Feedback button on front-end:', 'sitepress' ),
'icon_style_section_title' => __( 'Icon style:', 'sitepress' ),
'languages_to_section_title' => __( 'Show Translation Feedback module for these languages:', 'sitepress' ),
'expiration_section_title' => __( 'Expiration date for Translation Feedback module:', 'sitepress' ),
);
}
/**
* @return array
*/
private function get_module_toggle() {
return array(
'value' => 1,
'label' => __( 'Enable Translation Feedback module', 'sitepress' ),
'selected' => $this->settings->is_enabled(),
);
}
/**
* @return array
*/
private function get_button_modes() {
$modes = array(
WPML_TF_Settings::BUTTON_MODE_LEFT => array(
'value' => WPML_TF_Settings::BUTTON_MODE_LEFT,
'label' => __( 'Show on the left side of the screen', 'sitepress' ),
'selected' => false,
),
WPML_TF_Settings::BUTTON_MODE_RIGHT => array(
'value' => WPML_TF_Settings::BUTTON_MODE_RIGHT,
'label' => __( 'Show on the right side of the screen', 'sitepress' ),
'selected' => false,
),
WPML_TF_Settings::BUTTON_MODE_CUSTOM => array(
'value' => WPML_TF_Settings::BUTTON_MODE_CUSTOM,
'label' => __( 'I will add it manually (%1$sinstructions%2$s)', 'sitepress' ),
'link' => 'https://wpml.org/wpml-hook/wpml_tf_feedback_open_link/?utm_source=plugin&utm_medium=gui&utm_campaign=wpmlcore',
'selected' => false,
),
WPML_TF_Settings::BUTTON_MODE_DISABLED => array(
'value' => WPML_TF_Settings::BUTTON_MODE_DISABLED,
'label' => __( 'Do not show it', 'sitepress' ),
'selected' => false,
),
);
if ( isset( $modes[ $this->settings->get_button_mode() ] ) ) {
$modes[ $this->settings->get_button_mode() ]['selected'] = true;
}
return $modes;
}
private function get_icon_styles() {
$css_classes = WPML_TF_Frontend_Feedback_View::get_icon_css_classes();
$styles = array(
WPML_TF_Settings::ICON_STYLE_LEGACY => array(
'value' => WPML_TF_Settings::ICON_STYLE_LEGACY,
'image_class' => $css_classes[ WPML_TF_Settings::ICON_STYLE_LEGACY ],
'selected' => false,
),
WPML_TF_Settings::ICON_STYLE_STAR => array(
'value' => WPML_TF_Settings::ICON_STYLE_STAR,
'image_class' => $css_classes[ WPML_TF_Settings::ICON_STYLE_STAR ],
'selected' => false,
),
WPML_TF_Settings::ICON_STYLE_THUMBSUP => array(
'value' => WPML_TF_Settings::ICON_STYLE_THUMBSUP,
'image_class' => $css_classes[ WPML_TF_Settings::ICON_STYLE_THUMBSUP ],
'selected' => false,
),
WPML_TF_Settings::ICON_STYLE_BULLHORN => array(
'value' => WPML_TF_Settings::ICON_STYLE_BULLHORN,
'image_class' => $css_classes[ WPML_TF_Settings::ICON_STYLE_BULLHORN ],
'selected' => false,
),
WPML_TF_Settings::ICON_STYLE_COMMENT => array(
'value' => WPML_TF_Settings::ICON_STYLE_COMMENT,
'image_class' => $css_classes[ WPML_TF_Settings::ICON_STYLE_COMMENT ],
'selected' => false,
),
WPML_TF_Settings::ICON_STYLE_QUOTE => array(
'value' => WPML_TF_Settings::ICON_STYLE_QUOTE,
'image_class' => $css_classes[ WPML_TF_Settings::ICON_STYLE_QUOTE ],
'selected' => false,
),
);
if ( isset( $styles[ $this->settings->get_icon_style() ] ) ) {
$styles[ $this->settings->get_icon_style() ]['selected'] = true;
}
return $styles;
}
/**
* @return array
*/
private function get_languages_to() {
$languages_to = array();
$active_languages = $this->sitepress->get_active_languages();
$allowed_languages = $this->settings->get_languages_to();
if ( null === $allowed_languages ) {
$allowed_languages = array_keys( $active_languages );
}
foreach ( $active_languages as $code => $language ) {
$languages_to[ $code ] = array(
'value' => $code,
'label' => $language['display_name'],
'flag_url' => $this->sitepress->get_flag_url( $code ),
'selected' => false,
);
if ( in_array( $code, $allowed_languages ) ) {
$languages_to[ $code ]['selected'] = true;
}
}
return $languages_to;
}
/**
* @return array
*/
private function get_display_modes() {
$modes = array(
WPML_TF_Settings::DISPLAY_CUSTOM => array(
'value' => WPML_TF_Settings::DISPLAY_CUSTOM,
'label' => esc_html__( 'Ask for feedback about translated content that was %1$s in the last %2$s %3$s', 'sitepress' ),
'selected' => false,
),
WPML_TF_Settings::DISPLAY_ALWAYS => array(
'value' => WPML_TF_Settings::DISPLAY_ALWAYS,
'label' => __( 'Always ask for feedback (no time limit for feedback)', 'sitepress' ),
'selected' => false,
),
);
if ( isset( $modes[ $this->settings->get_display_mode() ] ) ) {
$modes[ $this->settings->get_display_mode() ]['selected'] = true;
}
return $modes;
}
/**
* @return array
*/
private function get_expiration_modes() {
$modes = array(
WPML_TF_Settings::EXPIRATION_ON_PUBLISH_OR_UPDATE => array(
'value' => WPML_TF_Settings::EXPIRATION_ON_PUBLISH_OR_UPDATE,
'label' => __( 'published or updated', 'sitepress' ),
'selected' => false,
),
WPML_TF_Settings::EXPIRATION_ON_PUBLISH_ONLY => array(
'value' => WPML_TF_Settings::EXPIRATION_ON_PUBLISH_ONLY,
'label' => __( 'published', 'sitepress' ),
'selected' => false,
),
WPML_TF_Settings::EXPIRATION_ON_UPDATE_ONLY => array(
'value' => WPML_TF_Settings::EXPIRATION_ON_UPDATE_ONLY,
'label' => __( 'updated', 'sitepress' ),
'selected' => false,
),
);
if ( isset( $modes[ $this->settings->get_expiration_mode() ] ) ) {
$modes[ $this->settings->get_expiration_mode() ]['selected'] = true;
}
return $modes;
}
/**
* @return array
*/
private function get_expiration_quantities() {
$quantities = array();
for ( $i = 1; $i < self::MAX_EXPIRATION_QUANTITY + 1; $i++ ) {
$quantities[ $i ] = array(
'value' => $i,
'selected' => false,
);
}
if ( isset( $quantities[ $this->settings->get_expiration_delay_quantity() ] ) ) {
$quantities[ $this->settings->get_expiration_delay_quantity() ]['selected'] = true;
}
return $quantities;
}
/**
* @return array
*/
private function get_expiration_units() {
$units = array(
WPML_TF_Settings::DELAY_DAY => array(
'value' => WPML_TF_Settings::DELAY_DAY,
'label' => __( 'day(s)', 'sitepress' ),
'selected' => false,
),
WPML_TF_Settings::DELAY_WEEK => array(
'value' => WPML_TF_Settings::DELAY_WEEK,
'label' => __( 'week(s)', 'sitepress' ),
'selected' => false,
),
WPML_TF_Settings::DELAY_MONTH => array(
'value' => WPML_TF_Settings::DELAY_MONTH,
'label' => __( 'month(s)', 'sitepress' ),
'selected' => false,
),
);
if ( isset( $units[ $this->settings->get_expiration_delay_unit() ] ) ) {
$units[ $this->settings->get_expiration_delay_unit() ]['selected'] = true;
}
return $units;
}
}

View File

@@ -0,0 +1,159 @@
<?php
/**
* Class WPML_TF_Frontend_Feedback_View
*
* @author OnTheGoSystems
*/
class WPML_TF_Frontend_Feedback_View {
const TEMPLATE_FOLDER = '/templates/translation-feedback/frontend/';
const FORM_TEMPLATE = 'feedback-form.twig';
const OPEN_TEMPLATE = 'feedback-open-button.twig';
const CUSTOM_OPEN_LINK_TEMPLATE = 'feedback-custom-open-link.twig';
const JS_OPEN_NODE_CLASS = 'js-wpml-tf-feedback-icon';
/** @var IWPML_Template_Service $template_service */
private $template_service;
/** @var SitePress $sitepress */
private $sitepress;
/** @var WPML_Queried_Object $queried_object */
private $queried_object;
/** @var WPML_TF_Settings $settings */
private $settings;
/**
* WPML_TF_Frontend_Hooks constructor.
*
* @param IWPML_Template_Service $template_service
* @param SitePress $sitepress
* @param WPML_Queried_Object $queried_object
* @param WPML_TF_Settings $settings
*/
public function __construct(
IWPML_Template_Service $template_service,
SitePress $sitepress,
WPML_Queried_Object $queried_object,
WPML_TF_Settings $settings
) {
$this->template_service = $template_service;
$this->sitepress = $sitepress;
$this->queried_object = $queried_object;
$this->settings = $settings;
}
/**
* @return string
*/
public function render_form() {
$model = array(
'strings' => array(
'dialog_title' => __( 'Rate translation', 'sitepress' ),
'thank_you_rating' => __( 'Thank you for your rating!', 'sitepress' ),
'thank_you_comment' => __( 'Thank you for your rating and comment!', 'sitepress' ),
'translated_from' => __( 'This page was translated from:', 'sitepress' ),
'please_rate' => __( 'Please rate this translation:', 'sitepress' ),
'your_rating' => __( 'Your rating:', 'sitepress' ),
'star5_title' => __( 'It is perfect!', 'sitepress' ),
'star4_title' => __( 'It is OK', 'sitepress' ),
'star3_title' => __( 'It could be improved', 'sitepress' ),
'star2_title' => __( 'I can see a lot of language errors', 'sitepress' ),
'star1_title' => __( "I can't understand anything", 'sitepress' ),
'change_rating' => __( 'Change', 'sitepress' ),
'error_examples' => __( 'Please give some examples of errors and how would you improve them:', 'sitepress' ),
'send_button' => __( 'Send', 'sitepress' ),
'honeypot_label' => __( 'If you are a human, do not fill in this field.', 'sitepress' ),
),
'flag_url' => $this->sitepress->get_flag_url( $this->queried_object->get_source_language_code() ),
'language_name' => $this->sitepress->get_display_language_name( $this->queried_object->get_source_language_code() ),
'document_id' => $this->queried_object->get_id(),
'document_type' => $this->queried_object->get_element_type(),
'action' => WPML_TF_Frontend_AJAX_Hooks_Factory::AJAX_ACTION,
'nonce' => wp_create_nonce( WPML_TF_Frontend_AJAX_Hooks_Factory::AJAX_ACTION ),
'source_url' => $this->queried_object->get_source_url(),
);
return $this->template_service->show( $model, self::FORM_TEMPLATE );
}
/**
* @return string
*/
public function render_open_button() {
$rendering = '';
if ( WPML_TF_Settings::BUTTON_MODE_CUSTOM !== $this->settings->get_button_mode() ) {
$model = array(
'strings' => array(
'form_open_title' => __( 'Rate translation of this page', 'sitepress' ),
),
'wrapper_css_classes' => $this->get_wrapper_css_classes(),
'icon_css_class' => $this->get_icon_css_class(),
);
$rendering = $this->template_service->show( $model, self::OPEN_TEMPLATE );
}
return $rendering;
}
/** @return string */
private function get_wrapper_css_classes() {
$base_classes = self::JS_OPEN_NODE_CLASS . ' wpml-tf-feedback-icon ';
$class = $base_classes . 'wpml-tf-feedback-icon-left';
if ( WPML_TF_Settings::BUTTON_MODE_RIGHT === $this->settings->get_button_mode() ) {
$class = $base_classes . 'wpml-tf-feedback-icon-right';
}
return $class;
}
/** @return string */
private function get_icon_css_class() {
$icon_style = $this->settings->get_icon_style();
$css_classes = self::get_icon_css_classes();
if ( array_key_exists( $icon_style, $css_classes ) ) {
return $css_classes[ $icon_style ];
}
return $css_classes[ WPML_TF_Settings::ICON_STYLE_LEGACY ];
}
/**
* @param string|array $args
*
* @return string
*/
public function render_custom_open_link( $args ) {
$model = wp_parse_args( $args, self::get_default_arguments_for_open_link() );
$model['classes'] = self::JS_OPEN_NODE_CLASS . ' ' . $model['classes'];
return $this->template_service->show( $model, self::CUSTOM_OPEN_LINK_TEMPLATE );
}
/** @return array */
public static function get_default_arguments_for_open_link() {
return array(
'title' => __( 'Rate translation of this page', 'sitepress' ),
'classes' => 'wpml-tf-feedback-custom-link',
);
}
/** @return array */
public static function get_icon_css_classes() {
return array(
WPML_TF_Settings::ICON_STYLE_LEGACY => 'otgs-ico-translation',
WPML_TF_Settings::ICON_STYLE_STAR => 'otgs-ico-star',
WPML_TF_Settings::ICON_STYLE_THUMBSUP => 'otgs-ico-thumbsup',
WPML_TF_Settings::ICON_STYLE_BULLHORN => 'otgs-ico-bullhorn',
WPML_TF_Settings::ICON_STYLE_COMMENT => 'otgs-ico-comment',
WPML_TF_Settings::ICON_STYLE_QUOTE => 'otgs-ico-quote',
);
}
}