@@ -16,242 +16,242 @@ |
||
| 16 | 16 | |
| 17 | 17 | class Mentions { |
| 18 | 18 | |
| 19 | - private static $schema_descendants = array( |
|
| 20 | - 'AmpStory', |
|
| 21 | - 'ArchiveComponent', |
|
| 22 | - 'Article', |
|
| 23 | - 'Atlas', |
|
| 24 | - 'Blog', |
|
| 25 | - 'Book', |
|
| 26 | - 'Chapter', |
|
| 27 | - 'Claim', |
|
| 28 | - 'Clip', |
|
| 29 | - 'Code', |
|
| 30 | - 'Collection', |
|
| 31 | - 'ComicStory', |
|
| 32 | - 'Comment', |
|
| 33 | - 'Conversation', |
|
| 34 | - 'Course', |
|
| 35 | - 'CreativeWorkSeason', |
|
| 36 | - 'CreativeWorkSeries', |
|
| 37 | - 'DataCatalog', |
|
| 38 | - 'Dataset', |
|
| 39 | - 'DefinedTermSet', |
|
| 40 | - 'Diet', |
|
| 41 | - 'DigitalDocument', |
|
| 42 | - 'Drawing', |
|
| 43 | - 'EducationalOccupationalCredential', |
|
| 44 | - 'Episode', |
|
| 45 | - 'ExercisePlan', |
|
| 46 | - 'Game', |
|
| 47 | - 'Guide', |
|
| 48 | - 'HowTo', |
|
| 49 | - 'HowToDirection', |
|
| 50 | - 'HowToSection', |
|
| 51 | - 'HowToStep', |
|
| 52 | - 'HowToTip', |
|
| 53 | - 'HyperToc', |
|
| 54 | - 'HyperTocEntry', |
|
| 55 | - 'LearningResource', |
|
| 56 | - 'Legislation', |
|
| 57 | - 'Manuscript', |
|
| 58 | - 'Map', |
|
| 59 | - 'MathSolver', |
|
| 60 | - 'MediaObject', |
|
| 61 | - 'Menu', |
|
| 62 | - 'MenuSection', |
|
| 63 | - 'Message', |
|
| 64 | - 'Movie', |
|
| 65 | - 'MusicComposition', |
|
| 66 | - 'MusicPlaylist', |
|
| 67 | - 'MusicRecording', |
|
| 68 | - 'Painting', |
|
| 69 | - 'Photograph', |
|
| 70 | - 'Play', |
|
| 71 | - 'Poster', |
|
| 72 | - 'PublicationIssue', |
|
| 73 | - 'PublicationVolume', |
|
| 74 | - 'Quotation', |
|
| 75 | - 'Review', |
|
| 76 | - 'Sculpture', |
|
| 77 | - 'Season', |
|
| 78 | - 'SheetMusic', |
|
| 79 | - 'ShortStory', |
|
| 80 | - 'SoftwareApplication', |
|
| 81 | - 'SoftwareSourceCode', |
|
| 82 | - 'SpecialAnnouncement', |
|
| 83 | - 'Thesis', |
|
| 84 | - 'TvSeason', |
|
| 85 | - 'TvSeries', |
|
| 86 | - 'VisualArtwork', |
|
| 87 | - 'WebContent', |
|
| 88 | - 'WebPage', |
|
| 89 | - 'WebPageElement', |
|
| 90 | - 'WebSite', |
|
| 91 | - 'AdvertiserContentArticle', |
|
| 92 | - 'NewsArticle', |
|
| 93 | - 'Report', |
|
| 94 | - 'SatiricalArticle', |
|
| 95 | - 'ScholarlyArticle', |
|
| 96 | - 'SocialMediaPosting', |
|
| 97 | - 'TechArticle', |
|
| 98 | - 'AnalysisNewsArticle', |
|
| 99 | - 'AskPublicNewsArticle', |
|
| 100 | - 'BackgroundNewsArticle', |
|
| 101 | - 'OpinionNewsArticle', |
|
| 102 | - 'ReportageNewsArticle', |
|
| 103 | - 'ReviewNewsArticle', |
|
| 104 | - 'MedicalScholarlyArticle', |
|
| 105 | - 'BlogPosting', |
|
| 106 | - 'DiscussionForumPosting', |
|
| 107 | - 'LiveBlogPosting', |
|
| 108 | - 'ApiReference', |
|
| 109 | - 'Audiobook', |
|
| 110 | - 'MovieClip', |
|
| 111 | - 'RadioClip', |
|
| 112 | - 'TvClip', |
|
| 113 | - 'VideoGameClip', |
|
| 114 | - 'ProductCollection', |
|
| 115 | - 'ComicCoverArt', |
|
| 116 | - 'Answer', |
|
| 117 | - 'CorrectionComment', |
|
| 118 | - 'Question', |
|
| 119 | - 'PodcastSeason', |
|
| 120 | - 'RadioSeason', |
|
| 121 | - 'TvSeason', |
|
| 122 | - 'BookSeries', |
|
| 123 | - 'MovieSeries', |
|
| 124 | - 'Periodical', |
|
| 125 | - 'PodcastSeries', |
|
| 126 | - 'RadioSeries', |
|
| 127 | - 'TvSeries', |
|
| 128 | - 'VideoGameSeries', |
|
| 129 | - 'ComicSeries', |
|
| 130 | - 'Newspaper', |
|
| 131 | - 'DataFeed', |
|
| 132 | - 'CompleteDataFeed', |
|
| 133 | - 'CategoryCodeSet', |
|
| 134 | - 'NoteDigitalDocument', |
|
| 135 | - 'PresentationDigitalDocument', |
|
| 136 | - 'SpreadsheetDigitalDocument', |
|
| 137 | - 'TextDigitalDocument', |
|
| 138 | - 'PodcastEpisode', |
|
| 139 | - 'RadioEpisode', |
|
| 140 | - 'TvEpisode', |
|
| 141 | - 'VideoGame', |
|
| 142 | - 'Recipe', |
|
| 143 | - 'Course', |
|
| 144 | - 'Quiz', |
|
| 145 | - 'LegislationObject', |
|
| 146 | - 'AudioObject', |
|
| 147 | - 'DModel', |
|
| 148 | - 'DataDownload', |
|
| 149 | - 'ImageObject', |
|
| 150 | - 'LegislationObject', |
|
| 151 | - 'MusicVideoObject', |
|
| 152 | - 'VideoObject', |
|
| 153 | - 'Audiobook', |
|
| 154 | - 'Barcode', |
|
| 155 | - 'EmailMessage', |
|
| 156 | - 'MusicAlbum', |
|
| 157 | - 'MusicRelease', |
|
| 158 | - 'ComicIssue', |
|
| 159 | - 'ClaimReview', |
|
| 160 | - 'CriticReview', |
|
| 161 | - 'EmployerReview', |
|
| 162 | - 'MediaReview', |
|
| 163 | - 'Recommendation', |
|
| 164 | - 'UserReview', |
|
| 165 | - 'ReviewNewsArticle', |
|
| 166 | - 'MobileApplication', |
|
| 167 | - 'VideoGame', |
|
| 168 | - 'WebApplication', |
|
| 169 | - 'CoverArt', |
|
| 170 | - 'ComicCoverArt', |
|
| 171 | - 'HealthTopicContent', |
|
| 172 | - 'AboutPage', |
|
| 173 | - 'CheckoutPage', |
|
| 174 | - 'CollectionPage', |
|
| 175 | - 'ContactPage', |
|
| 176 | - 'FaqPage', |
|
| 177 | - 'ItemPage', |
|
| 178 | - 'MedicalWebPage', |
|
| 179 | - 'ProfilePage', |
|
| 180 | - 'QaPage', |
|
| 181 | - 'RealEstateListing', |
|
| 182 | - 'SearchResultsPage', |
|
| 183 | - 'MediaGallery', |
|
| 184 | - 'ImageGallery', |
|
| 185 | - 'VideoGallery', |
|
| 186 | - 'SiteNavigationElement', |
|
| 187 | - 'Table', |
|
| 188 | - 'WpAdBlock', |
|
| 189 | - 'WpFooter', |
|
| 190 | - 'WpHeader', |
|
| 191 | - 'WpSideBar', |
|
| 192 | - ); |
|
| 19 | + private static $schema_descendants = array( |
|
| 20 | + 'AmpStory', |
|
| 21 | + 'ArchiveComponent', |
|
| 22 | + 'Article', |
|
| 23 | + 'Atlas', |
|
| 24 | + 'Blog', |
|
| 25 | + 'Book', |
|
| 26 | + 'Chapter', |
|
| 27 | + 'Claim', |
|
| 28 | + 'Clip', |
|
| 29 | + 'Code', |
|
| 30 | + 'Collection', |
|
| 31 | + 'ComicStory', |
|
| 32 | + 'Comment', |
|
| 33 | + 'Conversation', |
|
| 34 | + 'Course', |
|
| 35 | + 'CreativeWorkSeason', |
|
| 36 | + 'CreativeWorkSeries', |
|
| 37 | + 'DataCatalog', |
|
| 38 | + 'Dataset', |
|
| 39 | + 'DefinedTermSet', |
|
| 40 | + 'Diet', |
|
| 41 | + 'DigitalDocument', |
|
| 42 | + 'Drawing', |
|
| 43 | + 'EducationalOccupationalCredential', |
|
| 44 | + 'Episode', |
|
| 45 | + 'ExercisePlan', |
|
| 46 | + 'Game', |
|
| 47 | + 'Guide', |
|
| 48 | + 'HowTo', |
|
| 49 | + 'HowToDirection', |
|
| 50 | + 'HowToSection', |
|
| 51 | + 'HowToStep', |
|
| 52 | + 'HowToTip', |
|
| 53 | + 'HyperToc', |
|
| 54 | + 'HyperTocEntry', |
|
| 55 | + 'LearningResource', |
|
| 56 | + 'Legislation', |
|
| 57 | + 'Manuscript', |
|
| 58 | + 'Map', |
|
| 59 | + 'MathSolver', |
|
| 60 | + 'MediaObject', |
|
| 61 | + 'Menu', |
|
| 62 | + 'MenuSection', |
|
| 63 | + 'Message', |
|
| 64 | + 'Movie', |
|
| 65 | + 'MusicComposition', |
|
| 66 | + 'MusicPlaylist', |
|
| 67 | + 'MusicRecording', |
|
| 68 | + 'Painting', |
|
| 69 | + 'Photograph', |
|
| 70 | + 'Play', |
|
| 71 | + 'Poster', |
|
| 72 | + 'PublicationIssue', |
|
| 73 | + 'PublicationVolume', |
|
| 74 | + 'Quotation', |
|
| 75 | + 'Review', |
|
| 76 | + 'Sculpture', |
|
| 77 | + 'Season', |
|
| 78 | + 'SheetMusic', |
|
| 79 | + 'ShortStory', |
|
| 80 | + 'SoftwareApplication', |
|
| 81 | + 'SoftwareSourceCode', |
|
| 82 | + 'SpecialAnnouncement', |
|
| 83 | + 'Thesis', |
|
| 84 | + 'TvSeason', |
|
| 85 | + 'TvSeries', |
|
| 86 | + 'VisualArtwork', |
|
| 87 | + 'WebContent', |
|
| 88 | + 'WebPage', |
|
| 89 | + 'WebPageElement', |
|
| 90 | + 'WebSite', |
|
| 91 | + 'AdvertiserContentArticle', |
|
| 92 | + 'NewsArticle', |
|
| 93 | + 'Report', |
|
| 94 | + 'SatiricalArticle', |
|
| 95 | + 'ScholarlyArticle', |
|
| 96 | + 'SocialMediaPosting', |
|
| 97 | + 'TechArticle', |
|
| 98 | + 'AnalysisNewsArticle', |
|
| 99 | + 'AskPublicNewsArticle', |
|
| 100 | + 'BackgroundNewsArticle', |
|
| 101 | + 'OpinionNewsArticle', |
|
| 102 | + 'ReportageNewsArticle', |
|
| 103 | + 'ReviewNewsArticle', |
|
| 104 | + 'MedicalScholarlyArticle', |
|
| 105 | + 'BlogPosting', |
|
| 106 | + 'DiscussionForumPosting', |
|
| 107 | + 'LiveBlogPosting', |
|
| 108 | + 'ApiReference', |
|
| 109 | + 'Audiobook', |
|
| 110 | + 'MovieClip', |
|
| 111 | + 'RadioClip', |
|
| 112 | + 'TvClip', |
|
| 113 | + 'VideoGameClip', |
|
| 114 | + 'ProductCollection', |
|
| 115 | + 'ComicCoverArt', |
|
| 116 | + 'Answer', |
|
| 117 | + 'CorrectionComment', |
|
| 118 | + 'Question', |
|
| 119 | + 'PodcastSeason', |
|
| 120 | + 'RadioSeason', |
|
| 121 | + 'TvSeason', |
|
| 122 | + 'BookSeries', |
|
| 123 | + 'MovieSeries', |
|
| 124 | + 'Periodical', |
|
| 125 | + 'PodcastSeries', |
|
| 126 | + 'RadioSeries', |
|
| 127 | + 'TvSeries', |
|
| 128 | + 'VideoGameSeries', |
|
| 129 | + 'ComicSeries', |
|
| 130 | + 'Newspaper', |
|
| 131 | + 'DataFeed', |
|
| 132 | + 'CompleteDataFeed', |
|
| 133 | + 'CategoryCodeSet', |
|
| 134 | + 'NoteDigitalDocument', |
|
| 135 | + 'PresentationDigitalDocument', |
|
| 136 | + 'SpreadsheetDigitalDocument', |
|
| 137 | + 'TextDigitalDocument', |
|
| 138 | + 'PodcastEpisode', |
|
| 139 | + 'RadioEpisode', |
|
| 140 | + 'TvEpisode', |
|
| 141 | + 'VideoGame', |
|
| 142 | + 'Recipe', |
|
| 143 | + 'Course', |
|
| 144 | + 'Quiz', |
|
| 145 | + 'LegislationObject', |
|
| 146 | + 'AudioObject', |
|
| 147 | + 'DModel', |
|
| 148 | + 'DataDownload', |
|
| 149 | + 'ImageObject', |
|
| 150 | + 'LegislationObject', |
|
| 151 | + 'MusicVideoObject', |
|
| 152 | + 'VideoObject', |
|
| 153 | + 'Audiobook', |
|
| 154 | + 'Barcode', |
|
| 155 | + 'EmailMessage', |
|
| 156 | + 'MusicAlbum', |
|
| 157 | + 'MusicRelease', |
|
| 158 | + 'ComicIssue', |
|
| 159 | + 'ClaimReview', |
|
| 160 | + 'CriticReview', |
|
| 161 | + 'EmployerReview', |
|
| 162 | + 'MediaReview', |
|
| 163 | + 'Recommendation', |
|
| 164 | + 'UserReview', |
|
| 165 | + 'ReviewNewsArticle', |
|
| 166 | + 'MobileApplication', |
|
| 167 | + 'VideoGame', |
|
| 168 | + 'WebApplication', |
|
| 169 | + 'CoverArt', |
|
| 170 | + 'ComicCoverArt', |
|
| 171 | + 'HealthTopicContent', |
|
| 172 | + 'AboutPage', |
|
| 173 | + 'CheckoutPage', |
|
| 174 | + 'CollectionPage', |
|
| 175 | + 'ContactPage', |
|
| 176 | + 'FaqPage', |
|
| 177 | + 'ItemPage', |
|
| 178 | + 'MedicalWebPage', |
|
| 179 | + 'ProfilePage', |
|
| 180 | + 'QaPage', |
|
| 181 | + 'RealEstateListing', |
|
| 182 | + 'SearchResultsPage', |
|
| 183 | + 'MediaGallery', |
|
| 184 | + 'ImageGallery', |
|
| 185 | + 'VideoGallery', |
|
| 186 | + 'SiteNavigationElement', |
|
| 187 | + 'Table', |
|
| 188 | + 'WpAdBlock', |
|
| 189 | + 'WpFooter', |
|
| 190 | + 'WpHeader', |
|
| 191 | + 'WpSideBar', |
|
| 192 | + ); |
|
| 193 | 193 | |
| 194 | - public function __construct() { |
|
| 195 | - add_filter( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 10, 2 ); |
|
| 196 | - } |
|
| 194 | + public function __construct() { |
|
| 195 | + add_filter( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 10, 2 ); |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | - public function wl_after_get_jsonld( $jsonld, $post_id ) { |
|
| 198 | + public function wl_after_get_jsonld( $jsonld, $post_id ) { |
|
| 199 | 199 | |
| 200 | - if ( count( $jsonld ) === 0 || ! is_array( $jsonld[0] ) || ! array_key_exists( '@type', $jsonld[0] ) || array_key_exists( 'mentions', $jsonld[0] ) ) { |
|
| 201 | - return $jsonld; |
|
| 202 | - } |
|
| 200 | + if ( count( $jsonld ) === 0 || ! is_array( $jsonld[0] ) || ! array_key_exists( '@type', $jsonld[0] ) || array_key_exists( 'mentions', $jsonld[0] ) ) { |
|
| 201 | + return $jsonld; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - $type = $jsonld[0]['@type']; |
|
| 204 | + $type = $jsonld[0]['@type']; |
|
| 205 | 205 | |
| 206 | - if ( ! $this->entity_is_descendant_of_creative_work( $type ) && ! $this->entity_is_creative_work( $type ) ) { |
|
| 207 | - return $jsonld; |
|
| 208 | - } |
|
| 206 | + if ( ! $this->entity_is_descendant_of_creative_work( $type ) && ! $this->entity_is_creative_work( $type ) ) { |
|
| 207 | + return $jsonld; |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - $entity_references = Object_Relation_Service::get_instance() |
|
| 211 | - ->get_references( $post_id, Object_Type_Enum::POST ); |
|
| 210 | + $entity_references = Object_Relation_Service::get_instance() |
|
| 211 | + ->get_references( $post_id, Object_Type_Enum::POST ); |
|
| 212 | 212 | |
| 213 | - $about_id = array(); |
|
| 214 | - if ( array_key_exists( 'about', $jsonld[0] ) && is_array( $jsonld[0]['about'] ) ) { |
|
| 215 | - foreach ( $jsonld[0]['about'] as $about ) { |
|
| 216 | - $about_id[] = $about['@id']; |
|
| 217 | - } |
|
| 218 | - } |
|
| 213 | + $about_id = array(); |
|
| 214 | + if ( array_key_exists( 'about', $jsonld[0] ) && is_array( $jsonld[0]['about'] ) ) { |
|
| 215 | + foreach ( $jsonld[0]['about'] as $about ) { |
|
| 216 | + $about_id[] = $about['@id']; |
|
| 217 | + } |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | - $jsonld[0]['mentions'] = array_values( |
|
| 221 | - array_filter( |
|
| 222 | - array_map( |
|
| 223 | - function ( $item ) use ( $about_id ) { |
|
| 224 | - $id = \Wordlift_Entity_Service::get_instance()->get_uri( $item->get_id() ); |
|
| 225 | - if ( ! $id || in_array( $id, $about_id, true ) ) { |
|
| 226 | - return false; |
|
| 227 | - } |
|
| 220 | + $jsonld[0]['mentions'] = array_values( |
|
| 221 | + array_filter( |
|
| 222 | + array_map( |
|
| 223 | + function ( $item ) use ( $about_id ) { |
|
| 224 | + $id = \Wordlift_Entity_Service::get_instance()->get_uri( $item->get_id() ); |
|
| 225 | + if ( ! $id || in_array( $id, $about_id, true ) ) { |
|
| 226 | + return false; |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - return array( '@id' => $id ); |
|
| 229 | + return array( '@id' => $id ); |
|
| 230 | 230 | |
| 231 | - }, |
|
| 232 | - $entity_references |
|
| 233 | - ) |
|
| 234 | - ) |
|
| 235 | - ); |
|
| 231 | + }, |
|
| 232 | + $entity_references |
|
| 233 | + ) |
|
| 234 | + ) |
|
| 235 | + ); |
|
| 236 | 236 | |
| 237 | - // Remove mentions if the count is zero. |
|
| 238 | - if ( count( $jsonld[0]['mentions'] ) === 0 ) { |
|
| 239 | - unset( $jsonld[0]['mentions'] ); |
|
| 240 | - } |
|
| 237 | + // Remove mentions if the count is zero. |
|
| 238 | + if ( count( $jsonld[0]['mentions'] ) === 0 ) { |
|
| 239 | + unset( $jsonld[0]['mentions'] ); |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | - return $jsonld; |
|
| 243 | - } |
|
| 242 | + return $jsonld; |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - private function entity_is_descendant_of_creative_work( $type ) { |
|
| 246 | - if ( is_string( $type ) ) { |
|
| 247 | - $type = array( $type ); |
|
| 248 | - } |
|
| 245 | + private function entity_is_descendant_of_creative_work( $type ) { |
|
| 246 | + if ( is_string( $type ) ) { |
|
| 247 | + $type = array( $type ); |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | - return count( array_intersect( $type, $this::$schema_descendants ) ) > 0; |
|
| 251 | - } |
|
| 250 | + return count( array_intersect( $type, $this::$schema_descendants ) ) > 0; |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | - private function entity_is_creative_work( $type ) { |
|
| 254 | - return ( 'CreativeWork' === $type ) || ( is_array( $type ) && in_array( 'CreativeWork', $type, true ) ); |
|
| 255 | - } |
|
| 253 | + private function entity_is_creative_work( $type ) { |
|
| 254 | + return ( 'CreativeWork' === $type ) || ( is_array( $type ) && in_array( 'CreativeWork', $type, true ) ); |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | 257 | } |
@@ -192,27 +192,27 @@ discard block |
||
| 192 | 192 | ); |
| 193 | 193 | |
| 194 | 194 | public function __construct() { |
| 195 | - add_filter( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 10, 2 ); |
|
| 195 | + add_filter('wl_after_get_jsonld', array($this, 'wl_after_get_jsonld'), 10, 2); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - public function wl_after_get_jsonld( $jsonld, $post_id ) { |
|
| 198 | + public function wl_after_get_jsonld($jsonld, $post_id) { |
|
| 199 | 199 | |
| 200 | - if ( count( $jsonld ) === 0 || ! is_array( $jsonld[0] ) || ! array_key_exists( '@type', $jsonld[0] ) || array_key_exists( 'mentions', $jsonld[0] ) ) { |
|
| 200 | + if (count($jsonld) === 0 || ! is_array($jsonld[0]) || ! array_key_exists('@type', $jsonld[0]) || array_key_exists('mentions', $jsonld[0])) { |
|
| 201 | 201 | return $jsonld; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | $type = $jsonld[0]['@type']; |
| 205 | 205 | |
| 206 | - if ( ! $this->entity_is_descendant_of_creative_work( $type ) && ! $this->entity_is_creative_work( $type ) ) { |
|
| 206 | + if ( ! $this->entity_is_descendant_of_creative_work($type) && ! $this->entity_is_creative_work($type)) { |
|
| 207 | 207 | return $jsonld; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | $entity_references = Object_Relation_Service::get_instance() |
| 211 | - ->get_references( $post_id, Object_Type_Enum::POST ); |
|
| 211 | + ->get_references($post_id, Object_Type_Enum::POST); |
|
| 212 | 212 | |
| 213 | 213 | $about_id = array(); |
| 214 | - if ( array_key_exists( 'about', $jsonld[0] ) && is_array( $jsonld[0]['about'] ) ) { |
|
| 215 | - foreach ( $jsonld[0]['about'] as $about ) { |
|
| 214 | + if (array_key_exists('about', $jsonld[0]) && is_array($jsonld[0]['about'])) { |
|
| 215 | + foreach ($jsonld[0]['about'] as $about) { |
|
| 216 | 216 | $about_id[] = $about['@id']; |
| 217 | 217 | } |
| 218 | 218 | } |
@@ -220,13 +220,13 @@ discard block |
||
| 220 | 220 | $jsonld[0]['mentions'] = array_values( |
| 221 | 221 | array_filter( |
| 222 | 222 | array_map( |
| 223 | - function ( $item ) use ( $about_id ) { |
|
| 224 | - $id = \Wordlift_Entity_Service::get_instance()->get_uri( $item->get_id() ); |
|
| 225 | - if ( ! $id || in_array( $id, $about_id, true ) ) { |
|
| 223 | + function($item) use ($about_id) { |
|
| 224 | + $id = \Wordlift_Entity_Service::get_instance()->get_uri($item->get_id()); |
|
| 225 | + if ( ! $id || in_array($id, $about_id, true)) { |
|
| 226 | 226 | return false; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - return array( '@id' => $id ); |
|
| 229 | + return array('@id' => $id); |
|
| 230 | 230 | |
| 231 | 231 | }, |
| 232 | 232 | $entity_references |
@@ -235,23 +235,23 @@ discard block |
||
| 235 | 235 | ); |
| 236 | 236 | |
| 237 | 237 | // Remove mentions if the count is zero. |
| 238 | - if ( count( $jsonld[0]['mentions'] ) === 0 ) { |
|
| 239 | - unset( $jsonld[0]['mentions'] ); |
|
| 238 | + if (count($jsonld[0]['mentions']) === 0) { |
|
| 239 | + unset($jsonld[0]['mentions']); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | return $jsonld; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - private function entity_is_descendant_of_creative_work( $type ) { |
|
| 246 | - if ( is_string( $type ) ) { |
|
| 247 | - $type = array( $type ); |
|
| 245 | + private function entity_is_descendant_of_creative_work($type) { |
|
| 246 | + if (is_string($type)) { |
|
| 247 | + $type = array($type); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - return count( array_intersect( $type, $this::$schema_descendants ) ) > 0; |
|
| 250 | + return count(array_intersect($type, $this::$schema_descendants)) > 0; |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - private function entity_is_creative_work( $type ) { |
|
| 254 | - return ( 'CreativeWork' === $type ) || ( is_array( $type ) && in_array( 'CreativeWork', $type, true ) ); |
|
| 253 | + private function entity_is_creative_work($type) { |
|
| 254 | + return ('CreativeWork' === $type) || (is_array($type) && in_array('CreativeWork', $type, true)); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | } |