'_seopress_titles_title', 'desc' => '_seopress_titles_desc', 'keyword' => '_seopress_analysis_target_kw', 'canonical' => '_seopress_robots_canonical', 'noindex' => '_seopress_robots_index', 'nofollow' => '_seopress_robots_follow', 'og_title' => '_seopress_social_fb_title', 'og_desc' => '_seopress_social_fb_desc', 'og_image' => '_seopress_social_fb_img', 'tw_title' => '_seopress_social_twitter_title', 'tw_desc' => '_seopress_social_twitter_desc', 'tw_image' => '_seopress_social_twitter_img', ); } protected function term_meta_keys(): array { return array( '_seopress_titles_title', '_seopress_titles_desc', '_seopress_robots_index' ); } protected function has_settings(): bool { return array() !== $this->option( 'seopress_titles_option_name' ); } public function term_record( int $term_id ): array { return $this->clean( array( 'title' => $this->vars( $this->meta( $term_id, '_seopress_titles_title', true ) ), 'desc' => $this->vars( $this->meta( $term_id, '_seopress_titles_desc', true ) ), 'canonical' => $this->meta( $term_id, '_seopress_robots_canonical', true ), 'robots' => $this->robots_from( $this->meta( $term_id, '_seopress_robots_index', true ) ), ) ); } public function settings(): array { $titles = $this->option( 'seopress_titles_option_name' ); $social = $this->option( 'seopress_social_option_name' ); if ( empty( $titles ) && empty( $social ) ) { return array(); } $single = (array) ( $titles['seopress_titles_single_titles'] ?? array() ); $taxes = (array) ( $titles['seopress_titles_tax_titles'] ?? array() ); $templates = array(); $noindex_pt = array(); foreach ( $single as $type => $conf ) { $conf = (array) $conf; $title = $this->vars( (string) ( $conf['title'] ?? '' ) ); $desc = $this->vars( (string) ( $conf['description'] ?? '' ) ); if ( '' !== $title || '' !== $desc ) { $templates[ (string) $type ] = array( 'title' => $title, 'desc' => $desc ); } if ( 'yes' === (string) ( $conf['noindex'] ?? '' ) ) { $noindex_pt[] = (string) $type; } } $tax_templates = array(); $noindex_tax = array(); foreach ( $taxes as $tax => $conf ) { $conf = (array) $conf; $title = $this->vars( (string) ( $conf['title'] ?? '' ) ); $desc = $this->vars( (string) ( $conf['description'] ?? '' ) ); if ( '' !== $title || '' !== $desc ) { $tax_templates[ (string) $tax ] = array( 'title' => $title, 'desc' => $desc ); } if ( 'yes' === (string) ( $conf['noindex'] ?? '' ) ) { $noindex_tax[] = (string) $tax; } } return array( 'separator' => mb_substr( (string) ( $titles['seopress_titles_sep'] ?? '' ), 0, 3 ), 'home_title' => $this->vars( (string) ( $titles['seopress_titles_home_site_title'] ?? '' ) ), 'home_desc' => $this->vars( (string) ( $titles['seopress_titles_home_site_desc'] ?? '' ) ), 'templates' => $templates, 'noindex_types' => $noindex_pt, 'taxonomy_templates' => $tax_templates, 'noindex_taxonomies' => $noindex_tax, 'author_enabled' => empty( $titles['seopress_titles_archives_author_disable'] ), 'author_title' => $this->vars( (string) ( $titles['seopress_titles_archives_author_title'] ?? '' ) ), 'author_noindex' => 'yes' === (string) ( $titles['seopress_titles_archives_author_noindex'] ?? '' ), 'date_enabled' => empty( $titles['seopress_titles_archives_date_disable'] ), 'date_noindex' => 'yes' === (string) ( $titles['seopress_titles_archives_date_noindex'] ?? '' ), 'search_title' => $this->vars( (string) ( $titles['seopress_titles_archives_search_title'] ?? '' ) ), 'notfound_title' => $this->vars( (string) ( $titles['seopress_titles_archives_404_title'] ?? '' ) ), 'og_default_image' => (string) ( $social['seopress_social_facebook_img'] ?? '' ), 'twitter_site' => ltrim( (string) ( $social['seopress_social_twitter_card_username'] ?? '' ), '@' ), 'facebook_app_id' => (string) ( $social['seopress_social_facebook_app_id'] ?? '' ), 'organisation' => array( 'name' => (string) ( $social['seopress_social_knowledge_name'] ?? '' ), 'logo' => (string) ( $social['seopress_social_knowledge_img'] ?? '' ), 'type' => 'Person' === (string) ( $social['seopress_social_knowledge_type'] ?? '' ) ? 'person' : 'organization', ), 'social_profiles' => array_values( array_filter( array_map( 'strval', array( $social['seopress_social_accounts_facebook'] ?? '', $social['seopress_social_accounts_twitter'] ?? '', $social['seopress_social_accounts_instagram'] ?? '', $social['seopress_social_accounts_linkedin'] ?? '', $social['seopress_social_accounts_youtube'] ?? '', ) ) ) ), ); } public function counts(): array { $counts = parent::counts(); $counts['redirects'] = count( $this->redirect_posts() ); return $counts; } /** * @return array */ private function redirect_posts(): array { if ( ! post_type_exists( 'seopress_404' ) ) { return array(); } $posts = get_posts( array( 'post_type' => 'seopress_404', 'post_status' => 'publish', 'numberposts' => 500, 'fields' => 'all', 'suppress_filters' => true, // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.SuppressFilters_suppress_filters -- the import must see every post in every language. ) ); return is_array( $posts ) ? $posts : array(); } public function redirects( int $after, int $limit ): array { $out = array(); foreach ( $this->redirect_posts() as $post ) { if ( (int) $post->ID <= $after ) { continue; } $source = (string) get_post_meta( $post->ID, '_seopress_redirections_value', true ); $target = (string) get_post_meta( $post->ID, '_seopress_redirections_value_url', true ); $type = (int) get_post_meta( $post->ID, '_seopress_redirections_type', true ); if ( '' === $source ) { $source = (string) $post->post_title; } $out[] = array( 'id' => (int) $post->ID, 'source' => $source, 'target' => $target, 'type' => $type > 0 ? $type : 301, ); if ( count( $out ) >= max( 1, $limit ) ) { break; } } return $out; } }