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-builder.php
134 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Responsive Lightbox Builder Settings |
| 4 | * |
| 5 | * @package Responsive_Lightbox |
| 6 | */ |
| 7 | |
| 8 | // exit if accessed directly |
| 9 | if ( ! defined( 'ABSPATH' ) ) |
| 10 | exit; |
| 11 | |
| 12 | /** |
| 13 | * Responsive Lightbox Builder Settings class. |
| 14 | * |
| 15 | * @class Responsive_Lightbox_Settings_Builder |
| 16 | */ |
| 17 | class Responsive_Lightbox_Settings_Builder extends Responsive_Lightbox_Settings_Base { |
| 18 | |
| 19 | /** |
| 20 | * Tab key identifier. |
| 21 | * |
| 22 | * @var string |
| 23 | */ |
| 24 | const TAB_KEY = 'builder'; |
| 25 | |
| 26 | /** |
| 27 | * Validate settings for Builder tab. |
| 28 | * |
| 29 | * Handles field sanitization including permalink sanitization. |
| 30 | * |
| 31 | * @param array $input Input data from form submission. |
| 32 | * @return array Validated data. |
| 33 | */ |
| 34 | public function validate( $input ) { |
| 35 | // check if this is a reset operation |
| 36 | if ( $this->is_reset_request() ) { |
| 37 | $input = $this->merge_with_defaults( [] ); |
| 38 | add_settings_error( 'reset_rl_builder', 'settings_restored', esc_html__( 'Settings restored to defaults.', 'responsive-lightbox' ), 'updated' ); |
| 39 | return $input; |
| 40 | } |
| 41 | |
| 42 | // sanitize all fields (includes permalink sanitization via sanitize_field) |
| 43 | $input = $this->sanitize_fields( $input, 'builder' ); |
| 44 | |
| 45 | return $input; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Provide settings data for this tab. |
| 50 | * |
| 51 | * @param array $data Settings data. |
| 52 | * @return array |
| 53 | */ |
| 54 | public function settings_data( $data ) { |
| 55 | // get main instance |
| 56 | $rl = Responsive_Lightbox(); |
| 57 | |
| 58 | // build archives category options |
| 59 | $archives_category_options = [ |
| 60 | 'all' => __( 'All', 'responsive-lightbox' ) |
| 61 | ]; |
| 62 | |
| 63 | // add categories if gallery builder, categories, and archives are enabled |
| 64 | if ( $rl->options['builder']['gallery_builder'] && $rl->options['builder']['categories'] && $rl->options['builder']['archives'] ) { |
| 65 | $terms = get_terms( [ 'taxonomy' => 'rl_category', 'hide_empty' => false ] ); |
| 66 | |
| 67 | if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) { |
| 68 | foreach ( $terms as $term ) { |
| 69 | $archives_category_options[$term->slug] = $term->name; |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | $data[self::TAB_KEY] = [ |
| 75 | 'option_name' => 'responsive_lightbox_builder', |
| 76 | 'option_group' => 'responsive_lightbox_builder', |
| 77 | 'validate' => [ $this, 'validate' ], |
| 78 | 'sections' => [ |
| 79 | 'responsive_lightbox_builder' => [ |
| 80 | 'title' => __( 'Gallery Builder Settings', 'responsive-lightbox' ), |
| 81 | 'description' => '', |
| 82 | 'fields' => [ |
| 83 | 'gallery_builder' => [ |
| 84 | 'title' => __( 'Gallery Builder', 'responsive-lightbox' ), |
| 85 | 'type' => 'boolean', |
| 86 | 'label' => __( 'Enable advanced gallery builder.', 'responsive-lightbox' ) |
| 87 | ], |
| 88 | 'categories' => [ |
| 89 | 'title' => __( 'Categories', 'responsive-lightbox' ), |
| 90 | 'type' => 'boolean', |
| 91 | 'label' => __( 'Enable Gallery Categories.', 'responsive-lightbox' ), |
| 92 | 'description' => __( 'Enable if you want to use Gallery Categories.', 'responsive-lightbox' ) |
| 93 | ], |
| 94 | 'tags' => [ |
| 95 | 'title' => __( 'Tags', 'responsive-lightbox' ), |
| 96 | 'type' => 'boolean', |
| 97 | 'label' => __( 'Enable Gallery Tags.', 'responsive-lightbox' ), |
| 98 | 'description' => __( 'Enable if you want to use Gallery Tags.', 'responsive-lightbox' ) |
| 99 | ], |
| 100 | 'permalink' => [ |
| 101 | 'title' => __( 'Gallery Permalink', 'responsive-lightbox' ), |
| 102 | 'type' => 'text', |
| 103 | 'description' => '<code>' . site_url() . '/<strong>' . untrailingslashit( esc_html( $rl->options['builder']['permalink'] ) ) . '</strong>/</code><br />' . esc_html__( 'Enter gallery page slug.', 'responsive-lightbox' ) |
| 104 | ], |
| 105 | 'permalink_categories' => [ |
| 106 | 'title' => __( 'Categories Permalink', 'responsive-lightbox' ), |
| 107 | 'type' => 'text', |
| 108 | 'description' => '<code>' . site_url() . '/<strong>' . untrailingslashit( esc_html( $rl->options['builder']['permalink_categories'] ) ) . '</strong>/</code><br />' . esc_html__( 'Enter gallery categories archive page slug.', 'responsive-lightbox' ) |
| 109 | ], |
| 110 | 'permalink_tags' => [ |
| 111 | 'title' => __( 'Tags Permalink', 'responsive-lightbox' ), |
| 112 | 'type' => 'text', |
| 113 | 'description' => '<code>' . site_url() . '/<strong>' . untrailingslashit( esc_html( $rl->options['builder']['permalink_tags'] ) ) . '</strong>/</code><br />' . esc_html__( 'Enter gallery tags archive page slug.', 'responsive-lightbox' ) |
| 114 | ], |
| 115 | 'archives' => [ |
| 116 | 'title' => __( 'Archives', 'responsive-lightbox' ), |
| 117 | 'type' => 'boolean', |
| 118 | 'label' => __( 'Enable gallery archives.', 'responsive-lightbox' ) |
| 119 | ], |
| 120 | 'archives_category' => [ |
| 121 | 'title' => __( 'Archives Category', 'responsive-lightbox' ), |
| 122 | 'type' => 'select', |
| 123 | 'description' => __( 'Select category for gallery archives.', 'responsive-lightbox' ), |
| 124 | 'options' => $archives_category_options |
| 125 | ] |
| 126 | ] |
| 127 | ] |
| 128 | ] |
| 129 | ]; |
| 130 | |
| 131 | return $data; |
| 132 | } |
| 133 | } |
| 134 |