Move Map To Bottom - 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!

Related

Dokan seller verification page is stuck

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>

Switch fields order in Easy Digital Downloads checkout

I'd like to switch the order of the 'Billing City' and the 'Billing ZIP' field in the code below through a snippet in my functions.php file. I've been on it for hours, but I can't get it right. This is the code in the easy-digital-downloads/includes/checkout/template.php file, thank you so much for helping out:
<?php
do_action( 'edd_after_cc_fields' );
echo ob_get_clean();
}
add_action( 'edd_cc_form', 'edd_get_cc_form' );
/**
* Outputs the default credit card address fields
*
* #since 1.0
* #return void
*/
function edd_default_cc_address_fields() {
$logged_in = is_user_logged_in();
$customer = EDD()->session->get( 'customer' );
$customer = wp_parse_args( $customer, array( 'address' => array(
'line1' => '',
'line2' => '',
'city' => '',
'zip' => '',
'state' => '',
'country' => ''
) ) );
$customer['address'] = array_map( 'sanitize_text_field', $customer['address'] );
if( $logged_in ) {
$user_address = get_user_meta( get_current_user_id(), '_edd_user_address', true );
foreach( $customer['address'] as $key => $field ) {
if ( empty( $field ) && ! empty( $user_address[ $key ] ) ) {
$customer['address'][ $key ] = $user_address[ $key ];
} else {
$customer['address'][ $key ] = '';
}
}
}
/**
* Billing Address Details.
*
* Allows filtering the customer address details that will be pre-populated on the checkout form.
*
* #since 2.8
*
* #param array $address The customer address.
* #param array $customer The customer data from the session
*/
$customer['address'] = apply_filters( 'edd_checkout_billing_details_address', $customer['address'], $customer );
ob_start(); ?>
<fieldset id="edd_cc_address" class="cc-address">
<legend><?php _e( 'Billing Details', 'easy-digital-downloads' ); ?></legend>
<?php do_action( 'edd_cc_billing_top' ); ?>
<p id="edd-card-address-wrap">
<label for="card_address" class="edd-label">
<?php _e( 'Billing Address', 'easy-digital-downloads' ); ?>
<?php if( edd_field_is_required( 'card_address' ) ) { ?>
<span class="edd-required-indicator">*</span>
<?php } ?>
</label>
<span class="edd-description"><?php _e( 'The primary billing address for your credit card.', 'easy-digital-downloads' ); ?></span>
<input type="text" id="card_address" name="card_address" class="card-address edd-input<?php if( edd_field_is_required( 'card_address' ) ) { echo ' required'; } ?>" placeholder="<?php _e( 'Address line 1', 'easy-digital-downloads' ); ?>" value="<?php echo $customer['address']['line1']; ?>"<?php if( edd_field_is_required( 'card_address' ) ) { echo ' required '; } ?>/>
</p>
<p id="edd-card-address-2-wrap">
<label for="card_address_2" class="edd-label">
<?php _e( 'Billing Address Line 2 (optional)', 'easy-digital-downloads' ); ?>
<?php if( edd_field_is_required( 'card_address_2' ) ) { ?>
<span class="edd-required-indicator">*</span>
<?php } ?>
</label>
<span class="edd-description"><?php _e( 'The suite, apt no, PO box, etc, associated with your billing address.', 'easy-digital-downloads' ); ?></span>
<input type="text" id="card_address_2" name="card_address_2" class="card-address-2 edd-input<?php if( edd_field_is_required( 'card_address_2' ) ) { echo ' required'; } ?>" placeholder="<?php _e( 'Address line 2', 'easy-digital-downloads' ); ?>" value="<?php echo $customer['address']['line2']; ?>"<?php if( edd_field_is_required( 'card_address_2' ) ) { echo ' required '; } ?>/>
</p>
<p id="edd-card-city-wrap">
<label for="card_city" class="edd-label">
<?php _e( 'Billing City', 'easy-digital-downloads' ); ?>
<?php if( edd_field_is_required( 'card_city' ) ) { ?>
<span class="edd-required-indicator">*</span>
<?php } ?>
</label>
<span class="edd-description"><?php _e( 'The city for your billing address.', 'easy-digital-downloads' ); ?></span>
<input type="text" id="card_city" name="card_city" class="card-city edd-input<?php if( edd_field_is_required( 'card_city' ) ) { echo ' required'; } ?>" placeholder="<?php _e( 'City', 'easy-digital-downloads' ); ?>" value="<?php echo $customer['address']['city']; ?>"<?php if( edd_field_is_required( 'card_city' ) ) { echo ' required '; } ?>/>
</p>
<p id="edd-card-zip-wrap">
<label for="card_zip" class="edd-label">
<?php _e( 'Billing Zip / Postal Code', 'easy-digital-downloads' ); ?>
<?php if( edd_field_is_required( 'card_zip' ) ) { ?>
<span class="edd-required-indicator">*</span>
<?php } ?>
</label>
<span class="edd-description"><?php _e( 'The zip or postal code for your billing address.', 'easy-digital-downloads' ); ?></span>
<input type="text" size="4" id="card_zip" name="card_zip" class="card-zip edd-input<?php if( edd_field_is_required( 'card_zip' ) ) { echo ' required'; } ?>" placeholder="<?php _e( 'Zip / Postal Code', 'easy-digital-downloads' ); ?>" value="<?php echo $customer['address']['zip']; ?>"<?php if( edd_field_is_required( 'card_zip' ) ) { echo ' required '; } ?>/>
</p>
<p id="edd-card-country-wrap">
<label for="billing_country" class="edd-label">
<?php _e( 'Billing Country', 'easy-digital-downloads' ); ?>
<?php if( edd_field_is_required( 'billing_country' ) ) { ?>
<span class="edd-required-indicator">*</span>
<?php } ?>
</label>
<span class="edd-description"><?php _e( 'The country for your billing address.', 'easy-digital-downloads' ); ?></span>
<select name="billing_country" id="billing_country" data-nonce="<?php echo wp_create_nonce( 'edd-country-field-nonce' ); ?>" class="billing_country edd-select<?php if( edd_field_is_required( 'billing_country' ) ) { echo ' required'; } ?>"<?php if( edd_field_is_required( 'billing_country' ) ) { echo ' required '; } ?>>
<?php
$selected_country = edd_get_shop_country();
if( ! empty( $customer['address']['country'] ) && '*' !== $customer['address']['country'] ) {
$selected_country = $customer['address']['country'];
}
$countries = edd_get_country_list();
foreach( $countries as $country_code => $country ) {
echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>';
}
?>
</select>
</p>
<p id="edd-card-state-wrap">
<label for="card_state" class="edd-label">
<?php _e( 'Billing State / Province', 'easy-digital-downloads' ); ?>
<?php if( edd_field_is_required( 'card_state' ) ) { ?>
<span class="edd-required-indicator">*</span>
<?php } ?>
</label>
<span class="edd-description"><?php _e( 'The state or province for your billing address.', 'easy-digital-downloads' ); ?></span>
<?php
$selected_state = edd_get_shop_state();
$states = edd_get_shop_states( $selected_country );
if( ! empty( $customer['address']['state'] ) ) {
$selected_state = $customer['address']['state'];
}
if( ! empty( $states ) ) : ?>
<select name="card_state" id="card_state" class="card_state edd-select<?php if( edd_field_is_required( 'card_state' ) ) { echo ' required'; } ?>">
<?php
foreach( $states as $state_code => $state ) {
echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>';
}
?>
</select>
<?php else : ?>
<?php $customer_state = ! empty( $customer['address']['state'] ) ? $customer['address']['state'] : ''; ?>
<input type="text" size="6" name="card_state" id="card_state" class="card_state edd-input" value="<?php echo esc_attr( $customer_state ); ?>" placeholder="<?php _e( 'State / Province', 'easy-digital-downloads' ); ?>"/>
<?php endif; ?>
</p>
<?php do_action( 'edd_cc_billing_bottom' ); ?>
<?php wp_nonce_field( 'edd-checkout-address-fields', 'edd-checkout-address-fields-nonce', false, true ); ?>
</fieldset>
<?php
echo ob_get_clean();
}
add_action( 'edd_after_cc_fields', 'edd_default_cc_address_fields' );
Ok, based on your comments i would say the EASIEST (not the cleanest) way to achieve that is to include a small piece of JS to move the DIV
$("#edd-card-zip-wrap").insertBefore("#edd-card-city-wrap");
That should be enought :)
Edit:
Paste this code into your theme's functions.php
add_action( 'wp_enqueue_scripts', 'enqueue_my_script' );
function enqueue_my_script() {
wp_enqueue_script( 'my-custom-script', get_stylesheet_directory_uri() . '/my-script.js', array( "jquery" ), false, true );
}
This will search for a file named "my-script.js" that lives in the root folder of your theme (same level as the functions.php file)
That file content can be something like this:
Edited with fixed wait:
$("document").ready(function() {
var waitThisTime = 1000; // Wait this ms. 1000ms = 1sec
setTimeout(function(){
$("#edd-card-zip-wrap").insertBefore("#edd-card-city-wrap");
},waitThisTime);
});
You can do that by using below code snippet.
add_filter( 'woocommerce_checkout_fields', 'ro_postcode_city_interchange' );
function ro_postcode_city_interchange( $checkout_fields ) {
$checkout_fields['billing']['billing_postcode']['priority'] = 70;
$checkout_fields['billing']['billing_city']['priority'] = 90;
return $checkout_fields;
}
This code snipper will interchange the order as all fields have their priority so here you have to give postcode priority of city and city priority of zipcode.
Tested and works well.

