tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
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(
'general' => __( 'General', 'all-in-one-video-gallery' ),
'display' => __( 'Display', '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_general_settings',
'title' => __( 'General Settings', 'all-in-one-video-gallery' ),
'tab' => 'general'
),
array(
'id' => 'aiovg_player_settings',
'title' => __( 'Player Settings', 'all-in-one-video-gallery' ),
'tab' => 'general'
),
array(
'id' => 'aiovg_image_settings',
'title' => __( 'Image Settings', 'all-in-one-video-gallery' ),
'tab' => 'display'
),
array(
'id' => 'aiovg_categories_settings',
'title' => __( 'Categories Page', 'all-in-one-video-gallery' ),
'tab' => 'display'
),
array(
'id' => 'aiovg_videos_settings',
'title' => __( 'Video Gallery Pages', 'all-in-one-video-gallery' ),
'tab' => 'display'
),
array(
'id' => 'aiovg_video_settings',
'title' => __( 'Single Video Page', 'all-in-one-video-gallery' ),
'tab' => 'display'
),
array(
'id' => 'aiovg_permalink_settings',
'title' => __( 'Permalink Slugs', 'all-in-one-video-gallery' ),
'description' => __( 'NOTE: Just make sure that, after updating the fields in this section, you flush the rewrite rules by visiting "Settings > Permalinks". Otherwise you\'ll still see the old links.', 'all-in-one-video-gallery' ),
'tab' => 'advanced'
),
array(
'id' => 'aiovg_socialshare_settings',
'title' => __( 'Socialshare Buttons', 'all-in-one-video-gallery' ),
'description' => __( 'Select social share buttons displayed in the single video pages.', 'all-in-one-video-gallery' ),
'tab' => 'advanced'
),
array(
'id' => 'aiovg_page_settings',
'title' => __( 'Page Settings', 'all-in-one-video-gallery' ),
'tab' => 'advanced'
),
array(
'id' => 'aiovg_privacy_settings',
'title' => __( 'Privacy Settings', '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'
)
);
if ( false !== get_option( 'aiovg_brand_settings' ) ) {
$sections[] = array(
'id' => 'aiovg_brand_settings',
'title' => __( 'Logo & Branding', 'all-in-one-video-gallery' ),
'tab' => 'general'
);
}
return apply_filters( 'aiovg_settings_sections', $sections );
}
/**
* Get settings fields.
*
* @since 1.0.0
* @return array $fields Setting fields array.
*/
public function get_fields() {
$video_templates = aiovg_get_video_templates();
$fields = array(
'aiovg_general_settings' => array(
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?', 'all-in-one-video-gallery' ),
'description' => __( 'Check this box to also delete the associated media files when a video post or a video category is deleted', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
)
),
'aiovg_player_settings' => array(
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' => __( 'Ratio', 'all-in-one-video-gallery' ),
'description' => sprintf(
'%s
%s:
"56.25" - %s
"62.5" - %s
"75" - %s
"67" - %s
"100" - %s
"41.7" - %s',
__( "In percentage. 1 to 100. Calculate player's height using the ratio value entered.", 'all-in-one-video-gallery' ),
__( 'Examples', 'all-in-one-video-gallery' ),
__( 'Wide Screen TV', 'all-in-one-video-gallery' ),
__( 'Monitor Screens', 'all-in-one-video-gallery' ),
__( 'Classic TV', 'all-in-one-video-gallery' ),
__( 'Photo Camera', 'all-in-one-video-gallery' ),
__( 'Square', 'all-in-one-video-gallery' ),
__( 'Cinemascope', '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' => 'preload',
'label' => __( 'Preload', 'all-in-one-video-gallery' ),
'description' => sprintf(
'%s
%s
%s
%s',
__( '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' => 'controls',
'label' => __( 'Player Controls', 'all-in-one-video-gallery' ),
'description' => '',
'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' ),
'volume' => __( 'Volume', 'all-in-one-video-gallery' ),
'fullscreen' => __( 'Fullscreen', '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. 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' ),
'dailymotion' => __( 'Dailymotion', 'all-in-one-video-gallery' ),
'facebook' => __( 'Facebook', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'aiovg_sanitize_array'
)
),
'aiovg_image_settings' => array(
array(
'name' => 'width',
'label' => __( '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' => __( 'Ratio', 'all-in-one-video-gallery' ),
'description' => __( "In percentage. 1 to 100. Calculate images's height using the ratio value entered.", 'all-in-one-video-gallery' ),
'type' => 'text',
'sanitize_callback' => 'floatval'
),
),
'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' )
),
'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' => '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' )
),
'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'
)
),
'aiovg_videos_settings' => array(
array(
'name' => 'template',
'label' => __( 'Select Template', 'all-in-one-video-gallery' ),
'description' => ( aiovg_fs()->is_not_paying() ? sprintf( __( 'Upgrade Pro for more templates (Popup, Slider, etc.)', 'all-in-one-video-gallery' ), esc_url( aiovg_fs()->get_upgrade_url() ) ) : '' ),
'type' => 'select',
'options' => $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 Posted', 'all-in-one-video-gallery' ),
'views' => __( 'Views Count', 'all-in-one-video-gallery' ),
'rand' => __( 'Random', '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' => __( 'Thumbnail Style', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'select',
'options' => array(
'standard' => __( 'Image Top Aligned', 'all-in-one-video-gallery' ),
'image-left' => __( 'Image Left Aligned', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'sanitize_key'
),
array(
'name' => 'display',
'label' => __( 'Show / Hide', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'multicheck',
'options' => array(
'count' => __( 'Videos Count', 'all-in-one-video-gallery' ),
'category' => __( 'Category Name', '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' ),
'duration' => __( 'Video Duration', 'all-in-one-video-gallery' ),
'excerpt' => __( 'Video Excerpt', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'aiovg_sanitize_array'
),
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_video_settings' => array(
array(
'name' => 'display',
'label' => __( 'Show / Hide', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'multicheck',
'options' => array(
'category' => __( 'Category Name', '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' )
),
'sanitize_callback' => 'aiovg_sanitize_array'
),
array(
'name' => 'has_comments',
'label' => __( 'Enable Comments', 'all-in-one-video-gallery' ),
'description' => __( 'Allow visitors to comment videos using the standard WordPress comment form. Comments are public', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
)
),
'aiovg_permalink_settings' => array(
array(
'name' => 'video',
'label' => __( 'Video Detail Page', 'all-in-one-video-gallery' ),
'description' => __( 'Replaces the SLUG value used by custom post type "aiovg_videos".', 'all-in-one-video-gallery' ),
'type' => 'text',
'sanitize_callback' => 'sanitize_text_field'
)
),
'aiovg_socialshare_settings' => array(
array(
'name' => 'services',
'label' => __( 'Enable Services', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'multicheck',
'options' => array(
'facebook' => __( 'Facebook', 'all-in-one-video-gallery' ),
'twitter' => __( 'Twitter', 'all-in-one-video-gallery' ),
'gplus' => __( 'Google Plus', 'all-in-one-video-gallery' ),
'linkedin' => __( 'Linkedin', 'all-in-one-video-gallery' ),
'pinterest' => __( 'Pinterest', 'all-in-one-video-gallery' )
),
'sanitize_callback' => 'aiovg_sanitize_array'
)
),
'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' => '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_privacy_settings' => array(
array(
'name' => 'show_consent',
'label' => __( 'GDPR - Show Consent', 'all-in-one-video-gallery' ),
'description' => __( 'Ask for consent before loading YouTube / Vimeo content.', 'all-in-one-video-gallery' ),
'type' => 'checkbox',
'sanitize_callback' => 'intval'
),
array(
'name' => 'consent_message',
'label' => __( 'GDPR - Consent Message', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'wysiwyg',
'sanitize_callback' => 'wp_kses_post'
),
array(
'name' => 'consent_button_label',
'label' => __( 'GDPR - Consent Button Label', 'all-in-one-video-gallery' ),
'description' => '',
'type' => 'text',
'sanitize_callback' => 'sanitize_text_field'
)
)
);
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' => 'esc_url_raw'
),
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' => 'esc_url_raw'
),
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 = "aiovg_{$section['tab']}_settings";
// 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( '
%s
', $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 ( ! empty( $options[ $option ] ) ) { return $options[ $option ]; } return $default; } }