Duplicate Dashboard Shortcode
Support › MB Frontend Submission › Duplicate Dashboard ShortcodeResolved
- This topic has 4 replies, 2 voices, and was last updated 3 years, 6 months ago by
Ole Poetter.
-
AuthorPosts
-
October 13, 2021 at 6:16 PM #31295
Ole Poetter
ParticipantHi Long,
in this topic you said:
The main function of this file is to create the shortcode [mb_frontend_dashboard], you can copy the content in the file Dashboard.php to the file functions.php in the theme folder then change the name of the class, shortcode, URL ... to create your own shortcode and show on the page.
Which part of the dashboard.php has to be copied?
Kind regards,
OleOctober 13, 2021 at 11:19 PM #31308Long Nguyen
ModeratorHi Ole,
All code from line 8 to the end
class Dashboard { ... }
and you need to instantiate the class once. For example: You can add this code to the file functions.php https://pastebin.com/mZ5PCPhT
Then use the custom shortcode[custom_frontend_dashboard edit_page='12345']
October 14, 2021 at 12:22 PM #31312Ole Poetter
ParticipantHi Long,
thank you.
But this gives me
Fatal error: Uncaught Error: Class 'Arr' not found in /var/www/vhosts/server.de/xxx-xxx.com/member/wp-content/themes/blocksy-child/functions.php:144 Stack trace: #0 /var/www/vhosts/server.de/xxx-xxx.com/member/wp-content/themes/blocksy-child/functions.php(71): My_Dashboard->show_user_posts(Array) #1 /var/www/vhosts/server.de/xxx-xxx.com/member/wp-includes/shortcodes.php(356): My_Dashboard->shortcode(Array, '', 'custom_frontend...') #2 [internal function]: do_shortcode_tag(Array) #3 /var/www/vhosts/server.de/xxx-xxx.com/member/wp-includes/shortcodes.php(228): preg_replace_callback('/\\[(\\[?)(custom...', 'do_shortcode_ta...', '[custom_fronten...') #4 /var/www/vhosts/server.de/xxx-xxx.com/member/wp-includes/class-wp-hook.php(303): do_shortcode('[custom_fronten...') #5 /var/www/vhosts/server.de/pagebuilder-s in /var/www/vhosts/server.de/xxx-xxx.com/member/wp-content/themes/blocksy-child/functions.php on line 144
Line 140 - 150:
?> <table class="mbfs-posts"> <tr> <?php $columns = Arr::from_csv( $atts['columns'] ); if ( in_array( 'title', $columns ) ) { echo '<th>', esc_html( $atts['label_title'] ), '</th>'; } if ( in_array( 'date', $columns ) ) { echo '<th>', esc_html( $atts['label_date'] ), '</th>'; }
Kind regards,
OleOctober 14, 2021 at 6:48 PM #31319Long Nguyen
ModeratorHi,
Please try to add this code above the class
use WP_Query; use WP_Error; use MetaBox\Support\Arr; class My_Dashboard { ... }
I've re-checked the code and it works as well on my demo site.
October 14, 2021 at 6:56 PM #31320Ole Poetter
ParticipantHi Long,
thank you very much.
I figure it out.For information adding
use MetaBox\Support\Arr;
is enough. When addinguse WP_Query; use WP_Error;
too, I get another Warning.
Kind regards,
Ole -
AuthorPosts
- You must be logged in to reply to this topic.