WordPress.org

Make WordPress Core

Ticket #10609: function_and_output.txt

File function_and_output.txt, 1.5 KB (added by pyxis630, 5 years ago)
Line 
1Function get_home_path() from wp-admin/includes/file.php
2
3function get_home_path() {
4        $home = get_option( 'home' );
5        $siteurl = get_option( 'siteurl' );
6        if ( $home != '' && $home != $siteurl ) {
7                $wp_path_rel_to_home = str_replace($home, '', $siteurl); /* $siteurl - $home */
8                $pos = strpos($_SERVER["SCRIPT_FILENAME"], $wp_path_rel_to_home);
9                       
10                $home_path = substr($_SERVER["SCRIPT_FILENAME"], 0, $pos);
11                        echo "HOME_PATH0 = $home_path;<br />";
12                $home_path = trailingslashit( $home_path );
13                echo "HOME_PATH1 = $home_path;<br />WPPATHREL2H: $wp_path_rel_to_home<br />POS: $pos<br /><br />";
14        } else {
15                $home_path = ABSPATH;
16                echo "HOME_PATH2 = $home_path; <br />ABS: ".ABSPATH."<br />";
17        }
18        echo "HOME: $home<br />SITEURL: $siteurl<br />HOME_PATH3: $home_path<br />";
19//exit;
20        return $home_path;
21}
22
23Output when WordPress address (URL) and Blog address (URL) are changed at teh same time to a different value (both the same).
24
25HOME_PATH0 = ;
26HOME_PATH1 = /;
27WPPATHREL2H: http://site.com
28POS:
29
30HOME: http://127.0.0.5
31SITEURL: http://site.com
32HOME_PATH3: /
33HOME_PATH0 = ;
34HOME_PATH1 = /;
35WPPATHREL2H: http://site.com
36POS:
37
38HOME: http://127.0.0.5
39SITEURL: http://site.com
40HOME_PATH3: /
41HOME_PATH2 = C:\websites\site/;
42ABS: C:\websites\site/
43HOME: http://site.com
44SITEURL: http://site.com
45HOME_PATH3: C:\websites\site/
46HOME_PATH2 = C:\websites\site/;
47ABS: C:\websites\site/
48HOME: http://site.com
49SITEURL: http://site.com
50HOME_PATH3: C:\websites\site/