| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * Map / Contact Element |
|---|
| 4 | * |
|---|
| 5 | * Please do not edit this file. This file is part of the CyberChimps Framework and all modifications |
|---|
| 6 | * should be made in a child theme. |
|---|
| 7 | * |
|---|
| 8 | * @category CyberChimps Framework |
|---|
| 9 | * @package Framework |
|---|
| 10 | * @since 1.0 |
|---|
| 11 | * @author CyberChimps |
|---|
| 12 | * @license http://www.opensource.org/licenses/gpl-license.php GPL v3.0 (or later) |
|---|
| 13 | * @link http://www.cyberchimps.com/ |
|---|
| 14 | */ |
|---|
| 15 | // Don't load directly |
|---|
| 16 | if ( ! defined( 'ABSPATH' ) ) { |
|---|
| 17 | die( '-1' ); |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | if ( ! class_exists( 'CyberChimpsContactUs' ) ) { |
|---|
| 21 | |
|---|
| 22 | class CyberChimpsContactUs { |
|---|
| 23 | |
|---|
| 24 | protected static $instance; |
|---|
| 25 | public $options; |
|---|
| 26 | |
|---|
| 27 | /* Static Singleton Factory Method */ |
|---|
| 28 | |
|---|
| 29 | public static function instance() { |
|---|
| 30 | if ( ! isset( self::$instance ) ) { |
|---|
| 31 | $className = __CLASS__; |
|---|
| 32 | self::$instance = new $className; |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | return self::$instance; |
|---|
| 36 | } //end of instance |
|---|
| 37 | |
|---|
| 38 | /** |
|---|
| 39 | * Initializes plugin variables and sets up WordPress hooks/actions. |
|---|
| 40 | * |
|---|
| 41 | * @return void |
|---|
| 42 | */ |
|---|
| 43 | protected function __construct() { |
|---|
| 44 | add_action( 'map_contact', array( $this, 'render_display' ) ); |
|---|
| 45 | add_action( 'init', array( $this, 'meta_box' ) ); |
|---|
| 46 | |
|---|
| 47 | $this->options = get_option( 'cyberchimps_options' ); |
|---|
| 48 | } //end of construct |
|---|
| 49 | |
|---|
| 50 | public function render_display() { |
|---|
| 51 | |
|---|
| 52 | global $post, $post_id; |
|---|
| 53 | if(is_page()) |
|---|
| 54 | { |
|---|
| 55 | $post_id = $post->ID; |
|---|
| 56 | $custom_contact_title = get_post_meta( $post->ID, 'custom_contact_title', true ); |
|---|
| 57 | $custom_contact_address = get_post_meta( $post->ID, 'custom_contact_address', true ); |
|---|
| 58 | $custom_contact_number = get_post_meta( $post->ID, 'custom_contact_number', true ); |
|---|
| 59 | $custom_contact_email = get_post_meta( $post->ID, 'custom_contact_email', true ); |
|---|
| 60 | $contactus_element_text = get_post_meta( $post->ID, 'contactus_element_text', true ); |
|---|
| 61 | |
|---|
| 62 | } |
|---|
| 63 | else |
|---|
| 64 | { |
|---|
| 65 | |
|---|
| 66 | $custom_contact_title = cyberchimps_get_option('custom_contact_title'); |
|---|
| 67 | $custom_contact_address = cyberchimps_get_option('custom_contact_address'); |
|---|
| 68 | $custom_contact_number = cyberchimps_get_option('custom_contact_number'); |
|---|
| 69 | $custom_contact_email = cyberchimps_get_option('custom_contact_email'); |
|---|
| 70 | $contactus_element_text = cyberchimps_get_option('contactus_element_text'); |
|---|
| 71 | |
|---|
| 72 | } |
|---|
| 73 | if (!empty($custom_contact_title) || !empty($custom_contact_number) || !empty($custom_contact_email) ) { |
|---|
| 74 | ?> |
|---|
| 75 | |
|---|
| 76 | <style> |
|---|
| 77 | #map_contact_section{ |
|---|
| 78 | background-image:url('<?php echo get_template_directory_uri().'/cyberchimps/lib/images/contact_bg.jpg' ?>'); |
|---|
| 79 | background-position: center; |
|---|
| 80 | background-size: cover; |
|---|
| 81 | margin: 60px 0; |
|---|
| 82 | |
|---|
| 83 | } |
|---|
| 84 | </style> |
|---|
| 85 | |
|---|
| 86 | <div id="contact_us" class="row-fluid"> |
|---|
| 87 | <div class="span12"> |
|---|
| 88 | <h2 class="contact_title"><?php if(!empty($custom_contact_title)){echo $custom_contact_title; }?></h2> |
|---|
| 89 | </div> |
|---|
| 90 | <div class="contactus_wrapper span12"> |
|---|
| 91 | |
|---|
| 92 | <div class="span6"> |
|---|
| 93 | <div class="span12 contact_left_sec"> |
|---|
| 94 | <?php if(!empty($custom_contact_address)){?> |
|---|
| 95 | <div class="row-fluid contact_addr"> |
|---|
| 96 | <div class="span12"> |
|---|
| 97 | <div class="row-fluid"> |
|---|
| 98 | <div class="span1"><i class="fa fa-map-marker" aria-hidden="true"></i></div> |
|---|
| 99 | <div class="span10"><?php echo esc_html($custom_contact_address);?></div> |
|---|
| 100 | </div> |
|---|
| 101 | </div> |
|---|
| 102 | </div> |
|---|
| 103 | <?php } |
|---|
| 104 | if(!empty($custom_contact_number)){ |
|---|
| 105 | ?> |
|---|
| 106 | <div class="row-fluid contact_addr"> |
|---|
| 107 | <div class="span12"> |
|---|
| 108 | <div class="row-fluid"> |
|---|
| 109 | <div class="span1"><i class="fa fa-phone" aria-hidden="true"></i></div> |
|---|
| 110 | <div class="span10"><?php echo esc_html($custom_contact_number);?></div> |
|---|
| 111 | </div> |
|---|
| 112 | </div> |
|---|
| 113 | </div> |
|---|
| 114 | <?php } |
|---|
| 115 | if(!empty($custom_contact_email)){ |
|---|
| 116 | ?> |
|---|
| 117 | <div class="row-fluid contact_addr"> |
|---|
| 118 | <div class="span12"> |
|---|
| 119 | <div class="row-fluid"> |
|---|
| 120 | <div class="span1"><i class="fa fa-envelope" aria-hidden="true"></i></div> |
|---|
| 121 | <div class="span10"><?php echo esc_html($custom_contact_email);?></div> |
|---|
| 122 | </div> |
|---|
| 123 | </div> |
|---|
| 124 | </div> |
|---|
| 125 | <?php } ?> |
|---|
| 126 | </div> |
|---|
| 127 | </div> |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | <div class="span6"> |
|---|
| 131 | <div class="span12 contact_right_sec"> |
|---|
| 132 | <?php echo do_shortcode($contactus_element_text);?> |
|---|
| 133 | </div> |
|---|
| 134 | </div> |
|---|
| 135 | </div> |
|---|
| 136 | </div> |
|---|
| 137 | <?php |
|---|
| 138 | } |
|---|
| 139 | } //end of render_display |
|---|
| 140 | |
|---|
| 141 | public function meta_box() { |
|---|
| 142 | |
|---|
| 143 | $page_fields = array( |
|---|
| 144 | array( |
|---|
| 145 | 'type' => 'text', |
|---|
| 146 | 'id' => 'custom_contact_title', |
|---|
| 147 | 'class' => '', |
|---|
| 148 | 'name' => __( 'Contact Section Title', 'cyberchimps_core' ) |
|---|
| 149 | ), |
|---|
| 150 | array( |
|---|
| 151 | 'type' => 'text', |
|---|
| 152 | 'id' => 'custom_contact_address', |
|---|
| 153 | 'class' => '', |
|---|
| 154 | 'name' => __( 'Contact Address', 'cyberchimps_core' ) |
|---|
| 155 | ), |
|---|
| 156 | array( |
|---|
| 157 | 'type' => 'text', |
|---|
| 158 | 'id' => 'custom_contact_number', |
|---|
| 159 | 'class' => '', |
|---|
| 160 | 'name' => __( 'Contact Number', 'cyberchimps_core' ) |
|---|
| 161 | ), |
|---|
| 162 | array( |
|---|
| 163 | 'type' => 'text', |
|---|
| 164 | 'id' => 'custom_contact_email', |
|---|
| 165 | 'class' => '', |
|---|
| 166 | 'name' => __( 'Contact Email', 'cyberchimps_core' ) |
|---|
| 167 | ), |
|---|
| 168 | |
|---|
| 169 | array( |
|---|
| 170 | 'type' => 'text', |
|---|
| 171 | 'id' => 'contactus_element_text', |
|---|
| 172 | 'class' => '', |
|---|
| 173 | 'name' => __( 'Additional data', 'cyberchimps_core' ), |
|---|
| 174 | 'desc' => __('Recommended: Contact Form', 'cyberchimps_core') |
|---|
| 175 | ), |
|---|
| 176 | |
|---|
| 177 | |
|---|
| 178 | |
|---|
| 179 | ); |
|---|
| 180 | /* |
|---|
| 181 | * configure your meta box |
|---|
| 182 | */ |
|---|
| 183 | $page_config = array( |
|---|
| 184 | 'id' => 'map_contact_options', // meta box id, unique per meta box |
|---|
| 185 | 'title' => __( 'Custom Contact Options', 'cyberchimps_core' ), // meta box title |
|---|
| 186 | 'pages' => array( 'page' ), // post types, accept custom post types as well, default is array('post'); optional |
|---|
| 187 | 'context' => 'normal', // where the meta box appear: normal (default), advanced, side; optional |
|---|
| 188 | 'priority' => 'high', // order of meta box: high (default), low; optional |
|---|
| 189 | 'fields' => apply_filters( 'cyberchimps_custom_contact_metabox_fields', $page_fields, 'map_contact' ), // list of meta fields (can be added by field arrays) |
|---|
| 190 | 'local_images' => false, // Use local or hosted images (meta box images for add/remove) |
|---|
| 191 | 'use_with_theme' => true //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false). |
|---|
| 192 | ); |
|---|
| 193 | |
|---|
| 194 | /* |
|---|
| 195 | * Initiate your meta box |
|---|
| 196 | */ |
|---|
| 197 | $page_meta = new Cyberchimps_Meta_Box( $page_config ); |
|---|
| 198 | } |
|---|
| 199 | |
|---|
| 200 | } |
|---|
| 201 | } |
|---|
| 202 | CyberChimpsContactUs::instance(); |
|---|