Custom Fields
Re-Envisioned
Support MB Frontend Submission Duplicate Dashboard Shortcode

  • Creator
    Topic
  • #31295
    Resolved Ole Poetter
    Participant

    Hi 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,
    Ole

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #31308
    Long Nguyen
    Moderator

    Hi 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']

    #31312
    Ole Poetter
    Participant

    Hi 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,
    Ole

    #31319
    Long Nguyen
    Moderator

    Hi,

    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.

    #31320
    Ole Poetter
    Participant

    Hi Long,

    thank you very much.
    I figure it out.

    For information adding
    use MetaBox\Support\Arr;
    is enough. When adding

    use WP_Query;
    use WP_Error;

    too, I get another Warning.

    Kind regards,
    Ole

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.