@@ -71,11 +71,11 @@ |
||
71 | 71 | */ |
72 | 72 | public $live_video_end_date; |
73 | 73 | |
74 | - public function from( $data ) { |
|
75 | - $keys = array_keys( get_class_vars( get_class( $this ) ) ); |
|
74 | + public function from($data) { |
|
75 | + $keys = array_keys(get_class_vars(get_class($this))); |
|
76 | 76 | // Loop through the keys and set the value from array |
77 | - foreach ( $keys as $key ) { |
|
78 | - $this->$key = array_key_exists( $key, $data ) ? $data[ $key ] : null; |
|
77 | + foreach ($keys as $key) { |
|
78 | + $this->$key = array_key_exists($key, $data) ? $data[$key] : null; |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 |
@@ -7,90 +7,90 @@ |
||
7 | 7 | namespace Wordlift\Videoobject\Data\Video; |
8 | 8 | |
9 | 9 | class Video { |
10 | - /** |
|
11 | - * @var string The title of the video. |
|
12 | - */ |
|
13 | - public $name; |
|
14 | - |
|
15 | - /** |
|
16 | - * @var string The video description. |
|
17 | - */ |
|
18 | - public $description; |
|
19 | - |
|
20 | - /** |
|
21 | - * @var array Thumbnail urls. |
|
22 | - */ |
|
23 | - public $thumbnail_urls; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var string Published date. |
|
27 | - */ |
|
28 | - public $upload_date; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var string Video url. |
|
32 | - */ |
|
33 | - public $content_url; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var string Video duration in IS08601 format. |
|
37 | - */ |
|
38 | - public $duration; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var string |
|
42 | - */ |
|
43 | - public $embed_url; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var string An unique identifier, usually the video url. |
|
47 | - */ |
|
48 | - public $id; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var int The number of views for the video. |
|
52 | - */ |
|
53 | - public $views; |
|
54 | - |
|
55 | - /** |
|
56 | - * All the live video properties. |
|
57 | - */ |
|
58 | - /** |
|
59 | - * @var bool |
|
60 | - */ |
|
61 | - public $is_live_video; |
|
62 | - |
|
63 | - /** |
|
64 | - * @var string Live video start date |
|
65 | - */ |
|
66 | - public $live_video_start_date; |
|
67 | - |
|
68 | - /** |
|
69 | - * @var string Live video end date |
|
70 | - */ |
|
71 | - public $live_video_end_date; |
|
72 | - |
|
73 | - public function from( $data ) { |
|
74 | - $keys = array_keys( get_class_vars( get_class( $this ) ) ); |
|
75 | - // Loop through the keys and set the value from array |
|
76 | - foreach ( $keys as $key ) { |
|
77 | - $this->$key = array_key_exists( $key, $data ) ? $data[ $key ] : null; |
|
78 | - } |
|
79 | - } |
|
80 | - |
|
81 | - public function get_data() { |
|
82 | - |
|
83 | - return array( |
|
84 | - '@type' => 'VideoObject', |
|
85 | - 'name' => $this->name, |
|
86 | - 'description' => $this->description, |
|
87 | - 'contentUrl' => $this->content_url, |
|
88 | - 'embedUrl' => $this->embed_url, |
|
89 | - 'uploadDate' => $this->upload_date, |
|
90 | - 'thumbnailUrl' => $this->thumbnail_urls, |
|
91 | - 'duration' => $this->duration, |
|
92 | - ); |
|
93 | - |
|
94 | - } |
|
10 | + /** |
|
11 | + * @var string The title of the video. |
|
12 | + */ |
|
13 | + public $name; |
|
14 | + |
|
15 | + /** |
|
16 | + * @var string The video description. |
|
17 | + */ |
|
18 | + public $description; |
|
19 | + |
|
20 | + /** |
|
21 | + * @var array Thumbnail urls. |
|
22 | + */ |
|
23 | + public $thumbnail_urls; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var string Published date. |
|
27 | + */ |
|
28 | + public $upload_date; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var string Video url. |
|
32 | + */ |
|
33 | + public $content_url; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var string Video duration in IS08601 format. |
|
37 | + */ |
|
38 | + public $duration; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var string |
|
42 | + */ |
|
43 | + public $embed_url; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var string An unique identifier, usually the video url. |
|
47 | + */ |
|
48 | + public $id; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var int The number of views for the video. |
|
52 | + */ |
|
53 | + public $views; |
|
54 | + |
|
55 | + /** |
|
56 | + * All the live video properties. |
|
57 | + */ |
|
58 | + /** |
|
59 | + * @var bool |
|
60 | + */ |
|
61 | + public $is_live_video; |
|
62 | + |
|
63 | + /** |
|
64 | + * @var string Live video start date |
|
65 | + */ |
|
66 | + public $live_video_start_date; |
|
67 | + |
|
68 | + /** |
|
69 | + * @var string Live video end date |
|
70 | + */ |
|
71 | + public $live_video_end_date; |
|
72 | + |
|
73 | + public function from( $data ) { |
|
74 | + $keys = array_keys( get_class_vars( get_class( $this ) ) ); |
|
75 | + // Loop through the keys and set the value from array |
|
76 | + foreach ( $keys as $key ) { |
|
77 | + $this->$key = array_key_exists( $key, $data ) ? $data[ $key ] : null; |
|
78 | + } |
|
79 | + } |
|
80 | + |
|
81 | + public function get_data() { |
|
82 | + |
|
83 | + return array( |
|
84 | + '@type' => 'VideoObject', |
|
85 | + 'name' => $this->name, |
|
86 | + 'description' => $this->description, |
|
87 | + 'contentUrl' => $this->content_url, |
|
88 | + 'embedUrl' => $this->embed_url, |
|
89 | + 'uploadDate' => $this->upload_date, |
|
90 | + 'thumbnailUrl' => $this->thumbnail_urls, |
|
91 | + 'duration' => $this->duration, |
|
92 | + ); |
|
93 | + |
|
94 | + } |
|
95 | 95 | |
96 | 96 | } |
@@ -10,10 +10,10 @@ |
||
10 | 10 | */ |
11 | 11 | interface Provider { |
12 | 12 | |
13 | - /** |
|
14 | - * @param $videos array<Embedded_Video> |
|
15 | - * @return array<Video> |
|
16 | - */ |
|
17 | - public function get_videos_data( $videos ); |
|
13 | + /** |
|
14 | + * @param $videos array<Embedded_Video> |
|
15 | + * @return array<Video> |
|
16 | + */ |
|
17 | + public function get_videos_data( $videos ); |
|
18 | 18 | |
19 | 19 | } |
@@ -14,6 +14,6 @@ |
||
14 | 14 | * @param $videos array<Embedded_Video> |
15 | 15 | * @return array<Video> |
16 | 16 | */ |
17 | - public function get_videos_data( $videos ); |
|
17 | + public function get_videos_data($videos); |
|
18 | 18 | |
19 | 19 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | * |
22 | 22 | * @param $api_client |
23 | 23 | */ |
24 | - public function __construct( $api_client ) { |
|
24 | + public function __construct($api_client) { |
|
25 | 25 | $this->api_client = $api_client; |
26 | 26 | } |
27 | 27 |
@@ -11,18 +11,18 @@ |
||
11 | 11 | */ |
12 | 12 | abstract class Api_Provider implements Provider { |
13 | 13 | |
14 | - /** |
|
15 | - * @var Client |
|
16 | - */ |
|
17 | - protected $api_client; |
|
14 | + /** |
|
15 | + * @var Client |
|
16 | + */ |
|
17 | + protected $api_client; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Api_Provider constructor. |
|
21 | - * |
|
22 | - * @param $api_client |
|
23 | - */ |
|
24 | - public function __construct( $api_client ) { |
|
25 | - $this->api_client = $api_client; |
|
26 | - } |
|
19 | + /** |
|
20 | + * Api_Provider constructor. |
|
21 | + * |
|
22 | + * @param $api_client |
|
23 | + */ |
|
24 | + public function __construct( $api_client ) { |
|
25 | + $this->api_client = $api_client; |
|
26 | + } |
|
27 | 27 | |
28 | 28 | } |
@@ -13,6 +13,6 @@ |
||
13 | 13 | * |
14 | 14 | * @return array<Embedded_Video> |
15 | 15 | */ |
16 | - public function get_videos( $post_id ); |
|
16 | + public function get_videos($post_id); |
|
17 | 17 | |
18 | 18 | } |
@@ -9,11 +9,11 @@ |
||
9 | 9 | */ |
10 | 10 | interface Parser { |
11 | 11 | |
12 | - /** |
|
13 | - * @param int $post_id Post id. |
|
14 | - * |
|
15 | - * @return array<Embedded_Video> |
|
16 | - */ |
|
17 | - public function get_videos( $post_id ); |
|
12 | + /** |
|
13 | + * @param int $post_id Post id. |
|
14 | + * |
|
15 | + * @return array<Embedded_Video> |
|
16 | + */ |
|
17 | + public function get_videos( $post_id ); |
|
18 | 18 | |
19 | 19 | } |
@@ -6,40 +6,40 @@ |
||
6 | 6 | use Wordlift\Videoobject\Video_Processor; |
7 | 7 | |
8 | 8 | class Videoobject_Background_Process extends Background_Process { |
9 | - /** |
|
10 | - * @var Video_Processor |
|
11 | - */ |
|
12 | - private $video_processor; |
|
13 | - |
|
14 | - /** |
|
15 | - * Videoobject_Background_Process constructor. |
|
16 | - * |
|
17 | - * @param $video_processor Video_Processor |
|
18 | - * @param $data_source |
|
19 | - */ |
|
20 | - public function __construct( $video_processor, $data_source ) { |
|
21 | - $this->video_processor = $video_processor; |
|
22 | - parent::__construct( $data_source ); |
|
23 | - } |
|
24 | - |
|
25 | - protected function get_state_storage_key() { |
|
26 | - return '__wl_videoobject_import_state'; |
|
27 | - } |
|
28 | - |
|
29 | - protected function get_action_key() { |
|
30 | - return 'wl_videoobject_import_background_action'; |
|
31 | - } |
|
32 | - |
|
33 | - /** |
|
34 | - * @param $items |
|
35 | - * |
|
36 | - * @return bool|void |
|
37 | - */ |
|
38 | - protected function process_items( $items ) { |
|
39 | - foreach ( $items as $item ) { |
|
40 | - $this->video_processor->process_video_urls( get_post( $item ), $item ); |
|
41 | - } |
|
42 | - return true; |
|
43 | - } |
|
9 | + /** |
|
10 | + * @var Video_Processor |
|
11 | + */ |
|
12 | + private $video_processor; |
|
13 | + |
|
14 | + /** |
|
15 | + * Videoobject_Background_Process constructor. |
|
16 | + * |
|
17 | + * @param $video_processor Video_Processor |
|
18 | + * @param $data_source |
|
19 | + */ |
|
20 | + public function __construct( $video_processor, $data_source ) { |
|
21 | + $this->video_processor = $video_processor; |
|
22 | + parent::__construct( $data_source ); |
|
23 | + } |
|
24 | + |
|
25 | + protected function get_state_storage_key() { |
|
26 | + return '__wl_videoobject_import_state'; |
|
27 | + } |
|
28 | + |
|
29 | + protected function get_action_key() { |
|
30 | + return 'wl_videoobject_import_background_action'; |
|
31 | + } |
|
32 | + |
|
33 | + /** |
|
34 | + * @param $items |
|
35 | + * |
|
36 | + * @return bool|void |
|
37 | + */ |
|
38 | + protected function process_items( $items ) { |
|
39 | + foreach ( $items as $item ) { |
|
40 | + $this->video_processor->process_video_urls( get_post( $item ), $item ); |
|
41 | + } |
|
42 | + return true; |
|
43 | + } |
|
44 | 44 | |
45 | 45 | } |
@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | * @param $video_processor Video_Processor |
18 | 18 | * @param $data_source |
19 | 19 | */ |
20 | - public function __construct( $video_processor, $data_source ) { |
|
20 | + public function __construct($video_processor, $data_source) { |
|
21 | 21 | $this->video_processor = $video_processor; |
22 | - parent::__construct( $data_source ); |
|
22 | + parent::__construct($data_source); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | protected function get_state_storage_key() { |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return bool|void |
37 | 37 | */ |
38 | - protected function process_items( $items ) { |
|
39 | - foreach ( $items as $item ) { |
|
40 | - $this->video_processor->process_video_urls( get_post( $item ), $item ); |
|
38 | + protected function process_items($items) { |
|
39 | + foreach ($items as $item) { |
|
40 | + $this->video_processor->process_video_urls(get_post($item), $item); |
|
41 | 41 | } |
42 | 42 | return true; |
43 | 43 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | private $state_storage_key; |
12 | 12 | |
13 | - public function __construct( $state_storage_key ) { |
|
13 | + public function __construct($state_storage_key) { |
|
14 | 14 | $this->state_storage_key = $state_storage_key; |
15 | 15 | } |
16 | 16 | |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | |
37 | 37 | public function get_state() { |
38 | 38 | try { |
39 | - return get_option( $this->state_storage_key, Sync_State::unknown() ); |
|
40 | - } catch ( \Exception $e ) { |
|
39 | + return get_option($this->state_storage_key, Sync_State::unknown()); |
|
40 | + } catch (\Exception $e) { |
|
41 | 41 | return Sync_State::unknown(); |
42 | 42 | } |
43 | 43 |
@@ -3,46 +3,46 @@ |
||
3 | 3 | |
4 | 4 | abstract class Data_Source { |
5 | 5 | |
6 | - /** |
|
7 | - * @var string The key which is provided to the background process |
|
8 | - * in order to retrieve its state, it should be the same as the one provided to |
|
9 | - * background process. |
|
10 | - */ |
|
11 | - private $state_storage_key; |
|
12 | - |
|
13 | - public function __construct( $state_storage_key ) { |
|
14 | - $this->state_storage_key = $state_storage_key; |
|
15 | - } |
|
16 | - |
|
17 | - /** |
|
18 | - * A list of item ids. |
|
19 | - * |
|
20 | - * @return int[] |
|
21 | - */ |
|
22 | - abstract public function next(); |
|
23 | - |
|
24 | - /** |
|
25 | - * The count of total items which needs to be processed. |
|
26 | - * |
|
27 | - * @return int[] |
|
28 | - */ |
|
29 | - abstract public function count(); |
|
30 | - |
|
31 | - /** |
|
32 | - * A numerical value indicating how many items should be processed per |
|
33 | - * background call. |
|
34 | - * |
|
35 | - * @return int |
|
36 | - */ |
|
37 | - abstract public function get_batch_size(); |
|
38 | - |
|
39 | - public function get_state() { |
|
40 | - try { |
|
41 | - return get_option( $this->state_storage_key, Sync_State::unknown() ); |
|
42 | - } catch ( \Exception $e ) { |
|
43 | - return Sync_State::unknown(); |
|
44 | - } |
|
45 | - |
|
46 | - } |
|
6 | + /** |
|
7 | + * @var string The key which is provided to the background process |
|
8 | + * in order to retrieve its state, it should be the same as the one provided to |
|
9 | + * background process. |
|
10 | + */ |
|
11 | + private $state_storage_key; |
|
12 | + |
|
13 | + public function __construct( $state_storage_key ) { |
|
14 | + $this->state_storage_key = $state_storage_key; |
|
15 | + } |
|
16 | + |
|
17 | + /** |
|
18 | + * A list of item ids. |
|
19 | + * |
|
20 | + * @return int[] |
|
21 | + */ |
|
22 | + abstract public function next(); |
|
23 | + |
|
24 | + /** |
|
25 | + * The count of total items which needs to be processed. |
|
26 | + * |
|
27 | + * @return int[] |
|
28 | + */ |
|
29 | + abstract public function count(); |
|
30 | + |
|
31 | + /** |
|
32 | + * A numerical value indicating how many items should be processed per |
|
33 | + * background call. |
|
34 | + * |
|
35 | + * @return int |
|
36 | + */ |
|
37 | + abstract public function get_batch_size(); |
|
38 | + |
|
39 | + public function get_state() { |
|
40 | + try { |
|
41 | + return get_option( $this->state_storage_key, Sync_State::unknown() ); |
|
42 | + } catch ( \Exception $e ) { |
|
43 | + return Sync_State::unknown(); |
|
44 | + } |
|
45 | + |
|
46 | + } |
|
47 | 47 | |
48 | 48 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | private $term; |
20 | 20 | |
21 | - public function __construct( $term, $entities ) { |
|
21 | + public function __construct($term, $entities) { |
|
22 | 22 | $this->term = $term; |
23 | 23 | $this->entities = $entities; |
24 | 24 | } |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | 'tagName' => $this->term->name, |
31 | 31 | 'tagDescription' => $this->term->description, |
32 | 32 | // Before 4.5.0 taxonomy parameter **must** be passed to this function. |
33 | - 'tagLink' => get_edit_term_link( $this->term->term_id, $this->term->taxonomy ), |
|
33 | + 'tagLink' => get_edit_term_link($this->term->term_id, $this->term->taxonomy), |
|
34 | 34 | 'tagPostCount' => $this->term->count, |
35 | - 'tagTaxonomy' => get_taxonomy( $this->term->taxonomy )->label, |
|
35 | + 'tagTaxonomy' => get_taxonomy($this->term->taxonomy)->label, |
|
36 | 36 | 'entities' => $this->entities, |
37 | 37 | ); |
38 | 38 | } |
@@ -9,31 +9,31 @@ |
||
9 | 9 | |
10 | 10 | class Default_Term_Data implements Term_Data { |
11 | 11 | |
12 | - /** |
|
13 | - * @var array An array of entities bound to the term. |
|
14 | - */ |
|
15 | - private $entities; |
|
16 | - /** |
|
17 | - * @var \WP_Term |
|
18 | - */ |
|
19 | - private $term; |
|
12 | + /** |
|
13 | + * @var array An array of entities bound to the term. |
|
14 | + */ |
|
15 | + private $entities; |
|
16 | + /** |
|
17 | + * @var \WP_Term |
|
18 | + */ |
|
19 | + private $term; |
|
20 | 20 | |
21 | - public function __construct( $term, $entities ) { |
|
22 | - $this->term = $term; |
|
23 | - $this->entities = $entities; |
|
24 | - } |
|
21 | + public function __construct( $term, $entities ) { |
|
22 | + $this->term = $term; |
|
23 | + $this->entities = $entities; |
|
24 | + } |
|
25 | 25 | |
26 | - public function get_data() { |
|
26 | + public function get_data() { |
|
27 | 27 | |
28 | - return array( |
|
29 | - 'tagId' => $this->term->term_id, |
|
30 | - 'tagName' => $this->term->name, |
|
31 | - 'tagDescription' => $this->term->description, |
|
32 | - // Before 4.5.0 taxonomy parameter **must** be passed to this function. |
|
33 | - 'tagLink' => get_edit_term_link( $this->term->term_id, $this->term->taxonomy ), |
|
34 | - 'tagPostCount' => $this->term->count, |
|
35 | - 'tagTaxonomy' => get_taxonomy( $this->term->taxonomy )->label, |
|
36 | - 'entities' => $this->entities, |
|
37 | - ); |
|
38 | - } |
|
28 | + return array( |
|
29 | + 'tagId' => $this->term->term_id, |
|
30 | + 'tagName' => $this->term->name, |
|
31 | + 'tagDescription' => $this->term->description, |
|
32 | + // Before 4.5.0 taxonomy parameter **must** be passed to this function. |
|
33 | + 'tagLink' => get_edit_term_link( $this->term->term_id, $this->term->taxonomy ), |
|
34 | + 'tagPostCount' => $this->term->count, |
|
35 | + 'tagTaxonomy' => get_taxonomy( $this->term->taxonomy )->label, |
|
36 | + 'entities' => $this->entities, |
|
37 | + ); |
|
38 | + } |
|
39 | 39 | } |
@@ -17,9 +17,9 @@ |
||
17 | 17 | * |
18 | 18 | * @return array|array[]|mixed |
19 | 19 | */ |
20 | - public static function get_matched_entities_for_term( $term_id ) { |
|
20 | + public static function get_matched_entities_for_term($term_id) { |
|
21 | 21 | |
22 | - $entity = Entity_List_Factory::get_instance( $term_id ); |
|
22 | + $entity = Entity_List_Factory::get_instance($term_id); |
|
23 | 23 | |
24 | 24 | return $entity->get_jsonld_data(); |
25 | 25 | } |
@@ -10,16 +10,16 @@ |
||
10 | 10 | |
11 | 11 | class Jsonld_Utils { |
12 | 12 | |
13 | - /** |
|
14 | - * @param $term_id |
|
15 | - * |
|
16 | - * @return array|array[]|mixed |
|
17 | - */ |
|
18 | - public static function get_matched_entities_for_term( $term_id ) { |
|
13 | + /** |
|
14 | + * @param $term_id |
|
15 | + * |
|
16 | + * @return array|array[]|mixed |
|
17 | + */ |
|
18 | + public static function get_matched_entities_for_term( $term_id ) { |
|
19 | 19 | |
20 | - $entity = Entity_List_Factory::get_instance( $term_id ); |
|
20 | + $entity = Entity_List_Factory::get_instance( $term_id ); |
|
21 | 21 | |
22 | - return $entity->get_jsonld_data(); |
|
23 | - } |
|
22 | + return $entity->get_jsonld_data(); |
|
23 | + } |
|
24 | 24 | |
25 | 25 | } |
@@ -29,6 +29,6 @@ |
||
29 | 29 | * @since 3.16.0 $references argument added. |
30 | 30 | * @since 3.10.0 |
31 | 31 | */ |
32 | - public function convert( $post_id, &$references = array(), &$references_infos = array() ); |
|
32 | + public function convert($post_id, &$references = array(), &$references_infos = array()); |
|
33 | 33 | |
34 | 34 | } |
@@ -17,17 +17,17 @@ |
||
17 | 17 | */ |
18 | 18 | interface Wordlift_Post_Converter { |
19 | 19 | |
20 | - /** |
|
21 | - * Convert the specified post id. |
|
22 | - * |
|
23 | - * @param int $post_id The post id. |
|
24 | - * @param array $references An array of posts referenced by the specified post. |
|
25 | - * @param array $references_infos |
|
26 | - * |
|
27 | - * @return mixed The conversion result. |
|
28 | - * @since 3.16.0 $references argument added. |
|
29 | - * @since 3.10.0 |
|
30 | - */ |
|
31 | - public function convert( $post_id, &$references = array(), &$references_infos = array() ); |
|
20 | + /** |
|
21 | + * Convert the specified post id. |
|
22 | + * |
|
23 | + * @param int $post_id The post id. |
|
24 | + * @param array $references An array of posts referenced by the specified post. |
|
25 | + * @param array $references_infos |
|
26 | + * |
|
27 | + * @return mixed The conversion result. |
|
28 | + * @since 3.16.0 $references argument added. |
|
29 | + * @since 3.10.0 |
|
30 | + */ |
|
31 | + public function convert( $post_id, &$references = array(), &$references_infos = array() ); |
|
32 | 32 | |
33 | 33 | } |