PluginProbe
Friends / 4.2.0
Friends v4.2.0
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.2.0, at friends.php

194 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.2.0
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.2.0' );
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-abilities.php';
46 require_once __DIR__ . '/includes/class-blocks.php';
47 require_once __DIR__ . '/includes/class-feed.php';
48 require_once __DIR__ . '/includes/class-frontend.php';
49 require_once __DIR__ . '/includes/class-import.php';
50 require_once __DIR__ . '/includes/class-logging.php';
51 require_once __DIR__ . '/includes/class-messages.php';
52 require_once __DIR__ . '/includes/class-migration.php';
53 require_once __DIR__ . '/includes/class-notifications.php';
54 require_once __DIR__ . '/includes/class-reactions.php';
55 require_once __DIR__ . '/includes/class-rest.php';
56 require_once __DIR__ . '/includes/class-site-health.php';
57 require_once __DIR__ . '/includes/class-shortcodes.php';
58 require_once __DIR__ . '/includes/class-template-loader.php';
59 require_once __DIR__ . '/includes/class-third-parties.php';
60 require_once __DIR__ . '/includes/class-friend-tag.php';
61 require_once __DIR__ . '/includes/class-friends.php';
62
63 add_action( 'plugins_loaded', array( __NAMESPACE__ . '\Friends', 'init' ) );
64
65 if ( is_admin() && version_compare( get_option( 'friends_plugin_version' ), FRIENDS_VERSION, '<' ) ) {
66 add_action( 'admin_init', array( __NAMESPACE__ . '\Friends', 'upgrade_plugin' ) );
67 }
68
69 add_action( 'upgrader_process_complete', array( __NAMESPACE__ . '\Friends', 'upgrade_plugin_trigger' ), 10, 2 );
70 register_activation_hook( __FILE__, array( __NAMESPACE__ . '\Friends', 'activate_plugin' ) );
71 register_deactivation_hook( __FILE__, array( __NAMESPACE__ . '\Friends', 'deactivate_plugin' ) );
72 register_uninstall_hook( __FILE__, array( __NAMESPACE__ . '\Friends', 'uninstall_plugin' ) );
73
74 add_action( 'activate_blog', array( __NAMESPACE__ . '\Friends', 'activate_plugin' ) );
75 add_action( 'wp_initialize_site', array( __NAMESPACE__ . '\Friends', 'activate_for_blog' ) );
76
77 // Register widgets.
78 add_filter( 'customize_loaded_components', array( __NAMESPACE__ . '\Frontend', 'ensure_widget_editing' ) );
79
80 require_once __DIR__ . '/widgets/class-widget-base-friends-list.php';
81 require_once __DIR__ . '/widgets/class-widget-add-subscription.php';
82 add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Add_Subscription', 'register' ) );
83
84 require_once __DIR__ . '/widgets/class-widget-refresh.php';
85 add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Refresh', 'register' ) );
86
87 require_once __DIR__ . '/widgets/class-widget-friends-list.php';
88 add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Friends_List', 'register' ) );
89
90 require_once __DIR__ . '/widgets/class-widget-starred-friends-list.php';
91 add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Starred_Friends_List', 'register' ) );
92
93 require_once __DIR__ . '/widgets/class-widget-recent-friends-list.php';
94 add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Recent_Friends_List', 'register' ) );
95
96 require_once __DIR__ . '/widgets/class-widget-friend-stats.php';
97 add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Friend_Stats', 'register' ) );
98
99 require_once __DIR__ . '/widgets/class-widget-post-formats.php';
100 add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Post_Formats', 'register' ) );
101
102 require_once __DIR__ . '/widgets/class-widget-header.php';
103 add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Header', 'register' ) );
104
105 // Register bundled parsers.
106 add_action(
107 'friends_load_parsers',
108 function ( Feed $friends_feed ) {
109 require_once __DIR__ . '/feed-parsers/class-feed-parser-simplepie.php';
110 $friends_feed->register_parser( Feed_Parser_SimplePie::SLUG, new Feed_Parser_SimplePie( $friends_feed ) );
111 },
112 9
113 );
114
115 add_action(
116 'friends_load_parsers',
117 function ( Feed $friends_feed ) {
118 require_once __DIR__ . '/feed-parsers/class-feed-parser-microformats.php';
119 $friends_feed->register_parser( Feed_Parser_Microformats::SLUG, new Feed_Parser_Microformats() );
120 },
121 9
122 );
123
124 add_action(
125 'friends_load_parsers',
126 function ( Feed $friends_feed ) {
127 require_once __DIR__ . '/feed-parsers/class-feed-parser-json-feed.php';
128 $friends_feed->register_parser( Feed_Parser_JSON_Feed::SLUG, new Feed_Parser_JSON_Feed() );
129 },
130 9
131 );
132
133 add_action(
134 'friends_load_parsers',
135 function ( \Friends\Feed $friends_feed ) {
136 if ( ! class_exists( '\Activitypub\Activitypub' ) ) {
137 // ActivityPub plugin not active.
138 return;
139 }
140
141 global $wp_filter;
142 if ( isset( $wp_filter['friends_load_parsers']->callbacks[10] ) && class_exists( '\\ReflectionFunction' ) ) {
143 // Unhook the parser from ActivityPub 0.14.
144 foreach ( $wp_filter['friends_load_parsers']->callbacks[10] as $key => $hook ) {
145 $r = new \ReflectionFunction( $hook['function'] );
146 if ( \str_ends_with( $r->getFileName(), 'activitypub.php' ) ) {
147 remove_filter( 'friends_load_parsers', $hook['function'], 10 );
148 break;
149 }
150 }
151 }
152
153 require_once __DIR__ . '/feed-parsers/class-feed-parser-activitypub.php';
154 $friends_feed->register_parser( Feed_Parser_ActivityPub::SLUG, new Feed_Parser_ActivityPub( $friends_feed ) );
155 },
156 9
157 );
158
159 // Global functions, for phpcs.
160 /**
161 * Validate feed catch_all
162 *
163 * @param array $catch_all The catch_all value to.
164 * @return array A valid catch_all
165 */
166 function validate_feed_catch_all( $catch_all ) {
167 return Feed::validate_feed_catch_all( $catch_all );
168 }
169
170 /**
171 * Validate feed item rules
172 *
173 * @param array $rules The rules to validate.
174 * @return array The valid rules.
175 */
176 function validate_feed_rules( $rules ) {
177 return Feed::validate_feed_rules( $rules );
178 }
179
180 /**
181 * Check whether this is a valid URL
182 *
183 * @param string $url The URL to check.
184 * @return false|string URL or false on failure.
185 */
186 function check_url( $url ) {
187 return Friends::check_url( $url );
188 }
189
190 // Integrations.
191
192 require_once __DIR__ . '/integrations/class-enable-mastodon-apps.php';
193 Enable_Mastodon_Apps::init();
194