/** * Action handler that allows us to add a popup via WordPress hook. * * @since 4.7.1 * @param string $contents The PopUp contents. * @param array $options PopUp options. */ public function show_popup($contents, $options = array()) { $this->script_data['popup'] = lib2()->array->get($this->script_data['popup']); $popup = new IncPopupItem(); $data = lib2()->array->get($options); $data['content'] = $contents; $popup->populate($data); $popup->script_data['manual'] = true; // 1. Add the popup to the global popup-list. $this->popups[] = $popup; // 2. Enqueue the popup in the page footer. $item = $popup->get_script_data(false); unset($item['html']); unset($item['styles']); $this->script_data['popup'][] = $item; $this->load_scripts(); $this->enqueue_footer(); }