From 797b73e4d14dc600a0b194e1c1217973894c242b Mon Sep 17 00:00:00 2001 From: Herb Miller Date: Thu, 3 Sep 2020 14:50:03 +0100 Subject: [PATCH] Issue #158 - add support to embed from local WordPress installs. Fixes #162 - Correct type for until attribute of oik/countdown --- oik.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/oik.php b/oik.php index a3d0000..b5c62f1 100644 --- a/oik.php +++ b/oik.php @@ -75,6 +75,8 @@ function oik_plugin_file_loaded() { add_filter( "attachment_fields_to_edit", "oik_attachment_fields_to_edit", null, 2 ); add_filter( "attachment_fields_to_save", "oik_attachment_fields_to_save", null, 2 ); + add_filter( 'oembed_remote_get_args', 'oik_oembed_remote_get_args', 10, 2 ); + //remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 ); } /** @@ -271,6 +273,23 @@ function oik_attachment_fields_to_save( $post, $attachment) { return $post; } +/** + * Filters `oembed_remote_get_args to set sslverify=true for local requests. + * + * Uses a method in the oik_remote class from the class-oik-remote shared library. + * + * @param array $args Array of arguments for the remote request + * @param string $url the target URL + * @return array + */ +function oik_oembed_remote_get_args( $args, $url ) { + if ( !class_exists( 'oik_remote') ) { + oik_require_lib( 'class-oik-remote'); + } + $args = oik_remote::bw_adjust_args( $args, $url ); + return $args; +} + /** * Implements "admin_bar_menu" action for oik * @@ -601,7 +620,7 @@ function oik_register_dynamic_blocks() { , 'script' => null , 'attributes' => [ 'since' => [ 'type'=>'string' ] - ,'until' => [ 'type' => 'string '] + ,'until' => [ 'type' => 'string'] , 'url' => [ 'type' => 'string'] , 'description' => [ 'type' => 'string'] , 'expirytext' => [ 'type' => 'string']