devlab_menu_exists() ) { add_menu_page( __( 'DevLab', 'devlab-tag-dock' ), __( 'DevLab', 'devlab-tag-dock' ), 'manage_options', 'devlab', array( $this, 'render_page' ), 'dashicons-shield-alt', 80 ); $this->owns_parent_menu = true; } $this->hook_suffix = (string) add_submenu_page( 'devlab', __( 'Tag Dock', 'devlab-tag-dock' ), __( 'Tag Dock', 'devlab-tag-dock' ), 'manage_options', self::PAGE_SLUG, array( $this, 'render_page' ) ); } /** * Removes the duplicate "DevLab" sub-item that WordPress adds to a new * top-level menu. Runs after the sub-item exists, and only when this * plugin created the menu. * * @return void */ public function cleanup_parent_menu() { if ( $this->owns_parent_menu ) { remove_submenu_page( 'devlab', 'devlab' ); } } /** * Whether another DevLab plugin already registered the top-level menu. * * @return bool */ private function devlab_menu_exists() { global $menu; if ( ! is_array( $menu ) ) { return false; } foreach ( $menu as $item ) { if ( isset( $item[2] ) && 'devlab' === $item[2] ) { return true; } } return false; } /** * Whether the screen being displayed is this plugin's settings screen. * * @param string $hook_suffix Current admin page hook suffix. * @return bool */ private function is_plugin_screen( $hook_suffix ) { return '' !== $this->hook_suffix && $this->hook_suffix === $hook_suffix; } /** * Whether the one-time notice should be shown to the current user. * * @return bool */ private function notice_is_visible() { return current_user_can( 'manage_options' ) && ! get_user_meta( get_current_user_id(), self::NOTICE_META, true ); } /** * Loads the CSS (and the dismiss script) on this plugin's screen only. * * @param string $hook_suffix Current admin page hook suffix. * @return void */ public function enqueue_assets( $hook_suffix ) { if ( ! $this->is_plugin_screen( $hook_suffix ) ) { return; } wp_enqueue_style( 'devlab-hfs-admin', DEVLAB_HFS_URL . 'assets/css/admin.css', array(), DEVLAB_HFS_VERSION ); if ( $this->notice_is_visible() ) { wp_enqueue_script( 'devlab-hfs-admin', DEVLAB_HFS_URL . 'assets/js/admin.js', array(), DEVLAB_HFS_VERSION, true ); wp_localize_script( 'devlab-hfs-admin', 'devlabHfs', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( self::NOTICE_NONCE ), ) ); } } /** * Builds a link to the DevLab store with the campaign parameters. * * @param string $content Identifies which link was clicked (utm_content). * @return string Unescaped URL; escape with esc_url() on output. */ public function utm_url( $content ) { return add_query_arg( array( 'utm_source' => 'wporg', 'utm_medium' => 'plugin', 'utm_campaign' => DEVLAB_HFS_SLUG, 'utm_content' => $content, ), 'https://devlab.ia.br/store/' ); } /** * Prints the single, dismissible notice. It is limited to this plugin's own * screen and only says what the linked page really offers. * * @return void */ public function maybe_show_notice() { $screen = get_current_screen(); if ( ! $screen || ! $this->is_plugin_screen( $screen->id ) || ! $this->notice_is_visible() ) { return; } ?>

403 ) ); } $devlab_hfs_settings = DevLab_HFS_Settings::get(); $devlab_hfs_can_edit = DevLab_HFS_Settings::user_can_edit(); require DEVLAB_HFS_DIR . 'admin/views/settings-page.php'; } }