PluginProbe
Friends / 4.3.2
Friends v4.3.2
4.3.2 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 All 88 releases
← All changes | includes/class-messages.php +21 -0 4.3.14.3.2 View file →
@@ -160,8 +160,29 @@
160 160 $post_types = array( self::CPT );
161 161 return $post_types;
162 162 }
163 163
164 + /**
165 + * Look up a direct message by its URL.
166 + *
167 + * Messages live in their own post type which is not part of the frontend post
168 + * types, so Feed::url_to_postid() doesn't consider them by default.
169 + *
170 + * @param string $url The URL of the message.
171 + *
172 + * @return int|null The post ID or null if it wasn't found.
173 + */
174 + public static function url_to_postid( $url ) {
175 + $only_messages = function () {
176 + return array( self::CPT );
177 + };
178 +
179 + add_filter( 'friends_frontend_post_types', $only_messages, 999 );
180 + $post_id = Feed::url_to_postid( $url );
181 + remove_filter( 'friends_frontend_post_types', $only_messages, 999 );
182 +
183 + return $post_id;
184 + }
164 185
165 186 public function save_incoming_message( User $friend_user, $message, $subject = '', $feed_url = null, $remote_url = null, $reply_to = null ) {
166 187 $post_data = array(
167 188 'post_type' => self::CPT,