Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is a built-in function <a href="https://codex.wordpress.org/Function_Reference/wp_oembed_remove_provider" rel="nofollow"><code>wp_oembed_remove_provider</code></a>, respectively <a href="https://codex.wordpress.org/Function_Reference/wp_oembed_add_provider" rel="nofollow"><code>wp_oembed_add_provider</code></a>.</p> <p><strong>EDIT</strong></p> <p>add to functions.php file</p> <pre><code>function customize_oembed() { //load oembed class require_once ABSPATH . DIRECTORY_SEPARATOR . 'wp-includes' . DIRECTORY_SEPARATOR . 'class-oembed.php'; //get a singleton object $oembed = _wp_oembed_get_object(); /** * Forget about those lines * //empty the providers list $oembed-&gt;providers = array(); //add what you want wp_oembed_add_provider( 'http://site.com/watchvideo/*', 'http://site.com/oembedprovider' ); */ //use applying a filter $providers = array( 'youtube' =&gt; array( 'http://www.youtube.com/oembed', false), 'twitter'=&gt; array( 'http://api.twitter.com/1/statuses/oembed.{format}', true ) ); $oembed-&gt;providers = apply_filters('oembed_providers', $providers); } add_action('init', 'customize_oembed'); </code></pre> <p><strong>EDIT 2</strong></p> <p>I looked into it, and I found out, that you can use a filter <code>oembed_providers</code> exactly in the same way, as it is used in a constructor of the class. Therefore using additional wordpress functions, which would again try to require the class file and instantiate a singleton object, is useless, when you can do it in one function.</p> <p>(Despite of the fact, that it works, i still do not get a usage of this filter :-D)</p> <p><strong>EDIT 3</strong></p> <p>Finally, I got it working.</p> <p>It is really similar code to yours, though the argument in the function is basically useless. It only gives you original providers, which you want to override, so you are not using it and you can return an array directly.</p> <p>Maybe the important thing to remember is, after editing your list, you need to update your posts, since wordpress is saving some data into table <code>*_postmeta</code> under key <code>_oembed_…</code></p> <pre><code>function filter_oembed_provider_list( ) { return array( 'http://youtu.be/*' =&gt; array( 'http://www.youtube.com/oembed', false ) ); } add_filter( 'oembed_providers', 'filter_oembed_provider_list' ); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload