sitepress = $sitepress; } public function add_hooks() { if ( $this->is_wpml_media_screen() ) { add_filter( 'wpml_media_menu_overrides', array( $this, 'override_default_menu' ) ); } else { add_action( 'admin_head', array( $this, 'add_top_notice' ) ); } add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_js' ) ); } public function override_default_menu( $menu_elements ) { $menu_elements[] = array( $this, 'render_menu' ); return $menu_elements; } public function enqueue_js() { $wpml_media_url = $this->sitepress->get_wp_api()->constant( 'WPML_MEDIA_URL' ); wp_enqueue_script( 'wpml-media-setup', $wpml_media_url . '/res/js/wpml-media-posts-media-flag.js', array( 'jquery' ), false, true ); } private function is_wpml_media_screen() { return isset( $_GET['page'] ) && 'wpml-media' === $_GET['page']; } public function add_top_notice() { /* translators: name ot WPML-Media plugin */ $wpml_media = '' . __( 'WPML Media Translation', 'wpml-media' ) . ''; /* translators: used to build a link in the "Click here to finish the setup" */ $here_text = _x( 'here', 'Used to build a link in the "Click here to finish the setup"', 'wpml-media' ); $here_link = '' . $here_text . ''; /* translators: %1$s will be replaced with a translation of "WPML Media Translation", while %2$s is a link with the translation of the word "here" */ $text = vsprintf( esc_html__( 'The %1$s setup is almost complete. Click %2$s to finish the setup.', 'wpml-media' ), array( $wpml_media, $here_link ) ); $notice = new WPML_Notice( self::NOTICE_ID, $text, self::NOTICE_GROUP ); $notice->set_css_class_types( 'notice-warning' ); $notice->set_hideable( false ); $notice->set_dismissible( false ); $notice->set_collapsable( false ); $notice->add_exclude_from_page( 'wpml-media' ); $notice->add_capability_check( array( 'manage_options' ) ); $wpml_admin_notices = wpml_get_admin_notices(); $wpml_admin_notices->add_notice( $notice ); } public function render_menu() { ?>