HEX
Server: Apache/2.4.65 (Unix) OpenSSL/1.1.1k
System: Linux server-manager.elshandawiily.com 4.18.0-553.87.1.el8_10.x86_64 #1 SMP Mon Dec 1 05:11:16 EST 2025 x86_64
User: elshanda (1002)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/elshanda/biz.elshandawiily.com/wp-content/plugins/filebird-pro/includes/Admin/Settings.php
<?php
namespace FileBird\Admin;

use FileBird\Classes\Helpers;
use FileBird\Utils\Singleton;
use FileBird\Utils\Vite;
use FileBird\Addons\PostType\Models\Main as PostTypeModel;

defined( 'ABSPATH' ) || exit;
/**
 * Settings Page
 */
class Settings {
	private $hook_suffix    = null;
	const SETTING_PAGE_SLUG = 'filebird-settings';

	use Singleton;

	private function doHooks() {
		add_filter( 'plugin_action_links_' . NJFB_PLUGIN_BASE_NAME, array( $this, 'addActionLinks' ) );
		add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
		add_action( 'admin_menu', array( $this, 'settingsMenu' ) );
		add_action( 'wp_ajax_fbv_save_post_type_settings', array( $this, 'savePostTypeSettings' ) );
		add_action( 'in_admin_header', array( $this, 'in_admin_header' ) );
		add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
	}

	public function in_admin_header() {
		$screen = get_current_screen();

		if ( $screen->id === $this->hook_suffix ) {
			include NJFB_PLUGIN_PATH . '/views/settings/header.php';
		}
	}

	public function getSettingHookSuffix() {
		return $this->hook_suffix;
	}

	private function getInlineMenuIcon() {
		return 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCg0KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiDQoJeT0iMHB4IiB2aWV3Qm94PSIwI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MzgsMy41MS0zMy45NSw5Ljg1LTQ5LjAybDU2LjUsMTYwLjM5QzE1MC4yMiwzNDQuNDgsMTIzLjM5LDMwMi42NCwxMjMuMzksMjU0LjUzeiBNMjExLjA1LDM3NS4wMQ0KCWwzOS4xNC0xMDMuNThsMzYuODQsMTA0LjJjLTExLjcyLDMuNTgtMjQuMTUsNS41Mi0zNy4wMyw1LjUyQzIzNi40MSwzODEuMTQsMjIzLjMzLDM3OC45NywyMTEuMDUsMzc1LjAxeiBNMzA5LjUyLDM2Ni4yOA0KCWw0Mi44OS0xMTkuNTF2MC4yOWwzLTkuMzZjNC4yOS0xMy40LDYuMzctMjcuNDYsNS41MS00MS41Yy0wLjA3LTEuMDgtMC4xNS0yLjEzLTAuMjUtMy4xNWMxMC4xNCwxOC4yMSwxNS45MywzOS4xNywxNS45Myw2MS40OQ0KCUMzNzYuNjEsMzAyLjk0LDM0OS40NCwzNDQuOTgsMzA5LjUyLDM2Ni4yOHoiIC8+DQo8L3N2Zz4=';
	}

	public function settingsMenu() {
		$this->hook_suffix = add_menu_page(
			__( 'FileBird', 'filebird' ),
			__( 'FileBird', 'filebird' ),
			'manage_options',
			self::SETTING_PAGE_SLUG,
			array( $this, 'settingsPage' ),
			$this->getInlineMenuIcon(),
			81
		);
	}

	public function admin_enqueue_scripts( $hook_suffix ) {
		if ( $this->hook_suffix === $hook_suffix ) {
			$script_handle = Vite::enqueue_vite( 'admin.tsx' );

			$postTypes  = Helpers::getRawPostTypes();

			$enabledPostType     = get_option( 'fbv_enabled_posttype', '' );
			$wpmlActiveLanguages = apply_filters( 'wpml_active_languages', null, array( 'skip_missing' => 0 ) );
	
			wp_localize_script(
				$script_handle,
				'fbv_admin',
				array(
					'post_types'         => $postTypes,
					'enabled_post_types' => $enabledPostType ? explode( ',', $enabledPostType ) : array(),
					'rest_api_key'       => get_option( 'fbv_rest_api_key', '' ),
					'wpml'               => array(
						'display_sync' => ! empty( $wpmlActiveLanguages ),
					),
					'is_fbdl_activated' => class_exists( '\FileBird_Document_Library\\DocumentLibrary' )
				)
			);
		}
	}

	public function settingsPage() {
		$notice = '';

		$filebird_activation_error = get_option( 'filebird_activation_error', '' );
		if ( $filebird_activation_error != '' ) {
			update_option( 'filebird_activation_error', '' );
		}

		$filebird_activation_old_domain = get_option( 'filebird_activation_old_domain', '' );
		if ( $filebird_activation_old_domain != '' ) {
			update_option( 'filebird_activation_old_domain', '' );
		}

		if ( '' !== $filebird_activation_error ) {
			$filebird_activation_error = apply_filters( 'filebird_activation_error', $filebird_activation_error );
			if ( 'no-purchase' == $filebird_activation_error ) {
				$filebird_activation_error = __( 'It seems you don\'t have any valid FileBird license. Please <a href="https://ninjateam.org/support" target="_blank"><strong>contact support</strong></a> to get help or <a href="https://1.envato.market/Get-FileBird" target="_blank"><strong>purchase a FileBird license</strong></a>', 'filebird' );
			} elseif ( 'code-is-used' == $filebird_activation_error ) {
				$filebird_activation_error = sprintf( __( 'This license was used with <i>%s</i>, please <a href="https://1.envato.market/Get-FileBird" target="_blank"><strong>purchase another license</strong></a>, or <a href="https://ninjateam.org/support" target="_blank"><strong>contact support</strong></a>', 'filebird' ), esc_html( $filebird_activation_old_domain ) );
			}
			$notice = '<div style="margin-bottom: 1rem !important;" class="njt-warning-notice filebird-notice notice notice-warning is-dismissible wp-md:fb-max-w-[1060px] fb-m-auto"><p>' . $filebird_activation_error . '</p><button type="button" class="notice-dismiss" onClick="jQuery(\'.njt-warning-notice\').remove()"><span class="screen-reader-text">' . __( 'Dismiss this notice.', 'filebird' ) . '</span></button></div>';
		}

		?>

		<div class="wrap">
			<?php echo $notice; ?>
			<h1 id="filebird-setting-heading"><?php esc_html_e( 'FileBird Settings', 'filebird' ); ?></h1>
			<div id="filebird-setting"/>
		</div>
		<style>
			.notice:not(.filebird-notice) {
				display: none;
			}
		</style>
		<?php
	}

	public function plugin_row_meta( $links, $file ) {
		if ( strpos( $file, 'filebird.php' ) !== false ) {
			$new_links = array(
				'doc' => '<a href="https://ninjateam.gitbook.io/filebird/" target="_blank">' . __( 'Documentation', 'filebird' ) . '</a>',
			);

			$links = array_merge( $links, $new_links );
		}

		return $links;
	}

	public function addActionLinks( $links ) {
		$settingsLinks = array(
			'<a href="' . admin_url( 'admin.php?page=' . self::SETTING_PAGE_SLUG ) . '">' . esc_html__( 'Settings', 'filebird' ) . '</a>',
		);

		return array_merge( $settingsLinks, $links );
	}

	public function savePostTypeSettings() {
		check_ajax_referer( 'fbv_nonce', 'nonce', true );
		$fbv_enabled_posttype = '';
		if ( isset( $_POST['post_types'] ) ) {
			$post_types           = Helpers::sanitize_array( $_POST['post_types'] );
			$fbv_enabled_posttype = implode( ',', $post_types );
		}
		update_option( 'fbv_enabled_posttype', $fbv_enabled_posttype );
		wp_send_json_success(
			array( 'mess' => __( 'Settings saved!', 'filebird' ) )
		);
	}
}