PluginProbe
FileBird – WordPress Media Library Folders & File Manager / 6.3.4
FileBird – WordPress Media Library Folders & File Manager v6.3.4
6.5.8 6.5.7 6.5.5 6.5.4 trunk 4.3.1 5.1.6 5.3 5.3.2 5.4.3 5.4.4 5.4.5 5.5 5.5.3 5.5.5 5.5.8 5.5.8.1 5.6 5.6.1 5.6.2 5.6.3 5.6.4 6.2.3 6.2.5 6.3 All 36 releases
filebird / includes / Admin / Settings.php

Settings.php in FileBird – WordPress Media Library Folders & File Manager 6.3.4, at includes/Admin/Settings.php

144 lines 6.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace FileBird\Admin;
3
4 use FileBird\Classes\Helpers;
5 use FileBird\Utils\Singleton;
6 use FileBird\Utils\Vite;
7
8 defined( 'ABSPATH' ) || exit;
9 /**
10 * Settings Page
11 */
12 class Settings {
13 private $hook_suffix = null;
14 const SETTING_PAGE_SLUG = 'filebird-settings';
15
16 use Singleton;
17
18 private function doHooks() {
19 add_filter( 'plugin_action_links_' . NJFB_PLUGIN_BASE_NAME, array( $this, 'addActionLinks' ) );
20 add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
21 add_action( 'admin_menu', array( $this, 'settingsMenu' ) );
22 add_action( 'in_admin_header', array( $this, 'in_admin_header' ) );
23 add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
24 }
25
26 public function in_admin_header() {
27 $screen = get_current_screen();
28
29 if ( $screen->id === $this->hook_suffix ) {
30 include NJFB_PLUGIN_PATH . '/views/settings/header.php';
31 }
32 }
33
34 public function getSettingHookSuffix() {
35 return $this->hook_suffix;
36 }
37
38 private function getInlineMenuIcon() {
39 return 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCg0KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwM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AuMjYtMC4xNywwLjRDMTMzLjM0LDIwNS4yOCwxMzMuMzksMjA1LjE0LDEzMy40NSwyMDUuMDENCgl6IE0xMjMuMzksMjU0LjUzYzAtMTcuMzgsMy41MS0zMy45NSw5Ljg1LTQ5LjAybDU2LjUsMTYwLjM5QzE1MC4yMiwzNDQuNDgsMTIzLjM5LDMwMi42NCwxMjMuMzksMjU0LjUzeiBNMjExLjA1LDM3NS4wMQ0KCWwzOS4xNC0xMDMuNThsMzYuODQsMTA0LjJjLTExLjcyLDMuNTgtMjQuMTUsNS41Mi0zNy4wMyw1LjUyQzIzNi40MSwzODEuMTQsMjIzLjMzLDM3OC45NywyMTEuMDUsMzc1LjAxeiBNMzA5LjUyLDM2Ni4yOA0KCWw0Mi44OS0xMTkuNTF2MC4yOWwzLTkuMzZjNC4yOS0xMy40LDYuMzctMjcuNDYsNS41MS00MS41Yy0wLjA3LTEuMDgtMC4xNS0yLjEzLTAuMjUtMy4xNWMxMC4xNCwxOC4yMSwxNS45MywzOS4xNywxNS45Myw2MS40OQ0KCUMzNzYuNjEsMzAyLjk0LDM0OS40NCwzNDQuOTgsMzA5LjUyLDM2Ni4yOHoiIC8+DQo8L3N2Zz4=';
40 }
41
42 public function settingsMenu() {
43 $this->hook_suffix = add_menu_page(
44 __( 'FileBird', 'filebird' ),
45 __( 'FileBird', 'filebird' ),
46 'manage_options',
47 self::SETTING_PAGE_SLUG,
48 array( $this, 'settingsPage' ),
49 $this->getInlineMenuIcon(),
50 81
51 );
52 }
53
54 public function admin_enqueue_scripts( $hook_suffix ) {
55 if ( $this->hook_suffix === $hook_suffix ) {
56 $script_handle = Vite::enqueue_vite( 'admin.tsx' );
57
58 $postTypes = apply_filters(
59 'filebird_post_types',
60 get_post_types(
61 array(
62 'public' => true,
63 )
64 )
65 );
66
67 if ( isset( $postTypes['attachment'] ) ) {
68 unset( $postTypes['attachment'] );
69 }
70
71 foreach ( $postTypes as $key => $value ) {
72 $postTypes[ $key ] = get_post_type_object( $key )->labels->singular_name;
73 }
74
75 $wpmlActiveLanguages = apply_filters( 'wpml_active_languages', null, array( 'skip_missing' => 0 ) );
76
77 wp_localize_script(
78 $script_handle,
79 'fbv_admin',
80 array(
81 'post_types' => $postTypes,
82 'enabled_post_types' => array(),
83 'rest_api_key' => get_option( 'fbv_rest_api_key', '' ),
84 'wpml' => array(
85 'display_sync' => ! empty( $wpmlActiveLanguages ),
86 ),
87 )
88 );
89 }
90 }
91
92 public function settingsPage() {
93 $notice = '';
94
95 $filebird_activation_error = get_option( 'filebird_activation_error', '' );
96 if ( $filebird_activation_error != '' ) {
97 update_option( 'filebird_activation_error', '' );
98 }
99
100 $filebird_activation_old_domain = get_option( 'filebird_activation_old_domain', '' );
101 if ( $filebird_activation_old_domain != '' ) {
102 update_option( 'filebird_activation_old_domain', '' );
103 }
104
105 if ( '' !== $filebird_activation_error ) {
106 $filebird_activation_error = apply_filters( 'filebird_activation_error', $filebird_activation_error );
107 if ( 'no-purchase' == $filebird_activation_error ) {
108 $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' );
109 } elseif ( 'code-is-used' == $filebird_activation_error ) {
110 $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 ) );
111 }
112 $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>';
113 }
114
115 ?>
116
117 <div class="wrap">
118 <?php echo $notice; ?>
119 <h1 id="filebird-setting-heading"><?php esc_html_e( 'FileBird Settings', 'filebird' ); ?></h1>
120 <div id="filebird-setting"/>
121 </div>
122 <?php
123 }
124
125 public function plugin_row_meta( $links, $file ) {
126 if ( strpos( $file, 'filebird.php' ) !== false ) {
127 $new_links = array(
128 'doc' => '<a href="https://ninjateam.gitbook.io/filebird/" target="_blank">' . __( 'Documentation', 'filebird' ) . '</a>',
129 );
130
131 $links = array_merge( $links, $new_links );
132 }
133
134 return $links;
135 }
136
137 public function addActionLinks( $links ) {
138 $settingsLinks = array(
139 '<a href="' . admin_url( 'admin.php?page=' . self::SETTING_PAGE_SLUG ) . '">' . esc_html__( 'Settings', 'filebird' ) . '</a>',
140 );
141
142 return array_merge( $settingsLinks, $links );
143 }
144 }