Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide default values for new widget parameters #4

Open
boonebgorges opened this issue Nov 28, 2012 · 2 comments
Open

Provide default values for new widget parameters #4

boonebgorges opened this issue Nov 28, 2012 · 2 comments

Comments

@boonebgorges
Copy link
Member

When you introduced the new title_element field, it broke existing widgets, because no element at all was provided. In cases like this, where you introduce a new value, you should provide a default value. (In fact, it's a good idea to provide a default value in all cases.)

Basically, you might want to try something like this at the top of cac-featured-controller.php or thereabouts:

$defaults = array(
    'featured_content_type' => 'member',
    'custom_description' => '',
    // etc
);

$params = wp_parse_args( $params, $defaults );

This is a handy way of making sure that required fields (like title_element) are never left empty.

(I did notice that you have an Upgrade Notice that warns people that they'll need to resave their widgets. Providing default values will make it so that people don't have to do this. Also, people don't really read those :) )

@humanshell
Copy link
Collaborator

I was curious about this when releasing the latest version. I was worried that the update warning could go unnoticed. I'll add the defaults code to the description request from issue #3 for a 1.0.4 release. I'll update you when the new code gets pushed up.

@boonebgorges
Copy link
Member Author

Thanks!

On 11/28/12 16:37, Dominic Giglio wrote:

I was curious about this when releasing the latest version. I was
worried that the update warning could go unnoticed. I'll add the
defaults code to the description request from issue #3
#3
for a 1.0.4 release. I'll update you when the new code gets pushed up.


Reply to this email directly or view it on GitHub
#4 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants