Skip to content

Commit

Permalink
Fixed an issue where code editor scripts is not loaded for non-admin …
Browse files Browse the repository at this point in the history
…user.
  • Loading branch information
barthc committed Aug 5, 2024
1 parent bcc86de commit f445c3f
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions class-gwiz-gf-code-chest.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,13 @@ public function init() {

load_plugin_textdomain( $this->_slug, false, basename( dirname( __file__ ) ) . '/languages/' );

if ( current_user_can( 'administrator' ) ) {
add_filter( 'gform_tooltips', array( $this, 'tooltips' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_editor_script' ) );
add_action( 'gform_post_save_feed_settings', array( $this, 'save_code_chest_settings' ), 10, 4 );
add_filter( 'gform_noconflict_scripts', array( $this, 'noconflict_scripts' ) );
add_filter( 'gform_noconflict_styles', array( $this, 'noconflict_styles' ) );

// 11 so that this comes right after and can override the legacy Custom JS plugin setting config.
add_filter( 'gform_form_settings_fields', array( $this, 'replace_custom_js_setting' ), 11, 2 );
}
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_editor_script' ) );
add_action( 'gform_post_save_feed_settings', array( $this, 'save_code_chest_settings' ), 10, 4 );
add_filter( 'gform_noconflict_scripts', array( $this, 'noconflict_scripts' ) );
add_filter( 'gform_noconflict_styles', array( $this, 'noconflict_styles' ) );

// 11 so that this comes right after and can override the legacy Custom JS plugin setting config.
add_filter( 'gform_form_settings_fields', array( $this, 'replace_custom_js_setting' ), 11, 2 );

add_filter( 'gform_register_init_scripts', array( $this, 'register_init_script' ), 99, 1 );
add_filter( 'gform_register_init_scripts', array( $this, 'maybe_register_custom_js_scripts_first' ), 100, 1 );
Expand Down Expand Up @@ -423,17 +420,6 @@ public function get_custom_css( $form ) {
return rgar( $settings, 'code_chest_css' );
}

/**
* Registers tooltips with Gravity Forms. Needed for some things like radio choices.
*
* @param $tooltips array Existing tooltips.
*
* @return array
*/
public function tooltips( $tooltips ) {
return $tooltips;
}

public function feed_settings_fields() {
$form_id = rgget( 'id' );
$form = GFAPI::get_form( $form_id );
Expand Down

0 comments on commit f445c3f

Please sign in to comment.