| @@ -1,0 +1,69 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Admin Plugins | |
| 4 | + * | |
| 5 | + * @package GamiPress\Admin\Plugins | |
| 6 | + * @author GamiPress <[email protected]>, Ruben Garcia <[email protected]> | |
| 7 | + * @since 1.1.0 | |
| 8 | + */ | |
| 9 | +// Exit if accessed directly | |
| 10 | +if( !defined( 'ABSPATH' ) ) exit; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * Plugins row action links | |
| 14 | + * | |
| 15 | + * @since 1.1.0 | |
| 16 | + * @updated 1.4.9.2 Added support for multisite URL when GamiPress is network wide active | |
| 17 | + * | |
| 18 | + * @param array $links Array of plugin action links | |
| 19 | + * @param string $file Plugin file | |
| 20 | + * | |
| 21 | + * @return array $links | |
| 22 | + */ | |
| 23 | +function gamipress_plugin_action_links( $links, $file ) { | |
| 24 | + | |
| 25 | + if ( $file != 'gamipress/gamipress.php' ) | |
| 26 | + return $links; | |
| 27 | + | |
| 28 | + if( gamipress_is_network_wide_active() && ! is_main_site() ) { | |
| 29 | + // Set settings link to main site | |
| 30 | + $settings_link = '<a href="' . get_admin_url( get_main_site_id(), 'admin.php?page=gamipress_settings' ) . '">' . esc_html__( 'Settings', 'gamipress' ) . '</a>'; | |
| 31 | + } else { | |
| 32 | + // Set settings link to current site | |
| 33 | + $settings_link = '<a href="' . admin_url( 'admin.php?page=gamipress_settings' ) . '">' . esc_html__( 'Settings', 'gamipress' ) . '</a>'; | |
| 34 | + } | |
| 35 | + | |
| 36 | + array_unshift( $links, $settings_link ); | |
| 37 | + | |
| 38 | + return $links; | |
| 39 | + | |
| 40 | +} | |
| 41 | +add_filter( 'plugin_action_links', 'gamipress_plugin_action_links', 10, 2 ); | |
| 42 | + | |
| 43 | + | |
| 44 | +/** | |
| 45 | + * Plugin row meta links | |
| 46 | + * | |
| 47 | + * @since 1.1.0 | |
| 48 | + * | |
| 49 | + * @param array $input Array of plugin meta links | |
| 50 | + * @param string $file Plugin file | |
| 51 | + * | |
| 52 | + * @return array $input | |
| 53 | + */ | |
| 54 | +function gamipress_plugin_row_meta( $input, $file ) { | |
| 55 | + | |
| 56 | + if ( $file != 'gamipress/gamipress.php' ) | |
| 57 | + return $input; | |
| 58 | + | |
| 59 | + $links = array( | |
| 60 | + '<a href="https://gamipress.com/add-ons/">' . esc_html__( 'Add-ons', 'gamipress' ) . '</a>', | |
| 61 | + '<a href="https://gamipress.com/docs/">' . esc_html__( 'Docs', 'gamipress' ) . '</a>', | |
| 62 | + '<a href="https://gamipress.com/contact-us/">' . esc_html__( 'Support', 'gamipress' ) . '</a>', | |
| 63 | + ); | |
| 64 | + | |
| 65 | + $input = array_merge( $input, $links ); | |
| 66 | + | |
| 67 | + return $input; | |
| 68 | +} | |
| 69 | +add_filter( 'plugin_row_meta', 'gamipress_plugin_row_meta', 10, 2 ); | |