← Back
Editing: class-directorist-video-field.php
<?php /** * Directorist Video Field class. * */ namespace Directorist\Fields; if ( ! defined( 'ABSPATH' ) ) { exit; } class Video_Field extends Base_Field { public $type = 'video'; public function validate( $posted_data ) { $value = $this->get_value( $posted_data ); if ( ! directorist_is_contact_string( $value ) ) { $this->add_error( __( 'Invalid video URL.', 'directorist' ) ); return false; } if ( ! wp_http_validate_url( $value ) ) { $this->add_error( __( 'Invalid video URL.', 'directorist' ) ); } if ( ! directorist_validate_youtube_vimeo_url( $value ) ) { $this->add_error( __( 'Vimeo and Youtube video allowed only.', 'directorist' ) ); } if ( $this->has_error() ) { return false; } return true; } public function sanitize( $posted_data ) { $value = $this->get_value( $posted_data ); return directorist_is_contact_string( $value ) ? sanitize_url( $value ) : ''; } } Fields::register( new Video_Field() );
Save File
Cancel