sprintf( '%s', esc_url( get_support_url( 'plugin-list' ) ), esc_html__( 'Support', 'double-opt-in' ) ), 'f12_doi_feedback' => sprintf( '%s', esc_url( get_feedback_url( 'plugin-list' ) ), esc_html__( 'Feedback', 'double-opt-in' ) ), ); // Appended rather than prepended: Deactivate and Settings are what someone // opened this row for. return array_merge( $links, $own ); } if ( defined( 'FORGE12_OPTIN_BASENAME' ) ) { add_filter( 'plugin_action_links_' . FORGE12_OPTIN_BASENAME, __NAMESPACE__ . '\add_plugin_action_links' ); } /** * Add a Feedback & Support entry to the plugin's admin menu. * * add_submenu_page() cannot point at an external address, so the entry is * registered normally and its href rewritten afterwards. */ function add_feedback_menu_item(): void { $slug = 'f12-doi-feedback'; add_submenu_page( 'f12-doi-admin', __( 'Feedback', 'double-opt-in' ), __( 'Feedback & Support', 'double-opt-in' ), 'manage_options', $slug, '__return_null' ); point_menu_item_at( $slug, get_feedback_url( 'admin-menu' ) ); } /** * Send a registered submenu entry to an external address, and open it in a new tab. * * The URL travels as a JSON string literal and is compared against the * attribute value rather than being interpolated into a selector: escaping it * for a selector HTML-encodes the ampersands in the query string, so the * selector would ask for `…&from=…` while the anchor carries `…&from=…`, * match nothing, and quietly open in the same tab. Throwing an admin out of * their dashboard on the way to a bug report is a good way to lose the report. * * @param string $slug The slug the entry was registered under. * @param string $url Where it should actually go. */ function point_menu_item_at( string $slug, string $url ): void { global $submenu; if ( ! isset( $submenu['f12-doi-admin'] ) || ! is_array( $submenu['f12-doi-admin'] ) ) { return; } foreach ( $submenu['f12-doi-admin'] as $index => $item ) { if ( isset( $item[2] ) && $item[2] === $slug ) { $submenu['f12-doi-admin'][ $index ][2] = $url; break; } } add_action( 'admin_footer', function () use ( $url ) { ?>