PluginProbe
Friends / 4.0.6
Friends v4.0.6
4.3.1 4.3.0 4.2.2 4.2.1 4.2.0 4.1.0 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.0 2.9.1 2.9.2 All 87 releases
friends / friends.php

friends.php in Friends 4.0.6, at friends.php

193 lines 7.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin name: Friends
4 * Plugin URI: https://github.com/akirk/friends
5 * Version: 4.0.6
6 * Author: Alex Kirk
7 * Author URI: https://alex.kirk.at/
8 * Requires PHP: 7.4
9 *
10 * Description: A self-hosted social reader for WordPress: follow people via RSS and ActivityPub, with multiple themes and a plugin ecosystem.
11 *
12 * License: GPL2
13 * Text Domain: friends
14 * Domain Path: /languages/
15 *
16 * @package Friends
17 */
18
19 namespace Friends;
20
21 /**
22 * This file loads all the dependencies the Friends plugin.
23 */
24
25 defined( 'ABSPATH' ) || exit;
26 define( 'FRIENDS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
27 define( 'FRIENDS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
28 define( 'FRIENDS_PLUGIN_FILE', plugin_dir_path( __FILE__ ) . '/' . basename( __FILE__ ) );
29 define( 'FRIENDS_VERSION', '4.0.6' );
30
31 require_once __DIR__ . '/libs/Mf2/Parser.php';
32
33 require_once __DIR__ . '/includes/class-user.php';
34 require_once __DIR__ . '/includes/class-user-feed.php';
35 require_once __DIR__ . '/includes/class-user-query.php';
36 require_once __DIR__ . '/includes/class-user-query-result.php';
37 require_once __DIR__ . '/includes/class-subscription.php';
38
39 // Classes to be implemented or used by parser plugins.
40 require_once __DIR__ . '/feed-parsers/class-feed-parser.php';
41 require_once __DIR__ . '/feed-parsers/class-feed-parser-v2.php';
42 require_once __DIR__ . '/feed-parsers/class-feed-item.php';
43
44 require_once __DIR__ . '/includes/class-admin.php';
45 require_once __DIR__ . '/includes/class-blocks.php';
46 require_once __DIR__ . '/includes/class-feed.php';
47 require_once __DIR__ . '/includes/class-frontend.php';
48 require_once __DIR__ . '/includes/class-import.php';
49 require_once __DIR__ . '/includes/class-logging.php';
50 require_once __DIR__ . '/includes/class-messages.php';
51 require_once __DIR__ . '/includes/class-migration.php';
52 require_once __DIR__ . '/includes/class-notifications.php';
53 require_once __DIR__ . '/includes/class-reactions.php';
54 require_once __DIR__ . '/includes/class-rest.php';
55 require_once __DIR__ . '/includes/class-site-health.php';
56 require_once __DIR__ . '/includes/class-shortcodes.php';
57 require_once __DIR__ . '/includes/class-template-loader.php';
58 require_once __DIR__ . '/includes/class-third-parties.php';
59 require_once __DIR__ . '/includes/class-friend-tag.php';
60 require_once __DIR__ . '/includes/class-friends.php';
61
62 add_action( 'plugins_loaded', array( __NAMESPACE__ . '\Friends', 'init' ) );
63
64 if ( is_admin() && version_compare( get_option( 'friends_plugin_version' ), FRIENDS_VERSION, '<' ) ) {
65 add_action( 'admin_init', array( __NAMESPACE__ . '\Friends', 'upgrade_plugin' ) );
66 }
67
68 add_action( 'upgrader_process_complete', array( __NAMESPACE__ . '\Friends', 'upgrade_plugin_trigger' ), 10, 2 );
69 register_activation_hook( __FILE__, array( __NAMESPACE__ . '\Friends', 'activate_plugin' ) );
70 register_deactivation_hook( __FILE__, array( __NAMESPACE__ . '\Friends', 'deactivate_plugin' ) );
71 register_uninstall_hook( __FILE__, array( __NAMESPACE__ . '\Friends', 'uninstall_plugin' ) );
72
73 add_action( 'activate_blog', array( __NAMESPACE__ . '\Friends', 'activate_plugin' ) );
74 add_action( 'wp_initialize_site', array( __NAMESPACE__ . '\Friends', 'activate_for_blog' ) );
75
76 // Register widgets.
77 add_filter( 'customize_loaded_components', array( __NAMESPACE__ . '\Frontend', 'ensure_widget_editing' ) );
78
79 require_once __DIR__ . '/widgets/class-widget-base-friends-list.php';
80 require_once __DIR__ . '/widgets/class-widget-add-subscription.php';
81 add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Add_Subscription', 'register' ) );
82
83 require_once __DIR__ . '/widgets/class-widget-refresh.php';
84 add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Refresh', 'register' ) );
85
86 require_once __DIR__ . '/widgets/class-widget-friends-list.php';
87 add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Friends_List', 'register' ) );
88
89 require_once __DIR__ . '/widgets/class-widget-starred-friends-list.php';
90 add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Starred_Friends_List', 'register' ) );
91
92 require_once __DIR__ . '/widgets/class-widget-recent-friends-list.php';
93 add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Recent_Friends_List', 'register' ) );
94
95 require_once __DIR__ . '/widgets/class-widget-friend-stats.php';
96 add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Friend_Stats', 'register' ) );
97
98 require_once __DIR__ . '/widgets/class-widget-post-formats.php';
99 add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Post_Formats', 'register' ) );
100
101 require_once __DIR__ . '/widgets/class-widget-header.php';
102 add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Header', 'register' ) );
103
104 // Register bundled parsers.
105 add_action(
106 'friends_load_parsers',
107 function ( Feed $friends_feed ) {
108 require_once __DIR__ . '/feed-parsers/class-feed-parser-simplepie.php';
109 $friends_feed->register_parser( Feed_Parser_SimplePie::SLUG, new Feed_Parser_SimplePie( $friends_feed ) );
110 },
111 9
112 );
113
114 add_action(
115 'friends_load_parsers',
116 function ( Feed $friends_feed ) {
117 require_once __DIR__ . '/feed-parsers/class-feed-parser-microformats.php';
118 $friends_feed->register_parser( Feed_Parser_Microformats::SLUG, new Feed_Parser_Microformats() );
119 },
120 9
121 );
122
123 add_action(
124 'friends_load_parsers',
125 function ( Feed $friends_feed ) {
126 require_once __DIR__ . '/feed-parsers/class-feed-parser-json-feed.php';
127 $friends_feed->register_parser( Feed_Parser_JSON_Feed::SLUG, new Feed_Parser_JSON_Feed() );
128 },
129 9
130 );
131
132 add_action(
133 'friends_load_parsers',
134 function ( \Friends\Feed $friends_feed ) {
135 if ( ! class_exists( '\Activitypub\Activitypub' ) ) {
136 // ActivityPub plugin not active.
137 return;
138 }
139
140 global $wp_filter;
141 if ( isset( $wp_filter['friends_load_parsers']->callbacks[10] ) && class_exists( '\\ReflectionFunction' ) ) {
142 // Unhook the parser from ActivityPub 0.14.
143 foreach ( $wp_filter['friends_load_parsers']->callbacks[10] as $key => $hook ) {
144 $r = new \ReflectionFunction( $hook['function'] );
145 if ( \str_ends_with( $r->getFileName(), 'activitypub.php' ) ) {
146 remove_filter( 'friends_load_parsers', $hook['function'], 10 );
147 break;
148 }
149 }
150 }
151
152 require_once __DIR__ . '/feed-parsers/class-feed-parser-activitypub.php';
153 $friends_feed->register_parser( Feed_Parser_ActivityPub::SLUG, new Feed_Parser_ActivityPub( $friends_feed ) );
154 },
155 9
156 );
157
158 // Global functions, for phpcs.
159 /**
160 * Validate feed catch_all
161 *
162 * @param array $catch_all The catch_all value to.
163 * @return array A valid catch_all
164 */
165 function validate_feed_catch_all( $catch_all ) {
166 return Feed::validate_feed_catch_all( $catch_all );
167 }
168
169 /**
170 * Validate feed item rules
171 *
172 * @param array $rules The rules to validate.
173 * @return array The valid rules.
174 */
175 function validate_feed_rules( $rules ) {
176 return Feed::validate_feed_rules( $rules );
177 }
178
179 /**
180 * Check whether this is a valid URL
181 *
182 * @param string $url The URL to check.
183 * @return false|string URL or false on failure.
184 */
185 function check_url( $url ) {
186 return Friends::check_url( $url );
187 }
188
189 // Integrations.
190
191 require_once __DIR__ . '/integrations/class-enable-mastodon-apps.php';
192 Enable_Mastodon_Apps::init();
193