1) How can I remove the link from appearing on "pages"? 2) How can I move links?

1) How would I stop the "Report This Post" link from appearing on "pages" and "comments"? I only want the links on posts.

2) I would like to move the location of the "Report This Post" link to a different location on my post pages. How can I do this? I have access to post filters and a number of hook locations for my posts.

Can I just create a link/button with the proper code and hook it into the position I would like it to appear? What would be the code?

Same as above applies to "Report This Blog" links.

Some additional controls for the plugin would be a nice to have.

Thanks,
Mark

  • Hoang Ngo
    • Code Slayer

    Hi @mark,

    1) How would I stop the "Report This Post" link from appearing on "pages" and "comments"? I only want the links on posts.

    We will need to modify some code.
    To disable the comment link, on the line 39 file wp-content/plugins/moderation/moderation.php, you will see the code like this

    $moderation_use_filters = array(
            'post'      => true,
            'comment'   => true,
            'blog'      => true,
        );

    We will need to update the comment to false, so the code will look like this

    $moderation_use_filters = array(
            'post'      => true,
            'comment'   => false,
            'blog'      => true,
        );

    And the comment link will be disabled.

    For the page, line 525 same file, you will see the code

    if ( !is_admin() && $wpdb->blogid != BLOG_ID_CURRENT_SITE && !is_search() && $moderation_use_filters['post'] === true) {
    		$link = moderation_report_link('post', $post->ID);
    	}

    Just need to change it to

    if ( !is_admin() && $wpdb->blogid != BLOG_ID_CURRENT_SITE && !is_search() && $moderation_use_filters['post'] === true) {
     if($post->post_type=='post')
    		$link = moderation_report_link('post', $post->ID);
    }

    2) I would like to move the location of the "Report This Post" link to a different location on my post pages. How can I do this? I have access to post filters and a number of hook locations for my posts.

    Yes, you can, for generate the link, you can check the function moderation_report_link on same file, basicly you can do a simple shortcode to output the link. So you can post the link any where you want on the post content.

    If you have any issues please don't hesitate to let us know so we can assist

    Best Regards
    Hoang

  • mark
    • WPMU DEV Initiate

    Thanks Hoang.
    I got the first part of turning off comments and removing link from pages.

    I love the idea of doing a shortcode.

    I know where I want to place the link but I would appreciate some further advice on which part of the code to use as the "link" and how to actually link it to the text, 'Report This Post'.

    Thanks,
    -mark

  • mark
    • WPMU DEV Initiate

    Hi Hoang,
    I want to place the link above the content. My theme has a meta filter admin page that makes it easy to insert code above post content on all posts.

    This is the code I have in place as a placeholder for "Report This Post".
    ==========================
    <div style="width:100%">
    <div style="float:left;width:20%">
    [post_date]
    </div>

    <div id="reportpost"><p class="report-post-message"> Report This Post Button Here </p>
    </div>

    </div>
    <div style="clear:both"> </div>

    =============================

    Thanks,
    -mark

  • Hoang Ngo
    • Code Slayer

    Hi

    If that support shortcode, that will very great.

    We can generate the link by shortcode, so basicly, the usage will be

    <div id="reportpost"><p class="report-post-message"> [report_this_post_link] </p>
    </div>

    And here is the shortcode

    add_shortcode('report_this_post_url', 'report_this_post_url');
    function report_this_post_url()
    {
        return moderation_report_link('post',get_the_ID());
    }

    Best Regards
    Hoang

  • mark
    • WPMU DEV Initiate

    Hoang,
    I added 2nd part of code to theme functions.php but not getting this to work.

    I tried placing it in different locations, different configurations, and even inserted it directly into single.php file using <?php echo do_shortcode.... like several other includes/snippets I have used in another site.

    Can't get it to work?

    -mark

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.