value [optional]. * * @return void */ public static function chosen($selector = '.btn-toolbar', $debug = null, $options = array()) { // load always select2 plugin // JHtml::fetch('select2'); JText::script('JGLOBAL_SELECT_AN_OPTION'); static $loaded = 0; // register only once if (!$loaded) { $loaded = 1; /** * Use select2 rendering only in case of WordPress 5.2 or lower. * Starting from WordPress 5.3 the dropdowns are rendered properly * and there is no need to use a different layout. * Contrarily, we will lose the possibility of searching the options. * * @since 10.1.30 */ // $use_select2 = version_compare((new JVersion)->getShortVersion(), '5.3', '<') ? 1 : 0; $use_select2 = 0; // add support for chosen plugin JFactory::getDocument()->addScriptDeclaration( << 0) { data.allowClear = false; data.placeholder = null; } // turn off search when there are 5 options or less if ($(this).find('option').length <= 5) { data.minimumResultsForSearch = -1; } // init select2 plugin $(this).select2(data); } }); return this; } } })(jQuery); JAVASCRIPT ); } static $selectors = []; /** * The system is now able to initialize multiple selectors as a result of multiple calls. * * @since 10.1.63 */ if (!isset($selectors[$selector])) { $selectors[$selector] = 1; // init requested selectors JFactory::getDocument()->addScriptDeclaration( <<