hey Matthew can you post the full code to the solution whenever your close to the code to your plugin ??
creating functions confuses the eff out of me :(.
i seriously dont know how to use string replace to edit this
function gtf_get_mark_topic_read_link( $topic_id = 0 ) {
if ( !bbp_is_single_topic() ) {
return;
}
$topic_id = bbp_get_topic_id( $topic_id );
$url = admin_url(‘admin-ajax.php’);
$content = “
<span id=’gtf-mark-topic-read’>
<span id=’gtf-mark-topic-read-{$topic_id}’>
<a href='#' rel='nofollow'>Mark Topic Read</a>
<—change to Mark Read
</span>
?|? <—delete this
</span>
<script type=’text/javascript’>
jQuery(‘#gtf-mark-topic-read-link’).click( function(e) {
e.preventDefault();
var data = {
action: ‘mark_topic_read’,
topic_id: jQuery(this).data(‘topic’)
};
jQuery.post(‘{$url}’, data, function(response) {
jQuery(‘#gtf-mark-topic-read-{$topic_id}’).html(response);
});
});
</script>
“;
return apply_filters( ‘gtf_get_mark_topic_read_link’, $content, $topic_id );
}
function gtf_update_topic_last_read_meta( $user_id, $topic_id ) {
$last_reply_id = bbp_get_topic_last_reply_id( $topic_id );
$last_read_id = get_user_meta( $user_id, ‘gtf-last-read-‘ . $topic_id, true );
if ( empty( $last_read_id ) ) {
return add_user_meta( $user_id, ‘gtf-last-read-‘ . $topic_id, $last_reply_id, true );
} else if ( $last_read_id < $last_reply_id ) {
return update_user_meta( $user_id, ‘gtf-last-read-‘ . $topic_id, $last_reply_id );
} else {
return “Already Read”; <— change to Marked Read
}
}