• Resolved Advocat001

    (@advocat001)


    I’m looking to make two small customizations to my install, which will be used in a group project to analyze illustrations from an antique manuscript. While I’ve run text searches on the commentpress file folder, I’ve been unable to locate the line which writes the text:

    In the COMMENTS column, I’d like to have the text output:
    “Y Comments on Paragraph X” say instead “Y Comments on Item X”

    When clicking on the about link a text window opens with the title:
    “Leave a comment on paragraph X” which would have to changed to “Leave a comment on Item X”

    If you could point out the files where I can change these, it would be much appreciated.

    • This topic was modified 8 years, 6 months ago by Advocat001.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Christian Wach

    (@needle)

    Hi Advocat001,

    There is no need to change any files to achieve this – there is a filter in CommentPress Core 3.9 that you can use for this exact purpose called commentpress_lexia_block_name. Here’s an example where I replace “paragraph” with “verse” when displaying a Custom Post Type called ‘poem’:

    /**
     * Filter the name of the "paragraph" block.
     *
     * For example, the name of a block for a poem is "verse" rather than "paragraph".
     *
     * @param str $block_name The existing name of the block
     * @param str $block_type The type of block ('tag', 'line' or 'block')
     * @return str $block_name The modified name of the block
     */
    function my_poetry_plugin_filter_block_name( $block_name, $block_type ) {
    	if ( $block_type == 'tag' AND 'poem' == get_post_type() ) {
    		$block_name = __( 'verse', 'my-poetry-plugin' );
    	}
    	return $block_name;
    }
    add_filter( 'commentpress_lexia_block_name', 'my_poetry_plugin_filter_block_name', 10, 2 );
    

    Put the above code in the functions.php file of your child theme (you’re using a child theme, right?) and amend to suit your needs.

    CommentPress will automatically use the singular name of the Custom Post Type for the “whole page” section – in the above case, the section will read “Leave a comment on the whole Poem”. This can also be filtered using the commentpress_lexia_whole_entity_text filter if you need to do so.

    Cheers, Christian

    Thread Starter Advocat001

    (@advocat001)

    Marvelous, Christian! Works perfectly, thanks!

    Plugin Author Christian Wach

    (@needle)

    Thanks for letting me know.

    Cheers, Christian

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Customizing text in the Comments column’ is closed to new replies.