is_this_plugin( $file ) ) { return $links; } $plugin_links = array( sprintf( /* translators: 1: Open anchor tag, 2: Close anchor tag. */ esc_html_x( '%1$sDocs%2$s', 'plugin link', 'woo-additional-terms' ), sprintf( '', esc_url( Helper\Links::docs_uri() ) ), '' ), sprintf( /* translators: 1: Open anchor tag, 2: Close anchor tag. */ esc_html_x( '%1$sCommunity support%2$s', 'plugin link', 'woo-additional-terms' ), sprintf( '', esc_attr( woo_additional_terms()->get_slug() ) ), '' ), ); return array_merge( $links, $plugin_links ); } /** * Display additional links in the plugin table page. * Filters the list of action links displayed for a specific plugin in the Plugins list table. * * @since 1.0.0 * * @param array $links Plugin table/item action links. * @param string $file Path to the plugin file relative to the plugins' directory. * * @return array */ public function action_links( $links, $file ) { // Leave early if the filter is not for this plugin. if ( ! $this->is_this_plugin( $file ) ) { return $links; } $plugin_links = array(); $plugin_links[] = sprintf( /* translators: 1: Open anchor tag, 2: Close anchor tag. */ esc_html_x( '%1$sUpgrade to Pro%2$s', 'plugin link', 'woo-additional-terms' ), sprintf( '✅ ', esc_url( Helper\Links::pro_uri() ) ), '' ); if ( current_user_can( 'manage_woocommerce' ) ) { $plugin_links[] = sprintf( /* translators: 1: Open anchor tag, 2: Close anchor tag. */ esc_html_x( '%1$sSettings%2$s', 'plugin settings page', 'woo-additional-terms' ), sprintf( '', esc_url( Helper\Settings::page_uri() ) ), '' ); } return array_merge( $plugin_links, $links ); } /** * Check if the current plugin is the one we are looking for. * * @since 1.0.0 * * @param string $file Path to the plugin file relative to the plugins' directory. * * @return bool */ private function is_this_plugin( $file ) { return woo_additional_terms()->service( 'file' )->plugin_basename() === $file; } }