is_tm_dashboard = $is_tm_dashboard; } public function add_hooks() { add_action( 'admin_notices', array( $this, 'welcome_notice' ) ); add_action( 'init', array( $this, 'track_documentation_visit' ) ); add_action( 'admin_head', array( $this, 'enqueue_res' ) ); add_action( 'wp_ajax_' . self::DISMISS_ACTION, array( $this, 'dismiss' ) ); add_action( 'wp_ajax_' . self::TOGGLE_ACTION, array( $this, 'toggle' ) ); } public function enqueue_res() { wp_enqueue_script( 'wpml-media-welcome-notice', WPML_MEDIA_URL . '/res/js/menu/welcome-notice.js', array( 'jquery' ), false, true ); wp_localize_script( 'wpml-media-welcome-notice', 'wpmlMediaWelcomeNotice', array( 'dismissAjaxAction' => self::DISMISS_ACTION, 'toggleAjaxAction' => self::TOGGLE_ACTION, 'nonce' => wp_create_nonce( self::NONCE_KEY ), ) ); wp_enqueue_style( 'wpml-media-welcome-notice', WPML_MEDIA_URL . '/res/css/welcome-notice.css' ); } public function track_documentation_visit() { if ( isset( $_GET['action'] ) && self::ACKNOWLEDGE_ACTION === $_GET['action'] ) { if ( isset( $_GET['nonce'] ) && wp_create_nonce( self::NONCE_KEY ) === $_GET['nonce'] ) { $this->acknowledge(); } wp_redirect( $_GET['redirect_to'] ); } } public function welcome_notice() { $url = admin_url( add_query_arg( array( 'action' => self::ACKNOWLEDGE_ACTION, 'nonce' => wp_create_nonce( self::NONCE_KEY ), 'redirect_to' => self::DOC_URL ), 'index.php' ) ); $link = '' . esc_html__( 'Media Translation documentation', 'wpml-media' ) . ''; $button = '' . esc_html__( 'Learn more', 'wpml-media' ) . ''; if ( $this->is_new_install() ) { $title = esc_html__( 'Learn how to translate media', 'wpml-media' ); $body1 = esc_html__( 'WPML allows you to use different media (images, etc.) for translated content. The Media Translation process is integrated with WPML’s content translation, but requires additional steps.', 'wpml-media' ); $body2 = sprintf( esc_html__( 'Before you start, we highly recommend that you review the %s. Then, you’ll be able to close this message.', 'wpml-media' ), $link ); } else { $title = esc_html__( 'Media Translation is completely different now', 'wpml-media' ); $body1 = esc_html__( 'This release of Media Translation includes a complete new workflow, with complete new features and possibilities.', 'wpml-media' ); $body2 = sprintf( esc_html__( 'Even if you’re already familiar with WPML, you should read the new %s. Then, you’ll be able to close this message.', 'wpml-media' ), $link ); } $minimize_label = esc_html__( 'Minimize', 'wpml-media' ); $maximize_label = esc_html__( 'Maximize', 'wpml-media' ); $is_minimized = $this->is_minimized(); ?>

is_tm_dashboard ): ?>
self::ACKNOWLEDGED ); } else { $meta['status'] = self::ACKNOWLEDGED; } update_user_meta( $user_id, self::USER_META, $meta ); } public function dismiss() { if ( isset( $_POST['nonce'] ) && $_POST['nonce'] === wp_create_nonce( self::NONCE_KEY ) ) { $user_id = get_current_user_id(); $meta = get_user_meta( $user_id, self::USER_META, true ); $meta['status'] = self::DISMISSED; update_user_meta( $user_id, self::USER_META, $meta ); } } private function is_new_install() { return ! get_option( 'wpml_media_upgraded_from_prior_2_3_0' ); } private function is_minimized() { $meta = get_user_meta( get_current_user_id(), self::USER_META, true ); return isset( $meta ) && ! empty( $meta['minimized'] ); } public function toggle() { if ( isset( $_POST['nonce'] ) && $_POST['nonce'] === wp_create_nonce( self::NONCE_KEY ) ) { $user_id = get_current_user_id(); $meta = get_user_meta( $user_id, self::USER_META, true ); if ( empty( $meta ) ) { $meta = array( 'minimized' => 1 ); } else { $meta['minimized'] = (int) ( empty( $meta['minimized'] ) && 1 ); } update_user_meta( $user_id, self::USER_META, $meta ); } } }