{"id":28511,"date":"2014-03-26T18:28:04","date_gmt":"2014-03-26T18:28:04","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/wp-db-table-editor\/"},"modified":"2020-03-11T21:24:46","modified_gmt":"2020-03-11T21:24:46","slug":"wp-db-table-editor","status":"closed","type":"plugin","link":"https:\/\/wordpress.org\/plugins\/wp-db-table-editor\/","author":81086,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"1.8.4","stable_tag":"trunk","tested":"5.3.21","requires":"3.0.0","requires_php":"","requires_plugins":"","header_name":"DB-table-editor","header_author":"Russ Tyndall @ Acceleration.net","header_description":"","assets_banners_color":"","last_updated":"2020-03-11 21:24:46","external_support_url":"","external_repository_url":"","donate_link":"https:\/\/www.acceleration.net\/programming\/donate-to-acceleration-net\/","header_plugin_uri":"http:\/\/github.com\/AcceleratioNet\/wp-db-table-editor","header_author_uri":"http:\/\/www.acceleration.net","rating":4.2,"author_block_rating":0,"active_installs":800,"downloads":54785,"num_ratings":18,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":"4","2":0,"3":0,"4":0,"5":"15"},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":[],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":"2259397","resolution":"1","location":"plugin"}},"screenshots":{"1":"Here's a screenshot of it in action"},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[68419,153,1332],"plugin_category":[46,59],"plugin_contributors":[],"plugin_business_model":[],"class_list":["post-28511","plugin","type-plugin","status-closed","hentry","plugin_tags-admin-screens","plugin_tags-database","plugin_tags-editor","plugin_category-editor-and-writing","plugin_category-utilities-and-tools","plugin_committers-bobbysmith007"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/wp-db-table-editor.svg","icon_2x":false,"generated":true},"screenshots":[{"src":"https:\/\/ps.w.org\/wp-db-table-editor\/trunk\/screenshot-1.png?rev=2259397","caption":"Here's a screenshot of it in action"}],"raw_content":"<!--section=description-->\n<p>This is a Wordpress plugin that allows direct excel-like editing of\ntables in your Wordpress database.  It's goals are to provide useful,\nsimple, flexible database table admin screens.<\/p>\n\n<p>It supports:<\/p>\n\n<ul>\n<li>one table per admin screen, as many admin screens as desired\n\n<ul>\n<li>These are organized under a new \"DB Table Editor\" menu item<\/li>\n<\/ul><\/li>\n<li>excel spreadsheet like interface using SlickGrid<\/li>\n<li>Filter and Sort results<\/li>\n<li>Add, Edit &amp; Delete records<\/li>\n<li>Custom buttons extensibility<\/li>\n<li>Custom permissions per interface for viewing and editing \n(defaults to: edit_others_posts)\n\n<ul>\n<li>editing defaults to the same permission as viewing if not specified<\/li>\n<\/ul><\/li>\n<li>CSV exports of filtered grid<\/li>\n<li>Custom primary key names (but must be a single value \/ column)<\/li>\n<\/ul>\n\n<h3>Adding an Interface on the fly<\/h3>\n\n<p>If we go to look up a database table editor and we dont find it, but\nthere is a function named dbte_create_$tbl that matches, we will call\nthat function expecting it to return a dbte instance. This is useful\nin situations where we may not have the data for a table editor in all\ncircumstances (EG: not every page has a member id, so only do it on\nthat particular page).<\/p>\n\n<h3>Adding an Interface from a plugin<\/h3>\n\n<p>If you need to add an interface from a plugin, you should use the\n    admin_menu action with a lower than default priority.<\/p>\n\n<p>eg: <code>add_action( 'admin_menu', 'my_load_tables', -10 );<\/code><\/p>\n\n<p>Inside of the <code>my_load_tables<\/code> function you would include all the\ncalls to add_db_table_editor<\/p>\n\n<h3>Custom Buttons<\/h3>\n\n<p>Buttons can be created by pushing functions into\n    DBTableEditor.extraButtons.  Each of these is a slick grid\nrowButtonFormatter and should return a string of html.<\/p>\n\n<p>eg:\n   out += fn(row, cell, value, columnDef, dataContext);<\/p>\n\n<p>The button column width can be set by setting:\nDBTableEditor.buttonColumnWidth before the ready function is called<\/p>\n\n<h4>Hooks \/ Actions<\/h4>\n\n<ul>\n<li><p><code>db-table-editor_enqueue_scripts<\/code> is an action that will be called\nafter enqueueing all plugin scripts and before enqueueing <code>jsFile<\/code>\n(if it exists)<\/p>\n\n<p><code>function dbTableEditorScripts(){\nwp_register_script('employee-table-extensions-js',\nget_stylesheet_directory_uri().'\/employee-table.js',\narray('db-table-editor-js'));\n}\nadd_action('db-table-editor_enqueue_scripts', 'dbTableEditorScripts');<\/code><\/p><\/li>\n<\/ul>\n\n<h3>dbte_row_deleted, dbte_row_updated, dbte_row_inserted<\/h3>\n\n<p>Called after a row is deleted, updated, or inserted passes<\/p>\n\n<pre><code>`\n<\/code><\/pre>\n\n<p>add_action('dbte_row_deleted', 'my_dbte_row_deleted', 10, 2);<\/p>\n\n<p>function my_dbte_row_deleted($currentTable, $idRemoved){\n  \/\/ do things\n}<\/p>\n\n<p>add_action('dbte_row_updated', 'my_dbte_row_upserted', 10, 4);\nadd_action('dbte_row_inserted', 'my_dbte_row_upserted', 10, 4);<\/p>\n\n<p>function my_dbte_row_upserted($currentTable, $values, $columns, $indexedModified){\n  \/\/ do things\n}<\/p>\n\n<pre><code>`\n<\/code><\/pre>\n\n<h4>Shortcodes<\/h4>\n\n<p>You can use a shortcode to include a dbte interface on a wordpress\npage.  Please use with care.<\/p>\n\n<p>[dbte id=table-editor-id] - (id defaults to table)<\/p>\n\n<h3>Caveats<\/h3>\n\n<ul>\n<li>Dont put an editable table editor on your public facing screens using the shortcode!<\/li>\n<\/ul>\n\n<h3>Troubleshooting<\/h3>\n\n<p>Feel free to ask support questions \/ open trouble tickets<\/p>\n\n<ul>\n<li>https:\/\/wordpress.org\/support\/plugin\/wp-db-table-editor<\/li>\n<li>https:\/\/github.com\/AccelerationNet\/wp-db-table-editor\/issues<\/li>\n<\/ul>\n\n<h3>Advanced Examples<\/h3>\n\n<h3>Custom Javascript and Buttons on the table editor<\/h3>\n\n<p>See: examples\/custom-buttons-and-js.php\n     examples\/custom-buttons.js<\/p>\n\n<p>Shows how to add custom javascript to a report page and adds a custom\nload button on the grid<\/p>\n\n<h3>CF7 DB Submit Plugin integration<\/h3>\n\n<p>See: examples\/cf7dbsubmit_integration.php<\/p>\n\n<p>This is not a fully runnable example, but should give good examples of<\/p>\n\n<ul>\n<li>working cf7dbsubmit plugin<\/li>\n<li>Custom save delete hooks<\/li>\n<li>custom complex sql building with this plugin<\/li>\n<li>sending notifications on edit of specific fields<\/li>\n<\/ul>\n\n<p>cf7dbsubmit stores its data in a \"hashtable\" format of:<\/p>\n\n<p>form, submit_time, field_name, field_value<\/p>\n\n<p>but we want to present this in a more excel fasion of each field being\na column of our spreadsheet and each row being a different submission<\/p>\n\n<h3>Contributers and Thanks<\/h3>\n\n<ul>\n<li>bobbysmith007 \/ Acceleration.net - Primary developer of plugin<\/li>\n<li>nikomuse - i18n support<\/li>\n<\/ul>\n\n<!--section=installation-->\n<p>This is installed the same way all wordpress plugins:<\/p>\n\n<ul>\n<li><p>Drop the unzipped plugin directory into your wordpress install at\n   wp-content\/plugins\/wp-db-table-editor<\/p><\/li>\n<li><p>Activate the plugin via the Wordpress Admin &gt; \"Plugins\" menu<\/p><\/li>\n<\/ul>\n\n<h4>Adding an interface<\/h4>\n\n<p>DB-Table Editor Interfaces are added by calling the\nadd_db_table_editor function in your theme's <code>functions.php<\/code> file.\nThis supports <code>wp_parse_args<\/code> style arguments.<\/p>\n\n<ul>\n<li><code>title<\/code>: what shows up in the H1 on the screen and in menues\n\n<ul>\n<li>ex: <code>title=&gt;\"My Product Reports Page\"<\/code><\/li>\n<\/ul><\/li>\n<li><code>table<\/code>: the table we wish to display \/ edit\n\n<ul>\n<li>ex: <code>table=&gt;\"wp_my_custom_table\"<\/code><\/li>\n<\/ul><\/li>\n<li><code>id<\/code>: the admin interface id (defaults to table)\n\n<ul>\n<li>ex: <code>id=&gt;\"custom_table_interface_1\"<\/code><\/li>\n<\/ul><\/li>\n<li><code>id_column<\/code>: the column in each row that names the id for the row\n\n<ul>\n<li>ex: <code>id_column=&gt;\"id\"<\/code><\/li>\n<\/ul><\/li>\n<li><code>dataFn<\/code>: a function that returns the data to be displayed \/\nedited, defaults to <code>select * from {table}<\/code>. This should return ARRAY_N\nthrough wpdb-&gt;get_results. Alternatively it may return a DBTE_DataTable.\n   dataFn is called with the arguemnts array to add_db_table_editor;\n\n<ul>\n<li>ex: <code>dataFn=&gt;\"myCustomInterfaceFunction\"<\/code><\/li>\n<\/ul><\/li>\n<li><code>jsFile<\/code>: the name of a registered script that will be enqueued for\nthis interface\n\n<ul>\n<li>ex: <code>jsFile=&gt;\"my-custom-interface-js\"<\/code><\/li>\n<\/ul><\/li>\n<li><code>cap<\/code>: the capability a user needs to view\/edit this interface,\ndefaults to edit_others_posts\n\n<ul>\n<li>ex: <code>cap=&gt;\"edit_others_posts\"<\/code><\/li>\n<\/ul><\/li>\n<li><code>editcap<\/code>: the capability required to edit the grid, if not set\nall viewers are assumed to be editors\n\n<ul>\n<li>ex: <code>editcap=&gt;\"edit_others_posts\"<\/code><\/li>\n<\/ul><\/li>\n<li><code>noedit<\/code>: turns off the editing abilities (same as editcap=nosuchcapability)\n\n<ul>\n<li>ex: <code>noedit=&gt;true<\/code><\/li>\n<\/ul><\/li>\n<li><code>columnFilters<\/code>: Default column filters, this is an array of column-&gt;val\nto be applied as default column fitlers when the page is loaded\n\n<ul>\n<li>ex: <code>columnFilters=&gt;Array(\"Year\"=&gt;\"2017\")<\/code><\/li>\n<\/ul><\/li>\n<li><code>columnNameMap<\/code>: A map of actual column names to displayed label\n\n<ul>\n<li>Ex: <code>columnNameMap=&gt;Array('column_name'=&gt;'Column Alias')<\/code><\/li>\n<\/ul><\/li>\n<li><code>noedit_columns<\/code>, <code>hide_columns<\/code>: You may wish to hide some columns\nor prevent edit.  You may do so by setting these fields to the name\nof columns you wish hidden or uneditable (eg: the id)\n\n<ul>\n<li>Ex:<code>noedit_columns=&gt;\"data,id\"<\/code> or <code>noedit_columns=&gt;Array('data', 'id')<\/code><\/li>\n<\/ul><\/li>\n<li><code>save_cb<\/code>, <code>delete_cb<\/code>: function names to be called with an array of data:\nthe dbte, update array, column array and modified indexes array\n   call_user_func($cur-&gt;save_cb,Array('table'=&gt;$cur, 'update'=&gt;$up,\n                     'columns'=&gt;$cols, 'indexes'=&gt;$idxs, 'id'=&gt;$id));\n   call_user_func($cur-&gt;delete_cb,$cur,$id);\nIf your call back inserts data it should fill in $data['id'] and accept data\nby reference<\/li>\n<li><code>auto_date<\/code>: should columns that appear to be datetimes, be treated as such\nThis is based on the columns data type\n\n<ul>\n<li>Sort of buggy but allows some different date formats than iso8601<\/li>\n<li>Ex:<code>auto_date=&gt;true<\/code><\/li>\n<\/ul><\/li>\n<li><code>autoHeight<\/code>: passes the autoHeight option to slickgrid (makes\nthere not be a vertical scrollbar on the grid and instead in the\nwindow)\n\n<ul>\n<li>Ex:<code>auto_height=&gt;true<\/code><\/li>\n<\/ul><\/li>\n<li><code>async_data<\/code>: request data asyncronously instead of inlining\nit. Makes slow queries \"seem\" faster.\n\n<ul>\n<li>Ex:<code>async_data=&gt;true<\/code><\/li>\n<\/ul><\/li>\n<li><code>default_values<\/code>: an a_array of default values that new rows should have\n\n<ul>\n<li>Ex:<code>default_values=&gt;Array(\"name\"=&gt;\"First M Last\")<\/code><\/li>\n<\/ul><\/li>\n<li><code>export_id_field<\/code>: the field to use when limiting the export results\n\n<ul>\n<li>some sql needs a specific field - defaults to <code>table<\/code>.<code>id_col<\/code><\/li>\n<li>Ex:<code>\"export_id_field\"=&gt;\"mytbl.fooid\"<\/code><\/li>\n<\/ul><\/li>\n<\/ul>\n\n<p>Example:<\/p>\n\n<pre><code>`\n<\/code><\/pre>\n\n<p>if(function_exists('add_db_table_editor')){\n  add_db_table_editor('title=Employees&amp;table=employees');<\/p>\n\n<p>add_db_table_editor(array(\n    'title'=&gt;'Event Registrations',\n    'table'=&gt;'event_registrations',\n    'sql'=&gt;'SELECT * FROM event_registrations ORDER BY date_entered DESC'\n  ));<\/p>\n\n<p>}\n    `<\/p>\n\n<h4>Reasons and Expectations<\/h4>\n\n<p>Previously my company had been using DB-toolkit to provide minimal\ndatabase interfaces for custom tables through the Wordpress admin.\nWhile the configuration was cumbersome for what we were doing, it did\nwork and was easier than writing anything.  However, when DB-Toolkit\nstopped being maintained and I couldn't find a simple, but suitable\nreplacement, I decided to tackle my goals more head on<\/p>\n\n<p>Use of this plugin requires a basic knowledge of PHP, and SQL.  It was\nwritten by a programmer to help accomplish his work and does not\ncurrently provide admin configuration screens (instead simple function\ncalls in your theme's functions file are used to configure the\nscreens).  This was preferable to me, because my configuration is\nsafely in source control (a problem I had when DB-toolkit would\nupgrade and lose all configuration).<\/p>\n\n<!--section=faq-->\n<ul>\n<li>I dont see any interface \/ nothing changed?\n\n<ul>\n<li>Did you complete the installation process, including appropriate\nadd_db_table_editor calls?<\/li>\n<li>My delete button is missing \/ I Can't Edit<\/li>\n<li>You either dont have <code>editcap<\/code> or <code>id_column<\/code> is misconfigured<\/li>\n<li>https:\/\/github.com\/AccelerationNet\/wp-db-table-editor\/issues\/5<\/li>\n<\/ul><\/li>\n<\/ul>\n\n<!--section=changelog-->\n<p>For detailed information, please view:<\/p>\n\n<p>https:\/\/github.com\/AccelerationNet\/wp-db-table-editor\/commits<\/p>\n\n<p>Version: 1.6.0 - 2017-02-23\n    * New (customized) version of SlickGrid (branched from 6pac@github)\n      * allow access to the default filter and the filtered items\n    * Handle exports by sending a list of ids to export rather than\n      trying to recreate the full filter set serverside. Allows rather\n      arbitrary JS filtering functions without having to get nitty gritty\n      on the server<\/p>\n\n<p>Version: 1.5.6 - 2017-02-22\n    * allow easy button column width configuration<\/p>\n\n<p>Version: 1.5.5 - 2016-12-16\n    * fix deprecated constructor<\/p>\n\n<p>Version: 1.5.4 - 2016-12-06\n    * trim noedit_columns!<\/p>\n\n<p>Version: 1.5.3 - 2016-03-14\n    * Better numeric sorting<\/p>\n\n<p>Version: 1.5.2 - 2015-11-28\n    * fixed confused ajax-vs-async nomenclature<\/p>\n\n<p>Version: 1.5.1 - 2015-09-21\n    * Fixed bug with new rows without default values<\/p>\n\n<p>Version: 1.5 - 2015-09-15\n    * replace update &amp; insert call backs and actions with dbte_save\n      that passes an argument array instead of list of arguments.\n      should hopefully make upgrading easier (updated example).\n      This also allows the callback to set the \"id\" of the argument\n      array (should be passed by ref) in case of insert.\n    * async_data: option makes the grid pull data using ajax instead of\n      inlining it.  This might make the page appear more responsive if\n      the query takes forever. You are probably better off improving\n      your query.\n    * when calling save ajax, pass all query arguments for the current\n      page.  Also set default values along the way<\/p>\n\n<p>Version: 1.4.2 - 2015-08-17\n    * bug fixes: new rows were not updating their id\n    * saving now submits the currently active cell if there is one<\/p>\n\n<p>Version: 1.4.1 - 2015-06-19\n    * added some missing files for translation<\/p>\n\n<p>Version: 1.4 - 2015-06-18\n    * nikomuse provided i18n support<\/p>\n\n<p>Version: 1.3.2 - 2015-03-30\n    * introduce action <code>db_table_editor_init<\/code>, for other plugins\n      to use<\/p>\n\n<p>Version: 1.3.1 - 2015-03-30\n    * Introduce PhpSqlParser and use it instead of my\n      half-implemented index scanning, for inserting the where clause<\/p>\n\n<p>Version: 1.3 - 2015-02-18 10:30\n    * !! API CHANGE <code>update_cb<\/code>, <code>delete_cb<\/code>, and <code>dbte_row_updated<\/code>\n      all accept ID arguments -- TODO: perhaps these should accept\n      keyword arg arrays, to make it handle upgrades more gracefully?<\/p>\n\n<p>Version: 1.2.8 - 2015-02-04 10:30\n    * better docs\n    * better examples\n    * dbte_row_inserted, dbte_row_updated, dbte_row_deleted actions<\/p>","raw_excerpt":"This is a Wordpress plugin that allows direct excel-like editing of","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/28511","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=28511"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/bobbysmith007"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=28511"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=28511"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=28511"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=28511"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=28511"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=28511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}