sitepress = $sitepress; $this->endpoints = $endpoints; $this->auth = $auth; $this->ams_api = $ams_api; } /** * Returns a value which will be used for sorting the sections. * * @return int */ public function get_order() { return self::TAB_ORDER; } /** * Returns the unique slug of the sections which is used to build the URL for opening this section. * * @return string */ public function get_slug() { return self::SLUG; } /** * Returns one or more capabilities required to display this section. * * @return string|array */ public function get_capabilities() { return array( WPML_Manage_Translations_Role::CAPABILITY, 'manage_options' ); } /** * Returns the caption to display in the section. * * @return string */ public function get_caption() { return __( 'Translation Tools', 'wpml-translation-management' ); } /** * Returns the callback responsible for rendering the content of the section. * * @return callable */ public function get_callback() { return array( $this, 'render' ); } /** * Used to extend the logic for displaying/hiding the section. * * @return bool */ public function is_visible() { return true; } /** * Outputs the content of the section. */ public function render() { echo '
'; } /** * This method is hooked to the `admin_enqueue_scripts` action. * * @param string $hook The current page. */ public function admin_enqueue_scripts( $hook ) { if ( ! $this->is_ate_console_tab() ) { return; } $script_url = \add_query_arg( [ \WPML\ATE\Proxies\Widget::QUERY_VAR_ATE_WIDGET_SCRIPT => \WPML\ATE\Proxies\Widget::SCRIPT_NAME, ], \site_url() ); \wp_enqueue_script( self::ATE_APP_ID, $script_url, [], WPML_TM_VERSION, true ); } /** * It returns true if the current page and tab are the ATE Console. * * @return bool */ private function is_ate_console_tab() { $sm = filter_input( INPUT_GET, 'sm', FILTER_SANITIZE_STRING ); $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING ); return $sm && $page && self::SLUG === $sm && WPML_TM_FOLDER . '/menu/main.php' === $page; } /** * It returns the list of all translatable post types. * * @return array */ private function get_post_types_data() { $translatable_types = $this->sitepress->get_translatable_documents( true ); $data = []; if ( $translatable_types ) { foreach ( $translatable_types as $name => $post_type ) { $data[ esc_js( $name ) ] = [ 'labels' => [ 'name' => esc_js( $post_type->labels->name ), 'singular_name' => esc_js( $post_type->labels->singular_name ), ], 'description' => esc_js( $post_type->description ), ]; } } return $data; } /** * It returns the current user's language. * * @return string */ private function get_user_admin_language() { return $this->sitepress->get_user_admin_language( wp_get_current_user()->ID ); } /** * @return array