| 1 |
<?php |
| 2 |
|
| 3 |
defined( 'ABSPATH' ) || exit; |
| 4 |
|
| 5 |
/** |
| 6 |
* Includes HelpScout Beacon if enabled and if on a Datafeedr-specific page. |
| 7 |
* |
| 8 |
* @since 1.0.84 |
| 9 |
*/ |
| 10 |
function dfrapi_include_helpscout_beacon() { |
| 11 |
|
| 12 |
$options = get_option( 'dfrapi_configuration', [] ); |
| 13 |
|
| 14 |
if ( isset( $options['hs_beacon'] ) && 'off' === $options['hs_beacon'] ) { |
| 15 |
return; |
| 16 |
} |
| 17 |
|
| 18 |
if ( ! dfrapi_is_datafeedr_admin_page() ) { |
| 19 |
return; |
| 20 |
} |
| 21 |
|
| 22 |
include_once DFRAPI_PATH . 'js/helpscout-beacon.php'; |
| 23 |
} |
| 24 |
|
| 25 |
add_action( 'admin_footer', 'dfrapi_include_helpscout_beacon' ); |
| 26 |
|
| 27 |
/** |
| 28 |
* Add link to Configuration page to action links on Plugins page. |
| 29 |
* |
| 30 |
* @param array $links |
| 31 |
* |
| 32 |
* @return array |
| 33 |
*/ |
| 34 |
function dfrapi_add_plugin_action_links( array $links ): array { |
| 35 |
return array_merge( |
| 36 |
$links, |
| 37 |
[ |
| 38 |
'config' => sprintf |
| 39 |
( |
| 40 |
'<a href="%1$s">%2$s</a>', |
| 41 |
dfrapi_configuration_page_url(), |
| 42 |
__( 'Configuration', 'datafeedr-api' ) |
| 43 |
) |
| 44 |
] |
| 45 |
); |
| 46 |
} |
| 47 |
|
| 48 |
add_filter( 'plugin_action_links_' . DFRAPI_BASENAME, 'dfrapi_add_plugin_action_links' ); |
| 49 |
|
| 50 |
/** |
| 51 |
* Add links to Documentation and Contact page to meta row on Plugins page. |
| 52 |
* |
| 53 |
* @param array $links |
| 54 |
* @param string $plugin_file |
| 55 |
* |
| 56 |
* @return array |
| 57 |
*/ |
| 58 |
function dfrapi_add_plugin_row_meta( array $links, string $plugin_file ): array { |
| 59 |
if ( $plugin_file === DFRAPI_BASENAME ) { |
| 60 |
$links[] = sprintf( '<a href="' . DFRAPI_DOCS_URL . '" target="_blank" rel="noopener nofollow">%s</a>', __( 'Documentation', 'datafeedr-api' ) ); |
| 61 |
$links[] = sprintf( '<a href="' . DFRAPI_HELP_URL . '" target="_blank" rel="noopener nofollow">%s</a>', __( 'Support', 'datafeedr-api' ) ); |
| 62 |
} |
| 63 |
|
| 64 |
return $links; |
| 65 |
} |
| 66 |
|
| 67 |
add_filter( 'plugin_row_meta', 'dfrapi_add_plugin_row_meta', 10, 2 ); |
| 68 |
|