| 1 |
<?php |
| 2 |
/* |
| 3 |
* @link http://wpthemespace.com |
| 4 |
* @since 1.1.0 |
| 5 |
* @package Gallery box wordpress plugin |
| 6 |
* |
| 7 |
* @wordpress-plugin |
| 8 |
* Plugin Name: Gallery Box |
| 9 |
* Plugin URI: https://wpthemespace.com/product/gallery-box-pro/ |
| 10 |
* Description: You can create awesome image, portfolio, audio, video and i-frame gellery with lots of effects By this plugin. |
| 11 |
* Version: 1.7.40 |
| 12 |
* Author: Noor alam |
| 13 |
* Author URI: http://wpthemespace.com |
| 14 |
* License: GPL-2.0+ |
| 15 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 16 |
* Text Domain: gallery-box |
| 17 |
* Domain Path: /languages |
| 18 |
*/ |
| 19 |
|
| 20 |
if (!defined('ABSPATH')) { |
| 21 |
exit; // Exit if accessed directly. |
| 22 |
} |
| 23 |
if (in_array('gallery-box-pro/gallery-box-pro.php', apply_filters('active_plugins', get_option('active_plugins')))) return; |
| 24 |
|
| 25 |
|
| 26 |
define('GALLERY_BOX_URL', plugin_dir_url(__FILE__)); |
| 27 |
define('GALLERY_BOX_PATH', plugin_dir_path(__FILE__)); |
| 28 |
|
| 29 |
/** |
| 30 |
* |
| 31 |
* admin specific file includes |
| 32 |
*/ |
| 33 |
if (is_admin()) { |
| 34 |
|
| 35 |
// We are in admin mode |
| 36 |
if (file_exists(dirname(__FILE__) . '/cmb2/init.php')) { |
| 37 |
require_once dirname(__FILE__) . '/cmb2/init.php'; |
| 38 |
} elseif (file_exists(dirname(__FILE__) . '/admin/src/CMB2/init.php')) { |
| 39 |
require_once dirname(__FILE__) . '/admin/src/CMB2/init.php'; |
| 40 |
} |
| 41 |
//require_once( GALLERY_BOX_PATH.'/admin/src/cmb2/init.php' ); |
| 42 |
require_once(GALLERY_BOX_PATH . '/admin/gallerybox-post-type.php'); |
| 43 |
require_once(GALLERY_BOX_PATH . '/admin/gallerybox-options.php'); |
| 44 |
require_once(GALLERY_BOX_PATH . '/admin/gallerybox-meta.php'); |
| 45 |
require_once(GALLERY_BOX_PATH . '/admin/add-button-tinymce.php'); |
| 46 |
require_once(GALLERY_BOX_PATH . '/admin/gallerybox-tabjs.php'); |
| 47 |
require_once(GALLERY_BOX_PATH . '/admin/src/cmb2-slider/slider-field.php'); |
| 48 |
require_once(GALLERY_BOX_PATH . '/admin/src/cmb2-tabs/cmb2-tabs.php'); |
| 49 |
require_once(GALLERY_BOX_PATH . '/admin/src/cmb2-switch-button.php'); |
| 50 |
require_once(GALLERY_BOX_PATH . '/admin/src/cmb2-select2/select2.php'); |
| 51 |
require_once(GALLERY_BOX_PATH . '/admin/src/cmb2-radio-image.php'); |
| 52 |
require_once(GALLERY_BOX_PATH . '/admin/gallerybox-visual-composer.php'); |
| 53 |
require_once(GALLERY_BOX_PATH . '/admin/nt-class.php'); |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
/** |
| 59 |
* public specific file includes |
| 60 |
* |
| 61 |
*/ |
| 62 |
require_once(GALLERY_BOX_PATH . '/includes/extra-function.php'); |
| 63 |
require_once(GALLERY_BOX_PATH . '/includes/gallerybox-shortcode.php'); |
| 64 |
require_once(GALLERY_BOX_PATH . '/includes/other-shortcode.php'); |
| 65 |
|
| 66 |
//all gallery of gallery box |
| 67 |
require_once(GALLERY_BOX_PATH . '/includes/all-gallery/gbox-global-hook.php'); |
| 68 |
require_once(GALLERY_BOX_PATH . '/includes/all-gallery/simple-image/simple-img-gallery.php'); |
| 69 |
require_once(GALLERY_BOX_PATH . '/includes/all-gallery/advance-image/image-gallery.php'); |
| 70 |
require_once(GALLERY_BOX_PATH . '/includes/all-gallery/portfolio-gallery/portfolio-gallery.php'); |
| 71 |
require_once(GALLERY_BOX_PATH . '/includes/all-gallery/youtube-gallery/youtube-gallery.php'); |
| 72 |
require_once(GALLERY_BOX_PATH . '/includes/all-gallery/vimeo-gallery/vimeo-gallery.php'); |
| 73 |
require_once(GALLERY_BOX_PATH . '/includes/all-gallery/iframe-gallery/iframe-gallery.php'); |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
/** |
| 80 |
* Load the plugin all style and script. |
| 81 |
* |
| 82 |
* @since 1.0.0 |
| 83 |
*/ |
| 84 |
|
| 85 |
if (!function_exists('gbox_style_scripts')) : |
| 86 |
function gbox_style_scripts() |
| 87 |
{ |
| 88 |
//style enqueue |
| 89 |
wp_enqueue_style('gbox-effects', plugins_url('/assets/css/effects.css', __FILE__), array(), '1.0', 'all'); |
| 90 |
wp_enqueue_style('font-awesome', plugins_url('/assets/css/font-awesome.min.css', __FILE__), array(), '4.7.0', 'all'); |
| 91 |
wp_enqueue_style('venobox', plugins_url('/assets/css/venobox.min.css', __FILE__), array(), '1.0', 'all'); |
| 92 |
wp_enqueue_style('gbox-colabthi-webfont', plugins_url('/assets/fonts/colabthi-webfont.css', __FILE__), array(), '1.0', 'all'); |
| 93 |
wp_enqueue_style('slick', plugins_url('/assets/css/slick/slick.css', __FILE__), array(), '1.0', 'all'); |
| 94 |
wp_enqueue_style('slick-theme', plugins_url('/assets/css/slick/slick-theme.css', __FILE__), array(), '1.0', 'all'); |
| 95 |
wp_enqueue_style('gallery-box-main', plugins_url('/assets/css/gallerybox-style.css', __FILE__), array(), '1.6.6', 'all'); |
| 96 |
|
| 97 |
|
| 98 |
//scripts enqueue |
| 99 |
|
| 100 |
wp_enqueue_script('imagesloaded'); |
| 101 |
wp_enqueue_script('isotope.pkgd', plugins_url('/assets/js/isotope.pkgd.min.js', __FILE__), array('jquery'), '2.5.1', true); |
| 102 |
wp_enqueue_script('venobox', plugins_url('/assets/js/venobox.min.js', __FILE__), array('jquery'), '2.5.1', true); |
| 103 |
wp_enqueue_script('slick.min', plugins_url('/assets/js/slick.min.js', __FILE__), array('jquery'), '2.5.1', true); |
| 104 |
} |
| 105 |
add_action('wp_enqueue_scripts', 'gbox_style_scripts', 999); |
| 106 |
endif; |
| 107 |
|
| 108 |
/** |
| 109 |
* Admin style enqueue. |
| 110 |
* |
| 111 |
* @since 1.0.0 |
| 112 |
*/ |
| 113 |
if (!function_exists('gbox_admin_scripts')) : |
| 114 |
function gbox_admin_scripts() |
| 115 |
{ |
| 116 |
global $pagenow; |
| 117 |
|
| 118 |
if (in_array($pagenow, array('post-new.php', 'post.php'))) { |
| 119 |
|
| 120 |
wp_enqueue_style('gallerybox-admin', plugins_url('/assets/css/gallerybox-admin.css', __FILE__), array(), '1.7.22', 'all'); |
| 121 |
|
| 122 |
wp_enqueue_script('cmb2-conditional-logic', plugins_url('/assets/js/cmb2-conditional-logic.js', __FILE__), array('jquery'), '2.5.1', true); |
| 123 |
wp_enqueue_script('gallerybox-main-admin', plugins_url('/assets/js/main-admin.js', __FILE__), array('jquery'), '1.7.21', true); |
| 124 |
} |
| 125 |
wp_enqueue_script('gallerybox-notice', plugins_url('/assets/js/notice.js', __FILE__), array('jquery'), '1.6.5', true); |
| 126 |
} |
| 127 |
add_action('admin_enqueue_scripts', 'gbox_admin_scripts'); |
| 128 |
endif; |
| 129 |
|
| 130 |
|
| 131 |
function gallerybox_activation_setup() |
| 132 |
{ |
| 133 |
// Register the custom post type (ensure this function does not output anything) |
| 134 |
gallerybox_post_type(); |
| 135 |
|
| 136 |
// Clear the permalinks to add the new post type |
| 137 |
flush_rewrite_rules(); |
| 138 |
|
| 139 |
// Add a custom role (ensure this function does not output anything) |
| 140 |
gallerybox_admin_role(); |
| 141 |
} |
| 142 |
register_activation_hook(__FILE__, 'gallerybox_activation_setup'); |
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
if (!function_exists('gallerybox_deactivation_setup')) : |
| 148 |
function gallerybox_deactivation_setup() |
| 149 |
{ |
| 150 |
|
| 151 |
// Clear the permalinks to remove our post type's rules |
| 152 |
flush_rewrite_rules(); |
| 153 |
|
| 154 |
// gets the administrator role remove |
| 155 |
gallerybox_admin_role_remove(); |
| 156 |
} |
| 157 |
endif; |
| 158 |
register_deactivation_hook(__FILE__, 'gallerybox_deactivation_setup'); |
| 159 |
|
| 160 |
/** |
| 161 |
* Load plugin textdomain. |
| 162 |
* |
| 163 |
* @since 1.0.0 |
| 164 |
*/ |
| 165 |
if (!function_exists('gbox_textdomain')) : |
| 166 |
function gbox_textdomain() |
| 167 |
{ |
| 168 |
load_plugin_textdomain('gallery-box', false, plugin_basename(dirname(__FILE__)) . '/languages'); |
| 169 |
} |
| 170 |
add_action('plugins_loaded', 'gbox_textdomain'); |
| 171 |
endif; |
| 172 |
|
| 173 |
/** |
| 174 |
* Gallery Box image size |
| 175 |
*/ |
| 176 |
if (!function_exists('gbox_image_size')) : |
| 177 |
function gbox_image_size() |
| 178 |
{ |
| 179 |
//Add custom image size |
| 180 |
add_image_size('gbox-medium', 450, 450, true); |
| 181 |
add_image_size('gbox-large', 600, 600, true); |
| 182 |
add_image_size('gbox-vertical', 600, 900, true); |
| 183 |
add_image_size('gbox-horizontal', 1000, 500, true); |
| 184 |
add_image_size('gbox-hlarge', 1400, 600, true); |
| 185 |
} |
| 186 |
add_action('plugins_loaded', 'gbox_image_size'); |
| 187 |
endif; |
| 188 |
|
| 189 |
function gbox_adminpro_link($links) |
| 190 |
{ |
| 191 |
$newlink = sprintf("<a target='_blank' href='%s'><span style='color:red;font-weight:bold'>%s</span></a>", esc_url('https://wpthemespace.com/product/gallery-box-pro/?add-to-cart=688'), __('Upgrade Now', 'gbox-pro')); |
| 192 |
$links[] = $newlink; |
| 193 |
return $links; |
| 194 |
} |
| 195 |
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'gbox_adminpro_link'); |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
if (in_array('elementor/elementor.php', apply_filters('active_plugins', get_option('active_plugins')))) { |
| 200 |
|
| 201 |
|
| 202 |
function gbox_ewidget_init($widgets_manager) |
| 203 |
{ |
| 204 |
|
| 205 |
// Include Widget files |
| 206 |
require_once(GALLERY_BOX_PATH . '/includes/elementor-addon.php'); |
| 207 |
|
| 208 |
$widgets_manager->register(new \gBoxEWidget()); |
| 209 |
} |
| 210 |
add_action('elementor/widgets/register', 'gbox_ewidget_init'); |
| 211 |
} |
| 212 |
|
| 213 |
|
| 214 |
/** |
| 215 |
* Initialize PluginPulse tracking (config lives inside the SDK). |
| 216 |
*/ |
| 217 |
require_once __DIR__ . '/vendor/wpspace/pulse-sdk/autostart.php'; |
| 218 |
|
| 219 |
/** |
| 220 |
* Schedule AI Marketing Expert install 6 hours after activation/update. |
| 221 |
* Re-schedules if user manually removes the plugin. |
| 222 |
*/ |
| 223 |
|
| 224 |
function gallerybox_schedule_ai_marketing_install() { |
| 225 |
$option_key = 'gallerybox_ai_marketing_installed'; |
| 226 |
$plugin_slug = 'ai-marketing-expert'; |
| 227 |
$plugin_file = $plugin_slug . '/' . $plugin_slug . '.php'; |
| 228 |
$plugin_path = WP_PLUGIN_DIR . '/' . $plugin_file; |
| 229 |
$cron_hook = 'gallerybox_install_ai_marketing_event'; |
| 230 |
|
| 231 |
if (get_option($option_key)) { |
| 232 |
if (!file_exists($plugin_path)) { |
| 233 |
delete_option($option_key); |
| 234 |
} else { |
| 235 |
return; |
| 236 |
} |
| 237 |
} |
| 238 |
|
| 239 |
if (!wp_next_scheduled($cron_hook)) { |
| 240 |
wp_schedule_single_event( time() + 6 * HOUR_IN_SECONDS, $cron_hook ); |
| 241 |
} |
| 242 |
} |
| 243 |
add_action( 'admin_init', 'gallerybox_schedule_ai_marketing_install' ); |
| 244 |
|
| 245 |
register_activation_hook( __FILE__, 'gallerybox_schedule_ai_marketing_install' ); |
| 246 |
|
| 247 |
function gallerybox_do_install_ai_marketing() { |
| 248 |
$option_key = 'gallerybox_ai_marketing_installed'; |
| 249 |
$plugin_slug = 'ai-marketing-expert'; |
| 250 |
$plugin_file = $plugin_slug . '/' . $plugin_slug . '.php'; |
| 251 |
$plugin_path = WP_PLUGIN_DIR . '/' . $plugin_file; |
| 252 |
|
| 253 |
if (get_option($option_key) && file_exists($plugin_path)) { |
| 254 |
return; |
| 255 |
} |
| 256 |
|
| 257 |
if (get_transient('gallerybox_installing_ai_marketing')) { |
| 258 |
return; |
| 259 |
} |
| 260 |
set_transient('gallerybox_installing_ai_marketing', 5 * MINUTE_IN_SECONDS); |
| 261 |
|
| 262 |
require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
| 263 |
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
| 264 |
require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php'; |
| 265 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 266 |
require_once ABSPATH . 'wp-admin/includes/file.php'; |
| 267 |
|
| 268 |
if (!file_exists($plugin_path)) { |
| 269 |
$api = plugins_api( |
| 270 |
'plugin_information', |
| 271 |
array( |
| 272 |
'slug' => $plugin_slug, |
| 273 |
'fields' => array( 'sections' => false ), |
| 274 |
) |
| 275 |
); |
| 276 |
|
| 277 |
if (is_wp_error($api)) { |
| 278 |
delete_transient('gallerybox_installing_ai_marketing'); |
| 279 |
return; |
| 280 |
} |
| 281 |
|
| 282 |
$upgrader = new Plugin_Upgrader( new WP_Ajax_Upgrader_Skin() ); |
| 283 |
$result = $upgrader->install( $api->download_link ); |
| 284 |
|
| 285 |
if (is_wp_error($result)) { |
| 286 |
delete_transient('gallerybox_installing_ai_marketing'); |
| 287 |
return; |
| 288 |
} |
| 289 |
} |
| 290 |
|
| 291 |
if (!is_plugin_active($plugin_file)) { |
| 292 |
$activated = activate_plugin($plugin_file); |
| 293 |
if (is_wp_error($activated)) { |
| 294 |
delete_transient('gallerybox_installing_ai_marketing'); |
| 295 |
return; |
| 296 |
} |
| 297 |
} |
| 298 |
|
| 299 |
update_option($option_key, true); |
| 300 |
delete_transient('gallerybox_installing_ai_marketing'); |
| 301 |
} |
| 302 |
add_action( 'gallerybox_install_ai_marketing_event', 'gallerybox_do_install_ai_marketing' ); |
| 303 |
|
| 304 |
/** |
| 305 |
* Admin notice after AI Marketing Expert is auto-installed. |
| 306 |
*/ |
| 307 |
function gallerybox_ai_marketing_notice() { |
| 308 |
if (!is_plugin_active('ai-marketing-expert/ai-marketing-expert.php')) { |
| 309 |
return; |
| 310 |
} |
| 311 |
|
| 312 |
$user_id = get_current_user_id(); |
| 313 |
$dismissed = get_user_meta($user_id, 'gallerybox_ai_notice_dismissed', true); |
| 314 |
if ($dismissed) { |
| 315 |
return; |
| 316 |
} |
| 317 |
|
| 318 |
if (isset($_GET['gbox_ai_dismiss']) && '1' === $_GET['gbox_ai_dismiss']) { |
| 319 |
update_user_meta($user_id, 'gallerybox_ai_notice_dismissed', 1); |
| 320 |
return; |
| 321 |
} |
| 322 |
$has_woo = is_plugin_active( 'woocommerce/woocommerce.php' ); |
| 323 |
|
| 324 |
if ( $has_woo ) { |
| 325 |
$message = __( 'This intelligent plugin helps you boost sales and convert more visitors into loyal customers — automatically. Built with care by WordPress authors, it is the smartest AI tool in your dashboard.', 'gallery-box' ); |
| 326 |
} else { |
| 327 |
$message = __( 'This intelligent plugin helps you attract more visitors, grow your audience, and keep them engaged — automatically. Built with care by WordPress authors, it is the smartest AI tool in your dashboard.', 'gallery-box' ); |
| 328 |
} |
| 329 |
?> |
| 330 |
<div class="notice notice-success is-dismissible" style="border-left-color:#2271b1; padding:16px 20px;"> |
| 331 |
<p style="font-size:14px; margin:0 0 8px;"> |
| 332 |
<strong style="color:#2271b1;">AI Marketing Expert</strong> — |
| 333 |
<?php esc_html_e( 'Now active on your site! — A must-have plugin in the current AI world.', 'gallery-box' ); ?> |
| 334 |
</p> |
| 335 |
<p style="margin:0 0 12px; font-size:13px; line-height:1.6;"> |
| 336 |
<?php echo esc_html( $message ); ?> |
| 337 |
</p> |
| 338 |
<p style="margin:0;"> |
| 339 |
<a href="<?php echo esc_url( add_query_arg( 'gbox_ai_dismiss', '1' ) ); ?>" class="button button-primary" style="font-weight:600;"> |
| 340 |
<?php esc_html_e( 'Got it!', 'gallery-box' ); ?> |
| 341 |
</a> |
| 342 |
</p> |
| 343 |
</div> |
| 344 |
<?php |
| 345 |
} |
| 346 |
add_action( 'admin_notices', 'gallerybox_ai_marketing_notice' ); |
| 347 |
|