/** * Format the script in a way that will be compatible with WordPress. * * @return void (echoes the script) */ public function enqueue_script() { if (!self::$script_added && '' != self::$tooltip_script) { self::$script_added = true; echo '<script>jQuery(document).ready(function($) { "use strict"; ' . self::$tooltip_script . '});</script>'; } }
public function __construct($args) { /** * Run the parent class constructor */ parent::__construct($args); /** * Set the field arguments */ $this->args = $args; /** * Create the settings. */ new Kirki_Settings($this->args); /** * Check if we're on the customizer. * If we are, then we will create the controls, * add the scripts needed for the customizer * and any other tweaks that this field may require. */ if ($this->wp_customize) { /** * Create the control */ new Kirki_Control($this->args); /** * Create the scripts for postMessage to properly work */ Kirki_Customizer_Scripts_PostMessage::generate_script($this->args); /** * Create the scripts for tooltips. */ Kirki_Customizer_Scripts_Tooltips::generate_script($this->args); } }
public function test_basic() { Kirki_Customizer_Scripts_Tooltips::generate_script(array('type' => 'foo', 'settings' => 'bar', 'tooltip' => 'My Tooltip')); $this->assertEquals('$( "<a href=\'#\' class=\'tooltip hint--left\' data-hint=\'My Tooltip\'><span class=\'dashicons dashicons-info\'></span></a>" ).prependTo( "#customize-control-bar" );', Kirki_Customizer_Scripts_Tooltips::$tooltip_script); }