reduxframework / redux-framework

Redux is a simple, truly extensible options framework for WordPress themes and plugins!
http://redux.io
Other
1.73k stars 582 forks source link

Need some help on custom fields #2075

Closed itsabhik closed 9 years ago

itsabhik commented 9 years ago
  1. Redux Version : 3.4.1
  2. WordPress : 4.1.1
  3. Dev Mode : False
  4. -
  5. Standalone Theme (under development, based on _s)
  6. As a plugin (Installed and activated using TGM) 7 -

Hi, I need to create a new custom field based on multiple input text fields (to be very exact, its a bunch of text fields to store social media account URLs). I tried to clone the existing multi_text field with some modifications, but with no luck. Is there any way you can help me to do this? I am totally lost here.

The place where I am stuck is storing the value of each input in an array and retrieve it, sorry, but seems it requires advanced knowledge of PHP which I lack.

Any, any code sample to get me going will be a great help. Thanks

dovy commented 9 years ago

Here you go, a custom field boilerplate: https://github.com/ReduxFramework/extension-boilerplate

Use it with the loader: https://github.com/ReduxFramework/redux-extensions-loader

itsabhik commented 9 years ago

Hi Dovy, Thanks for the reply. That's exactly what I am following. But I am not sure what to code in public function render().

dovy commented 9 years ago

That's the HTML output of your actual field. Just be sure to put in the "name" argument the following:

your_opt_name[field_id], otherwise things won't save. ;)

itsabhik commented 9 years ago

Thanks dovy, How do I retrieve the data to display in the "value" field of the input text field?

dovy commented 9 years ago

In your global variable as if it were any other field.

Say your opt_name is redux_demo and you didn't change the global variable to anything, and say your field ID is field_id:

$redux_demo['field_demo']

I think you'd be wise to look at this field https://github.com/reduxframework/redux-framework/blob/master/ReduxCore/inc/fields/text/field_text.php and just copy the render section and go from there.

itsabhik commented 9 years ago

Thanks Dovy, You're a life-saver. That indeed is working.

dovy commented 9 years ago

;)

If you like Redux, please do some or all of the following: Review us: https://wordpress.org/support/view/plugin-reviews/redux-framework Like us: http://facebook.com/ReduxFramework Follow us: http://twitter.com/ReduxFramework Donate to keep us going: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MMFMHWUPKHKPW

itsabhik commented 9 years ago

First 3 are already done!! Regarding the 4th one, you surely deserve that. Coming in a day or two.

dovy commented 9 years ago

Awesome. Thanks!