PluginProbe
BugHerd / 1.0.6
BugHerd v1.0.6
1.0.20 1.0.18 1.0.19 1.0.17 trunk 1.0.0 1.0.1 1.0.11 1.0.12 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9
bugherd / includes / scripts.php

scripts.php in BugHerd 1.0.6, at includes/scripts.php

89 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Frontend and Admin Scripts.
4 *
5 * @package BugHerd
6 */
7
8 // If this file is called directly, abort.
9 if ( ! defined( 'WPINC' ) ) {
10 die;
11 }
12
13 /**
14 * Get the tracking script.
15 *
16 * @param string $project_key BugHerd project Key.
17 * @return string
18 * @since 1.0.0
19 */
20 function bugherd_get_the_script( $project_key ) {
21 return sprintf(
22 // phpcs:disable
23 '<script type="text/javascript" src="https://www.bugherd.com/sidebarv2.js?apikey=%s" async="true"></script>',
24 // phpcs:enable
25 esc_html( $project_key )
26 );
27 }
28
29 add_action( 'wp_head', 'bugherd_do_the_frontend_script' );
30 /**
31 * Add BugHerd integration code for the frontend.
32 *
33 * @return void
34 * @since 1.0.0
35 */
36 function bugherd_do_the_frontend_script() {
37 /**
38 * Filter the project_key variable to support other methods of setting this value.
39 *
40 * @param string $project_key BugHerd project Key.
41 * @return string
42 * @since 1.0.0
43 */
44 $project_key = apply_filters( 'bugherd_project_key', get_option( 'bugherd_project_key', '' ) );
45
46 if ( '' === $project_key ) {
47 return;
48 }
49
50 echo bugherd_get_the_script( $project_key ); // phpcs:ignore
51 }
52
53 add_action( 'admin_head', 'bugherd_do_the_admin_script' );
54 /**
55 * Add BugHerd integration code for the wp-admin.
56 *
57 * @return void
58 * @since 1.0.0
59 */
60 function bugherd_do_the_admin_script() {
61 /**
62 * Filter the enable_admin variable to support other methods of setting this value.
63 *
64 * @param boolean $enable_admin BugHerd enable admin.
65 * @return boolean
66 * @since 1.0.0
67 */
68 $enable_admin = apply_filters( 'bugherd_enable_admin', get_option( 'bugherd_enable_admin', false ) );
69
70 if ( ! $enable_admin ) {
71 return;
72 }
73
74 /**
75 * Filter the project_key variable to support other methods of setting this value.
76 *
77 * @param string $project_key BugHerd project Key.
78 * @return string
79 * @since 1.0.0
80 */
81 $project_key = apply_filters( 'bugherd_project_key', get_option( 'bugherd_project_key', '' ) );
82
83 if ( '' === $project_key ) {
84 return;
85 }
86
87 echo bugherd_get_the_script( $project_key ); // phpcs:ignore
88 }
89