BuddyDev

Search

Adding MediaPress custom post type meta box in WordPress admin?

  • Participant
    Kevin on #13498

    Hi all,

    I’m new here and am evaluating MediaPress for a site I’m about to start.

    Basically users signup or register, then they can nominate a project for a prize. As part of the nomination they can add photos to a gallery. So I’m using Theme My Login for theming the registration pages which is all good. I’m automatically creating a nomination (post type) when they to the nomination form, this autosaves. I will probably automatically create a MediaPress gallery at that point too.

    As well as letting users create nominations, the Admins also need to be able to see and possibly edit the gallery within WordPress admin on the nomination post.

    So in order to test this I’m just adding a custom meta box to the post type for now with the MPP shortcode:

    `
    function custom_meta_box_markup()
    {
    echo ‘meta’;
    echo do_shortcode(‘[mpp-uploader gallery_id=74]’);
    }
    function add_custom_meta_box()
    {
    add_meta_box(“demo-meta-box”, “Custom Meta Box”, “\Bbc\custom_meta_box_markup”, “entry”, “normal”, “high”, null);
    }
    add_action(“add_meta_boxes”, “\Bbc\add_custom_meta_box”);
    `

    Note, I’m hardcoding the ID of an existing gallery just to test. The problem I have is that although the markup is there, none of the functionality or styling is there in admin.

    My guess is that I just need enqueue the right plugin libraries in admin but how would I do that?

    Much appreciated
    Kev

  • Keymaster
    (BuddyDev Team)
    Posts: 21852
    Brajesh Singh on #13506

    Hi Kevin,
    Welcome to BuddyDev.

    Thank you for looking into MediaPress.

    Even though it is possible to get the editing capability on the backend post type screen, I will recommend linking to the actual gallery edit screen(I believe you wanted this for site admins).

    here is a modified version of your metabox.

    
    
    function custom_meta_box_markup()
    {
        $gallery_id = 74;
        $gallery = mpp_get_gallery( $gallery_id );
    
        printf( 'Associated Gallery: <a href="%1$s">%2$s</a><br/>', mpp_get_gallery_permalink( $gallery ), mpp_get_gallery_title( $gallery ) );
        printf( "Uploaded Media: %d <br/>", mpp_gallery_get_media_count( $gallery ) );
    
    	edit_post_link( "Edit", '', '', $gallery_id );
    }
    
    

    Hope that helps.

    regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved