settings_api = new PixelGallery_Settings_API; if (!defined('BDTPG_HIDE')) { add_action('admin_init', [$this, 'admin_init']); add_action('admin_menu', [$this, 'admin_menu'], 201); } if (!Tracker::is_allow_track()) { add_action('admin_notices', [$this, 'allow_tracker_activate_biggopti'], 10, 3); } // Handle white label access link $this->handle_white_label_access(); // Add custom CSS/JS functionality $this->init_custom_code_functionality(); // White label settings (admin only) add_action('wp_ajax_pg_save_white_label', [$this, 'save_white_label_ajax']); add_action('wp_ajax_pg_revoke_white_label_token', [$this, 'revoke_white_label_token_ajax']); add_action('admin_head', [$this, 'inject_white_label_icon_css']); // Plugin installation (admin only) add_action('wp_ajax_pg_install_plugin', [$this, 'install_plugin_ajax']); if (_is_pg_pro_activated()) { // Initialize rollback version functionality add_action('admin_init', [$this, 'rollback_init']); } } public function rollback_init() { if (class_exists('\PixelGalleryPro\Rollback_Version')) { $this->rollback_version = new \PixelGalleryPro\Rollback_Version(); } } /** * Initialize Custom Code Functionality * * @access public * @return void */ public function init_custom_code_functionality() { // AJAX handler for saving custom code (admin only) add_action('wp_ajax_pg_save_custom_code', [$this, 'save_custom_code_ajax']); // Admin scripts (admin only) add_action('admin_enqueue_scripts', [$this, 'enqueue_custom_code_scripts']); // Frontend injection is now handled by global functions in the main plugin file self::init_frontend_injection(); } /** * Initialize frontend injection hooks (works on both admin and frontend) * * @access public static * @return void */ public static function init_frontend_injection() { // Frontend hooks are now registered in the main plugin file // This method is kept for backwards compatibility but does nothing } /** * Enqueue scripts for custom code editor * * @access public * @return void */ public function enqueue_custom_code_scripts($hook) { if ($hook !== 'toplevel_page_pixel_gallery_options') { return; } // Enqueue WordPress built-in CodeMirror wp_enqueue_code_editor(array('type' => 'text/css')); wp_enqueue_code_editor(array('type' => 'application/javascript')); // Enqueue WordPress media library scripts wp_enqueue_media(); // Enqueue the admin script if it exists $admin_script_path = BDTPG_ASSETS_PATH . 'js/pg-admin.js'; if (file_exists($admin_script_path)) { wp_enqueue_script( 'pg-admin-script', BDTPG_ASSETS_URL . 'js/pg-admin.js', ['jquery', 'media-upload', 'media-views', 'code-editor'], BDTPG_VER, true ); // Localize script with AJAX data wp_localize_script('pg-admin-script', 'pg_admin_ajax', [ 'ajax_url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('pg_custom_code_nonce'), 'white_label_nonce' => wp_create_nonce('pg_white_label_nonce') ]); } else { // Fallback: localize to jquery if the admin script doesn't exist wp_localize_script('jquery', 'pg_admin_ajax', [ 'ajax_url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('pg_custom_code_nonce'), 'white_label_nonce' => wp_create_nonce('pg_white_label_nonce') ]); } } /** * AJAX handler for saving white label settings * * @access public * @return void */ public function save_white_label_ajax() { // Check nonce and permissions if (!wp_verify_nonce($_POST['nonce'], 'pg_white_label_nonce')) { wp_send_json_error(['message' => __('Security check failed', 'pixel-gallery')]); } if (!current_user_can('manage_options')) { wp_send_json_error(['message' => __('You do not have permission to manage white label settings', 'pixel-gallery')]); } // Check license eligibility if (!self::is_white_label_license()) { wp_send_json_error(['message' => __('Your license does not support white label features', 'pixel-gallery')]); } // Get white label settings $white_label_enabled = isset($_POST['pg_white_label_enabled']) ? (bool) $_POST['pg_white_label_enabled'] : false; $hide_license = isset($_POST['pg_white_label_hide_license']) ? (bool) $_POST['pg_white_label_hide_license'] : false; $bdtpg_hide = isset($_POST['pg_white_label_bdtpg_hide']) ? (bool) $_POST['pg_white_label_bdtpg_hide'] : false; $white_label_title = isset($_POST['pg_white_label_title']) ? sanitize_text_field($_POST['pg_white_label_title']) : ''; $white_label_icon = isset($_POST['pg_white_label_icon']) ? esc_url_raw($_POST['pg_white_label_icon']) : ''; $white_label_icon_id = isset($_POST['pg_white_label_icon_id']) ? absint($_POST['pg_white_label_icon_id']) : 0; $white_label_logo = isset($_POST['pg_white_label_logo']) ? esc_url_raw($_POST['pg_white_label_logo']) : ''; $pg_white_label_logo_id = isset($_POST['pg_white_label_logo_id']) ? absint($_POST['pg_white_label_logo_id']) : 0; // Save settings update_option('pg_white_label_enabled', $white_label_enabled); update_option('pg_white_label_hide_license', $hide_license); update_option('pg_white_label_bdtpg_hide', $bdtpg_hide); update_option('pg_white_label_title', $white_label_title); update_option('pg_white_label_icon', $white_label_icon); update_option('pg_white_label_icon_id', $white_label_icon_id); update_option('pg_white_label_logo', $white_label_logo); update_option('pg_white_label_logo_id', $pg_white_label_logo_id); // Set license title status if ($white_label_enabled) { update_option('pixel_gallery_license_title_status', true); } else { delete_option('pixel_gallery_license_title_status'); } // Only send access email if both white label mode AND BDTPG_HIDE are enabled if ($white_label_enabled && $bdtpg_hide) { $email_sent = $this->send_white_label_access_email(); } wp_send_json_success([ 'message' => __('White label settings saved successfully', 'pixel-gallery'), 'bdtpg_hide' => $bdtpg_hide, 'email_sent' => isset($email_sent) ? $email_sent : false ]); } /** * Send white label access email with special link * * @access private * @return bool */ private function send_white_label_access_email() { $license_email = self::get_license_email(); $admin_email = get_bloginfo('admin_email'); $license_key = self::get_license_key(); $site_name = get_bloginfo('name'); $site_url = get_bloginfo('url'); // Generate secure access token with additional entropy $access_token = wp_hash($license_key . time() . wp_salt() . wp_generate_password(32, false)); // Store access token in database with no expiration $token_data = [ 'token' => $access_token, 'license_key' => $license_key, 'created_at' => current_time('timestamp'), 'user_id' => get_current_user_id() ]; update_option('pg_white_label_access_token', $token_data); // Generate access URL using token instead of license key for security // Add white_label_tab=1 parameter to automatically switch to White Label tab $access_url = admin_url('admin.php?page=pixel_gallery_options&pg_wl=1&token=' . $access_token . '&white_label_tab=1#pixel_gallery_extra_options'); // Email subject $subject = sprintf('[%s] Pixel Gallery White Label Access Instructions', $site_name); // Email message $message = $this->get_white_label_email_template($site_name, $site_url, $access_url, $license_key); // Email headers $headers = [ 'Content-Type: text/html; charset=UTF-8', 'From: ' . $site_name . ' <' . $admin_email . '>' ]; $email_sent = false; // Send to license email if (!empty($license_email) && is_email($license_email)) { $email_sent = wp_mail($license_email, $subject, $message, $headers); // If on localhost or email failed, save email content for manual access if (!$email_sent || $this->is_localhost()) { $this->save_email_content_for_localhost($access_url, $message, $license_email); } } return $email_sent; } /** * Check if running on localhost * * @access private * @return bool */ private function is_localhost() { $server_name = $_SERVER['SERVER_NAME'] ?? ''; $server_addr = $_SERVER['SERVER_ADDR'] ?? ''; $localhost_indicators = [ 'localhost', '127.0.0.1', '::1', '.local', '.test', '.dev' ]; foreach ($localhost_indicators as $indicator) { if ( strpos($server_name, $indicator) !== false || strpos($server_addr, $indicator) !== false ) { return true; } } return false; } /** * Save email content for localhost testing * * @access private * @param string $access_url * @param string $email_content * @param string $recipient_email * @return void */ private function save_email_content_for_localhost($access_url, $email_content, $recipient_email) { $email_data = [ 'access_url' => $access_url, 'email_content' => $email_content, 'recipient_email' => $recipient_email, 'message' => 'Email functionality not available on localhost. Use the access URL below:' ]; // Save for admin notice display update_option('pg_localhost_email_data', $email_data); } /** * Get white label email template * * @access private * @param string $site_name * @param string $site_url * @param string $access_url * @param string $license_key * @return string */ private function get_white_label_email_template($site_name, $site_url, $access_url, $license_key) { $masked_license = substr($license_key, 0, 8) . '****-****-****-' . substr($license_key, -4); ob_start(); ?> Pixel Gallery White Label Access

%1$s for Pixel Gallery Pro on %2$s.', 'pixel-gallery' ) ), esc_html__( 'BDTPG_HIDE mode', 'pixel-gallery' ), esc_html( $site_name ) ); ?>


', '' ); ?>

show_access_error( esc_html__( 'Invalid access parameter. Please use the correct link from your email.', 'pixel-gallery' ) ); return; } // Validate the access token if (!$this->validate_white_label_access_token($access_token)) { $this->show_access_error( esc_html__( 'Invalid or expired access token. Please use the correct access link from your email.', 'pixel-gallery' ) ); return; } // Valid access - temporarily allow access by setting a flag add_action('admin_init', [$this, 'admin_init']); add_action('admin_menu', [$this, 'admin_menu'], 201); // Add success notice add_action('admin_notices', function () { echo '
'; echo '

' . esc_html__( '✅ White Label Access Granted!', 'pixel-gallery' ) . ' ' . esc_html__( 'You can now modify white label settings.', 'pixel-gallery' ) . '

'; echo '
'; }); } /** * Show access error page * * @access private * @param string $message * @return void */ private function show_access_error($message) { wp_die( '

' . esc_html__( '🔒 Pixel Gallery White Label Access', 'pixel-gallery' ) . '

' . '

' . esc_html__( 'Access Denied:', 'pixel-gallery' ) . ' ' . esc_html( $message ) . '

' . '

' . esc_html__( 'If you need assistance, please contact support with your license information.', 'pixel-gallery' ) . '

' . '

' . esc_html__( '← Return to Dashboard', 'pixel-gallery' ) . '

', esc_html__( 'Access Denied', 'pixel-gallery' ), ['response' => 403] ); } /** * Inject white label icon CSS * * @access public * @return void */ public function inject_white_label_icon_css() { $white_label_enabled = get_option('pg_white_label_enabled', false); $white_label_icon = get_option('pg_white_label_icon', ''); // Only inject CSS when white label is enabled AND a custom icon is set if ($white_label_enabled && !empty($white_label_icon)) { echo ''; } // When white label is disabled or no icon is set, don't inject any CSS // This allows WordPress's original icon to display naturally } /** * Get used widgets. * * @access public * @return array * @since 6.0.0 * */ public static function get_used_widgets() { $used_widgets = array(); if (class_exists('Elementor\Modules\Usage\Module')) { $module = Module::instance(); $old_error_level = error_reporting(); error_reporting(E_ALL & ~E_WARNING); // Suppress warnings $elements = $module->get_formatted_usage('raw'); error_reporting($old_error_level); // Restore $pg_widgets = self::get_pg_widgets_names(); if (is_array($elements) || is_object($elements)) { foreach ($elements as $post_type => $data) { foreach ($data['elements'] as $element => $count) { if (in_array($element, $pg_widgets, true)) { if (isset($used_widgets[$element])) { $used_widgets[$element] += $count; } else { $used_widgets[$element] = $count; } } } } } } return $used_widgets; } /** * Get used separate widgets. * * @access public * @return array * @since 6.0.0 * */ public static function get_used_only_widgets() { $used_widgets = array(); if (class_exists('Elementor\Modules\Usage\Module')) { $module = Module::instance(); $old_error_level = error_reporting(); error_reporting(E_ALL & ~E_WARNING); // Suppress warnings $elements = $module->get_formatted_usage('raw'); error_reporting($old_error_level); // Restore $pg_widgets = self::get_pg_only_widgets(); if (is_array($elements) || is_object($elements)) { foreach ($elements as $post_type => $data) { foreach ($data['elements'] as $element => $count) { if (in_array($element, $pg_widgets, true)) { if (isset($used_widgets[$element])) { $used_widgets[$element] += $count; } else { $used_widgets[$element] = $count; } } } } } } return $used_widgets; } /** * Get unused widgets. * * @access public * @return array * @since 6.0.0 * */ public static function get_unused_widgets() { if (!current_user_can('install_plugins')) { die(); } $pg_widgets = self::get_pg_widgets_names(); $used_widgets = self::get_used_widgets(); $unused_widgets = array_diff($pg_widgets, array_keys($used_widgets)); return $unused_widgets; } /** * Get unused separate widgets. * * @access public * @return array * @since 6.0.0 * */ public static function get_unused_only_widgets() { if (!current_user_can('install_plugins')) { die(); } $pg_widgets = self::get_pg_only_widgets(); $used_widgets = self::get_used_only_widgets(); $unused_widgets = array_diff($pg_widgets, array_keys($used_widgets)); return $unused_widgets; } /** * Get widgets name * * @access public * @return array * @since 6.0.0 * */ public static function get_pg_widgets_names() { $names = self::$modules_names; if (null === $names) { $names = array_map( function ($item) { return isset($item['name']) ? 'pg-' . str_replace('_', '-', $item['name']) : 'none'; }, self::$modules_list ); } return $names; } /** * Get separate widgets name * * @access public * @return array * @since 6.0.0 * */ public static function get_pg_only_widgets() { $names = self::$modules_names_only_widgets; if (null === $names) { $names = array_map( function ($item) { return isset($item['name']) ? 'bdt-' . str_replace('_', '-', $item['name']) : 'none'; }, self::$modules_list_only_widgets ); } return $names; } /** * Get URL with page id * * @access public * */ public static function get_url() { return admin_url('admin.php?page=' . self::PAGE_ID); } /** * Init settings API * * @access public * */ public function admin_init() { //set the settings $this->settings_api->set_sections($this->get_settings_sections()); $this->settings_api->set_fields($this->pixel_gallery_admin_settings()); //initialize settings $this->settings_api->admin_init(); $this->pg_redirect_to_get_pro(); if (_is_pg_pro_activated()) { $this->bdt_redirect_to_renew_link(); } } /** * Add Plugin Menus * * @access public * */ // Redirect to Pixel Gallery Pro pricing page public function pg_redirect_to_get_pro() { if (isset($_GET['page']) && $_GET['page'] === self::PAGE_ID . '_get_pro') { wp_redirect('https://pixelgallery.pro/pricing/'); exit; } } /** * Redirect to license renewal page * * @access public * */ public function bdt_redirect_to_renew_link() { if (isset($_GET['page']) && $_GET['page'] === self::PAGE_ID . '_license_renew') { wp_redirect('https://account.bdthemes.com/'); exit; } } public function admin_menu() { add_menu_page( BDTPG_TITLE . ' ' . esc_html__('Dashboard', 'pixel-gallery'), BDTPG_TITLE, 'manage_options', self::PAGE_ID, [$this, 'plugin_page'], $this->pixel_gallery_icon(), 58 ); add_submenu_page( self::PAGE_ID, esc_html__('Dashboard', 'pixel-gallery'), esc_html__('Dashboard', 'pixel-gallery'), 'manage_options', self::PAGE_ID, [$this, 'plugin_page'], ); add_submenu_page( self::PAGE_ID, BDTPG_TITLE, esc_html__('Core Widgets', 'pixel-gallery'), 'manage_options', self::PAGE_ID . '#pixel_gallery_active_modules', [$this, 'plugin_page'] ); add_submenu_page( self::PAGE_ID, BDTPG_TITLE, esc_html__('Extensions', 'pixel-gallery'), 'manage_options', self::PAGE_ID . '#pixel_gallery_elementor_extend', [$this, 'plugin_page'] ); if (!defined('BDTPG_LO')) { add_submenu_page( self::PAGE_ID, BDTPG_TITLE, esc_html__('Special Features', 'pixel-gallery'), 'manage_options', self::PAGE_ID . '#pixel_gallery_other_settings', [$this, 'plugin_page'] ); } add_submenu_page( self::PAGE_ID, BDTPG_TITLE, esc_html__('Extra Options', 'pixel-gallery'), 'manage_options', self::PAGE_ID . '#pixel_gallery_extra_options', [$this, 'plugin_page'] ); add_submenu_page( self::PAGE_ID, BDTPG_TITLE, esc_html__('System Status', 'pixel-gallery'), 'manage_options', self::PAGE_ID . '#pixel_gallery_analytics_system_req', [$this, 'plugin_page'] ); add_submenu_page( self::PAGE_ID, BDTPG_TITLE, esc_html__('Other Plugins', 'pixel-gallery'), 'manage_options', self::PAGE_ID . '#pixel_gallery_other_plugins', [$this, 'plugin_page'] ); if (true == _is_pg_pro_activated()) { add_submenu_page( self::PAGE_ID, BDTPG_TITLE, esc_html__('Rollback Version', 'pixel-gallery'), 'manage_options', self::PAGE_ID . '#pixel_gallery_rollback_version', [$this, 'plugin_page'] ); } } /** * Get SVG Icons of Pixel Gallery * * @access public * @return string */ public function pixel_gallery_icon() { return 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyNS4zLjEsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiDQoJIHZpZXdCb3g9IjAgMCA1MDIuMiA1MDEuOCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNTAyLjIgNTAxLjg7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+DQoJLnN0MHtmaWxsOiNGRkZGRkY7fQ0KPC9zdHlsZT4NCjxnPg0KCTxyZWN0IHg9Ijg4LjkiIHk9Ijk5IiBjbGFzcz0ic3QwIiB3aWR0aD0iMzQuMSIgaGVpZ2h0PSIzNC4xIi8+DQoJPHJlY3QgeD0iNTQuMiIgeT0iNTgiIGNsYXNzPSJzdDAiIHdpZHRoPSIyMS43IiBoZWlnaHQ9IjIxLjciLz4NCgk8cmVjdCB4PSI3MS40IiB5PSIyLjQiIGNsYXNzPSJzdDAiIHdpZHRoPSI5LjkiIGhlaWdodD0iOS45Ii8+DQoJPHJlY3QgeD0iOTkuNyIgeT0iMzUuNCIgY2xhc3M9InN0MCIgd2lkdGg9IjE0LjgiIGhlaWdodD0iMTQuOCIvPg0KCTxyZWN0IHg9Ijk4LjciIHk9IjE5NC4zIiBjbGFzcz0ic3QwIiB3aWR0aD0iMTQuOCIgaGVpZ2h0PSIxNC44Ii8+DQoJPHJlY3QgeD0iMTgyLjkiIHk9IjEyLjgiIGNsYXNzPSJzdDAiIHdpZHRoPSIxMi4zIiBoZWlnaHQ9IjEyLjMiLz4NCgk8cmVjdCB4PSIxNDEuMSIgeT0iMTQzLjYiIGNsYXNzPSJzdDAiIHdpZHRoPSI2MC40IiBoZWlnaHQ9IjYwLjQiLz4NCgk8cmVjdCB4PSIxNDMuMiIgeT0iNDYuNiIgY2xhc3M9InN0MCIgd2lkdGg9IjM1LjMiIGhlaWdodD0iMzUuMyIvPg0KCTxyZWN0IHg9IjU5LjciIHk9IjE1MS4xIiBjbGFzcz0ic3QwIiB3aWR0aD0iMjIiIGhlaWdodD0iMjIiLz4NCgk8cGF0aCBjbGFzcz0ic3QwIiBkPSJNMzk4LjIsNjIuNGMtMzMtMzIuNS03My40LTQ4LjgtMTIxLjMtNDguOGgtNDMuNnYzMi4yaC0yOS42djcyLjNoNzMuMmMxNy4xLDAsMzEuMyw2LjEsNDIuNiwxOC4yDQoJCWMxMS4xLDEyLjEsMTYuNywyNi45LDE2LjcsNDQuNnMtNS42LDMyLjUtMTYuNyw0NC42Yy0xMS4xLDEyLjEtMjUuMywxOC4yLTQyLjYsMTguMmgtNzMuMmwwLDBoLTYxLjV2NjQuOUg5Mi4zdjE5My4xaDExMS42VjM0OC4zDQoJCWg3My4yYzQ3LjksMCw4OC40LTE2LjMsMTIxLjMtNDguOHM0OS41LTcyLjEsNDkuNS0xMTguNUM0NDcuNywxMzQuNCw0MzEuMiw5NSwzOTguMiw2Mi40eiIvPg0KCTxyZWN0IHg9Ijc2LjIiIHk9IjI0My4zIiBjbGFzcz0ic3QwIiB3aWR0aD0iNDQuNSIgaGVpZ2h0PSI0NC41Ii8+DQo8L2c+DQo8L3N2Zz4NCg=='; } /** * Get SVG Icons of Pixel Gallery * * @access public * @return array */ public function get_settings_sections() { $sections = [ [ 'id' => 'pixel_gallery_active_modules', 'title' => esc_html__('Core Widgets', 'pixel-gallery') ], [ 'id' => 'pixel_gallery_elementor_extend', 'title' => esc_html__('Extensions', 'pixel-gallery') ], [ 'id' => 'pixel_gallery_other_settings', 'title' => esc_html__('Special Features', 'pixel-gallery'), ], ]; return $sections; } /** * Merge Admin Settings * * @access protected * @return array */ protected function pixel_gallery_admin_settings() { return ModuleService::get_widget_settings(function ($settings) { $settings_fields = $settings['settings_fields']; self::$modules_list = $settings_fields['pixel_gallery_active_modules']; self::$modules_list_only_widgets = $settings_fields['pixel_gallery_active_modules']; return $settings_fields; }); } /** * Get Welcome Panel * * @access public * @return void */ public function old_pixel_gallery_welcome() { ?>

pixel_gallery_system_requirement(); ?>

', ''); ?>

Pixel Gallery Dashboard Template

Pixel Gallery Dashboard Template

  • Theme Compatibility
  • Dynamic Content & Custom Fields Capabilities
  • Proper Documentation
  • Updates & Support
  • Ready Made Pages
  • Ready Made Blocks
  • Elementor Extended Widgets
  • Rooten Theme Pro Features
  • Priority Support
  • Incredibly Advanced
    Refund or Cancel Anytime
    Dynamic Content
  • Super-Flexible Widgets
    24/7 Premium Support
    Third Party Plugins
  • Special Discount!
    Custom Field Integration
    With Live Chat Support
  • Trusted Payment Methods
    Interactive Effects
    Video Tutorial
script(); } /** * Tabbable JavaScript codes & Initiate Color Picker * * This code uses localstorage for displaying active tabs */ function script() { ?> 'pg-allow-tracker', 'type' => 'warning', 'category' => 'critical', 'dismissible' => true, 'dismissible-time' => WEEK_IN_SECONDS * 4, 'message' => __('Please activate Usage Data Sharing features from Elementor, otherwise Widgets Analytics will not work. Please activate the settings from Elementor > Settings > General Tab > Usage Data Sharing. Thank you.', 'pixel-gallery'), ] ); } /** * Get all the pages * * @return array page names with key value pairs */ function get_pages() { $pages = get_pages(); $pages_options = []; if ($pages) { foreach ($pages as $page) { $pages_options[$page->ID] = $page->post_title; } } return $pages_options; } /** * Widgets Status */ public function pixel_gallery_widgets_status() { $track_nw_msg = ''; if (!Tracker::is_allow_track()) { $track_nw = esc_html__('This feature is not working because the Elementor Usage Data Sharing feature is Not Enabled.', 'pixel-gallery'); $track_nw_msg = 'bdt-tooltip="' . $track_nw . '"'; } ?>
>

>

>

0
0
0
', '' ); echo ' ' . esc_html__('from here.', 'pixel-gallery') . ''; ?>
'; $no_icon = ''; $environment = Utils::get_environment_info(); ?>
Pixel Gallery' ); ?>
pixel_gallery_widgets_status(); ?>

pixel_gallery_system_requirement(); ?>

render_custom_css_js_section(); ?>
render_white_label_section(); ?>
license_title) || empty($license_info->is_valid) ) { return false; } // Sanitize license title to prevent any potential issues $license_title = sanitize_text_field(strtolower($license_info->license_title)); // Check for other_param WL flag FIRST (for AppSumo and other special licenses) if (!empty($license_info->other_param)) { // Check if other_param contains WL flag if (is_array($license_info->other_param)) { if (in_array('WL', $license_info->other_param, true)) { return true; } } elseif (is_string($license_info->other_param)) { if (strpos($license_info->other_param, 'WL') !== false) { return true; } } } // Check standard license types (but NOT AppSumo - AppSumo requires WL flag) $allowed_types = self::get_white_label_allowed_license_types(); $allowed_hashes = array_values($allowed_types); // Split license title into words and check each word $words = preg_split('/\s+/', $license_title, -1, PREG_SPLIT_NO_EMPTY); foreach ($words as $word) { $word = trim($word); if (empty($word) || strlen($word) > 50) { // Prevent extremely long strings continue; } // Use SHA-256 for enhanced security $hash = hash('sha256', $word); if (in_array($hash, $allowed_hashes, true)) { // Strict comparison return true; } } return false; } /** * Render White Label Section * * @access public * @return void */ public function render_white_label_section() { //// Safely check if helper functions exist $is_pro_installed = function_exists('_is_pg_pro_installed') ? _is_pg_pro_installed() : false; $is_pro_activated = function_exists('_is_pg_pro_activated') ? _is_pg_pro_activated() : false; // Define plugin slug (adjust if needed) $plugin_slug = 'pixel-gallery-pro/pixel-gallery-pro.php'; // Case 1: Pro not installed if (!$is_pro_installed): ?>

