ID, 'spfaq_knowledge_nonce' ); $excluded = 'excluded' === get_post_meta( $post->ID, '_spfaq_sync', true ); echo '

'; if ( 'publish' === $post->post_status ) { $status = SPFAQ_API_Mapper::sync_status( $post, SPFAQ_API_Mapper::content_hash( $post ) ); echo '

' . esc_html__( 'Sync status:', 'spindle-faq' ) . ' ' . esc_html( self::status_label( $status ) ) . '

'; echo '

' . esc_html__( 'Stable ID:', 'spindle-faq' ) . ' ' . esc_html( SPFAQ_API_Mapper::uid( $post->ID ) ) . '

'; } else { echo '

' . esc_html__( 'Only published FAQs are shared.', 'spindle-faq' ) . '

'; } $suggested = (int) get_post_meta( $post->ID, '_spfaq_suggest_count', true ); if ( $suggested ) { /* translators: %d: how many times visitors asked this question */ echo '

' . esc_html( sprintf( _n( 'Suggested %d time by a companion plugin.', 'Suggested %d times by a companion plugin.', $suggested, 'spindle-faq' ), $suggested ) ) . '

'; } } /** * Human label for a status. * * @param string $status Status. * @return string */ public static function status_label( $status ) { $labels = array( 'indexed' => __( 'Indexed', 'spindle-faq' ), 'stale' => __( 'Stale (changed since indexed)', 'spindle-faq' ), 'pending' => __( 'Not indexed yet', 'spindle-faq' ), 'excluded' => __( 'Excluded', 'spindle-faq' ), ); return $labels[ $status ] ?? $status; } /** * Add the sync column. * * @param array $columns Columns. * @return array */ public static function columns( $columns ) { $options = SPFAQ_API_Options::options(); if ( ! empty( $options['enabled'] ) ) { $columns['spfaq_sync'] = __( 'Chat sync', 'spindle-faq' ); } return $columns; } /** * Render the sync column. * * @param string $column Column. * @param int $post_id Post ID. */ public static function column( $column, $post_id ) { if ( 'spfaq_sync' !== $column ) { return; } $post = get_post( $post_id ); if ( ! $post || 'publish' !== $post->post_status ) { echo '—'; return; } echo esc_html( self::status_label( SPFAQ_API_Mapper::sync_status( $post, SPFAQ_API_Mapper::content_hash( $post ) ) ) ); } }