I want to combine two forms from two different plugins namely : Wp job manager (Plugin A) and Afj Company Listings (plugin B). plugin A has a form called job-submit.php (located in: public_html/wp-content/plugins/wp-job-manager/templates) which would like to combine with another form from Plugin B called company_listings-submit.php (located in: public_html/wp-content/plugins/afj-company-listings/templates).
What I have done is to add get method in the job-submit.php but didnt work:
get_afj_company_listings_template( 'company_listings-submit.php' )
job-submit.php
/**
Content for job submission ([submit_job_form]) shortcode.
This template can be overridden by copying it to yourtheme/job_manager/job-submit.php.
#see https://wpjobmanager.com/document/template-overrides/
#author Automattic
#package wp-job-manager
#category Template
#version 1.34.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
global $job_manager;
?>
" method="post" id="submit-job-form" class="job-manager-form" enctype="multipart/form-data">
<?php
if ( isset( $resume_edit ) && $resume_edit ) {
printf( '<p><strong>' . esc_html__( "You are editing an existing job. %s", 'wp-job-manager' ) . '</strong></p>', '' . esc_html__( 'Create A New Job', 'wp-job-manager' ) . '' );
}
?>
<?php do_action( 'submit_job_form_start' ); ?>
<?php if ( apply_filters( 'submit_job_form_show_signin', true ) ) : ?>
<?php get_job_manager_template( 'account-signin.php' ); ?>
<?php endif; ?>
<?php if ( job_manager_user_can_post_job() || job_manager_user_can_edit_job( $job_id ) ) : ?>
<!-- Job Information Fields -->
<?php do_action( 'submit_job_form_job_fields_start' ); ?>
<!-- MY OWN CODE HERE-----afj-company-listings/templates/company_listings-submit.php wp-content/plugins/wp-job-manager/templates-->
<?php get_job_manager_template( 'company_listings-submit.php' ); ?>
<?php foreach ( $job_fields as $key => $field ) : ?>
<fieldset class="fieldset-<?php echo esc_attr( $key ); ?> fieldset-type-<?php echo esc_attr( $field['type'] ); ?>">
<label for="<?php echo esc_attr( $key ); ?>"><?php echo wp_kses_post(
$field['label'] ) . wp_kses_post( apply_filters( 'submit_job_form_required_label',
$field['required'] ? '' : ' ' . __( '(optional)', 'wp-job-manager' ) . '', $field )
); ?>
">
<?php get_job_manager_template( 'form-fields/' . $field['type'] . '-
field.php', [ 'key' => $key, 'field' => $field ] ); ?>
</div>
</fieldset>
<?php endforeach; ?>
<?php do_action( 'submit_job_form_job_fields_end' ); ?>
<!-- Company Information Fields -->
<?php if ( $company_fields ) : ?>
<h2><?php esc_html_e( 'Company Details', 'wp-job-manager' ); ?></h2>
<?php do_action( 'submit_job_form_company_fields_start' ); ?>
<?php foreach ( $company_fields as $key => $field ) : ?>
<fieldset class="fieldset-<?php echo esc_attr( $key ); ?> fieldset-type-<?php echo esc_attr( $field['type'] ); ?>">
<label for="<?php echo esc_attr( $key ); ?>"><?php echo wp_kses_post(
$field['label'] ) . wp_kses_post( apply_filters( 'submit_job_form_required_label',
$field['required'] ? '' : ' ' . __( '(optional)', 'wp-job-manager' ) . '', $field ) ); ?>
">
<?php get_job_manager_template( 'form-fields/' . $field['type'] . '-field.php', [ 'key' => $key, 'field' => $field ] ); ?>
</div>
</fieldset>
<?php endforeach; ?>
<?php do_action( 'submit_job_form_company_fields_end' ); ?>
<?php endif; ?>
<?php do_action( 'submit_job_form_end' ); ?>
<p>
<input type="hidden" name="job_manager_form" value="<?php echo esc_attr( $form ); ?>" />
<input type="hidden" name="job_id" value="<?php echo esc_attr( $job_id ); ?>" />
<input type="hidden" name="step" value="<?php echo esc_attr( $step ); ?>" />
<input type="submit" name="submit_job" class="button" value="<?php echo esc_attr(
$submit_button_text ); ?>" />
<?php
if ( isset( $can_continue_later ) && $can_continue_later ) {
echo '<input type="submit" name="save_draft" class="button secondary save_draft"
value="' . esc_attr__( 'Save Draft', 'wp-job-manager' ) . '" formnovalidate />';
}
?>
<span class="spinner" style="background-image: url(<?php echo esc_url( includes_url(
'images/spinner.gif' ) ); ?>);">
</p>
<?php else : ?>
<?php do_action( 'submit_job_form_disabled' ); ?>
<?php endif; ?>
company_listings-submit.php
" method="post" id="submit-company-form" class="job-manager-form" enctype="multipart/form-data">
<?php do_action( 'submit_company_form_start' ); ?>
<?php if ( apply_filters( 'submit_company_form_show_signin', true ) ) : ?>
<?php get_job_manager_template( 'account-signin.php', array( 'class' => $class ), 'afj-company-listings', COMPANY_LISTINGS_PLUGIN_DIR . '/templates/' ); ?>
<?php endif; ?>
<?php if ( company_listings_user_can_post_company() ) : ?>
<!-- Company Fields -->
<?php do_action( 'submit_company_form_company_fields_start' ); ?>
<?php foreach ( $company_fields as $key => $field ) : ?>
<fieldset class="fieldset-<?php esc_attr_e( $key ); ?>">
<label for="<?php esc_attr_e( $key ); ?>"><?php echo $field['label'] . apply_filters( 'submit_company_form_required_label', $field['required'] ? '' : ' <small>' . __( '(optional)', 'afj-company-listings' ) . '</small>', $field ); ?></label>
<div class="field">
<?php $class->get_field_template( $key, $field ); ?>
</div>
</fieldset>
<?php endforeach; ?>
<?php do_action( 'submit_company_form_company_fields_end' ); ?>
<p>
<?php wp_nonce_field( 'submit_form_posted' ); ?>
<input type="hidden" name="company_listings_form" value="<?php echo $form; ?>" />
<input type="hidden" name="company_id" value="<?php echo esc_attr( $company_id ); ?>" />
<input type="hidden" name="job_id" value="<?php echo esc_attr( $job_id ); ?>" />
<input type="hidden" name="step" value="<?php echo esc_attr( $step ); ?>" />
<input type="submit" name="submit_company" class="button" value="<?php esc_attr_e( $submit_button_text ); ?>" />
</p>
<?php else : ?>
<?php do_action( 'submit_company_form_disabled' ); ?>
<?php endif; ?>
<?php do_action( 'submit_company_form_end' ); ?>
I have little issue when I customize my Dokan address form.php because I want to delete some filed and shift between them to.. but when I finished the verification page on vonder dashboard was stuck and not responding and because it's related to setting page on the vonder dashboard so it's stuck too. So I have advance knowledge of coding and want you guys to check out if there is any mistake I did to the codes and edit it for me.
Note: I was also translate the fields from English language to Arabic.
................
<?php
/**
* Dokan Settings Address form Template
*
* #since 2.4
*
* #package dokan
*/
$address = isset( $profile_info['address'] ) ? $profile_info['address'] : '';
$address_street1 = isset( $profile_info['address']['street_1'] ) ? $profile_info['address']['street_1'] : '';
$address_street2 = isset( $profile_info['address']['street_2'] ) ? $profile_info['address']['street_2'] : '';
$address_city = isset( $profile_info['address']['city'] ) ? $profile_info['address']['city'] : '';
$address_zip = isset( $profile_info['address']['zip'] ) ? $profile_info['address']['zip'] : '';
$address_country = isset( $profile_info['address']['country'] ) ? $profile_info['address']['country'] : '';
$address_state = isset( $profile_info['address']['state'] ) ? $profile_info['address']['state'] : '';
?>
<input type="hidden" id="dokan_selected_country" value="<?php echo esc_attr( $address_country )?>" />
<input type="hidden" id="dokan_selected_state" value="<?php echo esc_attr( $address_state ); ?>" />
<div class="dokan-form-group">
<label class="dokan-w3 dokan-control-label" for="setting_address"><?php esc_html_e( 'العنوان', 'dokan-lite' ); ?></label>
<div class="dokan-w5 dokan-text-left dokan-address-fields">
<?php }
if ( $seller_address_fields['country'] ) {
$country_obj = new WC_Countries();
$countries = $country_obj->countries;
$states = $country_obj->states;
?>
<div class="dokan-form-group">
<label class="control-label" for="dokan_address[country]"><?php esc_html_e( 'الدولة ', 'dokan-lite' ); ?>
<?php
$required_attr = '';
if ( $seller_address_fields['country']['required'] ) {
$required_attr = 'required'; ?>
<span class="required"> *</span>
<?php } ?>
</label>
<select <?php echo esc_attr( $required_attr ); ?> <?php echo esc_attr( $disabled ) ?> name="dokan_address[country]" class="country_to_state dokan-form-control" id="dokan_address_country">
<?php dokan_country_dropdown( $countries, $address_country, false ); ?>
</select>
</div>
<?php }
if ( $seller_address_fields['state'] ) {
$address_state_class = '';
$is_input = false;
$no_states = false;
if ( isset( $states[$address_country] ) ) {
if ( empty( $states[$address_country] ) ) {
$address_state_class = 'dokan-hide';
$no_states = true;
}
} else {
$is_input = true;
}
?>
<div id="dokan-states-box" class="dokan-form-group">
<label class="control-label" for="dokan_address[state]"><?php esc_html_e( 'المحافظة ', 'dokan-lite' ); ?>
<?php
$required_attr = '';
if ( $seller_address_fields['state']['required'] ) {
$required_attr = 'required'; ?>
<span class="required"> *</span>
<?php } ?>
</label>
<?php if ( $is_input ) {
$required_attr = '';
if ( $seller_address_fields['state']['required'] ) {
$required_attr = 'required';
}
?>
<input <?php echo esc_attr( $required_attr ); ?> <?php echo esc_attr( $disabled ) ?> name="dokan_address[state]" class="dokan-form-control <?php echo esc_attr( $address_state_class ) ?>" id="dokan_address_state" value="<?php echo esc_attr( $address_state ) ?>"/>
<?php } else {
$required_attr = '';
if ( $seller_address_fields['state']['required'] ) {
$required_attr = 'required';
}
?>
<select <?php echo esc_attr( $required_attr ); ?> <?php echo esc_attr( $disabled ) ?> name="dokan_address[state]" class="dokan-form-control" id="dokan_address_state">
<?php dokan_state_dropdown( $states[$address_country], $address_state ) ?>
</select>
<?php } ?>
</div>
<?php if ( $seller_address_fields['street_1'] ) { ?>
<div class="dokan-form-group">
<label class="control-label" for="dokan_address[street_1]"><?php esc_html_e( 'الولاية ', 'dokan-lite' ); ?>
<?php
$required_attr = '';
if ( $seller_address_fields['street_1']['required'] ) {
$required_attr = 'required'; ?>
<span class="required"> *</span>
<?php } ?>
</label>
<input <?php echo esc_attr( $required_attr ); ?> <?php echo esc_attr( $disabled ) ?> id="dokan_address[street_1]" value="<?php echo esc_attr( $address_street1 ); ?>" name="dokan_address[street_1]" placeholder="<?php esc_attr_e( 'القرية/المنطقة' , 'dokan-lite' ) ?>" class="dokan-form-control input-md" type="text">
</div>
<?php }
if ( $seller_address_fields['street_2'] ) { ?>
<div class="dokan-form-group">
<label class="control-label" for="dokan_address[street_2]"><?php esc_html_e( 'رقم المنزل/رقم الشارع', 'dokan-lite' ); ?>
<?php
$required_attr = '';
if ( $seller_address_fields['street_2']['required'] ) {
$required_attr = 'required'; ?>
<span class="required"> *</span>
<?php } ?>
</label>
<input <?php echo esc_attr( $required_attr ); ?> <?php echo esc_attr( $disabled ) ?> id="dokan_address[street_2]" value="<?php echo esc_attr( $address_street2 ); ?>" name="dokan_address[street_2]" placeholder="<?php esc_attr_e( 'معلومات اخرى' , 'dokan-lite' ) ?>" class="dokan-form-control input-md" type="text">
</div>
<?php } ?>
<?php
/**
* Add vendor address verification templates.
*
* #since 3.4.2
*
* #param array $address Vendor address info.
* #param array $seller_address_fields Vendor required addresses.
*/
do_action( 'dokan_vendor_address_verification_template', $address, $seller_address_fields );
?>
</div>
</div>
I'm stuck on modifying shipping style in checkout. The goal is to redo the "Doprava" heading into a single column and shipping metods below. The shipping price should be on the right and the shipping name on the left.
I cant remove tag <.th> because then it stop works whole shipping metods.
Cart-shipping.php
<tr class="woocommerce-shipping-totals shipping">
<tr style="width:100%"><?php echo wp_kses_post( $package_name ); ?></tr>
<th data-title="<?php echo esc_attr( $package_name ); ?>" style="width:100%">
<?php if ( $available_methods ) : ?>
<ul id="shipping_method" class="woocommerce-shipping-methods">
<?php foreach ( $available_methods as $method ) : ?>
<li>
<?php
if ( 1 < count( $available_methods ) ) {
printf( '<input type="radio" name="shipping_method[%1$d]" data-index="%1$d" id="shipping_method_%1$d_%2$s" value="%3$s" class="shipping_method" %4$s />', $index, esc_attr( sanitize_title( $method->id ) ), esc_attr( $method->id ), checked( $method->id, $chosen_method, false ) ); // WPCS: XSS ok.
} else {
printf( '<input type="hidden" name="shipping_method[%1$d]" data-index="%1$d" id="shipping_method_%1$d_%2$s" value="%3$s" class="shipping_method" />', $index, esc_attr( sanitize_title( $method->id ) ), esc_attr( $method->id ) ); // WPCS: XSS ok.
}
printf( '<label for="shipping_method_%1$s_%2$s">%3$s</label>', $index, esc_attr( sanitize_title( $method->id ) ), wc_cart_totals_shipping_method_label( $method ) ); // WPCS: XSS ok.
do_action( 'woocommerce_after_shipping_rate', $method, $index );
?>
</li>
<?php endforeach; ?>
</ul>
<?php if ( is_cart() ) : ?>
<p class="woocommerce-shipping-destination">
<?php
if ( $formatted_destination ) {
// Translators: $s shipping destination.
printf( esc_html__( 'Shipping to %s.', 'woocommerce' ) . ' ', '<strong>' . esc_html( $formatted_destination ) . '</strong>' );
$calculator_text = esc_html__( 'Change address', 'woocommerce' );
} else {
echo wp_kses_post( apply_filters( 'woocommerce_shipping_estimate_html', __( 'Shipping options will be updated during checkout.', 'woocommerce' ) ) );
}
?>
</p>
<?php endif; ?>
<?php
elseif ( ! $has_calculated_shipping || ! $formatted_destination ) :
if ( is_cart() && 'no' === get_option( 'woocommerce_enable_shipping_calc' ) ) {
echo wp_kses_post( apply_filters( 'woocommerce_shipping_not_enabled_on_cart_html', __( 'Shipping costs are calculated during checkout.', 'woocommerce' ) ) );
} else {
echo wp_kses_post( apply_filters( 'woocommerce_shipping_may_be_available_html', __( 'Enter your address to view shipping options.', 'woocommerce' ) ) );
}
elseif ( ! is_cart() ) :
echo wp_kses_post( apply_filters( 'woocommerce_no_shipping_available_html', __( 'There are no shipping options available. Please ensure that your address has been entered correctly, or contact us if you need any help.', 'woocommerce' ) ) );
else :
// Translators: $s shipping destination.
echo wp_kses_post( apply_filters( 'woocommerce_cart_no_shipping_available_html', sprintf( esc_html__( 'No shipping options were found for %s.', 'woocommerce' ) . ' ', '<strong>' . esc_html( $formatted_destination ) . '</strong>' ) ) );
$calculator_text = esc_html__( 'Enter a different address', 'woocommerce' );
endif;
?>
<?php if ( $show_package_details ) : ?>
<?php echo '<p class="woocommerce-shipping-contents"><small>' . esc_html( $package_details ) . '</small></p>'; ?>
<?php endif; ?>
<?php if ( $show_shipping_calculator ) : ?>
<?php woocommerce_shipping_calculator( $calculator_text ); ?>
<?php endif; ?>
</th>
</tr>
frontend HTML
<tr class="woocommerce-shipping-totals shipping">
<th>Doprava</th>
<td data-title="Doprava">
<ul id="shipping_method" class="woocommerce-shipping-methods">
<li>
<input type="radio" name="shipping_method[0]" data-index="0" id="shipping_method_0_flat_rate1" value="flat_rate:1" class="shipping_method"><label for="shipping_method_0_flat_rate1">Zásilkovna: <span class="woocommerce-Price-amount amount"><bdi>49 <span class="woocommerce-Price-currencySymbol">Kč</span></bdi></span></label> </li>
<li>
<input type="radio" name="shipping_method[0]" data-index="0" id="shipping_method_0_flat_rate3" value="flat_rate:3" class="shipping_method"><label for="shipping_method_0_flat_rate3">Kurýr PPL: <span class="woocommerce-Price-amount amount"><bdi>69 <span class="woocommerce-Price-currencySymbol">Kč</span></bdi></span></label> </li>
<li>
<input type="radio" name="shipping_method[0]" data-index="0" id="shipping_method_0_flat_rate4" value="flat_rate:4" class="shipping_method" checked="checked"><label for="shipping_method_0_flat_rate4">Česká pošta - balík do ruky: <span class="woocommerce-Price-amount amount"><bdi>89 <span class="woocommerce-Price-currencySymbol">Kč</span></bdi></span></label> </li>
</ul>
</td>
</tr>
how to query woocommerce shipping method tax price ?
Porblem i don't tax + prive query!
Price query:
<?php if($method->cost > 0) : ?>+<span style="font-weight: normal"><?= $method->cost ?> Ft</span><?php endif; ?>
</label>
</div>
My code is:
<h2>Átvételi mód</h2>
<?php
$packages = WC()->shipping->get_packages();
$first = true;
foreach ($packages as $i => $package) {
$chosen_method = isset(WC()->session->chosen_shipping_methods[$i]) ? WC()->session->chosen_shipping_methods[$i] : '';
$product_names = array();
if (sizeof($packages) > 1) {
foreach ($package['contents'] as $item_id => $values) {
$product_names[$item_id] = $values['data']->get_name() . ' ×' . $values['quantity'];
}
$product_names = apply_filters('woocommerce_shipping_package_details_array', $product_names, $package);
}
/** #var WC_Shipping_Rate[] $available_methods */
$available_methods = $package['rates'];
$show_package_details = sizeof( $packages ) > 1;
$package_name = apply_filters( 'woocommerce_shipping_package_name', sprintf( _nx( 'Shipping', 'Shipping %d', ( $i + 1 ), 'shipping packages', 'woocommerce' ), ( $i + 1 ) ), $i, $package );
?>
<div class="shipping atvetelimod">
<td data-title="<?php echo esc_attr( $package_name ); ?>">
<?php if ( 1 < count( $available_methods ) ) : ?>
<div id="shipping_method row">
<?php
foreach ( $available_methods as $method ) : ?>
<div class="col-lg-6 balraszoveg">
<div class="jobbelvalaszto">
<label class="checkjel">
<input class="legyenelottefeher" type="radio" name="shipping_method[<?= $i ?>]" data-index="<?= $i ?>" id="shipping_method_<?= $i ?>_<?= sanitize_title( $method->id ) ?>" value="<?= esc_attr( $method->id ) ?>" class="shipping_method" <?= checked( $method->id, $chosen_method, false ) ?> />
</label>
</div>
<label class="jobboldaliszoveg" for="shipping_method_<?= $i ?>_<?= sanitize_title( $method->id ) ?>">
<strong><?= $method->get_label() ?></strong><br />
<?php if($method->cost > 0) : ?>+<span style="font-weight: normal"><?= $method->cost ?> Ft</span><?php endif; ?>
</label>
</div>
<?php endforeach; ?>
</div>
<?php elseif ( 1 === count( $available_methods ) ) : ?>
<?php
$method = current( $available_methods );
printf( '%3$s <input type="hidden" name="shipping_method[%1$d]" data-index="%1$d" id="shipping_method_%1$d" value="%2$s" class="shipping_method" />', $index, esc_attr( $method->id ), wc_cart_totals_shipping_method_label( $method ) );
do_action( 'woocommerce_after_shipping_rate', $method, $index );
?>
<?php elseif ( WC()->customer->has_calculated_shipping() ) : ?>
<?php echo apply_filters( is_cart() ? 'woocommerce_cart_no_shipping_available_html' : 'woocommerce_no_shipping_available_html', wpautop( __( 'There are no shipping methods available. Please ensure that your address has been entered correctly, or contact us if you need any help.', 'woocommerce' ) ) ); ?>
<?php elseif ( ! is_cart() ) : ?>
<?php echo wpautop( __( 'Enter your full address to see shipping costs.', 'woocommerce' ) ); ?>
<?php endif; ?>
<?php if ( $show_package_details ) : ?>
<?php echo '<p class="woocommerce-shipping-contents"><small>' . esc_html( $package_details ) . '</small></p>'; ?>
<?php endif; ?>
<?php if ( ! empty( $show_shipping_calculator ) ) : ?>
<?php woocommerce_shipping_calculator(); ?>
<?php endif; ?>
</td>
</div>
<?php }; ?>
I have a google map up on my contact form, I'd like to move it under my widget. I'm not sure how to go about this. I'm using WordPress Theme 'Adama.' Here is the contact form php file:
<?php
/**
* Template Name: Contact
*
* #package GalacticaThemes
* #subpackage Template
*/
get_header();
$disable_form = get_post_meta( get_the_ID(), 'adama_contact_disable_form', true );
if ( !$disable_form ) {
// Contact form
$is_sent = false;
$is_error = false;
$errors = array();
$contact_name = '';
$contact_email = '';
$contact_phone = '';
$contact_subject = '';
$contact_message = '';
// If the form is submitted
if ( isset( $_POST['contact_submitted'] ) ) {
// Name
if ( isset( $_POST['contact_name'] ) ) {
$contact_name = strip_tags( trim( $_POST['contact_name'] ) );
}
if ( $contact_name === '' ) {
// Name is required
$errors['contact_name'] = esc_html__( 'You forgot to enter your name.', 'adama' );
$is_error = true;
}
// Email
if ( isset( $_POST['email'] ) ) {
$contact_email = strip_tags( trim( $_POST['email'] ) );
}
if ( $contact_email === '' ) {
// Email is required
$errors['contact_email'] = esc_html__( 'You forgot to enter your email address.', 'adama' );
$is_error = true;
} else if ( !is_email( $contact_email ) ) {
// Validate email address
$errors['contact_email'] = esc_html__( 'You entered an invalid email address.', 'adama' );
$is_error = true;
} else {
$contact_email = sanitize_email( $contact_email );
}
// Phone
if ( isset( $_POST['contact_phone'] ) ) {
$contact_phone = strip_tags( trim( $_POST['contact_phone'] ) );
}
// Subject
if ( isset( $_POST['contact_subject'] ) ) {
$contact_subject = strip_tags( trim( $_POST['contact_subject'] ) );
}
if ( $contact_subject === '' ) {
// Subject is required
$errors['contact_subject'] = esc_html__( 'You forgot to enter message subject.', 'adama' );
$is_error = true;
}
// Message
if ( isset( $_POST['contact_message'] ) ) {
$contact_message = sanitize_text_field( strip_tags( trim( $_POST['contact_message'] ) ) );
}
if ( $contact_message === '' ) {
// Message is required
$errors['contact_message'] = esc_html__( 'You forgot to enter your message.', 'adama' );
$is_error = true;
}
// If there is no error, send email
if ( !$is_error ) {
$email_to = galactica_option_email( 'contact_email' );
$headers = esc_html__( 'From: ', 'adama' ) . "$contact_name <$contact_email>\r\n" . esc_html__( 'Reply-To: ', 'adama' ) . $contact_email;
$subject = sprintf(
esc_html__( '[%1$s - Contact] %2$s', 'adama' ),
get_bloginfo( 'name' ),
$contact_subject
);
$body = sprintf(
esc_html__( "Name: %s \n\nPhone: %s \n\nEmail: %s \n\nMessage: %s \n\n\n\nNote: This message was sent from contact form on %s website.", 'adama' ),
$contact_name,
$contact_phone,
$contact_email,
$contact_message,
get_bloginfo( 'name' )
);
$is_sent = wp_mail( $email_to, $subject, $body, $headers );
if ( !$is_sent ) {
$is_error = true;
}
}
}
}
// Map position
$map_position = get_post_meta( get_the_ID(), 'adama_contact_map_position', true );
$map_position = galactica_lower_in_array( $map_position, array( 'top', 'side' ), 'top' );
?>
<?php if ( $map_position === 'top' ) : ?>
<section>
<?php // Google Map
echo galactica_map( array(
'type' => galactica_option( 'contact_map_type', 'road' ),
'address' => implode( '|', galactica_option( 'contact_map_address', array() ) ),
'tooltip' => '',
'height' => galactica_option( 'contact_map_height', 'road' ) . 'px',
'zoom' => galactica_option( 'contact_map_zoom', 15 ),
'scrollwheel_enabled' => false,
)); ?>
</section>
<?php endif; ?>
<section class="w-section">
<div class="container">
<div class="row">
<div id="content" class="col-md-7 col-content">
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php if ( !post_password_required() && !$disable_form ) : ?>
<form method="post" action="<?php echo esc_url( get_permalink( get_the_ID() ) ); ?>" id="contact-form" role="form">
<?php if ( $is_sent ) : ?>
<div class="alert alert-success">
<?php esc_html_e( 'Your message was sent successfully.', 'adama' ); ?>
</div>
<?php else : ?>
<?php if ( $is_error ) : ?>
<div class="alert alert-danger">
<?php esc_html_e( 'There was an error submitting the form. Please check that you have entered valid information and try again.', 'adama' ); ?>
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
</div>
<?php endif; ?>
<div class="form-wrapper">
<div class="form-group">
<label for="contact_name"><?php esc_html_e( 'Name', 'adama' ); ?></label>
<input type="text" name="contact_name" id="contact_name" class="form-control form-control-validate-required" placeholder="<?php esc_attr_e( 'Your name', 'adama' ); ?>" value="<?php echo esc_attr( $contact_name ); ?>" />
<?php adama_form_error( $errors, 'contact_name' ); ?>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="contact_email"><?php esc_html_e( 'Email', 'adama' ); ?></label>
<input type="email" name="email" id="contact_email" class="form-control form-control-validate-required form-control-validate-email" placeholder="<?php esc_attr_e( 'Email address', 'adama' ); ?>" value="<?php echo esc_attr( $contact_email ); ?>" />
<?php adama_form_error( $errors, 'contact_email' ); ?>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="contact_phone"><?php esc_html_e( 'Phone', 'adama' ); ?></label>
<input type="text" name="contact_phone" id="contact_phone" class="form-control" placeholder="<?php esc_attr_e( 'Phone number', 'adama' ); ?>" value="<?php echo esc_attr( $contact_phone ); ?>" />
<?php adama_form_error( $errors, 'contact_phone' ); ?>
</div>
</div>
</div>
<div class="form-group">
<label for="contact_subject"><?php esc_html_e( 'Subject', 'adama' ); ?></label>
<input type="text" name="contact_subject" id="contact_subject" class="form-control form-control-validate-required" placeholder="<?php esc_attr_e( 'Subject', 'adama' ); ?>" value="<?php echo esc_attr( $contact_subject ); ?>" />
<?php adama_form_error( $errors, 'contact_subject' ); ?>
</div>
<div class="form-group">
<label for="contact_message"><?php esc_html_e( 'Message', 'adama' ); ?></label>
<textarea name="contact_message" id="contact_message" class="form-control form-control-validate-required contact-message" placeholder="<?php esc_attr_e( 'Write you message here...', 'adama' ); ?>"><?php echo esc_textarea( $contact_subject ); ?></textarea>
<?php adama_form_error( $errors, 'contact_message' ); ?>
</div>
<input type="hidden" name="contact_submitted" value="1" />
<button type="submit" class="btn btn-two" name="send"><?php esc_html_e( 'Send message', 'adama' ); ?></button>
</div>
<?php endif; ?>
</form>
<?php endif; ?>
<?php endwhile; ?>
</div><!-- #content -->
<?php get_sidebar( 'contact' ); ?>
</div>
</div>
</section>
<?php if ( !$disable_form ) { ?>
<script>
/* global jQuery */
// Javascript validation
jQuery( document ).ready( function( $ ) {
"use strict";
var $form = $( 'form#contact-form' );
$form.submit( function( e ) {
// Remove old error messages
$form.find( '.alert' ).remove();
// Validate
var hasError = false;
$form.find( '.form-control-validate-required' ).each( function() {
var $ctrl = $( this ),
labelText,
value = $.trim( $ctrl.val() );
if ( value === '' ) {
hasError = true;
labelText = $ctrl.prev( 'label' ).text();
$ctrl.parent().append( '<div class="alert alert-danger alert-form-message"><?php esc_html_e( 'You forgot to enter your', 'adama' ); ?> ' + labelText + '.</div>' );
} else if ( $ctrl.hasClass( 'form-control-validate-email' ) && !( /^([\w-\.]+#([\w-]+\.)+[\w-]{2,4})?$/.test( value ) ) ) {
hasError = true;
labelText = $ctrl.prev( 'label' ).text();
$ctrl.parent().append( '<div class="alert alert-danger alert-form-message"><?php esc_html_e( 'You entered an invalid', 'adama' ); ?> ' + labelText + '.</div>' );
}
});
// If no errors submit form via ajax
if ( hasError ) {
$form.prepend( '<div class="alert alert-danger"><?php esc_html_e( 'There was an error submitting the form. Please check that you have entered valid information and try again.', 'adama' ); ?><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>' );
} else {
var formData = $(this).serialize();
$.post( $( this ).attr( 'action' ), formData, function( data ) {
if ( data.indexOf( '<?php esc_html_e( 'Your message was sent successfully.', 'adama' ); ?>' ) !== -1 ) {
$form.find( '.form-wrapper' ).slideUp( 'fast', function() {
$form.prepend( '<div class="alert alert-success"><?php esc_html_e( 'Your message was sent successfully.', 'adama' ); ?></div>' );
});
} else {
$form.prepend( '<div class="alert alert-danger"><?php esc_html_e( 'There was an error submitting the form. Please check that you have entered valid information and try again.', 'adama' ); ?><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>' );
}
});
}
e.preventDefault();
});
});
</script>
<?php } ?>
<?php get_footer();
That currently shows up like this with these settings:
I would love to move the map to the bottom of the widget, but I'm not sure how... The theme settings only currently have "top" (which is a full width above the form and widget) and the side which also appears on top of the widget...
Edit:
Here's Sidebar.php
<?php
/**
* The sidebar containing the widget area
*
* Displays on posts and pages.
*
* #package GalacticaThemes
* #subpackage Template
*/
?>
<?php if ( galactica_is_sidebar_enabled() ) : ?>
<div id="sidebar" class="col-md-3 widget-area sidebar-classic" role="complementary">
<?php galactica_dynamic_sidebar(); ?>
</div><!-- #sidebar -->
<?php endif; ?>
Here's Contact Sidebar
<?php
/**
* The sidebar containing the contact page widget area
*
* #package GalacticaThemes
* #subpackage Template
*/
// Map position
$map_position = get_post_meta( get_the_ID(), 'adama_contact_map_position', true );
$map_position = galactica_lower_in_array( $map_position, array( 'top', 'side' ), 'top' );
?>
<?php if ( galactica_is_sidebar_enabled() ) : ?>
<div id="sidebar" class="col-md-5 widget-area sidebar-classic" role="complementary">
<?php if ( $map_position === 'side' ) : ?>
<div class="widget">
<?php // Google Map
echo galactica_map( array(
'type' => galactica_option( 'contact_map_type', 'road' ),
'address' => implode( '|', galactica_option( 'contact_map_address', array() ) ),
'tooltip' => '',
'height' => galactica_option( 'contact_map_height', 'road' ) . 'px',
'zoom' => galactica_option( 'contact_map_zoom', 15 ),
'scrollwheel_enabled' => false,
)); ?>
</div>
<?php endif; ?>
<?php galactica_dynamic_sidebar(); ?>
</div><!-- #sidebar -->
<?php endif; ?>
Looks like I might just have to move the map under in this file above here!
Not tested, obviously but I think you can just flip these two like this inside your contact sidebar file so the info is being called in before the map.
<?php galactica_dynamic_sidebar(); ?>
<?php if ( $map_position === 'side' ) : ?>
<div class="widget">
<?php // Google Map
echo galactica_map( array(
'type' => galactica_option( 'contact_map_type', 'road' ),
'address' => implode( '|', galactica_option( 'contact_map_address', array() ) ),
'tooltip' => '',
'height' => galactica_option( 'contact_map_height', 'road' ) . 'px',
'zoom' => galactica_option( 'contact_map_zoom', 15 ),
'scrollwheel_enabled' => false,
)); ?>
</div>
<?php endif; ?>
In sidebar-contact.php just flip the lines:
<?php
/**
* The sidebar containing the contact page widget area
*
* #package GalacticaThemes
* #subpackage Template
*/
// Map position
$map_position = get_post_meta( get_the_ID(), 'adama_contact_map_position', true );
$map_position = galactica_lower_in_array( $map_position, array( 'top', 'side' ), 'top' );
?>
<?php if ( galactica_is_sidebar_enabled() ) : ?>
<div id="sidebar" class="col-md-5 widget-area sidebar-classic" role="complementary">
<?php galactica_dynamic_sidebar(); ?>
<?php if ( $map_position === 'side' ) : ?>
<div class="widget">
<?php // Google Map
echo galactica_map( array(
'type' => galactica_option( 'contact_map_type', 'road' ),
'address' => implode( '|', galactica_option( 'contact_map_address', array() ) ),
'tooltip' => '',
'height' => galactica_option( 'contact_map_height', 'road' ) . 'px',
'zoom' => galactica_option( 'contact_map_zoom', 15 ),
'scrollwheel_enabled' => false,
)); ?>
</div>
<?php endif; ?>
</div><!-- #sidebar -->
<?php endif; ?>
This will give the desired request with the map under the widget!