first commit
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TF_Backend_Notices
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TF_Backend_Notices {
|
||||
|
||||
const GROUP = 'wpml_tf_backend_notices';
|
||||
const BULK_UPDATED = 'bulk_updated';
|
||||
|
||||
/** @var WPML_Notices $admin_notices */
|
||||
private $admin_notices;
|
||||
|
||||
/**
|
||||
* @param array $updated_feedback_ids
|
||||
* @parem string
|
||||
*/
|
||||
public function add_bulk_updated_notice( array $updated_feedback_ids, $action ) {
|
||||
$count_feedback = count( $updated_feedback_ids );
|
||||
|
||||
$message = _n( '%d feedback was updated.', '%d feedback were updated.', $count_feedback, 'sitepress' );
|
||||
|
||||
if ( 'trash' === $action ) {
|
||||
$permanent_trash_delay = defined( 'EMPTY_TRASH_DAYS' ) ? EMPTY_TRASH_DAYS : 30;
|
||||
|
||||
$message = _n( '%d feedback was trashed.', '%d feedback were trashed.', $count_feedback, 'sitepress' );
|
||||
$message .= ' ' . sprintf(
|
||||
__( 'The trashed feedback will be permanently deleted after %d days.', 'sitepress' ),
|
||||
$permanent_trash_delay
|
||||
);
|
||||
} elseif ( 'untrash' === $action ) {
|
||||
$message = _n( '%d feedback was restored.', '%d feedback were restored.', $count_feedback, 'sitepress' );
|
||||
} elseif ( 'delete' === $action ) {
|
||||
$message = _n( '%d feedback was permanently deleted.', '%d feedback were permanently deleted.', $count_feedback, 'sitepress' );
|
||||
}
|
||||
|
||||
$text = sprintf( $message, $count_feedback );
|
||||
|
||||
$new_notice = $this->get_admin_notices()->get_new_notice( self::BULK_UPDATED, $text, self::GROUP );
|
||||
$new_notice->set_hideable( true );
|
||||
$new_notice->set_css_class_types( 'notice-success' );
|
||||
$this->get_admin_notices()->add_notice( $new_notice );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add action to remove updated notice after display
|
||||
*/
|
||||
public function remove_bulk_updated_notice_after_display() {
|
||||
add_action( 'admin_notices', array( $this, 'remove_bulk_updated_notice' ), PHP_INT_MAX );
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove bulk_updated notice
|
||||
*/
|
||||
public function remove_bulk_updated_notice() {
|
||||
$this->get_admin_notices()->remove_notice( self::GROUP, self::BULK_UPDATED );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return WPML_Notices
|
||||
*/
|
||||
private function get_admin_notices() {
|
||||
if ( ! $this->admin_notices ) {
|
||||
$this->admin_notices = wpml_get_admin_notices();
|
||||
}
|
||||
|
||||
return $this->admin_notices;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WPML_TF_Promote_Notices
|
||||
*
|
||||
* @author OnTheGoSystems
|
||||
*/
|
||||
class WPML_TF_Promote_Notices {
|
||||
|
||||
const NOTICE_GROUP = 'wpml-tf-promote';
|
||||
const NOTICE_NEW_SITE = 'notice-new-site';
|
||||
const DOC_URL = 'https://wpml.org/documentation/getting-started-guide/getting-visitor-feedback-about-your-sites-translations/?utm_source=plugin&utm_medium=gui&utm_campaign=wpmlcore';
|
||||
|
||||
/** @var SitePress $sitepress */
|
||||
private $sitepress;
|
||||
|
||||
public function __construct( SitePress $sitepress ) {
|
||||
$this->sitepress = $sitepress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $user_id
|
||||
*/
|
||||
public function show_notice_for_new_site( $user_id ) {
|
||||
$notices = wpml_get_admin_notices();
|
||||
$settings_url = admin_url( '?page=' . WPML_PLUGIN_FOLDER . '/menu/languages.php#wpml-translation-feedback-options' );
|
||||
|
||||
$user_lang = $this->sitepress->get_user_admin_language( $user_id );
|
||||
$this->sitepress->switch_lang( $user_lang );
|
||||
|
||||
$text = '<h2>' . __( 'Want to know if recent translations you received have problems?', 'sitepress' ) . '</h2>';
|
||||
$text .= '<p>';
|
||||
$text .= __( 'You got back several jobs from translation and they now appear on your site.', 'sitepress' );
|
||||
$text .= ' ' . __( 'WPML lets you open these pages for feedback, so that visitors can tell you if they notice anything wrong.', 'sitepress' );
|
||||
$text .= '<br><br>';
|
||||
$text .= '<a href="' . $settings_url . '" class="button-secondary">' . __( 'Enable Translation Feedback', 'sitepress' ) . '</a>';
|
||||
$text .= ' <a href="' . self::DOC_URL . '" target="_blank">' . __( 'Learn more about translation feedback', 'sitepress' ) . '</a>';
|
||||
$text .= '</p>';
|
||||
|
||||
$notice = $notices->get_new_notice( self::NOTICE_NEW_SITE, $text, self::NOTICE_GROUP );
|
||||
$notice->set_dismissible( true );
|
||||
$notice->set_css_class_types( 'notice-info' );
|
||||
$notice->add_user_restriction( $user_id );
|
||||
|
||||
if ( ! $notices->is_notice_dismissed( $notice ) ) {
|
||||
$notices->add_notice( $notice );
|
||||
}
|
||||
|
||||
$this->sitepress->switch_lang( null );
|
||||
}
|
||||
|
||||
public function remove() {
|
||||
$notices = wpml_get_admin_notices();
|
||||
$notices->remove_notice( self::NOTICE_GROUP, self::NOTICE_NEW_SITE );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user