$label ) { if ( ! isset( $ordered[ $key ] ) ) { $ordered[ $key ] = $label; } } return $ordered; } /** * Render the group shortcode column. * * @param string $content Column HTML. * @param string $column Column key. * @param int $term_id Term ID. * @return string */ public function group_column( $content, $column, $term_id ) { if ( 'at_shortcode' !== $column ) { return $content; } $term = get_term( $term_id, Taxonomy::TAXONOMY ); if ( $term && ! is_wp_error( $term ) ) { $content = self::copy_code( '[advanced_testimonial group="' . $term->slug . '"]' ); } return $content; } /** * Add a "Copy shortcode" row action to testimonials (single-item shortcode). * * @param array $actions Existing actions. * @param \WP_Post $post Post. * @return array */ public function row_action( $actions, $post ) { if ( CPT::POST_TYPE === $post->post_type ) { $shortcode = '[advanced_testimonial ids="' . (int) $post->ID . '"]'; $actions['at_copy'] = '' . esc_html__( 'Copy shortcode', 'advanced-testimonial' ) . ''; } return $actions; } /** * Build a click-to-copy element. * * @param string $shortcode Shortcode text. * @return string */ public static function copy_code( $shortcode ) { return '' . esc_html( $shortcode ) . ''; } }