wordpress multiple select in theme option page

im trying to make this work. its theme option page that list categories and allow you to do MULTIPLE select
but something is wrong and it not saving the values and in the end how can i show these selected categories in index?
here is what i found in web and sof
<?php
add_action( 'admin_init', 'theme_options_init' );
add_action( 'admin_menu', 'theme_options_add_page' );
function theme_options_init(){
register_setting( 'sample_options', 'sample_theme_options', 'theme_options_validate' );
}
function theme_options_add_page() {
add_theme_page( __( 'Theme Options', 'sampletheme' ), __( 'Theme Options', 'sampletheme' ), 'edit_theme_options', 'theme_options', 'theme_options_do_page' );
}
function theme_options_do_page() {
global $select_options, $radio_options;
if ( ! isset( $_REQUEST['settings-updated'] ) )
$_REQUEST['settings-updated'] = false;
?>
<div class="wrap">
<?php screen_icon(); echo "<h2>" . get_current_theme() . __( ' Theme Options', 'sampletheme' ) . "</h2>"; ?>
<?php if ( false !== $_REQUEST['settings-updated'] ) : ?>
<div class="updated fade"><p><strong><?php _e( 'Options saved', 'sampletheme' ); ?></strong></p></div>
<?php endif; ?>
<form method="post" action="options.php">
<?php settings_fields( 'sample_options' ); ?>
<?php $options = get_option( 'sample_theme_options' ); ?>
<select multiple="multiple" name="site_options[categorychoice][]">
<?php $option = get_option('site_options'); ?>
<?php
$args = array(
'orderby' => 'name',
'parent' => 0,
'exclude' => 1
);
$categories = get_categories( $args );
foreach ($categories as $category) { ?>
<?php $selected = in_array( $category->cat_ID, $option['categorychoice'] ) ? ' selected="selected" ' : ''; ?>
<option value="<?php echo $category->term_id; ?>" <?php echo $selected; ?> >
<?php echo $category->cat_name . ' (' . $category->category_count .')'; ?>
</option>
<?php } //endforeach ?>
</select>
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e( 'Save Options', 'sampletheme' ); ?>" />
</p>
</form>
</div>
<?php
}
function theme_options_validate( $input ) {
global $select_options, $radio_options, $categories;
if ( ! array_key_exists( $input['categorychoice'], $categories ) )
$input['categorychoice'] = NULL;
return $input;
}

