Skip to main content
added 164 characters in body
Source Link
birgire
  • 67.8k
  • 7
  • 119
  • 251

If you want exactly this shortcode:

[video height="300" width="300" mp4="localhost.com/video.mp4"]

to output nothing, then you can use the wp_video_shortcode_override filter or the wp_video_shortcode filter to achieve that.

Here are two such examples:

Example #1

/**
 * Let the [video] shortcode output "almost" nothing (just a single space) for specific attributes
 */
add_filter( 'wp_video_shortcode_override', function ( $output, $attr, $content, $instance )
{  
    // Match specific attributes and values
    if( 
          isset( $atts['height'] ) 
        && 300 == $atts['height'] 
        && isset( $atts['width'] ) 
        && 400 == $atts['width'] 
        && isset( $atts['mp4'] )
        && 'localhost.com/video.mp4' == $atts['mp4']   
    )
        $output = ' '; // Must not be empty to override the output

    return $output;
}, 10, 4 );

Example #2

/**
 * Let the [video] shortcode output nothing for specific attributes
 */
add_filter( 'wp_video_shortcode', function( $output, $atts, $video, $post_id, $library )
{
    // Match specific attributes and values
    if( 
          isset( $atts['height'] ) 
        && 300 == $atts['height'] 
        && isset( $atts['width'] ) 
        && 400 == $atts['width'] 
        && isset( $atts['mp4'] )
        && 'localhost.com/video.mp4' == $atts['mp4']   
    )
        $output = '';
  
    return $output;
}, 10, 5 );

Note

I would recommend the first example, because there we are intercepting it early on and don't need to run all the code within the shortcode callback.

If you want exactly this shortcode:

[video height="300" width="300" mp4="localhost.com/video.mp4"]

to output nothing, then you can use the wp_video_shortcode_override filter or the wp_video_shortcode filter to achieve that.

Here are two such examples:

Example #1

/**
 * Let the [video] shortcode output "almost" nothing (just a single space) for specific attributes
 */
add_filter( 'wp_video_shortcode_override', function ( $output, $attr, $content, $instance )
{  
    // Match specific attributes and values
    if( 
          isset( $atts['height'] ) 
        && 300 == $atts['height'] 
        && isset( $atts['width'] ) 
        && 400 == $atts['width'] 
        && isset( $atts['mp4'] )
        && 'localhost.com/video.mp4' == $atts['mp4']   
    )
        $output = ' '; // Must not be empty to override the output

    return $output;
}, 10, 4 );

Example #2

/**
 * Let the [video] shortcode output nothing for specific attributes
 */
add_filter( 'wp_video_shortcode', function( $output, $atts, $video, $post_id, $library )
{
    // Match specific attributes and values
    if( 
          isset( $atts['height'] ) 
        && 300 == $atts['height'] 
        && isset( $atts['width'] ) 
        && 400 == $atts['width'] 
        && isset( $atts['mp4'] )
        && 'localhost.com/video.mp4' == $atts['mp4']   
    )
        $output = '';
  
    return $output;
}, 10, 5 );

If you want exactly this shortcode:

[video height="300" width="300" mp4="localhost.com/video.mp4"]

to output nothing, then you can use the wp_video_shortcode_override filter or the wp_video_shortcode filter to achieve that.

Here are two such examples:

Example #1

/**
 * Let the [video] shortcode output "almost" nothing (just a single space) for specific attributes
 */
add_filter( 'wp_video_shortcode_override', function ( $output, $attr, $content, $instance )
{  
    // Match specific attributes and values
    if( 
          isset( $atts['height'] ) 
        && 300 == $atts['height'] 
        && isset( $atts['width'] ) 
        && 400 == $atts['width'] 
        && isset( $atts['mp4'] )
        && 'localhost.com/video.mp4' == $atts['mp4']   
    )
        $output = ' '; // Must not be empty to override the output

    return $output;
}, 10, 4 );

Example #2

/**
 * Let the [video] shortcode output nothing for specific attributes
 */
add_filter( 'wp_video_shortcode', function( $output, $atts, $video, $post_id, $library )
{
    // Match specific attributes and values
    if( 
          isset( $atts['height'] ) 
        && 300 == $atts['height'] 
        && isset( $atts['width'] ) 
        && 400 == $atts['width'] 
        && isset( $atts['mp4'] )
        && 'localhost.com/video.mp4' == $atts['mp4']   
    )
        $output = '';
  
    return $output;
}, 10, 5 );

Note

I would recommend the first example, because there we are intercepting it early on and don't need to run all the code within the shortcode callback.

deleted 19 characters in body
Source Link
birgire
  • 67.8k
  • 7
  • 119
  • 251

If you want exactly this shortcode:

[video height="300" width="300" mp4="localhost.com/video.mp4"]

to output nothing, then you can use the wp_video_shortcode_override filter or the wp_video_shortcode filter to achieve that.

Here are two such examples:

Example #1

/**
 * Let the [video] shortcode output "almost" nothing (just a single space) for specific attributes
 */
add_filter( 'wp_video_shortcode_override', function ( $output, $attr, $content, $instance )
{  
    // Match specific attributes and values
    if( 
          isset( $atts['height'] ) 
        && 300 == $atts['height'] 
        && isset( $atts['width'] ) 
        && 400 == $atts['width'] 
        && isset( $atts['mp4'] )
        && 'localhost.com/video.mp4' == $atts['mp4']   
    )
        $output = ' '; // Must not be empty to override the output

    return $output;
}, 10, 4 );

You can also use the wp_video_shortcode filter.

Example #2

/**
 * Let the [video] shortcode output nothing for specific attributes
 */
add_filter( 'wp_video_shortcode', function( $output, $atts, $video, $post_id, $library )
{
    // Match specific attributes and values
    if( 
          isset( $atts['height'] ) 
        && 300 == $atts['height'] 
        && isset( $atts['width'] ) 
        && 400 == $atts['width'] 
        && isset( $atts['mp4'] )
        && 'localhost.com/video.mp4' == $atts['mp4']   
    )
        $output = '';
  
    return $output;
}, 10, 5 );

If you want exactly this shortcode:

[video height="300" width="300" mp4="localhost.com/video.mp4"]

to output nothing, then you can use the wp_video_shortcode_override filter or the wp_video_shortcode filter to achieve that.

Example #1

/**
 * Let the [video] shortcode output "almost" nothing (just a single space) for specific attributes
 */
add_filter( 'wp_video_shortcode_override', function ( $output, $attr, $content, $instance )
{  
    // Match specific attributes and values
    if( 
          isset( $atts['height'] ) 
        && 300 == $atts['height'] 
        && isset( $atts['width'] ) 
        && 400 == $atts['width'] 
        && isset( $atts['mp4'] )
        && 'localhost.com/video.mp4' == $atts['mp4']   
    )
        $output = ' '; // Must not be empty to override the output

    return $output;
}, 10, 4 );

You can also use the wp_video_shortcode filter.

Example #2

/**
 * Let the [video] shortcode output nothing for specific attributes
 */
add_filter( 'wp_video_shortcode', function( $output, $atts, $video, $post_id, $library )
{
    // Match specific attributes and values
    if( 
          isset( $atts['height'] ) 
        && 300 == $atts['height'] 
        && isset( $atts['width'] ) 
        && 400 == $atts['width'] 
        && isset( $atts['mp4'] )
        && 'localhost.com/video.mp4' == $atts['mp4']   
    )
        $output = '';
  
    return $output;
}, 10, 5 );

If you want exactly this shortcode:

[video height="300" width="300" mp4="localhost.com/video.mp4"]

to output nothing, then you can use the wp_video_shortcode_override filter or the wp_video_shortcode filter to achieve that.

Here are two such examples:

Example #1

/**
 * Let the [video] shortcode output "almost" nothing (just a single space) for specific attributes
 */
add_filter( 'wp_video_shortcode_override', function ( $output, $attr, $content, $instance )
{  
    // Match specific attributes and values
    if( 
          isset( $atts['height'] ) 
        && 300 == $atts['height'] 
        && isset( $atts['width'] ) 
        && 400 == $atts['width'] 
        && isset( $atts['mp4'] )
        && 'localhost.com/video.mp4' == $atts['mp4']   
    )
        $output = ' '; // Must not be empty to override the output

    return $output;
}, 10, 4 );

Example #2

/**
 * Let the [video] shortcode output nothing for specific attributes
 */
add_filter( 'wp_video_shortcode', function( $output, $atts, $video, $post_id, $library )
{
    // Match specific attributes and values
    if( 
          isset( $atts['height'] ) 
        && 300 == $atts['height'] 
        && isset( $atts['width'] ) 
        && 400 == $atts['width'] 
        && isset( $atts['mp4'] )
        && 'localhost.com/video.mp4' == $atts['mp4']   
    )
        $output = '';
  
    return $output;
}, 10, 5 );
added 312 characters in body
Source Link
birgire
  • 67.8k
  • 7
  • 119
  • 251

If you want exactly this shortcode:

[video height="300" width="300" mp4="localhost.com/video.mp4"]

to output nothing for specific attributes, then you can use the wp_video_shortcode_override filter or the wp_video_shortcode filter to achieve that.

Example:

Example #1

/**
 * Let the [video] shortcode output "almost" nothing (just a single space) for specific attributes
 */
add_filter( 'wp_video_shortcode_override', function ( $output, $attr, $content, $instance )
{  
    // Match specific attributes and values
    if( 
          isset( $atts['height'] ) 
        && 300 == $atts['height'] 
        && isset( $atts['width'] ) 
        && 400 == $atts['width'] 
        && isset( $atts['mp4'] )
        && 'localhost.com/video.mp4' == $atts['mp4']   
    )
        $output = ' '; // Must not be empty output to override itthe output

    return $output;
}, 10, 4 );

You can also use the wp_video_shortcode filter.

Example:

Example #2

/**
 * Let the [video] shortcode output nothing for specific attributes
 */
add_filter( 'wp_video_shortcode', function( $output, $atts, $video, $post_id, $library )
{
    // Match specific attributes and values
    if( 
          isset( $atts['height'] ) 
        && 300 == $atts['height'] 
        && isset( $atts['width'] ) 
        && 400 == $atts['width'] 
        && isset( $atts['mp4'] )
        && 'localhost.com/video.mp4' == $atts['mp4']   
    )
        $output = '';
  
    return $output;
}, 10, 5 );

If you want this shortcode:

[video height="300" width="300" mp4="localhost.com/video.mp4"]

to output nothing for specific attributes, then you can use wp_video_shortcode_override filter.

Example:

add_filter( 'wp_video_shortcode_override', function ( $output, $attr, $content, $instance )
{  
    if( 
          isset( $atts['height'] ) 
        && 300 == $atts['height'] 
        && isset( $atts['width'] ) 
        && 400 == $atts['width'] 
        && isset( $atts['mp4'] )
        && 'localhost.com/video.mp4' == $atts['mp4']   
    )
        $output = ' '; // Must not be empty output to override it

    return $output;
}, 10, 4 );

You can also use the wp_video_shortcode filter.

Example:

add_filter( 'wp_video_shortcode', function( $output, $atts, $video, $post_id, $library )
{
    if( 
          isset( $atts['height'] ) 
        && 300 == $atts['height'] 
        && isset( $atts['width'] ) 
        && 400 == $atts['width'] 
        && isset( $atts['mp4'] )
        && 'localhost.com/video.mp4' == $atts['mp4']   
    )
        $output = '';
  
    return $output;
}, 10, 5 );

If you want exactly this shortcode:

[video height="300" width="300" mp4="localhost.com/video.mp4"]

to output nothing, then you can use the wp_video_shortcode_override filter or the wp_video_shortcode filter to achieve that.

Example #1

/**
 * Let the [video] shortcode output "almost" nothing (just a single space) for specific attributes
 */
add_filter( 'wp_video_shortcode_override', function ( $output, $attr, $content, $instance )
{  
    // Match specific attributes and values
    if( 
          isset( $atts['height'] ) 
        && 300 == $atts['height'] 
        && isset( $atts['width'] ) 
        && 400 == $atts['width'] 
        && isset( $atts['mp4'] )
        && 'localhost.com/video.mp4' == $atts['mp4']   
    )
        $output = ' '; // Must not be empty to override the output

    return $output;
}, 10, 4 );

You can also use the wp_video_shortcode filter.

Example #2

/**
 * Let the [video] shortcode output nothing for specific attributes
 */
add_filter( 'wp_video_shortcode', function( $output, $atts, $video, $post_id, $library )
{
    // Match specific attributes and values
    if( 
          isset( $atts['height'] ) 
        && 300 == $atts['height'] 
        && isset( $atts['width'] ) 
        && 400 == $atts['width'] 
        && isset( $atts['mp4'] )
        && 'localhost.com/video.mp4' == $atts['mp4']   
    )
        $output = '';
  
    return $output;
}, 10, 5 );
Source Link
birgire
  • 67.8k
  • 7
  • 119
  • 251
Loading