File tree Expand file tree Collapse file tree 3 files changed +38
-13
lines changed
Expand file tree Collapse file tree 3 files changed +38
-13
lines changed Original file line number Diff line number Diff line change 1717
1818use function Activitypub \site_supports_blocks ;
1919
20+ require_once __DIR__ . '/includes/compat.php ' ;
2021require_once __DIR__ . '/includes/functions.php ' ;
2122
2223/**
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * ActivityPub implementation for WordPress/PHP functions either missing from older WordPress/PHP versions or not included by default.
4+ */
5+
6+ if ( ! function_exists ( 'str_starts_with ' ) ) {
7+ /**
8+ * Polyfill for `str_starts_with()` function added in PHP 8.0.
9+ *
10+ * Performs a case-sensitive check indicating if
11+ * the haystack begins with needle.
12+ *
13+ * @param string $haystack The string to search in.
14+ * @param string $needle The substring to search for in the `$haystack`.
15+ * @return bool True if `$haystack` starts with `$needle`, otherwise false.
16+ */
17+ function str_starts_with ( $ haystack , $ needle ) {
18+ if ( '' === $ needle ) {
19+ return true ;
20+ }
21+
22+ return 0 === strpos ( $ haystack , $ needle );
23+ }
24+ }
25+
26+ if ( ! function_exists ( 'get_self_link ' ) ) {
27+ /**
28+ * Returns the link for the currently displayed feed.
29+ *
30+ * @return string Correct link for the atom:self element.
31+ */
32+ function get_self_link () {
33+ $ host = wp_parse_url ( home_url () );
34+ $ path = isset ( $ _SERVER ['REQUEST_URI ' ] ) ? sanitize_text_field ( wp_unslash ( $ _SERVER ['REQUEST_URI ' ] ) ) : '' ;
35+ return esc_url ( apply_filters ( 'self_link ' , set_url_scheme ( 'http:// ' . $ host ['host ' ] . $ path ) ) );
36+ }
37+ }
Original file line number Diff line number Diff line change @@ -439,19 +439,6 @@ function is_single_user() {
439439 return false ;
440440}
441441
442- if ( ! function_exists ( 'get_self_link ' ) ) {
443- /**
444- * Returns the link for the currently displayed feed.
445- *
446- * @return string Correct link for the atom:self element.
447- */
448- function get_self_link () {
449- $ host = wp_parse_url ( home_url () );
450- $ path = isset ( $ _SERVER ['REQUEST_URI ' ] ) ? sanitize_text_field ( wp_unslash ( $ _SERVER ['REQUEST_URI ' ] ) ) : '' ;
451- return esc_url ( apply_filters ( 'self_link ' , set_url_scheme ( 'http:// ' . $ host ['host ' ] . $ path ) ) );
452- }
453- }
454-
455442/**
456443 * Check if a site supports the block editor.
457444 *
You can’t perform that action at this time.
0 commit comments