Skip to content

Commit 192c7ee

Browse files
committed
Initially added to GitHub v.1.3
0 parents  commit 192c7ee

112 files changed

Lines changed: 9435 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
**PEPRO BRANCHES MAP (MAPIFY)**
2+
===============================
3+
4+
##### **Developed by** [Perpro Development Group](https://pepro.dev/)
5+
6+
*Current Version: 1.3.0* \| *Lead Programmer:* [Amirhosseinhpv](https://hpv.im/)

assets/app/mapify.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div id="mapify-selected-details">
2+
<div></div>
3+
</div>
4+
<div class="mapify-container-parent">
5+
<div class="mtheme-dark">
6+
<div id="googlemapdiv" style="height: 100%;width: 100%;"></div>
7+
</div>
8+
</div>
9+
<div id="mapify-selected-details2">
10+
<input type="text" id="go_latitude" placeholder="Enter Latitude ..."/>
11+
<input type="text" id="go_longitude" placeholder="Enter Longitude ..."/>
12+
<button type="button" id="go_mapupdate" class="button"><?=__("Go to Coordinate","mapify");?></button>
13+
</div>

assets/app/metabx.php

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
<?php
2+
class MapifyCPTmEtaboxWalker {
3+
private $screens = array('mapify',);
4+
private $td;
5+
private $plugin_dir;
6+
private $plugin_url;
7+
private $assets_url;
8+
private $plugin_basename;
9+
private $plugin_file;
10+
private $version;
11+
private $db_slug;
12+
private $title;
13+
private $title_w;
14+
private $db_table = null;
15+
// __("Address", "mapify")
16+
// __("Phone", "mapify")
17+
// __("Site", "mapify")
18+
// __("Email", "mapify")
19+
// __("PinLong", "mapify")
20+
// __("PinLat", "mapify")
21+
// __("Province", "mapify")
22+
// __("Country", "mapify")
23+
// __("Twitter", "mapify")
24+
// __("Facebook", "mapify")
25+
// __("Instagram", "mapify")
26+
// __("Telegram", "mapify")
27+
// __("LinkedIn", "mapify")
28+
// __("Additional Text", "mapify")
29+
public function __construct() {
30+
global $wpdb;
31+
$this->td = "mapify";
32+
$this->plugin_dir = plugin_dir_path(__FILE__);
33+
$this->assets_url = plugins_url("/assets/", dirname(__FILE__,2));
34+
$this->db_slug = $this->td;
35+
$this->db_table = $wpdb->prefix . $this->db_slug;
36+
37+
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
38+
add_action( 'save_post', array( $this, 'save_post' ) );
39+
}
40+
public function get_fileds(){
41+
$fields = apply_filters( "mapify-cpt-metakeys", array(
42+
array('id' => 'pinimg', 'label' => __("Custom Pin Image", "mapify") ,'type' => 'text',),
43+
array('id' => 'content_template', 'label' => __("Post Content Template", "mapify") ,'type' => 'select', 'value' => array( "default" => __("Inherit from Setting",$this->td), "post" => __("Use Post Template",$this->td), "content" => __("Use Mapify Template",$this->td), )),
44+
array('id' => 'address', 'label' => __("Address", "mapify") ,'type' => 'textarea',),
45+
array('id' => 'phone', 'label' => __("Phone", "mapify") ,'type' => 'text',),
46+
array('id' => 'site', 'label' => __("Site", "mapify") ,'type' => 'url',),
47+
array('id' => 'email', 'label' => __("Email", "mapify") ,'type' => 'email',),
48+
array('id' => 'socailtw', 'label' => __("Twitter", "mapify") ,'type' => 'text',),
49+
array('id' => 'socailfb', 'label' => __("Facebook", "mapify") ,'type' => 'text',),
50+
array('id' => 'socailig', 'label' => __("Instagram", "mapify") ,'type' => 'text',),
51+
array('id' => 'socailtg', 'label' => __("Telegram", "mapify") ,'type' => 'text',),
52+
array('id' => 'socailli', 'label' => __("LinkedIn", "mapify") ,'type' => 'text',),
53+
array('id' => 'additional', 'label' => __("Additional Text", "mapify") ,'type' => 'textarea',),
54+
));
55+
array_push($fields,array('id' => 'map_data', 'label' => "RAW DATA" ,'type' => 'textarea',));
56+
return $fields ;
57+
}
58+
public function add_meta_boxes() {
59+
foreach ( $this->screens as $screen ) {
60+
add_meta_box(
61+
'place-details',
62+
__( 'Branch Details', $this->td),
63+
array( $this, 'add_meta_box_callback' ),
64+
$screen,
65+
'normal',
66+
'high'
67+
);
68+
}
69+
}
70+
public function add_meta_box_callback( $post ) {
71+
72+
wp_nonce_field( 'place_details_data', 'place_details_nonce' );
73+
$api = get_option("{$this->db_slug}-googlemapAPI",""); $apiw = ( empty($api) ? "" : "key=$api&" );
74+
wp_enqueue_script( "mapify_core", "//cdn.amcharts.com/lib/4/core.js", array( "jquery" ), "4.0.0", true);
75+
wp_enqueue_script( "mapify_maps", "//cdn.amcharts.com/lib/4/maps.js", array( "jquery" ), "4.0.0", true);
76+
wp_enqueue_script( "mapify_world", "//cdn.amcharts.com/lib/4/geodata/worldLow.js", array( "jquery" ), "4.0.0", true);
77+
wp_enqueue_script( "mapify_countries2", "//cdn.amcharts.com/lib/4/geodata/data/countries2.js", array( "jquery" ), "4.0.0", true);
78+
wp_enqueue_script( "mapify_googleapi", "//maps.googleapis.com/maps/api/js?{$apiw}libraries=places",array( 'jquery' ), '1.0.0', true );
79+
wp_register_script( "mapify_mapify", "{$this->assets_url}js/backend-mapify.js", array( "jquery" ), current_time("timestamp"), true);
80+
wp_enqueue_style( "mapify_mapify", "{$this->assets_url}css/backend-mapify.css");
81+
wp_localize_script( "mapify_mapify", "MAPIFY", array(
82+
"api" => $api?1:0,
83+
"spotlight" => "{$this->assets_url}img/spotlight.png",
84+
"drag" => _x("To change, drag this marker","js-translate", $this->td),
85+
"dragging" => _x("Currently dragging marker...","js-translate", $this->td),
86+
"vc_pinmarkermaker_clipboard" => __("Click To Set as your Pin image", $this->td),
87+
"vc_pinmarkermaker_numbers" => __("Numbers", $this->td),
88+
"vc_pinmarkermaker_character" => __("Character", $this->td),
89+
"vc_pinmarkermaker_symbols" => __("Symbols", $this->td),
90+
"drop" => _x("Drop on your location","js-translate", $this->td),));
91+
wp_enqueue_script( "mapify_mapify");
92+
93+
ob_start();
94+
do_action( "mapify-cpt-metabox-before-print", $post);
95+
include "{$this->plugin_dir}mapify.php";
96+
$this->generate_fields( $post );
97+
do_action( "mapify-cpt-metabox-after-print", $post);
98+
$tcona = ob_get_contents();
99+
ob_end_clean();
100+
echo $tcona;
101+
}
102+
public function generate_fields( $post ) {
103+
$output = '';
104+
foreach ( $this->get_fileds() as $field ) {
105+
$label = '<label for="' . $field['id'] . '">' . $field['label'] . '</label>';
106+
$db_value = get_post_meta( $post->ID, 'place_details_' . $field['id'], true );
107+
switch ( $field['type'] ) {
108+
case 'textarea':
109+
$input = sprintf(
110+
'<textarea class="large-text" id="%s" placeholder="%s" name="%s" rows="5">%s</textarea>',
111+
$field['id'],
112+
$field['label'],
113+
$field['id'],
114+
$db_value
115+
);
116+
break;
117+
case 'select':
118+
$input = sprintf( '<select class="large-text" id="%s" placeholder="%s" name="%s">', $field['id'], $field['label'], $field['id'], );
119+
foreach ($field['value'] as $key => $value) {
120+
$checked = selected( $db_value, $key,false);
121+
$input .= "<option value='$key' $checked>$value</option>";
122+
}
123+
$input .= "</select>";
124+
break;
125+
default:
126+
$input = sprintf(
127+
'<input %s id="%s" title="%s" placeholder="%s" name="%s" type="%s" value="%s">',
128+
$field['type'] !== "color" ? "class='regular-text mapifyfields {$field['id']}'" : "",
129+
$field['id'],
130+
$field['label'],
131+
$field['label'],
132+
$field['id'],
133+
$field['type'],
134+
$db_value
135+
);
136+
}
137+
$output .= $this->row_format( $label, $input,$field['id'] );
138+
}
139+
echo '<table class="form-table"><tbody>' . $output . '</tbody></table>';
140+
}
141+
public function row_format( $label, $input, $id ) {
142+
return sprintf(
143+
// '%s',
144+
"<tr id='mapify-{$id}'><th scope='row'>%s</th><td>%s</td></tr>",
145+
$label,
146+
$input
147+
);
148+
}
149+
public function save_post( $post_id ) {
150+
if ( ! isset( $_POST['place_details_nonce'] ) )
151+
return $post_id;
152+
$nonce = $_POST['place_details_nonce'];
153+
if ( !wp_verify_nonce( $nonce, 'place_details_data' ) )
154+
return $post_id;
155+
156+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
157+
return $post_id;
158+
159+
foreach ( $this->get_fileds() as $field ) {
160+
if ( isset( $_POST[ $field['id'] ] ) ) {
161+
switch ( $field['type'] ) {
162+
case 'email':
163+
$_POST[ $field['id'] ] = sanitize_email( $_POST[ $field['id'] ] );
164+
break;
165+
case 'text':
166+
$_POST[ $field['id'] ] = sanitize_text_field( $_POST[ $field['id'] ] );
167+
break;
168+
}
169+
update_post_meta( $post_id, 'place_details_' . $field['id'], $_POST[ $field['id'] ] );
170+
} else if ( $field['type'] === 'checkbox' ) {
171+
update_post_meta( $post_id, 'place_details_' . $field['id'], "" );
172+
}
173+
}
174+
}
175+
}
176+
177+
new MapifyCPTmEtaboxWalker;

assets/css/96594ad4.woff2

23.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)