sitepress = $sitepress; } public function show_notice_for_old_site() { $notices = wpml_get_admin_notices(); $settings_url = admin_url( '?page=' . WPML_PLUGIN_FOLDER . '/menu/languages.php#wpml-translation-feedback-options' ); $main_text = sprintf( __( 'With WPML 3.8.0, you can now get visitor feedback for your translations (%slearn more%s).', 'sitepress' ), '', '' ); $text = '

' . $main_text . '

'; $text .= '

'; $text .= __( 'Enable and configure the "Translation Feedback" feature', 'sitepress' ); $text .= '

'; $notice = $notices->get_new_notice( self::NOTICE_OLD_SITE, $text, self::NOTICE_GROUP ); $notice->set_dismissible( true ); $notice->set_css_class_types( 'notice-info' ); $notice->add_display_callback( array( 'WPML_TF_Promote_Notices', 'show_only_for_admin_users' ) ); if ( ! $notices->is_notice_dismissed( $notice ) ) { $notices->add_notice( $notice ); } } /** * @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 = '

' . __( 'Want to know if recent translations you received have problems?', 'sitepress' ) . '

'; $text .= '

'; $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 .= '

'; $text .= '' . __( 'Enable Translation Feedback', 'sitepress' ) . ''; $text .= ' ' . __( 'Learn more about translation feedback', 'sitepress' ) . ''; $text .= '

'; $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_OLD_SITE ); $notices->remove_notice( self::NOTICE_GROUP, self::NOTICE_NEW_SITE ); } /** @return bool */ public static function show_only_for_admin_users() { return current_user_can( 'manage_options' ); } }