Last active
September 27, 2023 06:01
-
-
Save ahsannayem/4e6097bb6c5398f3dc2b1e127d4b8cdb to your computer and use it in GitHub Desktop.
Show table on the WordPress Deshboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'admin_menu', function () { | |
add_menu_page( 'Admin View', 'NT Admin', 'manage_options', 'myplugin/myplugin-admin-page.php', function () { | |
$tableId = 173; // This is ninja table ID; | |
ninjaRenderTableOnAdmin($tableId); | |
}, 'dashicons-tickets', 6 ); | |
} ); | |
// Global function to render a table in admin panel | |
function ninjaRenderTableOnAdmin($tableId) | |
{ | |
add_action('ninja_table_before_render_table_source', function ($table, $table_vars, $tableArray) { | |
add_action('admin_footer', function () use ($table_vars, $tableArray) { | |
?> | |
<script type="text/javascript"> | |
window['<?php echo $table_vars['instance_name'];?>'] = <?php echo json_encode($table_vars, true); ?> | |
</script> | |
<?php | |
}); | |
}, 10, 3); | |
echo "<div style='background: white;' class='ninja_table_admin_wrap wrap'>"; | |
echo do_shortcode('[ninja_tables id="'.$tableId.'"]'); | |
echo '</div>'; | |
} |
Tq ahsan. If i Want to ask you for custom plug-in. Can you do it for me?
…On Tue, 26 Sep 2023 at 6:35 PM, ahsannayem ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
Add the following code and make sure you have changed the table ID.
add_action( 'admin_menu', function () {
add_menu_page( 'Admin View', 'NT Admin', 'manage_options',
'myplugin/myplugin-admin-page.php', function () {
$tableId = 65; // This is ninja table ID;
ninjaRenderTableOnAdmin($tableId);
}, 'dashicons-tickets', 6 );
add_submenu_page(
'myplugin/myplugin-admin-page.php',
'Second Table',
'Second Table',
'manage_options',
'myplugin-admin-page.php',
function () {
$id = 66; // This is ninja table ID;
ninjaRenderTableOnAdmin($id);
}
);
} );
// Global function to render a table in admin panel
function ninjaRenderTableOnAdmin($tableId)
{
add_action('ninja_table_before_render_table_source', function ($table,
$table_vars, $tableArray) {
add_action('admin_footer', function () use ($table_vars, $tableArray) {
?>
<script type="text/javascript">
window[''] =
</script>
<?php
});
}, 10, 3);
echo "
";
echo do_shortcode('[ninja_tables id="'.$tableId.'"]');
echo '
';
}
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/ahsannayem/4e6097bb6c5398f3dc2b1e127d4b8cdb#gistcomment-4704491>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHXKFRR74QKJFWTDOWW5BDTX4KVX5BFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTEMZTGY2DKOBSU52HE2LHM5SXFJTDOJSWC5DF>
.
You are receiving this email because you commented on the thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
Certainly! Please feel free to contact me via email at [email protected] and provide me with all the necessary details.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add the following code and make sure you have changed the table ID.
add_action( 'admin_menu', function () {
add_menu_page( 'Admin View', 'NT Admin', 'manage_options', 'myplugin/myplugin-admin-page.php', function () {
$tableId = 65; // This is ninja table ID;
ninjaRenderTableOnAdmin($tableId);
}, 'dashicons-tickets', 6 );
add_submenu_page(
'myplugin/myplugin-admin-page.php',
'Second Table',
'Second Table',
'manage_options',
'myplugin-admin-page.php',
function () {
$id = 66; // This is ninja table ID;
ninjaRenderTableOnAdmin($id);
}
);
} );
// Global function to render a table in admin panel
function ninjaRenderTableOnAdmin($tableId)
{
add_action('ninja_table_before_render_table_source', function ($table, $table_vars, $tableArray) {
add_action('admin_footer', function () use ($table_vars, $tableArray) {
?>
<script type="text/javascript">
window[''] =
</script>
<?php
});
}, 10, 3);
echo "
echo do_shortcode('[ninja_tables id="'.$tableId.'"]');
echo '
}