Files

1833 lines
102 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Settings
*
* @link https://plugins360.com
* @since 1.0.0
*
* @package All_In_One_Video_Gallery
*/
// Exit if accessed directly
if ( ! defined( 'WPINC' ) ) {
die;
}
/**
* AIOVG_Admin_Settings class.
*
* @since 1.0.0
*/
class AIOVG_Admin_Settings {
/**
* Settings tabs array.
*
* @since 1.0.0
* @access protected
* @var array
*/
protected $tabs = array();
/**
* Settings sections array.
*
* @since 1.0.0
* @access protected
* @var array
*/
protected $sections = array();
/**
* Settings fields array
*
* @since 1.0.0
* @access protected
* @var array
*/
protected $fields = array();
/**
* Add a settings menu for the plugin.
*
* @since 1.0.0
*/
public function admin_menu() {
add_submenu_page(
'all-in-one-video-gallery',
__( 'All-in-One Video Gallery - Settings', 'all-in-one-video-gallery' ),
__( 'Settings', 'all-in-one-video-gallery' ),
'manage_aiovg_options',
'aiovg_settings',
array( $this, 'display_settings_form' )
);
}
/**
* Display settings form.
*
* @since 1.0.0
*/
public function display_settings_form() {
require_once AIOVG_PLUGIN_DIR . 'admin/partials/settings.php';
}
/**
* Initiate settings.
*
* @since 1.0.0
*/
public function admin_init() {
$this->tabs = $this->get_tabs();
$this->sections = $this->get_sections();
$this->fields = $this->get_fields();
// Initialize settings
$this->initialize_settings();
}
/**
* Get settings tabs.
*
* @since 1.0.0
* @return array $tabs Setting tabs array.
*/
public function get_tabs() {
$tabs = array(
'display' => __( 'Display', 'all-in-one-video-gallery' ),
'player' => __( 'Player', 'all-in-one-video-gallery' ),
'engagement' => __( 'Engagement', 'all-in-one-video-gallery' ),
'access' => __( 'Access Control', 'all-in-one-video-gallery' ),
'seo' => __( 'SEO', 'all-in-one-video-gallery' ),
'advanced' => __( 'Advanced', 'all-in-one-video-gallery' )
);
return apply_filters( 'aiovg_settings_tabs', $tabs );
}
/**
* Get settings sections.
*
* @since 1.0.0
* @return array $sections Setting sections array.
*/
public function get_sections() {
$sections = array(
array(
'id' => 'aiovg_videos_settings',
'title' => __( 'Videos Layout', 'all-in-one-video-gallery' ),
'description' => '',
'tab' => 'display',
'page' => 'aiovg_videos_settings'
),
array(
'id' => 'aiovg_video_settings',
'title' => __( 'Single Video Page', 'all-in-one-video-gallery' ),
'description' => '',
'tab' => 'display',
'page' => 'aiovg_video_settings'
),
array(
'id' => 'aiovg_related_videos_settings',
'title' => __( 'Related Videos', 'all-in-one-video-gallery' ),
'description' => '',
'tab' => 'display',
'page' => 'aiovg_video_settings'
),
array(
'id' => 'aiovg_categories_settings',
'title' => __( 'Categories Layout', 'all-in-one-video-gallery' ),
'description' => '',
'tab' => 'display',
'page' => 'aiovg_categories_settings'
),
array(
'id' => 'aiovg_images_settings',
'title' => __( 'Thumbnail Display', 'all-in-one-video-gallery' ),
'menu_title' => __( 'Images', 'all-in-one-video-gallery' ),
'description' => '',
'tab' => 'display',
'page' => 'aiovg_images_settings'
),
array(
'id' => 'aiovg_featured_images_settings',
'title' => __( 'Featured Images', 'all-in-one-video-gallery' ),
'description' => '',
'tab' => 'display',
'page' => 'aiovg_images_settings'
),
array(
'id' => 'aiovg_pagination_settings',
'title' => __( 'Pagination', 'all-in-one-video-gallery' ),
'description' => '',
'tab' => 'display',
'page' => 'aiovg_pagination_settings'
),
array(
'id' => 'aiovg_player_settings',
'title' => __( 'Player Settings', 'all-in-one-video-gallery' ),
'description' => '',
'tab' => 'player',
'page' => 'aiovg_player_settings'
),
array(
'id' => 'aiovg_likes_settings',
'title' => __( 'Likes & Votes', 'all-in-one-video-gallery' ),
'description' => '',
'tab' => 'engagement',
'page' => 'aiovg_likes_settings'
),
array(
'id' => 'aiovg_email_capture_settings',
'title' => __( 'Email & Lead Capture', 'all-in-one-video-gallery' ),
'description' => sprintf(
'<div class="aiovg-margin-bottom">%s</div><div class="aiovg-notice aiovg-notice-info"><strong>%s:</strong> %s</div>',
__( 'Show an email collection form over your videos to capture leads. The form is not displayed for logged-in WordPress users. Once a viewer submits the email form or skips it, a browser cookie is stored to prevent the form from appearing again. If the viewer clears their cookies, the form will reappear.', 'all-in-one-video-gallery' ),
__( 'Coming Soon', 'all-in-one-video-gallery' ),
__( 'We are working on third-party email provider integrations (Mailchimp, FluentCRM, ActiveCampaign, MailerLite, Webhooks, etc.) as a part of our PRO version. These will allow automatic syncing of captured leads to your email marketing platform.', 'all-in-one-video-gallery' )
),
'tab' => 'engagement',
'page' => 'aiovg_email_capture_settings'
),
array(
'id' => 'aiovg_restrictions_settings',
'title' => __( 'Restrictions', 'all-in-one-video-gallery' ),
'description' => '',
'tab' => 'access',
'page' => 'aiovg_restrictions_settings'
),
array(
'id' => 'aiovg_trailer_settings',
'title' => __( 'Trailer / Teaser', 'all-in-one-video-gallery' ),
'description' => '',
'tab' => 'access',
'page' => 'aiovg_trailer_settings'
),
array(
'id' => 'aiovg_socialshare_settings',
'title' => __( 'Social Sharing', 'all-in-one-video-gallery' ),
'description' => '',
'tab' => 'seo',
'page' => 'aiovg_socialshare_settings'
),
array(
'id' => 'aiovg_general_settings',
'title' => __( 'General', 'all-in-one-video-gallery' ),
'description' => '',
'tab' => 'advanced',
'page' => 'aiovg_general_settings'
),
array(
'id' => 'aiovg_page_settings',
'title' => __( 'Page Settings', 'all-in-one-video-gallery' ),
'menu_title' => __( 'Pages & Permalinks', 'all-in-one-video-gallery' ),
'description' => '',
'tab' => 'advanced',
'page' => 'aiovg_page_settings'
),
array(
'id' => 'aiovg_permalink_settings',
'title' => __( 'Permalinks & Archive Settings', 'all-in-one-video-gallery' ),
'description' => sprintf(
__( 'NOTE: After updating the fields in this section, please visit <a href="%s">Settings → Permalinks</a> and simply save the page without making any changes to flush rewrite rules. Otherwise, you might still see old links.', 'all-in-one-video-gallery' ),
esc_url( admin_url( 'options-permalink.php' ) )
),
'tab' => 'advanced',
'page' => 'aiovg_page_settings'
),
array(
'id' => 'aiovg_api_settings',
'title' => __( 'API Keys', 'all-in-one-video-gallery' ),
'description' => '',
'tab' => 'advanced',
'page' => 'aiovg_api_settings'
),
array(
'id' => 'aiovg_bunny_stream_settings',
'title' => __( 'Bunny Stream', 'all-in-one-video-gallery' ),
'description' => sprintf(
'<div class="aiovg-notice aiovg-notice-info aiovg-margin-bottom"><strong>%s:</strong> %s</div>%s <a href="%s" target="_blank" rel="noopener noreferrer"><strong>%s</strong></a>',
__( 'Important', 'all-in-one-video-gallery' ),
sprintf(
__( 'Modifying your Bunny Stream settings (API Key, Library ID, or CDN Hostname) after your site is live may cause videos to stop functioning or result in data loss. <a href="%s">Contact us</a> if you want to make any changes after your site is live.', 'all-in-one-video-gallery' ),
esc_url( admin_url( 'admin.php?page=all-in-one-video-gallery-contact' ) )
),
__( 'Set up Bunny Stream to easily upload, store, and securely deliver your video content with optimal performance. Simply configure the necessary settings below to get started.', 'all-in-one-video-gallery' ),
'https://plugins360.com/all-in-one-video-gallery/configure-bunny-stream/',
__( 'View Setup Guide →', 'all-in-one-video-gallery' )
),
'tab' => 'advanced',
'page' => 'aiovg_bunny_stream_settings'
),
array(
'id' => 'aiovg_privacy_settings',
'title' => __( 'GDPR & Cookie Consent', 'all-in-one-video-gallery' ),
'description' => __( 'These options will help with privacy restrictions such as GDPR and the EU Cookie Law.', 'all-in-one-video-gallery' ),
'tab' => 'advanced',
'page' => 'aiovg_privacy_settings'
)
);
if ( false !== get_option( 'aiovg_brand_settings' ) ) {
$sections[] = array(
'id' => 'aiovg_brand_settings',
'title' => __( 'Logo & Branding', 'all-in-one-video-gallery' ),
'description' => '',
'tab' => 'player',
'page' => 'aiovg_brand_settings'
);
}
return apply_filters( 'aiovg_settings_sections', $sections );
}
/**
* Get settings fields.
*
* @since 1.0.0
* @return array $fields Setting fields array.
*/
public function get_fields() {
$fields = array(
'aiovg_player_settings' => array(
array(
'name' => 'player',
'label' => __( 'Player Library', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'radio',
'options' => array(
'videojs' => __( 'Video.js', 'all-in-one-video-gallery' ),
'vidstack' => __( 'Plyr.js', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'sanitize_key'
),
array(
'name' => 'theme',
'label' => __( 'Player Theme', 'all-in-one-video-gallery' ),
'description' => __( "Player's Built-in Theme uses the default styling from the selected player library (Video.js or Plyr.js). Plugin Theme replaces it with the plugin's own custom design.", 'all-in-one-video-gallery' ),
'type' => 'radio',
'options' => array(
'default' => __( "Player's Built-in Theme", 'all-in-one-video-gallery' ),
'custom' => __( 'Plugin Theme', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'sanitize_key'
),
array(
'name' => 'force_js_initialization',
'label' => __( 'Player Initialization', 'all-in-one-video-gallery' ),
'description' => __( 'Controls how the player is embedded on the page. "Iframe" (recommended) loads the player in an isolated frame, preventing conflicts with other JavaScript libraries on your site. "JavaScript" initializes the player directly on the page — use this if your theme or page builder requires direct access to the player element.', 'all-in-one-video-gallery' ),
'type' => 'radio',
'options' => array(
0 => __( 'Iframe', 'all-in-one-video-gallery' ),
1 => __( 'JavaScript', 'all-in-one-video-gallery' ),
),
'sanitize_callback' => 'intval'
),
array(
'name' => 'width',
'label' => __( 'Width', 'all-in-one-video-gallery' ),
'description' => __( 'In pixels. Maximum width of the player. Leave this field empty to scale 100% of its enclosing container/html element.', 'all-in-one-video-gallery' ),
'type' => 'text',
'sanitize_callback' => 'aiovg_sanitize_int'
),
array(
'name' => 'ratio',
'label' => __( 'Height (Ratio)', 'all-in-one-video-gallery' ),
'description' => sprintf(
'%s<br /><br /><ul class="aiovg-no-margin"><li><strong>%s:</strong></li><li>"56.25" - %s</li><li>"62.5" - %s</li><li>"75" - %s</li><li>"67" - %s</li><li>"100" - %s</li><li>"41.7" - %s</li><li>"177.78" - %s</li><li>"133.33" - %s</li></ul>',
__( "In percentage. Calculates the players height based on the entered ratio.", 'all-in-one-video-gallery' ),
__( 'Examples', 'all-in-one-video-gallery' ),
__( 'Wide Screen TV (16:9)', 'all-in-one-video-gallery' ),
__( 'Monitor Screens (16:10)', 'all-in-one-video-gallery' ),
__( 'Classic TV (4:3)', 'all-in-one-video-gallery' ),
__( 'Photo Camera (3:2)', 'all-in-one-video-gallery' ),
__( 'Square (1:1)', 'all-in-one-video-gallery' ),
__( 'Cinemascope (21:9)', 'all-in-one-video-gallery' ),
__( 'Vertical / Shorts (9:16)', 'all-in-one-video-gallery' ),
__( 'Vertical Classic (3:4)', 'all-in-one-video-gallery' )
),
'type' => 'text',
'sanitize_callback' => 'floatval'
),
array(
'name' => 'autoplay',
'label' => __( 'Autoplay', 'all-in-one-video-gallery' ),
'description' => __( 'Check this to start playing the video as soon as it is ready', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'loop',
'label' => __( 'Loop', 'all-in-one-video-gallery' ),
'description' => __( 'Check this, so that the video will start over again, every time it is finished', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'muted',
'label' => __( 'Muted', 'all-in-one-video-gallery' ),
'description' => __( 'Check this to turn OFF the audio output of the video by default', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'preload',
'label' => __( 'Preload', 'all-in-one-video-gallery' ),
'description' => sprintf(
'%s<br /><br /><ul class="aiovg-no-margin"><li>%s</li><li>%s</li><li>%s</li></ul>',
__( 'Specifies if and how the video should be loaded when the page loads.', 'all-in-one-video-gallery' ),
__( '"Auto" - The video should be loaded entirely when the page loads', 'all-in-one-video-gallery' ),
__( '"Metadata" - Only metadata should be loaded when the page loads', 'all-in-one-video-gallery' ),
__( '"None" - The video should not be loaded when the page loads', 'all-in-one-video-gallery' )
),
'type' => 'select',
'options' => array(
'auto' => __( 'Auto', 'all-in-one-video-gallery' ),
'metadata' => __( 'Metadata', 'all-in-one-video-gallery' ),
'none' => __( 'None', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'sanitize_key'
),
array(
'name' => 'playsinline',
'label' => __( 'Inline Playback on Mobile', 'all-in-one-video-gallery' ),
'description' => __( 'Check this to play videos inline on mobile devices instead of automatically going into fullscreen mode', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'quality_levels',
'label' => __( 'Quality Levels', 'all-in-one-video-gallery' ),
'description' => __( 'Enter the video quality levels, one per line.<br />Valid options are "4320p", "2880p", "2160p", "1440p", "1080p", "720p", "576p", "480p", "360p", and "240p".', 'all-in-one-video-gallery' ),
'type' => 'textarea',
'sanitize_callback' => 'sanitize_textarea_field'
),
array(
'name' => 'controls',
'label' => __( 'Player Controls', 'all-in-one-video-gallery' ),
'description' => sprintf(
__( '<a href="%s">Click here</a> to configure your share buttons.', 'all-in-one-video-gallery' ),
esc_url( admin_url( 'admin.php?page=aiovg_settings&tab=seo&section=aiovg_socialshare_settings' ) )
),
'type' => 'multicheck',
'options' => array(
'playpause' => __( 'Play / Pause', 'all-in-one-video-gallery' ),
'current' => __( 'Current Time', 'all-in-one-video-gallery' ),
'progress' => __( 'Progressbar', 'all-in-one-video-gallery' ),
'duration' => __( 'Duration', 'all-in-one-video-gallery' ),
'tracks' => __( 'Subtitles', 'all-in-one-video-gallery' ),
'chapters' => __( 'Chapters', 'all-in-one-video-gallery' ),
'speed' => __( 'Speed Control', 'all-in-one-video-gallery' ),
'quality' => __( 'Quality Selector', 'all-in-one-video-gallery' ),
'volume' => __( 'Volume Button', 'all-in-one-video-gallery' ),
'pip' => __( 'Picture-in-Picture Button', 'all-in-one-video-gallery' ),
'fullscreen' => __( 'Fullscreen Button', 'all-in-one-video-gallery' ),
'share' => __( 'Share Buttons', 'all-in-one-video-gallery' ),
'embed' => __( 'Embed Button', 'all-in-one-video-gallery' ),
'download' => __( 'Download Button', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'aiovg_sanitize_array'
),
array(
'name' => 'use_native_controls',
'label' => __( 'Use Native Controls', 'all-in-one-video-gallery' ),
'description' => __( 'Enables native player controls on the selected source types. For example, uses YouTube Player for playing YouTube videos, Vimeo Player for playing Vimeo videos, and Bunny Stream\'s native player for videos uploaded to Bunny Stream. Note that none of our custom player features will work on the selected sources.', 'all-in-one-video-gallery' ),
'type' => 'multicheck',
'options' => array(
'youtube' => __( 'YouTube', 'all-in-one-video-gallery' ),
'vimeo' => __( 'Vimeo', 'all-in-one-video-gallery' ),
'bunny_stream' => __( 'Bunny Stream', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'aiovg_sanitize_array'
),
array(
'name' => 'hide_youtube_logo',
'label' => __( 'Hide YouTube Logo', 'all-in-one-video-gallery' ),
'description' => __( 'YouTube\'s logo cannot be officially hidden, but this experimental option reduces its visibility in our custom player. Use with caution, as it may cause scaling or layout issues, especially with YouTube Shorts. Disable this option if you experience display problems.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'cc_load_policy',
'label' => __( 'Automatically Show Subtitles', 'all-in-one-video-gallery' ),
'description' => __( 'Check this option to automatically show subtitles on the player if available.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'hotkeys',
'label' => __( 'Keyboard Hotkeys', 'all-in-one-video-gallery' ),
'description' => sprintf(
'%s<br /><br /><ul class="aiovg-no-margin"><li>%s</li><li>%s</li><li>%s</li><li>%s</li><li>%s</li><li>%s</li><li>%s</li></ul>',
__( 'Check this option to enable keyboard shortcuts to control the player.', 'all-in-one-video-gallery' ),
__( '"Spacebar" - Toggles between Play and Pause.', 'all-in-one-video-gallery' ),
__( '"Left Arrow" - Rewinds the video.', 'all-in-one-video-gallery' ),
__( '"Right Arrow" - Forwards the video.', 'all-in-one-video-gallery' ),
__( '"Up Arrow" - Increases the volume.', 'all-in-one-video-gallery' ),
__( '"Down Arrow" - Lowers the volume.', 'all-in-one-video-gallery' ),
__( '"F Key" - Toggles fullscreen mode.', 'all-in-one-video-gallery' ),
__( '"M Key" - Toggles audio mute.', 'all-in-one-video-gallery' )
),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
)
),
'aiovg_email_capture_settings' => array(
array(
'name' => 'enable_email_capture',
'label' => __( 'Email Capture', 'all-in-one-video-gallery' ),
'description' => __( 'Show an email collection form over your videos to capture leads.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'pre_roll',
'label' => __( 'Before the Video', 'all-in-one-video-gallery' ),
'description' => __( 'Show the email form before the video starts playing.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'mid_roll',
'label' => __( 'During the Video (Percentage)', 'all-in-one-video-gallery' ),
'description' => __( 'Enter the percentage of video progress at which to show the email form (e.g. 50 for midway). Leave empty to disable. This works only on videos played using our custom player. Does not work with Dailymotion, Rumble, Facebook, or any third-party player embeds.', 'all-in-one-video-gallery' ),
'type' => 'text',
'sanitize_callback' => 'aiovg_sanitize_mid_roll_percentage'
),
array(
'name' => 'post_roll',
'label' => __( 'After the Video', 'all-in-one-video-gallery' ),
'description' => __( 'Show the email form after the video finishes playing. This works only on videos played using our custom player. Does not work with Dailymotion, Rumble, Facebook, or any third-party player embeds.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'collect_name',
'label' => __( 'Collect Name', 'all-in-one-video-gallery' ),
'description' => __( 'Add a "Name" field to the form.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'collect_phone',
'label' => __( 'Collect Phone Number', 'all-in-one-video-gallery' ),
'description' => __( 'Add a "Phone Number" field to the form.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'allow_skip',
'label' => __( 'Allow Skipping', 'all-in-one-video-gallery' ),
'description' => __( 'Allow viewers to skip the email form and continue watching.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'header_text',
'label' => __( 'Header Text', 'all-in-one-video-gallery' ),
'description' => __( 'The header text displayed above the form fields.', 'all-in-one-video-gallery' ),
'type' => 'text',
'placeholder' => __( 'Enter your email to continue watching', 'all-in-one-video-gallery' ),
'sanitize_callback' => 'sanitize_text_field'
),
array(
'name' => 'footer_text',
'label' => __( 'Footer Text', 'all-in-one-video-gallery' ),
'description' => __( 'Optional small text displayed below the form (e.g. consent notice, privacy info). HTML links are allowed. Example: By submitting, you agree to receive marketing emails. See our &lt;a href=\'#\'&gt;Privacy Policy&lt;/a&gt;.', 'all-in-one-video-gallery' ),
'type' => 'textarea',
'sanitize_callback' => 'wp_kses_post'
),
array(
'name' => 'button_label',
'label' => __( 'Button Label', 'all-in-one-video-gallery' ),
'description' => __( 'The text on the submit button.', 'all-in-one-video-gallery' ),
'type' => 'text',
'placeholder' => __( 'Submit', 'all-in-one-video-gallery' ),
'sanitize_callback' => 'sanitize_text_field'
),
array(
'name' => 'skip_text',
'label' => __( 'Skip Text', 'all-in-one-video-gallery' ),
'description' => __( 'The text for the skip link. Displayed only when "Allow Skipping" is enabled.', 'all-in-one-video-gallery' ),
'type' => 'text',
'placeholder' => __( 'Skip', 'all-in-one-video-gallery' ),
'sanitize_callback' => 'sanitize_text_field'
),
array(
'name' => 'blocked_email_domains',
'label' => __( 'Blocked Email Domains', 'all-in-one-video-gallery' ),
'description' => __( 'Enter disposable or unwanted email domains to block, one per line (e.g. mailinator.com, guerrillamail.com). Submissions from these domains will be silently rejected.', 'all-in-one-video-gallery' ),
'type' => 'textarea',
'placeholder' => "mailinator.com\nguerrillamail.com\nthrowaway.email",
'sanitize_callback' => 'aiovg_sanitize_email_domains'
),
),
'aiovg_images_settings' => array(
array(
'name' => 'width',
'label' => __( 'Image Width', 'all-in-one-video-gallery' ),
'description' => __( 'Always 100% of its enclosing container/html element.', 'all-in-one-video-gallery' ),
'type' => 'html',
'sanitize_callback' => 'aiovg_sanitize_int'
),
array(
'name' => 'ratio',
'label' => __( 'Image Height (Ratio)', 'all-in-one-video-gallery' ),
'description' => __( "In percentage. Calculates the images height based on the entered ratio.", 'all-in-one-video-gallery' ),
'type' => 'text',
'sanitize_callback' => 'floatval'
),
array(
'name' => 'size',
'label' => __( 'Image Size', 'all-in-one-video-gallery' ),
'description' => __( 'Those previous options control how the images are displayed on the front-end gallery pages. Whereas this option controls which image size to load.', 'all-in-one-video-gallery' ) . '<br /><br />' .
__( 'Whenever you upload an image, WordPress automatically creates 4 different image sizes. WordPress does this, so you don\'t have to keep resizing images manually and to ensure the best image size is selected for different locations on your website. Select "Thumbnail" for the small file size, so your gallery loads fast. Select "Large" if the image quality is important to your website.', 'all-in-one-video-gallery' ),
'type' => 'select',
'options' => array(
'thumbnail' => __( 'Thumbnail', 'all-in-one-video-gallery' ),
'medium' => __( 'Medium', 'all-in-one-video-gallery' ),
'large' => __( 'Large', 'all-in-one-video-gallery' ),
'full' => __( 'Full Size', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'sanitize_key'
)
),
'aiovg_featured_images_settings' => array(
array(
'name' => 'enabled',
'label' => __( 'Enable Featured Images', 'all-in-one-video-gallery' ),
'description' => __( 'Check this option to enable featured images.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'download_external_images',
'label' => __( 'Download External Images', 'all-in-one-video-gallery' ),
'description' => __( 'WordPress requires featured images to be stored locally as attachments. But, when you add videos from YouTube, Vimeo, Dailymotion & Rumble websites, we simply link the image URLs from their server. Check this option to download the images from such external websites to your server and to link them as featured.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'hide_on_single_video_pages',
'label' => __( 'Hide on Single Video Pages', 'all-in-one-video-gallery' ),
'description' => __( 'Some themes display the featured image above the player on our single video pages. Check this option if you want to hide this.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
)
),
'aiovg_likes_settings' => array(
array(
'name' => 'like_button',
'label' => __( 'Like Button', 'all-in-one-video-gallery' ),
'description' => __( 'Check this option to enable the like button', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'dislike_button',
'label' => __( 'Dislike Button', 'all-in-one-video-gallery' ),
'description' => __( 'Check this option to enable the dislike button', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'login_required_to_vote',
'label' => __( 'Login Required to Vote', 'all-in-one-video-gallery' ),
'description' => __( 'Check this option to require login to like or dislike', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
)
),
'aiovg_socialshare_settings' => array(
array(
'name' => 'services',
'label' => __( 'Sharing Platforms', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'multicheck',
'options' => array(
'facebook' => __( 'Facebook', 'all-in-one-video-gallery' ),
'twitter' => __( 'X (Twitter)', 'all-in-one-video-gallery' ),
'linkedin' => __( 'Linkedin', 'all-in-one-video-gallery' ),
'pinterest' => __( 'Pinterest', 'all-in-one-video-gallery' ),
'tumblr' => __( 'Tumblr', 'all-in-one-video-gallery' ),
'whatsapp' => __( 'WhatsApp', 'all-in-one-video-gallery' ),
'email' => __( 'Email', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'aiovg_sanitize_array'
),
array(
'name' => 'open_graph_tags',
'label' => __( 'Open Graph Tags', 'all-in-one-video-gallery' ),
'description' => __( 'Check this option to enable Facebook Open Graph meta tags and X (Twitter) cards on the single video pages', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'twitter_username',
'label' => __( 'X (Twitter) Username', 'all-in-one-video-gallery' ),
'description' => __( 'The X (Twitter) @username the player card should be attributed to. Required for sharing videos on X (Twitter).', 'all-in-one-video-gallery' ),
'placeholder' => '@username',
'type' => 'text',
'sanitize_callback' => 'sanitize_text_field'
)
),
'aiovg_videos_settings' => array(
array(
'name' => 'template',
'label' => __( 'Select Template', 'all-in-one-video-gallery' ),
'description' => ( aiovg_fs()->is_not_paying() ? sprintf( __( '<a href="%s" target="_blank">Upgrade Pro</a> for more templates (Popup, Inline, Slider, Playlist, Compact, etc.)', 'all-in-one-video-gallery' ), esc_url( aiovg_fs()->get_upgrade_url() ) ) : '' ),
'type' => 'select',
'options' => aiovg_get_video_templates(),
'sanitize_callback' => 'sanitize_key'
),
array(
'name' => 'columns',
'label' => __( 'Columns', 'all-in-one-video-gallery' ),
'description' => __( 'Enter the number of columns you like to have in the gallery view.', 'all-in-one-video-gallery' ),
'type' => 'number',
'min' => 1,
'max' => 12,
'step' => 1,
'sanitize_callback' => 'intval'
),
array(
'name' => 'limit',
'label' => __( 'Limit (per page)', 'all-in-one-video-gallery' ),
'description' => __( 'Number of videos to show per page. Use a value of "0" to show all videos.', 'all-in-one-video-gallery' ),
'type' => 'number',
'sanitize_callback' => 'intval'
),
array(
'name' => 'orderby',
'label' => __( 'Order By', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'select',
'options' => array(
'title' => __( 'Title', 'all-in-one-video-gallery' ),
'date' => __( 'Date Added', 'all-in-one-video-gallery' ),
'views' => __( 'Views Count', 'all-in-one-video-gallery' ),
'likes' => __( 'Likes Count', 'all-in-one-video-gallery' ),
'dislikes' => __( 'Dislikes Count', 'all-in-one-video-gallery' ),
'rand' => __( 'Random', 'all-in-one-video-gallery' ),
'menu_order' => __( 'Menu Order', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'sanitize_key'
),
array(
'name' => 'order',
'label' => __( 'Order', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'select',
'options' => array(
'asc' => __( 'Ascending', 'all-in-one-video-gallery' ),
'desc' => __( 'Descending', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'sanitize_key'
),
array(
'name' => 'thumbnail_style',
'label' => __( 'Image Position', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'select',
'options' => array(
'standard' => __( 'Top', 'all-in-one-video-gallery' ),
'image-left' => __( 'Left', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'sanitize_key'
),
array(
'name' => 'display',
'label' => __( 'Show / Hide (Thumbnails)', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'multicheck',
'options' => array(
'count' => __( 'Videos Count', 'all-in-one-video-gallery' ),
'title' => __( 'Video Title', 'all-in-one-video-gallery' ),
'category' => __( 'Category Name(s)', 'all-in-one-video-gallery' ),
'tag' => __( 'Tag Name(s)', 'all-in-one-video-gallery' ),
'date' => __( 'Date Added', 'all-in-one-video-gallery' ),
'user' => __( 'Author Name', 'all-in-one-video-gallery' ),
'views' => __( 'Views Count', 'all-in-one-video-gallery' ),
'likes' => __( 'Likes Count', 'all-in-one-video-gallery' ),
'dislikes' => __( 'Dislikes Count', 'all-in-one-video-gallery' ),
'comments' => __( 'Comments Count', 'all-in-one-video-gallery' ),
'duration' => __( 'Video Duration', 'all-in-one-video-gallery' ),
'excerpt' => __( 'Video Excerpt (Short Description)', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'aiovg_sanitize_array'
),
array(
'name' => 'title_length',
'label' => __( 'Title Length', 'all-in-one-video-gallery' ),
'description' => __( 'Number of characters.', 'all-in-one-video-gallery' ),
'type' => 'number',
'sanitize_callback' => 'intval'
),
array(
'name' => 'excerpt_length',
'label' => __( 'Excerpt Length', 'all-in-one-video-gallery' ),
'description' => __( 'Number of characters.', 'all-in-one-video-gallery' ),
'type' => 'number',
'sanitize_callback' => 'intval'
)
),
'aiovg_categories_settings' => array(
array(
'name' => 'template',
'label' => __( 'Select Template', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'select',
'options' => array(
'grid' => __( 'Grid', 'all-in-one-video-gallery' ),
'list' => __( 'List', 'all-in-one-video-gallery' ),
'dropdown' => __( 'Dropdown', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'sanitize_key'
),
array(
'name' => 'columns',
'label' => __( 'Columns', 'all-in-one-video-gallery' ),
'description' => __( 'Enter the number of columns you like to have in your categories page.', 'all-in-one-video-gallery' ),
'type' => 'number',
'min' => 1,
'max' => 12,
'step' => 1,
'sanitize_callback' => 'intval'
),
array(
'name' => 'limit',
'label' => __( 'Limit (per page)', 'all-in-one-video-gallery' ),
'description' => __( 'Number of categories to show per page. Use a value of "0" to show all categories.', 'all-in-one-video-gallery' ),
'type' => 'number',
'sanitize_callback' => 'intval'
),
array(
'name' => 'orderby',
'label' => __( 'Order By', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'select',
'options' => array(
'id' => __( 'ID', 'all-in-one-video-gallery' ),
'count' => __( 'Count', 'all-in-one-video-gallery' ),
'name' => __( 'Name', 'all-in-one-video-gallery' ),
'slug' => __( 'Slug', 'all-in-one-video-gallery' ),
'menu_order' => __( 'Menu Order', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'sanitize_key'
),
array(
'name' => 'order',
'label' => __( 'Order', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'select',
'options' => array(
'asc' => __( 'Ascending', 'all-in-one-video-gallery' ),
'desc' => __( 'Descending', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'sanitize_key'
),
array(
'name' => 'hierarchical',
'label' => __( 'Show Hierarchy', 'all-in-one-video-gallery' ),
'description' => __( 'Check this to show the child categories', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'show_description',
'label' => __( 'Show Description', 'all-in-one-video-gallery' ),
'description' => __( 'Check this to show the categories description', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'show_count',
'label' => __( 'Show Videos Count', 'all-in-one-video-gallery' ),
'description' => __( 'Check this to show the videos count next to the category name', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'hide_empty',
'label' => __( 'Hide Empty Categories', 'all-in-one-video-gallery' ),
'description' => __( 'Check this to hide categories with no videos', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'breadcrumbs',
'label' => __( 'Enable Breadcrumbs', 'all-in-one-video-gallery' ),
'description' => __( 'Check this option to display breadcrumbs on category pages', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
)
),
'aiovg_pagination_settings' => array(
array(
'name' => 'ajax',
'label' => __( 'Ajax Pagination', 'all-in-one-video-gallery' ),
'description' => __( 'Check this to enable Pagination with Ajax', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'mid_size',
'label' => __( 'Page Range', 'all-in-one-video-gallery' ),
'description' => __( 'Enter how many page numbers to show either side of the current page in the pagination links. Default 2.', 'all-in-one-video-gallery' ),
'type' => 'text',
'sanitize_callback' => 'aiovg_sanitize_int'
)
),
'aiovg_video_settings' => array(
array(
'name' => 'display',
'label' => __( 'Show / Hide', 'all-in-one-video-gallery' ),
'description' => sprintf(
__( '<a href="%s">Click here</a> to configure your share buttons.', 'all-in-one-video-gallery' ),
esc_url( admin_url( 'admin.php?page=aiovg_settings&tab=seo&section=aiovg_socialshare_settings' ) )
),
'type' => 'multicheck',
'options' => array(
'category' => __( 'Category Name(s)', 'all-in-one-video-gallery' ),
'tag' => __( 'Tag Name(s)', 'all-in-one-video-gallery' ),
'date' => __( 'Date Added', 'all-in-one-video-gallery' ),
'user' => __( 'Author Name', 'all-in-one-video-gallery' ),
'views' => __( 'Views Count', 'all-in-one-video-gallery' ),
'related' => __( 'Related Videos', 'all-in-one-video-gallery' ),
'share' => __( 'Share Buttons', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'aiovg_sanitize_array'
),
array(
'name' => 'has_comments',
'label' => __( 'Comments', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'radio',
'options' => array(
1 => __( 'Enable comments (can be overridden per video)', 'all-in-one-video-gallery' ),
2 => __( 'Forcefully enable comments on all the video pages', 'all-in-one-video-gallery' ),
-1 => __( 'Disable comments (can be overridden per video)', 'all-in-one-video-gallery' ),
-2 => __( 'Forcefully disable comments on all the video pages', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'intval'
)
),
'aiovg_related_videos_settings' => array(
array(
'name' => 'title',
'label' => __( 'Title', 'all-in-one-video-gallery' ),
'description' => __( 'Enter the title to be displayed above the related videos section.', 'all-in-one-video-gallery' ),
'placeholder' => __( 'Related Videos', 'all-in-one-video-gallery' ),
'type' => 'text',
'sanitize_callback' => 'sanitize_text_field'
),
array(
'name' => 'columns',
'label' => __( 'Columns', 'all-in-one-video-gallery' ),
'description' => __( 'Enter the number of columns you like to have in the related videos section.', 'all-in-one-video-gallery' ),
'type' => 'number',
'min' => 1,
'max' => 12,
'step' => 1,
'sanitize_callback' => 'intval'
),
array(
'name' => 'limit',
'label' => __( 'Limit (per page)', 'all-in-one-video-gallery' ),
'description' => __( 'Number of videos to show per page. Use a value of "0" to show all videos.', 'all-in-one-video-gallery' ),
'type' => 'number',
'sanitize_callback' => 'intval'
),
array(
'name' => 'orderby',
'label' => __( 'Order By', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'select',
'options' => array(
'title' => __( 'Title', 'all-in-one-video-gallery' ),
'date' => __( 'Date Added', 'all-in-one-video-gallery' ),
'views' => __( 'Views Count', 'all-in-one-video-gallery' ),
'likes' => __( 'Likes Count', 'all-in-one-video-gallery' ),
'dislikes' => __( 'Dislikes Count', 'all-in-one-video-gallery' ),
'rand' => __( 'Random', 'all-in-one-video-gallery' ),
'menu_order' => __( 'Menu Order', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'sanitize_key'
),
array(
'name' => 'order',
'label' => __( 'Order', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'select',
'options' => array(
'asc' => __( 'Ascending', 'all-in-one-video-gallery' ),
'desc' => __( 'Descending', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'sanitize_key'
),
array(
'name' => 'display',
'label' => __( 'Pagination', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'multicheck',
'options' => array(
'pagination' => __( 'Show pagination in related videos', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'aiovg_sanitize_array'
),
),
'aiovg_permalink_settings' => array(
array(
'name' => 'video',
'label' => __( 'Single Video Page Slug', 'all-in-one-video-gallery' ),
'description' => __( 'Replaces the default slug value ("aiovg_videos") used by our plugin for single video page URLs. Please enter a slug that is not already used by any pages or posts on your website.', 'all-in-one-video-gallery' ),
'type' => 'text',
'sanitize_callback' => 'sanitize_text_field'
),
array(
'name' => 'video_archive_page',
'label' => __( 'Video Archive Page', 'all-in-one-video-gallery' ),
'description' => sprintf(
'<p>%s</p><p>%s</p>',
esc_html__( 'Select a page to serve as the custom video archive. Requests to the default archive will be redirected here. The [aiovg_videos] shortcode must be on this page.', 'all-in-one-video-gallery' ),
esc_html__( 'The selected page slug will be used as the base in single video URLs. This will override the value set in "Single Video Page Slug" above.', 'all-in-one-video-gallery' )
),
'type' => 'pages',
'sanitize_callback' => 'sanitize_key'
)
),
'aiovg_restrictions_settings' => array(
array(
'name' => 'enable_restrictions',
'label' => __( 'Enable Restrictions', 'all-in-one-video-gallery' ),
'description' => sprintf(
__( 'Enable restrictions to control who can access your videos. Adds a "Restrictions" accordion under the "Access Control" tab in the video form (<a href="%s" target="_blank" rel="noopener noreferrer">Video Gallery → All Videos</a>).', 'all-in-one-video-gallery' ),
esc_url( admin_url( 'edit.php?post_type=aiovg_videos' ) )
),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'access_control',
'label' => __( 'Access Control', 'all-in-one-video-gallery' ),
'description' => __( 'Users with editing permissions (e.g., administrators, editors) will always have access. This is a global setting but can be overridden for individual videos.', 'all-in-one-video-gallery' ),
'type' => 'select',
'options' => array(
0 => __( 'Everyone', 'all-in-one-video-gallery' ),
1 => __( 'Logged out users', 'all-in-one-video-gallery' ),
2 => __( 'Logged in users', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'intval'
),
array(
'name' => 'restricted_roles',
'label' => __( 'Allowed User Roles', 'all-in-one-video-gallery' ),
'description' => __( 'If no roles are selected, all users will have access. Users with editing permissions will always have access. This is a global setting but can be overridden for individual videos.', 'all-in-one-video-gallery' ),
'type' => 'multicheck',
'options' => aiovg_get_user_roles(),
'sanitize_callback' => 'aiovg_sanitize_array'
),
array(
'name' => 'restricted_message',
'label' => __( 'Restricted Message', 'all-in-one-video-gallery' ),
'description' => __( 'Enter the message displayed in place of the video player to users who do not have permission to view restricted videos.', 'all-in-one-video-gallery' ),
'type' => 'wysiwyg',
'sanitize_callback' => 'wp_kses_post'
),
array(
'name' => 'show_restricted_label',
'label' => __( 'Show Restricted Badge on Thumbnails', 'all-in-one-video-gallery' ),
'description' => __( 'Display a badge on gallery thumbnails when a video is restricted.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'restricted_label_text',
'label' => __( 'Thumbnail Badge Text', 'all-in-one-video-gallery' ),
'description' => __( 'Enter the text displayed on the restricted badge in gallery thumbnails.', 'all-in-one-video-gallery' ),
'type' => 'text',
'placeholder' => __( 'Restricted', 'all-in-one-video-gallery' ),
'sanitize_callback' => 'sanitize_text_field'
),
array(
'name' => 'restricted_label_bg_color',
'label' => __( 'Thumbnail Badge Background Color', 'all-in-one-video-gallery' ),
'description' => __( 'Choose a background color for the thumbnail badge on gallery thumbnails.', 'all-in-one-video-gallery' ),
'type' => 'color',
'sanitize_callback' => 'sanitize_text_field'
),
array(
'name' => 'restricted_label_text_color',
'label' => __( 'Thumbnail Badge Text Color', 'all-in-one-video-gallery' ),
'description' => __( 'Choose a text color for the thumbnail badge on gallery thumbnails.', 'all-in-one-video-gallery' ),
'type' => 'color',
'sanitize_callback' => 'sanitize_text_field'
)
),
'aiovg_trailer_settings' => array(
array(
'name' => 'enable_trailers',
'label' => __( 'Enable Trailers', 'all-in-one-video-gallery' ),
'description' => sprintf(
__( 'Enable trailers for restricted videos. Adds a "Trailer / Teaser" accordion under the "Access Control" tab in the video form (<a href="%s" target="_blank" rel="noopener noreferrer">Video Gallery → All Videos</a>).', 'all-in-one-video-gallery' ),
esc_url( admin_url( 'edit.php?post_type=aiovg_videos' ) )
),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'player_overlay_text',
'label' => __( 'Player Overlay Text', 'all-in-one-video-gallery' ),
'description' => __( 'Enter the text shown on the trailer player overlay. Defaults to "Watch Full Video" if a link URL is set, or "Trailer" if not.', 'all-in-one-video-gallery' ),
'type' => 'text',
'placeholder' => __( 'Watch Full Video', 'all-in-one-video-gallery' ),
'sanitize_callback' => 'sanitize_text_field'
),
array(
'name' => 'player_overlay_link',
'label' => __( 'Player Overlay Link URL', 'all-in-one-video-gallery' ),
'description' => __( 'Enter a URL for the player overlay (e.g. membership or login page). Leave empty to display text only.', 'all-in-one-video-gallery' ),
'type' => 'text',
'sanitize_callback' => 'aiovg_sanitize_url'
),
array(
'name' => 'show_trailer_label',
'label' => __( 'Show Trailer Badge on Thumbnails', 'all-in-one-video-gallery' ),
'description' => __( 'Display a badge on gallery thumbnails when a restricted video has a trailer.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'trailer_label_text',
'label' => __( 'Thumbnail Badge Text', 'all-in-one-video-gallery' ),
'description' => __( 'Enter the text displayed on the trailer badge in gallery thumbnails.', 'all-in-one-video-gallery' ),
'type' => 'text',
'placeholder' => __( 'Trailer', 'all-in-one-video-gallery' ),
'sanitize_callback' => 'sanitize_text_field'
),
array(
'name' => 'trailer_label_bg_color',
'label' => __( 'Thumbnail Badge Background Color', 'all-in-one-video-gallery' ),
'description' => __( 'Choose a background color for the thumbnail badge on gallery thumbnails.', 'all-in-one-video-gallery' ),
'type' => 'color',
'sanitize_callback' => 'sanitize_text_field'
),
array(
'name' => 'trailer_label_text_color',
'label' => __( 'Thumbnail Badge Text Color', 'all-in-one-video-gallery' ),
'description' => __( 'Choose a text color for the thumbnail badge on gallery thumbnails.', 'all-in-one-video-gallery' ),
'type' => 'color',
'sanitize_callback' => 'sanitize_text_field'
)
),
'aiovg_privacy_settings' => array(
array(
'name' => 'show_consent',
'label' => __( 'Cookie Consent', 'all-in-one-video-gallery' ),
'description' => __( 'Ask for viewer consent before loading YouTube, Vimeo, or embedded videos from any third-party websites.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'consent_message',
'label' => __( 'Consent Message', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'wysiwyg',
'sanitize_callback' => 'wp_kses_post'
),
array(
'name' => 'consent_button_label',
'label' => __( 'Consent Button Label', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'text',
'sanitize_callback' => 'sanitize_text_field'
),
array(
'name' => 'disable_cookies',
'label' => __( 'Disable Cookies from our Plugin', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'multicheck',
'options' => array(
'aiovg_videos_views' => __( '<strong>aiovg_videos_views</strong>: Required for unique views calculation. Disabling this option would count each view by the user. So, when a user watches the same video 10 times, the views count will also increase by 10 for that video. But, under the unique views, the views count is calculated only once per user for a video.', 'all-in-one-video-gallery' ),
'aiovg_rand_seed' => __( '<strong>aiovg_rand_seed</strong>: Required if you show videos in a random order with the pagination on any of your pages.', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'aiovg_sanitize_array'
),
),
'aiovg_general_settings' => array(
array(
'name' => 'primary_color',
'label' => __( 'Primary Color', 'all-in-one-video-gallery' ),
'description' => __( 'Select a primary color used to style elements across the plugin — player controls, buttons, highlights, and other accent elements. This applies site-wide to all plugin output.', 'all-in-one-video-gallery' ),
'type' => 'color',
'sanitize_callback' => 'sanitize_text_field'
),
array(
'name' => 'force_load_assets',
'label' => __( 'Force Load Plugin Assets', 'all-in-one-video-gallery' ),
'description' => __( 'Force-load the plugin\'s CSS and/or JavaScript files on all front-end pages. Enable this option only if layouts do not render correctly due to page builders or theme conflicts.', 'all-in-one-video-gallery' ),
'type' => 'multicheck',
'options' => array(
'css' => __( 'Force load CSS (recommended)', 'all-in-one-video-gallery' ),
'js' => __( 'Force load JavaScript (advanced)', 'all-in-one-video-gallery' ),
),
'sanitize_callback' => 'aiovg_sanitize_array'
),
array(
'name' => 'lazyloading',
'label' => __( 'Lazyload Images / Videos', 'all-in-one-video-gallery' ),
'description' => __( 'Enable this option to lazy load images and videos added by the plugin to enhance page load speed and performance. If you experience any issues with content display, try disabling this option.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'statistics',
'label' => __( 'Track Video Views', 'all-in-one-video-gallery' ),
'description' => __( 'Track how many times visitors play your videos. View counts are displayed on gallery thumbnails and single video pages when enabled. Disable this if you do not need view statistics.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'datetime_format',
'label' => __( 'Date & Time Format', 'all-in-one-video-gallery' ),
'description' => sprintf(
'%s <a href="https://wordpress.org/documentation/article/customize-date-and-time-format/" target="_blank" rel="noopener noreferrer">%s</a><br />%s',
__( "Enter the PHP DateTime format that the plugin should use when displaying the dates on the site's front end.", 'all-in-one-video-gallery' ),
__( 'Documentation on date and time formatting.', 'all-in-one-video-gallery' ),
__( 'When left empty, the plugin will display a human-readable format such as "1 hour ago", "5 mins ago", and "2 days ago".', 'all-in-one-video-gallery' )
),
'placeholder' => 'F j, Y',
'type' => 'text',
'sanitize_callback' => 'sanitize_text_field'
),
array(
'name' => 'number_format',
'label' => __( 'Number Format', 'all-in-one-video-gallery' ),
'description' => __( 'Choose how to display large numbers when displaying views, likes, etc.', 'all-in-one-video-gallery' ),
'type' => 'select',
'options' => array(
'full' => __( 'Full Format (e.g., 1,200, 3,400,000)', 'all-in-one-video-gallery' ),
'short' => __( 'Short Format (e.g., 1.2K, 3.4M)', 'all-in-one-video-gallery' )
),
'default' => 'full',
'sanitize_callback' => 'sanitize_text_field'
),
array(
'name' => 'maybe_flush_rewrite_rules',
'label' => __( 'Auto Flush Rewrite Rules', 'all-in-one-video-gallery' ),
'description' => __( 'Enable this option to let the plugin automatically detect and refresh missing permalink rules when necessary. This setting is usually not required, as rewrite rules are refreshed when relevant plugin settings or assigned pages change. Disable this option if you experience frequent 404, 500, or performance-related issues.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'delete_plugin_data',
'label' => __( 'Remove Data on Uninstall', 'all-in-one-video-gallery' ),
'description' => __( 'Check this box to delete all of the plugin data (database stored content) when uninstalled', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'delete_media_files',
'label' => __( 'Delete Media Files on Delete', 'all-in-one-video-gallery' ),
'description' => __( 'Check this box to delete the associated media files when a video post or video category is deleted, including any files stored on Bunny Stream (if enabled).', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'custom_css',
'label' => __( 'Custom CSS', 'all-in-one-video-gallery' ),
'description' => __( 'Add your own CSS code to customize the appearance and style of the plugin elements. This allows you to tailor the design to match your site\'s theme seamlessly.', 'all-in-one-video-gallery' ),
'type' => 'textarea',
'sanitize_callback' => 'sanitize_textarea_field'
)
),
'aiovg_api_settings' => array(
array(
'name' => 'youtube_api_key',
'label' => __( 'YouTube API Key', 'all-in-one-video-gallery' ),
'description' => sprintf( __( 'Follow <a href="%s" target="_blank" rel="noopener noreferrer">this guide</a> to get your own API key.', 'all-in-one-video-gallery' ), 'https://plugins360.com/all-in-one-video-gallery/how-to-get-youtube-api-key/' ),
'type' => 'text',
'sanitize_callback' => 'sanitize_text_field'
),
array(
'name' => 'vimeo_access_token',
'label' => __( 'Vimeo Access Token', 'all-in-one-video-gallery' ),
'description' => sprintf( __( 'Follow <a href="%s" target="_blank" rel="noopener noreferrer">this guide</a> to get your own access token.', 'all-in-one-video-gallery' ), 'https://plugins360.com/all-in-one-video-gallery/how-to-get-vimeo-access-token/' ),
'type' => 'text',
'sanitize_callback' => 'sanitize_text_field'
)
),
'aiovg_page_settings' => array(
array(
'name' => 'category',
'label' => __( 'Single Category Page', 'all-in-one-video-gallery' ),
'description' => __( 'This is the page where the videos from a particular category is displayed. The [aiovg_category] short code must be on this page.', 'all-in-one-video-gallery' ),
'type' => 'pages',
'sanitize_callback' => 'sanitize_key'
),
array(
'name' => 'tag',
'label' => __( 'Single Tag Page', 'all-in-one-video-gallery' ),
'description' => __( 'This is the page where the videos from a particular tag is displayed. The [aiovg_tag] short code must be on this page.', 'all-in-one-video-gallery' ),
'type' => 'pages',
'sanitize_callback' => 'sanitize_key'
),
array(
'name' => 'search',
'label' => __( 'Search Page', 'all-in-one-video-gallery' ),
'description' => __( 'This is the page where the search results are displayed. The [aiovg_search] short code must be on this page.', 'all-in-one-video-gallery' ),
'type' => 'pages',
'sanitize_callback' => 'sanitize_key'
),
array(
'name' => 'user_videos',
'label' => __( 'User Videos Page', 'all-in-one-video-gallery' ),
'description' => __( 'This is the page where the videos from an user is displayed. The [aiovg_user_videos] short code must be on this page.', 'all-in-one-video-gallery' ),
'type' => 'pages',
'sanitize_callback' => 'sanitize_key'
),
array(
'name' => 'player',
'label' => __( 'Player Page', 'all-in-one-video-gallery' ),
'description' => __( 'This is the page used to show the video player.', 'all-in-one-video-gallery' ),
'type' => 'pages',
'sanitize_callback' => 'sanitize_key'
)
),
'aiovg_bunny_stream_settings' => array(
array(
'name' => 'enable_bunny_stream',
'label' => __( 'Enable Bunny Stream Hosting', 'all-in-one-video-gallery' ),
'description' => __( 'Enable this option to add a "Bunny Stream" upload button to the video forms under the "All Videos" menu. Videos uploaded through front-end forms will also be stored in Bunny Stream when this option is enabled.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'api_key',
'label' => __( 'API Key', 'all-in-one-video-gallery' ),
'description' => __( 'You can find this in your Bunny.net Dashboard under: <strong>Stream → Your Library → API</strong>.', 'all-in-one-video-gallery' ),
'type' => 'text',
'sanitize_callback' => 'sanitize_text_field'
),
array(
'name' => 'library_id',
'label' => __( 'Video Library ID', 'all-in-one-video-gallery' ),
'description' => __( 'You can find this in your Bunny.net Dashboard under: <strong>Stream → Your Library → API</strong>.', 'all-in-one-video-gallery' ),
'type' => 'text',
'sanitize_callback' => 'aiovg_sanitize_int'
),
array(
'name' => 'cdn_hostname',
'label' => __( 'CDN Hostname', 'all-in-one-video-gallery' ),
'description' => __( 'You can find this in your Bunny.net Dashboard under: <strong>Stream → Your Library → API</strong>.', 'all-in-one-video-gallery' ),
'type' => 'text',
'sanitize_callback' => 'sanitize_text_field'
),
array(
'name' => 'collection_id',
'label' => __( 'Collection ID', 'all-in-one-video-gallery' ),
'description' => __( 'Optional. You can find this in your Bunny.net Dashboard under: <strong>Stream → Your Library → Collections</strong>. Click the three dots over the thumbnail of a collection to view the ID.', 'all-in-one-video-gallery' ),
'type' => 'text',
'sanitize_callback' => 'sanitize_text_field'
),
array(
'name' => 'enable_token_authentication',
'label' => __( 'Enable Token Authentication', 'all-in-one-video-gallery' ),
'description' => __( 'Check this option if token authentication is enabled in your Bunny.net account. The plugin will automatically generate signed URLs for secure video playback.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'token_authentication_key',
'label' => __( 'Token Authentication Key', 'all-in-one-video-gallery' ),
'description' => __( 'You can find this in your Bunny.net Dashboard under: <strong>Stream → Your Library → Security</strong>.', 'all-in-one-video-gallery' ),
'type' => 'text',
'sanitize_callback' => 'sanitize_text_field'
),
array(
'name' => 'token_expiry',
'label' => __( 'Token Expiry (in seconds)', 'all-in-one-video-gallery' ),
'description' => __( 'Optional. Set how long signed URLs remain valid. Default is 3600 seconds (1 hour).', 'all-in-one-video-gallery' ),
'type' => 'text',
'sanitize_callback' => 'aiovg_sanitize_int'
)
)
);
if ( false !== get_option( 'aiovg_brand_settings' ) ) {
$fields['aiovg_brand_settings'] = array(
array(
'name' => 'show_logo',
'label' => __( 'Show Logo', 'all-in-one-video-gallery' ),
'description' => __( 'Check this option to show the watermark on the video.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'logo_image',
'label' => __( 'Logo Image', 'all-in-one-video-gallery' ),
'description' => __( 'Upload the image file of your logo. We recommend using the transparent PNG format with width below 100 pixels. If you do not enter any image, no logo will displayed.', 'all-in-one-video-gallery' ),
'type' => 'file',
'sanitize_callback' => 'aiovg_sanitize_url'
),
array(
'name' => 'logo_link',
'label' => __( 'Logo Link', 'all-in-one-video-gallery' ),
'description' => __( 'The URL to visit when the watermark image is clicked. Clicking a logo will have no affect unless this is configured.', 'all-in-one-video-gallery' ),
'type' => 'text',
'sanitize_callback' => 'aiovg_sanitize_url'
),
array(
'name' => 'logo_position',
'label' => __( 'Logo Position', 'all-in-one-video-gallery' ),
'description' => __( 'This sets the corner in which to display the watermark.', 'all-in-one-video-gallery' ),
'type' => 'select',
'options' => array(
'topleft' => __( 'Top Left', 'all-in-one-video-gallery' ),
'topright' => __( 'Top Right', 'all-in-one-video-gallery' ),
'bottomleft' => __( 'Bottom Left', 'all-in-one-video-gallery' ),
'bottomright' => __( 'Bottom Right', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'sanitize_key'
),
array(
'name' => 'logo_margin',
'label' => __( 'Logo Margin', 'all-in-one-video-gallery' ),
'description' => __( 'The distance, in pixels, of the logo from the edges of the display.', 'all-in-one-video-gallery' ),
'type' => 'text',
'sanitize_callback' => 'floatval'
),
array(
'name' => 'copyright_text',
'label' => __( 'Copyright Text', 'all-in-one-video-gallery' ),
'description' => __( 'Text that is shown when a user right-clicks the player with the mouse.', 'all-in-one-video-gallery' ),
'type' => 'text',
'sanitize_callback' => 'sanitize_text_field'
)
);
}
return apply_filters( 'aiovg_settings_fields', $fields );
}
/**
* Initialize and registers the settings sections and fields to WordPress.
*
* @since 1.0.0
*/
public function initialize_settings() {
// Register settings sections & fields
foreach ( $this->sections as $section ) {
$page_hook = isset( $section['page'] ) ? $section['page'] : $section['id'];
// Sections
if ( false === get_option( $section['id'] ) ) {
add_option( $section['id'] );
}
if ( isset( $section['description'] ) && ! empty( $section['description'] ) ) {
$callback = array( $this, 'settings_section_callback' );
} elseif ( isset( $section['callback'] ) ) {
$callback = $section['callback'];
} else {
$callback = null;
}
add_settings_section( $section['id'], $section['title'], $callback, $page_hook );
// Fields
$fields = $this->fields[ $section['id'] ];
foreach ( $fields as $option ) {
$name = $option['name'];
$type = isset( $option['type'] ) ? $option['type'] : 'text';
$label = isset( $option['label'] ) ? $option['label'] : '';
$callback = isset( $option['callback'] ) ? $option['callback'] : array( $this, 'callback_' . $type );
$args = array(
'id' => $name,
'class' => isset( $option['class'] ) ? $option['class'] : $name,
'label_for' => "{$section['id']}[{$name}]",
'description' => isset( $option['description'] ) ? $option['description'] : '',
'name' => $label,
'section' => $section['id'],
'size' => isset( $option['size'] ) ? $option['size'] : null,
'options' => isset( $option['options'] ) ? $option['options'] : '',
'sanitize_callback' => isset( $option['sanitize_callback'] ) ? $option['sanitize_callback'] : '',
'type' => $type,
'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : '',
'min' => isset( $option['min'] ) ? $option['min'] : '',
'max' => isset( $option['max'] ) ? $option['max'] : '',
'step' => isset( $option['step'] ) ? $option['step'] : ''
);
add_settings_field( "{$section['id']}[{$name}]", $label, $callback, $page_hook, $section['id'], $args );
}
// Creates our settings in the options table
register_setting( $page_hook, $section['id'], array( $this, 'sanitize_options' ) );
}
}
/**
* Displays a section description.
*
* @since 1.0.0
* @param array $args Settings section args.
*/
public function settings_section_callback( $args ) {
foreach ( $this->sections as $section ) {
if ( $section['id'] == $args['id'] ) {
printf( '<div class="inside"><em>%s</em></div>', $section['description'] );
break;
}
}
}
/**
* Displays a text field for a settings field.
*
* @since 1.0.0
* @param array $args Settings field args.
*/
public function callback_text( $args ) {
$value = esc_attr( $this->get_option( $args['id'], $args['section'], '' ) );
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular-text';
$type = isset( $args['type'] ) ? $args['type'] : 'text';
$placeholder = empty( $args['placeholder'] ) ? '' : ' placeholder="' . $args['placeholder'] . '"';
$html = sprintf( '<input type="%1$s" class="%2$s widefat" id="%3$s[%4$s]" name="%3$s[%4$s]" value="%5$s"%6$s/>', $type, $size, $args['section'], $args['id'], $value, $placeholder );
$html .= $this->get_field_description( $args );
echo $html;
}
/**
* Displays a url field for a settings field.
*
* @since 1.0.0
* @param array $args Settings field args.
*/
public function callback_url( $args ) {
$this->callback_text( $args );
}
/**
* Displays a number field for a settings field.
*
* @since 1.0.0
* @param array $args Settings field args.
*/
public function callback_number( $args ) {
$value = esc_attr( $this->get_option( $args['id'], $args['section'], 0 ) );
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular-text';
$type = isset( $args['type'] ) ? $args['type'] : 'number';
$placeholder = empty( $args['placeholder'] ) ? '' : ' placeholder="' . $args['placeholder'] . '"';
$min = empty( $args['min'] ) ? '' : ' min="' . $args['min'] . '"';
$max = empty( $args['max'] ) ? '' : ' max="' . $args['max'] . '"';
$step = empty( $args['max'] ) ? '' : ' step="' . $args['step'] . '"';
$html = sprintf( '<input type="%1$s" class="%2$s widefat" id="%3$s[%4$s]" name="%3$s[%4$s]" value="%5$s"%6$s%7$s%8$s%9$s/>', $type, $size, $args['section'], $args['id'], $value, $placeholder, $min, $max, $step );
$html .= $this->get_field_description( $args );
echo $html;
}
/**
* Displays a checkbox for a settings field.
*
* @since 1.0.0
* @param array $args Settings field args.
*/
public function callback_checkbox( $args ) {
$value = esc_attr( $this->get_option( $args['id'], $args['section'], 0 ) );
$html = '<fieldset>';
$html .= sprintf( '<label for="%1$s[%2$s]">', $args['section'], $args['id'] );
$html .= sprintf( '<input type="hidden" name="%1$s[%2$s]" value="0" />', $args['section'], $args['id'] );
$html .= sprintf( '<input type="checkbox" class="checkbox" id="%1$s[%2$s]" name="%1$s[%2$s]" value="1" %3$s />', $args['section'], $args['id'], checked( $value, 1, false ) );
$html .= sprintf( '%1$s</label>', $args['description'] );
$html .= '</fieldset>';
echo $html;
}
/**
* Displays a multicheckbox for a settings field.
*
* @since 1.0.0
* @param array $args Settings field args.
*/
public function callback_multicheck( $args ) {
$value = $this->get_option( $args['id'], $args['section'], array() );
$html = '<fieldset>';
$html .= sprintf( '<input type="hidden" name="%1$s[%2$s]" value="" />', $args['section'], $args['id'] );
foreach ( $args['options'] as $key => $label ) {
$checked = in_array( $key, $value ) ? 'checked="checked"' : '';
$html .= sprintf( '<label for="%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key );
$html .= sprintf( '<input type="checkbox" class="checkbox" id="%1$s[%2$s][%3$s]" name="%1$s[%2$s][%3$s]" value="%3$s" %4$s />', $args['section'], $args['id'], $key, $checked );
$html .= sprintf( '%1$s</label><br>', $label );
}
$html .= '</fieldset>';
$html .= $this->get_field_description( $args );
echo $html;
}
/**
* Displays a radio button for a settings field.
*
* @since 1.0.0
* @param array $args Settings field args.
*/
public function callback_radio( $args ) {
$value = $this->get_option( $args['id'], $args['section'], '' );
$html = '<fieldset>';
foreach ( $args['options'] as $key => $label ) {
$html .= sprintf( '<label for="%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key );
$html .= sprintf( '<input type="radio" class="radio" id="%1$s[%2$s][%3$s]" name="%1$s[%2$s]" value="%3$s" %4$s />', $args['section'], $args['id'], $key, checked( $value, $key, false ) );
$html .= sprintf( '%1$s</label><br>', $label );
}
$html .= $this->get_field_description( $args );
$html .= '</fieldset>';
echo $html;
}
/**
* Displays a selectbox for a settings field.
*
* @since 1.0.0
* @param array $args Settings field args.
*/
public function callback_select( $args ) {
$value = esc_attr( $this->get_option( $args['id'], $args['section'], '' ) );
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular-text';
$html = sprintf( '<select class="%1$s" name="%2$s[%3$s]" id="%2$s[%3$s]">', $size, $args['section'], $args['id'] );
foreach ( $args['options'] as $key => $label ) {
$html .= sprintf( '<option value="%s"%s>%s</option>', $key, selected( $value, $key, false ), $label );
}
$html .= sprintf( '</select>' );
$html .= $this->get_field_description( $args );
echo $html;
}
/**
* Displays a textarea for a settings field.
*
* @since 1.0.0
* @param array $args Settings field args.
*/
public function callback_textarea( $args ) {
$value = esc_textarea( $this->get_option( $args['id'], $args['section'], '' ) );
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular-text';
$placeholder = empty( $args['placeholder'] ) ? '' : ' placeholder="'.$args['placeholder'].'"';
$html = sprintf( '<textarea rows="5" cols="55" class="%1$s" id="%2$s[%3$s]" name="%2$s[%3$s]"%4$s>%5$s</textarea>', $size, $args['section'], $args['id'], $placeholder, $value );
$html .= $this->get_field_description( $args );
echo $html;
}
/**
* Displays the html for a settings field.
*
* @since 1.0.0
* @param array $args Settings field args.
*/
public function callback_html( $args ) {
echo $this->get_field_description( $args );
}
/**
* Displays a rich text textarea for a settings field.
*
* @since 1.0.0
* @param array $args Settings field args.
*/
public function callback_wysiwyg( $args ) {
$value = $this->get_option( $args['id'], $args['section'], '' );
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : '500px';
echo '<div style="max-width: ' . $size . ';">';
$editor_settings = array(
'teeny' => true,
'textarea_name' => $args['section'] . '[' . $args['id'] . ']',
'textarea_rows' => 10
);
if ( isset( $args['options'] ) && is_array( $args['options'] ) ) {
$editor_settings = array_merge( $editor_settings, $args['options'] );
}
wp_editor( $value, $args['section'] . '-' . $args['id'], $editor_settings );
echo '</div>';
echo $this->get_field_description( $args );
}
/**
* Displays a file upload field for a settings field.
*
* @since 1.0.0
* @param array $args Settings field args.
*/
public function callback_file( $args ) {
$value = esc_attr( $this->get_option( $args['id'], $args['section'], '' ) );
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular-text';
$id = $args['section'] . '[' . $args['id'] . ']';
$label = isset( $args['options']['button_label'] ) ? $args['options']['button_label'] : __( 'Choose File', 'all-in-one-video-gallery' );
$html = '<div class="aiovg-media-uploader"> ';
$html .= sprintf( '<input type="text" class="%1$s" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s"/>', $size, $args['section'], $args['id'], $value );
$html .= '<input type="button" class="aiovg-upload-media button" value="' . $label . '" />';
$html .= '</div> ';
$html .= $this->get_field_description( $args );
echo $html;
}
/**
* Displays a password field for a settings field.
*
* @since 1.0.0
* @param array $args Settings field args.
*/
public function callback_password( $args ) {
$value = esc_attr( $this->get_option( $args['id'], $args['section'], '' ) );
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular-text';
$html = sprintf( '<input type="password" class="%1$s" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s"/>', $size, $args['section'], $args['id'], $value );
$html .= $this->get_field_description( $args );
echo $html;
}
/**
* Displays a color picker field for a settings field.
*
* @since 1.0.0
* @param array $args Settings field args.
*/
public function callback_color( $args ) {
$value = esc_attr( $this->get_option( $args['id'], $args['section'], '#ffffff' ) );
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular-text';
$html = sprintf( '<input type="text" class="%1$s aiovg-color-picker" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s" data-default-color="%5$s" />', $size, $args['section'], $args['id'], $value, '#ffffff' );
$html .= $this->get_field_description( $args );
echo $html;
}
/**
* Displays a select box for creating the pages select box.
*
* @since 1.0.0
* @param array $args Settings field args.
*/
public function callback_pages( $args ) {
$dropdown_args = array(
'show_option_none' => '— ' . __( 'Select a page', 'all-in-one-video-gallery' ) . ' —',
'option_none_value' => -1,
'selected' => esc_attr( $this->get_option( $args['id'], $args['section'], -1 ) ),
'name' => $args['section'] . '[' . $args['id'] . ']',
'id' => $args['section'] . '[' . $args['id'] . ']',
'echo' => 0
);
$html = wp_dropdown_pages( $dropdown_args );
$html .= $this->get_field_description( $args );
echo $html;
}
/**
* Get field description for display.
*
* @since 1.0.0
* @param array $args Settings field args.
*/
public function get_field_description( $args ) {
if ( ! empty( $args['description'] ) ) {
$description = sprintf( '<p class="description">%s</p>', $args['description'] );
} else {
$description = '';
}
return $description;
}
/**
* Sanitize callback for Settings API.
*
* @since 1.0.0
* @param array $options The unsanitized collection of options.
* @return The collection of sanitized values.
*/
public function sanitize_options( $options ) {
if ( ! $options ) {
return $options;
}
foreach ( $options as $option_slug => $option_value ) {
$sanitize_callback = $this->get_sanitize_callback( $option_slug );
// If callback is set, call it
if ( $sanitize_callback ) {
$options[ $option_slug ] = call_user_func( $sanitize_callback, $option_value );
continue;
}
}
return $options;
}
/**
* Get sanitization callback for given option slug.
*
* @since 1.0.0
* @param string $slug Option slug.
* @return mixed String or bool false.
*/
public function get_sanitize_callback( $slug = '' ) {
if ( empty( $slug ) ) {
return false;
}
// Iterate over registered fields and see if we can find proper callback
foreach ( $this->fields as $section => $options ) {
foreach ( $options as $option ) {
if ( $option['name'] != $slug ) {
continue;
}
// Return the callback name
return isset( $option['sanitize_callback'] ) && is_callable( $option['sanitize_callback'] ) ? $option['sanitize_callback'] : false;
}
}
return false;
}
/**
* Get the value of a settings field.
*
* @since 1.0.0
* @param string $option Settings field name.
* @param string $section The section name this field belongs to.
* @param string $default Default text if it's not found.
* @return string
*/
public function get_option( $option, $section, $default = '' ) {
$options = get_option( $section );
if ( isset( $options[ $option ] ) ) {
return $options[ $option ];
}
return $default;
}
}