magnific_popup.module in Magnific Popup 8
Same filename and directory in other branches
Magnific popup module file for hooks and global methods.
File
magnific_popup.moduleView source
<?php
/**
* @file
* Magnific popup module file for hooks and global methods.
*/
/**
* Implements hook_library_info_alter().
*
* Used to maintain backwards compatibility with the legacy library path
* used in the early versions of the module.
*/
function magnific_popup_library_info_alter(&$libraries, $extension) {
if ($extension === 'magnific_popup' && _magnific_popup_use_legacy_path()) {
if (isset($libraries['magnific_popup']['js']['/libraries/magnific-popup/dist/jquery.magnific-popup.min.js'])) {
$libraries['magnific_popup']['js']['/libraries/magnific-popup/jquery.magnific-popup.min.js'] = $libraries['magnific_popup']['js']['/libraries/magnific-popup/dist/jquery.magnific-popup.min.js'];
unset($libraries['magnific_popup']['js']['/libraries/magnific-popup/dist/jquery.magnific-popup.min.js']);
}
if (isset($libraries['magnific_popup']['css']['base']['/libraries/magnific-popup/dist/magnific-popup.css'])) {
$libraries['magnific_popup']['css']['base']['/libraries/magnific-popup/magnific-popup.css'] = $libraries['magnific_popup']['css']['base']['/libraries/magnific-popup/dist/magnific-popup.css'];
unset($libraries['magnific_popup']['css']['base']['/libraries/magnific-popup/dist/magnific-popup.css']);
}
}
}
/**
* Attempts to determine where the magnific popup library is installed.
*
* @see https://www.drupal.org/node/2857287
*
* @return bool
* TRUE if the legacy path should be used.
*/
function _magnific_popup_use_legacy_path() {
if (file_exists(DRUPAL_ROOT . '/libraries/magnific-popup/jquery.magnific-popup.min.js') && file_exists(DRUPAL_ROOT . '/libraries/magnific-popup/magnific-popup.css')) {
return TRUE;
}
return FALSE;
}
Functions
Name | Description |
---|---|
magnific_popup_library_info_alter | Implements hook_library_info_alter(). |
_magnific_popup_use_legacy_path | Attempts to determine where the magnific popup library is installed. |