HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/delta/wp-content/plugins/sitepress-multilingual-cms/classes/admin-bar/Hooks.php
<?php

namespace WPML\TM\AdminBar;

class Hooks implements \IWPML_Frontend_Action, \IWPML_DIC_Action {

	/** @var \WPML_Post_Translation */
	private $postTranslations;

	public function __construct( \WPML_Post_Translation $postTranslations ) {
		$this->postTranslations = $postTranslations;
	}

	public function add_hooks() {
		if ( is_user_logged_in() ) {
			add_action( 'admin_bar_menu', [ $this, 'addTranslateMenuItem' ], 80 );
			add_action( 'wp_enqueue_scripts', [ $this, 'enqueueScripts' ] );
		}
	}

	public function addTranslateMenuItem( \WP_Admin_Bar $wpAdminMenu ) {
		global $wp_the_query;

		$queriedObject = $wp_the_query->get_queried_object();

		if ( ! empty( $queriedObject ) && ! empty( $queriedObject->post_type ) ) {
			wpml_tm_load_status_display_filter();

			$trid = $this->postTranslations->get_element_trid( $queriedObject->ID );
			if ( $trid ) {
				$originalID = $this->postTranslations->get_original_post_ID( $trid );
				$lang       = $this->postTranslations->get_element_lang_code( $queriedObject->ID );

				$translateLink = apply_filters( 'wpml_link_to_translation', '', $originalID, $lang, $trid );

				if ( $translateLink ) {
					$img = '<img class="ab-icon" src="' . ICL_PLUGIN_URL . '/res/img/icon16.svg">';
					$wpAdminMenu->add_menu(
						[
							'id'    => 'translate',
							'title' => $img . __( 'Edit Translation', 'wpml-translation-management' ),
							'href'  => admin_url() . $translateLink,
						]
					);
				}
			}
		}
	}

	public function enqueueScripts() {
		wp_enqueue_style( 'wpml-tm-admin-bar', WPML_TM_URL . '/res/css/admin-bar-style.css', array(), ICL_SITEPRESS_SCRIPT_VERSION );
	}
}