Changeset 8187
- Timestamp:
- 02/04/2019 04:36:07 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
r8186 r8187 824 824 global $wpdb; 825 825 826 if ( ! get_post() ) { 826 $post = false; 827 if ( is_singular( 'plugin' ) ) { 828 $post = get_post(); 829 } 830 831 $path = self::get_current_url( $path_only = true ); 832 if ( ! $path ) { 827 833 return; 828 834 } … … 830 836 wp_cache_add_global_groups( array( 'locale-associations' ) ); 831 837 832 if ( false === ( $sites = wp_cache_get( 'local-sites-' . get_post()->post_name, 'locale-associations' ) ) ) { 838 // WARNING: for any changes below, check other uses of the `locale-assosciations` group as there's shared cache keys in use. 839 $cache_key = $post ? 'local-sites-' . $post->post_name : 'local-sites'; 840 if ( false === ( $sites = wp_cache_get( $cache_key, 'locale-associations' ) ) ) { 833 841 834 842 // get subdomain/locale associations 835 843 $subdomains = $wpdb->get_results( 'SELECT locale, subdomain FROM wporg_locales', OBJECT_K ); 836 844 837 $sites = Plugin_I18n::instance()->get_locales();838 839 845 require_once GLOTPRESS_LOCALES_PATH; 846 847 if ( $post ) { 848 $sites = Plugin_I18n::instance()->get_locales(); 849 } else { 850 $sites = array(); 851 foreach ( array_keys( $subdomains ) as $locale ) { 852 $sites[] = (object) array( 853 'wp_locale' => $locale 854 ); 855 } 856 } 840 857 841 858 foreach ( $sites as $key => $site ) { … … 884 901 } ); 885 902 886 wp_cache_set( 'local-sites-' . get_post()->post_name, $sites, 'locale-associations', DAY_IN_SECONDS ); 887 } 888 889 if ( is_singular() ) { 890 $path = parse_url( get_permalink(), PHP_URL_PATH ); 891 if ( get_query_var( 'plugin_advanced' ) ) { 892 $path .= 'advanced/'; 893 } 894 } else { 895 // WordPress doesn't have a good way to get the canonical version of non-singular urls. 896 $path = $_SERVER['REQUEST_URI']; // phpcs:ignore 903 wp_cache_set( $cache_key, $sites, 'locale-associations', DAY_IN_SECONDS ); 897 904 } 898 905 … … 915 922 * Outputs a <link rel="canonical"> on archive pages. 916 923 */ 917 public function archive_rel_canonical_link() {924 public static function archive_rel_canonical_link() { 918 925 if ( $url = self::get_current_url() ) { 919 926 printf( … … 927 934 * Get the current front-end requested URL. 928 935 */ 929 public function get_current_url() {936 public static function get_current_url( $path_only = false ) { 930 937 $queried_object = get_queried_object(); 931 938 $link = false; … … 953 960 } 954 961 962 if ( $path_only && $link ) { 963 $path = parse_url( $link, PHP_URL_PATH ); 964 if ( $query = parse_url( $link, PHP_URL_QUERY ) ) { 965 $path .= '?' . $query; 966 } 967 968 return $path; 969 } 970 955 971 return $link; 956 972 }
Note: See TracChangeset
for help on using the changeset viewer.