> $actions * @return array> */ public static function remove_o2_action_edit( array $actions ): array { if ( ! self::should_show_compact_view() ) { return $actions; } return array_filter( $actions, function ( $action ) { return 'edit' !== $action['action']; } ); } public static function get_post_content_preview( string $content, bool $is_xpost ): string { if ( ! $is_xpost ) { // No content preview for regular posts. return ''; } // Get origin (+myp2) from string "X-post from +myp2 : My P2 Post Title". preg_match( '/((?:\+|�?43;)[\w]+)/', $content, $matches ); if ( ! isset( $matches[1] ) ) { return $content; } return sprintf( /* Translators: %s is the name of a blog */ _x( 'From %s', 'Post is from (blog name)', 'p2020' ), $matches[1] ); } public static function get_post_title_preview( string $title, bool $is_xpost ): string { if ( $is_xpost ) { $title = preg_replace( '/X\-Post:|X\-Comment:/i', '', $title ); } return $title; } /** * @param array $fragment * @return array */ public static function format_post_preview( array $fragment ): array { if ( ! self::should_show_compact_view() ) { return $fragment; } // Process post content preview. $fragment['contentPreview'] = self::get_post_content_preview( $fragment['contentRaw'], $fragment['is_xpost'] ); // Clear contentRaw as we no longer need it, and we'd rather not send it down. $fragment['contentRaw'] = ''; // Process post title. $fragment['titleFiltered'] = self::get_post_title_preview( $fragment['titleFiltered'], $fragment['is_xpost'] ); if ( empty( trim( $fragment['titleFiltered'] ) ) ) { $fragment['isUntitled'] = true; } return $fragment; } public static function disable_xpost_hovercards( bool $setting ): bool { if ( self::should_show_compact_view() ) { return true; } return $setting; } /** * @param array $args * @return array */ public static function o2_fragment_get_fragment_args( array $args ): array { if ( self::should_show_compact_view() ) { $args['skip']['post'] = [ 'contentFiltered' => true, 'mentions' => true, 'tags' => true, 'shortcodes' => true, 'comments' => true, ]; } return $args; } /** * Filter callback. * * Group pinned posts when in compact mode. */ public static function filter_should_group_pinned_posts( bool $should_group ): bool { if ( self::should_show_compact_view() ) { return true; } return $should_group; } }