'', 'post_author' => \__( 'Post Author (user_id)', 'activitypub' ), 'title' => \__( 'Post', 'activitypub' ), 'comments' => \__( 'Comments', 'activitypub' ), 'date' => \__( 'Publication Date', 'activitypub' ), 'migrate' => \__( 'Migrate', 'activitypub' ), ); } public function get_sortable_columns() { return array(); } public function prepare_items() { $columns = $this->get_columns(); $hidden = array( 'post_author', 'migrate' ); $sortable = $this->get_sortable_columns(); $this->process_action(); $this->_column_headers = array( $columns, $hidden, $sortable ); foreach ( \Activitypub\Tools\Posts::get_posts_to_migrate() as $post ) { $this->items[] = array( 'post_author' => $post->post_author, 'title' => \sprintf( '%2s', \get_permalink( $post->ID ), $post->post_title ), 'comments' => $post->comment_count, 'date' => $post->post_date, 'migrate' => \get_post_meta( $post->ID, '_activitypub_permalink_compat', true ), ); } // pagination $per_page = $this->get_items_per_page( 'elements_per_page', 10 ); $current_page = $this->get_pagenum(); $total_items = count( $this->items ); $table_data = array_slice( $this->items, ( ( $current_page - 1 ) * $per_page ), $per_page ); $this->set_pagination_args( array( 'total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil( $total_items / $per_page ), ) ); // actions if ( isset( $_REQUEST['_wpnonce'] ) ) { $nonce = \esc_attr( $_REQUEST['_wpnonce'] ); } // delete if ( isset( $_REQUEST['action'] ) && 'activitypub_tools' === $_REQUEST['page'] && 'delete_notice' === $_REQUEST['action'] ) { if ( wp_verify_nonce( $nonce, 'activitypub_migrate_actions' ) ) { //\Activitypub\Tools\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'] ) && 'activitypub_tools' === $_REQUEST['page'] && 'delete' === $_REQUEST['action'] ) { if ( wp_verify_nonce( $nonce, 'activitypub_migrate_actions' ) ) { \Activitypub\Tools\Posts::migrate_post( rawurldecode( $_REQUEST['post_url'] ), absint( $_REQUEST['post_author'] ) ); \delete_post_meta( \url_to_postid( $_REQUEST['post_url'] ), '_activitypub_permalink_compat' ); } } } public function single_row( $item ) { $inline_styles = ( $item['comments'] > 0 ) ? 'warning' : ''; ?>