'activate', 'plugin' => $plugin_slug, ), admin_url('plugins.php') ), 'activate-plugin_' . $plugin_slug ); ?>

>

Icon Preview

Logo Preview

'c4b2af4722ee54e317672875b2d8cf49aa884bf5820ec6091114fea5ec6560e4', 'extended' => '4d7120eb6c796b04273577476eb2e20c34c51d7fa1025ec19c3414448abc241e', 'developer' => '88fa0d759f845b47c044c2cd44e29082cf6fea665c30c146374ec7c8f3d699e3', // Note: AppSumo and Lifetime licenses removed from automatic access // They require WL flag in other_param for white label functionality ]; return $allowed_types; } public static function license_wl_status() { $status = get_option('pixel_gallery_license_title_status'); if ($status) { return true; } return false; } /** * Get License Email * * @access public * @return string */ public static function get_license_email() { return trim(get_option('pixel_gallery_license_email', get_bloginfo('admin_email'))); } /** * Others Plugin - Using standalone plugin manager */ public function pixel_gallery_others_plugin() { // Include and render the standalone others plugin manager require_once BDTPG_INC_PATH . 'setup-wizard/pixel-gallery-others-plugin.php'; // Call the helper function to render the plugin manager pixel_gallery_others_plugin(); } /** * Check plugin status (installed, active, or not installed) * * @param string $plugin_path Plugin file path * @return string 'active', 'installed', or 'not_installed' */ private function get_plugin_status($plugin_path) { // Check if plugin is active if (is_plugin_active($plugin_path)) { return 'active'; } // Check if plugin is installed but not active $installed_plugins = get_plugins(); if (isset($installed_plugins[$plugin_path])) { return 'installed'; } // Plugin is not installed return 'not_installed'; } /** * AJAX handler for saving custom code * * @access public * @return void */ public function save_custom_code_ajax() { // Verify nonce if (!wp_verify_nonce($_POST['nonce'] ?? '', 'pg_custom_code_nonce')) { wp_send_json_error(['message' => 'Invalid security token.']); } // Check user capability if (!current_user_can('manage_options')) { wp_send_json_error(['message' => 'Insufficient permissions.']); } // Sanitize and save the custom code $custom_css = isset($_POST['custom_css']) ? wp_unslash($_POST['custom_css']) : ''; $custom_js = isset($_POST['custom_js']) ? wp_unslash($_POST['custom_js']) : ''; $custom_css_2 = isset($_POST['custom_css_2']) ? wp_unslash($_POST['custom_css_2']) : ''; $custom_js_2 = isset($_POST['custom_js_2']) ? wp_unslash($_POST['custom_js_2']) : ''; // Handle excluded pages - ensure we get proper array format $excluded_pages = array(); if (isset($_POST['excluded_pages'])) { if (is_array($_POST['excluded_pages'])) { $excluded_pages = $_POST['excluded_pages']; } elseif (is_string($_POST['excluded_pages']) && !empty($_POST['excluded_pages'])) { // Handle case where it might be a single value $excluded_pages = [$_POST['excluded_pages']]; } } // Sanitize excluded pages - convert to integers and remove empty values $excluded_pages = array_map('intval', $excluded_pages); $excluded_pages = array_filter($excluded_pages, function ($page_id) { return $page_id > 0; }); // Save to database update_option('pg_custom_css', $custom_css); update_option('pg_custom_js', $custom_js); update_option('pg_custom_css_2', $custom_css_2); update_option('pg_custom_js_2', $custom_js_2); update_option('pg_excluded_pages', $excluded_pages); wp_send_json_success([ 'message' => 'Custom code saved successfully!', 'excluded_count' => count($excluded_pages) ]); } /** * Handle AJAX plugin installation * * @access public * @return void */ public function install_plugin_ajax() { // Check nonce if (!wp_verify_nonce($_POST['nonce'], 'pg_install_plugin_nonce')) { wp_send_json_error(['message' => __('Security check failed', 'pixel-gallery')]); } // Check user capability if (!current_user_can('install_plugins')) { wp_send_json_error(['message' => __('You do not have permission to install plugins', 'pixel-gallery')]); } $plugin_slug = sanitize_text_field($_POST['plugin_slug']); if (empty($plugin_slug)) { wp_send_json_error(['message' => __('Plugin slug is required', 'pixel-gallery')]); } // Include necessary WordPress files require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; require_once ABSPATH . 'wp-admin/includes/class-wp-ajax-upgrader-skin.php'; // Get plugin information $api = plugins_api('plugin_information', [ 'slug' => $plugin_slug, 'fields' => [ 'sections' => false, ], ]); if (is_wp_error($api)) { wp_send_json_error(['message' => __('Plugin not found: ', 'pixel-gallery') . $api->get_error_message()]); } // Install the plugin $skin = new \WP_Ajax_Upgrader_Skin(); $upgrader = new \Plugin_Upgrader($skin); $result = $upgrader->install($api->download_link); if (is_wp_error($result)) { wp_send_json_error(['message' => __('Installation failed: ', 'pixel-gallery') . $result->get_error_message()]); } elseif ($skin->get_errors()->has_errors()) { wp_send_json_error(['message' => __('Installation failed: ', 'pixel-gallery') . $skin->get_error_messages()]); } elseif (is_null($result)) { wp_send_json_error(['message' => __('Installation failed: Unable to connect to filesystem', 'pixel-gallery')]); } // Get installation status $install_status = install_plugin_install_status($api); wp_send_json_success([ 'message' => __('Plugin installed successfully!', 'pixel-gallery'), 'plugin_file' => $install_status['file'], 'plugin_name' => $api->name ]); } /** * Extract plugin slug from plugin path * * @param string $plugin_path Plugin file path * @return string Plugin slug */ private function extract_plugin_slug_from_path($plugin_path) { $parts = explode('/', $plugin_path); return isset($parts[0]) ? $parts[0] : ''; } /** * Get plugin action button HTML based on plugin status * * @param string $plugin_path Plugin file path * @param string $install_url Plugin installation URL * @param string $plugin_slug Plugin slug for activation * @return string Button HTML */ private function get_plugin_action_button($plugin_path, $install_url, $plugin_slug = '') { $status = $this->get_plugin_status($plugin_path); switch ($status) { case 'active': return ''; case 'installed': $activate_url = wp_nonce_url( add_query_arg([ 'action' => 'activate', 'plugin' => $plugin_path ], admin_url('plugins.php')), 'activate-plugin_' . $plugin_path ); return '' . __('Activate', 'pixel-gallery') . ''; case 'not_installed': default: $plugin_slug = $this->extract_plugin_slug_from_path($plugin_path); $nonce = wp_create_nonce('pg_install_plugin_nonce'); return '' . __('Install', 'pixel-gallery') . ''; } } /** * Rollback Version Content * * @access public * @return void */ public function pg_rollback_version_content() { // Use the already initialized rollback version instance $this->rollback_version->pg_rollback_version_content(); } /** * Validate white label access token * * @access public * @param string $token * @return bool */ public function validate_white_label_access_token($token) { $stored_token_data = get_option('pg_white_label_access_token', []); if (empty($stored_token_data) || !isset($stored_token_data['token'])) { return false; } // Check token match if ($stored_token_data['token'] !== $token) { return false; } // Check if token was generated for current license $current_license_key = self::get_license_key(); if ($stored_token_data['license_key'] !== $current_license_key) { return false; } return true; } /** * AJAX handler for revoking white label access token * * @access public * @return void */ public function revoke_white_label_token_ajax() { // Check nonce and permissions if (!wp_verify_nonce($_POST['nonce'], 'pg_white_label_nonce')) { wp_send_json_error(['message' => __('Security check failed', 'pixel-gallery')]); } if (!current_user_can('manage_options')) { wp_send_json_error(['message' => __('You do not have permission to manage white label settings', 'pixel-gallery')]); } // Check license eligibility if (!self::is_white_label_license()) { wp_send_json_error(['message' => __('Your license does not support white label features', 'pixel-gallery')]); } // Revoke the token $revoked = $this->revoke_white_label_access_token(); if ($revoked) { wp_send_json_success([ 'message' => __('White label access token has been revoked successfully', 'pixel-gallery') ]); } else { wp_send_json_error([ 'message' => __('No active access token found to revoke', 'pixel-gallery') ]); } } /** * Revoke white label access token * * @access public * @return bool */ public function revoke_white_label_access_token() { $token_data = get_option('pg_white_label_access_token', []); if (!empty($token_data)) { delete_option('pg_white_label_access_token'); return true; } return false; } /** * Get License Key * * @access public * @return string */ public static function get_license_key() { $license_key = get_option('pixel_gallery_license_key'); return trim($license_key); } } new PixelGallery_Admin_Settings();