• Resolved David Gewirtz

    (@dgewirtz)


    Is it possible/how would I add some text or HTML between the title of an admin page and the fields on the page. I’d like to add a description for a child page or, possibly, embed some HTML.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Thread Starter David Gewirtz

    (@dgewirtz)

    That works well for given fields. Is there any way to hook into the option page title itself? I tried a bunch of the before_ and after_ options with no luck on the new_cmb2_box call.

    Thanks!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    hmm

    I believe you could potentially handle that with your own custom display callback, but that’s a fair amount of potential work.

    I’m also seeing these hooks that are before the output of the forms, but not sure exactly where in the context it’d show to say the options page title:

    /**
     * Hook before form table begins
     *
     * @param array  $cmb_id      The current box ID.
     * @param int    $object_id   The ID of the current object.
     * @param string $object_type The type of object you are working with.
     *                            Usually <code>post</code> (this applies to all post-types).
     *                            Could also be <code>comment</code>, <code>user</code> or <code>options-page</code>.
     * @param array  $cmb         This CMB2 object.
     */
    do_action( 'cmb2_before_form', $this->cmb_id, $object_id, $object_type, $this );
    
    /**
     * Hook before form table begins
     *
     * The first dynamic portion of the hook name, $object_type, is the type of object
     * you are working with. Usually <code>post</code> (this applies to all post-types).
     * Could also be <code>comment</code>, <code>user</code> or <code>options-page</code>.
     *
     * The second dynamic portion of the hook name, $this->cmb_id, is the meta_box id.
     *
     * @param array  $cmb_id      The current box ID
     * @param int    $object_id   The ID of the current object
     * @param array  $cmb         This CMB2 object
     */
    do_action( "cmb2_before_{$object_type}_form_{$this->cmb_id}", $object_id, $this );
    

    Worth trying.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Adding text/html between title and fields’ is closed to new replies.