• Resolved tbare

    (@tbare)


    Is it possible to create the link from another plugin as opposed to the theme’s functions.php file?

    I’m trying to avoid hardcoding changes in a theme where the user may change themes (thus making a child theme irrelevant as well).

    I’m writing a custom plugin, and would love to be able to create the table link from there instead of the theme’s functions.php

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author bobbysmith007

    (@bobbysmith007)

    The theme file is merely the suggested call site to add_db_table_editor. You can call that function anywhere after it is defined and you can put the resulting data-table on any page you want (there is a shortcode [dbte id=my-table] or echo dbte_shortcode(Array("id"=>"my-table"))). Perhaps make use of the “plugins_loaded” action.

    Cheers,
    Russ

    Thread Starter tbare

    (@tbare)

    Thanks! I actually got there before I saw your reply — I was getting an error when I tried it, but then I realized it was because of the way i was adding the db table prefix. Got it resovled by doing this (for anyone else with the same question / issue):

    function  add_budget_number_table_editor() {
      global $wpdb;
      $table = $wpdb->prefix.'budget_numbers';
      add_db_table_editor(array( 'title'=>'Budget Numbers', 'table'=>$table, 'sql'=>"SELECT * FROM ".$table." ORDER BY id DESC" ));
    }
    add_action( 'plugins_loaded', ' add_budget_number_table_editor');
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add table in another plugin instead of theme’s functions?’ is closed to new replies.