From abc704f92d51020b31d313c7bee3d34e33b2f3e0 Mon Sep 17 00:00:00 2001 From: Eduardo Humberto Date: Wed, 24 Apr 2019 19:27:42 -0300 Subject: [PATCH] Youtube Importer: fix errors and set importer visible --- src/importer/class-tainacan-importer-handler.php | 16 ++++++++-------- src/importer/class-tainacan-youtube-importer.php | 11 ++++++++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/importer/class-tainacan-importer-handler.php b/src/importer/class-tainacan-importer-handler.php index 67e44cdac..5ec565309 100644 --- a/src/importer/class-tainacan-importer-handler.php +++ b/src/importer/class-tainacan-importer-handler.php @@ -61,14 +61,14 @@ class Importer_Handler { 'manual_mapping' => false, ]); -// $this->register_importer([ -// 'name' => 'Youtube (Experimental)', -// 'description' => __('Import items from an Youtube URL', 'tainacan'), -// 'slug' => 'youtube_importer', -// 'class_name' => '\Tainacan\Importer\Youtube_Importer', -// 'manual_collection' => true, -// 'manual_mapping' => true, -// ]); + $this->register_importer([ + 'name' => 'Youtube (Experimental)', + 'description' => __('Import items from an Youtube URL', 'tainacan'), + 'slug' => 'youtube_importer', + 'class_name' => '\Tainacan\Importer\Youtube_Importer', + 'manual_collection' => true, + 'manual_mapping' => true, + ]); do_action('tainacan_register_importers'); diff --git a/src/importer/class-tainacan-youtube-importer.php b/src/importer/class-tainacan-youtube-importer.php index 9c44c7357..0d2cbe678 100644 --- a/src/importer/class-tainacan-youtube-importer.php +++ b/src/importer/class-tainacan-youtube-importer.php @@ -20,7 +20,7 @@ class Youtube_Importer extends Importer { ]; /** - * construct + * constructor */ public function __construct($attributes = array()) { parent::__construct($attributes); @@ -109,7 +109,7 @@ class Youtube_Importer extends Importer { break; case 'url': - $value = 'https://www.youtube.com/watch?v=' . $item->snippet->videoId; + $value = 'https://www.youtube.com/watch?v=' . $item->contentDetails->videoId; break; } @@ -129,7 +129,10 @@ class Youtube_Importer extends Importer { } /** - * identify the type of url is send by user + * method responsible for identify the type of url + * + * @param bool $showDetails + * @return array|bool */ public function identify_url( $showDetails = false ){ $url = $this->get_url(); @@ -212,6 +215,8 @@ class Youtube_Importer extends Importer { } /** + * return the list of items for the different types of url + * * @return array|mixed */ private function get_list_items() {