Advertisement
Guest User

Untitled

a guest
Apr 15th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) {
  2.     $meta_boxes[] = [
  3.         'title'      => 'Video',
  4.         'fields'     => [
  5.             [
  6.                 'id'   => 'video',
  7.                 'type' => 'url',
  8.                 'name' => 'Video URL',
  9.             ],
  10.         ],
  11.         'validation' => [
  12.             'rules' => [
  13.                 'video' => [
  14.                     'only_mp4' => true,
  15.                 ],
  16.             ],
  17.         ],
  18.         'message'    => [
  19.             'video' => [
  20.                 'only_mp4' => 'Only MP4 is allowed.',
  21.             ],
  22.         ],
  23.     ];
  24.     return $meta_boxes;
  25. } );
  26.  
  27. add_action( 'admin_print_footer_scripts', function () {
  28.     ?>
  29.     <script>
  30.         jQuery.validator.addMethod('only_mp4', function (value, element) {
  31.             return /mp4$/.test(value);
  32.         }, 'Please enter URL with suffix "mp4".');
  33.     </script>
  34.     <?php
  35. }, 99 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement