the plugin's meta key) and, * where the plugin is unusual, overrides one method. */ abstract class MetaAdapter extends Adapter { /** * Our field name => the source's meta key. Fields: title, desc, keyword, * canonical, noindex, nofollow, og_title, og_desc, og_image, tw_title, * tw_desc, tw_image, breadcrumb_title. * * @return array */ abstract protected function keys(): array; protected function post_meta_keys(): array { $keys = $this->keys(); return array_values( array_filter( array( $keys['title'] ?? '', $keys['desc'] ?? '', $keys['keyword'] ?? '', $keys['canonical'] ?? '' ) ) ); } protected function term_meta_keys(): array { return array(); } public function post_record( int $post_id ): array { $keys = $this->keys(); $robots = $this->robots_from( $this->meta( $post_id, (string) ( $keys['noindex'] ?? '' ) ) ); if ( '' !== (string) ( $keys['nofollow'] ?? '' ) ) { $robots = array_values( array_unique( array_merge( $robots, $this->robots_from( $this->meta( $post_id, (string) $keys['nofollow'] ), 'nofollow' ) ) ) ); } return $this->clean( array( 'title' => $this->vars( $this->meta( $post_id, (string) ( $keys['title'] ?? '' ) ) ), 'desc' => $this->vars( $this->meta( $post_id, (string) ( $keys['desc'] ?? '' ) ) ), 'keywords' => array_values( array_filter( array_map( 'trim', explode( ',', $this->meta( $post_id, (string) ( $keys['keyword'] ?? '' ) ) ) ) ) ), 'canonical' => $this->meta( $post_id, (string) ( $keys['canonical'] ?? '' ) ), 'robots' => $robots, 'breadcrumb_title' => $this->meta( $post_id, (string) ( $keys['breadcrumb_title'] ?? '' ) ), 'social' => array( 'og_title' => $this->meta( $post_id, (string) ( $keys['og_title'] ?? '' ) ), 'og_desc' => $this->meta( $post_id, (string) ( $keys['og_desc'] ?? '' ) ), 'og_image' => $this->meta( $post_id, (string) ( $keys['og_image'] ?? '' ) ), 'tw_title' => $this->meta( $post_id, (string) ( $keys['tw_title'] ?? '' ) ), 'tw_desc' => $this->meta( $post_id, (string) ( $keys['tw_desc'] ?? '' ) ), 'tw_image' => $this->meta( $post_id, (string) ( $keys['tw_image'] ?? '' ) ), ), ) ); } }