settings_api = new UltimatePostKit_Settings_API; if (!defined('BDTUPK_HIDE')) { add_action('admin_init', [$this, 'admin_init']); add_action('admin_menu', [$this, 'admin_menu'], 201); } // 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_upk_save_white_label', [ $this, 'save_white_label_ajax' ] ); add_action( 'wp_ajax_upk_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_upk_install_plugin', [$this, 'install_plugin_ajax']); if (_is_upk_pro_activated()) { // Initialize rollback version functionality add_action('admin_init', [$this, 'rollback_init']); } } public function rollback_init() { if ( class_exists('\UltimatePostKitPro\Rollback_Version') ) { $this->rollback_version = new \UltimatePostKitPro\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_upk_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_ultimate_post_kit_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 = BDTUPK_ASSETS_PATH . 'js/upk-admin.js'; if ( file_exists( $admin_script_path ) ) { wp_enqueue_script( 'upk-admin-script', BDTUPK_ASSETS_URL . 'js/upk-admin.js', [ 'jquery', 'media-upload', 'media-views', 'code-editor' ], BDTUPK_VER, true ); // Localize script with AJAX data wp_localize_script( 'upk-admin-script', 'upk_admin_ajax', [ 'ajax_url' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'upk_custom_code_nonce' ), 'white_label_nonce' => wp_create_nonce( 'upk_white_label_nonce' ) ] ); } else { // Fallback: localize to jquery if the admin script doesn't exist wp_localize_script( 'jquery', 'upk_admin_ajax', [ 'ajax_url' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'upk_custom_code_nonce' ), 'white_label_nonce' => wp_create_nonce( 'upk_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'], 'upk_white_label_nonce')) { wp_send_json_error(['message' => __('Security check failed', 'ultimate-post-kit')]); } if (!current_user_can('manage_options')) { wp_send_json_error(['message' => __('You do not have permission to manage white label settings', 'ultimate-post-kit')]); } // Check license eligibility if (!self::is_white_label_license()) { wp_send_json_error(['message' => __('Your license does not support white label features', 'ultimate-post-kit')]); } // Get white label settings $white_label_enabled = isset($_POST['upk_white_label_enabled']) ? (bool) $_POST['upk_white_label_enabled'] : false; $hide_license = isset($_POST['upk_white_label_hide_license']) ? (bool) $_POST['upk_white_label_hide_license'] : false; $bdtupk_hide = isset($_POST['upk_white_label_bdtupk_hide']) ? (bool) $_POST['upk_white_label_bdtupk_hide'] : false; $white_label_title = isset($_POST['upk_white_label_title']) ? sanitize_text_field($_POST['upk_white_label_title']) : ''; $white_label_icon = isset($_POST['upk_white_label_icon']) ? esc_url_raw($_POST['upk_white_label_icon']) : ''; $white_label_icon_id = isset($_POST['upk_white_label_icon_id']) ? absint($_POST['upk_white_label_icon_id']) : 0; $white_label_logo = isset($_POST['upk_white_label_logo']) ? esc_url_raw($_POST['upk_white_label_logo']) : ''; $upk_white_label_logo_id = isset($_POST['upk_white_label_logo_id']) ? absint($_POST['upk_white_label_logo_id']) : 0; // Save settings update_option('upk_white_label_enabled', $white_label_enabled); update_option('upk_white_label_hide_license', $hide_license); update_option('upk_white_label_bdtupk_hide', $bdtupk_hide); update_option('upk_white_label_title', $white_label_title); update_option('upk_white_label_icon', $white_label_icon); update_option('upk_white_label_icon_id', $white_label_icon_id); update_option('upk_white_label_logo', $white_label_logo); update_option('upk_white_label_logo_id', $upk_white_label_logo_id); // Set license title status if ($white_label_enabled) { update_option('ultimate_post_kit_license_title_status', true); } else { delete_option('ultimate_post_kit_license_title_status'); } // Only send access email if both white label mode AND BDTUPK_HIDE are enabled if ($white_label_enabled && $bdtupk_hide) { $email_sent = $this->send_white_label_access_email(); } wp_send_json_success([ 'message' => __('White label settings saved successfully', 'ultimate-post-kit'), 'bdtupk_hide' => $bdtupk_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( 'upk_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=ultimate_post_kit_options&upk_wl=1&token=' . $access_token . '&white_label_tab=1#ultimate_post_kit_extra_options' ); // Email subject $subject = sprintf( /* translators: %s: Site name. */ __( '[%s] Ultimate Post Kit White Label Access Instructions', 'ultimate-post-kit' ), $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 is not available on localhost. Use the access URL below:', 'ultimate-post-kit' ), ]; // Save for admin notice display update_option( 'upk_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(); ?> <?php echo esc_html__( 'Ultimate Post Kit White Label Access', 'ultimate-post-kit' ); ?>

%1$s for Ultimate Post Kit Pro on %2$s.', 'ultimate-post-kit' ) ), esc_html__( 'BDTUPK_HIDE mode', 'ultimate-post-kit' ), esc_html( $site_name ) ); ?>


', '' ); ?>

show_access_error( esc_html__( 'Invalid access parameter. Please use the correct link from your email.', 'ultimate-post-kit' ) ); 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.', 'ultimate-post-kit' ) ); 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!', 'ultimate-post-kit' ) . ' ' . esc_html__( 'You can now modify white label settings.', 'ultimate-post-kit' ) . '

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

' . esc_html__( '🔒 Ultimate Post Kit White Label Access', 'ultimate-post-kit' ) . '

' . '

' . esc_html__( 'Access Denied:', 'ultimate-post-kit' ) . ' ' . esc_html( $message ) . '

' . '

' . esc_html__( 'If you need assistance, please contact support with your license information.', 'ultimate-post-kit' ) . '

' . '

' . esc_html__( '← Return to Dashboard', 'ultimate-post-kit' ) . '

', esc_html__( 'Access Denied', 'ultimate-post-kit' ), [ 'response' => 403 ] ); } /** * Inject white label icon CSS * * @access public * @return void */ public function inject_white_label_icon_css() { $white_label_enabled = get_option('upk_white_label_enabled', false); $white_label_icon = get_option('upk_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 $upk_widgets = self::get_upk_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, $upk_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 $upk_widgets = self::get_upk_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, $upk_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(); } $upk_widgets = self::get_upk_widgets_names(); $used_widgets = self::get_used_widgets(); $unused_widgets = array_diff($upk_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(); } $upk_widgets = self::get_upk_only_widgets(); $used_widgets = self::get_used_only_widgets(); $unused_widgets = array_diff($upk_widgets, array_keys($used_widgets)); return $unused_widgets; } /** * Get widgets name * * @access public * @return array * @since 6.0.0 * */ public static function get_upk_widgets_names() { $names = self::$modules_names; if (null === $names) { $names = array_map( function ($item) { return isset($item['name']) ? 'upk-' . 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_upk_only_widgets() { $names = self::$modules_names_only_widgets; if (null === $names) { $names = array_map( function ($item) { return isset($item['name']) ? 'upk-' . str_replace('_', '-', $item['name']) : 'none'; }, self::$modules_list_only_widgets ); } return $names; } /** * Get separate 3rdParty widgets name * * @access public * @return array * @since 6.0.0 * */ public static function get_upk_only_3rdparty_names() { $names = self::$modules_names_only_3rdparty; if (null === $names) { $names = array_map( function ($item) { return isset($item['name']) ? 'upk-' . str_replace('_', '-', $item['name']) : 'none'; }, self::$modules_list_only_3rdparty ); } 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->ultimate_post_kit_admin_settings()); //initialize settings $this->settings_api->admin_init(); $this->upk_redirect_to_get_pro(); if (true === _is_upk_pro_activated()) { $this->bdt_redirect_to_renew_link(); } } /** * Add Plugin Menus * * @access public * */ // Redirect to Ultimate Post Kit Pro pricing page public function upk_redirect_to_get_pro() { if (isset($_GET['page']) && $_GET['page'] === self::PAGE_ID . '_get_pro') { // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect -- Intentional redirect to a fixed, hardcoded external URL; wp_safe_redirect would block off-site hosts. wp_redirect('https://postkit.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') { // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect -- Intentional redirect to a fixed, hardcoded external URL; wp_safe_redirect would block off-site hosts. wp_redirect('https://account.bdthemes.com/'); exit; } } /** * Add Plugin Menus * * @access public * */ public function admin_menu() { add_menu_page( BDTUPK_TITLE . ' ' . esc_html__('Dashboard', 'ultimate-post-kit'), BDTUPK_TITLE, 'manage_options', self::PAGE_ID, [$this, 'plugin_page'], $this->ultimate_post_kit_icon(), 58 ); add_submenu_page( self::PAGE_ID, BDTUPK_TITLE, esc_html__('Core Widgets', 'ultimate-post-kit'), 'manage_options', self::PAGE_ID . '#ultimate_post_kit_active_modules', [$this, 'plugin_page'] ); add_submenu_page( self::PAGE_ID, BDTUPK_TITLE, esc_html__('Extensions', 'ultimate-post-kit'), 'manage_options', self::PAGE_ID . '#ultimate_post_kit_elementor_extend', [$this, 'plugin_page'] ); add_submenu_page( self::PAGE_ID, BDTUPK_TITLE, esc_html__('Special Features', 'ultimate-post-kit'), 'manage_options', self::PAGE_ID . '#ultimate_post_kit_other_settings', [$this, 'plugin_page'] ); add_submenu_page( self::PAGE_ID, BDTUPK_TITLE, esc_html__('API Settings', 'ultimate-post-kit'), 'manage_options', self::PAGE_ID . '#ultimate_post_kit_api_settings', [$this, 'plugin_page'] ); add_submenu_page( self::PAGE_ID, BDTUPK_TITLE, esc_html__('Extra Options', 'ultimate-post-kit'), 'manage_options', self::PAGE_ID . '#ultimate_post_kit_extra_options', [$this, 'plugin_page'] ); add_submenu_page( self::PAGE_ID, BDTUPK_TITLE, esc_html__('System Status', 'ultimate-post-kit'), 'manage_options', self::PAGE_ID . '#ultimate_post_kit_analytics_system_req', [$this, 'plugin_page'] ); add_submenu_page( self::PAGE_ID, BDTUPK_TITLE, esc_html__('Other Plugins', 'ultimate-post-kit'), 'manage_options', self::PAGE_ID . '#ultimate_post_kit_other_plugins', [$this, 'plugin_page'] ); // add_submenu_page( // self::PAGE_ID, // BDTUPK_TITLE, // esc_html__('Get Up to 60%', 'ultimate-post-kit'), // 'manage_options', // self::PAGE_ID . '#ultimate_post_kit_affiliate', // [$this, 'plugin_page'] // ); if (true == _is_upk_pro_activated()) { add_submenu_page( self::PAGE_ID, BDTUPK_TITLE, esc_html__('Rollback Version', 'ultimate-post-kit'), 'manage_options', self::PAGE_ID . '#ultimate_post_kit_rollback_version', [$this, 'plugin_page'] ); add_submenu_page( self::PAGE_ID, BDTUPK_TITLE, esc_html__('Template Builder', 'ultimate-post-kit'), 'edit_pages', 'edit.php?post_type=upk-template-builder', ); } } /** * Get SVG Icons of Ultimate Post Kit * * @access public * @return string */ public function ultimate_post_kit_icon() { return 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyNC4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiDQoJIHZpZXdCb3g9IjAgMCA5MDkuMyA4ODMuOCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgOTA5LjMgODgzLjg7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+DQoJLnN0MHtmaWxsOiNBN0FBQUQ7fQ0KPC9zdHlsZT4NCjxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik04MTEuMiwyNzIuOUg2ODEuNnYxMjkuN2MwLDEzLjYtMTEsMjQuNy0yNC43LDI0LjdoLTEwNWMtMTMuNiwwLTI0LjctMTEtMjQuNy0yNC43YzAsMCwwLDAsMCwwdi0xMDUNCgljMC0xMy42LDExLTI0LjcsMjQuNi0yNC43YzAsMCwwLDAsMCwwaDEyOS43VjE0My4zYzAtMTMuNi0xMS0yNC43LTI0LjctMjQuN0gzOTcuNmMtMTMuNiwwLTI0LjcsMTEtMjQuNywyNC43YzAsMCwwLDAsMCwwdjQ3MS41DQoJYzAsMTMuNi0xMSwyNC42LTI0LjYsMjQuN2MwLDAsMCwwLDAsMGgtMTA1Yy0xMy42LDAtMjQuNy0xMS0yNC43LTI0Ljd2LTM3NWMwLTEzLjYtMTEtMjQuNy0yNC43LTI0LjdIODljLTEzLjYsMC0yNC43LDExLTI0LjcsMjQuNw0KCWMwLDAsMCwwLDAsMHY1MjkuNGMwLDEzLjYsMTEsMjQuNywyNC43LDI0LjdoNDEzLjZjMTMuNiwwLDI0LjctMTEuMSwyNC43LTI0LjdWNjA2LjJjMC0xMy42LDExLTI0LjcsMjQuNy0yNC43aDI1OS4zDQoJYzEzLjYsMCwyNC43LTExLDI0LjctMjQuN1YyOTcuNkM4MzUuOSwyODQsODI0LjksMjczLDgxMS4yLDI3Mi45QzgxMS4yLDI3Mi45LDgxMS4yLDI3Mi45LDgxMS4yLDI3Mi45eiIvPg0KPHJlY3QgeD0iNzMyIiB5PSI4Mi42IiBjbGFzcz0ic3QwIiB3aWR0aD0iMzQuOCIgaGVpZ2h0PSIzNC44Ii8+DQo8cmVjdCB4PSI3OTEiIHk9IjE0OS43IiBjbGFzcz0ic3QwIiB3aWR0aD0iMjMuOSIgaGVpZ2h0PSIyMy45Ii8+DQo8cmVjdCB4PSI4MDMiIHk9IjgyLjYiIGNsYXNzPSJzdDAiIHdpZHRoPSIxNy44IiBoZWlnaHQ9IjE3LjgiLz4NCjxyZWN0IHg9Ijg2Ni43IiB5PSIxNTUuOCIgY2xhc3M9InN0MCIgd2lkdGg9IjE3LjgiIGhlaWdodD0iMTcuOCIvPg0KPHJlY3QgeD0iODI4LjkiIHk9IjQ0LjMiIGNsYXNzPSJzdDAiIHdpZHRoPSI4LjkiIGhlaWdodD0iOC45Ii8+DQo8cmVjdCB4PSI4NzcuNCIgeT0iMzgiIGNsYXNzPSJzdDAiIHdpZHRoPSI3LjIiIGhlaWdodD0iNy4yIi8+DQo8cmVjdCB4PSI4NTIuNiIgeT0iODciIGNsYXNzPSJzdDAiIHdpZHRoPSI4LjkiIGhlaWdodD0iOC45Ii8+DQo8cmVjdCB4PSI3MzUuNCIgeT0iMTgyLjgiIGNsYXNzPSJzdDAiIHdpZHRoPSIxOS43IiBoZWlnaHQ9IjE5LjciLz4NCjxyZWN0IHg9IjgyNi4zIiB5PSIyMDQuNiIgY2xhc3M9InN0MCIgd2lkdGg9IjE0LjEiIGhlaWdodD0iMTQuMSIvPg0KPC9zdmc+DQo='; } /** * Get SVG Icons of Element Pack * * @access public * @return array */ public function get_settings_sections() { $sections = [ [ 'id' => 'ultimate_post_kit_active_modules', 'title' => esc_html__('Core Widgets', 'ultimate-post-kit'), 'icon' => 'dashicons dashicons-screenoptions', ], [ 'id' => 'ultimate_post_kit_elementor_extend', 'title' => esc_html__('Extensions', 'ultimate-post-kit'), 'icon' => 'dashicons dashicons-screenoptions', ], [ 'id' => 'ultimate_post_kit_other_settings', 'title' => esc_html__('Special Features', 'ultimate-post-kit'), 'icon' => 'dashicons dashicons-screenoptions', ], [ 'id' => 'ultimate_post_kit_api_settings', 'title' => esc_html__('API Settings', 'ultimate-post-kit'), 'icon' => 'dashicons dashicons-admin-settings', ], ]; return $sections; } /** * Merge Admin Settings * * @access protected * @return array */ protected function ultimate_post_kit_admin_settings() { return ModuleService::get_widget_settings(function ($settings) { $settings_fields = $settings['settings_fields']; self::$modules_list = $settings_fields['ultimate_post_kit_active_modules']; self::$modules_list_only_widgets = $settings_fields['ultimate_post_kit_active_modules']; return $settings_fields; }); } /** * Get Welcome Panel * * @access public * @return void */ public function ultimate_post_kit_welcome() { ?>

', ''); ?>

<?php echo esc_attr__( 'Ultimate Post Kit Dashboard Template', 'ultimate-post-kit' ); ?>

<?php echo esc_attr__( 'Ultimate Post Kit Dashboard Template', 'ultimate-post-kit' ); ?>

settings_api->show_navigation(); ?>
ultimate_post_kit_welcome(); ?>
settings_api->show_forms(); ?>
ultimate_post_kit_extra_options(); ?>
ultimate_post_kit_analytics_system_req_content(); ?>
ultimate_post_kit_others_plugin(); ?>
upk_rollback_version_content(); ?>
ultimate_post_kit_get_pro(); ?>
footer_info(); } ?>
script(); } /** * Tabbable JavaScript codes & Initiate Color Picker * * This code uses localstorage for displaying active tabs */ function script() { ?>

Ultimate Post Kit Pro plugin made with love by BdThemes Team.
All rights reserved by BdThemes.com.

ID] = $page->post_title; } } return $pages_options; } /** * Check if current license supports white label features * Now includes other_param checking for AppSumo WL flag * * @access public static * @return bool */ public static function is_white_label_license() { // Check if pro version is activated first if (!function_exists('_is_upk_pro_activated') || !_is_upk_pro_activated()) { return false; } // Since UltimatePostKitPro\Base doesn't exist, return false for now // This should be replaced with actual pro license checking logic when available $license_info = UltimatePostKitPro\Base\Ultimate_Post_Kit_Base::GetRegisterInfo(); // Security: Validate license info structure if (empty($license_info) || !is_object($license_info) || empty($license_info->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_upk_pro_installed') ? _is_upk_pro_installed() : false; $is_pro_activated = function_exists('_is_upk_pro_activated') ? _is_upk_pro_activated() : false; // Define plugin slug (adjust if needed) $plugin_slug = 'ultimate-post-kit-pro/ultimate-post-kit-pro.php'; // Case 1: Pro not installed if ( ! $is_pro_installed ) : ?>

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

>

<?php echo esc_attr__( 'Icon Preview', 'ultimate-post-kit' ); ?>

<?php echo esc_attr__( 'Logo Preview', 'ultimate-post-kit' ); ?>

⚠️ BDTUPK_HIDE Currently Active

Advanced white label mode is currently enabled. Ultimate Post Kit menus are hidden from the admin interface.

📧 Email Access System

When you enable BDTUPK_HIDE, an email will be automatically sent to:

  • License Email:
  • Admin Email:

This email will contain a special access link that allows you to return to these settings even when BDTUPK_HIDE is active.

ultimate_post_kit_widgets_status(); ?>

ultimate_post_kit_system_requirement(); ?>
>

>

>

0
0
0
', '' ); echo ' ' . esc_html__('from here.', 'ultimate-post-kit') . ''; ?>
'; $no_icon = ''; $environment = Utils::get_environment_info(); ?>
Ultimate Post Kit' ); ?>
'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( 'upk_custom_css', $custom_css ); update_option( 'upk_custom_js', $custom_js ); update_option( 'upk_custom_css_2', $custom_css_2 ); update_option( 'upk_custom_js_2', $custom_js_2 ); update_option( 'upk_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'], 'upk_install_plugin_nonce')) { wp_send_json_error(['message' => __('Security check failed', 'ultimate-post-kit')]); } // Check user capability if (!current_user_can('install_plugins')) { wp_send_json_error(['message' => __('You do not have permission to install plugins', 'ultimate-post-kit')]); } $plugin_slug = sanitize_text_field($_POST['plugin_slug']); if (empty($plugin_slug)) { wp_send_json_error(['message' => __('Plugin slug is required', 'ultimate-post-kit')]); } // 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: ', 'ultimate-post-kit') . $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: ', 'ultimate-post-kit') . $result->get_error_message()]); } elseif ($skin->get_errors()->has_errors()) { wp_send_json_error(['message' => __('Installation failed: ', 'ultimate-post-kit') . $skin->get_error_messages()]); } elseif (is_null($result)) { wp_send_json_error(['message' => __('Installation failed: Unable to connect to filesystem', 'ultimate-post-kit')]); } // Get installation status $install_status = install_plugin_install_status($api); wp_send_json_success([ 'message' => __('Plugin installed successfully!', 'ultimate-post-kit'), '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', 'ultimate-post-kit') . ''; case 'not_installed': default: $plugin_slug = $this->extract_plugin_slug_from_path($plugin_path); $nonce = wp_create_nonce('upk_install_plugin_nonce'); return '' . __('Install', 'ultimate-post-kit') . ''; } } /** * Extra Options Start Here */ /** * Render Custom CSS & JS Section * * @access public * @return void */ public function render_custom_css_js_section() { ?>

render_custom_css_js_section(); ?>
render_white_label_section(); ?>
rollback_version->upk_rollback_version_content(); } /** * Get allowed white label license types (SHA-256 hashes) * This centralized method makes it easy to add new license types in the future * Note: AppSumo and Lifetime licenses require WL flag in other_param instead of automatic access * * @access public static * @return array Array of SHA-256 hashes for allowed license types */ public static function get_white_label_allowed_license_types() { $allowed_types = [ 'agency' => '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; } /** * Revoke white label access token * * @access public * @return bool */ public function revoke_white_label_access_token() { $token_data = get_option( 'upk_white_label_access_token', [] ); if ( ! empty( $token_data ) ) { delete_option( 'upk_white_label_access_token' ); return true; } return false; } /** * 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( 'upk_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'], 'upk_white_label_nonce')) { wp_send_json_error(['message' => __('Security check failed', 'ultimate-post-kit')]); } if (!current_user_can('manage_options')) { wp_send_json_error(['message' => __('You do not have permission to manage white label settings', 'ultimate-post-kit')]); } // Check license eligibility if (!self::is_white_label_license()) { wp_send_json_error(['message' => __('Your license does not support white label features', 'ultimate-post-kit')]); } // 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', 'ultimate-post-kit') ]); } else { wp_send_json_error([ 'message' => __('No active access token found to revoke', 'ultimate-post-kit') ]); } } /** * Get License Key * * @access public * @return string */ public static function get_license_key() { $license_key = get_option('ultimate_post_kit_license_key'); return trim($license_key); } /** * Get License Email * * @access public * @return string */ public static function get_license_email() { return trim(get_option('ultimate_post_kit_license_email', get_bloginfo('admin_email'))); } } new UltimatePostKit_Admin_Settings();