option( 'slim_seo' ); } /** * @return array */ private function bundle( int $id, bool $term ): array { $raw = $term ? get_term_meta( $id, 'slim_seo', true ) : get_post_meta( $id, 'slim_seo', true ); return is_array( $raw ) ? $raw : array(); } public function post_record( int $post_id ): array { $b = $this->bundle( $post_id, false ); $robots = array(); if ( ! empty( $b['noindex'] ) ) { $robots[] = 'noindex'; } if ( ! empty( $b['nofollow'] ) ) { $robots[] = 'nofollow'; } return $this->clean( array( 'title' => $this->vars( (string) ( $b['title'] ?? '' ) ), 'desc' => $this->vars( (string) ( $b['description'] ?? '' ) ), 'canonical' => (string) ( $b['canonical'] ?? '' ), 'robots' => $robots, 'social' => array( 'og_title' => (string) ( $b['facebook_title'] ?? '' ), 'og_desc' => (string) ( $b['facebook_description'] ?? '' ), 'og_image' => (string) ( $b['facebook_image'] ?? '' ), 'tw_title' => (string) ( $b['twitter_title'] ?? '' ), 'tw_desc' => (string) ( $b['twitter_description'] ?? '' ), 'tw_image' => (string) ( $b['twitter_image'] ?? '' ), ), ) ); } public function term_record( int $term_id ): array { $b = $this->bundle( $term_id, true ); return $this->clean( array( 'title' => $this->vars( (string) ( $b['title'] ?? '' ) ), 'desc' => $this->vars( (string) ( $b['description'] ?? '' ) ), ) ); } public function settings(): array { $o = $this->option( 'slim_seo' ); if ( empty( $o ) ) { return array(); } return array( 'home_title' => $this->vars( (string) ( $o['home']['title'] ?? '' ) ), 'home_desc' => $this->vars( (string) ( $o['home']['description'] ?? '' ) ), ); } }