Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) {
- $meta_boxes[] = [
- 'title' => 'Video',
- 'fields' => [
- [
- 'id' => 'video',
- 'type' => 'url',
- 'name' => 'Video URL',
- ],
- ],
- 'validation' => [
- 'rules' => [
- 'video' => [
- 'only_mp4' => true,
- ],
- ],
- ],
- 'message' => [
- 'video' => [
- 'only_mp4' => 'Only MP4 is allowed.',
- ],
- ],
- ];
- return $meta_boxes;
- } );
- add_action( 'admin_print_footer_scripts', function () {
- ?>
- <script>
- jQuery.validator.addMethod('only_mp4', function (value, element) {
- return /mp4$/.test(value);
- }, 'Please enter URL with suffix "mp4".');
- </script>
- <?php
- }, 99 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement