'_wds_title', 'desc' => '_wds_metadesc', 'keyword' => '_wds_focus-keywords', 'canonical' => '_wds_canonical', 'noindex' => '_wds_meta-robots-noindex', 'nofollow' => '_wds_meta-robots-nofollow', 'og_title' => '_wds_opengraph', ); } protected function has_settings(): bool { return array() !== $this->option( 'wds_onpage_options' ); } public function post_record( int $post_id ): array { $record = parent::post_record( $post_id ); // The OpenGraph field is an array (title, description, images), not a string. $og = get_post_meta( $post_id, '_wds_opengraph', true ); if ( is_array( $og ) ) { $social = array( 'og_title' => (string) ( $og['title'] ?? '' ), 'og_desc' => (string) ( $og['description'] ?? '' ), 'og_image' => (string) ( is_array( $og['images'] ?? null ) ? ( $og['images'][0] ?? '' ) : '' ), ); $social = array_filter( $social, static fn( $v ) => '' !== $v ); if ( ! empty( $social ) ) { $record['social'] = array_merge( (array) ( $record['social'] ?? array() ), $social ); } else { unset( $record['social'] ); } } return $record; } public function settings(): array { $o = $this->option( 'wds_onpage_options' ); if ( empty( $o ) ) { return array(); } $out = array( 'separator' => mb_substr( (string) ( $o['separator'] ?? '' ), 0, 3 ), 'home_title' => $this->vars( (string) ( $o['home']['title'] ?? '' ) ), 'home_desc' => $this->vars( (string) ( $o['home']['description'] ?? '' ) ), ); $templates = array(); foreach ( get_post_types( array( 'public' => true ) ) as $type ) { $conf = (array) ( $o[ 'pt-' . $type ] ?? $o[ $type ] ?? array() ); $title = $this->vars( (string) ( $conf['title'] ?? '' ) ); $desc = $this->vars( (string) ( $conf['description'] ?? '' ) ); if ( '' !== $title || '' !== $desc ) { $templates[ $type ] = array( 'title' => $title, 'desc' => $desc ); } } $out['templates'] = $templates; return $out; } }