michaeluno / admin-page-framework

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

Code field type #194

Closed vladkucherov closed 9 years ago

vladkucherov commented 9 years ago

Hi,

I would like to request a "code" field type that will have a textarea similar to JSFiddle.

Is it possible any time soon?

Thanks, Vlad.

michaeluno commented 9 years ago

Hi,

I guess the ace field type by Per Søderlind is what you are looking for. It is included in the demo component (Dashboard -> Demo -> Custom Field Types -> ACE ).

You may want to check it out.

vladkucherov commented 9 years ago

Hi,

Is there a chance to include it in the field types plugin / the main plugin?

michaeluno commented 9 years ago

Not likely to be built-in.

To register a custom field type, you just instantiate the class that defines the custom field type. It should be straight forward.

Let me know if you have any difficulty doing that.

vladkucherov commented 9 years ago

No difficulties, but it could be much easier if I didn't have to declare this:

new AceCustomFieldType( __CLASS__ );

in every metabox I create. also I think we should have a method to set global options (like all the field by default should be HTML and not CSS)

michaeluno commented 9 years ago

but it could be much easier if I didn't have to declare this:

As of v3.5, it is no longer required. Try not passing anything. It is still recommended to set a class though because if a class name is not set, the field type will be site-wide which can cause unexpected behavior for other plugins that use the framework.

vladkucherov commented 9 years ago

It doesn't work without declaring a class. the deceleration only works on demo mode (the file is not included)

is there away to initiate the class without including the file on demo off?

michaeluno commented 9 years ago

It doesn't work without declaring a class.

Have you tried this?

new AceCustomFieldType;

And comment out the other lines that pass the class name. This way, the field type will be registered site-wide not per a class basis.

vladkucherov commented 9 years ago

Yes I figured this out already. The problem is including the file... like with the rest of the files, I don't want to "know" the path to the file. especially if it's located inside "example"

maybe you should move the field type into the loader?

michaeluno commented 9 years ago

Just copy the class that defines the field type into your plugin/theme and include it from your convenient location. I don't see why this is hard.

vladkucherov commented 9 years ago

I am not saying it's hard, but I think everything related to the framework should be loaded by the framework. I am just trying to come up with a better solution :-) that's all

michaeluno commented 9 years ago

Maybe do you want an admin page that lists activated field types and lets you activate/deactivate/upload field types?

vladkucherov commented 9 years ago

Like an add-on to the minifier?

michaeluno commented 9 years ago

Like the plugins.php page of WordPress except that plugins are field types.

vladkucherov commented 9 years ago

This is of course a great idea :+1:

michaeluno commented 9 years ago

Can you post a new topic about it? I'm going to close this one as it seem to be resolved.