ds = ''; if ( ! empty( $this->args->ID ) ) { $keywords = get_post_meta( $this->args->ID, 'rank_math_focus_keyword', true ); } if ( ! empty( $this->args->term_id ) ) { $keywords = get_term_meta( $this->args->term_id, 'rank_math_focus_keyword', true ); } if ( ! is_string( $keywords ) ) { return null; } $keywords = explode( ',', $keywords ); if ( '' !== $keywords[0] ) { return $keywords[0]; } return null; } /** * Get Focus keywords. * * @return string */ public function get_focus_keywords() { if ( is_singular() || is_category() || is_tag() || is_tax() ) { return Paper::get()->get_keywords(); } $keywords = ''; if ( ! empty( $this->args->ID ) ) { $keywords = get_post_meta( $this->args->ID, 'rank_math_focus_keyword', true ); } if ( ! empty( $this->args->term_id ) ) { $keywords = get_term_meta( $this->args->term_id, 'rank_math_focus_keyword', true ); } return $keywords; } /** * Get the current page number as a string (i.e. "page 1 of 5"). * * @return string */ public function get_page() { $sep = $this->get_sep(); $max = $this->determine_max_pages(); $page = $this->determine_page_number(); if ( $max > 1 && $page > 1 ) { /* translators: %1$d: current page number, %2$d: max pages. */ return sprintf( $sep . ' ' . __( 'Page %1$d of %2$d', 'rank-math' ), $page, $max ); } return null; } /** * Get only the page number (without context). * * @return string|null */ public function get_pagenumber() { $page = $this->determine_page_number(); return $page > 0 ? (string) $page : null; } /** * Get the max page number. * * @return string|null */ public function get_pagetotal() { $max = $this->determine_max_pages(); return $max > 0 ? (string) $max : null; } /** * Get a specific custom field value. * * @param string $name The name of the custom field to retrieve. * @return string|null */ public function get_customfield( $name ) { if ( Str::is_empty( $name ) ) { return null; } if ( ! empty( get_query_var( 'sitemap' ) ) && 'locations' !== get_query_var( 'sitemap' ) ) { return null; } if ( is_author() ) { return get_user_meta( $this->args->ID, $name, true ); } if ( is_category() || is_tag() || is_tax() ) { return get_term_meta( $this->args->term_id, $name, true ); } return is_singular() || ! empty( $this->args->post_type ) ? get_post_meta( $this->args->ID, $name, true ) : null; } /** * Get the post type "single" label. * * @return string|null */ public function get_post_type_single() { $name = $this->determine_post_type_label( 'single' ); return '' !== $name ? $name : null; } /** * Get the post type "plural" label. * * @return string|null */ public function get_post_type_plural() { $name = $this->determine_post_type_label( 'plural' ); return '' !== $name ? $name : null; } }