Plugin Directory

Changeset 3284473


Ignore:
Timestamp:
04/30/2025 02:10:58 AM (10 months ago)
Author:
bugherd
Message:

Update to version 1.0.14 from GitHub

Location:
bugherd
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • bugherd/tags/1.0.14/bugherd.php

    r3230897 r3284473  
    77 * Author URI:      https://bugherd.com
    88 * Text Domain:     bugherd
    9  * Version:         1.0.12
     9 * Version:         1.0.14
    1010 * License:         GPLv3 or later
    1111 *
     
    2525require_once plugin_dir_path( __FILE__ ) . 'includes/settings.php';
    2626require_once plugin_dir_path( __FILE__ ) . 'includes/scripts.php';
     27
     28/**
     29 * Add a "Settings" link in the Plugins section.
     30 */
     31add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'bugherd_add_settings_link' );
     32function bugherd_add_settings_link( $links ) {
     33    $settings_link = '<a href="' . esc_url(admin_url('options-general.php?page=bugherd')) . '">' . esc_html__('Settings', 'bugherd') . '</a>';
     34    array_unshift( $links, $settings_link ); // Adds it at the beginning of the links
     35    return $links;
     36}
  • bugherd/tags/1.0.14/includes/scripts.php

    r2420524 r3284473  
    1616 * @param string $project_key BugHerd project Key.
    1717 * @return string
    18  * @since 1.0.0
    1918 */
    2019function bugherd_get_the_script( $project_key ) {
    2120    return sprintf(
    22         // phpcs:disable
    2321        '<script type="text/javascript" src="https://www.bugherd.com/sidebarv2.js?apikey=%s" async="true"></script>',
    24         // phpcs:enable
    2522        esc_html( $project_key )
    2623    );
    2724}
    2825
    29 add_action( 'wp_head', 'bugherd_do_the_frontend_script' );
     26/**
     27 * Check if BugHerd should be disabled based on query parameters.
     28 *
     29 * Users can add `?disable_bugherd` (or any defined query params) to prevent BugHerd from loading.
     30 *
     31 * @return bool
     32 */
     33function is_bugherd_disabled_by_query() {
     34    $query_params = get_option( 'bugherd_disable_query_params', 'disable_bugherd, bricks, elementor, no_bugherd' );
     35    $disabled_params = array_map('trim', explode(',', $query_params)); // Convert to an array
     36
     37    foreach ( $disabled_params as $param ) {
     38        if ( isset( $_GET[ $param ] ) ) {
     39            return true;
     40        }
     41    }
     42    return false;
     43}
     44
    3045/**
    3146 * Add BugHerd integration code for the frontend.
    32  *
    33  * @return void
    34  * @since 1.0.0
    3547 */
     48add_action( 'wp_head', 'bugherd_do_the_frontend_script' );
    3649function 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', '' ) );
     50    $project_key = get_option( 'bugherd_project_key', '' );
    4551
    46     if ( '' === $project_key ) {
     52    // Prevent BugHerd from loading if any specified query parameter is present
     53    if ( is_bugherd_disabled_by_query() ) {
    4754        return;
    4855    }
    4956
    50     echo bugherd_get_the_script( $project_key ); // phpcs:ignore
     57    if ( empty( $project_key ) ) {
     58        return;
     59    }
     60
     61    echo bugherd_get_the_script( $project_key );
    5162}
    5263
     64/**
     65 * Add BugHerd integration code for wp-admin.
     66 */
    5367add_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  */
    6068function 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    $enable_admin = filter_var( get_option( 'bugherd_enable_admin', false ), FILTER_VALIDATE_BOOLEAN );
    6970
     71    // If admin mode is disabled in settings, don't load BugHerd
    7072    if ( ! $enable_admin ) {
    7173        return;
    7274    }
    7375
    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 ) {
     76    // Prevent BugHerd from loading if any specified query parameter is present
     77    if ( is_bugherd_disabled_by_query() ) {
    8478        return;
    8579    }
    8680
    87     echo bugherd_get_the_script( $project_key ); // phpcs:ignore
     81    $project_key = get_option( 'bugherd_project_key', '' );
     82
     83    if ( empty( $project_key ) ) {
     84        return;
     85    }
     86
     87    echo bugherd_get_the_script( $project_key );
    8888}
  • bugherd/tags/1.0.14/includes/settings.php

    r2425291 r3284473  
    1111}
    1212
    13 add_action( 'admin_enqueue_scripts', 'bugherd_enqueue_admin_stylesheet' );
    14 /**
    15  * Enqueue stylesheet in the admin.
    16  *
    17  * @return void
    18  * @since 1.0.0
    19  */
    20 function bugherd_enqueue_admin_stylesheet() {
    21     wp_enqueue_style( 'bugherd', plugin_dir_url( __DIR__ ) . 'assets/css/style.css', array(), '1.0.0' );
    22 }
    23 
    2413add_action( 'admin_menu', 'bugherd_register_options_page' );
    25 /**
    26  * Add menu into options page
    27  *
    28  * @since 1.0.0
    29  * @return void
    30  */
    3114function bugherd_register_options_page() {
    3215    add_options_page(
     
    3922}
    4023
    41 add_filter( 'plugin_action_links_bugherd/bugherd.php', 'bugherd_options_page_link', 10, 4 );
    42 /**
    43  * Add options page link to the plugin actions list.
    44  *
    45  * @param array  $actions An array of plugin action links. By default this can include 'activate', 'deactivate', and 'delete'.
    46  * @param string $plugin_file Path to the plugin file relative to the plugins directory.
    47  * @param array  $plugin_data An array of plugin data.
    48  * @param string $context The plugin context.
    49  * @return array
    50  * @since 1.0.1
    51  */
    52 function bugherd_options_page_link( $actions, $plugin_file, $plugin_data, $context ) {
    53     $actions[] = sprintf(
    54         '<a href="%s">%s</a>',
    55         esc_url( admin_url( 'options-general.php?page=bugherd' ) ),
    56         esc_html__( 'Settings', 'bugherd' )
    57     );
    58     return $actions;
     24add_action( 'admin_init', 'bugherd_register_settings' );
     25function bugherd_register_settings() {
     26    add_settings_section( 'bugherd_settings', '', '__return_false', 'bugherd_settings' );
     27
     28    // Project Key
     29    register_setting( 'bugherd_settings', 'bugherd_project_key', [
     30        'type' => 'string',
     31        'description' => esc_html__( 'BugHerd Project Key', 'bugherd' ),
     32        'sanitize_callback' => 'sanitize_text_field',
     33        'show_in_rest' => true,
     34        'default' => '',
     35    ]);
     36
     37    // Enable BugHerd in WP Admin
     38    register_setting( 'bugherd_settings', 'bugherd_enable_admin', [
     39        'type' => 'boolean',
     40        'description' => esc_html__( 'Enable BugHerd in wp-admin?', 'bugherd' ),
     41        'sanitize_callback' => 'sanitize_text_field',
     42        'show_in_rest' => true,
     43        'default' => false,
     44    ]);
     45
     46    // Query Params for Disabling BugHerd
     47    register_setting( 'bugherd_settings', 'bugherd_disable_query_params', [
     48        'type' => 'string',
     49        'description' => esc_html__( 'Comma-separated list of query parameters to disable BugHerd.', 'bugherd' ),
     50        'sanitize_callback' => 'sanitize_text_field',
     51        'show_in_rest' => true,
     52        'default' => false,
     53    ]);
     54
     55    // Add Fields
     56    add_settings_field( 'bugherd_project_key_field', __( 'Project Key', 'bugherd' ), 'bugherd_project_key_settings_field', 'bugherd_settings', 'bugherd_settings' );
     57
     58    add_settings_field( 'bugherd_enable_admin_field', __( 'Enable BugHerd in wp-admin?', 'bugherd' ), 'bugherd_enable_admin_settings_field', 'bugherd_settings', 'bugherd_settings' );
     59
     60    add_settings_field( 'bugherd_disable_query_params_field', __( 'Query Parameters to Disable BugHerd', 'bugherd' ), 'bugherd_disable_query_params_settings_field', 'bugherd_settings', 'bugherd_settings' );
    5961}
    6062
    61 add_action( 'admin_menu', 'bugherd_register_settings' );
    62 /**
    63  * Register options and settings fields.
    64  *
    65  * @return void
    66  * @since 1.0.0
    67  */
    68 function bugherd_register_settings() {
    69 
    70     // Section.
    71     add_settings_section( 'bugherd_settings', '', '__return_false', 'bugherd_settings' );
    72 
    73     // Project ID.
    74     register_setting(
    75         'bugherd_settings',
    76         'bugherd_project_key',
    77         array(
    78             'type'              => 'string',
    79             'description'       => esc_html__( 'Bugherd Project Key', 'bugherd' ),
    80             'sanitize_callback' => 'sanitize_text_field',
    81             'show_in_rest'      => true,
    82             'default'           => '',
    83         )
    84     );
    85 
    86     // Enable Admin.
    87     register_setting(
    88         'bugherd_settings',
    89         'bugherd_enable_admin',
    90         array(
    91             'type'              => 'boolean',
    92             'description'       => esc_html__( 'Enable BugHerd in wp-admin?', 'bugherd' ),
    93             'sanitize_callback' => 'sanitize_text_field',
    94             'show_in_rest'      => true,
    95             'default'           => false,
    96         )
    97     );
    98 
    99     // Project ID Field.
    100     add_settings_field(
    101         'bugherd_project_key_field',
    102         __( 'Project Key', 'bugherd' ),
    103         'bugherd_project_key_settings_field',
    104         'bugherd_settings',
    105         'bugherd_settings'
    106     );
    107 
    108     // Enable admin Field.
    109     add_settings_field(
    110         'bugherd_enable_admin_field',
    111         __( 'Enable BugHerd in wp-admin?', 'bugherd' ),
    112         'bugherd_enable_admin_settings_field',
    113         'bugherd_settings',
    114         'bugherd_settings'
     63function bugherd_project_key_settings_field() {
     64    printf(
     65        '<input type="text" id="bugherd-project-key" name="bugherd_project_key" value="%s" class="regular-text ltr" /><p class="description">%s</p>',
     66        esc_attr( get_option( 'bugherd_project_key' ) ),
     67        esc_html__( 'Leave blank to disable plugin.', 'bugherd' )
    11568    );
    11669}
    11770
    118 /**
    119  * Display the settings field for the Project Key.
    120  *
    121  * @return void
    122  * @since 1.0.0
    123  */
    124 function bugherd_project_key_settings_field() {
     71function bugherd_enable_admin_settings_field() {
    12572    printf(
    126         '<label id="%2$s-description">%1$s:</label><input type="text" id="%2$s" name="%4$s" value="%3$s" aria-describedby="%2$s-description" class="regular-text ltr" /><p class="description">%5$s</p>',
    127         esc_html__( 'Project Key', 'bugherd' ),
    128         esc_attr( 'bugherd-project-key' ),
    129         esc_attr( get_option( 'bugherd_project_key' ) ),
    130         esc_attr( 'bugherd_project_key' ),
    131         esc_html__( 'Leave blank to disable plugin', 'bugherd' )
     73        '<input type="checkbox" id="bugherd-enable-admin" name="bugherd_enable_admin" value="1" %s /><label for="bugherd-enable-admin">%s</label>',
     74        checked( get_option( 'bugherd_enable_admin' ), '1', false ),
     75        esc_html__( 'Show BugHerd on WP Admin pages?', 'bugherd' )
    13276    );
    13377}
    13478
    135 /**
    136  * Display the settings for the Enable in Admin checkbox.
    137  *
    138  * @return void
    139  * @since 1.0.0
    140  */
    141 function bugherd_enable_admin_settings_field() {
     79function bugherd_disable_query_params_settings_field() {
    14280    printf(
    143         '<input type="checkbox" id="%2$s" name="%4$s" value="1" %3$s aria-describedby="%2$s-description" /><label id="%2$s-description">%1$s</label><p class="description">%5$s</p>',
    144         esc_html__( 'Also show BugHerd on WP Admin pages?', 'bugherd' ),
    145         esc_attr( 'bugherd-enable-admin' ),
    146         checked( get_option( 'bugherd_enable_admin' ), '1', false ),
    147         esc_attr( 'bugherd_enable_admin' ),
    148         esc_html__( 'If selected, the BugHerd sidebar will also appear on WordPress admin screens, in addition to your website.', 'bugherd' )
     81        '<input type="text" id="bugherd-disable-query-params" name="bugherd_disable_query_params" value="%s" class="regular-text" />
     82        <p class="description">%s</p>',
     83        esc_attr( get_option( 'bugherd_disable_query_params', 'disable_bugherd, bricks, elementor, no_bugherd' ) ),
     84        esc_html__( 'Enter query parameters (comma-separated) to disable BugHerd. Example: bricks, elementor' )
    14985    );
    15086}
    15187
    152 /**
    153  * Display the options page.
    154  *
    155  * @return void
    156  * @since 1.0.0
    157  */
    15888function bugherd_options_page() {
    159 
    160     // Logo.
     89    echo '<div class="wrap bugherd-settings-container">';
     90   
     91    // Logo
    16192    printf(
    16293        '<img src="%s%s" class="bugherd-logo">',
     
    16596    );
    16697
    167     // Tagline.
     98    // Tagline
    16899    printf(
    169100        '<h2 class="bugherd-tagline">%s<br>%s</h2>',
     
    174105    echo '<form method="post" action="options.php" class="card bugherd-container">';
    175106
    176         // Intro.
    177         printf(
    178             '<p>%s <a href="%s" target="_blank" rel="noopener">%s</a></p>',
    179             esc_html__( 'To install BugHerd on this site simply add your BugHerd Project Key to the field below. Not sure where to find your Project Key?', 'bugherd' ),
    180             esc_url( 'https://support.bugherd.com/hc/en-us/articles/360002121575' ),
    181             esc_html__( 'Check out this help article.', 'bugherd' )
    182         );
     107    // Intro
     108    printf(
     109        '<p>%s <a href="%s" target="_blank" rel="noopener">%s</a></p>',
     110        esc_html__( 'To install BugHerd on this site simply add your BugHerd Project Key to the field below. Not sure where to find your Project Key?', 'bugherd' ),
     111        esc_url( 'https://support.bugherd.com/hc/en-us/articles/360002121575' ),
     112        esc_html__( 'Check out this help article.', 'bugherd' )
     113    );
    183114
    184         // Settings.
    185         settings_fields( 'bugherd_settings' );
    186         do_settings_sections( 'bugherd_settings' );
     115    settings_fields( 'bugherd_settings' );
     116    do_settings_sections( 'bugherd_settings' );
    187117
    188         // Submit.
    189         printf(
    190             '<div class="bugherd-submit">%1$s<p>%2$s <a href="%3$s" target="_blank" rel="noopener">%3$s</a></p></div>',
    191             get_submit_button(), // phpcs:ignore
    192             esc_html__( 'Need help? Try', 'bugherd' ),
    193             esc_url( 'https://support.bugherd.com' )
    194         );
     118    // Submit button
     119    printf(
     120        '<div class="bugherd-submit">%1$s<p>%2$s <a href="%3$s" target="_blank" rel="noopener">%3$s</a></p></div>',
     121        get_submit_button(),
     122        esc_html__( 'Need help? Try', 'bugherd' ),
     123        esc_url( 'https://support.bugherd.com' )
     124    );
    195125
    196126    echo '</form>';
     127    echo '</div>';
    197128}
  • bugherd/tags/1.0.14/readme.txt

    r3230897 r3284473  
    55Requires PHP: 5.6
    66Tested up to: 6.6
    7 Stable tag: 1.0.12
     7Stable tag: 1.0.14
    88License: GPLv3 or later
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    1717## How it works
    1818
    19 [youtube https://www.youtube.com/watch?v=LinanY71jQc]
     19[youtube https://www.youtube.com/watch?v=izG3vI9t_YE]
    2020
    2121BugHerd's simple website feedback and bug tracking tool sits on top of your website and lets you and your stakeholders log website feedback instantaneously.
     
    9494BugHerd is the world's simplest visual feedback tool for websites. You will never need to second guess what your client meant by the feedback they sent via email or on a spreadsheet.
    9595
    96 ## Do I need to signup?
    97 Yes, in order to use BugHerd, you will need to sign up for an account at [https://bugherd.com/](https://bugherd.com/). All BugHerd accounts come with a 7-day free trial, so that you have enough time to work out which plan you need for the work that you do. Our plans are available from $49/month.
     96## Do I need to sign up?
     97Yes, in order to use BugHerd, you will need to sign up for an account at [https://bugherd.com/](https://bugherd.com/). All BugHerd accounts come with a 7-day free trial, so that you have enough time to work out which plan you need for the work that you do. Our plans are available from $41/month.
    9898
    9999## Do I need to install anything?
     
    121121
    122122== Changelog ==
     123
     124= 1.0.14
     125* Users can add `?disable_bugherd` (or any defined query params) to prevent BugHerd from loading. Useful where BugHerd might conflict with theme builders like BricksBuilder.
     126
     127= 1.0.13
     128* Bump stable tag
     129* Updated readme
    123130
    124131= 1.0.12 =
  • bugherd/trunk/bugherd.php

    r3230897 r3284473  
    77 * Author URI:      https://bugherd.com
    88 * Text Domain:     bugherd
    9  * Version:         1.0.12
     9 * Version:         1.0.14
    1010 * License:         GPLv3 or later
    1111 *
     
    2525require_once plugin_dir_path( __FILE__ ) . 'includes/settings.php';
    2626require_once plugin_dir_path( __FILE__ ) . 'includes/scripts.php';
     27
     28/**
     29 * Add a "Settings" link in the Plugins section.
     30 */
     31add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'bugherd_add_settings_link' );
     32function bugherd_add_settings_link( $links ) {
     33    $settings_link = '<a href="' . esc_url(admin_url('options-general.php?page=bugherd')) . '">' . esc_html__('Settings', 'bugherd') . '</a>';
     34    array_unshift( $links, $settings_link ); // Adds it at the beginning of the links
     35    return $links;
     36}
  • bugherd/trunk/includes/scripts.php

    r2420524 r3284473  
    1616 * @param string $project_key BugHerd project Key.
    1717 * @return string
    18  * @since 1.0.0
    1918 */
    2019function bugherd_get_the_script( $project_key ) {
    2120    return sprintf(
    22         // phpcs:disable
    2321        '<script type="text/javascript" src="https://www.bugherd.com/sidebarv2.js?apikey=%s" async="true"></script>',
    24         // phpcs:enable
    2522        esc_html( $project_key )
    2623    );
    2724}
    2825
    29 add_action( 'wp_head', 'bugherd_do_the_frontend_script' );
     26/**
     27 * Check if BugHerd should be disabled based on query parameters.
     28 *
     29 * Users can add `?disable_bugherd` (or any defined query params) to prevent BugHerd from loading.
     30 *
     31 * @return bool
     32 */
     33function is_bugherd_disabled_by_query() {
     34    $query_params = get_option( 'bugherd_disable_query_params', 'disable_bugherd, bricks, elementor, no_bugherd' );
     35    $disabled_params = array_map('trim', explode(',', $query_params)); // Convert to an array
     36
     37    foreach ( $disabled_params as $param ) {
     38        if ( isset( $_GET[ $param ] ) ) {
     39            return true;
     40        }
     41    }
     42    return false;
     43}
     44
    3045/**
    3146 * Add BugHerd integration code for the frontend.
    32  *
    33  * @return void
    34  * @since 1.0.0
    3547 */
     48add_action( 'wp_head', 'bugherd_do_the_frontend_script' );
    3649function 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', '' ) );
     50    $project_key = get_option( 'bugherd_project_key', '' );
    4551
    46     if ( '' === $project_key ) {
     52    // Prevent BugHerd from loading if any specified query parameter is present
     53    if ( is_bugherd_disabled_by_query() ) {
    4754        return;
    4855    }
    4956
    50     echo bugherd_get_the_script( $project_key ); // phpcs:ignore
     57    if ( empty( $project_key ) ) {
     58        return;
     59    }
     60
     61    echo bugherd_get_the_script( $project_key );
    5162}
    5263
     64/**
     65 * Add BugHerd integration code for wp-admin.
     66 */
    5367add_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  */
    6068function 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    $enable_admin = filter_var( get_option( 'bugherd_enable_admin', false ), FILTER_VALIDATE_BOOLEAN );
    6970
     71    // If admin mode is disabled in settings, don't load BugHerd
    7072    if ( ! $enable_admin ) {
    7173        return;
    7274    }
    7375
    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 ) {
     76    // Prevent BugHerd from loading if any specified query parameter is present
     77    if ( is_bugherd_disabled_by_query() ) {
    8478        return;
    8579    }
    8680
    87     echo bugherd_get_the_script( $project_key ); // phpcs:ignore
     81    $project_key = get_option( 'bugherd_project_key', '' );
     82
     83    if ( empty( $project_key ) ) {
     84        return;
     85    }
     86
     87    echo bugherd_get_the_script( $project_key );
    8888}
  • bugherd/trunk/includes/settings.php

    r2425291 r3284473  
    1111}
    1212
    13 add_action( 'admin_enqueue_scripts', 'bugherd_enqueue_admin_stylesheet' );
    14 /**
    15  * Enqueue stylesheet in the admin.
    16  *
    17  * @return void
    18  * @since 1.0.0
    19  */
    20 function bugherd_enqueue_admin_stylesheet() {
    21     wp_enqueue_style( 'bugherd', plugin_dir_url( __DIR__ ) . 'assets/css/style.css', array(), '1.0.0' );
    22 }
    23 
    2413add_action( 'admin_menu', 'bugherd_register_options_page' );
    25 /**
    26  * Add menu into options page
    27  *
    28  * @since 1.0.0
    29  * @return void
    30  */
    3114function bugherd_register_options_page() {
    3215    add_options_page(
     
    3922}
    4023
    41 add_filter( 'plugin_action_links_bugherd/bugherd.php', 'bugherd_options_page_link', 10, 4 );
    42 /**
    43  * Add options page link to the plugin actions list.
    44  *
    45  * @param array  $actions An array of plugin action links. By default this can include 'activate', 'deactivate', and 'delete'.
    46  * @param string $plugin_file Path to the plugin file relative to the plugins directory.
    47  * @param array  $plugin_data An array of plugin data.
    48  * @param string $context The plugin context.
    49  * @return array
    50  * @since 1.0.1
    51  */
    52 function bugherd_options_page_link( $actions, $plugin_file, $plugin_data, $context ) {
    53     $actions[] = sprintf(
    54         '<a href="%s">%s</a>',
    55         esc_url( admin_url( 'options-general.php?page=bugherd' ) ),
    56         esc_html__( 'Settings', 'bugherd' )
    57     );
    58     return $actions;
     24add_action( 'admin_init', 'bugherd_register_settings' );
     25function bugherd_register_settings() {
     26    add_settings_section( 'bugherd_settings', '', '__return_false', 'bugherd_settings' );
     27
     28    // Project Key
     29    register_setting( 'bugherd_settings', 'bugherd_project_key', [
     30        'type' => 'string',
     31        'description' => esc_html__( 'BugHerd Project Key', 'bugherd' ),
     32        'sanitize_callback' => 'sanitize_text_field',
     33        'show_in_rest' => true,
     34        'default' => '',
     35    ]);
     36
     37    // Enable BugHerd in WP Admin
     38    register_setting( 'bugherd_settings', 'bugherd_enable_admin', [
     39        'type' => 'boolean',
     40        'description' => esc_html__( 'Enable BugHerd in wp-admin?', 'bugherd' ),
     41        'sanitize_callback' => 'sanitize_text_field',
     42        'show_in_rest' => true,
     43        'default' => false,
     44    ]);
     45
     46    // Query Params for Disabling BugHerd
     47    register_setting( 'bugherd_settings', 'bugherd_disable_query_params', [
     48        'type' => 'string',
     49        'description' => esc_html__( 'Comma-separated list of query parameters to disable BugHerd.', 'bugherd' ),
     50        'sanitize_callback' => 'sanitize_text_field',
     51        'show_in_rest' => true,
     52        'default' => false,
     53    ]);
     54
     55    // Add Fields
     56    add_settings_field( 'bugherd_project_key_field', __( 'Project Key', 'bugherd' ), 'bugherd_project_key_settings_field', 'bugherd_settings', 'bugherd_settings' );
     57
     58    add_settings_field( 'bugherd_enable_admin_field', __( 'Enable BugHerd in wp-admin?', 'bugherd' ), 'bugherd_enable_admin_settings_field', 'bugherd_settings', 'bugherd_settings' );
     59
     60    add_settings_field( 'bugherd_disable_query_params_field', __( 'Query Parameters to Disable BugHerd', 'bugherd' ), 'bugherd_disable_query_params_settings_field', 'bugherd_settings', 'bugherd_settings' );
    5961}
    6062
    61 add_action( 'admin_menu', 'bugherd_register_settings' );
    62 /**
    63  * Register options and settings fields.
    64  *
    65  * @return void
    66  * @since 1.0.0
    67  */
    68 function bugherd_register_settings() {
    69 
    70     // Section.
    71     add_settings_section( 'bugherd_settings', '', '__return_false', 'bugherd_settings' );
    72 
    73     // Project ID.
    74     register_setting(
    75         'bugherd_settings',
    76         'bugherd_project_key',
    77         array(
    78             'type'              => 'string',
    79             'description'       => esc_html__( 'Bugherd Project Key', 'bugherd' ),
    80             'sanitize_callback' => 'sanitize_text_field',
    81             'show_in_rest'      => true,
    82             'default'           => '',
    83         )
    84     );
    85 
    86     // Enable Admin.
    87     register_setting(
    88         'bugherd_settings',
    89         'bugherd_enable_admin',
    90         array(
    91             'type'              => 'boolean',
    92             'description'       => esc_html__( 'Enable BugHerd in wp-admin?', 'bugherd' ),
    93             'sanitize_callback' => 'sanitize_text_field',
    94             'show_in_rest'      => true,
    95             'default'           => false,
    96         )
    97     );
    98 
    99     // Project ID Field.
    100     add_settings_field(
    101         'bugherd_project_key_field',
    102         __( 'Project Key', 'bugherd' ),
    103         'bugherd_project_key_settings_field',
    104         'bugherd_settings',
    105         'bugherd_settings'
    106     );
    107 
    108     // Enable admin Field.
    109     add_settings_field(
    110         'bugherd_enable_admin_field',
    111         __( 'Enable BugHerd in wp-admin?', 'bugherd' ),
    112         'bugherd_enable_admin_settings_field',
    113         'bugherd_settings',
    114         'bugherd_settings'
     63function bugherd_project_key_settings_field() {
     64    printf(
     65        '<input type="text" id="bugherd-project-key" name="bugherd_project_key" value="%s" class="regular-text ltr" /><p class="description">%s</p>',
     66        esc_attr( get_option( 'bugherd_project_key' ) ),
     67        esc_html__( 'Leave blank to disable plugin.', 'bugherd' )
    11568    );
    11669}
    11770
    118 /**
    119  * Display the settings field for the Project Key.
    120  *
    121  * @return void
    122  * @since 1.0.0
    123  */
    124 function bugherd_project_key_settings_field() {
     71function bugherd_enable_admin_settings_field() {
    12572    printf(
    126         '<label id="%2$s-description">%1$s:</label><input type="text" id="%2$s" name="%4$s" value="%3$s" aria-describedby="%2$s-description" class="regular-text ltr" /><p class="description">%5$s</p>',
    127         esc_html__( 'Project Key', 'bugherd' ),
    128         esc_attr( 'bugherd-project-key' ),
    129         esc_attr( get_option( 'bugherd_project_key' ) ),
    130         esc_attr( 'bugherd_project_key' ),
    131         esc_html__( 'Leave blank to disable plugin', 'bugherd' )
     73        '<input type="checkbox" id="bugherd-enable-admin" name="bugherd_enable_admin" value="1" %s /><label for="bugherd-enable-admin">%s</label>',
     74        checked( get_option( 'bugherd_enable_admin' ), '1', false ),
     75        esc_html__( 'Show BugHerd on WP Admin pages?', 'bugherd' )
    13276    );
    13377}
    13478
    135 /**
    136  * Display the settings for the Enable in Admin checkbox.
    137  *
    138  * @return void
    139  * @since 1.0.0
    140  */
    141 function bugherd_enable_admin_settings_field() {
     79function bugherd_disable_query_params_settings_field() {
    14280    printf(
    143         '<input type="checkbox" id="%2$s" name="%4$s" value="1" %3$s aria-describedby="%2$s-description" /><label id="%2$s-description">%1$s</label><p class="description">%5$s</p>',
    144         esc_html__( 'Also show BugHerd on WP Admin pages?', 'bugherd' ),
    145         esc_attr( 'bugherd-enable-admin' ),
    146         checked( get_option( 'bugherd_enable_admin' ), '1', false ),
    147         esc_attr( 'bugherd_enable_admin' ),
    148         esc_html__( 'If selected, the BugHerd sidebar will also appear on WordPress admin screens, in addition to your website.', 'bugherd' )
     81        '<input type="text" id="bugherd-disable-query-params" name="bugherd_disable_query_params" value="%s" class="regular-text" />
     82        <p class="description">%s</p>',
     83        esc_attr( get_option( 'bugherd_disable_query_params', 'disable_bugherd, bricks, elementor, no_bugherd' ) ),
     84        esc_html__( 'Enter query parameters (comma-separated) to disable BugHerd. Example: bricks, elementor' )
    14985    );
    15086}
    15187
    152 /**
    153  * Display the options page.
    154  *
    155  * @return void
    156  * @since 1.0.0
    157  */
    15888function bugherd_options_page() {
    159 
    160     // Logo.
     89    echo '<div class="wrap bugherd-settings-container">';
     90   
     91    // Logo
    16192    printf(
    16293        '<img src="%s%s" class="bugherd-logo">',
     
    16596    );
    16697
    167     // Tagline.
     98    // Tagline
    16899    printf(
    169100        '<h2 class="bugherd-tagline">%s<br>%s</h2>',
     
    174105    echo '<form method="post" action="options.php" class="card bugherd-container">';
    175106
    176         // Intro.
    177         printf(
    178             '<p>%s <a href="%s" target="_blank" rel="noopener">%s</a></p>',
    179             esc_html__( 'To install BugHerd on this site simply add your BugHerd Project Key to the field below. Not sure where to find your Project Key?', 'bugherd' ),
    180             esc_url( 'https://support.bugherd.com/hc/en-us/articles/360002121575' ),
    181             esc_html__( 'Check out this help article.', 'bugherd' )
    182         );
     107    // Intro
     108    printf(
     109        '<p>%s <a href="%s" target="_blank" rel="noopener">%s</a></p>',
     110        esc_html__( 'To install BugHerd on this site simply add your BugHerd Project Key to the field below. Not sure where to find your Project Key?', 'bugherd' ),
     111        esc_url( 'https://support.bugherd.com/hc/en-us/articles/360002121575' ),
     112        esc_html__( 'Check out this help article.', 'bugherd' )
     113    );
    183114
    184         // Settings.
    185         settings_fields( 'bugherd_settings' );
    186         do_settings_sections( 'bugherd_settings' );
     115    settings_fields( 'bugherd_settings' );
     116    do_settings_sections( 'bugherd_settings' );
    187117
    188         // Submit.
    189         printf(
    190             '<div class="bugherd-submit">%1$s<p>%2$s <a href="%3$s" target="_blank" rel="noopener">%3$s</a></p></div>',
    191             get_submit_button(), // phpcs:ignore
    192             esc_html__( 'Need help? Try', 'bugherd' ),
    193             esc_url( 'https://support.bugherd.com' )
    194         );
     118    // Submit button
     119    printf(
     120        '<div class="bugherd-submit">%1$s<p>%2$s <a href="%3$s" target="_blank" rel="noopener">%3$s</a></p></div>',
     121        get_submit_button(),
     122        esc_html__( 'Need help? Try', 'bugherd' ),
     123        esc_url( 'https://support.bugherd.com' )
     124    );
    195125
    196126    echo '</form>';
     127    echo '</div>';
    197128}
  • bugherd/trunk/readme.txt

    r3230897 r3284473  
    55Requires PHP: 5.6
    66Tested up to: 6.6
    7 Stable tag: 1.0.12
     7Stable tag: 1.0.14
    88License: GPLv3 or later
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    1717## How it works
    1818
    19 [youtube https://www.youtube.com/watch?v=LinanY71jQc]
     19[youtube https://www.youtube.com/watch?v=izG3vI9t_YE]
    2020
    2121BugHerd's simple website feedback and bug tracking tool sits on top of your website and lets you and your stakeholders log website feedback instantaneously.
     
    9494BugHerd is the world's simplest visual feedback tool for websites. You will never need to second guess what your client meant by the feedback they sent via email or on a spreadsheet.
    9595
    96 ## Do I need to signup?
    97 Yes, in order to use BugHerd, you will need to sign up for an account at [https://bugherd.com/](https://bugherd.com/). All BugHerd accounts come with a 7-day free trial, so that you have enough time to work out which plan you need for the work that you do. Our plans are available from $49/month.
     96## Do I need to sign up?
     97Yes, in order to use BugHerd, you will need to sign up for an account at [https://bugherd.com/](https://bugherd.com/). All BugHerd accounts come with a 7-day free trial, so that you have enough time to work out which plan you need for the work that you do. Our plans are available from $41/month.
    9898
    9999## Do I need to install anything?
     
    121121
    122122== Changelog ==
     123
     124= 1.0.14
     125* Users can add `?disable_bugherd` (or any defined query params) to prevent BugHerd from loading. Useful where BugHerd might conflict with theme builders like BricksBuilder.
     126
     127= 1.0.13
     128* Bump stable tag
     129* Updated readme
    123130
    124131= 1.0.12 =
Note: See TracChangeset for help on using the changeset viewer.