WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Safe Report Comments] Help for PHP noob: How i do manual link? (14 posts)

  1. hpguru
    Member
    Posted 3 years ago #

    In case this does not work out you can place the flagging link manually by defining no_autostart_safe_report_comments in your themes' functions.php file and initializing the class via $safe_report_comments = new Safe_Report_Comments(false);

    This text is nothing to me. So i want code to functions.php and comments.php, how i do this Report link manually?

    http://wordpress.org/extend/plugins/safe-report-comments/

  2. Thorsten Ott
    Member
    Posted 3 years ago #

    1) Deactivate the plugin
    2) Add the following lines to your themes' functions.php file

    define( 'no_autostart_safe_report_comments', true );
    require_once( ABSPATH . '/wp-content/plugins/safe-report-comments/safe-report-comments.php' );
    $safe_report_comments = new Safe_Report_Comments(false);

    3) at the place where you would like to add the report link place the following code
    echo $safe_report_comments->get_flagging_link( $comment_id='', $result_id='', $text='Report comment' );
    Make sure to replace the parameters with the desired values. result_id is the css id of the entity in which the ajax result should be displayed. $text is the link text.

    Please let me know if this makes any sense and works for you.

    Thorsten

  3. hpguru
    Member
    Posted 3 years ago #

    Fatal error: Call to a member function get_flagging_link() on a non-object in /home/hpguru/public_html/wp-content/themes/revolution-code-blue/comments.php on line 43

  4. Thorsten Ott
    Member
    Posted 3 years ago #

    can you paste the related parts of the comments.php and the functions.php?

  5. hpguru
    Member
    Posted 3 years ago #

    functions.php

    <?php
    if ( function_exists('register_sidebars') )
        register_sidebars(2);
    ?>
    <?php //Begin Theme Options Code
    $themename = "Revolution Code Blue";
    $shortname = "cb";
    $options = array (
    	array(	"name" => "Color Scheme",
    			"id" => $shortname."_color_scheme",
    			"std" => "Default",
    			"type" => "select",
                "options" => array("Blue","Gray","Red"))
    );
    function myFilter($query) {
        if ($query->is_feed) {
            $query->set('cat','-1323'); //Don't forget to change the category ID =^o^=
        }
    return $query;
    }
    add_filter('pre_get_posts','myFilter');
    function my_akismet_count() {
    $akismetcount = number_format_i18n(get_option('akismet_spam_count'));
    echo "<a href='http://akismet.com/'>Akismet</a> on suojannut blogia " . $akismetcount . " roskakommentilta";
    }
    define( 'no_autostart_safe_report_comments', true );
    require_once( ABSPATH . '/wp-content/plugins/safe-report-comments/safe-report-comments.php' );
    $safe_report_comments = new Safe_Report_Comments(false);
      function make_chunky($ret)
      {
    
    blah blah...

    comments.php

    <?php foreach ($comments as $comment) : ?>
    <?php $comment_type = get_comment_type(); ?>
    <?php if($comment_type == 'comment') { ?>
    
    		<li class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
    			<?php comment_author_link() ?> sanoi <?php comment_date('d.m.Y k\l\o\ H:i') ?> <?php edit_comment_link('(Muokkaa)','',''); ?><br />
    			<?php if ($comment->comment_approved == '0') : ?>
    			<em>Kommenttisi on moderoitavana.</em>
    			<?php endif; ?>
    
    	<div class="commenttext">
    
    		<?php comment_text() ?>
    
    <?php echo $safe_report_comments->get_flagging_link( $comment_id='', $result_id='', $text='Report comment' ); ?>
    
    	</div>
    
    	<div style="border-bottom: margin-bottom:20px; padding:0px 0px 10px 0px; clear:both;"></div>
    
    		</li>
    
    <?php } else { $trackback = true; } /* End of is_comment statement */ ?>
    
    	<?php endforeach; /* end for each comment */ ?>
    
    	</ol>
    
    <?php if ($trackback == true) { ?>
    <h4>Paluuviitteet</h4>
    <ol>
    <?php foreach ($comments as $comment) : ?>
    <?php $comment_type = get_comment_type(); ?>
    <?php if($comment_type != 'comment') { ?>
    <li><?php comment_author_link() ?></li>
    <?php } ?>
    <?php endforeach; ?>
    </ol>
    <br class="clear" />
    <br class="clear" />
    <?php } ?>
  6. Thorsten Ott
    Member
    Posted 3 years ago #

    First thing: could you verify that the path to the plugin file matches your environment in the require statement require_once( ABSPATH . '/wp-content/plugins/safe-report-comments/safe-report-comments.php' );
    Second: make sure that neither call $safe_report_comments = new Safe_Report_Comments(false); nor echo $safe_report_comments->get_flagging_link() are called within a function. If they are called from within a function make sure to add a global $safe_report_comments; statement before working with the $safe_report_comments variable.

  7. hpguru
    Member
    Posted 3 years ago #

    Path is ok.

    Is functions.php code ok?

    define( 'no_autostart_safe_report_comments', true );
    require_once( ABSPATH . '/wp-content/plugins/safe-report-comments/safe-report-comments.php' );
    $safe_report_comments = new Safe_Report_Comments(false);

    Is this code ok? I try it, but same error...

    <?php $safe_report_comments->get_flagging_link( $comment_id='', $result_id='', $text='Report comment' ); ?>

    Thank you. I'm very noob with PHP.

  8. Thorsten Ott
    Member
    Posted 3 years ago #

    You deactivated the plugin, right?
    Also try to use this in your comments.php file. Maybe your theme is using a callback function to generate the comments.
    <?php global $safe_report_comments; echo $safe_report_comments->get_flagging_link( $comment_id='', $result_id='', $text='Report comment' ); ?>

    Good luck

  9. hpguru
    Member
    Posted 3 years ago #

    Plugin is de-activated. I try your code now. Thank you.

  10. hpguru
    Member
    Posted 3 years ago #

    Now

    Wrong usage of print_flagging_link().

  11. Thorsten Ott
    Member
    Posted 3 years ago #

    You need to provide the $comment_id parameter when you are not using the get_flagging_link() function within the comment loop.

  12. hpguru
    Member
    Posted 3 years ago #

    Now i see report comments but when i try it, nothing happens.

  13. Thorsten Ott
    Member
    Posted 3 years ago #

    can I contact you via mail/skype?

  14. hpguru
    Member
    Posted 3 years ago #

    Yes. jyri.vaatainen(att)hpguru(dot)net

Topic Closed

This topic has been closed to new replies.

About this Topic