PluginProbe ʕ •ᴥ•ʔ
Responsive Lightbox & Gallery / trunk
Responsive Lightbox & Gallery vtrunk
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 / settings / class-settings-remote-library.php
responsive-lightbox / includes / settings Last commit date
class-settings-addons.php 4 months ago class-settings-base.php 5 months ago class-settings-builder.php 5 months ago class-settings-capabilities.php 5 months ago class-settings-folders.php 4 months ago class-settings-galleries.php 5 months ago class-settings-general.php 5 months ago class-settings-licenses.php 4 months ago class-settings-lightboxes.php 4 months ago class-settings-remote-library.php 5 months ago
class-settings-remote-library.php
145 lines
1 <?php
2 /**
3 * Responsive Lightbox Remote Library Settings
4 *
5 * @package Responsive_Lightbox
6 */
7
8 // exit if accessed directly
9 if ( ! defined( 'ABSPATH' ) )
10 exit;
11
12 /**
13 * Responsive Lightbox Remote Library Settings class.
14 *
15 * @class Responsive_Lightbox_Settings_Remote_Library
16 */
17 class Responsive_Lightbox_Settings_Remote_Library extends Responsive_Lightbox_Settings_Base {
18
19 /**
20 * Tab key identifier.
21 *
22 * @var string
23 */
24 const TAB_KEY = 'remote_library';
25
26 /**
27 * Get priority for settings data filter.
28 *
29 * @return int
30 */
31 protected function get_settings_data_priority() {
32 return 100; // load late to catch provider fields
33 }
34
35 /**
36 * Validate settings for Remote Library tab.
37 *
38 * Handles field sanitization and applies filter for provider extensions.
39 *
40 * @param array $input Input data from form submission.
41 * @return array Validated data.
42 */
43 public function validate( $input ) {
44 // check if this is a reset operation
45 if ( $this->is_reset_request() ) {
46 $input = $this->merge_with_defaults( [] );
47 add_settings_error( 'reset_rl_remote_library', 'settings_restored', esc_html__( 'Settings restored to defaults.', 'responsive-lightbox' ), 'updated' );
48 return $input;
49 }
50
51 // sanitize all fields
52 $input = $this->sanitize_fields( $input, 'remote_library' );
53
54 // apply filter for provider extensions
55 $input = apply_filters( 'rl_remote_library_settings', $input );
56
57 return $input;
58 }
59
60 /**
61 * Provide settings data for this tab.
62 *
63 * @param array $data Settings data.
64 * @return array
65 */
66 public function settings_data( $data ) {
67 // get main instance
68 $rl = Responsive_Lightbox();
69
70 // base fields for remote library settings section
71 $base_fields = [
72 'active' => [
73 'title' => __( 'Remote Library', 'responsive-lightbox' ),
74 'type' => 'boolean',
75 'label' => __( 'Enable remote libraries.', 'responsive-lightbox' ),
76 'description' => __( 'Check this to enable remote access to the following image libraries.', 'responsive-lightbox' )
77 ],
78 'max_image_size' => [
79 'title' => __( 'Max Image Size', 'responsive-lightbox' ),
80 'type' => 'number',
81 'min' => 1,
82 'description' => __( 'Maximum allowed image size for remote downloads.', 'responsive-lightbox' ),
83 'append' => __( 'MB', 'responsive-lightbox' )
84 ],
85 'caching' => [
86 'title' => __( 'Caching', 'responsive-lightbox' ),
87 'type' => 'boolean',
88 'label' => __( 'Enable remote library requests caching.', 'responsive-lightbox' )
89 ],
90 'cache_expiry' => [
91 'title' => '',
92 'type' => 'number',
93 'min' => 1,
94 'description' => __( 'Enter the cache expiry time.', 'responsive-lightbox' ),
95 'append' => __( 'hour(s)', 'responsive-lightbox' ),
96 'logic' => [ 'field' => 'caching', 'operator' => 'is', 'value' => 'true' ],
97 'animation' => 'slide'
98 ]
99 ];
100
101 // get provider fields from new filter (preferred method for extensions)
102 $provider_fields = apply_filters( 'rl_remote_library_provider_fields', [] );
103
104 // fallback: get provider fields from legacy settings (for backward compatibility)
105 if ( empty( $provider_fields ) && $rl->settings->has_setting_tab( 'remote_library' ) ) {
106 $remote_fields = $rl->settings->get_setting_fields( 'remote_library' );
107 foreach ( $remote_fields as $field_id => $field ) {
108 // skip base fields, only get provider fields (those with section = providers)
109 if ( isset( $field['section'] ) && $field['section'] === 'responsive_lightbox_remote_library_providers' ) {
110 $provider_fields[$field_id] = $field;
111 }
112 }
113 }
114
115 $data[self::TAB_KEY] = [
116 'option_name' => 'responsive_lightbox_remote_library',
117 'option_group' => 'responsive_lightbox_remote_library',
118 'validate' => [ $this, 'validate' ],
119 'sections' => [
120 'responsive_lightbox_remote_library' => [
121 'title' => __( 'Remote Library Settings', 'responsive-lightbox' ),
122 'description' => '',
123 'fields' => $base_fields
124 ],
125 'responsive_lightbox_remote_library_providers' => [
126 'title' => __( 'Media Providers', 'responsive-lightbox' ),
127 'callback' => [ $this, 'remote_library_providers_description' ],
128 'fields' => $provider_fields
129 ]
130 ]
131 ];
132
133 return $data;
134 }
135
136 /**
137 * Remote Library Media Providers description.
138 *
139 * @return void
140 */
141 public function remote_library_providers_description() {
142 echo '<p class="description">' . sprintf( esc_html__( 'Below you\'ll find a list of available remote media libraries. If you\'re looking for Pixabay, Pexels, Instagram and other integrations please check the %s addon.', 'responsive-lightbox' ), '<a href="http://www.dfactory.co/products/remote-library-pro/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=addon" target="_blank">Remote Library Pro</a>' ) . '</p>';
143 }
144 }
145