michaeluno / admin-page-framework

Facilitates WordPress plugin and theme development.
http://admin-page-framework.michaeluno.jp/
Other
337 stars 71 forks source link

Can't change metabox position. #224

Closed ivandotv closed 8 years ago

ivandotv commented 8 years ago

Referring to the tutorial 9 Add metabox in admin page I can't seem to move the metabox in to the main area. It always appears on the side, context property doesn't change anything. And if I introduce sections, then metabox is pushed down. screenshot_00220151117 t

michaeluno commented 8 years ago

That's strange.

Can you check if you get the same problem in the loader plugin admin page accessed via Dashboard -> Admin Page Framework -> Help -> Report? That page has setting fields and also a page meta box.

ivandotv commented 8 years ago

Yes, metabox is in top right.

ivandotv commented 8 years ago

Try this code: I still can't make the metabox go to top right, maybe I'm doing somethign wrong, or it might be some kind of CSS issue.

class iki_MainThemeOptions extends AdminPageFramework {

    public function setUp() {

        $this->setRootMenuPage(
            'Theme Options'
        );

        $this->addSubMenuItems(
            array(
                'title'     => 'Global Options',
                'page_slug' => 'iki_global_options',
            ), array(
            'title'     => 'Second Global',
            'page_slug' => 'iki_other_options',
        ) );

        $this->addSettingSections(
            'iki_global_options',
            array(
                'section_id'  => 'my_first_section',
                'title'       => 'My First Form Section',
                'description' => 'This section is for text fields.',
            ),
            array(
                'section_id'  => 'my_second_section',
                'title'       => 'My Second Form Section',
                'description' => 'This section is for selectors.',
            )
        );
        $this->addSettingFields(
            'my_first_section',    // target page slug
            array(
                'field_id'   => 'my_color',
                'type'       => 'color',
                'title'      => 'Color',
                'repeatable' => true,
                'sortable'   => true,
            ),
            array(
                'field_id'   => 'my_image',
                'type'       => 'image',
                'title'      => 'Image',
                'repeatable' => true,
                'sortable'   => true,
                'attributes' => array(
                    'style' => 'max-width: 300px;',
                )
            )
        );
        $this->addSettingFields(
            'my_second_section',    // target page slug
            array(
                'field_id'   => 'my_color',
                'type'       => 'color',
                'title'      => 'Color',
                'repeatable' => true,
                'sortable'   => true,
            ),
            array(
                'field_id'   => 'my_image',
                'type'       => 'image',
                'title'      => 'Image',
                'repeatable' => true,
                'sortable'   => true,
                'attributes' => array(
                    'style' => 'max-width: 300px;',
                )
            )
        );
    }

}

new iki_MainThemeOptions();

and for metboxes

class APF_Tutorial_SidePageMetaBox extends AdminPageFramework_MetaBox_Page {

}

new APF_Tutorial_SidePageMetaBox(
    null,                                           // meta box id - passing null will make it auto generate
    __( 'Side Page Meta Box', 'admin-page-framework-tutorial' ), // title
    'iki_global_options',
    'normal',                                         // context
    'default'                                       // priority
);
michaeluno commented 8 years ago

It seems there is a bug in the framework core introduced in v3.5.5 that you can no longer able to add form fields without an in-page tab. This will be fixed in the next release. So for the time being, can you try to put form fields in in-page tabs?

And let me know if that does not solve this problem. Sorry for the inconvenience.

ivandotv commented 8 years ago

No problem.

michaeluno commented 8 years ago

It seems the dev version has a problem. If you are using it, can you go back to the stable version and see if the problem goes away?

To check the included library version, you can find it by moving your mouse over the footer link named Admin Page Framework in the created admin page.

michaeluno commented 8 years ago

I just noticed that you need to set side to the context parameter.

new APF_Tutorial_SidePageMetaBox(
    null,                                           // meta box id - passing null will make it auto generate
    __( 'Side Page Meta Box', 'admin-page-framework-tutorial' ), // title
    'iki_global_options',
    'side',                                         // context <--- this one!
    'default'                                       // priority
);

Let me know if this fixes your problem.

By the way, the dev branch has been updated and it fixes an issue of adding form fields without in-page tabs. Also never mind what I said that a bug was introduced in v3.5.5. That wasn't the case. The dev branch had an issue of loading incorrect files.

ivandotv commented 8 years ago

I've tried with side , it's not in the code I posted previously, put I've tried all three valid options.

michaeluno commented 8 years ago

Okay, I could confirm this problem finally when no side meta box exists and a normal oradvanced one gets added. I'll change the framework code to set 1 to the screen layout option when no side meta box exists.

Thanks for the report.

michaeluno commented 8 years ago

v3.6.5 has been released which includes this fix.