pterotype/includes/commentlinks.php

51 lines
1.3 KiB
PHP
Raw Normal View History

<?php
namespace pterotype\commentlinks;
function get_object_id( $comment_id ) {
global $wpdb;
return $wpdb->get_var( $wpdb->prepare(
"SELECT object_id FROM {$wpdb->prefix}pterotype_comments WHERE comment_id = %d",
2018-10-28 17:23:36 +00:00
$comment_id
) );
}
function get_comment_id( $object_id ) {
global $wpdb;
return $wpdb->get_var( $wpdb->prepare(
"SELECT comment_id FROM {$wpdb->prefix}pterotype_comments WHERE object_id = %d",
2018-10-28 17:23:36 +00:00
$object_id
) );
}
function get_object_activitypub_id( $comment_id ) {
global $wpdb;
return $wpdb->get_var( $wpdb->prepare(
"
SELECT activitypub_id FROM {$wpdb->prefix}pterotype_comments
JOIN {$wpdb->prefix}pterotype_objects
ON {$wpdb->prefix}pterotype_comments.object_id = {$wpdb->prefix}pterotype_objects.id
WHERE comment_id = %d
",
$comment_id
) );
}
function link_comment( $comment_id, $object_id ) {
global $wpdb;
return $wpdb->insert(
"{$wpdb->prefix}pterotype_comments",
array( 'comment_id' => $comment_id, 'object_id' => $object_id ),
'%d'
);
}
function unlink_comment( $comment_id, $object_id ) {
global $wpdb;
return $wpdb->delete(
"{$wpdb->prefix}pterotype_comments",
array( 'comment_id' => $comment_id, 'object_id' => $object_id ),
'%d'
);
}
?>