Changeset 3454310
- Timestamp:
- 02/05/2026 07:25:27 AM (2 months ago)
- Location:
- squirrly-seo/trunk
- Files:
-
- 2 edited
-
models/Frontend.php (modified) (7 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
squirrly-seo/trunk/models/Frontend.php
r3359108 r3454310 781 781 782 782 /** 783 * Get the keyword fo fthis URL783 * Get the keyword for this URL 784 784 * 785 785 * @param $post … … 787 787 * @return array|false|WP_Error|WP_Term 788 788 */ 789 private function getTagDetails( $post ) { 790 $temp = str_replace( '…', '...', single_tag_title( '', false ) ); 791 792 foreach ( get_taxonomies() as $tax ) { 793 if ( $tax <> 'category' ) { 794 795 if ( $tag = get_term_by( 'name', $temp, $tax ) ) { 796 if ( ! is_wp_error( $tag ) ) { 797 return $tag; 798 } 799 } 800 } 801 } 802 803 if ( $tag = get_term_by( 'id', $post->term_id, $post->taxonomy ) ) { 804 if ( ! is_wp_error( $tag ) ) { 805 return $tag; 789 private function getTagDetails( $post = null ) { 790 791 if ( ! is_tag() ) { 792 return false; 793 } 794 795 // Best: WP already gives you the tag term 796 $term = get_queried_object(); 797 if ( $term instanceof WP_Term && $term->taxonomy === 'post_tag' && ! is_wp_error( $term ) ) { 798 return $term; 799 } 800 801 // Fallback: tag ID from query var 802 $tag_id = (int) get_queried_object_id(); 803 if ( $tag_id ) { 804 $term = get_term( $tag_id, 'post_tag' ); 805 if ( $term && ! is_wp_error( $term ) ) { 806 return $term; 807 } 808 } 809 810 // Final fallback (only if you truly have it) 811 if ( $post && ! empty($post->term_id) ) { 812 $term = get_term( (int) $post->term_id, 'post_tag' ); 813 if ( $term && ! is_wp_error( $term ) ) { 814 return $term; 806 815 } 807 816 } … … 810 819 } 811 820 821 822 812 823 /** 813 824 * Get the taxonomies details for this URL … … 817 828 * @return array|bool|false|mixed|null|object|string|WP_Error|WP_Term 818 829 */ 819 private function getTaxonomyDetails( $post ) { 820 if ( $id = get_queried_object_id() ) { 821 $term = get_term( $id, '' ); 822 if ( ! is_wp_error( $term ) ) { 830 private function getTaxonomyDetails( $post = null ) { 831 832 if ( ! is_tax() ) { 833 return false; 834 } 835 836 // Best: WP already resolved the current term for this taxonomy archive 837 $term = get_queried_object(); 838 if ( $term instanceof WP_Term && ! is_wp_error( $term ) ) { 839 return $term; 840 } 841 842 // Fallback: use query vars (taxonomy + term id) 843 $term_id = (int) get_queried_object_id(); 844 $taxonomy = get_query_var( 'taxonomy' ); // e.g. 'product_cat', 'portfolio_tag', etc. 845 846 if ( $term_id && $taxonomy ) { 847 $term = get_term( $term_id, $taxonomy ); 848 if ( $term && ! is_wp_error( $term ) ) { 823 849 return $term; 824 850 } 825 851 } 826 852 827 if ( $term = get_term_by( 'id', $post->term_id, $post->taxonomy ) ) { 828 if ( ! is_wp_error( $term ) ) { 853 // Final fallback: if you truly have it in $post 854 if ( $post && ! empty($post->term_id) && ! empty($post->taxonomy) ) { 855 $term = get_term_by( 'id', (int) $post->term_id, $post->taxonomy ); 856 if ( $term && ! is_wp_error( $term ) ) { 829 857 return $term; 830 858 } … … 834 862 } 835 863 864 865 836 866 /** 837 867 * Get the category details for this URL … … 841 871 * @return array|false|object|WP_Error|null 842 872 */ 843 private function getCategoryDetails( $post ) { 844 845 if ( $term = get_category( get_query_var( 'cat' ), false ) ) { 846 if ( ! is_wp_error( $term ) ) { 873 private function getCategoryDetails( $post = null ) { 874 875 if ( ! is_category() ) { 876 return false; 877 } 878 879 // Best: already-resolved term object for the current category archive 880 $term = get_queried_object(); 881 if ( $term instanceof WP_Term && $term->taxonomy === 'category' && ! is_wp_error( $term ) ) { 882 return $term; 883 } 884 885 // Fallback: category ID from query var 886 $cat_id = (int) get_query_var( 'cat' ); 887 if ( $cat_id ) { 888 $term = get_term( $cat_id, 'category' ); // or get_category($cat_id) 889 if ( $term && ! is_wp_error( $term ) ) { 847 890 return $term; 848 891 } 849 892 } 850 893 851 if ( $tag = get_term_by( 'id', $post->term_id, $post->taxonomy ) ) { 852 if ( ! is_wp_error( $tag ) ) { 894 // Final fallback (only if you truly have it) 895 if ( $post && ! empty($post->term_id) ) { 896 $term = get_term( (int) $post->term_id, 'category' ); 897 if ( $term && ! is_wp_error( $term ) ) { 853 898 return $term; 854 899 } … … 858 903 } 859 904 905 906 860 907 /** 861 908 * Get the profile details for this URL 862 909 * 863 * @return object910 * @return false|object 864 911 */ 865 912 public function getAuthorDetails() { 866 $author = false; 867 global $authordata; 868 if ( isset( $authordata->data ) ) { 869 $author = $authordata->data; 870 $author->description = get_the_author_meta( 'description' ); 871 } 872 873 return $author; 874 } 913 if ( ! is_author() ) { 914 return false; 915 } 916 917 // On author archives this should be the WP_User object 918 $author = get_queried_object(); 919 if ( $author instanceof WP_User ) { 920 // Keep your expected "description" field 921 $author->description = get_user_meta( $author->ID, 'description', true ); 922 return $author; 923 } 924 925 // Fallback: author ID from query var 926 $author_id = (int) get_query_var('author'); 927 if ( $author_id ) { 928 $user = get_userdata( $author_id ); 929 if ( $user ) { 930 $user->description = get_user_meta( $user->ID, 'description', true ); 931 return $user; 932 } 933 } 934 935 return false; 936 } 937 938 875 939 876 940 /** -
squirrly-seo/trunk/readme.txt
r3435711 r3454310 4 4 Tags: SEO, AI, XML sitemap, google search console, schema 5 5 Requires at least: 5.3 6 Tested up to: 6. 86 Tested up to: 6.9 7 7 Stable tag: 12.4.15 8 8 Requires PHP: 7.0 … … 258 258 * Fix - Correct the automation patterns for publish time 259 259 * Fix - Javascript error on automation patterns 260 * Fix - Tag, category and author pages details to show the correct language 260 261 261 262 = 12.4.14 =
Note: See TracChangeset
for help on using the changeset viewer.