PluginProbe
Friends / trunk
Friends vtrunk
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 trunk, at friends.php

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