@@ -256,15 +256,17 @@ public static function get_comment_type_strings() {
256256 }
257257
258258 /**
259- * Returns an array of post formats (with articlex )
259+ * Returns an array of post types (with articles )
260260 *
261261 * @return array The array of translated comment type names.
262262 */
263- public static function get_post_format_strings () {
263+ public static function get_post_type_strings () {
264264 $ strings = array (
265- // Special case. any value that evals to false will be considered standard
265+ // Generic Post Types
266+ 'post ' => __ ( 'this Post ' , 'semantic-linkbacks ' ),
267+ 'page ' => __ ( 'this Page ' , 'semantic-linkbacks ' ),
268+ // Post Format Types
266269 'standard ' => __ ( 'this Article ' , 'semantic-linkbacks ' ),
267-
268270 'aside ' => __ ( 'this Aside ' , 'semantic-linkbacks ' ),
269271 'chat ' => __ ( 'this Chat ' , 'semantic-linkbacks ' ),
270272 'gallery ' => __ ( 'this Gallery ' , 'semantic-linkbacks ' ),
@@ -409,6 +411,39 @@ public static function comment_text_add_cite( $text, $comment = null, $args = ar
409411 return $ text . sprintf ( $ cite , $ url , $ host );
410412 }
411413
414+ /**
415+ * Returns a post type that is used to generate text. This can be from post formats/kinds/post type/etc
416+ *
417+ * @param int $post_id Post ID
418+ *
419+ * @return string the post type
420+ */
421+ public static function get_post_type ( $ post_id ) {
422+ $ post_typestrings = self ::get_post_type_strings ();
423+ $ post_format = 'post ' ;
424+ if ( 'page ' === get_post_type ( $ post_id ) ) {
425+ $ post_format = 'page ' ;
426+ }
427+ if ( current_theme_supports ( 'post-formats ' ) ) {
428+ $ post_format = get_post_format ( $ post_id );
429+ // add "standard" as default for post format enabled types
430+ if ( ! $ post_format || ! in_array ( $ post_format , array_keys ( $ post_typestrings ), true ) ) {
431+ $ post_format = 'standard ' ;
432+ }
433+ }
434+
435+ $ post_type = $ post_typestrings [ $ post_format ];
436+
437+ // If this is the page homepages are redirected to then use the site name
438+ if ( $ post_id === get_option ( 'webmention_home_mentions ' , 0 ) ) {
439+ $ post_type = get_bloginfo ( 'name ' );
440+ }
441+
442+ return apply_filters ( 'semantic_linkbacks_post_type ' , $ post_type , $ post_id );
443+ }
444+
445+
446+
412447 /**
413448 * Generate excerpt for all types except "reply"
414449 *
@@ -441,21 +476,7 @@ public static function comment_text_excerpt( $text, $comment = null, $args = arr
441476 $ semantic_linkbacks_type = 'mention ' ;
442477 }
443478
444- if ( ! current_theme_supports ( 'post-formats ' ) ) {
445- $ post_format = 'standard ' ;
446- } else {
447- $ post_format = get_post_format ( $ comment ->comment_post_ID );
448- // add "standard" as default
449- if ( ! $ post_format || ! in_array ( $ post_format , array_keys ( self ::get_post_format_strings () ), true ) ) {
450- $ post_format = 'standard ' ;
451- }
452- }
453-
454- // get post type
455- $ post_formatstrings = self ::get_post_format_strings ();
456- $ post_type = $ post_formatstrings [ $ post_format ];
457-
458- $ post_type = apply_filters ( 'semantic_linkbacks_post_type ' , $ post_type , $ comment ->comment_post_ID );
479+ $ post_type = self ::get_post_type ( $ comment ->comment_post_ID );
459480
460481 // get all the excerpts
461482 $ comment_type_excerpts = self ::get_comment_type_excerpts ();
0 commit comments