| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Pixel Gallery |
| 4 |
* Plugin URI: https://pixelgallery.pro/ |
| 5 |
* Description: The all-new <a href="https://pixelgallery.pro/">Pixel Gallery</a> brings incredibly advanced, and super-flexible widgets, and A to Z essential addons to the Elementor page builder for WordPress. Explore expertly-coded widgets with first-class support by experts. |
| 6 |
* Version: 2.1.13 |
| 7 |
* Author: BdThemes |
| 8 |
* Author URI: https://bdthemes.com/ |
| 9 |
* Text Domain: pixel-gallery |
| 10 |
* Domain Path: /languages |
| 11 |
* License: GPL3 |
| 12 |
* Elementor requires at least: 4.0.0 |
| 13 |
* Elementor tested up to: 4.1.4 |
| 14 |
*/ |
| 15 |
|
| 16 |
// Some pre defined value for easy use |
| 17 |
define( 'BDTPG_VER', '2.1.13' ); |
| 18 |
define( 'BDTPG_TPL_DB_VER', '1.0.0' ); |
| 19 |
define( 'BDTPG__FILE__', __FILE__ ); |
| 20 |
|
| 21 |
// Load white label configuration if it exists (before defining BDTPG_TITLE) |
| 22 |
if ( ! defined( 'BDTPG_WL' ) ) { |
| 23 |
if ( get_option( 'pg_white_label_enabled' ) ) { |
| 24 |
define( 'BDTPG_WL', true ); |
| 25 |
$white_label_config = dirname( __FILE__ ) . '/admin/white-label/white-label-config.php'; |
| 26 |
if ( file_exists( $white_label_config ) ) { |
| 27 |
require_once( $white_label_config ); |
| 28 |
} |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
if ( ! defined( 'BDTPG_TITLE' ) ) { |
| 33 |
define( 'BDTPG_TITLE', 'Pixel Gallery' ); |
| 34 |
} |
| 35 |
|
| 36 |
if ( ! function_exists( '_is_pg_pro_installed' ) ) { |
| 37 |
|
| 38 |
function _is_pg_pro_installed() { |
| 39 |
|
| 40 |
if ( ! function_exists( 'get_plugins' ) ) { |
| 41 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 42 |
} |
| 43 |
|
| 44 |
$file_path = 'pixel-gallery-pro/pixel-gallery-pro.php'; |
| 45 |
$installed_plugins = get_plugins(); |
| 46 |
|
| 47 |
return isset( $installed_plugins[ $file_path ] ); |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
if ( ! function_exists( '_is_pg_pro_activated' ) ) { |
| 52 |
|
| 53 |
function _is_pg_pro_activated() { |
| 54 |
|
| 55 |
if ( ! function_exists( 'get_plugins' ) ) { |
| 56 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 57 |
} |
| 58 |
|
| 59 |
$file_path = 'pixel-gallery-pro/pixel-gallery-pro.php'; |
| 60 |
$installed_plugins = get_plugins(); |
| 61 |
|
| 62 |
if ( is_plugin_active( $file_path ) ) { |
| 63 |
return true; |
| 64 |
} |
| 65 |
|
| 66 |
return false; |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
// Helper function here |
| 71 |
require_once ( dirname( __FILE__ ) . '/includes/helper.php' ); |
| 72 |
|
| 73 |
if ( ! _is_pg_pro_activated() ) { |
| 74 |
require_once BDTPG_INC_PATH . 'class-pro-widget-map.php'; |
| 75 |
} |
| 76 |
|
| 77 |
if ( function_exists( 'pg_license_validation' ) && true !== pg_license_validation() ) { |
| 78 |
require_once BDTPG_INC_PATH . 'class-pro-widget-map.php'; |
| 79 |
} |
| 80 |
|
| 81 |
require_once ( dirname( __FILE__ ) . '/includes/utils.php' ); |
| 82 |
|
| 83 |
/** |
| 84 |
* Loads translations |
| 85 |
* |
| 86 |
* @return void |
| 87 |
*/ |
| 88 |
|
| 89 |
if ( ! function_exists( 'pixel_gallery_load_textdomain' ) ) { |
| 90 |
function pixel_gallery_load_textdomain() { |
| 91 |
load_plugin_textdomain( 'pixel-gallery', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
| 92 |
} |
| 93 |
add_action( 'init', 'pixel_gallery_load_textdomain' ); |
| 94 |
} |
| 95 |
|
| 96 |
/** |
| 97 |
* Plugin load here correctly |
| 98 |
* Also loaded the language file from here |
| 99 |
*/ |
| 100 |
function pixel_gallery_load_plugin() { |
| 101 |
|
| 102 |
if ( ! did_action( 'elementor/loaded' ) ) { |
| 103 |
add_action( 'admin_notices', 'pixel_gallery_fail_load' ); |
| 104 |
|
| 105 |
return; |
| 106 |
} |
| 107 |
|
| 108 |
// Setup wizard init file |
| 109 |
require_once( dirname( __FILE__ ) . '/includes/setup-wizard/init.php' ); |
| 110 |
|
| 111 |
// Widgets filters here |
| 112 |
require_once ( BDTPG_INC_PATH . 'pixel-gallery-filters.php' ); |
| 113 |
|
| 114 |
// Pixel gallery widget and assets loader |
| 115 |
require_once ( BDTPG_PATH . 'loader.php' ); |
| 116 |
|
| 117 |
// Initialize custom CSS/JS injection on frontend |
| 118 |
add_action( 'wp_head', 'pg_inject_header_custom_code', 999 ); |
| 119 |
add_action( 'wp_footer', 'pg_inject_footer_custom_code', 999 ); |
| 120 |
} |
| 121 |
|
| 122 |
add_action( 'plugins_loaded', 'pixel_gallery_load_plugin', 9 ); |
| 123 |
|
| 124 |
|
| 125 |
/** |
| 126 |
* Check Elementor installed and activated correctly |
| 127 |
*/ |
| 128 |
function pixel_gallery_fail_load() { |
| 129 |
|
| 130 |
$screen = get_current_screen(); |
| 131 |
|
| 132 |
if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) { |
| 133 |
return; |
| 134 |
} |
| 135 |
|
| 136 |
$plugin = 'elementor/elementor.php'; |
| 137 |
|
| 138 |
if ( _is_elementor_installed() ) { |
| 139 |
if ( ! current_user_can( 'activate_plugins' ) ) { |
| 140 |
return; |
| 141 |
} |
| 142 |
$activation_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin ); |
| 143 |
$admin_message = '<p>' . esc_html__( 'Ops! Pixel Gallery not working because you need to activate the Elementor plugin first.', 'pixel-gallery' ) . '</p>'; |
| 144 |
$admin_message .= '<p>' . sprintf( '<a href="%s" class="button-primary">%s</a>', $activation_url, esc_html__( 'Activate Elementor Now', 'pixel-gallery' ) ) . '</p>'; |
| 145 |
} else { |
| 146 |
if ( ! current_user_can( 'install_plugins' ) ) { |
| 147 |
return; |
| 148 |
} |
| 149 |
$install_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' ); |
| 150 |
$admin_message = '<p>' . esc_html__( 'Ops! Pixel Gallery not working because you need to install the Elementor plugin', 'pixel-gallery' ) . '</p>'; |
| 151 |
$admin_message .= '<p>' . sprintf( '<a href="%s" class="button-primary">%s</a>', $install_url, esc_html__( 'Install Elementor Now', 'pixel-gallery' ) ) . '</p>'; |
| 152 |
} |
| 153 |
|
| 154 |
printf( '<div class="error">%1$s</div>', wp_kses_post( $admin_message ) ); |
| 155 |
} |
| 156 |
|
| 157 |
/** |
| 158 |
* Check the elementor installed or not |
| 159 |
*/ |
| 160 |
if ( ! function_exists( '_is_elementor_installed' ) ) { |
| 161 |
function _is_elementor_installed() { |
| 162 |
$file_path = 'elementor/elementor.php'; |
| 163 |
$installed_plugins = get_plugins(); |
| 164 |
|
| 165 |
return isset( $installed_plugins[ $file_path ] ); |
| 166 |
} |
| 167 |
} |
| 168 |
|
| 169 |
/** |
| 170 |
* Added biggopti after install or upgrade to v6 |
| 171 |
* |
| 172 |
* @param string $plugin |
| 173 |
* @return void |
| 174 |
*/ |
| 175 |
function pg_activation_redirect( $plugin ) { |
| 176 |
if ( ! did_action( 'elementor/loaded' ) ) { |
| 177 |
return; |
| 178 |
} |
| 179 |
|
| 180 |
if ( $plugin == plugin_basename( BDTPG__FILE__ ) ) { |
| 181 |
exit( wp_redirect( admin_url( 'admin.php?page=pixel_gallery_options¬ice=v6' ) ) ); |
| 182 |
} |
| 183 |
} |
| 184 |
|
| 185 |
add_action( 'activated_plugin', 'pg_activation_redirect', 20 ); |
| 186 |
|