Advertisement
marstheme

Untitled

Jan 15th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.82 KB | None | 0 0
  1. if( ! function_exists( 'videotube_child_do_restrict_featured_tag' ) ){
  2.    
  3.     /**
  4.      * Filter the WP_error
  5.      * @param $errors
  6.      * @param $submit_data
  7.      */
  8.    
  9.     function videotube_child_do_restrict_featured_tag( $errors, $submit_data ) {
  10.        
  11.         // Change your featured tag name here.
  12.         $my_featured_tag_name   =   'featured';
  13.        
  14.         if( isset( $submit_data['video_tag'] ) ){
  15.    
  16.             $video_tags =   explode(",", $submit_data['video_tag'] );
  17.  
  18.             // Check if submitted data contains the featured tag.
  19.             if( array_search( $my_featured_tag_name, $video_tags ) !== false ){
  20.                
  21.                 // add an error if tag found.
  22.                 $errors->add( "video-tag", esc_html__( 'Sorry, you cannot enter the featured tag.' ));
  23.             }
  24.         }
  25.  
  26.         return $errors;
  27.     }
  28.    
  29.     add_filter( 'do_ajax_submit_video_errors' , 'videotube_child_do_restrict_featured_tag', 10, 2 );
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement