NEXT craftinamerica.org. Base setup for headless wordpress https://www.craftinamerica.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. class P2P_Column_User extends P2P_Column {
  3. function __construct( $directed ) {
  4. parent::__construct( $directed );
  5. add_action( 'pre_user_query', array( __CLASS__, 'user_query' ), 9 );
  6. add_filter( 'manage_users_custom_column', array( $this, 'display_column' ), 10, 3 );
  7. }
  8. protected function get_items() {
  9. global $wp_list_table;
  10. return $wp_list_table->items;
  11. }
  12. // Add the query vars to the global user query (on the user admin screen)
  13. static function user_query( $query ) {
  14. if ( isset( $query->_p2p_capture ) )
  15. return;
  16. // Don't overwrite existing P2P query
  17. if ( isset( $query->query_vars['connected_type'] ) )
  18. return;
  19. _p2p_append( $query->query_vars, wp_array_slice_assoc( $_GET,
  20. P2P_URL_Query::get_custom_qv() ) );
  21. }
  22. function get_admin_link( $item ) {
  23. $args = array(
  24. 'connected_type' => $this->ctype->name,
  25. 'connected_direction' => $this->ctype->flip_direction()->get_direction(),
  26. 'connected_items' => $item->get_id(),
  27. );
  28. $admin_link = apply_filters( "p2p_user_admin_column_link", add_query_arg( $args, admin_url( 'users.php' ) ), $item );
  29. return $admin_link;
  30. }
  31. function display_column( $content, $column, $item_id ) {
  32. return $content . parent::render_column( $column, $item_id );
  33. }
  34. }