WordPress Reservation Form Plugin Using by Ajax

You need to create a PHP file in plugin directory and copy below the snippets

<?php
/*
Plugin Name: Ajax Reservation Form
Plugin URI: http://example.com
Description: Reservation Form
Version: 1.0
Author: Ataur Rahman
Author URI: md-ataur.github.io
License: GPL v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: ajaxrf
*/

defined( 'ABSPATH' ) or die( 'No script kiddies please!' );

if(!class_exists('AjaxReservationForm')){

	class AjaxReservationForm{

		public function __construct(){
			add_action('plugins_loaded', array($this, 'ajaxrf_load_textdomain' ));
			add_action('wp_enqueue_scripts', array($this, 'ajaxrf_enqueue_scripts'));
			add_shortcode( 'ajax_reservation_form', array($this,'ajaxrf_shortcode' ));
			add_action( 'wp_ajax_ajaxRSF', array($this, 'AjaxdataProcess') );
			add_action( 'wp_ajax_nopriv_ajaxRSF', array($this, 'AjaxdataProcess') );
		}
		public function ajaxrf_load_textdomain(){
			load_plugin_textdomain( 'ajaxrf', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
		}
		public function ajaxrf_enqueue_scripts(){
			wp_enqueue_style( 'bootstrap', plugin_dir_url( __FILE__ ).'assets/public/css/bootstrap.min.css');
			wp_enqueue_script( 'ajax-reservation-js', plugin_dir_url( __FILE__ ).'assets/public/js/ajax-reservation.js', array( 'jquery' ), time(), true );
			$ajaxUrl = admin_url( 'admin-ajax.php');
			wp_localize_script( 'ajax-reservation-js', 'url', array('ajaxUrl' => $ajaxUrl) );
		}

		public static function AjaxdataProcess(){
			if (check_ajax_referer( 'rsf_nonce_action', 'rn', false )) {
				$name 	= sanitize_text_field( isset($_POST['RFname'])?$_POST['RFname']:'' );
				$email 	= sanitize_email( isset($_POST['RFemail'])?$_POST['RFemail']:'' );
				$phone 	= sanitize_text_field( isset($_POST['RFphone'])?$_POST['RFphone']:'' );
				$person = sanitize_text_field( isset($_POST['RFperson'])?$_POST['RFperson']:'' );
				$date 	= sanitize_text_field( isset($_POST['RFdate'])?$_POST['RFdate']:'' );
				$time 	= sanitize_text_field( isset($_POST['RFtime'])?$_POST['RFtime']:'' );
				$message 	= sanitize_text_field( isset($_POST['RFMessage'])?$_POST['RFMessage']:'' );
				if (!empty($name) && !empty($email) && !empty($phone) && !empty($person) && !empty($date) && !empty($time)) {					
					$email_message = wp_sprintf( "From: %s \nEmail: %s \nPhone: %s \nPersons: %s \nTime: %s \nMessage: %s", $name , $email, $phone, $person, $time, $message);		
					//$admin_email = get_option('admin_email');			
					wp_mail( 'contact@onlivetech.com', $name, $email_message );
					die ('<p class="alert alert-success">Successfully sent your reservation</p>');
				}else{
					die('<p class="alert alert-danger">Fields must no be empty</p>');
				}
			}
		}

		public static function ajax_reservation_form(){			
			?>
			<div class="container">
				<div class="col-md-6 offset-md-3">
					<div id="msg"></div>
	                <form action="<?php the_permalink(); ?>" id="Rform">
	                	<?php wp_nonce_field( 'rsf_nonce_action', 'rsf_nonce_field');?>
                        <div class="form-group">
                            <label for="name" class="label"><?php _e('Name','ajaxrf');?></label>
                            <input type="text" class="form-control" id="RFname">                            
                        </div>
                        <div class="form-group">
                            <label for="email" class="label"><?php _e('Email','ajaxrf');?></label>
                            <input type="email" class="form-control" id="RFemail">                           
                        </div>
                        <div class="form-group">
                            <label for="phone" class="label"><?php _e('Phone','ajaxrf');?></label>
                            <input type="text" class="form-control" id="RFphone">
                        </div>
                        <div class="form-group">
                            <label for="persons" class="label"><?php _e('Number of Persons','ajaxrf');?></label>
                            <select name="persons" id="RFperson" class="form-control">
                                <option value="1"><?php _e('1 person','ajaxrf');?> </option>
                                <option value="2"><?php _e('2 person','ajaxrf');?> </option>
                                <option value="3"><?php _e('3 person','ajaxrf');?></option>
                                <option value="4"><?php _e('4 person','ajaxrf');?></option>
                                <option value="5"><?php _e('5 person','ajaxrf');?></option>
                            </select>                            
                        </div>
                        <div class="row">
	                        <div class="form-group col-md-6">
	                            <label for="date" class="label"><?php _e('Date','ajaxrf');?></label>
	                            <input type="date" class="form-control" id="RFdate">	                            
	                        </div>
	                        <div class="form-group col-md-6">
	                            <label for="time" class="label"><?php _e('Time','ajaxrf');?></label>
	                            <input type="time" class="form-control" id="RFtime" autocomplete="off">
	                        </div>
                        </div>	 
                        <div class="form-group">
                        	<textarea class="form-control" id="RFMessage" rows="5"></textarea>
                        </div>                 
	                    <div class="row justify-content-center">
	                    	<button id="reserveForm" class="btn btn-primary"><?php _e('Reserve Now','ajaxrf');?></button>
	                    </div>
	                </form>
	            </div>
			</div>
			<?php
		}

		public function ajaxrf_shortcode(){
			// Turn on output buffering.
    		ob_start();

			self::ajax_reservation_form(); // echo the form

			// Turn off output buffering and then return the output echoed via the above functions.
    		return ob_get_clean();
		}
	}
	
	new AjaxReservationForm;
}

You need to create a js file and copy below the snippets

;(function($){
	$(document).ready(function(){		
		$('#reserveForm').on('click', function(){
			$.post(url.ajaxUrl, {
				action: 'ajaxRSF',
				rn: $('#rsf_nonce_field').val(),
				RFname: $('#RFname').val(),
				RFemail: $('#RFemail').val(),
				RFphone: $('#RFphone').val(),
				RFperson: $('#RFperson').val(),
				RFdate: $('#RFdate').val(),
				RFtime: $('#RFtime').val(),
				RFMessage: $('#RFMessage').val()
			}, function(data) {
				$('#msg').html(data);
				console.log(data);
				$('#Rform')[0].reset();
			});			
			return false;
		});
	});
})(jQuery);
Advertisements

Build Your Own WordPress Contact Form Using by Ajax

You need to create a template file and copy below the snippets

<?php
/**
 * Template Name: Ajax Contact Form
 */
get_header();
?>

<div class="container">
	<div class="col-md-6 offset-md-3">	
		<form action="<?php the_permalink(); ?>" method="post" id="cform">
			<?php wp_nonce_field('cf_nonce_action','cf_nonce_field'); ?>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label for="firstName"><?php _e("First Name","practice");?></label>
						<input type="text" class="form-control" id="firstName">
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label for="lastName"><?php _e("Last Name","practice");?></label>
						<input type="text" class="form-control" id="lastName">
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label for="subject"><?php _e("Subject","practice");?></label>
						<input type="text" class="form-control" id="subject">
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label for="phone"><?php _e("Phone","practice");?></label>
						<input type="text" class="form-control" id="phone" >
					</div>
				</div>
			</div>
			<div class="form-group">
				<label for="email"><?php _e("Email Address","practice");?></label>
				<input type="email" class="form-control" id="email">
			</div>
			<div class="form-group">
				<label for="message"><?php _e("Message","practice");?></label>
				<textarea class="form-control" id="message" rows="5"></textarea>
			</div>
			<button type="submit" id="ajaxForm" class="btn btn-primary btn-block"><i class="fa fa-paper-plane"></i> <?php _e("Send Message","practice")?></button>
		</form>
	</div>
</div>

<?php get_footer();?>

Then you need to create a js file and copy below the snippets

;(function($){
	$(document).ready(function(){		
		$('#ajaxForm').on('click',function(){
			$.post(cfurl.ajaxurl,{
				action: 'ajaxContactForm',
				nonce: $('#cf_nonce_field').val(),
				firstName: $('#firstName').val(),
				lastName: $('#lastName').val(),
				subject: $('#subject').val(),
				phone: $('#phone').val(),
				email: $('#email').val(),
				message: $('#message').val(),
			}, function(data){
				alert(data);
				console.log(data);
				$("#cform")[0].reset();
			});			
			return false;
		});
	});
})(jQuery);

What we did on the js file.
First of all, question yourself what would you do. I would like to send user data to the WordPress or php by the form click event without page relode. We created a click event and then sent user data by jQuery post function.

Functions.php file

/**
 * Enqueue scripts and styles.
 */
function practice_scripts() {
	wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/assets/public/css/bootstrap.min.css');		
	
	if (is_page_template('templates/ajax-contact-form.php')) {
		wp_enqueue_script( 'ajax-cf-js', get_template_directory_uri() . '/assets/public/js/ajax-contact-form.js', array( 'jquery' ), time(), true );
	}	

	$ajaxurl = admin_url('admin-ajax.php');	
	wp_localize_script( 'ajax-cf-js', 'cfurl', array('ajaxurl' => $ajaxurl) );

}
add_action( 'wp_enqueue_scripts', 'practice_scripts' );


/**
 * Ajax Contact Form
 */
function practice_ajaxContactForm(){	
	if(check_ajax_referer('cf_nonce_action', 'nonce')){
		$firstName = sanitize_text_field( isset($_POST['firstName'])?$_POST['firstName']:'' );
		$lastName = sanitize_text_field( isset($_POST['lastName'])?$_POST['lastName']:'' );
		$subject = sanitize_text_field( isset($_POST['subject'])?$_POST['subject']:'' );
		$phone = sanitize_text_field( isset($_POST['phone'])?$_POST['phone']:'' );
		$email = sanitize_email( isset($_POST['email'])?$_POST['email']:'' );
		$message = esc_textarea( isset($_POST['message'])?$_POST['message']:'' );
		if (!empty($firstName) && !empty($lastName) && !empty($subject) && !empty($phone) && !empty($email) && !empty($message)) {
			$_message = sprintf("From: %s \nEmail: %s \nPhone: %s \nMessage: %s", $firstName, $email, $phone, $message  );
			$admin_email = get_option('admin_email');		
			wp_mail( $admin_email, $subject, $_message );
			die('Successfully Message Sent');
		}else{
			die('Fields must not be empty!');
		}				
	}
}
add_action('wp_ajax_ajaxContactForm', 'practice_ajaxContactForm'); // Logged in
add_action('wp_ajax_nopriv_ajaxContactForm', 'practice_ajaxContactForm'); // Not Logged in

Woocommerce error face

archive-product.php or search page doesn’t work on my theme
The solution for me was to add theme support… Which, it’s been a while since I used woocommerce, so I completely forgot about that. But after adding the following line to my functions.php file, archive-product.php is now being used (/mytheme/woocommerce/archive-product.php) and I can update it, as I should be able to.

add_theme_support('woocommerce');

Simple Tips to Getting Approved on ThemeForest

HTML markup validation:

Please check HTML markup validation before developing a theme.

WordPress Code:

The following functions must be present:

	
	wp_head() - just before </head>
	wp_footer() - just before </body>
	body_class() - inside <body> or <html> tags
	post_class()
  • WordPress theme files and directories must be named using lowercase letters. Words must be separated by hyphens, not camelCase or underscores.
  • Themes must not add any entries to the admin bar and must not remove, hide
  • The $content_width variable must be used to define the maximum allowed width for images, videos, and oEmbeds displayed within a theme
  • Default WordPress CSS classes must be covered in the stylesheet.
  • WP_Filesystem methods must be used where available instead of direct PHP filesystem calls. For example, mkdir, fopen, fread, fwrite, fputs, etc., must not be used.

Prefix Everything:

For my WordPress themes, I use the themename_ prefix all around, as it is simple and clean.

	<?php 

	// Functions
	function prefix_setup()
	
	// Classes
	class Prefix_Class {}

	// Global Variables
	global $prefix_passengers;

	// Action Hooks
	do_action( ‘prefix_start_engine’ );

	// Filter Hooks
	$register = apply_filters( prefix_register );

	// Non Third-Pary Script Handles
	wp_enqueue_script( 'prefix-functions', get_template_directory_uri() . 'js/custom/functions.js' );

	// Non Third-Pary Style Handles
	wp_enqueue_style( 'prefix-minified-style', get_template_directory_uri() . 'style.min.css' );

	// Images
	add_image_size( 'prefix-large', 800, 600 );

	?>		

Properly Include Scripts and Styles:

Do Not Prefix Third Party Scripts. Themes must use the scripts shipped with WordPress instead of including their own copy of the script or using one from a CDN. This includes jQuery, jQuery UI, Backbone, Underscore, etc. protocol-relative formats such as //example.com/file.js instead of http://example.com/file.js

	
	<?php

	/**
	 * Third Party Styles
	 * More info: https://github.com/grappler/wp-standard-handles
	 */
	 
	// Incorrect 
	wp_enqueue_style( 'prefix-font-awesome', get_template_directory_uri() . '/css/font-awesome.css', array(), '4.2.0', 'all' );

	// Corrrect 
	wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome.css', array(), '4.2.0', 'all' );

	/**
	 * Third Party Scripts
	 */
	 
	// Incorrect 
	wp_enqueue_script( 'prefix-fitvids', get_template_directory_uri() . '/js/jquery.fitvids.js', array( 'jquery' ), '1.1.1', true );

	// Corrrect 
	wp_enqueue_script( 'jquery-fitvids', get_template_directory_uri() . '/js/jquery.fitvids.js', array( 'jquery' ), '1.1.1', true );

	?>	

Font Loading:

The fonts must be enqueued using wp_enqueue_style().

wp_enqueue_style( 'theme-prefix-fonts', "//fonts.googleapis.com/css?family=Lora:400,700|Inconsolata:700", '', '1.0.0', 'screen' );

Escape Everything:

	
	<?php

	// Use anytime HTML element encloses a section of data:
	echo esc_html( $no_html );

	// Use on all URLs, including those in the 'src' and 'href' attributes of an HTML element:
	<img src="<?php echo esc_url( $escaped_url ); ?>" />

	// Use for inline Javascript:
	<a href="#" onclick="<?php echo esc_js( $escaped_js ); ?>">
		<?php esc_html__( 'Click Here', 'text-domain' ); ?>
	</a>

	// Use for an HTML attribute:
	<div class="<?php echo esc_attr( $escaped_class ); ?>">

	?>		

Pluggable functions use:

A function can only be reassigned this way once, so you can’t install two plugins that plug the same function for different reasons. For safety, it is best to always wrap your functions with
if( ! function_exists(‘wp_mail’) ) { } , otherwise you will produce fatal errors on plugin activation.

PHP Code:

It is recommended that development is done with errors enabled and WP_DEBUG set to true. Follow the coding standard WordPress PHP Coding Standards.

  • Themes must work with the latest release of PHP. There is no required minimum supported version of PHP
  • The create_function() function has been deprecated as of PHP 7.2.0 and must no longer be used.
  • The “@” operator must not be used to suppress error messages or notices.
  • Tabs must be used for indentation
  • The creation of global variables is discouraged. They should be used only if absolutely necessary. If used, they must follow the prefixing rules.
  • The eval() function must not be used.

Check for PHP Errors and Warnings:

One of the easiest errors to check for is standard PHP errors. Enable wp_debug and go to town self-reviewing your theme to ensure there are no PHP errors, notices or warnings anywhere. You should also check for errors every time you submit an update.

HTML/CSS Code:

Note: It is strongly recommended that your theme follows both the WordPress HTML Coding Standards and the WordPress CSS Coding Standards.

  • CSS styling must not be hardcoded anywhere within a theme, either inline or in a tag.
  • A table of contents at the top of the stylesheet to act as a guide is required.
  • Dynamic styling must be added via wp_add_inline_style() with the exception of adding a background image to an element. In this instance, the following would be permitted:
  • 		<div id="header-background" style="background-image: url( <?php echo esc_url( '$header-background' ); ?> );"></div>
    	
  • IDs and classes must be appropriately named and follow a naming convention.
  • Strongly Recommended that all your code be run through the W3C validator. Items will be soft-rejected for important errors such as unclosed tags, nesting errors, duplicate IDs, etc.

JavaScript Code:

It is strongly recommended that your theme follow the WordPress JavaScript Coding Standards.

  • JavaScript code must be placed in external files whenever possible.
  • If defined in the global scope, all functions and variables should be prefixed with a unique identifier.
  • Unbind all event handlers before binding.
  • If PHP variables or data need to be passed to JavaScript, wp_localize_script() must be used.
  • If using jQuery, then .on() must be used instead of .click(), .bind(), .hover(), etc.
  • Development and debugging code such as console.log() must be removed.
  • Strict mode must be used for all JavaScript. For example, for jQuery:
	(function($) {
      "use strict";
      // your code here
   })(jQuery);

Translation Ready:

  • All theme text strings must be translatable
  • Text strings must not contain variables or constants
  • The text domain must use dashes rather than underscores and be lowercase plain-text.
  • Translation file should be in English and delivered as a .pot file. The .pot will contain all translation strings. The .pot file name should match the theme-slug (i.e. themeslug.pot).
  • Themes can include actual translation files (.po/.mo) for any variety of specific languages, but must not add the en_US.mo or en_US.po because English is already implied.

Theme Security Requirements:

Validation
Where possible, data must be validated on input. Although validation may occur on the client side, this cannot be solely relied on. The data also needs to be revalidated on the server side before the data is saved.
For more information on validation, refer to Data Validation article.Data Validation

Sanitization
If data cannot be validated on input, it must be sanitized instead.For example, it may not be possible to validate a text field, instead, it should be sanitized using the sanitize_text_field() or wp_kses() functions.For more information on sanitization, refer to Data Sanitization/Escaping

Working with the Database
Themes must not work directly with the database to create, update or delete site content and should generally only use WordPress core functions to display content.If there is a valid reason to work with the database, then the wpdb class provided by WordPress must be used. SQL statements must be prepared using $wpdb->prepare().

Escaping Output
WordPress core functions that return dynamic data must be escaped by the theme, except for those core functions starting with ‘the_’, which are generally escaped already. For example, home_url, admin_url, get_permalink, get_header_image, etc., should be escaped, but the_content, the_permalink, etc., are not required to be escaped.

Nonces
Any data that is submitted to the server must use nonces. If a user is allowed to submit data to the server, a nonce must be used to verify the origin and intent of the request.

SVG Upload
Themes must not enable SVG uploads as it raises security concerns due to the possibility of attackers executing malicious code through SVG’s XML.

Update TGMPA:

Keep in mind that every time you release a new version of your theme, you should double check that the latest version of TGMPA is included.

Properly Include Plugins Using TGMPA:

	<?php
	
	// Include a plugin from the WordPress Repository:
	array(
	  'name'      => esc_html__( 'WooCommerce', 'text-domain' ),
	  'slug'      => 'woocommerce',
	  'required'  => false,
	),

	// Include a plugin bundled within a WordPress theme:
	array(
	  'name'      => esc_html__( 'Example Plugin', 'text-domain' ),
	  'slug'      => 'example-plugin',
	  'source'    => get_template_directory() . '/inc/plugins/example-plugin.zip',
	  'required'  => false,
	),

	?> 	

Disable TGMPA Force Actions:

Every user should have free rein to activate or deactivate any WordPress plugins installed on their website.

Core Features:

1.Themes must not use features/APIs meant for WordPress core.
2.Themes must be widget-ready in all advertised locations. All widgetized areas must be appropriately styled to match the theme/demo design.
3.wp_nav_menu() must be included in at least one theme location. Menu locations may only display placeholders such as Add Menu and Set Menu if the current user is a logged in admin user and no menu has yet been set.
4.Themes must not unregister default WordPress widgets. Instead, new widgets should be registered via a plugin.
5.Must support all of the following features:

  • Comments
  • Sidebars
  • Editor style
  • Title tag

6.index.php must be reserved for the standard blog “latest posts” view.
7.Content, including placeholder/demo content, must not be hardcoded into the template files.
8.Admin code should be kept separate from public facing code via the is_admin() conditional to prevent unauthorized access.
9.Specify column names instead of * in your queries.

Menu Position:

If the theme has an Options page and no other sub menu items, then it must go in either the Customizer (strongly recommended) or the Appearance section.

Customizer:

Users are increasingly expecting to find theme options within the Customizer. All Customizer settings must be properly validated and sanitized with an appropriate sanitization callback.

Child Themes:

If a child theme is provided with the theme, it must:

  • Load the parent stylesheet using wp_enqueue_style() instead of @import.
  • Consist of style.css, functions.php and screenshot.png files at a minimum.
  • Append “Child” to the theme name so it can be identified as a child theme.

Plugin Territory Functionality:

  • Analytics code
  • SEO options
  • Forms
  • Non-design related meta boxes
  • Resource caching
  • Dashboard widgets
  • Custom Post Types
  • Custom Taxonomies
  • Shortcodes
  • Widgets
  • Social media like, follow and, share buttons
  • Framework related metabox

Third-Party Plugins & Libraries:

If you include plugins with your theme, you must use the TGM Plugin Activation (TGM PA) library.

  • You must keep included plugins and libraries up to date.
  • The force_activation and force_deactivation TGM PA parameters must not be set to true.
  • For plugins included in the zip file, the version TGM PA parameter must be set and kept up to date
  • You must not rename the original class-tgm-plugin-activation.php file to anything else.
  • Bundled plugins must be included in the main zip file.

Checking for Plugins:

Do not use is_plugin_active() when checking whether a plugin is active or not. is_plugin_active() is not reliable as it depends on the plugin’s folder/filename(which may change). Instead, you can use function_exists() or class_exists() as these are more reliable.

Import & Export Plugin:

Importers must not add content without user permission. Importers must not overwrite current content without clear warnings to the user. Custom Importers must use the WP Filesystem API.
Import/export functionality should be included via a plugin such as One Click Demo Import

Theme Unit Test Data:

Common issues are table display errors, image alignments, responsive comments, pingbacks display errors, password-protected post styling issues, and search index mishaps.

Run Theme Check:

Theme Check is literally the easiest way to check your WordPress theme against the latest coding standards and techniques. You can use Envato Theme Check plugin.

Provide Offline and online Documentation:

Documentation can be either publicly accessible online or included in the archive offline. Having offline documentation ensures that your customers are not hanging when there is not an Internet connection available or when your files are inaccessible – for any reason.

WordPress Information

ওয়ার্ডপ্রেস টার্মিনোলজি

1.slug (mean user friendly url)
2.Template Hierarchy ( ওয়ার্ডপ্রেসে পাট্টিকুলারলি যদি কিছু ফাইল থাকে ওয়ার্ডপ্রেস আগে সেই ফাইলটা দিয়ে কন্টেন্ট দেখায়। যদি ওটা না থাকে তাহলে আরেকটা ফাইল দিয়ে চেক করে যে এ ফাইলটা আছে কিনা তখন সেটা দিয়ে কন্টেন্ট দেখায়। যদি সেটাও না থাকে তাহলে আরেকটা ফাইল দিয়ে কন্টেন্ট দেখায় এভাবে সবশেষে কেউ যদি না থাকে তাহলে index.php দিয়ে কন্টেন্ট দেখায়। এই যে ওর্ডারটা, কন্টেন্ট দেখানোর জন্য কোন টেমপেল্ট ফাইলটা লোড হবে কোন php ফাইলটা লোড হবে। এই ওর্ডারটাকেই বলা হয় Template Hierarchy )

3.Taxonomy And Terms (Categories, Tags)
4.Transient (Temporary Storage)

What is hook?

হুক আসলে জাস্ট একটা ইভেন্ট ব্রডকাস্টিং সিস্টেম। দুই রকমের হুক আছে, অ্যাকশন হুক এবং ফিল্টার হুক

প্লাগেবল ফাংশন কি?

একটা ফাংশনকে এমন ভাবে ডিফাইন করা হয়, যাতে করে ইউজার সেই ফাংশনটি রিরাইট করতে পারে। অথাৎ একটা কন্ডিশনের ভিক্তিতে চেক করা হয় ফাংশনটি লিখা হয়েছে কিনা? যদি না হয় তাহলে ফলবেক হিসেবে কারেন্ট ফাংশনটিকে রির্টান করে। আর যদি থাকে তার মানে সেই existing ফাংশনটিকে নতুন করে লিখা হয়েছে। তখন সে নতুনটাকে রির্টান করে।

Google Live Map

<?php

/*
Template Name: map
*/

get_header();

?>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCPj2rrgRVKPap-cVS9_Wpd4fkBkXGF7fI&callback=myMap"></script>

<style>
	.common_page_container {border-top: 1px dashed #dddddd;margin:14px auto;padding: 24px 0;}
	.outletadd {padding: 0 0 0 3%;width:36%;}
	.store-col {float: left;margin: 0;}
	.store-col li {background:#f6f6f6;border: 1px solid #ddd;list-style: none;margin: 0 0 6px;padding: 3px 6px;}
	.store-col a {text-decoration: none; font-size: 13px;}
	#map-add {font-size: 13px; font-family: arial;}
	.map-add.store-col {float: left;margin: 0px;width:100%;}
	#MapCanvas {margin: 0;  max-width: 100%;min-height:380px;min-width: 300px;padding: 0;}
</style>

<script type="text/javascript">
	function updateMap(selectControl){ 
	    switch(selectControl){
			case 'Shimanto': 
			  initialize(23.738143,90.376614, "1st Floor, Road no-2, Dhanmondi, Dhaka<br/>Phone:+8802-8618890");
			  addressChange("Shimanto Square: <br/> 1st Floor, Road no-2, Dhanmondi, Dhaka <br/>Mobile:+88-01730068075");
			  break; 
			  
			case 'Mohammadpur':
			  initialize(23.76508,90.358429, "Shop No. 223-224, Toyko Square, Japan Garden City <br/>Mobile:+88-01730068069");
			  addressChange("Mohammadpur: <br/>Shop No. 223-224, Toyko Square, Japan Garden City <br/>Mobile:+88-01730068069");
			  break;
		}
	}   


	function initialize(lat,Lng,titletxt) { 
	    var mapOptions = {
	      center: new google.maps.LatLng(lat,Lng),
	      zoom: 17
	    };

	    var map = new google.maps.Map(document.getElementById("MapCanvas"),mapOptions);
		
		var marker = new google.maps.Marker({
			position: new google.maps.LatLng(lat,Lng),
			map: map,
			icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png'
			//title: 'Rang'
		});

		var infowindow = new google.maps.InfoWindow({
		  content: titletxt,
		  zIndex: 990,
		});

		infowindow.open(map,marker);
	}

	function addressChange(add){
		document.getElementById('map-add').innerHTML = add;	
	}

	jQuery(document).ready( function($) {
		google.maps.event.addDomListener(window, 'load', initialize(24.1263456,90.3802059, "269-272 Tejgaon I/A Dhaka-1208, Bangladesh <br/>Tel: +88 02-8870616, 8870631<br/>"),check);	
	});
		
</script>



<div class="common_page_container">
	<div class="selectoutlet store-col">
		<ul>
			<li><a href="javascript:;" rel="Shimanto" onclick="updateMap(this.rel)">&nbsp; Shimanto Square</a></li>
			<li><a href="javascript:;" rel="Mohammadpur" onclick="updateMap(this.rel)">&nbsp; Mohammadpur</a></li>
			
		</ul>
		<!--<form>
			<select name="mapchange"  onchange="updateMap(this.options[this.selectedIndex].value)">
				<option value="Basundhara">&nbsp; Basundhara City</option>
				<option value="pink_city">&nbsp; Pink City</option>
				<option value="jamuna_future">&nbsp;Jamuna Future Park 1</option>
				<option value="jamuna_future2">&nbsp;Jamuna Future Park 2</option>
				
			</select>
		</form> -->
	</div>
	<div class="outletadd store-col">
		<div id="map-add">269-272 Tejgaon I/A Dhaka-1208, Bangladesh <br/>Tel: +88 02-8870616, 8870631<br/>E-mail: info@energypac-fashions.com</div>
	</div>
	<div class="map-add store-col">
		<div id="MapCanvas"></div>
	</div>
	<div class="clearer"></div>
</div>


<?php 
get_footer(); 

?>

Image uploading Problem

|| File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini file

|| solved: Go to the file directory public_html wp-admin then put the php.ini file, and include following code


upload_max_filesize = 64M;
post_max_size = 32M;
safe_mode = off;