current_shown_item = isset( $_GET['sm'] ) ? $_GET['sm'] : $this->get_default_tab(); $this->base_target_url = dirname( __FILE__ ); } public function display_main( WPML_UI_Screen_Options_Pagination $dashboard_pagination = null ) { $this->dashboard_pagination = $dashboard_pagination; if ( true !== apply_filters( 'wpml_tm_lock_ui', false ) ) { $this->render_main(); } } abstract protected function render_main(); private function build_tab_item_target_url($target) { return $this->base_target_url . $target; } abstract protected function build_tab_items(); /** * @return string */ private function get_current_shown_item() { return $this->current_shown_item; } private function build_tabs() { $tm_sub_menu = $this->get_current_shown_item(); foreach ($this->tab_items as $id => $tab_item) { if (!isset($tab_item['caption'])) { continue; } if (!isset($tab_item['target']) && !isset($tab_item['callback'])) { continue; } $caption = $tab_item['caption']; if ( ! $this->current_user_can_access( $tab_item )) { continue; } $classes = array( 'nav-tab' ); if ($tm_sub_menu == $id) { $classes[] = 'nav-tab-active'; } $class = implode(' ', $classes); $href = 'admin.php?page=' . WPML_TM_FOLDER . $this->get_page_slug() . '&sm=' . $id; ?> get_current_shown_item(); foreach ($this->tab_items as $id => $tab_item) { if (!isset($tab_item['caption'])) { continue; } if (!isset($tab_item['target']) && !isset($tab_item['callback'])) { continue; } if ($tm_sub_menu == $id) { if ( $this->current_user_can_access( $tab_item ) ) { if ( isset( $tab_item['target'] ) ) { $target = $tab_item['target']; /** @noinspection PhpIncludeInspection */ include_once $this->build_tab_item_target_url( $target ); } if ( isset( $tab_item['callback'] ) ) { $callback = $tab_item['callback']; call_user_func( $callback ); } } } } do_action('icl_tm_menu_' . $tm_sub_menu); } protected function render_items() { if ($this->tab_items) { ?>