Setting new gallery defaults
When creating galleries, you may often use the same settings every time for each gallery. With the following code snippet you can see examples of how to customize some of the default gallery settings every time you create a new gallery.
add_filter( 'sunshine_admin_meta_sunshine-gallery', 'sunshine_set_gallery_defaults', 9999 );
function sunshine_set_gallery_defaults( $options ) {
foreach ( $options['sunshine-gallery-options'] as &$section ) {
foreach ( $section['fields'] as &$field ) {
// Set default status to password.
if ( $field['id'] === 'status' ) {
$field['default'] = 'password';
}
// Set default password.
if ( $field['id'] === 'password' ) {
$field['default'] = strtoupper( sunshine_random_string( 10 ) );
}
// Set gallery expiration to 30 days from now.
if ( $field['id'] === 'end_date' ) {
$field['default'] = strtotime( '+30 days' );
}
}
}
return $options;
}
Learn how to add this custom code to your WordPress website
You can pick and choose which of these to use when you implement the code.
Still need help?
If you have not yet found your answer in the documentation articles, please contact support