Support » Plugins » Hacks » Please help understanding why use this instead of

  • So I’ve been working with WP_List_Table reading from this guide I’m trying to understand why in:

    function column_booktitle($item) {
      $actions = array(
                'edit'      => sprintf('<a href="?page=%s&action=%s&book=%s">Edit</a>',$_REQUEST['page'],'edit',$item['ID']),
                'delete'    => sprintf('<a href="?page=%s&action=%s&book=%s">Delete</a>',$_REQUEST['page'],'delete',$item['ID']),
            );
      return sprintf('%1$s %2$s', $item['booktitle'], $this->row_actions($actions) );
    }

    do they use:

    return sprintf('%1$s %2$s', $item['booktitle'], $this->row_actions($actions) );

    instead of:

    return $item->name . $this->row_actions($actions);

    Is there any real reason? or just preference?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Another example. This might be me being silly but why use:

    function get_bulk_actions() {
      $actions = array(
        'delete'    => 'Delete'
      );
      return $actions;
    }

    instead of:

    function get_bulk_actions() {
      return $actions = array(
        'delete'    => 'Delete'
      );
    }

    wouldn’t it be faster to process in case 2, even if it is minuscule?

    or am I wrong and is there some purpose behind having it done the other way?

    both are syntactically correct, as for processing time, it doesn’t make enough of a difference to mean anything, it’s probably done moreso for ease of code following, no other reason.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Please help understanding why use this instead of’ is closed to new replies.