• I need added new field to WP_Widget_Media_Image. Deactivate default widget, copy it class, add my field to widget form, but can`t save value of this field. Help me, pls

Viewing 9 replies - 1 through 9 (of 9 total)
  • Moderator bcworkz

    (@bcworkz)

    Did you add your field’s information to the schema declared in get_instance_schema()? Nothing is updated unless it’s part of the schema.

    It wouldn’t change things operationally, but did you know you can simply extend WP_Widget_Media_Image and just override the functions you need to be different? If you find yourself needing to override nearly every function though, just copying and renaming would be equally effective.

    Thread Starter Chirukin Bogdan

    (@cheater111)

    Yes, I write my field in cheme and I know about extends WP_Widget_Media_Image

    Moderator bcworkz

    (@bcworkz)

    Please post your widget class code at pastebin.com and provide a link here so we can take a closer look.

    Thread Starter Chirukin Bogdan

    (@cheater111)

    class WPR_Widget_Image extends WP_Widget_Media_Image – i want created choose of template. image-widget.js is empty. I think that it may be do on js(corretly insert field in widget form and save updates), because I do it with gallery-widget on js.

    Thread Starter Chirukin Bogdan

    (@cheater111)

    Moderator bcworkz

    (@bcworkz)

    Thanks for posting your code. I had a look-see but I then realized I don’t know enough about how the media widgets work to intelligently comment on why your setting is not saved.

    However, I noticed your select field name is “temlate” (no ‘p’) but the schema key name is “template”. Maybe it’s naive, but it seems to me the mismatch could impact what gets saved or not. A shot in the dark, but it’s remotely possible to hit something all the same.

    Thread Starter Chirukin Bogdan

    (@cheater111)

    Ok, can I somehow ask this to those who developed media-widgets?

    Moderator bcworkz

    (@bcworkz)

    That could prove to be difficult and it’s unnecessary. You just need someone with more experience with these than me. If you haven’t already done so, I suggest you ask at WordPress StackExchange.

    Thread Starter Chirukin Bogdan

    (@cheater111)

    Thank you, will ask

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘WP_Widget_Media_Image new field’ is closed to new replies.