{"id":4071,"date":"2015-12-22T10:04:53","date_gmt":"2015-12-22T09:04:53","guid":{"rendered":"https:\/\/plainviewplugins.com\/?page_id=4071"},"modified":"2018-02-10T20:32:14","modified_gmt":"2018-02-10T19:32:14","slug":"row-actions","status":"publish","type":"page","link":"https:\/\/plainviewplugins.com\/sdk\/row-actions\/","title":{"rendered":"Row actions"},"content":{"rendered":"<div id=\"attachment_4072\" style=\"width: 219px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4072\" class=\"size-full wp-image-4072\" src=\"https:\/\/plainviewplugins.com\/wp-content\/uploads\/2015\/12\/action_row_example.png\" alt=\"The main line and the row actions underneath\" width=\"209\" height=\"55\" srcset=\"https:\/\/plainviewplugins.com\/wp-content\/uploads\/2015\/12\/action_row_example.png 209w, https:\/\/plainviewplugins.com\/wp-content\/uploads\/2015\/12\/action_row_example-150x39.png 150w\" sizes=\"auto, (max-width: 209px) 100vw, 209px\" \/><p id=\"caption-attachment-4072\" class=\"wp-caption-text\">The main line and the row actions underneath<\/p><\/div>\n<p>Row actions are actions belonging to an item in a table. In the image above, the row actions are the three verbs underneath the item&#8217;s main line, or name.<\/p>\n<p>Each action consists of a linked text, with an optional link title.<\/p>\n<pre>\/\/ Create the row actions object\r\n$row_actions = $this-&gt;row_actions();\r\n\r\n\/\/ Set the base url, so that we don't have to set the ID for each action URL.\r\n$row_actions-&gt;url( add_query_arg( [ 'id' =&gt; $recording-&gt;id ] ) );\r\n\r\n\/\/ Create a new action\r\n$row_actions-&gt;action( 'edit' )\r\n \/\/ Set the URL, in this case using an array, like for add_query_arg\r\n -&gt;url( [ 'tab' =&gt; 'edit_recording' ] )\r\n \/\/ Translate the title\r\n -&gt;title_( 'Edit the recording' )\r\n \/\/ Set the translated action text\r\n -&gt;text( 'Edit' );\r\n\r\n\/\/ Retrieve an existing action\r\n$row_actions-&gt;action( 'edit' )\r\n \/\/ Set another text.\r\n -&gt;text( 'Edit this' );\r\n\r\n\/\/ New action\r\n$row_actions-&gt;action( 'view' )\r\n \/\/ Order from 10 to 99. 50 is the default.\r\n -&gt;sort_order( 25 )\r\n \/\/ Setting the URL directly\r\n -&gt;url( '?tab=edit' )\r\n \/\/ This title is not translated\r\n -&gt;title( 'View the recording' )\r\n \/\/ Set the text without translating it\r\n -&gt;text( 'View' );\r\n\r\n\/\/ The main row is optional, uses the same methods as the actions and can be set before or after the actions.\r\n$row_actions-&gt;main()\r\n -&gt;url( [ 'tab' =&gt; 'edit_recording' ] )\r\n -&gt;title( 'Edit the recording' )\r\n -&gt;text( 'A taxonomy recording' );\r\n\r\necho $row_actions;<\/pre>\n<h2>Ordering<\/h2>\n<p>When the actions are displayed, they are sorted first using the internal order number, then alphabetically.<\/p>\n<p>The default order is 50, with 10 coming before 50 which comes before 90.<\/p>\n<p>The order can be changed with <code>-&gt;sort_order( 25 )<\/code>.<\/p>\n<h2>Same as<\/h2>\n<p>Since the main action usually shares the same properties as the edit link, you can create it based off of an existing action.<\/p>\n<pre><code>$row_actions-&gt;main()\r\n \/\/ Copy the properties from the edit action\r\n -&gt;<strong>same_as( 'edit' )<\/strong>\r\n \/\/ But use our own text, instead of \"Edit\"\r\n -&gt;text( 'A taxonomy recording' );<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Row actions are actions belonging to an item in a table. In the image above, the row actions are the three verbs underneath the item&#8217;s main line, or name. Each action consists of a linked text, with an optional link title. \/\/ Create the row actions object $row_actions = $this-&gt;row_actions(); \/\/ Set the base url, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1676,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-4071","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/plainviewplugins.com\/wp-json\/wp\/v2\/pages\/4071","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/plainviewplugins.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/plainviewplugins.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/plainviewplugins.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/plainviewplugins.com\/wp-json\/wp\/v2\/comments?post=4071"}],"version-history":[{"count":11,"href":"https:\/\/plainviewplugins.com\/wp-json\/wp\/v2\/pages\/4071\/revisions"}],"predecessor-version":[{"id":4802,"href":"https:\/\/plainviewplugins.com\/wp-json\/wp\/v2\/pages\/4071\/revisions\/4802"}],"up":[{"embeddable":true,"href":"https:\/\/plainviewplugins.com\/wp-json\/wp\/v2\/pages\/1676"}],"wp:attachment":[{"href":"https:\/\/plainviewplugins.com\/wp-json\/wp\/v2\/media?parent=4071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}