• stas0238

    (@stas0238)


    Hello,
    I would like to know if it is possible to make script depends based on option value ?
    For example I have select control with options

    $this->add_control(
      'event',
       [
    	'label' => __( 'Event', 'st-domain' ),
    	'type' => Controls_Manager::SELECT,
    	'options' => [
    	        'hover' => __( 'Hover', 'st-domain' ),
    		'click' => __( 'Click', 'st-domain' ),
    		'none' => __( 'None', 'st-domain' ),
    	],
    	'default' => 'hover',
    	'frontend_available' => true,
        ]
    );

    and I have

    public function get_script_depends() {
    		$settings = $this->get_settings_for_display(); // or if I write $this->get_settings(); I will have the same results
    		if ( $settings['event'] == 'click' ) {
    			return ['custom_script'];
            }
    		return [];
    	}

    but If I write it as above then after refresh Elementor editor cannot be loaded -> https://prntscr.com/1xmcyf1

    My question is how is it possible to make depends only if one of options is choosen with specific value (in my case ‘event’ == ‘click’). I hope you understood me right.
    Thanks @stas0238

    • This topic was modified 3 years ago by stas0238.
    • This topic was modified 3 years ago by stas0238.
    • This topic was modified 3 years ago by stas0238.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘get_script_depends based on option’ is closed to new replies.