Wordpress comment form not submitting

I have an issue I cannot solve. On my single.php page I included the comment form:
<?php comments_template('/partials/comments.php'); ?>
In my partials folder I made a comments.php (from the theme where this is working fine):
<?php
/**
* The template for displaying Comments.
*
* The area of the page that contains both current comments
* and the comment form. The actual display of comments is
* handled by a callback to MYtheme_comment().
*
*/
function MYtheme_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case 'pingback' :
case 'trackback' :
?>
<li class="post pingback">
<p><?php esc_html_e( 'Pingback:', 'my_theme' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( esc_html__( 'Edit', 'my_theme' ), '<span class="edit-link">', '</span>' ); ?></p>
<?php
break;
default :
?>
<li <?php comment_class('clearfix'); ?> id="comment-<?php comment_ID(); ?>">
<span class="comment_avatar">
<?php
$avatar_size = 100;
if ( '0' != $comment->comment_parent ){
$avatar_size = 100;
}
echo get_avatar( $comment, $avatar_size );
echo '</span><span class="comment_content">';
?>
<div class="comment-text">
<?php
/* translators: 1: comment author, 2: date and time */
printf( esc_html__( '%1$s %2$s', 'my_theme' ),
sprintf( '<span class="comment-author">%s</span>', get_comment_author_link() ),
sprintf( '<time pubdate datetime="%2$s">%3$s</time>',
esc_url( get_comment_link( $comment->comment_ID ) ),
get_comment_time( 'c' ),
/* translators: 1: date, 2: time */
sprintf( esc_html__( '%1$s at %2$s', 'my_theme' ), get_comment_date(), get_comment_time() )
)
);
?>
<?php edit_comment_link( esc_html__( 'Edit', 'my_theme' ), '<span class="edit-link">', '</span>' ); ?>
<?php if ( $comment->comment_approved == '0' ) : ?>
<em class="comment-awaiting-moderation"><?php esc_html_e( 'Your comment is awaiting moderation.', 'my_theme' ); ?></em>
<br />
<?php else: ?>
<?php comment_text(); ?>
<?php endif; ?>
<p class="reply">
<?php comment_reply_link( array_merge( $args, array( 'reply_text' => esc_html__( 'Reply ', 'my_theme' ).'<i class="ci_icon-chevronright-thin"></i>', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</p><!-- .reply -->
</span>
</div>
<?php
break;
endswitch;
}
?>
<div id="comments">
<?php if ( post_password_required() ) : ?>
<p class="nopassword"><?php esc_html_e( 'This post is password protected. Enter the password to view any comments.', 'my_theme' ); ?></p>
</div><!-- #comments -->
<?php
/* Stop the rest of comments.php from being processed,
* but don't kill the script entirely -- we still have
* to fully load the template.
*/
return;
endif;
?>
<?php // You can start editing here -- including this comment! ?>
<?php if ( have_comments() ) : ?>
<h3 id="comments-title"><?php printf( _n( 'One comment', '%1$s comments', get_comments_number(), 'my_theme' ), number_format_i18n( get_comments_number() ) );?></h3>
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
<nav id="comment-nav-above">
<h1 class="assistive-text"><?php esc_html_e( 'Comment navigation', 'my_theme' ); ?></h1>
<div class="nav-previous"><?php previous_comments_link( esc_html__( '← Older Comments', 'my_theme' ) ); ?></div>
<div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments →', 'my_theme' ) ); ?></div>
</nav>
<?php endif; // check for comment navigation ?>
<ol class="commentlist">
<?php
/* Loop through and list the comments. Tell wp_list_comments()
* to use MYtheme_comment() to format the comments.
* If you want to overload this in a child theme then you can
* define MYtheme_comment() and that will be used instead.
* See MYtheme_comment() in twentyeleven/functions.php for more.
*/
wp_list_comments( array( 'callback' => 'MYtheme_comment' ) );
?>
</ol>
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
<nav id="comment-nav-below">
<h1 class="assistive-text"><?php esc_html_e( 'Comment navigation', 'my_theme' ); ?></h1>
<div class="nav-previous"><?php previous_comments_link( esc_html__( '← Older Comments', 'my_theme' ) ); ?></div>
<div class="nav-next"><?php next_comments_link( esc_html__( 'Newer Comments →', 'my_theme' ) ); ?></div>
</nav>
<?php endif; // check for comment navigation ?>
<?php
/* If there are no comments and comments are closed, let's leave a little note, shall we?
* But we don't want the note on pages or post types that do not support comments.
*/
elseif ( ! comments_open() && ! is_page() && post_type_supports( get_post_type(), 'comments' ) ) :
?>
<p class="nocomments"><?php esc_html_e( 'Comments are closed.', 'my_theme' ); ?></p>
<?php endif; ?>
<?php
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$fields = array(
'author' =>
'<div class="comment_fields"><p class="comment-form-author"><input id="author" name="author" type="text" placeholder="' . esc_html__( 'Name*', 'my_theme' ) . '" value="' . esc_attr( $commenter['comment_author'] ) .
'" size="30"' . $aria_req . ' /></p>',
'email' =>
'<p class="comment-form-email"><input id="email" name="email" type="text" placeholder="' . esc_html__( 'E-mail*', 'my_theme' ) . '" value="' . esc_attr( $commenter['comment_author_email'] ) .
'" size="30"' . $aria_req . ' /></p>',
'url' =>
'<p class="comment-form-url"><input id="url" name="url" type="text" placeholder="' . esc_html__( 'Website*', 'my_theme' ) . '" value="' . esc_attr( $commenter['comment_author_url'] ) .
'" size="30"' . $aria_req . ' /></p></div>',
);
$comment_field = '<p class="comment-form-comment"><textarea id="comment" name="comment" placeholder="' . esc_html__( 'Message*', 'my_theme' ) . '" cols="45" rows="8" aria-required="true"></textarea></p>';
comment_form(array(
'fields' => $fields,
'comment_field' => $comment_field,
'comment_notes_after' => '',
'id_submit' => 'comment-submit',
'title_reply' => esc_html__( 'Leave a reply', 'my_theme' ),
'label_submit' => esc_html__( 'Leave a comment', 'my_theme' ),
)); ?>
<div class="clear"></div>
</div><!-- #comments -->
The form appears, my comments are enabled in the wordpress. I fill the form and click on the submit button, and nothing happens!
So I tried to ajaxify it by adding the code from here
<script type="text/javascript">
jQuery('document').ready(function($){
// Get the comment form
var commentform = $('#commentform');
// Add a Comment Status message
commentform.prepend('<div id="comment-status" ></div>');
// Defining the Status message element
var statusdiv = $('#comment-status');
commentform.submit(function(){
// Serialize and store form data
var formdata = commentform.serialize();
//Add a status message
statusdiv.html('<p class="ajax-placeholder">Processing...</p>');
//Extract action URL from commentform
var formurl = commentform.attr('action');
//Post Form with data
$.ajax({
type: 'post',
url: formurl,
data: formdata,
error: function(XMLHttpRequest, textStatus, errorThrown){
statusdiv.html('<p class="ajax-error" >You might have left one of the fields blank, or be posting too quickly</p>');
},
success: function(data, textStatus){
if(data == "success")
statusdiv.html('<p class="ajax-success" >Thanks for your comment. We appreciate your response.</p>');
else
statusdiv.html('<p class="ajax-error" >Please wait a while before posting your next comment</p>');
commentform.find('textarea[name=comment]').val('');
}
});
return false;
});
});
</script>
Now when I comment, I get first the first error about leaving one of the fields blank, and then after that immediately I get the second error about posting a comment too quickly. I also noticed a 409 (Conflict) error in the console in Chrome that comes from mythemefolder/wp-comments-post.php which is a default from action link that comes from wordpress.
The strange thing is that once I refresh my page, I can see the post that I've added with ajax post. If I remove ajax and try to post a comment, and then refresh, nothing happens.
So what can be the issue? Why is there nothing being posted when I have no AJAX, and why are comments appearing when I have AJAX but only on page refresh?
EDIT
In Firebug when I inspect and send the form, I get:
POST mythemefolder/wp-comments-post.php 302 Moved Temporarily 2,51s
POST mythemefolder/wp-comments-post.php 409 Conflict 1,37s
GET mythemefolder/postname/#comment-11 200 OK 2,64s
So something happens. When I open the conflict one I find
<p>Duplicate comment detected; it looks as though you’ve already said that!</p></body>
Any clues?
Found the answer, the fault was my theme. It had a preventDefault() on a .submit button when clicked. The comment form works when I remove that part.

Adding custom input fields to Wordpress search

My goal is to add 2 input fields to the Wordpress search form, First Name and Last Name. Each one will show the post results for their respectful custom meta fields from the post type "services". But for some reason, when I tested it out, it's not showing any of the posts that have that custom meta field.
Here's the code that I have so far in my searchform.php file.
<?php
$meta_query = array();
if( !empty( $_GET['first_name'] ) ) {
$meta_query[] = array( 'key' => 'first_name', 'value' => $_GET['first_name'] );
}
if( !empty( $_GET['last_name'] ) ) {
$meta_query[] = array( 'key' => 'last_name', 'value' => $_GET['last_name'] );
}
$search = new WP_Query( array(
'post_type' => 'service',
'meta_query' => $meta_query
) );
?>
<form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
<input type="text" name="s" id="s" <?php if(is_search()) { ?>value="<?php the_search_query(); ?>" <?php } else { ?>value="Enter keywords …" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"<?php } ?> /><br />
<label>First Name</label><input type="text" name="first_name" />
<br />
<label>Last Name</label><input type="text" name="last_name"/>
<input type="submit" id="searchsubmit" value="Search" />
</form>
Here's all the code in my search.php file:
<?php
/**
* #package WordPress
* #subpackage Law Business
* #since Law Business 1.0
*
* Search Page Template
* Created by CMSMasters
*
*/
if( $_GET['first_name'] ) {
$meta_query[] = array( 'key' => 'first_name', 'value' => $_GET['first_name'] );
}
if( $_GET['last_name'] ) {
$meta_query['relation'] = 'OR';
$meta_query[] = array( 'key' => 'last_name', 'value' => $_GET['last_name'] );
}
get_header();
$cmsms_option = cmsms_get_global_options();
$cmsms_layout = $cmsms_option[CMSMS_SHORTNAME . '_search_layout'];
if (!$cmsms_layout) {
$cmsms_layout = 'r_sidebar';
}
echo '<!--_________________________ Start Content _________________________ -->' . "\n";
if ($cmsms_layout == 'r_sidebar') {
echo '<section id="content" role="main">' . "\n\t";
} elseif ($cmsms_layout == 'l_sidebar') {
echo '<section id="content" class="fr" role="main">' . "\n\t";
} else {
echo '<section id="middle_content" role="main">' . "\n\t";
}
?>
<div class="entry-summary">
<section class="blog">
<?php
if (!have_posts()) :
echo '<div class="error_block">' .
'<h2>' . __('Nothing found. Try another search?', 'cmsmasters') . '</h2>';
get_search_form();
echo '</div>';
else :
while (have_posts()) : the_post();
if (get_post_type() == 'post') {
if (get_post_format() != '') {
$cmsms_service_format = get_post_meta(get_the_ID(), 'cmsms_service_format', true);
}
} elseif (get_post_type() == 'service') {
$cmsms_service_format = get_post_meta(get_the_ID(), 'cmsms_service_format', true);
if (!$cmsms_service_format) {
$cmsms_service_format = 'slider';
}
?>
<article id="post-<?php the_ID(); ?>" <?php post_class('format-' . $cmsms_service_format); ?>>
<?php
cmsms_heading(get_the_ID(), 'service');
if (has_post_thumbnail()) {
cmsms_thumb(get_the_ID(), 'post-thumbnail', true, false, true, false, true, true, false);
}
the_excerpt();
cmsms_more(get_the_ID(), 'service');
?>
</article>
<div class="divider"></div>
<?php
} elseif (get_post_type() == 'page') {
?>
<article id="post-<?php the_ID(); ?>" <?php post_class('format-page'); ?>>
<?php
cmsms_heading(get_the_ID());
if (has_post_thumbnail()) {
cmsms_thumb(get_the_ID(), 'post-thumbnail', true, false, true, false, true, true, false);
}
the_excerpt();
?>
<div class="entry-content">
<h6><?php _e('This page contains your query', 'cmsmasters'); ?></h6>
</div>
<footer class="entry-meta">
<?php cmsms_more(get_the_ID()); ?>
</footer>
</article>
<div class="divider"></div>
<?php
}
endwhile;
pagination();
endif;
?>
</section>
</div>
</section>
<!-- _________________________ Finish Content _________________________ -->
<?php
if ($cmsms_layout == 'r_sidebar') {
echo "\n" . '<!-- _________________________ Start Sidebar _________________________ -->' . "\n" .
'<section id="sidebar" role="complementary">' . "\n";
get_sidebar();
echo "\n" . '</section>' . "\n" .
'<!-- _________________________ Finish Sidebar _________________________ -->' . "\n";
} elseif ($cmsms_layout == 'l_sidebar') {
echo "\n" . '<!-- _________________________ Start Sidebar _________________________ -->' . "\n" .
'<section id="sidebar" class="fl" role="complementary">' . "\n";
get_sidebar();
echo "\n" . '</section>' . "\n" .
'<!-- _________________________ Finish Sidebar _________________________ -->' . "\n";
}
get_footer();
I would appreciate any help.
try:
$meta_query = array();
if( $_GET['first_name'] ) {
$meta_query[] = array( 'key' => 'first_name', 'value' => $_GET['first_name'] );
}
if( $_GET['last_name'] ) {
$meta_query['relation'] = 'OR';
$meta_query[] = array( 'key' => 'last_name', 'value' => $_GET['last_name'] );
}
$search = new WP_Query( array(
'post_type' => 'service',
'meta_query' => $meta_query
) );
Also because you are using wp_query you're loop needs to be using the variable you saved your query in....
if (!$search->have_posts()) :
echo '<div class="error_block">' .
'<h2>' . __('Nothing found. Try another search?', 'cmsmasters') . '</h2>';
get_search_form();
echo '</div>';
else :
while ($search->have_posts()) : $search->the_post();

Categories