| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Responsive Gallery Grid |
| 4 |
Plugin URI: https://responsive-gallery-grid.bdwm.be |
| 5 |
Description: Converts the default wordpress gallery to a Google+ styled image gallery grid, where the images are scaled to fill the gallery container, while maintaining image aspect ratio's. |
| 6 |
Author: Jules Colle, BDWM |
| 7 |
Author URI: http://bdwm.be |
| 8 |
Version: 2.4.1 |
| 9 |
|
| 10 |
This program is free software; you can redistribute it and/or modify |
| 11 |
it under the terms of the GNU General Public License, version 2, as |
| 12 |
published by the Free Software Foundation. |
| 13 |
|
| 14 |
This program is distributed in the hope that it will be useful, |
| 15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 |
GNU General Public License for more details. |
| 18 |
|
| 19 |
You should have received a copy of the GNU General Public License |
| 20 |
along with this program; if not, write to the Free Software |
| 21 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 22 |
|
| 23 |
*/ |
| 24 |
|
| 25 |
// don't do anything if the RGG plugin is already loaded |
| 26 |
// (RGG and RGG Pro should not be activated together, but if they are, make sure only the first one loaded is used.) |
| 27 |
|
| 28 |
if (!function_exists('rgg_gallery_shortcode')) { |
| 29 |
|
| 30 |
define('RGG_PLUGIN', 'rgg'); |
| 31 |
define('RGG_OPTIONS', 'rgg_options'); |
| 32 |
|
| 33 |
define( 'RGG_VERSION', '2.4.1' ); |
| 34 |
define( 'RGG_REQUIRED_WP_VERSION', '4.1' ); |
| 35 |
define( 'RGG_PLUGIN_PATH', __FILE__ ); |
| 36 |
define( 'RGG_PLUGIN_BASENAME', plugin_basename( RGG_PLUGIN_PATH ) ); |
| 37 |
define( 'RGG_PLUGIN_NAME', trim( dirname( RGG_PLUGIN_BASENAME ), '/' ) ); |
| 38 |
define( 'RGG_PLUGIN_DIR', untrailingslashit( dirname( RGG_PLUGIN_PATH ) ) ); |
| 39 |
define( 'RGG_PLUGIN_DIR_URL', plugins_url('',RGG_PLUGIN_PATH)); |
| 40 |
|
| 41 |
define('RGG_IS_PRO', file_exists(RGG_PLUGIN_DIR.'/pro/rgg_pro_options.php')); |
| 42 |
|
| 43 |
global $rgg_options, $rgg_settings; |
| 44 |
$rgg_settings = array(); |
| 45 |
require_once RGG_PLUGIN_DIR.'/rgg-options.php'; |
| 46 |
if (RGG_IS_PRO) { |
| 47 |
require_once RGG_PLUGIN_DIR.'/pro/update.php'; |
| 48 |
} |
| 49 |
require_once RGG_PLUGIN_DIR.'/gallery-shortcode.php'; |
| 50 |
require_once RGG_PLUGIN_DIR.'/gutenberg.php'; |
| 51 |
|
| 52 |
|
| 53 |
// register scripts and styles |
| 54 |
|
| 55 |
function rgg_register_scripts() { |
| 56 |
|
| 57 |
|
| 58 |
global $rgg_settings, $rgg_options; |
| 59 |
|
| 60 |
if (count($rgg_settings) == 0) return; |
| 61 |
|
| 62 |
$rgg_settings['rgg_is_pro'] = RGG_IS_PRO; |
| 63 |
|
| 64 |
$deps = array('jquery'); |
| 65 |
|
| 66 |
foreach ($rgg_settings as $single_gallery_settings) { |
| 67 |
|
| 68 |
if (!is_array($single_gallery_settings)) { |
| 69 |
continue; |
| 70 |
} |
| 71 |
|
| 72 |
if ( |
| 73 |
$single_gallery_settings['lightbox'] == 'simplelightbox' |
| 74 |
) { |
| 75 |
wp_enqueue_script( 'rgg-simplelightbox', RGG_PLUGIN_DIR_URL . '/lib/simplelightbox/simple-lightbox.min.js', array( 'jquery' ), RGG_VERSION ); |
| 76 |
$deps[] = 'rgg-simplelightbox'; |
| 77 |
} |
| 78 |
if ($single_gallery_settings['lightbox'] == 'image-above') { |
| 79 |
wp_enqueue_script('slick', RGG_PLUGIN_DIR_URL.'/lib/slick/slick.1.9.0.min.js', ['jquery'], RGG_VERSION); |
| 80 |
$deps[] = 'slick'; |
| 81 |
} |
| 82 |
|
| 83 |
} |
| 84 |
|
| 85 |
wp_enqueue_script('jquery'); |
| 86 |
wp_enqueue_script('rgg-main', RGG_PLUGIN_DIR_URL.'/js/main.js', $deps, RGG_VERSION ); |
| 87 |
wp_localize_script( 'rgg-main', 'rgg_params', $rgg_settings ); |
| 88 |
} |
| 89 |
|
| 90 |
function rgg_register_styles() { |
| 91 |
|
| 92 |
//global $rgg_settings, $rgg_options; |
| 93 |
|
| 94 |
// enqueue css |
| 95 |
|
| 96 |
$deps = array(); |
| 97 |
|
| 98 |
// big change: load all css always. (in header.) This is because there is no way to know at this point if a shortcode will be loaded that will need the css. |
| 99 |
// TODO: at least minimize it then? |
| 100 |
|
| 101 |
wp_enqueue_style( 'rgg-simplelightbox', RGG_PLUGIN_DIR_URL.'/lib/simplelightbox/simplelightbox.min.css', array(), RGG_VERSION); |
| 102 |
$deps[] = 'rgg-simplelightbox'; |
| 103 |
|
| 104 |
wp_enqueue_style('slickstyle', RGG_PLUGIN_DIR_URL.'/lib/slick/slick.1.9.0.min.css', [], RGG_VERSION); |
| 105 |
wp_enqueue_style('slick-theme', RGG_PLUGIN_DIR_URL.'/lib/slick/slick-theme.css', ['slickstyle'], RGG_VERSION); |
| 106 |
$deps[] = 'slick-theme'; |
| 107 |
|
| 108 |
wp_enqueue_style( 'rgg-style', RGG_PLUGIN_DIR_URL.'/css/style.css', $deps, RGG_VERSION ); |
| 109 |
|
| 110 |
} |
| 111 |
|
| 112 |
add_action('wp_footer', 'rgg_register_scripts'); |
| 113 |
add_action('wp_enqueue_scripts', 'rgg_register_styles'); |
| 114 |
} |