@@ -11,230 +11,230 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class EEH_Qtip_Loader extends EEH_Base |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * EEH_Qtip_Loader Object |
|
| 16 | - * @var EEH_Qtip_Loader |
|
| 17 | - * @access private |
|
| 18 | - */ |
|
| 19 | - private static $_instance = null; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * array of qtip config objects |
|
| 23 | - * @var EE_Qtip_Config[] |
|
| 24 | - */ |
|
| 25 | - private $_qtips = array(); |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - *@singleton method used to instantiate class object |
|
| 31 | - *@access public |
|
| 32 | - *@return EEH_Qtip_Loader instance |
|
| 33 | - */ |
|
| 34 | - public static function instance() |
|
| 35 | - { |
|
| 36 | - // check if class object is instantiated |
|
| 37 | - if (self::$_instance === null or ! is_object(self::$_instance) or ! ( self::$_instance instanceof EEH_Qtip_Loader )) { |
|
| 38 | - self::$_instance = new self(); |
|
| 39 | - } |
|
| 40 | - return self::$_instance; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - *private constructor to prevent direct creation |
|
| 47 | - * @Constructor |
|
| 48 | - * @access private |
|
| 49 | - * @return \EEH_Qtip_Loader |
|
| 50 | - */ |
|
| 51 | - private function __construct() |
|
| 52 | - { |
|
| 53 | - // let's just make sure this is instantiated in the right place. |
|
| 54 | - if (did_action('wp_print_styles') || did_action('admin_head')) { |
|
| 55 | - EE_Error::doing_it_wrong('EEH_Qtip_Loader', esc_html__('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso'), '4.1'); |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Call this from wp_enqueue_scripts or admin_enqueue_scripts to setup and enqueue the qtip library |
|
| 62 | - * |
|
| 63 | - * @access public |
|
| 64 | - * @return void |
|
| 65 | - */ |
|
| 66 | - public function register_and_enqueue() |
|
| 67 | - { |
|
| 68 | - $qtips_js = !defined('SCRIPT_DEBUG') ? EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.js' : EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.js'; |
|
| 69 | - $qtip_map = EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.map'; |
|
| 70 | - $qtipcss = !defined('SCRIPT_DEBUG') ? EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.css' : EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.css'; |
|
| 71 | - |
|
| 72 | - wp_register_script('qtip-map', $qtip_map, array(), '3', true); |
|
| 73 | - wp_register_script('qtip', $qtips_js, array('jquery'), '3.0.3', true); |
|
| 74 | - wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS . 'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, true); |
|
| 75 | - |
|
| 76 | - wp_register_style('qtip-css', $qtipcss, array(), '2.2'); |
|
| 77 | - |
|
| 78 | - // k now let's see if there are any registered qtips. If there are, then we need to setup the localized script for ee-qtip-helper.js (and enqueue ee-qtip-helper.js of course!) |
|
| 79 | - if (!empty($this->_qtips)) { |
|
| 80 | - wp_enqueue_script('ee-qtip-helper'); |
|
| 81 | - wp_enqueue_style('qtip-css'); |
|
| 82 | - $qtips = array(); |
|
| 83 | - foreach ($this->_qtips as $qtip) { |
|
| 84 | - $qts = $qtip->get_tips(); |
|
| 85 | - foreach ($qts as $qt) { |
|
| 86 | - if (! $qt instanceof EE_Qtip) { |
|
| 87 | - continue; |
|
| 88 | - } |
|
| 89 | - $qtips[] = array( |
|
| 90 | - 'content_id' => $qt->content_id, |
|
| 91 | - 'options' => $qt->options, |
|
| 92 | - 'target' => $qt->target, |
|
| 93 | - ); |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - if (!empty($qtips)) { |
|
| 97 | - wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips )); |
|
| 98 | - } |
|
| 99 | - } else { |
|
| 100 | - // qtips has been requested without any registration (so assuming its just directly used in the admin). |
|
| 101 | - wp_enqueue_script('qtip'); |
|
| 102 | - wp_enqueue_style('qtip-css'); |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * This simply registers the given qtip config and: |
|
| 110 | - * - adds it to the $_qtips property array. |
|
| 111 | - * - sets up the content containers for all qtips in the config, |
|
| 112 | - * - registers and enqueues the qtip scripts and styles. |
|
| 113 | - * |
|
| 114 | - * @access public |
|
| 115 | - * @param array $paths Array of paths to check for the EE_Qtip class. If present we check these path(s) first. If not present (empty array), then it's assumed it's either in core/libraries/qtips OR the file is already loaded. |
|
| 116 | - * @param string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips] |
|
| 117 | - * @return void |
|
| 118 | - */ |
|
| 119 | - public function register($configname, $paths = array()) |
|
| 120 | - { |
|
| 121 | - |
|
| 122 | - // let's just make sure this is instantiated in the right place. |
|
| 123 | - if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) { |
|
| 124 | - EE_Error::doing_it_wrong('EEH_Qtip_Loader->register()', esc_html__('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso'), '4.1'); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - $configname = (array) $configname; // typecast to array |
|
| 128 | - foreach ($configname as $config) { |
|
| 129 | - $this->_register($config, $paths); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - // hook into appropriate footer |
|
| 133 | - $footer_action = is_admin() ? 'admin_footer' : 'wp_footer'; |
|
| 134 | - add_action($footer_action, array($this, 'setup_qtip'), 10); |
|
| 135 | - |
|
| 136 | - // make sure we "turn on" qtip js. |
|
| 137 | - add_filter('FHEE_load_qtip', '__return_true'); |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * private utility for registering and setting up qtip config objects |
|
| 144 | - * |
|
| 145 | - * @access private |
|
| 146 | - * @param string $config the short name of the class (will be used to generate the expected classname) |
|
| 147 | - * @param array $paths array of paths to check (or if empty we check core/libraries/qtips or assume its loaded) |
|
| 148 | - * @throws EE_Error |
|
| 149 | - * @return void |
|
| 150 | - */ |
|
| 151 | - private function _register($config, $paths) |
|
| 152 | - { |
|
| 153 | - // before doing anything we have to make sure that EE_Qtip_Config parent is required. |
|
| 154 | - EE_Registry::instance()->load_lib('Qtip_Config', array(), true); |
|
| 155 | - |
|
| 156 | - if (!empty($paths)) { |
|
| 157 | - $paths = (array) $paths; |
|
| 158 | - foreach ($paths as $path) { |
|
| 159 | - $path = $path . $config . '.lib.php'; |
|
| 160 | - if (!is_readable($path)) { |
|
| 161 | - continue; |
|
| 162 | - } else { |
|
| 163 | - require_once $path; |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - // does class exist at this point? If it does then let's instantiate. If it doesn't then let's continue with other paths. |
|
| 169 | - if (!class_exists($config)) { |
|
| 170 | - $path = EE_LIBRARIES . 'qtips/' . $config . '.lib.php'; |
|
| 171 | - if (!is_readable($path)) { |
|
| 172 | - throw new EE_Error(sprintf(esc_html__('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable. Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config)); |
|
| 173 | - } else { |
|
| 174 | - require_once $path; |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - // now we attempt a class_exists one more time. |
|
| 179 | - if (!class_exists($config)) { |
|
| 180 | - throw new EE_Error(sprintf(esc_html__('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config)); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - // made it HERE? FINALLY, let's get things setup. |
|
| 184 | - $a = new ReflectionClass($config); |
|
| 185 | - $qtip = $a->newInstance(); |
|
| 186 | - |
|
| 187 | - // verify that $qtip is a valid object |
|
| 188 | - if (! $qtip instanceof EE_Qtip_Config) { |
|
| 189 | - throw new EE_Error(sprintf(esc_html__('The class given for the Qtip loader (%1$s) is not a child of the %2$sEE_Qtip_Config%3$s class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config, '<strong>', '</strong>')); |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - $this->_qtips[] = $a->newInstance(); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * This takes care of generating the qtip content containers. |
|
| 199 | - * Output gets put in the appropriate page footer (depending on context (either admin_footer or wp_footer) ) |
|
| 200 | - * |
|
| 201 | - * @access public |
|
| 202 | - * @return void |
|
| 203 | - */ |
|
| 204 | - public function setup_qtip() |
|
| 205 | - { |
|
| 206 | - if (empty($this->_qtips)) { |
|
| 207 | - return; // no qtips! |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - $content = array(); |
|
| 211 | - |
|
| 212 | - foreach ($this->_qtips as $qtip) { |
|
| 213 | - $content[] = $this->_generate_content_container($qtip); |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - echo implode('<br />', $content); |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * Generates a content container from a given EE_Qtip_Config object. |
|
| 222 | - * |
|
| 223 | - * @param EE_Qtip_Config $qtip |
|
| 224 | - * @return string (html content container for qtip); |
|
| 225 | - */ |
|
| 226 | - private function _generate_content_container($qtip) |
|
| 227 | - { |
|
| 228 | - $qts = $qtip->get_tips(); |
|
| 229 | - $content = array(); |
|
| 230 | - foreach ($qts as $qt) { |
|
| 231 | - if (! $qt instanceof EE_Qtip) { |
|
| 232 | - continue; |
|
| 233 | - } |
|
| 234 | - $content[] = '<div class="ee-qtip-helper-content hidden" id="' . esc_attr($qt->content_id) . '">' . |
|
| 235 | - $qt->content . '</div>'; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - return implode('<br />', $content); |
|
| 239 | - } |
|
| 14 | + /** |
|
| 15 | + * EEH_Qtip_Loader Object |
|
| 16 | + * @var EEH_Qtip_Loader |
|
| 17 | + * @access private |
|
| 18 | + */ |
|
| 19 | + private static $_instance = null; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * array of qtip config objects |
|
| 23 | + * @var EE_Qtip_Config[] |
|
| 24 | + */ |
|
| 25 | + private $_qtips = array(); |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + *@singleton method used to instantiate class object |
|
| 31 | + *@access public |
|
| 32 | + *@return EEH_Qtip_Loader instance |
|
| 33 | + */ |
|
| 34 | + public static function instance() |
|
| 35 | + { |
|
| 36 | + // check if class object is instantiated |
|
| 37 | + if (self::$_instance === null or ! is_object(self::$_instance) or ! ( self::$_instance instanceof EEH_Qtip_Loader )) { |
|
| 38 | + self::$_instance = new self(); |
|
| 39 | + } |
|
| 40 | + return self::$_instance; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + *private constructor to prevent direct creation |
|
| 47 | + * @Constructor |
|
| 48 | + * @access private |
|
| 49 | + * @return \EEH_Qtip_Loader |
|
| 50 | + */ |
|
| 51 | + private function __construct() |
|
| 52 | + { |
|
| 53 | + // let's just make sure this is instantiated in the right place. |
|
| 54 | + if (did_action('wp_print_styles') || did_action('admin_head')) { |
|
| 55 | + EE_Error::doing_it_wrong('EEH_Qtip_Loader', esc_html__('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso'), '4.1'); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Call this from wp_enqueue_scripts or admin_enqueue_scripts to setup and enqueue the qtip library |
|
| 62 | + * |
|
| 63 | + * @access public |
|
| 64 | + * @return void |
|
| 65 | + */ |
|
| 66 | + public function register_and_enqueue() |
|
| 67 | + { |
|
| 68 | + $qtips_js = !defined('SCRIPT_DEBUG') ? EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.js' : EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.js'; |
|
| 69 | + $qtip_map = EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.map'; |
|
| 70 | + $qtipcss = !defined('SCRIPT_DEBUG') ? EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.css' : EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.css'; |
|
| 71 | + |
|
| 72 | + wp_register_script('qtip-map', $qtip_map, array(), '3', true); |
|
| 73 | + wp_register_script('qtip', $qtips_js, array('jquery'), '3.0.3', true); |
|
| 74 | + wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS . 'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, true); |
|
| 75 | + |
|
| 76 | + wp_register_style('qtip-css', $qtipcss, array(), '2.2'); |
|
| 77 | + |
|
| 78 | + // k now let's see if there are any registered qtips. If there are, then we need to setup the localized script for ee-qtip-helper.js (and enqueue ee-qtip-helper.js of course!) |
|
| 79 | + if (!empty($this->_qtips)) { |
|
| 80 | + wp_enqueue_script('ee-qtip-helper'); |
|
| 81 | + wp_enqueue_style('qtip-css'); |
|
| 82 | + $qtips = array(); |
|
| 83 | + foreach ($this->_qtips as $qtip) { |
|
| 84 | + $qts = $qtip->get_tips(); |
|
| 85 | + foreach ($qts as $qt) { |
|
| 86 | + if (! $qt instanceof EE_Qtip) { |
|
| 87 | + continue; |
|
| 88 | + } |
|
| 89 | + $qtips[] = array( |
|
| 90 | + 'content_id' => $qt->content_id, |
|
| 91 | + 'options' => $qt->options, |
|
| 92 | + 'target' => $qt->target, |
|
| 93 | + ); |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + if (!empty($qtips)) { |
|
| 97 | + wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips )); |
|
| 98 | + } |
|
| 99 | + } else { |
|
| 100 | + // qtips has been requested without any registration (so assuming its just directly used in the admin). |
|
| 101 | + wp_enqueue_script('qtip'); |
|
| 102 | + wp_enqueue_style('qtip-css'); |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * This simply registers the given qtip config and: |
|
| 110 | + * - adds it to the $_qtips property array. |
|
| 111 | + * - sets up the content containers for all qtips in the config, |
|
| 112 | + * - registers and enqueues the qtip scripts and styles. |
|
| 113 | + * |
|
| 114 | + * @access public |
|
| 115 | + * @param array $paths Array of paths to check for the EE_Qtip class. If present we check these path(s) first. If not present (empty array), then it's assumed it's either in core/libraries/qtips OR the file is already loaded. |
|
| 116 | + * @param string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips] |
|
| 117 | + * @return void |
|
| 118 | + */ |
|
| 119 | + public function register($configname, $paths = array()) |
|
| 120 | + { |
|
| 121 | + |
|
| 122 | + // let's just make sure this is instantiated in the right place. |
|
| 123 | + if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) { |
|
| 124 | + EE_Error::doing_it_wrong('EEH_Qtip_Loader->register()', esc_html__('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso'), '4.1'); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + $configname = (array) $configname; // typecast to array |
|
| 128 | + foreach ($configname as $config) { |
|
| 129 | + $this->_register($config, $paths); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + // hook into appropriate footer |
|
| 133 | + $footer_action = is_admin() ? 'admin_footer' : 'wp_footer'; |
|
| 134 | + add_action($footer_action, array($this, 'setup_qtip'), 10); |
|
| 135 | + |
|
| 136 | + // make sure we "turn on" qtip js. |
|
| 137 | + add_filter('FHEE_load_qtip', '__return_true'); |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * private utility for registering and setting up qtip config objects |
|
| 144 | + * |
|
| 145 | + * @access private |
|
| 146 | + * @param string $config the short name of the class (will be used to generate the expected classname) |
|
| 147 | + * @param array $paths array of paths to check (or if empty we check core/libraries/qtips or assume its loaded) |
|
| 148 | + * @throws EE_Error |
|
| 149 | + * @return void |
|
| 150 | + */ |
|
| 151 | + private function _register($config, $paths) |
|
| 152 | + { |
|
| 153 | + // before doing anything we have to make sure that EE_Qtip_Config parent is required. |
|
| 154 | + EE_Registry::instance()->load_lib('Qtip_Config', array(), true); |
|
| 155 | + |
|
| 156 | + if (!empty($paths)) { |
|
| 157 | + $paths = (array) $paths; |
|
| 158 | + foreach ($paths as $path) { |
|
| 159 | + $path = $path . $config . '.lib.php'; |
|
| 160 | + if (!is_readable($path)) { |
|
| 161 | + continue; |
|
| 162 | + } else { |
|
| 163 | + require_once $path; |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + // does class exist at this point? If it does then let's instantiate. If it doesn't then let's continue with other paths. |
|
| 169 | + if (!class_exists($config)) { |
|
| 170 | + $path = EE_LIBRARIES . 'qtips/' . $config . '.lib.php'; |
|
| 171 | + if (!is_readable($path)) { |
|
| 172 | + throw new EE_Error(sprintf(esc_html__('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable. Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config)); |
|
| 173 | + } else { |
|
| 174 | + require_once $path; |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + // now we attempt a class_exists one more time. |
|
| 179 | + if (!class_exists($config)) { |
|
| 180 | + throw new EE_Error(sprintf(esc_html__('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config)); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + // made it HERE? FINALLY, let's get things setup. |
|
| 184 | + $a = new ReflectionClass($config); |
|
| 185 | + $qtip = $a->newInstance(); |
|
| 186 | + |
|
| 187 | + // verify that $qtip is a valid object |
|
| 188 | + if (! $qtip instanceof EE_Qtip_Config) { |
|
| 189 | + throw new EE_Error(sprintf(esc_html__('The class given for the Qtip loader (%1$s) is not a child of the %2$sEE_Qtip_Config%3$s class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config, '<strong>', '</strong>')); |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + $this->_qtips[] = $a->newInstance(); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * This takes care of generating the qtip content containers. |
|
| 199 | + * Output gets put in the appropriate page footer (depending on context (either admin_footer or wp_footer) ) |
|
| 200 | + * |
|
| 201 | + * @access public |
|
| 202 | + * @return void |
|
| 203 | + */ |
|
| 204 | + public function setup_qtip() |
|
| 205 | + { |
|
| 206 | + if (empty($this->_qtips)) { |
|
| 207 | + return; // no qtips! |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + $content = array(); |
|
| 211 | + |
|
| 212 | + foreach ($this->_qtips as $qtip) { |
|
| 213 | + $content[] = $this->_generate_content_container($qtip); |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + echo implode('<br />', $content); |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * Generates a content container from a given EE_Qtip_Config object. |
|
| 222 | + * |
|
| 223 | + * @param EE_Qtip_Config $qtip |
|
| 224 | + * @return string (html content container for qtip); |
|
| 225 | + */ |
|
| 226 | + private function _generate_content_container($qtip) |
|
| 227 | + { |
|
| 228 | + $qts = $qtip->get_tips(); |
|
| 229 | + $content = array(); |
|
| 230 | + foreach ($qts as $qt) { |
|
| 231 | + if (! $qt instanceof EE_Qtip) { |
|
| 232 | + continue; |
|
| 233 | + } |
|
| 234 | + $content[] = '<div class="ee-qtip-helper-content hidden" id="' . esc_attr($qt->content_id) . '">' . |
|
| 235 | + $qt->content . '</div>'; |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + return implode('<br />', $content); |
|
| 239 | + } |
|
| 240 | 240 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | public static function instance() |
| 35 | 35 | { |
| 36 | 36 | // check if class object is instantiated |
| 37 | - if (self::$_instance === null or ! is_object(self::$_instance) or ! ( self::$_instance instanceof EEH_Qtip_Loader )) { |
|
| 37 | + if (self::$_instance === null or ! is_object(self::$_instance) or ! (self::$_instance instanceof EEH_Qtip_Loader)) { |
|
| 38 | 38 | self::$_instance = new self(); |
| 39 | 39 | } |
| 40 | 40 | return self::$_instance; |
@@ -65,25 +65,25 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public function register_and_enqueue() |
| 67 | 67 | { |
| 68 | - $qtips_js = !defined('SCRIPT_DEBUG') ? EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.js' : EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.js'; |
|
| 69 | - $qtip_map = EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.map'; |
|
| 70 | - $qtipcss = !defined('SCRIPT_DEBUG') ? EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.css' : EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.css'; |
|
| 68 | + $qtips_js = ! defined('SCRIPT_DEBUG') ? EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.js' : EE_GLOBAL_ASSETS_URL.'qtip/jquery.qtip.js'; |
|
| 69 | + $qtip_map = EE_GLOBAL_ASSETS_URL.'qtip/jquery.qtip.min.map'; |
|
| 70 | + $qtipcss = ! defined('SCRIPT_DEBUG') ? EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.css' : EE_GLOBAL_ASSETS_URL.'qtip/jquery.qtip.css'; |
|
| 71 | 71 | |
| 72 | 72 | wp_register_script('qtip-map', $qtip_map, array(), '3', true); |
| 73 | 73 | wp_register_script('qtip', $qtips_js, array('jquery'), '3.0.3', true); |
| 74 | - wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS . 'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, true); |
|
| 74 | + wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS.'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, true); |
|
| 75 | 75 | |
| 76 | 76 | wp_register_style('qtip-css', $qtipcss, array(), '2.2'); |
| 77 | 77 | |
| 78 | 78 | // k now let's see if there are any registered qtips. If there are, then we need to setup the localized script for ee-qtip-helper.js (and enqueue ee-qtip-helper.js of course!) |
| 79 | - if (!empty($this->_qtips)) { |
|
| 79 | + if ( ! empty($this->_qtips)) { |
|
| 80 | 80 | wp_enqueue_script('ee-qtip-helper'); |
| 81 | 81 | wp_enqueue_style('qtip-css'); |
| 82 | 82 | $qtips = array(); |
| 83 | 83 | foreach ($this->_qtips as $qtip) { |
| 84 | 84 | $qts = $qtip->get_tips(); |
| 85 | 85 | foreach ($qts as $qt) { |
| 86 | - if (! $qt instanceof EE_Qtip) { |
|
| 86 | + if ( ! $qt instanceof EE_Qtip) { |
|
| 87 | 87 | continue; |
| 88 | 88 | } |
| 89 | 89 | $qtips[] = array( |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | ); |
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | - if (!empty($qtips)) { |
|
| 97 | - wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips )); |
|
| 96 | + if ( ! empty($qtips)) { |
|
| 97 | + wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array('qtips' => $qtips)); |
|
| 98 | 98 | } |
| 99 | 99 | } else { |
| 100 | 100 | // qtips has been requested without any registration (so assuming its just directly used in the admin). |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | // before doing anything we have to make sure that EE_Qtip_Config parent is required. |
| 154 | 154 | EE_Registry::instance()->load_lib('Qtip_Config', array(), true); |
| 155 | 155 | |
| 156 | - if (!empty($paths)) { |
|
| 156 | + if ( ! empty($paths)) { |
|
| 157 | 157 | $paths = (array) $paths; |
| 158 | 158 | foreach ($paths as $path) { |
| 159 | - $path = $path . $config . '.lib.php'; |
|
| 160 | - if (!is_readable($path)) { |
|
| 159 | + $path = $path.$config.'.lib.php'; |
|
| 160 | + if ( ! is_readable($path)) { |
|
| 161 | 161 | continue; |
| 162 | 162 | } else { |
| 163 | 163 | require_once $path; |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // does class exist at this point? If it does then let's instantiate. If it doesn't then let's continue with other paths. |
| 169 | - if (!class_exists($config)) { |
|
| 170 | - $path = EE_LIBRARIES . 'qtips/' . $config . '.lib.php'; |
|
| 171 | - if (!is_readable($path)) { |
|
| 169 | + if ( ! class_exists($config)) { |
|
| 170 | + $path = EE_LIBRARIES.'qtips/'.$config.'.lib.php'; |
|
| 171 | + if ( ! is_readable($path)) { |
|
| 172 | 172 | throw new EE_Error(sprintf(esc_html__('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable. Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config)); |
| 173 | 173 | } else { |
| 174 | 174 | require_once $path; |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | // now we attempt a class_exists one more time. |
| 179 | - if (!class_exists($config)) { |
|
| 179 | + if ( ! class_exists($config)) { |
|
| 180 | 180 | throw new EE_Error(sprintf(esc_html__('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config)); |
| 181 | 181 | } |
| 182 | 182 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | $qtip = $a->newInstance(); |
| 186 | 186 | |
| 187 | 187 | // verify that $qtip is a valid object |
| 188 | - if (! $qtip instanceof EE_Qtip_Config) { |
|
| 188 | + if ( ! $qtip instanceof EE_Qtip_Config) { |
|
| 189 | 189 | throw new EE_Error(sprintf(esc_html__('The class given for the Qtip loader (%1$s) is not a child of the %2$sEE_Qtip_Config%3$s class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config, '<strong>', '</strong>')); |
| 190 | 190 | } |
| 191 | 191 | |
@@ -228,11 +228,11 @@ discard block |
||
| 228 | 228 | $qts = $qtip->get_tips(); |
| 229 | 229 | $content = array(); |
| 230 | 230 | foreach ($qts as $qt) { |
| 231 | - if (! $qt instanceof EE_Qtip) { |
|
| 231 | + if ( ! $qt instanceof EE_Qtip) { |
|
| 232 | 232 | continue; |
| 233 | 233 | } |
| 234 | - $content[] = '<div class="ee-qtip-helper-content hidden" id="' . esc_attr($qt->content_id) . '">' . |
|
| 235 | - $qt->content . '</div>'; |
|
| 234 | + $content[] = '<div class="ee-qtip-helper-content hidden" id="'.esc_attr($qt->content_id).'">'. |
|
| 235 | + $qt->content.'</div>'; |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | return implode('<br />', $content); |