function structured_data_marketing_form in Structured Data (JSON+LD Rich Snippets) 7
Fieldset builder for the Marketing details settings form.
1 call to structured_data_marketing_form()
- structured_data_settings_form in ./
structured_data.admin.inc - Form callback for admin settings page.
File
- ./
structured_data.admin.inc, line 25 - Administrative pages for the structured_data module.
Code
function structured_data_marketing_form(&$form_state) {
$fieldset = array(
'#type' => 'fieldset',
'#title' => t('Marketing details'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$site_name = variable_get('site_name', '');
$fieldset['structured_data_site_name_custom'] = array(
'#type' => 'textfield',
'#title' => t('Official site name'),
'#description' => t('Site name or Company name, must be reasonably similar to your domain name. If left blank, %name will be used.', array(
'%name' => $site_name,
)),
'#default_value' => variable_get('structured_data_site_name_custom', ''),
'#attributes' => array(
'placeholder' => check_plain($site_name),
),
);
$fieldset['structured_data_site_name_alternative'] = array(
'#type' => 'textfield',
'#title' => t('Alternative site name (optional)'),
'#description' => t('An alternate name you want Search Engines to consider.'),
'#default_value' => variable_get('structured_data_site_name_alternative', ''),
);
$logo_path = structured_data_get_site_logo();
$logo_info = getimagesize($logo_path);
$logo_info['width'] = $logo_info[0];
$logo_info['height'] = $logo_info[1];
if ($logo_info['width'] > 600 || $logo_info['height'] > 60) {
$problem_width = t('a width greater than 600px');
$problem_height = t('a height greater than 60px');
$problem_both = $problem_width . ' ' . t('or') . ' ' . $problem_height;
if ($logo_info['width'] > 600 && $logo_info['height'] > 60) {
$problem = $problem_both;
}
else {
if ($logo_info['width'] > 600) {
$problem = $problem_width;
}
elseif ($logo_info['height'] > 60) {
$problem = $problem_height;
}
}
drupal_set_message(t('Logos with @problem will be rejected by Google.', array(
'@problem' => $problem,
)), 'warning');
}
$fieldset['structured_data_site_logo_current'] = array(
'#type' => 'item',
'#title' => t('Image that will be presented to search engines as your logo:'),
'#markup' => theme('image', array(
'path' => $logo_path,
)),
);
$fieldset['structured_data_site_logo_custom'] = array(
'#type' => 'managed_file',
'#title' => t('Custom site logo'),
'#description' => t('Logos should be exactly 60px tall with width <= 600px. Allowed extensions: jpg, jpeg, png, gif.'),
'#upload_location' => 'public://structured_data/',
'#default_value' => variable_get('structured_data_site_logo_custom', ''),
'#upload_location' => 'public://',
'#upload_validators' => array(
'file_validate_extensions' => array(
'gif png jpg jpeg',
),
'file_validate_image_resolution' => array(
'600x60',
),
),
);
if (variable_get('structured_data_site_name_custom', FALSE) != FALSE) {
$fieldset['#collapsed'] = FALSE;
}
return $fieldset;
}