├── .editorconfig ├── .gitignore ├── .scrutinizer.yml ├── .travis.yml ├── CONTRIBUTING.md ├── Gruntfile.js ├── README.md ├── bin └── install-wp-tests.sh ├── composer.json ├── grunt ├── aliases.yaml ├── checktextdomain.js ├── makepot.js ├── phpcpd.js ├── phpcs.js ├── phpmd.js ├── phpunit.js └── watch.js ├── includes ├── class-wp-oembed-controller.php ├── class-wp-rest-oembed-controller.php ├── default-filters.php ├── functions.php └── template.php ├── languages ├── oembed-api-ar.mo ├── oembed-api-ar.po ├── oembed-api-ary.mo ├── oembed-api-ary.po ├── oembed-api-da_DK.mo ├── oembed-api-da_DK.po ├── oembed-api-de_CH.mo ├── oembed-api-de_CH.po ├── oembed-api-de_DE.mo ├── oembed-api-de_DE.po ├── oembed-api-el.mo ├── oembed-api-el.po ├── oembed-api-en_AU.mo ├── oembed-api-en_AU.po ├── oembed-api-es_ES.mo ├── oembed-api-es_ES.po ├── oembed-api-fi.mo ├── oembed-api-fi.po ├── oembed-api-fr_FR.mo ├── oembed-api-fr_FR.po ├── oembed-api-he_IL.mo ├── oembed-api-he_IL.po ├── oembed-api-it_IT.mo ├── oembed-api-it_IT.po ├── oembed-api-ja.mo ├── oembed-api-ja.po └── oembed-api.pot ├── license.txt ├── package.json ├── phpcs.ruleset.xml ├── phpunit.multisite.xml ├── phpunit.xml ├── scripts ├── frontend.js └── tinymce-plugin.js ├── tests ├── bootstrap.php ├── test-frontend.php ├── test-headers.php ├── test-plugin.php ├── test-wp-oembed-controller.php └── test-wp-rest-oembed-controller.php └── wp-api-oembed.php /.editorconfig: -------------------------------------------------------------------------------- 1 | # This file is for unifying the coding style for different editors and IDEs 2 | # editorconfig.org 3 | 4 | # WordPress Coding Standards 5 | # http://make.wordpress.org/core/handbook/coding-standards/ 6 | 7 | root = true 8 | 9 | [*] 10 | charset = utf-8 11 | end_of_line = lf 12 | insert_final_newline = true 13 | trim_trailing_whitespace = true 14 | indent_style = tab 15 | 16 | [{.jshintrc,*.json,*.yml}] 17 | indent_style = space 18 | indent_size = 2 19 | 20 | [{*.txt,wp-config-sample.php}] 21 | end_of_line = crlf 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # General 2 | .DS_Store 3 | composer.lock 4 | 5 | # npm 6 | /node_modules 7 | 8 | # Release task 9 | /release 10 | 11 | # Build files 12 | /js/*.js 13 | /js/*.map 14 | /css/*.css 15 | /css/*.map 16 | 17 | # Sass 18 | .sass-cache 19 | 20 | # Vendor (e.g. Composer) 21 | vendor/* 22 | !vendor/.gitkeep 23 | -------------------------------------------------------------------------------- /.scrutinizer.yml: -------------------------------------------------------------------------------- 1 | # Scrutinizer Configuration File 2 | 3 | tools: 4 | external_code_coverage: false 5 | 6 | php_sim: 7 | enabled: true 8 | min_mass: 50 9 | 10 | php_pdepend: 11 | enabled: true 12 | configuration_file: null 13 | suffixes: 14 | - php 15 | excluded_dirs: { } 16 | 17 | php_analyzer: 18 | enabled: true 19 | extensions: 20 | - php 21 | dependency_paths: { } 22 | path_configs: { } 23 | 24 | php_changetracking: 25 | enabled: true 26 | bug_patterns: 27 | - '\bfix(?:es|ed)?\b' 28 | feature_patterns: 29 | - '\badd(?:s|ed)?\b' 30 | - '\bimplement(?:s|ed)?\b' 31 | 32 | php_hhvm: 33 | enabled: true 34 | command: hhvm 35 | extensions: 36 | - php 37 | path_configs: { } 38 | 39 | before_commands: { } 40 | after_commands: { } 41 | artifacts: { } 42 | build_failure_conditions: { } 43 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 5.2 5 | - 5.3 6 | - 5.4 7 | - 5.5 8 | - 5.6 9 | - 7.0 10 | - hhvm 11 | 12 | matrix: 13 | allow_failures: 14 | - php: hhvm 15 | 16 | env: 17 | - WP_VERSION=nightly WP_MULTISITE=0 18 | - WP_VERSION=nightly WP_MULTISITE=1 19 | 20 | # Clones WordPress and configures our testing environment. 21 | before_script: 22 | # Setup Coveralls 23 | - phpenv local 5.5 24 | - composer install --no-interaction 25 | - phpenv local --unset 26 | 27 | - npm install 28 | 29 | - bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 $WP_VERSION 30 | 31 | script: 32 | - grunt checktextdomain 33 | - if [[ ${TRAVIS_PHP_VERSION:0:3} != "5.2" ]]; then vendor/bin/phpmd includes text codesize,naming,unusedcode; fi 34 | - if [[ ${TRAVIS_PHP_VERSION:0:3} != "5.2" ]]; then vendor/bin/phpcpd -n includes; fi 35 | - vendor/bin/phpcs -n --report=emacs --standard=phpcs.ruleset.xml includes 36 | - phpunit --coverage-clover build/logs/clover.xml 37 | 38 | after_script: 39 | # Push coverage off to Codecov 40 | - bash <(curl -s https://codecov.io/bash) 41 | - vendor/bin/test-reporter 42 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to oEmbed API 2 | 3 | ## Slack 4 | 5 | Discussions happen in the [#feature-oembed](https://wordpress.slack.com/messages/feature-oembed/) WordPress Slack channel. 6 | 7 | ## Pull Requests 8 | 9 | Code is developed on feature branches. Pull requests are where we discuss the development in progress, and determine whether a given feature branch is ready for merging to master. 10 | 11 | Please create your pull request as soon as you start work on a branch. If you are working on the pull request, assign it to yourself. If you’re want feedback from someone else, assign the pull request to them. 12 | 13 | Remember to check your diff regularly to make sure you’re only changing code you expect to be. 14 | 15 | When creating a branch, please use the following naming structure: (number of original Github issue)-followed-by-keywords-describing-the-project. 16 | 17 | When creating a pull request, please use a clear title and reference the issue in the pull request description. 18 | 19 | Hat tip to Fusion for [this text](https://github.com/fusioneng/tech-docs/blob/master/tools/github.md#pull-requests). 20 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function (grunt) { 2 | 3 | // measures the time each task takes 4 | require('time-grunt')(grunt); 5 | 6 | // load grunt config 7 | require('load-grunt-config')(grunt); 8 | 9 | // PHPUnit test task. 10 | grunt.registerMultiTask( 'phpcs', 'Runs PHPCS tests.', function() { 11 | grunt.util.spawn( { 12 | cmd: this.data.cmd, 13 | args: this.data.args, 14 | opts: { stdio: 'inherit' } 15 | }, this.async() ); 16 | } ); 17 | 18 | // PHPUnit test task. 19 | grunt.registerMultiTask( 'phpcpd', 'Runs PHPCPD tests.', function() { 20 | grunt.util.spawn( { 21 | cmd: this.data.cmd, 22 | args: this.data.args, 23 | opts: { stdio: 'inherit' } 24 | }, this.async() ); 25 | } ); 26 | 27 | // PHPUnit test task. 28 | grunt.registerMultiTask( 'phpmd', 'Runs PHPMD tests.', function() { 29 | grunt.util.spawn( { 30 | cmd: this.data.cmd, 31 | args: this.data.args, 32 | opts: { stdio: 'inherit' } 33 | }, this.async() ); 34 | } ); 35 | 36 | // PHPUnit test task. 37 | grunt.registerMultiTask( 'phpunit', 'Runs PHPUnit tests.', function() { 38 | grunt.util.spawn( { 39 | cmd: this.data.cmd, 40 | args: this.data.args, 41 | opts: { stdio: 'inherit' } 42 | }, this.async() ); 43 | } ); 44 | }; 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # oEmbed API # 2 | Contributors: swissspidy, pento 3 | Donate link: 4 | Tags: oembed, api 5 | Requires at least: 4.1 6 | Tested up to: 4.4-trunk 7 | Stable tag: trunk 8 | License: GPLv2 or later 9 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 | 11 | Allow others to easily embed your blog posts on their sites using oEmbed. 12 | 13 | ## Description ## 14 | 15 | It’s pretty easy to embed YouTube videos or tweets in WordPress. Just paste the URL to the content on a new line and you automagically get a preview of the embed. 16 | 17 | We wondered why this doesn’t also work with WordPress blogs and created this little plugin here. 18 | 19 | This plugin makes WordPress an oEmbed provider, which means you can easily embed your blog posts somewhere else. Even on your own website! 20 | 21 | The beautiful embeds contain a short summary of the post and (if available) also its featured image. 22 | 23 | Everything is easily extensible. You can completely change the look and feel of the embedded content. 24 | 25 | **Note:** We are working on bringing this functionality to WordPress core at one point. See WordPress Core ticket [\#32522](https://core.trac.wordpress.org/ticket/32522) for more details. 26 | 27 | **Get Involved** 28 | 29 | We hold weekly chats about this plugin in the \#feature-oembed WordPress Slack channel. Read the [announcement post](http://make.wordpress.org/core/2015/07/17/oembed-feature-plugin/) for more information. 30 | 31 | You can also join the discussion on [Trac](https://core.trac.wordpress.org/ticket/32522) and submit pull requests on [GitHub](https://github.com/swissspidy/oEmbed-API). 32 | 33 | [![Build Status](https://travis-ci.org/swissspidy/oEmbed-API.svg?branch=master)](https://travis-ci.org/swissspidy/oEmbed-API) 34 | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/swissspidy/oEmbed-API/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/swissspidy/oEmbed-API/?branch=master) 35 | [![Code Climate](https://codeclimate.com/github/swissspidy/oEmbed-API/badges/gpa.svg)](https://codeclimate.com/github/swissspidy/oEmbed-API) 36 | [![Codecov Code Coverage](https://codecov.io/github/swissspidy/oEmbed-API/coverage.svg?branch=master)](https://codecov.io/github/swissspidy/oEmbed-API/?branch=master) 37 | 38 | ## Installation ## 39 | 40 | ### Manual Installation ### 41 | 42 | 1. Upload the entire `/oembed-api` directory to the `/wp-content/plugins/` directory. 43 | 2. Activate oEmbed API through the 'Plugins' menu in WordPress. 44 | 3. Copy the permalink of one of your blog posts and paste it into a new post. It should automatically be embedded. 45 | 46 | ## Frequently Asked Questions ## 47 | 48 | ### Is the REST API required for this plugin to work? ### 49 | 50 | While we support the REST API, it is not required for this plugin to run. The only thing you need is an up-to-date version of WordPress. 51 | 52 | ### How does it work again? ### 53 | 54 | We leverage a technique called oEmbed. Thanks to oEmbed, you can embed content from the web by only knowing its URL. While WordPress has supported this feature since version 2.9, it actually isn’t an oEmbed provider itself. That’s what we’re changing. 55 | 56 | This plugin is fully compliant with the JSON specification at [oEmbed.com](http://oembed.com). 57 | 58 | ### Is it really that easy? ### 59 | 60 | Yes. 61 | 62 | ### How can I replace the blue WordPress logo in my embeds? ### 63 | 64 | The WordPress logo is displayed when there’s no site icon available. Site icons represent your site in browser tabs, bookmark menus, and on the home screen of mobile devices. Add your unique site icon in the Customizer and it will be used in the embed too. 65 | 66 | ### Why can’t I embed site XY? ### 67 | 68 | The oEmbed API plugin needs to run on both sites so the embedded site serves the right HTML and that your site knows how to embed it. 69 | 70 | ### Why is my embedded site not showing? ### 71 | 72 | When you get an empty preview, it’s possible that the embedded site has the `X-Frame-Options` header set. This prevents loading the site in an iframe for security reasons. 73 | 74 | ### How can I disable the oEmbed API? ### 75 | 76 | See the 'Other Notes' section for that. 77 | 78 | ## Screenshots ## 79 | 80 | 1. Example of how embedding a WordPress post looks like. 81 | 2. Example of a post with a featured image 82 | 3. You can easily copy the sharing URL for any post. 83 | 84 | ## Developer Reference ## 85 | 86 | There are some handy functions developer can use with this plugin. 87 | 88 | For example, `get_post_embed_url` returns the URL to a post’s embed template used for the iframe, while `get_post_embed_html` returns the `', 142 | esc_url( $embed_url ), 143 | absint( $width ), 144 | absint( $height ), 145 | esc_attr__( 'Embedded WordPress Post', 'oembed-api' ) 146 | ); 147 | 148 | /** 149 | * Filters the oEmbed HTML output. 150 | * 151 | * @since 4.4.0 152 | * 153 | * @param string $output The default HTML. 154 | * @param WP_Post $post Current post object. 155 | * @param int $width Width of the response. 156 | * @param int $height Height of the response. 157 | */ 158 | return apply_filters( 'oembed_html', $output, $post, $width, $height ); 159 | } 160 | 161 | /** 162 | * Get the oEmbed response data for a given post. 163 | * 164 | * @since 4.4.0 165 | * 166 | * @param WP_Post|int $post Optional. Post object or ID. Default is global `$post`. 167 | * @param int $width The requested width. 168 | * @return array|false Response data on success, false if post doesn't exist. 169 | */ 170 | function get_oembed_response_data( $post = null, $width ) { 171 | $post = get_post( $post ); 172 | 173 | if ( ! $post ) { 174 | return false; 175 | } 176 | 177 | if ( 'publish' !== get_post_status( $post ) ) { 178 | return false; 179 | } 180 | 181 | /** 182 | * Filter the allowed minimum width for the oEmbed response. 183 | * 184 | * @param int $width The minimum width. Defaults to 200. 185 | */ 186 | $minwidth = apply_filters( 'oembed_minwidth', 200 ); 187 | 188 | /** 189 | * Filter the allowed maximum width for the oEmbed response. 190 | * 191 | * @param int $width The maximum width. Defaults to 600. 192 | */ 193 | $maxwidth = apply_filters( 'oembed_maxwidth', 600 ); 194 | 195 | if ( $width < $minwidth ) { 196 | $width = $minwidth; 197 | } else if ( $width > $maxwidth ) { 198 | $width = $maxwidth; 199 | } 200 | 201 | $height = ceil( $width / 16 * 9 ); 202 | 203 | if ( 200 > $height ) { 204 | $height = 200; 205 | } 206 | 207 | $data = array( 208 | 'version' => '1.0', 209 | 'provider_name' => get_bloginfo( 'name' ), 210 | 'provider_url' => get_home_url(), 211 | 'author_name' => get_bloginfo( 'name' ), 212 | 'author_url' => get_home_url(), 213 | 'title' => $post->post_title, 214 | 'type' => 'link', 215 | ); 216 | 217 | $author = get_userdata( $post->post_author ); 218 | 219 | if ( $author ) { 220 | $data['author_name'] = $author->display_name; 221 | $data['author_url'] = get_author_posts_url( $author->ID ); 222 | } 223 | 224 | /** 225 | * Filter the oEmbed response data. 226 | * 227 | * @since 4.4.0 228 | * 229 | * @param array $data The response data. 230 | * @param WP_Post $post The post object. 231 | * @param int $width The requested width. 232 | * @param int $height The calculated height. 233 | */ 234 | return apply_filters( 'oembed_response_data', $data, $post, $width, $height ); 235 | } 236 | 237 | /** 238 | * Filters the oEmbed response data to return an iframe embed code. 239 | * 240 | * @since 4.4.0 241 | * 242 | * @param array $data The response data. 243 | * @param WP_Post $post The post object. 244 | * @param int $width The requested width. 245 | * @param int $height The calculated height. 246 | * @return array The modified response data. 247 | */ 248 | function get_oembed_response_data_rich( $data, $post, $width, $height ) { 249 | $data['width'] = absint( $width ); 250 | $data['height'] = absint( $height ); 251 | $data['type'] = 'rich'; 252 | $data['html'] = get_post_embed_html( $post, $width, $height ); 253 | 254 | // Add post thumbnail to response if available. 255 | $thumbnail_id = false; 256 | 257 | if ( has_post_thumbnail( $post->ID ) ) { 258 | $thumbnail_id = get_post_thumbnail_id( $post->ID ); 259 | } 260 | 261 | if ( 'attachment' === get_post_type( $post ) ) { 262 | if ( wp_attachment_is_image( $post ) ) { 263 | $thumbnail_id = $post->ID; 264 | } else if ( wp_attachment_is( 'video', $post ) ) { 265 | $thumbnail_id = get_post_thumbnail_id( $post ); 266 | $data['type'] = 'video'; 267 | } 268 | } 269 | 270 | if ( $thumbnail_id ) { 271 | list( $thumbnail_url, $thumbnail_width, $thumbnail_height ) = wp_get_attachment_image_src( $thumbnail_id, array( $width, 99999 ) ); 272 | $data['thumbnail_url'] = $thumbnail_url; 273 | $data['thumbnail_width'] = $thumbnail_width; 274 | $data['thumbnail_height'] = $thumbnail_height; 275 | } 276 | 277 | return $data; 278 | } 279 | 280 | /** 281 | * Load the plugin textdomain. 282 | * 283 | * @codeCoverageIgnore 284 | */ 285 | function wp_oembed_load_textdomain() { 286 | load_plugin_textdomain( 'oembed-api', false, basename( dirname( plugin_dir_path( __FILE__ ) ) ) . '/languages' ); 287 | } 288 | 289 | /** 290 | * Register our scripts. 291 | */ 292 | function wp_oembed_register_scripts() { 293 | wp_register_script( 'wp-oembed', plugin_dir_url( dirname( __FILE__ ) ) . 'scripts/frontend.js', array(), '0.9.0-' . date( 'Ymd' ) ); 294 | } 295 | 296 | /** 297 | * Register our TinyMCE plugin. 298 | * 299 | * @param array $plugins List of current TinyMCE plugins. 300 | * @return array The modified list of TinyMCE plugins. 301 | */ 302 | function wp_oembed_add_mce_plugin( $plugins ) { 303 | $plugins['wp-oembed'] = plugins_url( 'scripts/tinymce-plugin.js', dirname( __FILE__ ) ); 304 | 305 | return $plugins; 306 | } 307 | 308 | /** 309 | * Load the resize script in the main window when TinyMCE is loaded, so that the 310 | * embed popup can also resize the iframe correctly. 311 | * 312 | * @param array $opts TinyMCE options. 313 | */ 314 | function wp_oembed_load_mce_script( $opts ) { 315 | if ( array_key_exists( 'tinymce', $opts ) && $opts['tinymce'] ) { 316 | wp_enqueue_script( 'wp-oembed' ); 317 | } 318 | } 319 | 320 | /** 321 | * Ensures that the specified format is either 'json' or 'xml'. 322 | * 323 | * @since 4.4.0 324 | * 325 | * @param string $format The oEmbed response format. Accepts 'json', 'xml'. 326 | * @return string The format, either 'xml' or 'json'. Default 'json'. 327 | */ 328 | function wp_oembed_ensure_format( $format ) { 329 | if ( ! in_array( $format, array( 'json', 'xml' ), true ) ) { 330 | return 'json'; 331 | } 332 | 333 | return $format; 334 | } 335 | 336 | /** 337 | * Hooks into the REST API output to print XML instead of JSON. 338 | * 339 | * @access private 340 | * 341 | * @param bool $served Whether the request has already been served. 342 | * @param WP_HTTP_ResponseInterface $result Result to send to the client. Usually a WP_REST_Response. 343 | * @param WP_REST_Request $request Request used to generate the response. 344 | * @param WP_REST_Server $server Server instance. 345 | * @return true 346 | */ 347 | function _oembed_rest_pre_serve_request( $served, $result, $request, $server ) { 348 | $params = $request->get_params(); 349 | 350 | if ( '/wp/v2/oembed' !== $request->get_route() || 'GET' !== $request->get_method() ) { 351 | return $served; 352 | } 353 | 354 | if ( ! isset( $params['format'] ) || 'xml' !== $params['format'] ) { 355 | return $served; 356 | } 357 | 358 | // Embed links inside the request. 359 | $data = $server->response_to_data( $result, false ); 360 | 361 | if ( 404 === $result->get_status() ) { 362 | $data = $data[0]; 363 | } 364 | 365 | $result = _oembed_create_xml( $data ); 366 | 367 | // Bail if there's no XML. 368 | if ( ! $result ) { 369 | status_header( 501 ); 370 | die( 'Not implemented' ); 371 | } 372 | 373 | if ( ! headers_sent() ) { 374 | $server->send_header( 'Content-Type', 'text/xml; charset=' . get_option( 'blog_charset' ) ); 375 | } 376 | 377 | echo $result; 378 | 379 | return true; 380 | } 381 | 382 | /** 383 | * Creates an XML string from a given array. 384 | * 385 | * @since 4.4.0 386 | * @access private 387 | * 388 | * @param array $data The original oEmbed response data. 389 | * @param SimpleXMLElement $node Optional. XML node to append the result to recursively. 390 | * @return string|false XML string on success, false on error. 391 | */ 392 | function _oembed_create_xml( $data, $node = null ) { 393 | if ( ! is_array( $data ) || empty( $data ) ) { 394 | return false; 395 | } 396 | 397 | if ( null === $node ) { 398 | $node = new SimpleXMLElement( '' ); 399 | } 400 | 401 | foreach ( $data as $key => $value ) { 402 | if ( is_numeric( $key ) ) { 403 | $key = 'oembed'; 404 | } 405 | 406 | if ( is_array( $value ) ) { 407 | $item = $node->addChild( $key ); 408 | _oembed_create_xml( $value, $item ); 409 | } else { 410 | $node->addChild( $key, esc_html( $value ) ); 411 | } 412 | } 413 | 414 | return $node->asXML(); 415 | } 416 | 417 | /** 418 | * Add the query vars we need for the oEmbed controller. 419 | * 420 | * 'oembed', 'format', 'url', '_jsonp' and 'maxwidth' 421 | * are used for the oEmbed API endpoint. 422 | * 'embed' is used for the /embed/ rewrite endpoint. 423 | * 424 | * @since 4.4.0 425 | * 426 | * @param array $query_vars Registered query vars. 427 | * @return array The modified query vars array. 428 | */ 429 | function wp_oembed_add_query_vars( $query_vars ) { 430 | return array_merge( $query_vars, array( 'embed', 'oembed', 'format', 'url', '_jsonp', 'maxwidth' ) ); 431 | } 432 | 433 | /** 434 | * Returns the path to the post embed template. 435 | * 436 | * This template is used for displaying a post inside an iframe. 437 | * Themes can override this if necessary. 438 | * 439 | * @since 4.4.0 440 | * 441 | * @param string $template The path of the template to include. 442 | * @return string The filtered template. 443 | */ 444 | function wp_oembed_include_template( $template ) { 445 | if ( is_embed() ) { 446 | return dirname( plugin_dir_path( __FILE__ ) ) . '/includes/template.php'; 447 | } 448 | 449 | return $template; 450 | } 451 | 452 | /** 453 | * Is the query for an embedded post? 454 | * 455 | * @since 4.4.0 456 | * 457 | * @return bool Whether we're in an embedded post or not. 458 | */ 459 | function is_embed() { 460 | return (bool) false !== get_query_var( 'embed', false ) && ( is_singular() || is_404() ); 461 | } 462 | 463 | /** 464 | * Filters the returned oEmbed HTML. 465 | * 466 | * If the $url isn't on the trusted providers list, 467 | * we need to filter the HTML heavily for security. 468 | * 469 | * Only filters 'rich' and 'html' response types. 470 | * 471 | * @since 4.4.0 472 | * 473 | * @param string $return The returned oEmbed HTML. 474 | * @param object $data A data object result from an oEmbed provider. 475 | * @param string $url The URL of the content to be embedded. 476 | * @return string The filtered and sanitized oEmbed result. 477 | */ 478 | function wp_filter_oembed_result( $return, $data, $url ) { 479 | if ( false === $return || ! in_array( $data->type, array( 'rich', 'video' ) ) ) { 480 | return $return; 481 | } 482 | 483 | require_once( ABSPATH . WPINC . '/class-oembed.php' ); 484 | $wp_oembed = _wp_oembed_get_object(); 485 | 486 | // Don't modify the HTML for trusted providers. 487 | if ( false !== $wp_oembed->get_provider( $url, array( 'discover' => false ) ) ) { 488 | return $return; 489 | } 490 | 491 | $allowed_html = array( 492 | 'iframe' => array( 493 | 'src' => true, 494 | 'width' => true, 495 | 'height' => true, 496 | 'frameborder' => true, 497 | 'marginwidth' => true, 498 | 'marginheight' => true, 499 | 'scrolling' => true, 500 | 'title' => true, 501 | 'class' => true, 502 | ), 503 | ); 504 | 505 | $html = wp_kses( $return, $allowed_html ); 506 | preg_match( '|^.*().*$|m', $html, $iframes ); 507 | 508 | if ( empty( $iframes ) ) { 509 | return false; 510 | } 511 | 512 | $html = str_replace( '%s', 544 | get_the_permalink(), 545 | __( 'Read more', 'oembed-api' ) 546 | ) 547 | ); 548 | } 549 | 550 | /** 551 | * Display the post excerpt for the embed template. 552 | * 553 | * @since 4.4.0 554 | */ 555 | function the_excerpt_embed() { 556 | $output = get_the_excerpt(); 557 | 558 | /** 559 | * Filter the post excerpt for the embed template. 560 | * 561 | * @param string $output The current post excerpt. 562 | */ 563 | echo apply_filters( 'the_excerpt_embed', $output ); 564 | } 565 | 566 | /** 567 | * Filters the post excerpt for the embed template. 568 | * 569 | * Shows players for video and audio attachments. 570 | * 571 | * @since 4.4.0 572 | * 573 | * @param string $content The current post excerpt. 574 | * @return string The modified post excerpt. 575 | */ 576 | function wp_oembed_excerpt_attachment( $content ) { 577 | if ( is_attachment() ) { 578 | return prepend_attachment( '' ); 579 | } 580 | 581 | return $content; 582 | } 583 | 584 | /** 585 | * Custom old slug redirection function. 586 | * 587 | * @SuppressWarnings(PHPMD.CyclomaticComplexity) 588 | * @SuppressWarnings(PHPMD.NPathComplexity) 589 | * @codeCoverageIgnore 590 | */ 591 | function wp_oembed_old_slug_redirect() { 592 | global $wp_query, $wpdb; 593 | 594 | if ( false === get_query_var( 'embed', false ) ) { 595 | return; 596 | } 597 | 598 | if ( ! is_404() || false === get_query_var( 'name', false ) ) { 599 | return; 600 | } 601 | 602 | // Guess the current post_type based on the query vars. 603 | $post_type = 'post'; 604 | 605 | if ( get_query_var( 'post_type' ) ) { 606 | $post_type = get_query_var( 'post_type' ); 607 | } elseif ( get_query_var( 'pagename', false ) ) { 608 | $post_type = 'page'; 609 | } 610 | 611 | if ( is_array( $post_type ) ) { 612 | if ( count( $post_type ) > 1 ) { 613 | return; 614 | } 615 | $post_type = reset( $post_type ); 616 | } 617 | 618 | // Do not attempt redirect for hierarchical post types. 619 | if ( is_post_type_hierarchical( $post_type ) ) { 620 | return; 621 | } 622 | 623 | $query = $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta, $wpdb->posts WHERE ID = post_id AND post_type = %s AND meta_key = '_wp_old_slug' AND meta_value = %s", $post_type, $wp_query->query_vars['name'] ); 624 | 625 | if ( get_query_var( 'year', false ) ) { 626 | $query .= $wpdb->prepare( ' AND YEAR(post_date) = %d', $wp_query->query_vars['year'] ); 627 | } 628 | if ( get_query_var( 'monthnum', false ) ) { 629 | $query .= $wpdb->prepare( ' AND MONTH(post_date) = %d', $wp_query->query_vars['monthnum'] ); 630 | } 631 | if ( get_query_var( 'day', false ) ) { 632 | $query .= $wpdb->prepare( ' AND DAYOFMONTH(post_date) = %d', $wp_query->query_vars['day'] ); 633 | } 634 | 635 | $post_id = (int) $wpdb->get_var( $query ); 636 | 637 | if ( ! $post_id ) { 638 | return; 639 | } 640 | 641 | wp_redirect( get_post_embed_url( $post_id ), 301 ); 642 | exit; 643 | } 644 | 645 | /** 646 | * Disable the admin bar in the embed template. 647 | */ 648 | function wp_oembed_disable_admin_bar() { 649 | if ( is_embed() ) { 650 | add_filter( 'show_admin_bar', '__return_false', 9999 ); 651 | } 652 | } 653 | -------------------------------------------------------------------------------- /includes/template.php: -------------------------------------------------------------------------------- 1 | 20 | 21 | > 22 | 23 | <?php wp_title( '-', true, 'right' ); ?> 24 | 25 | 380 | 532 | 538 | 539 | > 540 | $data ) { 562 | if ( $data['width'] / $data['height'] > $aspect_ratio ) { 563 | $aspect_ratio = $data['width'] / $data['height']; 564 | $measurements = array( $data['width'], $data['height'] ); 565 | $image_size = $size; 566 | } 567 | } 568 | } 569 | 570 | /** 571 | * Filter the thumbnail image size for use in the embed template. 572 | * 573 | * @param string $image_size Thumbnail image size. 574 | */ 575 | $image_size = apply_filters( 'oembed_thumbnail_image_size', $image_size ); 576 | 577 | $shape = $measurements[0] / $measurements[1] >= 1.75 ? 'rectangular' : 'square'; 578 | 579 | /** 580 | * Filter the thumbnail shape for use in the embed template. 581 | * 582 | * Rectangular images are shown above the title 583 | * while square images are shown next to the content. 584 | * 585 | * @param string $shape Thumbnail image shape. Either 'rectangular' or 'square'. 586 | */ 587 | $shape = apply_filters( 'oembed_thumbnail_image_shape', $shape ); 588 | } 589 | ?> 590 |
> 591 | 592 | 597 | 598 | 599 |

600 | 601 | 602 | 603 |

604 | 605 | 606 | 611 | 612 | 613 |
614 | 615 | 621 | 622 | 674 | 706 |
707 | 711 |
712 |

713 | 714 |
715 |

716 |
717 | 718 | 743 |
744 | 752 | 753 | 754 | -------------------------------------------------------------------------------- /languages/oembed-api-ar.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swissspidy/oEmbed-API/b0b8b5fb14fcc3be541c6ea9510c81c10dd710ff/languages/oembed-api-ar.mo -------------------------------------------------------------------------------- /languages/oembed-api-ar.po: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 Pascal Birchler 2 | # This file is distributed under the GPLv2+. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: oEmbed API 0.6.0\n" 6 | "Report-Msgid-Bugs-To: https://pascalbirchler.com\n" 7 | "POT-Creation-Date: 2015-09-15 12:11+0200\n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=UTF-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "PO-Revision-Date: 2015-09-15 12:45+0200\n" 12 | "Language-Team: Said El Bakkali \n" 13 | "X-Generator: Poedit 1.8.4\n" 14 | "X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c\n" 15 | "Plural-Forms: nplurals=6; plural=(n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5);\n" 16 | "X-Poedit-SourceCharset: UTF-8\n" 17 | "X-Poedit-Basepath: ..\n" 18 | "X-Textdomain-Support: yes\n" 19 | "Last-Translator: Pascal Birchler \n" 20 | "Language: ar\n" 21 | "X-Poedit-SearchPath-0: .\n" 22 | 23 | #: includes/class-wp-rest-oembed-controller.php:62 24 | msgid "Invalid URL." 25 | msgstr "URL غير صالح." 26 | 27 | #: includes/class-wp-rest-oembed-controller.php:67 28 | msgid "Invalid format." 29 | msgstr "صيغة غير صالحة" 30 | 31 | #: includes/functions.php:121 32 | msgid "Embedded WordPress Post" 33 | msgstr "تضمين مقالات ووردبريس" 34 | 35 | #: includes/template.php:37 36 | msgid "… (%d word)" 37 | msgid_plural "… (%d words)" 38 | msgstr[0] "… (لا توجد أي كلمة)" 39 | msgstr[1] "… (كلمة واحدة)" 40 | msgstr[2] "… (كلمتان)" 41 | msgstr[3] "… (%d كلمات)" 42 | msgstr[4] "… (%d كلمة)" 43 | msgstr[5] "… (%d كلمة)" 44 | 45 | #: includes/template.php:423 46 | msgid "%s Comment" 47 | msgid_plural "%s Comments" 48 | msgstr[0] "%s لا توجد تعليقات" 49 | msgstr[1] "%s تعليق واحد" 50 | msgstr[2] "%s تعليقان" 51 | msgstr[3] "%s تعليقات" 52 | msgstr[4] "%s تعليقا" 53 | msgstr[5] "%s تعليق" 54 | 55 | #: includes/template.php:436 56 | msgid "Open sharing dialog" 57 | msgstr "فتح مشاركة الحوار" 58 | 59 | #: includes/template.php:445 60 | msgid "Copy and paste this URL into your site to embed:" 61 | msgstr "قم بنسخ ولصق هذا الرابط إلى موقع الويب الخاص بك لتضمين:" 62 | 63 | #: includes/template.php:455 64 | msgid "Close sharing dialog" 65 | msgstr "غلق مشاركة الحوار" 66 | 67 | #. Plugin Name of the plugin/theme 68 | msgid "oEmbed API" 69 | msgstr "oEmbed API" 70 | 71 | #. Plugin URI of the plugin/theme 72 | msgid "https://github.com/swissspidy/oEmbed-API" 73 | msgstr "https://github.com/swissspidy/oEmbed-API" 74 | 75 | #. Description of the plugin/theme 76 | msgid "Allow others to easily embed your blog posts on their sites using oEmbed." 77 | msgstr "السماح للأخرين بتضمين مقالات مدونتك في مواقعهم بسهولة بإستعمال oEmbed." 78 | 79 | #. Author of the plugin/theme 80 | msgid "Pascal Birchler" 81 | msgstr "Pascal Birchler" 82 | 83 | #. Author URI of the plugin/theme 84 | msgid "https://pascalbirchler.com" 85 | msgstr "https://pascalbirchler.com" 86 | 87 | #. translators: If your word count is based on single characters (e.g. East 88 | #. Asian characters), enter 'characters_excluding_spaces' or 89 | #. 'characters_including_spaces'. Otherwise, enter 'words'. Do not translate 90 | #. into your own language. 91 | #: includes/template.php:31 92 | msgctxt "Word count type. Do not translate!" 93 | msgid "words" 94 | msgstr "‏words" 95 | -------------------------------------------------------------------------------- /languages/oembed-api-ary.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swissspidy/oEmbed-API/b0b8b5fb14fcc3be541c6ea9510c81c10dd710ff/languages/oembed-api-ary.mo -------------------------------------------------------------------------------- /languages/oembed-api-ary.po: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 Pascal Birchler 2 | # This file is distributed under the GPLv2+. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: oEmbed API 0.6.0\n" 6 | "Report-Msgid-Bugs-To: https://pascalbirchler.com\n" 7 | "POT-Creation-Date: 2015-09-15 12:11+0200\n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=UTF-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "PO-Revision-Date: 2015-09-15 12:45+0200\n" 12 | "Language-Team: Said El Bakkali \n" 13 | "X-Generator: Poedit 1.8.4\n" 14 | "X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c\n" 15 | "Plural-Forms: nplurals=6; plural=(n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5);\n" 16 | "X-Poedit-SourceCharset: UTF-8\n" 17 | "X-Poedit-Basepath: ..\n" 18 | "X-Textdomain-Support: yes\n" 19 | "Last-Translator: Pascal Birchler \n" 20 | "Language: ar_MA\n" 21 | "X-Poedit-SearchPath-0: .\n" 22 | 23 | #: includes/class-wp-rest-oembed-controller.php:62 24 | msgid "Invalid URL." 25 | msgstr "URL غير صالح." 26 | 27 | #: includes/class-wp-rest-oembed-controller.php:67 28 | msgid "Invalid format." 29 | msgstr "صيغة غير صالحة" 30 | 31 | #: includes/functions.php:121 32 | msgid "Embedded WordPress Post" 33 | msgstr "تضمين مقالات ووردبريس" 34 | 35 | #: includes/template.php:37 36 | msgid "… (%d word)" 37 | msgid_plural "… (%d words)" 38 | msgstr[0] "… (لا توجد أي كلمة)" 39 | msgstr[1] "… (كلمة واحدة)" 40 | msgstr[2] "… (كلمتان)" 41 | msgstr[3] "… (%d كلمات)" 42 | msgstr[4] "… (%d كلمة)" 43 | msgstr[5] "… (%d كلمة)" 44 | 45 | #: includes/template.php:423 46 | msgid "%s Comment" 47 | msgid_plural "%s Comments" 48 | msgstr[0] "%s لا توجد تعليقات" 49 | msgstr[1] "%s تعليق واحد" 50 | msgstr[2] "%s تعليقان" 51 | msgstr[3] "%s تعليقات" 52 | msgstr[4] "%s تعليقا" 53 | msgstr[5] "%s تعليق" 54 | 55 | #: includes/template.php:436 56 | msgid "Open sharing dialog" 57 | msgstr "فتح مشاركة الحوار" 58 | 59 | #: includes/template.php:445 60 | msgid "Copy and paste this URL into your site to embed:" 61 | msgstr "قم بنسخ ولصق هذا الرابط إلى موقع الويب الخاص بك لتضمين:" 62 | 63 | #: includes/template.php:455 64 | msgid "Close sharing dialog" 65 | msgstr "غلق مشاركة الحوار" 66 | 67 | #. Plugin Name of the plugin/theme 68 | msgid "oEmbed API" 69 | msgstr "oEmbed API" 70 | 71 | #. Plugin URI of the plugin/theme 72 | msgid "https://github.com/swissspidy/oEmbed-API" 73 | msgstr "https://github.com/swissspidy/oEmbed-API" 74 | 75 | #. Description of the plugin/theme 76 | msgid "Allow others to easily embed your blog posts on their sites using oEmbed." 77 | msgstr "السماح للأخرين بتضمين مقالات مدونتك في مواقعهم بسهولة بإستعمال oEmbed." 78 | 79 | #. Author of the plugin/theme 80 | msgid "Pascal Birchler" 81 | msgstr "Pascal Birchler" 82 | 83 | #. Author URI of the plugin/theme 84 | msgid "https://pascalbirchler.com" 85 | msgstr "https://pascalbirchler.com" 86 | 87 | #. translators: If your word count is based on single characters (e.g. East 88 | #. Asian characters), enter 'characters_excluding_spaces' or 89 | #. 'characters_including_spaces'. Otherwise, enter 'words'. Do not translate 90 | #. into your own language. 91 | #: includes/template.php:31 92 | msgctxt "Word count type. Do not translate!" 93 | msgid "words" 94 | msgstr "‏words" 95 | -------------------------------------------------------------------------------- /languages/oembed-api-da_DK.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swissspidy/oEmbed-API/b0b8b5fb14fcc3be541c6ea9510c81c10dd710ff/languages/oembed-api-da_DK.mo -------------------------------------------------------------------------------- /languages/oembed-api-da_DK.po: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 Pascal Birchler 2 | # This file is distributed under the GPLv2+. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: oEmbed API 0.6.0\n" 6 | "Report-Msgid-Bugs-To: https://pascalbirchler.com\n" 7 | "POT-Creation-Date: 2015-09-11 14:56+0200\n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=UTF-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "PO-Revision-Date: 2015-09-11 15:10+0200\n" 12 | "Language-Team: Pascal Birchler \n" 13 | "X-Generator: Poedit 1.8.4\n" 14 | "X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c\n" 15 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 16 | "X-Poedit-SourceCharset: UTF-8\n" 17 | "X-Poedit-Basepath: ..\n" 18 | "X-Textdomain-Support: yes\n" 19 | "Last-Translator: \n" 20 | "Language: da_DK\n" 21 | "X-Poedit-SearchPath-0: .\n" 22 | 23 | #: includes/class-wp-rest-oembed-controller.php:62 24 | msgid "Invalid URL." 25 | msgstr "Ugyldig URL." 26 | 27 | #: includes/class-wp-rest-oembed-controller.php:67 28 | msgid "Invalid format." 29 | msgstr "Ugyldig format." 30 | 31 | #: includes/functions.php:121 32 | msgid "Embedded WordPress Post" 33 | msgstr "Indlejret WordPress indlæg" 34 | 35 | #: includes/template.php:37 36 | msgid "… (%d word)" 37 | msgid_plural "… (%d words)" 38 | msgstr[0] "… (%d ord)" 39 | msgstr[1] "… (%d ord)" 40 | 41 | #: includes/template.php:423 42 | msgid "%s Comment" 43 | msgid_plural "%s Comments" 44 | msgstr[0] "%s Kommentar" 45 | msgstr[1] "%s Kommentarer" 46 | 47 | #: includes/template.php:436 48 | msgid "Open sharing dialog" 49 | msgstr "Åben delingsdialogen" 50 | 51 | #: includes/template.php:445 52 | msgid "Copy and paste this URL into your site to embed:" 53 | msgstr "Kopier og indsæt denne URL i din side for at indlejre:" 54 | 55 | #: includes/template.php:455 56 | msgid "Close sharing dialog" 57 | msgstr "Luk delingsdialog" 58 | 59 | #. Plugin Name of the plugin/theme 60 | msgid "oEmbed API" 61 | msgstr "oEmbed API" 62 | 63 | #. Plugin URI of the plugin/theme 64 | msgid "https://github.com/swissspidy/oEmbed-API" 65 | msgstr "https://github.com/swissspidy/oEmbed-API" 66 | 67 | #. Description of the plugin/theme 68 | msgid "Allow others to easily embed your blog posts on their sites using oEmbed." 69 | msgstr "Tillad andre let at indlejre dine blog indlæg i deres sider med oEmbed." 70 | 71 | #. Author of the plugin/theme 72 | msgid "Pascal Birchler" 73 | msgstr "Pascal Birchler" 74 | 75 | #. Author URI of the plugin/theme 76 | msgid "https://pascalbirchler.com" 77 | msgstr "https://pascalbirchler.com" 78 | 79 | #. translators: If your word count is based on single characters (e.g. East 80 | #. Asian characters), enter 'characters_excluding_spaces' or 81 | #. 'characters_including_spaces'. Otherwise, enter 'words'. Do not translate 82 | #. into your own language. 83 | #: includes/template.php:31 84 | msgctxt "Word count type. Do not translate!" 85 | msgid "words" 86 | msgstr "words" 87 | -------------------------------------------------------------------------------- /languages/oembed-api-de_CH.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swissspidy/oEmbed-API/b0b8b5fb14fcc3be541c6ea9510c81c10dd710ff/languages/oembed-api-de_CH.mo -------------------------------------------------------------------------------- /languages/oembed-api-de_CH.po: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 Pascal Birchler 2 | # This file is distributed under the GPLv2+. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: oEmbed API 0.6.0\n" 6 | "Report-Msgid-Bugs-To: https://pascalbirchler.com\n" 7 | "POT-Creation-Date: 2015-09-12 12:40+0200\n" 8 | "PO-Revision-Date: 2015-09-12 23:51+0200\n" 9 | "Last-Translator: Pascal Birchler \n" 10 | "Language-Team: Pascal Birchler \n" 11 | "Language: de_CH\n" 12 | "MIME-Version: 1.0\n" 13 | "Content-Type: text/plain; charset=UTF-8\n" 14 | "Content-Transfer-Encoding: 8bit\n" 15 | "X-Generator: Poedit 1.8.4\n" 16 | "X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;" 17 | "_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;" 18 | "esc_html_x:1,2c\n" 19 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 20 | "X-Poedit-SourceCharset: UTF-8\n" 21 | "X-Poedit-Basepath: ..\n" 22 | "X-Textdomain-Support: yes\n" 23 | "X-Poedit-SearchPath-0: .\n" 24 | "X-Poedit-SearchPathExcluded-0: vendor\n" 25 | "X-Poedit-SearchPathExcluded-1: node_modules\n" 26 | 27 | #: includes/class-wp-rest-oembed-controller.php:62 28 | msgid "Invalid URL." 29 | msgstr "Ungültige URL." 30 | 31 | #: includes/class-wp-rest-oembed-controller.php:67 32 | msgid "Invalid format." 33 | msgstr "Ungültiges Format." 34 | 35 | #: includes/functions.php:121 36 | msgid "Embedded WordPress Post" 37 | msgstr "Eingebetteter WordPress-Blogbeitrag" 38 | 39 | #. translators: If your word count is based on single characters (e.g. East Asian characters), 40 | #. enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'. 41 | #. Do not translate into your own language. 42 | #. 43 | #: includes/functions.php:483 44 | msgctxt "Word count type. Do not translate!" 45 | msgid "words" 46 | msgstr "words" 47 | 48 | #: includes/functions.php:489 49 | #, php-format 50 | msgid "… (%d word)" 51 | msgid_plural "… (%d words)" 52 | msgstr[0] "… (%d Wort)" 53 | msgstr[1] "… (%d Wörter)" 54 | 55 | #: includes/template.php:420 56 | #, php-format 57 | msgid "%s Comment" 58 | msgid_plural "%s Comments" 59 | msgstr[0] "%s Kommentar" 60 | msgstr[1] "%s Kommentare" 61 | 62 | #: includes/template.php:432 63 | msgid "Open sharing dialog" 64 | msgstr "Sharing-Dialog öffnen" 65 | 66 | #: includes/template.php:441 67 | msgid "Copy and paste this URL into your site to embed:" 68 | msgstr "Füge diese URL zum Einbetten auf deiner Website ein:" 69 | 70 | #: includes/template.php:451 71 | msgid "Close sharing dialog" 72 | msgstr "Sharing-Dialog schliessen" 73 | -------------------------------------------------------------------------------- /languages/oembed-api-de_DE.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swissspidy/oEmbed-API/b0b8b5fb14fcc3be541c6ea9510c81c10dd710ff/languages/oembed-api-de_DE.mo -------------------------------------------------------------------------------- /languages/oembed-api-de_DE.po: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 Pascal Birchler 2 | # This file is distributed under the GPLv2+. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: oEmbed API 0.6.0\n" 6 | "Report-Msgid-Bugs-To: https://pascalbirchler.com\n" 7 | "POT-Creation-Date: 2015-09-11 12:38+0200\n" 8 | "PO-Revision-Date: 2015-09-12 23:51+0200\n" 9 | "Last-Translator: Pascal Birchler \n" 10 | "Language-Team: Pascal Birchler \n" 11 | "Language: de_DE\n" 12 | "MIME-Version: 1.0\n" 13 | "Content-Type: text/plain; charset=UTF-8\n" 14 | "Content-Transfer-Encoding: 8bit\n" 15 | "X-Generator: Poedit 1.8.4\n" 16 | "X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;" 17 | "_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;" 18 | "esc_html_x:1,2c\n" 19 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 20 | "X-Poedit-SourceCharset: UTF-8\n" 21 | "X-Poedit-Basepath: ..\n" 22 | "X-Textdomain-Support: yes\n" 23 | "X-Poedit-SearchPath-0: .\n" 24 | "X-Poedit-SearchPathExcluded-0: vendor\n" 25 | "X-Poedit-SearchPathExcluded-1: node_modules\n" 26 | 27 | #: includes/class-wp-rest-oembed-controller.php:62 28 | msgid "Invalid URL." 29 | msgstr "Ungültige URL." 30 | 31 | #: includes/class-wp-rest-oembed-controller.php:67 32 | msgid "Invalid format." 33 | msgstr "Ungültiges Format." 34 | 35 | #: includes/functions.php:121 36 | msgid "Embedded WordPress Post" 37 | msgstr "Eingebetteter WordPress-Blogbeitrag" 38 | 39 | #: includes/template.php:37 40 | msgid "… (%d word)" 41 | msgid_plural "… (%d words)" 42 | msgstr[0] "… (%d Wort)" 43 | msgstr[1] "… (%d Wörter)" 44 | 45 | #: includes/template.php:423 46 | msgid "%s Comment" 47 | msgid_plural "%s Comments" 48 | msgstr[0] "%s Kommentar" 49 | msgstr[1] "%s Kommentare" 50 | 51 | #: includes/template.php:436 52 | msgid "Open sharing dialog" 53 | msgstr "Sharing-Dialog öffnen" 54 | 55 | #: includes/template.php:445 56 | msgid "Copy and paste this URL into your site to embed:" 57 | msgstr "Füge diese URL zum Einbetten auf deiner Website ein:" 58 | 59 | #: includes/template.php:455 60 | msgid "Close sharing dialog" 61 | msgstr "Sharing-Dialog schließen" 62 | 63 | #. Plugin Name of the plugin/theme 64 | msgid "oEmbed API" 65 | msgstr "oEmbed API" 66 | 67 | #. Plugin URI of the plugin/theme 68 | msgid "https://github.com/swissspidy/oEmbed-API" 69 | msgstr "https://github.com/swissspidy/oEmbed-API" 70 | 71 | #. Description of the plugin/theme 72 | msgid "" 73 | "Allow others to easily embed your blog posts on their sites using oEmbed." 74 | msgstr "" 75 | "Ermögliche es anderen deine Blogbeiträge bequem mittels oEmbed einzubetten." 76 | 77 | #. Author of the plugin/theme 78 | msgid "Pascal Birchler" 79 | msgstr "Pascal Birchler" 80 | 81 | #. Author URI of the plugin/theme 82 | msgid "https://pascalbirchler.com" 83 | msgstr "https://pascalbirchler.com" 84 | 85 | #. translators: If your word count is based on single characters (e.g. East 86 | #. Asian characters), enter 'characters_excluding_spaces' or 87 | #. 'characters_including_spaces'. Otherwise, enter 'words'. Do not translate 88 | #. into your own language. 89 | #: includes/template.php:31 90 | msgctxt "Word count type. Do not translate!" 91 | msgid "words" 92 | msgstr "" 93 | 94 | #, fuzzy 95 | #~ msgctxt "verb" 96 | #~ msgid "Post" 97 | #~ msgstr "Eingebetteter WordPress Blogbeitrag" 98 | 99 | #, fuzzy 100 | #~ msgid "Invalid comment ID." 101 | #~ msgstr "Ungültiges Format." 102 | 103 | #, fuzzy 104 | #~ msgid "Invalid post ID." 105 | #~ msgstr "Ungültiges Format." 106 | 107 | #, fuzzy 108 | #~ msgid "Invalid meta ID." 109 | #~ msgstr "Ungültiges Format." 110 | 111 | #, fuzzy 112 | #~ msgid "Invalid meta parameters." 113 | #~ msgstr "Ungültiges Format." 114 | 115 | #, fuzzy 116 | #~ msgid "Invalid meta key." 117 | #~ msgstr "Ungültiges Format." 118 | 119 | #, fuzzy 120 | #~ msgid "Invalid status." 121 | #~ msgstr "Ungültiges Format." 122 | 123 | #, fuzzy 124 | #~ msgid "Invalid type." 125 | #~ msgstr "Ungültige URL." 126 | 127 | #, fuzzy 128 | #~ msgid "Invalid post parent ID." 129 | #~ msgstr "Ungültiges Format." 130 | 131 | #, fuzzy 132 | #~ msgid "Invalid author object." 133 | #~ msgstr "Ungültiges Format." 134 | 135 | #, fuzzy 136 | #~ msgid "Invalid author ID." 137 | #~ msgstr "Ungültiges Format." 138 | 139 | #, fuzzy 140 | #~ msgid "Invalid featured image ID." 141 | #~ msgstr "Ungültiges Format." 142 | 143 | #, fuzzy 144 | #~ msgid "Invalid taxonomy." 145 | #~ msgstr "Ungültiges Format." 146 | 147 | #, fuzzy 148 | #~ msgid "Invalid user ID." 149 | #~ msgstr "Ungültiges Format." 150 | 151 | #, fuzzy 152 | #~ msgid "Invalid param." 153 | #~ msgstr "Ungültiges Format." 154 | -------------------------------------------------------------------------------- /languages/oembed-api-el.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swissspidy/oEmbed-API/b0b8b5fb14fcc3be541c6ea9510c81c10dd710ff/languages/oembed-api-el.mo -------------------------------------------------------------------------------- /languages/oembed-api-el.po: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 Pascal Birchler 2 | # This file is distributed under the GPLv2+. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: oEmbed API 0.6.0\n" 6 | "Report-Msgid-Bugs-To: https://pascalbirchler.com\n" 7 | "POT-Creation-Date: 2015-07-27 13:00:02+00:00\n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=utf-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "PO-Revision-Date: 2015-09-12 00:24+0200\n" 12 | "Last-Translator: kanenas.net (aka Nikolas Branis) \n" 13 | "Language-Team: Pascal Birchler \n" 14 | "X-Generator: Poedit 1.5.4\n" 15 | "X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;" 16 | "_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;" 17 | "esc_html_x:1,2c\n" 18 | "Language: en\n" 19 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 20 | "X-Poedit-SourceCharset: UTF-8\n" 21 | "X-Poedit-Basepath: ../\n" 22 | "X-Textdomain-Support: yes\n" 23 | "X-Poedit-SearchPath-0: .\n" 24 | 25 | #: includes/class-wp-rest-oembed-controller.php:62 26 | msgid "Invalid URL." 27 | msgstr "Μη έγκυρη διεύθυνση URL." 28 | 29 | #: includes/class-wp-rest-oembed-controller.php:67 30 | msgid "Invalid format." 31 | msgstr "Μη έγκυρη μορφή." 32 | 33 | #: includes/functions.php:121 34 | msgid "Embedded WordPress Post" 35 | msgstr "Ενσωματωμένο WordPress Άρθρο" 36 | 37 | #: includes/template.php:37 38 | msgid "… (%d word)" 39 | msgid_plural "… (%d words)" 40 | msgstr[0] "… (%d λέξη)" 41 | msgstr[1] "… (%d λέξεις)" 42 | 43 | #: includes/template.php:423 44 | msgid "%s Comment" 45 | msgid_plural "%s Comments" 46 | msgstr[0] "%s Σχόλιο" 47 | msgstr[1] "%s Σχόλια" 48 | 49 | #: includes/template.php:436 50 | msgid "Open sharing dialog" 51 | msgstr "Ανοίξτε το πλαίσιο διαλόγου κοινής χρήσης" 52 | 53 | #: includes/template.php:445 54 | msgid "Copy and paste this URL into your site to embed:" 55 | msgstr "" 56 | "Αντιγράψτε και επικολλήστε αυτό το URL στο δικτυακό σας τόπο για να " 57 | "ενσωματώσετε:" 58 | 59 | #: includes/template.php:455 60 | msgid "Close sharing dialog" 61 | msgstr "Κλείστε το πλαίσιο διαλόγου κοινής χρήσης" 62 | 63 | #. Plugin Name of the plugin/theme 64 | msgid "oEmbed API" 65 | msgstr "oEmbed API" 66 | 67 | #. Plugin URI of the plugin/theme 68 | msgid "https://github.com/swissspidy/oEmbed-API" 69 | msgstr "https://github.com/swissspidy/oEmbed-API" 70 | 71 | #. Description of the plugin/theme 72 | msgid "" 73 | "Allow others to easily embed your blog posts on their sites using oEmbed." 74 | msgstr "" 75 | "Αφήστε τους άλλους να ενσωματώσουν εύκολα τα άρθρα σας στους δικτυακούς τους " 76 | "τόπους, χρησιμοποιώντας το oEmbed." 77 | 78 | #. Author of the plugin/theme 79 | msgid "Pascal Birchler" 80 | msgstr "Pascal Birchler" 81 | 82 | #. Author URI of the plugin/theme 83 | msgid "https://pascalbirchler.com" 84 | msgstr "https://pascalbirchler.com" 85 | 86 | #. translators: If your word count is based on single characters (e.g. East 87 | #. Asian characters), enter 'characters_excluding_spaces' or 88 | #. 'characters_including_spaces'. Otherwise, enter 'words'. Do not translate 89 | #. into your own language. 90 | #: includes/template.php:31 91 | msgctxt "Word count type. Do not translate!" 92 | msgid "words" 93 | msgstr "words" 94 | -------------------------------------------------------------------------------- /languages/oembed-api-en_AU.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swissspidy/oEmbed-API/b0b8b5fb14fcc3be541c6ea9510c81c10dd710ff/languages/oembed-api-en_AU.mo -------------------------------------------------------------------------------- /languages/oembed-api-en_AU.po: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 Pascal Birchler 2 | # This file is distributed under the GPLv2+. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: oEmbed API 0.6.0\n" 6 | "Report-Msgid-Bugs-To: https://pascalbirchler.com\n" 7 | "POT-Creation-Date: 2015-09-11 23:48+1000\n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=UTF-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "PO-Revision-Date: 2015-09-11 23:49+1000\n" 12 | "Language-Team: Pascal Birchler \n" 13 | "X-Generator: Poedit 1.8.4\n" 14 | "X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c\n" 15 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 16 | "X-Poedit-SourceCharset: UTF-8\n" 17 | "X-Poedit-Basepath: ..\n" 18 | "X-Textdomain-Support: yes\n" 19 | "Last-Translator: \n" 20 | "Language: en_AU\n" 21 | "X-Poedit-SearchPath-0: .\n" 22 | 23 | #: includes/class-wp-rest-oembed-controller.php:62 24 | msgid "Invalid URL." 25 | msgstr "Invalid URL." 26 | 27 | #: includes/class-wp-rest-oembed-controller.php:67 28 | msgid "Invalid format." 29 | msgstr "Invalid format." 30 | 31 | #: includes/functions.php:121 32 | msgid "Embedded WordPress Post" 33 | msgstr "Embedded WordPress Post" 34 | 35 | #: includes/template.php:37 36 | msgid "… (%d word)" 37 | msgid_plural "… (%d words)" 38 | msgstr[0] "… (%d word)" 39 | msgstr[1] "… (%d words)" 40 | 41 | #: includes/template.php:423 42 | msgid "%s Comment" 43 | msgid_plural "%s Comments" 44 | msgstr[0] "%s Comment" 45 | msgstr[1] "%s Comments" 46 | 47 | #: includes/template.php:436 48 | msgid "Open sharing dialog" 49 | msgstr "Open sharing dialog" 50 | 51 | #: includes/template.php:445 52 | msgid "Copy and paste this URL into your site to embed:" 53 | msgstr "Copy and paste this URL into your site to embed:" 54 | 55 | #: includes/template.php:455 56 | msgid "Close sharing dialog" 57 | msgstr "Close sharing dialog" 58 | 59 | #. Plugin Name of the plugin/theme 60 | msgid "oEmbed API" 61 | msgstr "oEmbed API" 62 | 63 | #. Plugin URI of the plugin/theme 64 | msgid "https://github.com/swissspidy/oEmbed-API" 65 | msgstr "https://github.com/swissspidy/oEmbed-API" 66 | 67 | #. Description of the plugin/theme 68 | msgid "Allow others to easily embed your blog posts on their sites using oEmbed." 69 | msgstr "Allow others to easily embed your blog posts on their sites using oEmbed." 70 | 71 | #. Author of the plugin/theme 72 | msgid "Pascal Birchler" 73 | msgstr "Pascal Birchler" 74 | 75 | #. Author URI of the plugin/theme 76 | msgid "https://pascalbirchler.com" 77 | msgstr "https://pascalbirchler.com" 78 | 79 | #. translators: If your word count is based on single characters (e.g. East 80 | #. Asian characters), enter 'characters_excluding_spaces' or 81 | #. 'characters_including_spaces'. Otherwise, enter 'words'. Do not translate 82 | #. into your own language. 83 | #: includes/template.php:31 84 | msgctxt "Word count type. Do not translate!" 85 | msgid "words" 86 | msgstr "words" 87 | -------------------------------------------------------------------------------- /languages/oembed-api-es_ES.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swissspidy/oEmbed-API/b0b8b5fb14fcc3be541c6ea9510c81c10dd710ff/languages/oembed-api-es_ES.mo -------------------------------------------------------------------------------- /languages/oembed-api-es_ES.po: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 Pascal Birchler 2 | # This file is distributed under the GPLv2+. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: oEmbed API 0.6.0\n" 6 | "Report-Msgid-Bugs-To: https://pascalbirchler.com\n" 7 | "POT-Creation-Date: 2015-09-16 20:47-0500\n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=UTF-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "PO-Revision-Date: 2015-09-16 21:24-0500\n" 12 | "Language-Team: Pascal Birchler \n" 13 | "X-Generator: Poedit 1.8.4\n" 14 | "X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c\n" 15 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 16 | "X-Poedit-SourceCharset: UTF-8\n" 17 | "X-Poedit-Basepath: ..\n" 18 | "X-Textdomain-Support: yes\n" 19 | "Last-Translator: Eduardo Reveles \n" 20 | "Language: es_ES\n" 21 | "X-Poedit-SearchPath-0: .\n" 22 | 23 | #: includes/class-wp-rest-oembed-controller.php:62 24 | msgid "Invalid URL." 25 | msgstr "URL inválida." 26 | 27 | #: includes/class-wp-rest-oembed-controller.php:67 28 | msgid "Invalid format." 29 | msgstr "Formato inválido." 30 | 31 | #: includes/functions.php:121 32 | msgid "Embedded WordPress Post" 33 | msgstr "Entrada de WordPress insertada" 34 | 35 | #: includes/template.php:37 36 | msgid "… (%d word)" 37 | msgid_plural "… (%d words)" 38 | msgstr[0] "… (%d palabra)" 39 | msgstr[1] "… (%d palabras)" 40 | 41 | #: includes/template.php:423 42 | msgid "%s Comment" 43 | msgid_plural "%s Comments" 44 | msgstr[0] "%s Comentario" 45 | msgstr[1] "%s Comentarios" 46 | 47 | #: includes/template.php:436 48 | msgid "Open sharing dialog" 49 | msgstr "Abrir ventana de compartir" 50 | 51 | #: includes/template.php:445 52 | msgid "Copy and paste this URL into your site to embed:" 53 | msgstr "Copia y pega esta URL en tu sitio para insertar la entrada:" 54 | 55 | #: includes/template.php:455 56 | msgid "Close sharing dialog" 57 | msgstr "Cerrar ventana de compartir" 58 | 59 | #. Plugin Name of the plugin/theme 60 | msgid "oEmbed API" 61 | msgstr "oEmbed API" 62 | 63 | #. Plugin URI of the plugin/theme 64 | msgid "https://github.com/swissspidy/oEmbed-API" 65 | msgstr "https://github.com/swissspidy/oEmbed-API" 66 | 67 | #. Description of the plugin/theme 68 | msgid "Allow others to easily embed your blog posts on their sites using oEmbed." 69 | msgstr "Permite a otros insertar fácilmente tus entradas en sus sitios usando oEmbed." 70 | 71 | #. Author of the plugin/theme 72 | msgid "Pascal Birchler" 73 | msgstr "Pascal Birchler" 74 | 75 | #. Author URI of the plugin/theme 76 | msgid "https://pascalbirchler.com" 77 | msgstr "https://pascalbirchler.com" 78 | 79 | #. translators: If your word count is based on single characters (e.g. East 80 | #. Asian characters), enter 'characters_excluding_spaces' or 81 | #. 'characters_including_spaces'. Otherwise, enter 'words'. Do not translate 82 | #. into your own language. 83 | #: includes/template.php:31 84 | msgctxt "Word count type. Do not translate!" 85 | msgid "words" 86 | msgstr "words" 87 | -------------------------------------------------------------------------------- /languages/oembed-api-fi.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swissspidy/oEmbed-API/b0b8b5fb14fcc3be541c6ea9510c81c10dd710ff/languages/oembed-api-fi.mo -------------------------------------------------------------------------------- /languages/oembed-api-fi.po: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 Pascal Birchler 2 | # This file is distributed under the GPLv2+. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: oEmbed API 0.6.0\n" 6 | "Report-Msgid-Bugs-To: https://pascalbirchler.com\n" 7 | "POT-Creation-Date: 2015-07-27 13:00:02+00:00\n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=UTF-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "PO-Revision-Date: 2015-09-20 14:27+0100\n" 12 | "Last-Translator: Aki Björklund \n" 13 | "Language-Team: Pascal Birchler \n" 14 | "X-Generator: Poedit 1.7.6\n" 15 | "X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;" 16 | "_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;" 17 | "esc_html_x:1,2c\n" 18 | "Language: fi\n" 19 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 20 | "X-Poedit-SourceCharset: UTF-8\n" 21 | "X-Poedit-Basepath: ../\n" 22 | "X-Textdomain-Support: yes\n" 23 | "X-Poedit-SearchPath-0: .\n" 24 | 25 | #: includes/class-wp-rest-oembed-controller.php:62 26 | msgid "Invalid URL." 27 | msgstr "Virheellinen URL." 28 | 29 | #: includes/class-wp-rest-oembed-controller.php:67 30 | msgid "Invalid format." 31 | msgstr "Viallinen muoto." 32 | 33 | #: includes/functions.php:121 34 | msgid "Embedded WordPress Post" 35 | msgstr "Upotettu WordPress-artikkeli" 36 | 37 | #: includes/template.php:37 38 | msgid "… (%d word)" 39 | msgid_plural "… (%d words)" 40 | msgstr[0] "… (%d sana)" 41 | msgstr[1] "… (%d sanaa)" 42 | 43 | #: includes/template.php:423 44 | msgid "%s Comment" 45 | msgid_plural "%s Comments" 46 | msgstr[0] "%s kommentti" 47 | msgstr[1] "%s kommenttia" 48 | 49 | #: includes/template.php:436 50 | msgid "Open sharing dialog" 51 | msgstr "Avaa jakamistila" 52 | 53 | #: includes/template.php:445 54 | msgid "Copy and paste this URL into your site to embed:" 55 | msgstr "Kopioi ja liitä tämä URL sivustollesi upottaaksesi artikkelin:" 56 | 57 | #: includes/template.php:455 58 | msgid "Close sharing dialog" 59 | msgstr "Sulje jakamistila" 60 | 61 | #. Plugin Name of the plugin/theme 62 | msgid "oEmbed API" 63 | msgstr "oEmbed-API" 64 | 65 | #. Plugin URI of the plugin/theme 66 | msgid "https://github.com/swissspidy/oEmbed-API" 67 | msgstr "https://github.com/swissspidy/oEmbed-API" 68 | 69 | #. Description of the plugin/theme 70 | msgid "Allow others to easily embed your blog posts on their sites using oEmbed." 71 | msgstr "" 72 | "Tee artikkelien upottaminen toisille sivustoille helpoksi oEmbedin avulla." 73 | 74 | #. Author of the plugin/theme 75 | msgid "Pascal Birchler" 76 | msgstr "Pascal Birchler" 77 | 78 | #. Author URI of the plugin/theme 79 | msgid "https://pascalbirchler.com" 80 | msgstr "https://pascalbirchler.com" 81 | 82 | #. translators: If your word count is based on single characters (e.g. East 83 | #. Asian characters), enter 'characters_excluding_spaces' or 84 | #. 'characters_including_spaces'. Otherwise, enter 'words'. Do not translate 85 | #. into your own language. 86 | #: includes/template.php:31 87 | msgctxt "Word count type. Do not translate!" 88 | msgid "words" 89 | msgstr "words" 90 | -------------------------------------------------------------------------------- /languages/oembed-api-fr_FR.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swissspidy/oEmbed-API/b0b8b5fb14fcc3be541c6ea9510c81c10dd710ff/languages/oembed-api-fr_FR.mo -------------------------------------------------------------------------------- /languages/oembed-api-fr_FR.po: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 Pascal Birchler 2 | # This file is distributed under the GPLv2+. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: oEmbed API 0.6.0\n" 6 | "Report-Msgid-Bugs-To: https://pascalbirchler.com\n" 7 | "POT-Creation-Date: 2015-07-27 13:00:02+00:00\n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=UTF-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "PO-Revision-Date: 2015-09-17 14:06+0100\n" 12 | "Last-Translator: \n" 13 | "Language-Team: \n" 14 | "X-Generator: Poedit 1.5.7\n" 15 | "X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;" 16 | "_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;" 17 | "esc_html_x:1,2c\n" 18 | "Plural-Forms: nplurals=2; plural=(n > 1);\n" 19 | "X-Poedit-SourceCharset: UTF-8\n" 20 | "X-Poedit-Basepath: ../\n" 21 | "X-Textdomain-Support: yes\n" 22 | "X-Poedit-SearchPath-0: .\n" 23 | 24 | #: includes/class-wp-rest-oembed-controller.php:62 25 | msgid "Invalid URL." 26 | msgstr "Url invalide." 27 | 28 | #: includes/class-wp-rest-oembed-controller.php:67 29 | msgid "Invalid format." 30 | msgstr "Format invalide." 31 | 32 | #: includes/functions.php:121 33 | msgid "Embedded WordPress Post" 34 | msgstr "Article WordPress Intégré" 35 | 36 | #: includes/template.php:37 37 | msgid "… (%d word)" 38 | msgid_plural "… (%d words)" 39 | msgstr[0] "… (%d mot)" 40 | msgstr[1] "… (%d mots)" 41 | 42 | #: includes/template.php:423 43 | msgid "%s Comment" 44 | msgid_plural "%s Comments" 45 | msgstr[0] "%s Commentaire" 46 | msgstr[1] "%s Commentaires" 47 | 48 | #: includes/template.php:436 49 | msgid "Open sharing dialog" 50 | msgstr "Afficher la fenêtre de partage" 51 | 52 | #: includes/template.php:445 53 | msgid "Copy and paste this URL into your site to embed:" 54 | msgstr "Copiez et collez cette Url dans votre site pour l'intégrer :" 55 | 56 | #: includes/template.php:455 57 | msgid "Close sharing dialog" 58 | msgstr "Fermer la fenêtre de partage" 59 | 60 | #. Plugin Name of the plugin/theme 61 | msgid "oEmbed API" 62 | msgstr "oEmbed API" 63 | 64 | #. Plugin URI of the plugin/theme 65 | msgid "https://github.com/swissspidy/oEmbed-API" 66 | msgstr "https://github.com/swissspidy/oEmbed-API" 67 | 68 | #. Description of the plugin/theme 69 | msgid "" 70 | "Allow others to easily embed your blog posts on their sites using oEmbed." 71 | msgstr "" 72 | "Permet à vos visiteurs d'intégrer vos articles de blog au sein de leur " 73 | "site via l'utilisation de oEmbed" 74 | 75 | #. Author of the plugin/theme 76 | msgid "Pascal Birchler" 77 | msgstr "Pascal Birchler" 78 | 79 | #. Author URI of the plugin/theme 80 | msgid "https://pascalbirchler.com" 81 | msgstr "https://pascalbirchler.com" 82 | 83 | #. translators: If your word count is based on single characters (e.g. East 84 | #. Asian characters), enter 'characters_excluding_spaces' or 85 | #. 'characters_including_spaces'. Otherwise, enter 'words'. Do not translate 86 | #. into your own language. 87 | #: includes/template.php:31 88 | msgctxt "Word count type. Do not translate!" 89 | msgid "words" 90 | msgstr "words" 91 | -------------------------------------------------------------------------------- /languages/oembed-api-he_IL.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swissspidy/oEmbed-API/b0b8b5fb14fcc3be541c6ea9510c81c10dd710ff/languages/oembed-api-he_IL.mo -------------------------------------------------------------------------------- /languages/oembed-api-he_IL.po: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 Pascal Birchler 2 | # This file is distributed under the GPLv2+. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: oEmbed API 0.6.0\n" 6 | "Report-Msgid-Bugs-To: https://pascalbirchler.com\n" 7 | "POT-Creation-Date: 2015-09-22 00:27+0300\n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=UTF-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "PO-Revision-Date: 2015-09-22 00:40+0300\n" 12 | "Language-Team: Rami Yushuvaev \n" 13 | "X-Generator: Poedit 1.8.4\n" 14 | "X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c\n" 15 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 16 | "X-Poedit-SourceCharset: UTF-8\n" 17 | "X-Poedit-Basepath: ..\n" 18 | "X-Textdomain-Support: yes\n" 19 | "Last-Translator: Rami Y \n" 20 | "Language: he_IL\n" 21 | "X-Poedit-SearchPath-0: .\n" 22 | 23 | #: includes/class-wp-rest-oembed-controller.php:62 24 | msgid "Invalid URL." 25 | msgstr "כתובת URL אינה תקינה." 26 | 27 | #: includes/class-wp-rest-oembed-controller.php:67 28 | msgid "Invalid format." 29 | msgstr "פורמט לא תקין" 30 | 31 | #: includes/functions.php:121 32 | msgid "Embedded WordPress Post" 33 | msgstr "הטמעת פוסטים" 34 | 35 | #: includes/template.php:37 36 | msgid "… (%d word)" 37 | msgid_plural "… (%d words)" 38 | msgstr[0] "… (מילה %d)" 39 | msgstr[1] "… (%d מילים)" 40 | 41 | #: includes/template.php:423 42 | msgid "%s Comment" 43 | msgid_plural "%s Comments" 44 | msgstr[0] "תגובה %s" 45 | msgstr[1] "%s תגובות" 46 | 47 | #: includes/template.php:436 48 | msgid "Open sharing dialog" 49 | msgstr "פתח דיאלוג שיתוף" 50 | 51 | #: includes/template.php:445 52 | msgid "Copy and paste this URL into your site to embed:" 53 | msgstr "להטמעה יש להעתיק ולהדביק כתובת URL זו באתר:" 54 | 55 | #: includes/template.php:455 56 | msgid "Close sharing dialog" 57 | msgstr "סגור דיאלוג שיתוף" 58 | 59 | #. Plugin Name of the plugin/theme 60 | msgid "oEmbed API" 61 | msgstr "oEmbed API" 62 | 63 | #. Plugin URI of the plugin/theme 64 | msgid "https://github.com/swissspidy/oEmbed-API" 65 | msgstr "https://github.com/swissspidy/oEmbed-API" 66 | 67 | #. Description of the plugin/theme 68 | msgid "Allow others to easily embed your blog posts on their sites using oEmbed." 69 | msgstr "אפשרו לאתרים אחרים להטמיע בקלות את הפוסטים שלכם באמצעות פרוטוקול oEmbed." 70 | 71 | #. Author of the plugin/theme 72 | msgid "Pascal Birchler" 73 | msgstr "פסקל בירצ'לר" 74 | 75 | #. Author URI of the plugin/theme 76 | msgid "https://pascalbirchler.com" 77 | msgstr "https://pascalbirchler.com" 78 | 79 | #. translators: If your word count is based on single characters (e.g. East 80 | #. Asian characters), enter 'characters_excluding_spaces' or 81 | #. 'characters_including_spaces'. Otherwise, enter 'words'. Do not translate 82 | #. into your own language. 83 | #: includes/template.php:31 84 | msgctxt "Word count type. Do not translate!" 85 | msgid "words" 86 | msgstr "words" 87 | -------------------------------------------------------------------------------- /languages/oembed-api-it_IT.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swissspidy/oEmbed-API/b0b8b5fb14fcc3be541c6ea9510c81c10dd710ff/languages/oembed-api-it_IT.mo -------------------------------------------------------------------------------- /languages/oembed-api-it_IT.po: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 Pascal Birchler 2 | # This file is distributed under the GPLv2+. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: oEmbed API 0.6.0\n" 6 | "Report-Msgid-Bugs-To: https://pascalbirchler.com\n" 7 | "POT-Creation-Date: 2015-09-19 14:14+0200\n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=UTF-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "PO-Revision-Date: 2015-09-19 14:27+0200\n" 12 | "Language-Team: Pascal Birchler \n" 13 | "X-Generator: Poedit 1.8.4\n" 14 | "X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c\n" 15 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 16 | "X-Poedit-SourceCharset: UTF-8\n" 17 | "X-Poedit-Basepath: ..\n" 18 | "X-Textdomain-Support: yes\n" 19 | "Last-Translator: Andrea Gandino \n" 20 | "Language: it\n" 21 | "X-Poedit-SearchPath-0: .\n" 22 | 23 | #: includes/class-wp-rest-oembed-controller.php:62 24 | msgid "Invalid URL." 25 | msgstr "URL non valido." 26 | 27 | #: includes/class-wp-rest-oembed-controller.php:67 28 | msgid "Invalid format." 29 | msgstr "Formato non valido." 30 | 31 | #: includes/functions.php:121 32 | msgid "Embedded WordPress Post" 33 | msgstr "Post di WordPress incorporato" 34 | 35 | #: includes/template.php:37 36 | msgid "… (%d word)" 37 | msgid_plural "… (%d words)" 38 | msgstr[0] "… (%d parola)" 39 | msgstr[1] "… (%d parole)" 40 | 41 | #: includes/template.php:423 42 | msgid "%s Comment" 43 | msgid_plural "%s Comments" 44 | msgstr[0] "%s Commento" 45 | msgstr[1] "%s Commenti" 46 | 47 | #: includes/template.php:436 48 | msgid "Open sharing dialog" 49 | msgstr "Apri la finestra di condivisione" 50 | 51 | #: includes/template.php:445 52 | msgid "Copy and paste this URL into your site to embed:" 53 | msgstr "Copia e incolla questo URL nel tuo sito per incorporare il post:" 54 | 55 | #: includes/template.php:455 56 | msgid "Close sharing dialog" 57 | msgstr "Chiudi la finestra di condivisione" 58 | 59 | #. Plugin Name of the plugin/theme 60 | msgid "oEmbed API" 61 | msgstr "oEmbed API" 62 | 63 | #. Plugin URI of the plugin/theme 64 | msgid "https://github.com/swissspidy/oEmbed-API" 65 | msgstr "https://github.com/swissspidy/oEmbed-API" 66 | 67 | #. Description of the plugin/theme 68 | msgid "Allow others to easily embed your blog posts on their sites using oEmbed." 69 | msgstr "Permetti che altri incorporino facilmente i tuoi post nei loro siti utilizzando oEmbed." 70 | 71 | #. Author of the plugin/theme 72 | msgid "Pascal Birchler" 73 | msgstr "Pascal Birchler" 74 | 75 | #. Author URI of the plugin/theme 76 | msgid "https://pascalbirchler.com" 77 | msgstr "https://pascalbirchler.com" 78 | 79 | #. translators: If your word count is based on single characters (e.g. East 80 | #. Asian characters), enter 'characters_excluding_spaces' or 81 | #. 'characters_including_spaces'. Otherwise, enter 'words'. Do not translate 82 | #. into your own language. 83 | #: includes/template.php:31 84 | msgctxt "Word count type. Do not translate!" 85 | msgid "words" 86 | msgstr "" 87 | -------------------------------------------------------------------------------- /languages/oembed-api-ja.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swissspidy/oEmbed-API/b0b8b5fb14fcc3be541c6ea9510c81c10dd710ff/languages/oembed-api-ja.mo -------------------------------------------------------------------------------- /languages/oembed-api-ja.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: oEmbed API\n" 4 | "Report-Msgid-Bugs-To: https://pascalbirchler.com\n" 5 | "POT-Creation-Date: 2015-10-02 02:00+0900\n" 6 | "PO-Revision-Date: 2015-10-02 02:18+0900\n" 7 | "Last-Translator: hinaloe \n" 8 | "Language-Team: Daisuke Takahashi, Hinaloe \n" 9 | "Language: ja\n" 10 | "MIME-Version: 1.0\n" 11 | "Content-Type: text/plain; charset=UTF-8\n" 12 | "Content-Transfer-Encoding: 8bit\n" 13 | "X-Generator: Poedit 1.8.1\n" 14 | "X-Poedit-Basepath: ..\n" 15 | "X-Poedit-WPHeader: wp-api-oembed.php\n" 16 | "Plural-Forms: nplurals=1; plural=0;\n" 17 | "X-Poedit-SourceCharset: UTF-8\n" 18 | "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;" 19 | "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;" 20 | "_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n" 21 | "X-Poedit-SearchPath-0: .\n" 22 | "X-Poedit-SearchPathExcluded-0: *.js\n" 23 | 24 | #: includes/class-wp-legacy-oembed-controller.php:87 25 | #: includes/class-wp-rest-oembed-controller.php:59 26 | msgid "Invalid URL." 27 | msgstr "無効な URL です。" 28 | 29 | #: includes/functions.php:127 30 | msgid "Embedded WordPress Post" 31 | msgstr "埋め込まれた WordPress の投稿" 32 | 33 | #: includes/functions.php:515 34 | msgid "Read more" 35 | msgstr "続きを読む" 36 | 37 | #: includes/template.php:628 38 | msgid "%s Comment" 39 | msgid_plural "%s Comments" 40 | msgstr[0] "%s 件のコメント" 41 | 42 | #: includes/template.php:642 43 | msgid "Open sharing dialog" 44 | msgstr "共有ダイアログを開く" 45 | 46 | #: includes/template.php:653 47 | msgid "WordPress Embed" 48 | msgstr "WordPressに埋め込む" 49 | 50 | #: includes/template.php:656 51 | msgid "HTML Embed" 52 | msgstr "HTMLで埋め込む" 53 | 54 | #: includes/template.php:663 55 | msgid "Copy and paste this URL into your WordPress site to embed" 56 | msgstr "埋め込むにはこのURLをコピーしてWordPressサイトに貼り付けてください。" 57 | 58 | #: includes/template.php:670 59 | msgid "Copy and paste this code into your site to embed" 60 | msgstr "埋め込むにはこのコードをコピーしてサイトに貼り付けてください。" 61 | 62 | #: includes/template.php:675 63 | msgid "Close sharing dialog" 64 | msgstr "共有ダイアログを閉じる" 65 | 66 | #: includes/template.php:684 67 | msgid "Page not found" 68 | msgstr "ページが見つかりません" 69 | 70 | #: includes/template.php:687 71 | msgid "Error 404! The requested content was not found." 72 | msgstr "エラー 404 リクエストされたページは見つかりませんでした。" 73 | 74 | #. Plugin Name of the plugin/theme 75 | msgid "oEmbed API" 76 | msgstr "oEmbed API" 77 | 78 | #. Plugin URI of the plugin/theme 79 | msgid "https://github.com/swissspidy/oEmbed-API" 80 | msgstr "https://github.com/swissspidy/oEmbed-API" 81 | 82 | #. Description of the plugin/theme 83 | msgid "" 84 | "Allow others to easily embed your blog posts on their sites using oEmbed." 85 | msgstr "" 86 | "oEmbed を使って、他の人がサイトにブログ投稿を簡単に埋め込めるようにします。" 87 | 88 | #. Author of the plugin/theme 89 | msgid "Pascal Birchler" 90 | msgstr "Pascal Birchler" 91 | 92 | #. Author URI of the plugin/theme 93 | msgid "https://pascalbirchler.com" 94 | msgstr "https://pascalbirchler.com" 95 | 96 | #: includes/functions.php:511 97 | msgctxt "read more link" 98 | msgid "… %s" 99 | msgstr "… %s" 100 | 101 | #~ msgid "Invalid format." 102 | #~ msgstr "無効な形式です。" 103 | 104 | #~ msgid "… (%d word)" 105 | #~ msgid_plural "… (%d words)" 106 | #~ msgstr[0] "… (%d 文字)" 107 | 108 | #~ msgid "Copy and paste this URL into your site to embed:" 109 | #~ msgstr "埋め込むにはこの URL をコピーして、サイトに貼り付けてください:" 110 | 111 | #~ msgctxt "Word count type. Do not translate!" 112 | #~ msgid "words" 113 | #~ msgstr "characters_including_spaces" 114 | -------------------------------------------------------------------------------- /languages/oembed-api.pot: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 Pascal Birchler 2 | # This file is distributed under the GPLv2+. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: oEmbed API 0.9.0\n" 6 | "Report-Msgid-Bugs-To: https://pascalbirchler.com\n" 7 | "POT-Creation-Date: 2015-07-27 13:00:02+00:00\n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=utf-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n" 12 | "Last-Translator: Pascal Birchler\n" 13 | "Language-Team: Pascal Birchler \n" 14 | "X-Generator: grunt-wp-i18n 0.5.2\n" 15 | "X-Poedit-KeywordsList: " 16 | "__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_" 17 | "attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n" 18 | "Language: en\n" 19 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 20 | "X-Poedit-Country: Switzerland\n" 21 | "X-Poedit-SourceCharset: UTF-8\n" 22 | "X-Poedit-Basepath: ../\n" 23 | "X-Poedit-SearchPath-0: .\n" 24 | "X-Poedit-Bookmarks: \n" 25 | "X-Textdomain-Support: yes\n" 26 | 27 | #: includes/class-wp-legacy-oembed-controller.php:87 28 | #: includes/class-wp-rest-oembed-controller.php:59 29 | msgid "Invalid URL." 30 | msgstr "" 31 | 32 | #: includes/functions.php:127 33 | msgid "Embedded WordPress Post" 34 | msgstr "" 35 | 36 | #: includes/functions.php:492 37 | msgid "Read more" 38 | msgstr "" 39 | 40 | #: includes/template.php:599 41 | msgid "%s Comment" 42 | msgid_plural "%s Comments" 43 | msgstr[0] "" 44 | msgstr[1] "" 45 | 46 | #: includes/template.php:613 47 | msgid "Open sharing dialog" 48 | msgstr "" 49 | 50 | #: includes/template.php:624 51 | msgid "WordPress Embed" 52 | msgstr "" 53 | 54 | #: includes/template.php:627 55 | msgid "HTML Embed" 56 | msgstr "" 57 | 58 | #: includes/template.php:634 59 | msgid "Copy and paste this URL into your WordPress site to embed" 60 | msgstr "" 61 | 62 | #: includes/template.php:641 63 | msgid "Copy and paste this code into your site to embed" 64 | msgstr "" 65 | 66 | #: includes/template.php:646 67 | msgid "Close sharing dialog" 68 | msgstr "" 69 | 70 | #: includes/template.php:655 71 | msgid "Page not found" 72 | msgstr "" 73 | 74 | #: includes/template.php:658 75 | msgid "Error 404! The requested content was not found." 76 | msgstr "" 77 | 78 | #. Plugin Name of the plugin/theme 79 | msgid "oEmbed API" 80 | msgstr "" 81 | 82 | #. Plugin URI of the plugin/theme 83 | msgid "https://github.com/swissspidy/oEmbed-API" 84 | msgstr "" 85 | 86 | #. Description of the plugin/theme 87 | msgid "Allow others to easily embed your blog posts on their sites using oEmbed." 88 | msgstr "" 89 | 90 | #. Author of the plugin/theme 91 | msgid "Pascal Birchler" 92 | msgstr "" 93 | 94 | #. Author URI of the plugin/theme 95 | msgid "https://pascalbirchler.com" 96 | msgstr "" 97 | 98 | #: includes/functions.php:488 99 | msgctxt "read more link" 100 | msgid "… %s" 101 | msgstr "" -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "oembed-api", 3 | "title": "oEmbed API", 4 | "description": "Allow others to easily embed your blog posts on their sites using oEmbed.", 5 | "version": "0.6.0", 6 | "homepage": "https://github.com/swissspidy/oEmbed-API", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/swissspidy/oEmbed-API" 10 | }, 11 | "devDependencies": { 12 | "grunt": "~0.4.5", 13 | "grunt-checktextdomain": "~1.0.0", 14 | "grunt-contrib-watch": "~0.6.1", 15 | "grunt-exec": "~0.4.6", 16 | "grunt-wp-i18n": "~0.5.1", 17 | "load-grunt-config": "~0.16.0", 18 | "time-grunt": "~1.1.0" 19 | }, 20 | "keywords": [] 21 | } 22 | -------------------------------------------------------------------------------- /phpcs.ruleset.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sniffs for the coding standards of the oEmbed-API plugin 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /phpunit.multisite.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | tests/ 15 | 16 | 17 | 18 | 19 | 20 | . 21 | 22 | 23 | ./includes 24 | ./wp-api-oembed.php 25 | 26 | ./includes/default-filters.php 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | tests/ 12 | 13 | 14 | 15 | 16 | 17 | . 18 | 19 | 20 | ./includes 21 | ./wp-api-oembed.php 22 | 23 | ./includes/default-filters.php 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /scripts/frontend.js: -------------------------------------------------------------------------------- 1 | (function ( window, document ) { 2 | 'use strict'; 3 | 4 | window.wp = window.wp || {}; 5 | 6 | if ( !! window.wp.receiveEmbedMessage ) { 7 | return; 8 | } 9 | 10 | window.wp.receiveEmbedMessage = function( e ) { 11 | if ( ! ( e.data.secret || e.data.message || e.data.value ) ) { 12 | return; 13 | } 14 | 15 | var iframes = document.querySelectorAll( '.wp-embedded-content[data-secret="' + e.data.secret + '"]' ); 16 | 17 | for ( var i = 0; i < iframes.length; i++ ) { 18 | var source = iframes[ i ]; 19 | 20 | /* Resize the iframe on request. */ 21 | if ( 'height' === e.data.message ) { 22 | var height = e.data.value; 23 | if ( height > 1000 ) { 24 | height = 1000; 25 | } else if ( height < 200 ) { 26 | height = 200; 27 | } 28 | 29 | source.height = (height) + "px"; 30 | } 31 | 32 | /* Link to a specific URL on request. */ 33 | if ( 'link' === e.data.message ) { 34 | var sourceURL = document.createElement( 'a' ), targetURL = document.createElement( 'a' ); 35 | sourceURL.href = source.getAttribute( 'src' ); 36 | targetURL.href = e.data.value; 37 | 38 | /* Only continue if link hostname matches iframe's hostname. */ 39 | if ( targetURL.host === sourceURL.host && document.activeElement === source ) { 40 | window.top.location.href = e.data.value; 41 | } 42 | } 43 | } 44 | } 45 | 46 | window.addEventListener( 'message', window.wp.receiveEmbedMessage, false ); 47 | 48 | function onLoad() { 49 | var isIE10 = 10 === new Function( "/*@cc_on return @_jscript_version; @*/" )(), 50 | isIE11 = !!navigator.userAgent.match( /Trident.*rv\:11\./ ); 51 | 52 | /* Remove security attribute from iframes in IE10 and IE11. */ 53 | if ( isIE10 || isIE11 ) { 54 | var iframes = document.querySelectorAll( '.wp-embedded-content[security]' ), iframeClone; 55 | 56 | for ( var i = 0; i < iframes.length; i++ ) { 57 | iframeClone = iframes[ i ].cloneNode( true ); 58 | iframeClone.removeAttribute( 'security' ); 59 | iframes[ i ].parentNode.insertBefore( iframeClone, iframes[ i ].nextSibling ); 60 | iframes[ i ].parentNode.removeChild( iframes[ i ] ); 61 | } 62 | } 63 | } 64 | 65 | document.addEventListener( 'DOMContentLoaded', onLoad, false ); 66 | })( window, document ); 67 | -------------------------------------------------------------------------------- /scripts/tinymce-plugin.js: -------------------------------------------------------------------------------- 1 | (function ( tinymce ) { 2 | 'use strict'; 3 | 4 | tinymce.PluginManager.add( 'wp-oembed', function ( editor, url ) { 5 | editor.on( 'init', function () { 6 | var scriptId = editor.dom.uniqueId(); 7 | 8 | var scriptElm = editor.dom.create( 'script', { 9 | id: scriptId, 10 | type: 'text/javascript', 11 | src: url + '/frontend.js' 12 | } ); 13 | 14 | editor.getDoc().getElementsByTagName( 'head' )[ 0 ].appendChild( scriptElm ); 15 | } ); 16 | } ); 17 | })( window.tinymce ); 18 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | publicly_queryable || ( $post_type_object->_builtin && $post_type_object->public ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tests/test-frontend.php: -------------------------------------------------------------------------------- 1 | assertEquals( '', wp_oembed_include_template( '' ) ); 17 | 18 | $post_id = $this->factory->post->create(); 19 | $this->go_to( get_post_embed_url( $post_id ) ); 20 | 21 | $this->assertQueryTrue( 'is_single', 'is_singular' ); 22 | $this->assertEquals( dirname( plugin_dir_path( __FILE__ ) ) . '/includes/template.php', wp_oembed_include_template( '' ) ); 23 | } 24 | 25 | /** 26 | * Test discovery links. 27 | */ 28 | function test_add_oembed_discovery_links_non_singular() { 29 | ob_start(); 30 | wp_oembed_add_discovery_links(); 31 | $actual = ob_get_clean(); 32 | $this->assertSame( '', $actual ); 33 | } 34 | 35 | /** 36 | * Test discovery links on a single post. 37 | */ 38 | function test_add_oembed_discovery_links() { 39 | $post_id = $this->factory->post->create(); 40 | $this->go_to( get_permalink( $post_id ) ); 41 | 42 | $this->assertQueryTrue( 'is_single', 'is_singular' ); 43 | 44 | ob_start(); 45 | wp_oembed_add_discovery_links(); 46 | $actual = ob_get_clean(); 47 | 48 | $expected = '' . "\n"; 49 | $expected .= '' . "\n"; 50 | 51 | $this->assertEquals( $expected, $actual ); 52 | } 53 | 54 | /** 55 | * Test trusted HTML. 56 | */ 57 | function test_filter_oembed_result_trusted() { 58 | $html = '

'; 59 | 60 | $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' ); 61 | 62 | $this->assertEquals( $html, $actual ); 63 | } 64 | 65 | /** 66 | * Test untrusted HTML. 67 | */ 68 | function test_filter_oembed_result_untrusted() { 69 | $html = '

'; 70 | $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), 'http://example.com/sample-page/' ); 71 | 72 | $matches = array(); 73 | preg_match( '|src=".*#\?secret=([\w\d]+)" data-secret="([\w\d]+)"|', $actual, $matches ); 74 | 75 | $this->assertTrue( isset( $matches[1] ) ); 76 | $this->assertTrue( isset( $matches[2] ) ); 77 | $this->assertEquals( $matches[1], $matches[2] ); 78 | } 79 | 80 | /** 81 | * Test that only 1 iframe is allowed, nothing else. 82 | */ 83 | function test_filter_oembed_result_multiple_tags() { 84 | $html = '

'; 85 | $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ); 86 | 87 | $this->assertEquals( '', $actual ); 88 | } 89 | 90 | /** 91 | * Test that only 1 iframe is allowed, nothing else. 92 | */ 93 | function test_filter_oembed_result_newlines() { 94 | $html = <<var = 1; 96 | 97 | 98 |

99 | EOD; 100 | 101 | $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ); 102 | 103 | $this->assertEquals( '', $actual ); 104 | } 105 | 106 | /** 107 | * Test untrusted HTML without iframe. 108 | */ 109 | function test_filter_oembed_result_no_iframe() { 110 | $html = 'Hello

World

'; 111 | $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ); 112 | 113 | $this->assertFalse( $actual ); 114 | 115 | $html = '

'; 116 | $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ); 117 | 118 | $this->assertFalse( $actual ); 119 | } 120 | 121 | /** 122 | * Test if the secret is appended to the URL. 123 | */ 124 | function test_filter_oembed_result_secret() { 125 | $html = ''; 126 | $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ); 127 | 128 | $matches = array(); 129 | preg_match( '|src="https://wordpress.org#\?secret=([\w\d]+)" data-secret="([\w\d]+)"|', $actual, $matches ); 130 | 131 | $this->assertTrue( isset( $matches[1] ) ); 132 | $this->assertTrue( isset( $matches[2] ) ); 133 | $this->assertEquals( $matches[1], $matches[2] ); 134 | } 135 | 136 | /** 137 | * Test what happens when a wrong type is passed. 138 | */ 139 | function test_filter_oembed_result_wrong_type() { 140 | $actual = wp_filter_oembed_result( 'some string', (object) array( 'type' => 'link' ), '' ); 141 | 142 | $this->assertEquals( 'some string', $actual ); 143 | } 144 | 145 | /** 146 | * Test what happens when there isn't a result 147 | */ 148 | function test_filter_oembed_result_false() { 149 | $this->assertFalse( wp_filter_oembed_result( false, (object) array( 'type' => 'rich' ), '' ) ); 150 | } 151 | 152 | /** 153 | * Test add_host_js method. 154 | */ 155 | function test_add_host_js() { 156 | ob_start(); 157 | wp_oembed_add_host_js(); 158 | ob_end_clean(); 159 | 160 | $this->assertTrue( wp_script_is( 'wp-oembed' ) ); 161 | } 162 | 163 | /** 164 | * Test default oEmbed output for a post. 165 | */ 166 | function test_oembed_output() { 167 | $user = $this->factory->user->create_and_get( array( 168 | 'display_name' => 'John Doe', 169 | ) ); 170 | 171 | $post_id = $this->factory->post->create( array( 172 | 'post_author' => $user->ID, 173 | 'post_title' => 'Hello World', 174 | 'post_content' => 'Foo Bar', 175 | 'post_excerpt' => 'Bar Baz', 176 | ) ); 177 | $this->go_to( get_post_embed_url( $post_id ) ); 178 | 179 | $this->assertQueryTrue( 'is_single', 'is_singular' ); 180 | 181 | ob_start(); 182 | include( dirname( plugin_dir_path( __FILE__ ) ) . '/includes/template.php' ); 183 | $actual = ob_get_clean(); 184 | 185 | $doc = new DOMDocument(); 186 | $this->assertTrue( $doc->loadHTML( $actual ) ); 187 | $this->assertTrue( false === strpos( $actual, 'Page not found' ) ); 188 | $this->assertTrue( false !== strpos( $actual, 'Hello World' ) ); 189 | } 190 | 191 | /** 192 | * Test oEmbed output for a post with a thumbnail. 193 | */ 194 | function test_oembed_output_thumbnail() { 195 | $post_id = $this->factory->post->create( array( 196 | 'post_title' => 'Hello World', 197 | 'post_content' => 'Foo Bar', 198 | 'post_excerpt' => 'Bar Baz', 199 | ) ); 200 | $file = DIR_TESTDATA . '/images/canola.jpg'; 201 | $attachment_id = $this->factory->attachment->create_object( $file, $post_id, array( 202 | 'post_mime_type' => 'image/jpeg', 203 | ) ); 204 | set_post_thumbnail( $post_id, $attachment_id ); 205 | 206 | $this->go_to( get_post_embed_url( $post_id ) ); 207 | 208 | $this->assertQueryTrue( 'is_single', 'is_singular' ); 209 | 210 | ob_start(); 211 | include( dirname( plugin_dir_path( __FILE__ ) ) . '/includes/template.php' ); 212 | $actual = ob_get_clean(); 213 | 214 | $doc = new DOMDocument(); 215 | $this->assertTrue( $doc->loadHTML( $actual ) ); 216 | $this->assertFalse( strpos( $actual, 'Page not found' ) ); 217 | $this->assertTrue( false !== strpos( $actual, 'Hello World' ) ); 218 | $this->assertTrue( false !== strpos( $actual, 'canola.jpg' ) ); 219 | } 220 | 221 | /** 222 | * Test oEmbed output for a non-existent post. 223 | */ 224 | function test_oembed_output_404() { 225 | $this->go_to( home_url( '/?p=123&embed=true' ) ); 226 | $GLOBALS['wp_query']->query_vars['embed'] = true; 227 | 228 | $this->assertQueryTrue( 'is_404' ); 229 | 230 | $this->assertEquals( dirname( plugin_dir_path( __FILE__ ) ) . '/includes/template.php', wp_oembed_include_template( '' ) ); 231 | 232 | ob_start(); 233 | include( dirname( plugin_dir_path( __FILE__ ) ) . '/includes/template.php' ); 234 | $actual = ob_get_clean(); 235 | 236 | $doc = new DOMDocument(); 237 | $this->assertTrue( $doc->loadHTML( $actual ) ); 238 | $this->assertTrue( false !== strpos( $actual, 'Page not found' ) ); 239 | } 240 | 241 | /** 242 | * Test oEmbed output for an attachment. 243 | */ 244 | function test_oembed_output_attachment() { 245 | $post = $this->factory->post->create_and_get(); 246 | $file = DIR_TESTDATA . '/images/canola.jpg'; 247 | $attachment_id = $this->factory->attachment->create_object( $file, $post->ID, array( 248 | 'post_mime_type' => 'image/jpeg', 249 | 'post_title' => 'Hello World', 250 | 'post_content' => 'Foo Bar', 251 | 'post_excerpt' => 'Bar Baz', 252 | ) ); 253 | 254 | $this->go_to( get_post_embed_url( $attachment_id ) ); 255 | 256 | $this->assertQueryTrue( 'is_single', 'is_singular', 'is_attachment' ); 257 | 258 | ob_start(); 259 | include( dirname( plugin_dir_path( __FILE__ ) ) . '/includes/template.php' ); 260 | $actual = ob_get_clean(); 261 | 262 | $doc = new DOMDocument(); 263 | $this->assertTrue( $doc->loadHTML( $actual ) ); 264 | $this->assertFalse( strpos( $actual, 'Page not found' ) ); 265 | $this->assertTrue( false !== strpos( $actual, 'Hello World' ) ); 266 | $this->assertTrue( false !== strpos( $actual, 'canola.jpg' ) ); 267 | } 268 | 269 | /** 270 | * Test oEmbed output for a draft post. 271 | */ 272 | function test_oembed_output_draft_post() { 273 | $post_id = $this->factory->post->create( array( 274 | 'post_title' => 'Hello World', 275 | 'post_content' => 'Foo Bar', 276 | 'post_excerpt' => 'Bar Baz', 277 | 'post_status' => 'draft', 278 | ) ); 279 | 280 | $this->go_to( get_post_embed_url( $post_id ) ); 281 | 282 | $this->assertQueryTrue( 'is_404' ); 283 | $this->assertEquals( dirname( plugin_dir_path( __FILE__ ) ) . '/includes/template.php', wp_oembed_include_template( '' ) ); 284 | 285 | ob_start(); 286 | include( dirname( plugin_dir_path( __FILE__ ) ) . '/includes/template.php' ); 287 | $actual = ob_get_clean(); 288 | 289 | $doc = new DOMDocument(); 290 | $this->assertTrue( $doc->loadHTML( $actual ) ); 291 | $this->assertTrue( false !== strpos( $actual, 'Page not found' ) ); 292 | } 293 | 294 | /** 295 | * Test oEmbed output for a scheduled post. 296 | */ 297 | function test_oembed_output_scheduled_post() { 298 | $post_id = $this->factory->post->create( array( 299 | 'post_title' => 'Hello World', 300 | 'post_content' => 'Foo Bar', 301 | 'post_excerpt' => 'Bar Baz', 302 | 'post_status' => 'future', 303 | 'post_date' => strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 day' ) ), 304 | ) ); 305 | 306 | $this->go_to( get_post_embed_url( $post_id ) ); 307 | 308 | $this->assertQueryTrue( 'is_404' ); 309 | $this->assertEquals( dirname( plugin_dir_path( __FILE__ ) ) . '/includes/template.php', wp_oembed_include_template( '' ) ); 310 | 311 | ob_start(); 312 | include( dirname( plugin_dir_path( __FILE__ ) ) . '/includes/template.php' ); 313 | $actual = ob_get_clean(); 314 | 315 | $doc = new DOMDocument(); 316 | $this->assertTrue( $doc->loadHTML( $actual ) ); 317 | $this->assertTrue( false !== strpos( $actual, 'Page not found' ) ); 318 | } 319 | 320 | /** 321 | * Test oEmbed output for a private post. 322 | */ 323 | function test_oembed_output_private_post() { 324 | $post_id = $this->factory->post->create( array( 325 | 'post_title' => 'Hello World', 326 | 'post_content' => 'Foo Bar', 327 | 'post_excerpt' => 'Bar Baz', 328 | 'post_status' => 'private', 329 | ) ); 330 | 331 | $this->go_to( get_post_embed_url( $post_id ) ); 332 | 333 | $this->assertQueryTrue( 'is_404' ); 334 | $this->assertEquals( dirname( plugin_dir_path( __FILE__ ) ) . '/includes/template.php', wp_oembed_include_template( '' ) ); 335 | 336 | ob_start(); 337 | include( dirname( plugin_dir_path( __FILE__ ) ) . '/includes/template.php' ); 338 | $actual = ob_get_clean(); 339 | 340 | $doc = new DOMDocument(); 341 | $this->assertTrue( $doc->loadHTML( $actual ) ); 342 | $this->assertTrue( false !== strpos( $actual, 'Page not found' ) ); 343 | } 344 | 345 | /** 346 | * Test oEmbed output for a private post as an editor. 347 | */ 348 | function test_oembed_output_private_post_with_permissions() { 349 | $user_id = $this->factory->user->create( array( 'role' => 'editor' ) ); 350 | wp_set_current_user( $user_id ); 351 | 352 | $post_id = $this->factory->post->create( array( 353 | 'post_title' => 'Hello World', 354 | 'post_content' => 'Foo Bar', 355 | 'post_excerpt' => 'Bar Baz', 356 | 'post_status' => 'private', 357 | 'post_author' => $user_id, 358 | ) ); 359 | 360 | $this->go_to( get_post_embed_url( $post_id ) ); 361 | 362 | $this->assertQueryTrue( 'is_single', 'is_singular' ); 363 | $this->assertEquals( dirname( plugin_dir_path( __FILE__ ) ) . '/includes/template.php', wp_oembed_include_template( '' ) ); 364 | 365 | ob_start(); 366 | include( dirname( plugin_dir_path( __FILE__ ) ) . '/includes/template.php' ); 367 | $actual = ob_get_clean(); 368 | 369 | $doc = new DOMDocument(); 370 | $this->assertTrue( $doc->loadHTML( $actual ) ); 371 | $this->assertTrue( false === strpos( $actual, 'Page not found' ) ); 372 | $this->assertTrue( false !== strpos( $actual, 'Hello World' ) ); 373 | } 374 | 375 | /** 376 | * Test if registering our script works. 377 | */ 378 | function test_register_scripts() { 379 | wp_scripts()->remove( 'wp-oembed' ); 380 | $this->assertFalse( wp_script_is( 'wp-oembed', 'registered' ) ); 381 | 382 | wp_oembed_register_scripts(); 383 | $this->assertTrue( wp_script_is( 'wp-oembed', 'registered' ) ); 384 | } 385 | 386 | /** 387 | * Test adding the TinyMCE plugin. 388 | */ 389 | function test_add_mce_plugin() { 390 | $actual = wp_oembed_add_mce_plugin( array() ); 391 | 392 | $this->assertEquals( array( 'wp-oembed' => plugins_url( 'scripts/tinymce-plugin.js', dirname( __FILE__ ) ) ), $actual ); 393 | } 394 | 395 | /** 396 | * Test the excerpt. 397 | */ 398 | function test_wp_oembed_excerpt_more_no_embed() { 399 | $GLOBALS['wp_query'] = new WP_Query(); 400 | 401 | $this->assertEquals( 'foo bar', wp_oembed_excerpt_more( 'foo bar' ) ); 402 | } 403 | 404 | /** 405 | * Test excerpt function. 406 | */ 407 | function test_wp_oembed_excerpt_more() { 408 | $post_id = $this->factory->post->create( array( 409 | 'post_content' => 'Foo Bar', 410 | ) ); 411 | 412 | $this->assertEquals( '', wp_oembed_excerpt_more( '' ) ); 413 | 414 | $this->go_to( get_post_embed_url( $post_id ) ); 415 | 416 | $actual = wp_oembed_excerpt_more( '' ); 417 | 418 | $expected = sprintf( 419 | '… Read more', 420 | get_the_permalink() 421 | ); 422 | 423 | $this->assertEquals( $expected, $actual ); 424 | } 425 | } 426 | -------------------------------------------------------------------------------- /tests/test-headers.php: -------------------------------------------------------------------------------- 1 | markTestSkipped( 'xdebug is required for this test' ); 20 | } 21 | 22 | $post = $this->factory->post->create_and_get( array( 23 | 'post_title' => 'Hello World', 24 | ) ); 25 | 26 | $request = array( 27 | 'url' => get_permalink( $post->ID ), 28 | 'format' => 'json', 29 | 'maxwidth' => 600, 30 | 'callback' => '', 31 | ); 32 | 33 | $legacy_controller = new WP_oEmbed_Controller(); 34 | $legacy_controller->dispatch( $request ); 35 | 36 | $headers = xdebug_get_headers(); 37 | 38 | $this->assertTrue( in_array( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), $headers ) ); 39 | $this->assertTrue( in_array( 'X-Content-Type-Options: nosniff', $headers ) ); 40 | 41 | $request['callback'] = 'foobar'; 42 | 43 | $legacy_controller->dispatch( $request ); 44 | 45 | $headers = xdebug_get_headers(); 46 | 47 | $this->assertTrue( in_array( 'Content-Type: application/javascript; charset=' . get_option( 'blog_charset' ), $headers ) ); 48 | $this->assertTrue( in_array( 'X-Content-Type-Options: nosniff', $headers ) ); 49 | } 50 | 51 | /** 52 | * Test the HTTP headers set by the xml_response method. 53 | */ 54 | function test_request_xml_response_headers() { 55 | if ( ! function_exists( 'xdebug_get_headers' ) ) { 56 | $this->markTestSkipped( 'xdebug is required for this test' ); 57 | } 58 | 59 | $post = $this->factory->post->create_and_get( array( 60 | 'post_title' => 'Hello World', 61 | ) ); 62 | 63 | $request = array( 64 | 'url' => get_permalink( $post->ID ), 65 | 'format' => 'xml', 66 | 'maxwidth' => 600, 67 | ); 68 | 69 | $legacy_controller = new WP_oEmbed_Controller(); 70 | $legacy_controller->dispatch( $request ); 71 | 72 | $headers = xdebug_get_headers(); 73 | 74 | $this->assertTrue( in_array( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), $headers ) ); 75 | } 76 | 77 | /** 78 | * Test HTTP headers set by the rest_pre_serve_request method. 79 | */ 80 | function test_rest_pre_serve_request_headers() { 81 | if ( ! function_exists( 'xdebug_get_headers' ) ) { 82 | $this->markTestSkipped( 'xdebug is required for this test' ); 83 | } 84 | 85 | require_once( dirname( __FILE__ ) . '/../vendor/json-rest-api/plugin.php' ); 86 | require_once( dirname( __FILE__ ) . '/../includes/class-wp-rest-oembed-controller.php' ); 87 | 88 | $user = $this->factory->user->create_and_get( array( 89 | 'display_name' => 'John Doe', 90 | ) ); 91 | $post = $this->factory->post->create_and_get( array( 92 | 'post_author' => $user->ID, 93 | 'post_title' => 'Hello World', 94 | ) ); 95 | 96 | $request = new WP_REST_Request( 'GET', '/wp/v2/oembed' ); 97 | $request->set_param( 'url', get_permalink( $post->ID ) ); 98 | $request->set_param( 'format', 'xml' ); 99 | 100 | $server = new WP_REST_Server; 101 | 102 | $response = $server->dispatch( $request ); 103 | 104 | ob_start(); 105 | _oembed_rest_pre_serve_request( true, $response, $request, $server ); 106 | $output = ob_get_clean(); 107 | 108 | $this->assertNotEmpty( $output ); 109 | 110 | $headers = xdebug_get_headers(); 111 | 112 | $this->assertTrue( in_array( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), $headers ) ); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /tests/test-plugin.php: -------------------------------------------------------------------------------- 1 | assertTrue( function_exists( 'wp_oembed_rewrite_endpoint' ) ); 17 | } 18 | 19 | /** 20 | * Test if the register_rest_route function exists. 21 | */ 22 | function test_rest_api_available() { 23 | $this->assertFalse( function_exists( 'register_rest_route' ) ); 24 | } 25 | 26 | /** 27 | * Ensure our rewrite endpoint is there. 28 | */ 29 | function test_rewrite_endpoint() { 30 | global $wp_rewrite; 31 | 32 | unset( $wp_rewrite->endpoints ); 33 | wp_oembed_rewrite_endpoint(); 34 | 35 | $this->assertEquals( EP_PERMALINK | EP_PAGES | EP_ATTACHMENT, $wp_rewrite->endpoints[0][0] ); 36 | $this->assertEquals( 'embed', $wp_rewrite->endpoints[0][1] ); 37 | $this->assertEquals( 'embed', $wp_rewrite->endpoints[0][2] ); 38 | } 39 | 40 | /** 41 | * Test the get_post_embed_url function. 42 | */ 43 | function test_get_post_embed_url_non_existent_post() { 44 | $embed_url = get_post_embed_url( 0 ); 45 | $this->assertFalse( $embed_url ); 46 | } 47 | 48 | /** 49 | * Test the get_post_embed_url function. 50 | */ 51 | function test_get_post_embed_url() { 52 | update_option( 'permalink_structure', '/%postname%' ); 53 | 54 | $post_id = $this->factory->post->create(); 55 | $permalink = get_permalink( $post_id ); 56 | $embed_url = get_post_embed_url( $post_id ); 57 | 58 | $this->assertEquals( user_trailingslashit( trailingslashit( $permalink ) . 'embed' ), $embed_url ); 59 | 60 | update_option( 'permalink_structure', '' ); 61 | } 62 | 63 | /** 64 | * Test the get_post_embed_url function. 65 | */ 66 | function test_get_post_embed_url_pretty_permalinks() { 67 | $post_id = $this->factory->post->create(); 68 | $permalink = get_permalink( $post_id ); 69 | $embed_url = get_post_embed_url( $post_id ); 70 | 71 | $this->assertEquals( $permalink . '&embed=true', $embed_url ); 72 | } 73 | 74 | /** 75 | * Test the get_post_embed_html function. 76 | */ 77 | function test_get_post_embed_html_non_existent_post() { 78 | $this->assertFalse( get_post_embed_html( 0, 200, 200 ) ); 79 | $this->assertFalse( get_post_embed_html( null, 200, 200 ) ); 80 | } 81 | 82 | /** 83 | * Test the get_post_embed_html function. 84 | */ 85 | function test_get_post_embed_html() { 86 | $post_id = $this->factory->post->create(); 87 | 88 | $expected = ''; 89 | 90 | $this->assertStringEndsWith( $expected, get_post_embed_html( $post_id, 200, 200 ) ); 91 | } 92 | 93 | /** 94 | * Test get_oembed_response_data with a post that doesn't exist. 95 | */ 96 | function test_get_oembed_response_data_non_existent_post() { 97 | $this->assertFalse( get_oembed_response_data( 0, 100 ) ); 98 | } 99 | 100 | /** 101 | * Test get_oembed_response_data normally. 102 | */ 103 | function test_get_oembed_response_data() { 104 | $post = $this->factory->post->create_and_get( array( 105 | 'post_title' => 'Some Post', 106 | ) ); 107 | 108 | $data = get_oembed_response_data( $post, 400 ); 109 | 110 | $this->assertEqualSets( array( 111 | 'version' => '1.0', 112 | 'provider_name' => get_bloginfo( 'name' ), 113 | 'provider_url' => get_home_url( '/' ), 114 | 'author_name' => get_bloginfo( 'name' ), 115 | 'author_url' => get_home_url( '/' ), 116 | 'title' => 'Some Post', 117 | 'type' => 'rich', 118 | 'width' => 400, 119 | 'height' => 225, 120 | 'html' => get_post_embed_html( $post, 400, 225 ), 121 | ), $data ); 122 | } 123 | 124 | /** 125 | * Test get_oembed_response_data with an author. 126 | */ 127 | function test_get_oembed_response_data_author() { 128 | $user_id = $this->factory->user->create( array( 129 | 'display_name' => 'John Doe', 130 | ) ); 131 | 132 | $post = $this->factory->post->create_and_get( array( 133 | 'post_title' => 'Some Post', 134 | 'post_author' => $user_id, 135 | ) ); 136 | 137 | $data = get_oembed_response_data( $post, 400 ); 138 | 139 | $this->assertEqualSets( array( 140 | 'version' => '1.0', 141 | 'provider_name' => get_bloginfo( 'name' ), 142 | 'provider_url' => get_home_url( '/' ), 143 | 'author_name' => 'John Doe', 144 | 'author_url' => get_author_posts_url( $user_id ), 145 | 'title' => 'Some Post', 146 | 'type' => 'rich', 147 | 'width' => 400, 148 | 'height' => 225, 149 | 'html' => get_post_embed_html( $post, 400, 225 ), 150 | ), $data ); 151 | } 152 | 153 | /** 154 | * Test get_oembed_response_data normally. 155 | */ 156 | function test_get_oembed_response_link() { 157 | remove_filter( 'oembed_response_data', 'get_oembed_response_data_rich' ); 158 | 159 | $post = $this->factory->post->create_and_get( array( 160 | 'post_title' => 'Some Post', 161 | ) ); 162 | 163 | $data = get_oembed_response_data( $post, 600 ); 164 | 165 | $this->assertEqualSets( array( 166 | 'version' => '1.0', 167 | 'provider_name' => get_bloginfo( 'name' ), 168 | 'provider_url' => get_home_url( '/' ), 169 | 'author_name' => get_bloginfo( 'name' ), 170 | 'author_url' => get_home_url( '/' ), 171 | 'title' => 'Some Post', 172 | 'type' => 'link', 173 | ), $data ); 174 | 175 | add_filter( 'oembed_response_data', 'get_oembed_response_data_rich', 10, 4 ); 176 | } 177 | 178 | /** 179 | * Test get_oembed_response_data for a draft post. 180 | */ 181 | function test_get_oembed_response_data_draft_post() { 182 | $post = $this->factory->post->create_and_get( array( 183 | 'post_status' => 'draft', 184 | ) ); 185 | 186 | $this->assertFalse( get_oembed_response_data( $post, 100 ) ); 187 | } 188 | 189 | /** 190 | * Test get_oembed_response_data for a scheduled post. 191 | */ 192 | function test_get_oembed_response_data_scheduled_post() { 193 | $post = $this->factory->post->create_and_get( array( 194 | 'post_status' => 'future', 195 | 'post_date' => strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 day' ) ), 196 | ) ); 197 | 198 | $this->assertFalse( get_oembed_response_data( $post, 100 ) ); 199 | } 200 | 201 | /** 202 | * Test get_oembed_response_data for a private post. 203 | */ 204 | function test_get_oembed_response_data_private_post() { 205 | $post = $this->factory->post->create_and_get( array( 206 | 'post_status' => 'private', 207 | ) ); 208 | 209 | $this->assertFalse( get_oembed_response_data( $post, 100 ) ); 210 | } 211 | 212 | /** 213 | * Test get_oembed_response_data with a maxwidth that is too high. 214 | */ 215 | function test_get_oembed_response_data_maxwidth_too_high() { 216 | $post = $this->factory->post->create_and_get(); 217 | 218 | $data = get_oembed_response_data( $post, 1000 ); 219 | 220 | $this->assertEquals( 600, $data['width'] ); 221 | $this->assertEquals( 338, $data['height'] ); 222 | } 223 | 224 | /** 225 | * Test get_oembed_response_data with a maxwidth that is too low. 226 | */ 227 | function test_get_oembed_response_data_maxwidth_too_low() { 228 | $post = $this->factory->post->create_and_get(); 229 | 230 | $data = get_oembed_response_data( $post, 100 ); 231 | 232 | $this->assertEquals( 200, $data['width'] ); 233 | $this->assertEquals( 200, $data['height'] ); 234 | } 235 | 236 | /** 237 | * Test get_oembed_response_data with a post thumbnail. 238 | */ 239 | function test_get_oembed_response_data_thumbnail() { 240 | $post = $this->factory->post->create_and_get(); 241 | $file = DIR_TESTDATA . '/images/canola.jpg'; 242 | $attachment_id = $this->factory->attachment->create_object( $file, $post->ID, array( 243 | 'post_mime_type' => 'image/jpeg', 244 | ) ); 245 | set_post_thumbnail( $post, $attachment_id ); 246 | 247 | $data = get_oembed_response_data( $post, 400 ); 248 | 249 | $this->assertArrayHasKey( 'thumbnail_url', $data ); 250 | $this->assertArrayHasKey( 'thumbnail_width', $data ); 251 | $this->assertArrayHasKey( 'thumbnail_height', $data ); 252 | $this->assertTrue( 400 >= $data['thumbnail_width'] ); 253 | } 254 | 255 | /** 256 | * Test oEmbed response data with attachments 257 | */ 258 | function test_get_oembed_response_data_attachment() { 259 | $parent = $this->factory->post->create(); 260 | $file = DIR_TESTDATA . '/images/canola.jpg'; 261 | $post = $this->factory->attachment->create_object( $file, $parent, array( 262 | 'post_mime_type' => 'image/jpeg', 263 | ) ); 264 | 265 | $data = get_oembed_response_data( $post, 400 ); 266 | 267 | $this->assertArrayHasKey( 'thumbnail_url', $data ); 268 | $this->assertArrayHasKey( 'thumbnail_width', $data ); 269 | $this->assertArrayHasKey( 'thumbnail_height', $data ); 270 | $this->assertTrue( 400 >= $data['thumbnail_width'] ); 271 | } 272 | 273 | /** 274 | * Test if our query vars have been successfully registered. 275 | */ 276 | function test_query_vars() { 277 | /* @var WP $wp */ 278 | global $wp; 279 | 280 | foreach ( array( 'embed', 'oembed', 'format', 'url', '_jsonp', 'maxwidth' ) as $query_var ) { 281 | $this->assertTrue( in_array( $query_var, $wp->public_query_vars ) ); 282 | } 283 | } 284 | 285 | /** 286 | * Test get_oembed_endpoint_url 287 | */ 288 | function test_get_oembed_endpoint_url() { 289 | $this->assertEquals( home_url() . '/?oembed=true', get_oembed_endpoint_url() ); 290 | $this->assertEquals( home_url() . '/?oembed=true', get_oembed_endpoint_url( '', 'json' ) ); 291 | $this->assertEquals( home_url() . '/?oembed=true', get_oembed_endpoint_url( '', 'xml' ) ); 292 | 293 | $post_id = $this->factory->post->create(); 294 | $url = get_permalink( $post_id ); 295 | 296 | $this->assertEquals( home_url() . '/?oembed=true&url=' . $url, get_oembed_endpoint_url( $url ) ); 297 | $this->assertEquals( home_url() . '/?oembed=true&url=' . $url . '&format=xml', get_oembed_endpoint_url( $url, 'xml' ) ); 298 | } 299 | 300 | /** 301 | * Test the wp_oembed_ensure_format function. 302 | */ 303 | function test_wp_oembed_ensure_format() { 304 | $this->assertEquals( 'json', wp_oembed_ensure_format( 'json' ) ); 305 | $this->assertEquals( 'xml', wp_oembed_ensure_format( 'xml' ) ); 306 | $this->assertEquals( 'json', wp_oembed_ensure_format( 123 ) ); 307 | $this->assertEquals( 'json', wp_oembed_ensure_format( 'random' ) ); 308 | $this->assertEquals( 'json', wp_oembed_ensure_format( array() ) ); 309 | } 310 | 311 | /** 312 | * Test the _oembed_create_xml function. 313 | */ 314 | function test_oembed_create_xml() { 315 | $actual = _oembed_create_xml( array( 316 | 'foo' => 'bar', 317 | 'bar' => 'baz', 318 | 'ping' => 'pong', 319 | ) ); 320 | 321 | $expected = 'barbazpong'; 322 | 323 | $this->assertStringEndsWith( $expected, trim( $actual ) ); 324 | 325 | $actual = _oembed_create_xml( array( 326 | 'foo' => array( 327 | 'bar' => 'baz', 328 | ), 329 | 'ping' => 'pong', 330 | ) ); 331 | 332 | $expected = 'bazpong'; 333 | 334 | $this->assertStringEndsWith( $expected, trim( $actual ) ); 335 | 336 | $actual = _oembed_create_xml( array( 337 | 'foo' => array( 338 | 'bar' => array( 339 | 'ping' => 'pong', 340 | ), 341 | ), 342 | 'hello' => 'world', 343 | ) ); 344 | 345 | $expected = 'pongworld'; 346 | 347 | $this->assertStringEndsWith( $expected, trim( $actual ) ); 348 | 349 | $actual = _oembed_create_xml( array( 350 | array( 351 | 'foo' => array( 352 | 'bar', 353 | ), 354 | ), 355 | 'helloworld', 356 | ) ); 357 | 358 | $expected = 'barhelloworld'; 359 | 360 | $this->assertStringEndsWith( $expected, trim( $actual ) ); 361 | } 362 | 363 | /** 364 | * Test is_embed. 365 | */ 366 | function test_is_embed() { 367 | $this->assertFalse( is_embed() ); 368 | 369 | $post_id = $this->factory->post->create(); 370 | $this->go_to( get_post_embed_url( $post_id ) ); 371 | $this->assertTrue( is_embed() ); 372 | 373 | $file = DIR_TESTDATA . '/images/canola.jpg'; 374 | $attachment_id = $this->factory->attachment->create_object( $file, $post_id, array( 375 | 'post_mime_type' => 'image/jpeg', 376 | ) ); 377 | $this->go_to( get_post_embed_url( $attachment_id ) ); 378 | $this->assertTrue( is_embed() ); 379 | 380 | $this->go_to( home_url( '/?p=123&embed=true' ) ); 381 | $this->assertTrue( is_embed() ); 382 | } 383 | } 384 | -------------------------------------------------------------------------------- /tests/test-wp-oembed-controller.php: -------------------------------------------------------------------------------- 1 | '', 19 | 'format' => 'json', 20 | 'maxwidth' => 600, 21 | ); 22 | 23 | $legacy_controller = new WP_oEmbed_Controller(); 24 | 25 | $this->assertEquals( 'Invalid URL.', $legacy_controller->dispatch( $request ) ); 26 | } 27 | 28 | /** 29 | * Test request for a normal post. 30 | */ 31 | function test_request_json() { 32 | $user = $this->factory->user->create_and_get( array( 33 | 'display_name' => 'John Doe', 34 | ) ); 35 | $post = $this->factory->post->create_and_get( array( 36 | 'post_author' => $user->ID, 37 | 'post_title' => 'Hello World', 38 | ) ); 39 | 40 | // WP_Query arguments. 41 | $request = array( 42 | 'url' => get_permalink( $post->ID ), 43 | 'format' => 'json', 44 | 'maxwidth' => 400, 45 | 'callback' => '', 46 | 'oembed' => true, 47 | ); 48 | 49 | $legacy_controller = new WP_oEmbed_Controller(); 50 | 51 | $data = json_decode( $legacy_controller->dispatch( $request ), true ); 52 | 53 | $this->assertTrue( is_array( $data ) ); 54 | 55 | $this->assertArrayHasKey( 'version', $data ); 56 | $this->assertArrayHasKey( 'provider_name', $data ); 57 | $this->assertArrayHasKey( 'provider_url', $data ); 58 | $this->assertArrayHasKey( 'author_name', $data ); 59 | $this->assertArrayHasKey( 'author_url', $data ); 60 | $this->assertArrayHasKey( 'title', $data ); 61 | $this->assertArrayHasKey( 'type', $data ); 62 | $this->assertArrayHasKey( 'width', $data ); 63 | 64 | $this->assertEquals( '1.0', $data['version'] ); 65 | $this->assertEquals( get_bloginfo( 'name' ), $data['provider_name'] ); 66 | $this->assertEquals( get_home_url(), $data['provider_url'] ); 67 | $this->assertEquals( $user->display_name, $data['author_name'] ); 68 | $this->assertEquals( get_author_posts_url( $user->ID, $user->user_nicename ), $data['author_url'] ); 69 | $this->assertEquals( $post->post_title, $data['title'] ); 70 | $this->assertEquals( 'rich', $data['type'] ); 71 | $this->assertTrue( $data['width'] <= $request['maxwidth'] ); 72 | } 73 | 74 | /** 75 | * Test request for a normal post. 76 | */ 77 | function test_request_jsonp() { 78 | $user = $this->factory->user->create_and_get( array( 79 | 'display_name' => 'John Doe', 80 | ) ); 81 | $post = $this->factory->post->create_and_get( array( 82 | 'post_author' => $user->ID, 83 | 'post_title' => 'Hello World', 84 | ) ); 85 | 86 | $request = array( 87 | 'url' => get_permalink( $post->ID ), 88 | 'format' => 'json', 89 | 'maxwidth' => 600, 90 | 'callback' => 'mycallback', 91 | ); 92 | 93 | $legacy_controller = new WP_oEmbed_Controller(); 94 | 95 | $data = $legacy_controller->dispatch( $request ); 96 | 97 | $this->assertEquals( 0, strpos( $data, '/**/mycallback(' ) ); 98 | } 99 | 100 | /** 101 | * Test JSONP request with an invalid callback. 102 | */ 103 | function test_request_jsonp_invalid_callback() { 104 | $user = $this->factory->user->create_and_get( array( 105 | 'display_name' => 'John Doe', 106 | ) ); 107 | $post = $this->factory->post->create_and_get( array( 108 | 'post_author' => $user->ID, 109 | 'post_title' => 'Hello World', 110 | ) ); 111 | 112 | $request = array( 113 | 'url' => get_permalink( $post->ID ), 114 | 'format' => 'json', 115 | 'maxwidth' => 600, 116 | 'callback' => array( 'foo', 'bar' ), 117 | ); 118 | 119 | $legacy_controller = new WP_oEmbed_Controller(); 120 | 121 | $data = $legacy_controller->dispatch( $request ); 122 | 123 | $this->assertFalse( strpos( $data, '/**/mycallback(' ) ); 124 | } 125 | 126 | /** 127 | * Test getting the JSON response with invalid data. 128 | */ 129 | function test_request_json_invalid_data() { 130 | $request = array( 131 | 'callback' => '', 132 | ); 133 | 134 | $legacy_controller = new WP_oEmbed_Controller(); 135 | 136 | $this->assertEquals( 'Not implemented', $legacy_controller->json_response( null, $request ) ); 137 | $this->assertEquals( 'Not implemented', $legacy_controller->json_response( 123, $request ) ); 138 | $this->assertEquals( 'Not implemented', $legacy_controller->json_response( array(), $request ) ); 139 | } 140 | 141 | /** 142 | * Test request for a normal post. 143 | */ 144 | function test_request_xml() { 145 | $user = $this->factory->user->create_and_get( array( 146 | 'display_name' => 'John Doe', 147 | ) ); 148 | $post = $this->factory->post->create_and_get( array( 149 | 'post_author' => $user->ID, 150 | 'post_title' => 'Hello World', 151 | ) ); 152 | 153 | $request = array( 154 | 'url' => get_permalink( $post->ID ), 155 | 'format' => 'xml', 156 | 'maxwidth' => 400, 157 | 'callback' => '', 158 | ); 159 | 160 | $legacy_controller = new WP_oEmbed_Controller(); 161 | 162 | $data = $legacy_controller->dispatch( $request ); 163 | 164 | $data = simplexml_load_string( $data ); 165 | $this->assertInstanceOf( 'SimpleXMLElement', $data ); 166 | 167 | $data = (array) $data; 168 | 169 | $this->assertArrayHasKey( 'version', $data ); 170 | $this->assertArrayHasKey( 'provider_name', $data ); 171 | $this->assertArrayHasKey( 'provider_url', $data ); 172 | $this->assertArrayHasKey( 'author_name', $data ); 173 | $this->assertArrayHasKey( 'author_url', $data ); 174 | $this->assertArrayHasKey( 'title', $data ); 175 | $this->assertArrayHasKey( 'type', $data ); 176 | $this->assertArrayHasKey( 'width', $data ); 177 | 178 | $this->assertEquals( '1.0', $data['version'] ); 179 | $this->assertEquals( get_bloginfo( 'name' ), $data['provider_name'] ); 180 | $this->assertEquals( get_home_url(), $data['provider_url'] ); 181 | $this->assertEquals( $user->display_name, $data['author_name'] ); 182 | $this->assertEquals( get_author_posts_url( $user->ID, $user->user_nicename ), $data['author_url'] ); 183 | $this->assertEquals( $post->post_title, $data['title'] ); 184 | $this->assertEquals( 'rich', $data['type'] ); 185 | $this->assertTrue( $data['width'] <= $request['maxwidth'] ); 186 | } 187 | 188 | /** 189 | * Test getting the XML response with invalid data. 190 | */ 191 | function test_request_xml_invalid_data() { 192 | $legacy_controller = new WP_oEmbed_Controller(); 193 | 194 | $this->assertEquals( 'Not implemented', $legacy_controller->xml_response( null ) ); 195 | $this->assertEquals( 'Not implemented', $legacy_controller->xml_response( 123 ) ); 196 | $this->assertEquals( 'Not implemented', $legacy_controller->xml_response( array() ) ); 197 | } 198 | 199 | /** 200 | * Test request for a child blog post embed in root blog. 201 | * 202 | * @group multisite 203 | */ 204 | function test_request_ms_child_in_root_blog() { 205 | if ( ! is_multisite() ) { 206 | $this->markTestSkipped( __METHOD__ . ' is a multisite-only test.' ); 207 | } 208 | 209 | $child = $this->factory->blog->create(); 210 | 211 | switch_to_blog( $child ); 212 | 213 | $post = $this->factory->post->create_and_get( array( 214 | 'post_title' => 'Hello Child Blog', 215 | ) ); 216 | 217 | $request = array( 218 | 'url' => get_permalink( $post->ID ), 219 | 'format' => 'json', 220 | 'maxwidth' => 600, 221 | 'callback' => '', 222 | ); 223 | 224 | $legacy_controller = new WP_oEmbed_Controller(); 225 | 226 | $data = json_decode( $legacy_controller->dispatch( $request ), true ); 227 | 228 | $this->assertTrue( is_array( $data ) ); 229 | 230 | restore_current_blog(); 231 | } 232 | } 233 | -------------------------------------------------------------------------------- /tests/test-wp-rest-oembed-controller.php: -------------------------------------------------------------------------------- 1 | server = $wp_rest_server = new WP_REST_Server; 36 | 37 | // Configure the REST API route. 38 | add_action( 'rest_api_init', array( new WP_REST_oEmbed_Controller(), 'register_routes' ) ); 39 | 40 | // Filter the REST API response to output XML if requested. 41 | add_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4 ); 42 | 43 | do_action( 'rest_api_init' ); 44 | } 45 | 46 | /** 47 | * Runs after each test. 48 | */ 49 | public function tearDown() { 50 | parent::tearDown(); 51 | 52 | /* @var WP_REST_Server $wp_rest_server */ 53 | global $wp_rest_server; 54 | $wp_rest_server = null; 55 | } 56 | 57 | /** 58 | * Test if our route has been registerd correctly. 59 | * 60 | * Borrowed from the REST API. 61 | */ 62 | public function test_route_availability() { 63 | // Check the route was registered correctly. 64 | $filtered_routes = $this->server->get_routes(); 65 | $this->assertArrayHasKey( '/wp/v2/oembed', $filtered_routes ); 66 | $route = $filtered_routes['/wp/v2/oembed']; 67 | $this->assertCount( 1, $route ); 68 | $this->assertArrayHasKey( 'callback', $route[0] ); 69 | $this->assertArrayHasKey( 'methods', $route[0] ); 70 | $this->assertArrayHasKey( 'args', $route[0] ); 71 | } 72 | 73 | /** 74 | * Test a POST request. 75 | */ 76 | function test_request_with_wrong_method() { 77 | $request = new WP_REST_Request( 'POST', '/wp/v2/oembed' ); 78 | 79 | $response = $this->server->dispatch( $request ); 80 | $data = $response->get_data(); 81 | 82 | $this->assertEquals( 'rest_no_route', $data[0]['code'] ); 83 | } 84 | 85 | /** 86 | * Test a request with a missing URL param. 87 | */ 88 | function test_request_without_url_param() { 89 | $request = new WP_REST_Request( 'GET', '/wp/v2/oembed' ); 90 | 91 | $response = $this->server->dispatch( $request ); 92 | $data = $response->get_data(); 93 | 94 | $this->assertEquals( 'rest_missing_callback_param', $data[0]['code'] ); 95 | $this->assertEquals( 'url', $data[0]['data']['params'][0] ); 96 | } 97 | 98 | /** 99 | * Test a request with a wrong URL. 100 | */ 101 | function test_request_with_bad_url() { 102 | $request = new WP_REST_Request( 'GET', '/wp/v2/oembed' ); 103 | $request->set_param( 'url', 'http://google.com/' ); 104 | 105 | $response = $this->server->dispatch( $request ); 106 | $data = $response->get_data(); 107 | 108 | $this->assertEquals( 'oembed_invalid_url', $data[0]['code'] ); 109 | } 110 | 111 | /** 112 | * Test a request with invalid format. 113 | */ 114 | function test_request_invalid_format() { 115 | $post_id = $this->factory->post->create(); 116 | 117 | $request = new WP_REST_Request( 'GET', '/wp/v2/oembed' ); 118 | $request->set_param( 'url', get_permalink( $post_id ) ); 119 | $request->set_param( 'format', 'random' ); 120 | 121 | $response = $this->server->dispatch( $request ); 122 | $data = $response->get_data(); 123 | 124 | $this->assertTrue( is_array( $data ) ); 125 | } 126 | 127 | /** 128 | * Test request for a normal post. 129 | */ 130 | function test_request_json() { 131 | $user = $this->factory->user->create_and_get( array( 132 | 'display_name' => 'John Doe', 133 | ) ); 134 | $post = $this->factory->post->create_and_get( array( 135 | 'post_author' => $user->ID, 136 | 'post_title' => 'Hello World', 137 | ) ); 138 | 139 | $request = new WP_REST_Request( 'GET', '/wp/v2/oembed' ); 140 | $request->set_param( 'url', get_permalink( $post->ID ) ); 141 | $request->set_param( 'maxwidth', 400 ); 142 | 143 | $response = $this->server->dispatch( $request ); 144 | $data = $response->get_data(); 145 | 146 | $this->assertTrue( is_array( $data ) ); 147 | 148 | $this->assertArrayHasKey( 'version', $data ); 149 | $this->assertArrayHasKey( 'provider_name', $data ); 150 | $this->assertArrayHasKey( 'provider_url', $data ); 151 | $this->assertArrayHasKey( 'author_name', $data ); 152 | $this->assertArrayHasKey( 'author_url', $data ); 153 | $this->assertArrayHasKey( 'title', $data ); 154 | $this->assertArrayHasKey( 'type', $data ); 155 | $this->assertArrayHasKey( 'width', $data ); 156 | 157 | $this->assertEquals( '1.0', $data['version'] ); 158 | $this->assertEquals( get_bloginfo( 'name' ), $data['provider_name'] ); 159 | $this->assertEquals( get_home_url(), $data['provider_url'] ); 160 | $this->assertEquals( $user->display_name, $data['author_name'] ); 161 | $this->assertEquals( get_author_posts_url( $user->ID, $user->user_nicename ), $data['author_url'] ); 162 | $this->assertEquals( $post->post_title, $data['title'] ); 163 | $this->assertEquals( 'rich', $data['type'] ); 164 | $this->assertTrue( $data['width'] <= $request->get_param( 'maxwidth' ) ); 165 | } 166 | 167 | /** 168 | * Test request for a normal post. 169 | */ 170 | function test_request_xml() { 171 | $user = $this->factory->user->create_and_get( array( 172 | 'display_name' => 'John Doe', 173 | ) ); 174 | $post = $this->factory->post->create_and_get( array( 175 | 'post_author' => $user->ID, 176 | 'post_title' => 'Hello World', 177 | ) ); 178 | 179 | $request = new WP_REST_Request( 'GET', '/wp/v2/oembed' ); 180 | $request->set_param( 'url', get_permalink( $post->ID ) ); 181 | $request->set_param( 'format', 'xml' ); 182 | $request->set_param( 'maxwidth', 400 ); 183 | 184 | $response = $this->server->dispatch( $request ); 185 | $data = $response->get_data(); 186 | 187 | $this->assertTrue( is_array( $data ) ); 188 | 189 | $this->assertArrayHasKey( 'version', $data ); 190 | $this->assertArrayHasKey( 'provider_name', $data ); 191 | $this->assertArrayHasKey( 'provider_url', $data ); 192 | $this->assertArrayHasKey( 'author_name', $data ); 193 | $this->assertArrayHasKey( 'author_url', $data ); 194 | $this->assertArrayHasKey( 'title', $data ); 195 | $this->assertArrayHasKey( 'type', $data ); 196 | $this->assertArrayHasKey( 'width', $data ); 197 | 198 | $this->assertEquals( '1.0', $data['version'] ); 199 | $this->assertEquals( get_bloginfo( 'name' ), $data['provider_name'] ); 200 | $this->assertEquals( get_home_url(), $data['provider_url'] ); 201 | $this->assertEquals( $user->display_name, $data['author_name'] ); 202 | $this->assertEquals( get_author_posts_url( $user->ID, $user->user_nicename ), $data['author_url'] ); 203 | $this->assertEquals( $post->post_title, $data['title'] ); 204 | $this->assertEquals( 'rich', $data['type'] ); 205 | $this->assertTrue( $data['width'] <= $request->get_param( 'maxwidth' ) ); 206 | } 207 | 208 | /** 209 | * Test XML output by the rest_pre_serve_request method. 210 | */ 211 | function test_rest_pre_serve_request() { 212 | $user = $this->factory->user->create_and_get( array( 213 | 'display_name' => 'John Doe', 214 | ) ); 215 | $post = $this->factory->post->create_and_get( array( 216 | 'post_author' => $user->ID, 217 | 'post_title' => 'Hello World', 218 | ) ); 219 | 220 | $request = new WP_REST_Request( 'GET', '/wp/v2/oembed' ); 221 | $request->set_param( 'url', get_permalink( $post->ID ) ); 222 | $request->set_param( 'format', 'xml' ); 223 | 224 | $response = $this->server->dispatch( $request ); 225 | 226 | ob_start(); 227 | _oembed_rest_pre_serve_request( true, $response, $request, $this->server ); 228 | $output = ob_get_clean(); 229 | 230 | $xml = simplexml_load_string( $output ); 231 | $this->assertInstanceOf( 'SimpleXMLElement', $xml ); 232 | } 233 | 234 | /** 235 | * Test the rest_pre_serve_request method. 236 | */ 237 | function test_rest_pre_serve_request_wrong_format() { 238 | $post = $this->factory->post->create_and_get(); 239 | 240 | $request = new WP_REST_Request( 'GET', '/wp/v2/oembed' ); 241 | $request->set_param( 'url', get_permalink( $post->ID ) ); 242 | $request->set_param( 'format', 'json' ); 243 | 244 | $response = $this->server->dispatch( $request ); 245 | 246 | $this->assertTrue( _oembed_rest_pre_serve_request( true, $response, $request, $this->server ) ); 247 | } 248 | 249 | /** 250 | * Test the rest_pre_serve_request method. 251 | */ 252 | function test_rest_pre_serve_request_wrong_method() { 253 | $post = $this->factory->post->create_and_get(); 254 | 255 | $request = new WP_REST_Request( 'HEAD', '/wp/v2/oembed' ); 256 | $request->set_param( 'url', get_permalink( $post->ID ) ); 257 | $request->set_param( 'format', 'xml' ); 258 | 259 | $response = $this->server->dispatch( $request ); 260 | 261 | $this->assertTrue( _oembed_rest_pre_serve_request( true, $response, $request, $this->server ) ); 262 | } 263 | 264 | /** 265 | * Test get_oembed_endpoint_url 266 | */ 267 | function test_get_oembed_endpoint_url() { 268 | $this->assertEquals( home_url() . '/?rest_route=/wp/v2/oembed', get_oembed_endpoint_url() ); 269 | $this->assertEquals( home_url() . '/?rest_route=/wp/v2/oembed', get_oembed_endpoint_url( '', 'xml' ) ); 270 | 271 | $post_id = $this->factory->post->create(); 272 | $url = get_permalink( $post_id ); 273 | 274 | $this->assertEquals( home_url() . '/?rest_route=%2Fwp%2Fv2%2Foembed&url=' . $url, get_oembed_endpoint_url( $url ) ); 275 | $this->assertEquals( home_url() . '/?rest_route=%2Fwp%2Fv2%2Foembed&url=' . $url . '&format=xml', get_oembed_endpoint_url( $url, 'xml' ) ); 276 | } 277 | 278 | /** 279 | * Test get_oembed_endpoint_url 280 | */ 281 | function test_get_oembed_endpoint_url_pretty_permalinks() { 282 | update_option( 'permalink_structure', '/%postname%' ); 283 | 284 | $this->assertEquals( home_url() . '/wp-json/wp/v2/oembed', get_oembed_endpoint_url() ); 285 | $this->assertEquals( home_url() . '/wp-json/wp/v2/oembed', get_oembed_endpoint_url( '', 'xml' ) ); 286 | 287 | $post_id = $this->factory->post->create(); 288 | $url = get_permalink( $post_id ); 289 | 290 | $this->assertEquals( home_url() . '/wp-json/wp/v2/oembed?url=' . $url, get_oembed_endpoint_url( $url ) ); 291 | $this->assertEquals( home_url() . '/wp-json/wp/v2/oembed?url=' . $url . '&format=xml', get_oembed_endpoint_url( $url, 'xml' ) ); 292 | 293 | update_option( 'permalink_structure', '' ); 294 | } 295 | 296 | /** 297 | * Test the availability of the item's schema for display / public consumption purposes 298 | */ 299 | public function test_get_item_schema() { 300 | $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/oembed' ); 301 | $response = rest_handle_options_request( null, $this->server, $request ); 302 | $data = $response->get_data(); 303 | $properties = $data['schema']['properties']; 304 | $this->assertEquals( 11, count( $properties ) ); 305 | $this->assertArrayHasKey( 'type', $properties ); 306 | $this->assertArrayHasKey( 'version', $properties ); 307 | $this->assertArrayHasKey( 'width', $properties ); 308 | $this->assertArrayHasKey( 'height', $properties ); 309 | $this->assertArrayHasKey( 'title', $properties ); 310 | $this->assertArrayHasKey( 'url', $properties ); 311 | $this->assertArrayHasKey( 'html', $properties ); 312 | $this->assertArrayHasKey( 'author_name', $properties ); 313 | $this->assertArrayHasKey( 'author_url', $properties ); 314 | $this->assertArrayHasKey( 'provider_name', $properties ); 315 | $this->assertArrayHasKey( 'provider_url', $properties ); 316 | } 317 | 318 | /** 319 | * Test request for a child blog post embed in root blog. 320 | * 321 | * @group multisite 322 | */ 323 | function test_request_ms_child_in_root_blog() { 324 | if ( ! is_multisite() ) { 325 | $this->markTestSkipped( __METHOD__ . ' is a multisite-only test.' ); 326 | } 327 | 328 | $child = $this->factory->blog->create(); 329 | 330 | switch_to_blog( $child ); 331 | 332 | $post = $this->factory->post->create_and_get( array( 333 | 'post_title' => 'Hello Child Blog', 334 | ) ); 335 | 336 | $user = $this->factory->user->create_and_get( array( 337 | 'display_name' => 'John Doe', 338 | ) ); 339 | $post = $this->factory->post->create_and_get( array( 340 | 'post_author' => $user->ID, 341 | 'post_title' => 'Hello World', 342 | ) ); 343 | 344 | $request = new WP_REST_Request( 'GET', '/wp/v2/oembed' ); 345 | $request->set_param( 'url', get_permalink( $post->ID ) ); 346 | 347 | $response = $this->server->dispatch( $request ); 348 | $data = $response->get_data(); 349 | 350 | $this->assertTrue( is_array( $data ) ); 351 | 352 | $this->assertArrayHasKey( 'version', $data ); 353 | $this->assertArrayHasKey( 'provider_name', $data ); 354 | $this->assertArrayHasKey( 'provider_url', $data ); 355 | $this->assertArrayHasKey( 'author_name', $data ); 356 | $this->assertArrayHasKey( 'author_url', $data ); 357 | $this->assertArrayHasKey( 'title', $data ); 358 | $this->assertArrayHasKey( 'type', $data ); 359 | 360 | restore_current_blog(); 361 | } 362 | } 363 | -------------------------------------------------------------------------------- /wp-api-oembed.php: -------------------------------------------------------------------------------- 1 |