PluginProbe ʕ •ᴥ•ʔ
Responsive Lightbox & Gallery / 2.7.2
Responsive Lightbox & Gallery v2.7.2
2.7.8 trunk 1.0.0 1.0.1 1.0.1.1 1.0.2 1.0.3 1.0.4 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4.0 1.4.0.1 1.4.1 1.4.11 1.4.12 1.4.13 1.4.14 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.3.1 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7
responsive-lightbox / includes / class-settings-pages.php
responsive-lightbox / includes Last commit date
galleries 4 months ago providers 4 months ago settings 4 months ago class-fast-image.php 2 years ago class-folders.php 4 months ago class-frontend.php 4 months ago class-galleries.php 4 months ago class-multilang.php 2 years ago class-remote-library-api.php 4 months ago class-remote-library.php 4 months ago class-settings-api.php 4 months ago class-settings-data.php 4 months ago class-settings-pages.php 4 months ago class-settings.php 4 months ago class-tour.php 4 months ago class-welcome.php 2 years ago class-widgets.php 2 years ago functions.php 3 years ago
class-settings-pages.php
176 lines
1 <?php
2 // exit if accessed directly
3 if ( ! defined( 'ABSPATH' ) )
4 exit;
5
6 /**
7 * Responsive_Lightbox_Settings_Pages class.
8 *
9 * Defines full Settings API page and tabs structure.
10 *
11 * @class Responsive_Lightbox_Settings_Pages
12 */
13 class Responsive_Lightbox_Settings_Pages {
14
15 /**
16 * Class constructor.
17 *
18 * @return void
19 */
20 public function __construct() {
21 add_filter( 'rl_settings_pages', [ $this, 'settings_pages' ], 20 );
22 }
23
24 /**
25 * Provide Settings API pages definition.
26 *
27 * @param array $pages Existing pages.
28 * @return array
29 */
30 public function settings_pages( $pages ) {
31 // hard break: define a single top-level page with tabs
32 $pages = [];
33
34 $rl = Responsive_Lightbox();
35
36 $capability = apply_filters(
37 'rl_lightbox_settings_capability',
38 $rl->options['capabilities']['active'] ? 'edit_lightbox_settings' : 'manage_options'
39 );
40
41 // determine default lightbox script
42 $default_lightbox = ! empty( $rl->options['settings']['script'] ) ? $rl->options['settings']['script'] : '';
43 $default_lightbox_subpage = $default_lightbox !== '' ? $default_lightbox : '';
44
45 // lightbox scripts (subpages under Lightboxes)
46 $lightbox_subpages = [];
47 $scripts = Responsive_Lightbox_Settings_Data::get_scripts();
48 foreach ( $scripts as $key => $script ) {
49 $lightbox_subpages[$key] = [
50 'label' => $script['name'] . ( $key === $default_lightbox ? ' ' . __( '(default)', 'responsive-lightbox' ) : '' )
51 ];
52 }
53
54 if ( $default_lightbox_subpage === '' || ! isset( $lightbox_subpages[$default_lightbox_subpage] ) ) {
55 reset( $lightbox_subpages );
56 $default_lightbox_subpage = key( $lightbox_subpages );
57 }
58
59 // determine default gallery type
60 $default_gallery = ! empty( $rl->options['settings']['default_gallery'] ) ? $rl->options['settings']['default_gallery'] : '';
61 $default_gallery_section = $default_gallery !== '' ? $default_gallery . '_gallery' : '';
62
63 // gallery types (subpages under Galleries)
64 $gallery_types = apply_filters( 'rl_gallery_types', $rl->get_data( 'gallery_types' ) );
65
66 if ( isset( $gallery_types['default'] ) )
67 unset( $gallery_types['default'] );
68
69 $gallery_subpages = [];
70 foreach ( $gallery_types as $key => $label ) {
71 $is_default = $key === $default_gallery;
72 $gallery_subpages[$key . '_gallery'] = [
73 'label' => $label . ( $is_default ? ' ' . __( '(default)', 'responsive-lightbox' ) : '' ),
74 'option_name' => 'responsive_lightbox_' . $key . '_gallery'
75 ];
76 }
77
78 if ( $default_gallery_section === '' || ! isset( $gallery_subpages[$default_gallery_section] ) ) {
79 reset( $gallery_subpages );
80 $default_gallery_section = key( $gallery_subpages );
81 }
82
83 // licenses tab is conditional
84 $extensions = apply_filters( 'rl_settings_licenses', [] );
85
86 $tabs = [
87 'settings' => [
88 'label' => __( 'General', 'responsive-lightbox' ),
89 'option_name' => 'responsive_lightbox_settings'
90 ],
91 'configuration' => [
92 'label' => __( 'Lightboxes', 'responsive-lightbox' ),
93 'option_name' => 'responsive_lightbox_configuration',
94 'subpages' => $lightbox_subpages,
95 'default_subpage' => $default_lightbox_subpage
96 ],
97 'gallery' => [
98 'label' => __( 'Galleries', 'responsive-lightbox' ),
99 'subpages' => $gallery_subpages,
100 'default_subpage' => $default_gallery_section
101 ],
102 'builder' => [
103 'label' => __( 'Builder', 'responsive-lightbox' ),
104 'option_name' => 'responsive_lightbox_builder'
105 ],
106 'folders' => [
107 'label' => __( 'Folders', 'responsive-lightbox' ),
108 'option_name' => 'responsive_lightbox_folders'
109 ],
110 'capabilities' => [
111 'label' => __( 'Capabilities', 'responsive-lightbox' ),
112 'option_name' => 'responsive_lightbox_capabilities'
113 ],
114 'remote_library' => [
115 'label' => __( 'Remote Library', 'responsive-lightbox' ),
116 'option_name' => 'responsive_lightbox_remote_library'
117 ]
118 ];
119
120 // Backward compatibility: Convert legacy tab registrations to Settings API format
121 // Add-ons using rl_settings_tabs_extra will automatically appear in Settings API UI
122 $legacy_tabs = apply_filters( 'rl_settings_tabs_extra', [] );
123
124 if ( ! empty( $legacy_tabs ) ) {
125 foreach ( $legacy_tabs as $tab_key => $tab_data ) {
126 // Skip if already registered via modern filter or if it's a core tab
127 if ( isset( $tabs[$tab_key] ) )
128 continue;
129
130 // Convert legacy format to Settings API format
131 $tabs[$tab_key] = [
132 'label' => isset( $tab_data['name'] ) ? $tab_data['name'] : ucfirst( str_replace( '_', ' ', $tab_key ) ),
133 'option_name' => isset( $tab_data['key'] ) ? $tab_data['key'] : 'responsive_lightbox_' . $tab_key
134 ];
135 }
136 }
137
138 // Add licenses tab after add-on tabs (if extensions exist)
139 if ( ! empty( $extensions ) ) {
140 $tabs['licenses'] = [
141 'label' => __( 'Licenses', 'responsive-lightbox' ),
142 'option_name' => 'responsive_lightbox_licenses'
143 ];
144 }
145
146 // Add addons tab last
147 $tabs['addons'] = [
148 'label' => __( 'Add-ons', 'responsive-lightbox' ),
149 'option_name' => 'responsive_lightbox_addons',
150 'form' => [ 'buttons' => false ]
151 ];
152
153 /**
154 * Allow add-ons to register tabs with Settings API.
155 *
156 * @since 2.7.0
157 * @param array $tabs Existing tabs array.
158 * @return array Modified tabs array with add-on tabs included.
159 */
160 $tabs = apply_filters( 'rl_settings_api_tabs', $tabs );
161
162 $pages['settings'] = [
163 'type' => 'page',
164 'menu_slug' => 'responsive-lightbox-settings',
165 'page_title' => __( 'Responsive Lightbox & Gallery', 'responsive-lightbox' ),
166 'menu_title' => __( 'Lightbox', 'responsive-lightbox' ),
167 'capability' => $capability,
168 'icon' => 'dashicons-format-image',
169 'position' => 57.1,
170 'tabs' => $tabs
171 ];
172
173 return $pages;
174 }
175 }
176