code cleanup

This commit is contained in:
Django Doucet 2022-10-01 23:17:47 -06:00
parent be9b74478d
commit aa1b54462e
3 changed files with 51 additions and 44 deletions

View file

@ -128,7 +128,12 @@ class Activity_Dispatcher {
$activitypub_activity = new \Activitypub\Model\Activity( 'Delete', \Activitypub\Model\Activity::TYPE_SIMPLE );
$activitypub_activity->set_id( $activitypub_url . '#delete' );
$activitypub_activity->set_actor( $actor );
$activitypub_activity->set_object( array( "id" => $activitypub_url, "type" => "Tombstone" ) );
$activitypub_activity->set_object(
array(
'id' => $activitypub_url,
'type' => 'Tombstone',
)
);
$activitypub_activity->set_deleted( $deleted );
foreach ( \Activitypub\get_follower_inboxes( $user_id ) as $inbox => $to ) {

View file

@ -42,7 +42,7 @@ class Migrate_List extends \WP_List_Table {
);
}
/* pagination */
// pagination
$per_page = $this->get_items_per_page( 'elements_per_page', 10 );
$current_page = $this->get_pagenum();
$total_items = count( $this->items );
@ -51,23 +51,23 @@ class Migrate_List extends \WP_List_Table {
array(
'total_items' => $total_items,
'per_page' => $per_page,
'total_pages' => ceil( $total_items / $per_page )
'total_pages' => ceil( $total_items / $per_page ),
)
);
/* actions */
// actions
if ( isset( $_REQUEST['_wpnonce'] ) ) {
$nonce = \esc_attr( $_REQUEST['_wpnonce'] );
}
// delete
if (isset($_REQUEST['action']) && $_REQUEST['page'] == "activitypub_tools" && $_REQUEST['action'] == "delete") {
if ( isset( $_REQUEST['action'] ) && 'activitypub_tools' === $_REQUEST['page'] && 'delete' === $_REQUEST['action'] ) {
if ( wp_verify_nonce( $nonce, 'activitypub_delete_post' ) ) {
\Activitypub\Migrate\Posts::delete_url( rawurldecode( $_REQUEST['post_url'] ), absint( $_REQUEST['post_author'] ) );
\delete_post_meta( \url_to_postid( $_REQUEST['post_url'] ), '_activitypub_permalink_compat' );
}
}
// delete and announce
if (isset($_REQUEST['action']) && $_REQUEST['page'] == "activitypub_tools" && $_REQUEST['action'] == "delete_and_boost") {
if ( isset( $_REQUEST['action'] ) && 'activitypub_tools' === $_REQUEST['page'] && 'delete_announce' === $_REQUEST['action'] ) {
if ( wp_verify_nonce( $nonce, 'activitypub_delete_announce_post' ) ) {
\Activitypub\Migrate\Posts::migrate_post( rawurldecode( $_REQUEST['post_url'] ), absint( $_REQUEST['post_author'] ) );
\delete_post_meta( \url_to_postid( $_REQUEST['post_url'] ), '_activitypub_permalink_compat' );
@ -92,24 +92,26 @@ class Migrate_List extends \WP_List_Table {
case 'migrate':
return $item[ $column_name ];
default:
return print_r( $item, true ); //Show the whole array for troubleshooting purposes
return print_r( $item, true );
}
}
function column_title( $item ) {
public function column_title( $item ) {
$delete_announce_nonce = wp_create_nonce( 'activitypub_delete_announce_post' );
$delete_nonce = wp_create_nonce( 'activitypub_delete_post' );
$actions = array(
'delete_boost' => sprintf('<a href="?page=%s&action=%s&post_author=%s&post_url=%s&_wpnonce=%s">%s</a>',
'delete_announce' => sprintf(
'<a href="?page=%s&action=%s&post_author=%s&post_url=%s&_wpnonce=%s">%s</a>',
esc_attr( $_REQUEST['page'] ),
'delete_and_boost',
'delete_announce',
$item['post_author'],
\rawurlencode( $item['migrate'] ),
$delete_announce_nonce,
__( 'Delete & Announce', 'activitypub' )
),
'delete' => sprintf('<a href="?page=%s&action=%s&post_author=%s&post_url=%s&_wpnonce=%s">%s</a>',
'delete' => sprintf(
'<a href="?page=%s&action=%s&post_author=%s&post_url=%s&_wpnonce=%s">%s</a>',
esc_attr( $_REQUEST['page'] ),
'delete',
$item['post_author'],