';
// Label top or left
if ($type!='button' && $type!='submit' && ($label_position=='top' || $label_position=='left'))
$output .= $label;
// Field output
if ($type == 'textarea')
$output .= '
';
return apply_filters('lorem_ipsum_books_media_store_shortcode_output', $output, 'trx_form_item', $atts, $content);
}
add_shortcode('trx_form_item', 'lorem_ipsum_books_media_store_sc_form_item');
}
// AJAX Callback: Send contact form data
if ( !function_exists( 'lorem_ipsum_books_media_store_sc_form_send' ) ) {
function lorem_ipsum_books_media_store_sc_form_send() {
if ( !wp_verify_nonce( lorem_ipsum_books_media_store_get_value_gp('nonce'), admin_url('admin-ajax.php') ) )
die();
$response = array('error'=>'');
if (!($contact_email = lorem_ipsum_books_media_store_get_theme_option('contact_email')) && !($contact_email = lorem_ipsum_books_media_store_get_theme_option('admin_email')))
$response['error'] = esc_html__('Unknown admin email!', 'trx_utils');
else {
$type = lorem_ipsum_books_media_store_substr($_REQUEST['type'], 0, 7);
parse_str($_POST['data'], $post_data);
if (in_array($type, array('form_1', 'form_2'))) {
$user_name = lorem_ipsum_books_media_store_strshort($post_data['username'], 100);
$user_email = lorem_ipsum_books_media_store_strshort($post_data['email'], 100);
$user_subj = lorem_ipsum_books_media_store_strshort($post_data['subject'], 100);
$user_msg = lorem_ipsum_books_media_store_strshort($post_data['message'], lorem_ipsum_books_media_store_get_theme_option('message_maxlength_contacts'));
$subj = sprintf(esc_html__('Site %s - Contact form message from %s', 'trx_utils'), get_bloginfo('site_name'), $user_name);
$msg = "\n".esc_html__('Name:', 'trx_utils') .' '.esc_html($user_name)
. "\n".esc_html__('E-mail:', 'trx_utils') .' '.esc_html($user_email)
. "\n".esc_html__('Subject:', 'trx_utils').' '.esc_html($user_subj)
. "\n".esc_html__('Message:', 'trx_utils').' '.esc_html($user_msg);
} else {
$subj = sprintf(esc_html__('Site %s - Custom form data', 'trx_utils'), get_bloginfo('site_name'));
$msg = '';
if (is_array($post_data) && count($post_data) > 0) {
foreach ($post_data as $k=>$v)
$msg .= "\n{$k}: $v";
}
}
$msg .= "\n\n............. " . get_bloginfo('site_name') . " (" . esc_url(home_url('/')) . ") ............";
$mail = lorem_ipsum_books_media_store_get_theme_option('mail_function');
if (!@$mail($contact_email, $subj, apply_filters('lorem_ipsum_books_media_store_filter_form_send_message', $msg))) {
$response['error'] = esc_html__('Error send message!', 'trx_utils');
}
echo json_encode($response);
die();
}
}
}
// Show additional fields in the form
if ( !function_exists( 'lorem_ipsum_books_media_store_sc_form_show_fields' ) ) {
function lorem_ipsum_books_media_store_sc_form_show_fields($fields) {
if (is_array($fields) && count($fields)>0) {
foreach ($fields as $f) {
if (in_array($f['type'], array('hidden', 'text'))) {
echo '