-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.php
More file actions
119 lines (91 loc) · 3.51 KB
/
Copy pathutils.php
File metadata and controls
119 lines (91 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/* WP backwards compatibility */
if( !function_exists('strip_shortcodes') ) {
// strip_shortcodes introduced in 2.5
function strip_shortcodes( $content ){
return $content;
}
}
if( !function_exists('path_is_absolute') ) {
function path_is_absolute( $path ) {
// this is definitive if true but fails if $path does not exist or contains a symbolic link
if ( realpath($path) == $path )
return true;
if ( strlen($path) == 0 || $path[0] == '.' )
return false;
// windows allows absolute paths like this
if ( preg_match('#^[a-zA-Z]:\\\\#', $path) )
return true;
// a path starting with / or \ is absolute; anything else is relative
return ( $path[0] == '/' || $path[0] == '\\' );
}
}
if( !function_exists('path_join') ) {
function path_join( $base, $path ) {
if ( path_is_absolute($path) )
return $path;
return rtrim($base, '/') . '/' . ltrim($path, '/');
}
}
if ( !defined('WP_SITEURL') )
define( 'WP_SITEURL', get_option('siteurl') );
if ( ! defined( 'WP_CONTENT_URL' ) )
define( 'WP_CONTENT_URL', WP_SITEURL . '/wp-content' );
if ( ! defined( 'WP_CONTENT_DIR' ) )
define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
if ( ! defined( 'WP_PLUGIN_URL' ) )
define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
if ( ! defined( 'WP_PLUGIN_DIR' ) )
define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
if ( ! defined( 'WPMU_PLUGIN_URL' ) )
define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL. '/mu-plugins' );
if ( ! defined( 'WPMU_PLUGIN_DIR' ) )
define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' );
/* ***************************** */
/* WP RP backwards compatibility */
/* ***************************** */
function wp_random_posts ($number = 10){
$limitclause="LIMIT " . $number;
$random_posts = wp_get_random_posts ($limitclause);
foreach ($random_posts as $random_post ){
$output .= '<li>';
$output .= '<a href="' . get_permalink($random_post->ID) . '" title="' . esc_attr(wptexturize($random_post->post_title)) . '">' . wptexturize($random_post->post_title) . '</a></li>';
}
$output = '<ul class="randome_post">' . $output . '</ul>';
echo $output;
}
function wp_most_popular_posts ($number = 10){
$limitclause="LIMIT " . $number;
$most_popular_posts = wp_get_most_popular_posts ($limitclause);
foreach($most_popular_posts as $most_popular_post) {
$output .= '<li><a href="' . get_permalink($most_popular_post->ID) . '" title="' . esc_attr(wptexturize($most_popular_post->post_title)) . '">' . wptexturize($most_popular_post->post_title) . '</a></li>';
}
$output = '<ul class="most_popular_post">' . $output . '</ul>';
echo $output;
}
function wp_most_commented_posts ($number = 10){
$limitclause="LIMIT " . $number;
$most_commented_posts = wp_get_most_commented_posts ($limitclause);
foreach($most_commented_posts as $most_commented_post) {
$output .= '<li><a href="'.get_permalink($most_commented_post->ID).'" title="' . esc_attr(wptexturize($most_commented_post->post_title)) . '">' . wptexturize($most_commented_post->post_title) . '</a></li>';
}
$output = '<ul class="most_commented_post">' . $output . '</ul>';
echo $output;
}
function wp23_related_posts() {
wp_related_posts();
}
function wp_related_posts() {
$output = wp_get_related_posts();
echo $output;
}
function wp_get_random_posts ($limitclause="") {
return wp_fetch_random_posts($limitclause);
}
function wp_get_most_commented_posts($limitclause="") {
return wp_fetch_most_commented_posts($limitclause);
}
function wp_get_most_popular_posts ($limitclause="") {
return wp_fetch_most_popular_posts($limitclause);
}
?>