• Resolved jane-taubman

    (@jane-taubman)


    add_action( 'admin_init', 'rjt_load_tables' );
    
    function rjt_load_tables() {
    if(function_exists('add_db_table_editor')){
     add_db_table_editor('title=Products&table=wp_rjt_product');
    
    add_db_table_editor(array( 'title'=>'Prices', 'table'=>'wp_rjt_prices'));
     }
    }

    I am using the above in a plug to try and add two tables to the Dashboard on my site. Both tables exist, and if I put a “hello world” in the middle it appears on the admin screen.

    Trying to add this with out using the hook fails as my plugin gets started before the add_db_table_editor function is available.

    Sorry if I am doing something stupid.

    https://www.ads-software.com/plugins/wp-db-table-editor/

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

    (@bobbysmith007)

    That all seems quite reasonable… I am not sure what this issue is, but I will look into it. Perhaps there is some event ordering aspect that I am not currently aware of / thinking about.

    Plugin Author bobbysmith007

    (@bobbysmith007)

    Ok, the problem is that admin_init is unintuitively called after admin_menu. Since admin_menu is the event used by wp-db-table-editor, you will need to hook that with a lower priority than the plugin.

    add_action( 'admin_menu', 'rjt_load_tables', -10 );
    solves the problem for me. Please feel free to reopen if it doesnt resolve this issue for you. I will also update the readme.

    Thanks!

    Thread Starter jane-taubman

    (@jane-taubman)

    Thanks very much, that fixed it. Sorry to have troubled you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Problem getting started’ is closed to new replies.