Skip to content

Commit d25f869

Browse files
authored
Fixed an issue that prevented code editor scripts from loading for users with capabilities to edit Gravity Forms, but who did not have the administrator role.
1 parent bcc86de commit d25f869

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

class-gwiz-gf-code-chest.php

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,6 @@ public function init() {
208208

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

211-
if ( current_user_can( 'administrator' ) ) {
212-
add_filter( 'gform_tooltips', array( $this, 'tooltips' ) );
213-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_editor_script' ) );
214-
add_action( 'gform_post_save_feed_settings', array( $this, 'save_code_chest_settings' ), 10, 4 );
215-
add_filter( 'gform_noconflict_scripts', array( $this, 'noconflict_scripts' ) );
216-
add_filter( 'gform_noconflict_styles', array( $this, 'noconflict_styles' ) );
217-
218-
// 11 so that this comes right after and can override the legacy Custom JS plugin setting config.
219-
add_filter( 'gform_form_settings_fields', array( $this, 'replace_custom_js_setting' ), 11, 2 );
220-
}
221-
222211
add_filter( 'gform_register_init_scripts', array( $this, 'register_init_script' ), 99, 1 );
223212
add_filter( 'gform_register_init_scripts', array( $this, 'maybe_register_custom_js_scripts_first' ), 100, 1 );
224213

@@ -240,6 +229,18 @@ public function init() {
240229
add_action( 'gform_post_form_duplicated', array( $this, 'duplicate_form_feeds' ), 10, 2 );
241230
}
242231

232+
public function init_admin() {
233+
parent::init_admin();
234+
235+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_editor_script' ) );
236+
add_action( 'gform_post_save_feed_settings', array( $this, 'save_code_chest_settings' ), 10, 4 );
237+
add_filter( 'gform_noconflict_scripts', array( $this, 'noconflict_scripts' ) );
238+
add_filter( 'gform_noconflict_styles', array( $this, 'noconflict_styles' ) );
239+
240+
// 11 so that this comes right after and can override the legacy Custom JS plugin setting config.
241+
add_filter( 'gform_form_settings_fields', array( $this, 'replace_custom_js_setting' ), 11, 2 );
242+
}
243+
243244
public function enqueue_editor_script() {
244245
if ( GFForms::get_page() !== 'form_settings_gf-code-chest' ) {
245246
return;
@@ -423,17 +424,6 @@ public function get_custom_css( $form ) {
423424
return rgar( $settings, 'code_chest_css' );
424425
}
425426

426-
/**
427-
* Registers tooltips with Gravity Forms. Needed for some things like radio choices.
428-
*
429-
* @param $tooltips array Existing tooltips.
430-
*
431-
* @return array
432-
*/
433-
public function tooltips( $tooltips ) {
434-
return $tooltips;
435-
}
436-
437427
public function feed_settings_fields() {
438428
$form_id = rgget( 'id' );
439429
$form = GFAPI::get_form( $form_id );

0 commit comments

Comments
 (0)