WIP: Iconpicker
This commit is contained in:
BIN
inc/vendors/cmb2-plugins/custom-fields/iconpicker/assets/css/iconpicker.eot
vendored
Normal file
BIN
inc/vendors/cmb2-plugins/custom-fields/iconpicker/assets/css/iconpicker.eot
vendored
Normal file
Binary file not shown.
19
inc/vendors/cmb2-plugins/custom-fields/iconpicker/assets/css/iconpicker.svg
vendored
Normal file
19
inc/vendors/cmb2-plugins/custom-fields/iconpicker/assets/css/iconpicker.svg
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<metadata>Copyright (C) 2014 by original authors @ fontello.com</metadata>
|
||||
<defs>
|
||||
<font id="iconpicker" horiz-adv-x="1000" >
|
||||
<font-face font-family="iconpicker" font-weight="400" font-stretch="normal" units-per-em="1000" ascent="850" descent="-150" />
|
||||
<missing-glyph horiz-adv-x="1000" />
|
||||
<glyph glyph-name="spin3" unicode="" d="m494 850c-266 0-483-210-494-472c-1-19 13-20 13-20l84 0c16 0 19 10 19 18c10 199 176 358 378 358c107 0 205-45 273-118l-58-57c-11-12-11-27 5-31l247-50c21-5 46 11 37 44l-58 227c-2 9-16 22-29 13l-65-60c-89 91-214 148-352 148z m409-508c-16 0-19-10-19-18c-10-199-176-358-377-358c-108 0-205 45-274 118l59 57c10 12 10 27-5 31l-248 50c-21 5-46-11-37-44l58-227c2-9 16-22 30-13l64 60c89-91 214-148 353-148c265 0 482 210 493 473c1 18-13 19-13 19l-84 0z" horiz-adv-x="1000" />
|
||||
<glyph glyph-name="search" unicode="" d="m643 386q0 103-74 176t-176 74t-177-74t-73-176t73-177t177-73t176 73t74 177z m286-465q0-29-22-50t-50-21q-30 0-50 21l-191 191q-100-69-223-69q-80 0-153 31t-125 84t-84 125t-31 153t31 152t84 126t125 84t153 31t152-31t126-84t84-126t31-152q0-123-69-223l191-191q21-21 21-51z" horiz-adv-x="928.6" />
|
||||
<glyph glyph-name="cancel" unicode="" d="m724 112q0-22-15-38l-76-76q-16-15-38-15t-38 15l-164 165l-164-165q-16-15-38-15t-38 15l-76 76q-16 16-16 38t16 38l164 164l-164 164q-16 16-16 38t16 38l76 76q16 16 38 16t38-16l164-164l164 164q16 16 38 16t38-16l76-76q15-15 15-38t-15-38l-164-164l164-164q15-15 15-38z" horiz-adv-x="785.7" />
|
||||
<glyph glyph-name="block" unicode="" d="m732 352q0 90-48 164l-421-420q76-50 166-50q62 0 118 25t96 65t65 97t24 119z m-557-167l421 421q-75 50-167 50q-83 0-153-40t-110-112t-41-152q0-91 50-167z m682 167q0-88-34-168t-91-137t-137-92t-166-34t-167 34t-137 92t-91 137t-34 168t34 167t91 137t137 91t167 34t166-34t137-91t91-137t34-167z" horiz-adv-x="857.1" />
|
||||
<glyph glyph-name="down-dir" unicode="" d="m571 457q0-14-10-25l-250-250q-11-11-25-11t-25 11l-250 250q-11 11-11 25t11 25t25 11h500q14 0 25-11t10-25z" horiz-adv-x="571.4" />
|
||||
<glyph glyph-name="up-dir" unicode="" d="m571 171q0-14-10-25t-25-10h-500q-15 0-25 10t-11 25t11 26l250 250q10 10 25 10t25-10l250-250q10-11 10-26z" horiz-adv-x="571.4" />
|
||||
<glyph glyph-name="left-dir" unicode="" d="m357 600v-500q0-14-10-25t-26-11t-25 11l-250 250q-10 11-10 25t10 25l250 250q11 11 25 11t26-11t10-25z" horiz-adv-x="357.1" />
|
||||
<glyph glyph-name="right-dir" unicode="" d="m321 350q0-14-10-25l-250-250q-11-11-25-11t-25 11t-11 25v500q0 15 11 25t25 11t25-11l250-250q10-10 10-25z" horiz-adv-x="357.1" />
|
||||
</font>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
BIN
inc/vendors/cmb2-plugins/custom-fields/iconpicker/assets/css/iconpicker.ttf
vendored
Normal file
BIN
inc/vendors/cmb2-plugins/custom-fields/iconpicker/assets/css/iconpicker.ttf
vendored
Normal file
Binary file not shown.
BIN
inc/vendors/cmb2-plugins/custom-fields/iconpicker/assets/css/iconpicker.woff
vendored
Normal file
BIN
inc/vendors/cmb2-plugins/custom-fields/iconpicker/assets/css/iconpicker.woff
vendored
Normal file
Binary file not shown.
2
inc/vendors/cmb2-plugins/custom-fields/iconpicker/assets/css/jquery.fonticonpicker.min.css
vendored
Normal file
2
inc/vendors/cmb2-plugins/custom-fields/iconpicker/assets/css/jquery.fonticonpicker.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
13
inc/vendors/cmb2-plugins/custom-fields/iconpicker/assets/js/jquery.fonticonpicker.min.js
vendored
Normal file
13
inc/vendors/cmb2-plugins/custom-fields/iconpicker/assets/js/jquery.fonticonpicker.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
9
inc/vendors/cmb2-plugins/custom-fields/iconpicker/assets/js/script.js
vendored
Normal file
9
inc/vendors/cmb2-plugins/custom-fields/iconpicker/assets/js/script.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
$( document ).ready( function () {
|
||||
$( '.opalestate-iconpicker' ).each( function () {
|
||||
$( this ).fontIconPicker();
|
||||
} );
|
||||
} );
|
||||
|
||||
} )( jQuery );
|
||||
@@ -0,0 +1,2 @@
|
||||
/* Grey Theme file for fontIconPicker {@link https://github.com/micc83/fontIconPicker} */
|
||||
.fip-grey.icons-selector{font-size:16px}.fip-grey.icons-selector .selector{border:1px solid #EDEDED;background-color:#fff}.fip-grey.icons-selector .selector-button{background-color:#F4F4F4;border-left:1px solid #E1E1E1}.fip-grey.icons-selector .selector-button:hover{background-color:#f1f1f1}.fip-grey.icons-selector .selector-button:hover i{color:#999}.fip-grey.icons-selector .selector-button i{color:#aaa;text-shadow:0 1px 0 #FFF}.fip-grey.icons-selector .selected-icon i{color:#404040}.fip-grey.icons-selector .selector-popup{-moz-box-shadow:0 1px 1px rgba(0,0,0,.04);-webkit-box-shadow:0 1px 1px rgba(0,0,0,.04);box-shadow:0 1px 1px rgba(0,0,0,.04);border:1px solid #E5E5E5}.fip-grey.icons-selector .selector-category select,.fip-grey.icons-selector .selector-search input[type=text]{border:1px solid #EDEDED;color:#404040;-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none;outline:0}.fip-grey.icons-selector input::-webkit-input-placeholder{color:#ddd}.fip-grey.icons-selector input:-moz-placeholder{color:#ddd}.fip-grey.icons-selector input::-moz-placeholder{color:#ddd}.fip-grey.icons-selector input:-ms-input-placeholder{color:#ddd!important}.fip-grey.icons-selector .selector-search i{color:#eee}.fip-grey.icons-selector .fip-icons-container{background-color:#fff;border:1px solid #EDEDED}.fip-grey.icons-selector .fip-icons-container .loading{color:#eee}.fip-grey.icons-selector .fip-box{border:1px solid #EFEFEF}.fip-grey.icons-selector .fip-box:hover{background-color:#f6f6f6}.fip-grey.icons-selector .selector-footer,.fip-grey.icons-selector .selector-footer i{color:#ddd}.fip-grey.icons-selector .selector-arrows i:hover{color:#777}.fip-grey.icons-selector span.current-icon,.fip-grey.icons-selector span.current-icon:hover{background-color:#2EA2CC;color:#fff;border:1px solid #298CBA}.fip-grey.icons-selector .icons-picker-error i:before{color:#eee}
|
||||
76
inc/vendors/cmb2-plugins/custom-fields/iconpicker/iconpicker.php
vendored
Executable file
76
inc/vendors/cmb2-plugins/custom-fields/iconpicker/iconpicker.php
vendored
Executable file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* Opalestate_Field_Iconpicker
|
||||
*
|
||||
* @package opalestate
|
||||
* @author Opal Team <info@wpopal.com >
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Opalestate_Field_Iconpicker {
|
||||
|
||||
/**
|
||||
* Current version number
|
||||
*/
|
||||
const VERSION = '1.0.0';
|
||||
|
||||
/**
|
||||
* Initialize the plugin by hooking into CMB2
|
||||
*/
|
||||
public static function init() {
|
||||
// $icons = new Fontawesome();
|
||||
// $this->icon_data = $icons->get_icons();
|
||||
|
||||
add_filter( 'cmb2_render_opal_iconpicker', [ __CLASS__, 'render_iconpicker' ], 10, 5 );
|
||||
add_filter( 'cmb2_sanitize_opal_iconpicker', [ __CLASS__, 'sanitize_icon' ], 10, 4 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render field.
|
||||
*/
|
||||
public static function render_iconpicker( $field, $field_escaped_value, $field_object_id, $field_object_type, $field_type_object ) {
|
||||
self::setup_admin_scripts();
|
||||
|
||||
$users = $field->value;
|
||||
|
||||
// $output = sprintf(
|
||||
// '<select id="%1$s" class="%2$s" name="%3$s">',
|
||||
// sanitize_key( $this->form->form_id . $args['id'] ),
|
||||
// esc_attr( $args['class'] ),
|
||||
// esc_attr( $args['id'] )
|
||||
// );
|
||||
//
|
||||
// foreach ( $this->icon_data as $icon_item ) {
|
||||
// $full_icon_class = $icon_item['prefix'] . ' ' . $icon_item['class'];
|
||||
// $output .= '<option value="' . $full_icon_class . '" ' . selected( $full_icon_class, $value, false ) . '>' . esc_html( $icon_item['class'] ) . '</option>';
|
||||
// }
|
||||
//
|
||||
// $output .= '</select>';
|
||||
//
|
||||
// echo $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize data.
|
||||
*/
|
||||
public static function sanitize_icon( $override_value, $value, $object_id, $field_args ) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue scripts and styles.
|
||||
*/
|
||||
public static function setup_admin_scripts() {
|
||||
// Iconpicker.
|
||||
wp_register_style( 'fonticonpicker', plugins_url( 'assets/css/jquery.fonticonpicker.min.css', __FILE__ ), [], self::VERSION );
|
||||
wp_register_style( 'fonticonpicker-grey-theme', plugins_url( 'assets/themes/grey-theme/jquery.fonticonpicker.grey.min.css', __FILE__ ), [], self::VERSION );
|
||||
|
||||
wp_enqueue_style( 'fonticonpicker' );
|
||||
wp_enqueue_style( 'fonticonpicker-grey-theme' );
|
||||
}
|
||||
}
|
||||
|
||||
Opalestate_Field_Iconpicker::init();
|
||||
101
inc/vendors/cmb2-plugins/custom-fields/iconpicker/providers/fontawesome.php
vendored
Normal file
101
inc/vendors/cmb2-plugins/custom-fields/iconpicker/providers/fontawesome.php
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fontawesome
|
||||
*
|
||||
* A helper class for outputting common HTML elements, such as product drop downs
|
||||
*/
|
||||
class Opalestate_Iconpicker_Fontawesome {
|
||||
|
||||
const BRANDS_URL = OPALESTATE_PLUGIN_URL . 'assets/3rd/font-awesome/webfonts/fa-brands-400.svg';
|
||||
const SOLID_URL = OPALESTATE_PLUGIN_URL . 'assets/3rd/font-awesome/webfonts/fa-solid-900.svg';
|
||||
const REGULAR_URL = OPALESTATE_PLUGIN_URL . 'assets/3rd/font-awesome/webfonts/fa-regular-400.svg';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $icons = [];
|
||||
|
||||
/**
|
||||
* Fontawesome constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->get_solid_icons();
|
||||
$this->get_regular_icons();
|
||||
$this->get_brands_icons();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all icons.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_icons() {
|
||||
return $this->icons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets data.
|
||||
*
|
||||
* @param $path
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_data( $path ) {
|
||||
$svg = wp_remote_get( $path );
|
||||
$svg = wp_remote_retrieve_body( $svg );
|
||||
|
||||
preg_match_all( '/glyph-name="(.*?)"/', $svg, $data, PREG_SET_ORDER );
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets solid icons.
|
||||
*/
|
||||
public function get_solid_icons() {
|
||||
$data = $this->get_data( static::SOLID_URL );
|
||||
if ( $data ) {
|
||||
foreach ( $data as $match ) {
|
||||
$item = [];
|
||||
$item['class'] = 'fa-' . $match[1];
|
||||
$item['prefix'] = 'fas';
|
||||
$this->icons[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets regular icons.
|
||||
*/
|
||||
public function get_regular_icons() {
|
||||
$data = $this->get_data( static::REGULAR_URL );
|
||||
if ( $data ) {
|
||||
foreach ( $data as $match ) {
|
||||
$item = [];
|
||||
$item['class'] = 'fa-' . $match[1];
|
||||
$item['prefix'] = 'far';
|
||||
$this->icons[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets brands icons.
|
||||
*/
|
||||
public function get_brands_icons() {
|
||||
$data = $this->get_data( static::BRANDS_URL );
|
||||
|
||||
if ( $data ) {
|
||||
foreach ( $data as $match ) {
|
||||
$item = [];
|
||||
$item['class'] = 'fa-' . $match[1];
|
||||
$item['prefix'] = 'fab';
|
||||
$this->icons[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
inc/vendors/cmb2-plugins/custom-fields/map/composer.json
vendored
Executable file
13
inc/vendors/cmb2-plugins/custom-fields/map/composer.json
vendored
Executable file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "mustardbees/cmb_field_map",
|
||||
"description": "Google Maps field type for Custom Metaboxes and Fields for WordPress",
|
||||
"type": "wordpress-plugin",
|
||||
"keywords": ["wordpress", "plugin"],
|
||||
"homepage": "https://github.com/mustardBees/cmb_field_map/",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Phil Wylie",
|
||||
"homepage": "http://www.philwylie.co.uk/"
|
||||
}
|
||||
]
|
||||
}
|
||||
17
inc/vendors/cmb2-plugins/custom-fields/map/css/style.css
vendored
Executable file
17
inc/vendors/cmb2-plugins/custom-fields/map/css/style.css
vendored
Executable file
@@ -0,0 +1,17 @@
|
||||
.opal-map {
|
||||
min-height: 300px;
|
||||
width: 100%;
|
||||
margin: 5px 1px 1px;
|
||||
border: solid 1px #DDD;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.opal-map img {
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.opalestate-map-wrap {
|
||||
display: block;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
padding: 12px;
|
||||
}
|
||||
109
inc/vendors/cmb2-plugins/custom-fields/map/js/script.js
vendored
Executable file
109
inc/vendors/cmb2-plugins/custom-fields/map/js/script.js
vendored
Executable file
@@ -0,0 +1,109 @@
|
||||
(function( $ ) {
|
||||
'use strict';
|
||||
|
||||
var maps = [];
|
||||
|
||||
$( '.cmb-type-opal-map' ).each( function() {
|
||||
initializeMap( $( this ) );
|
||||
});
|
||||
|
||||
function initializeMap( mapInstance ) {
|
||||
var searchInput = mapInstance.find( '.opal-map-search' );
|
||||
var mapCanvas = mapInstance.find( '.opal-map' );
|
||||
var latitude = mapInstance.find( '.opal-map-latitude' );
|
||||
var longitude = mapInstance.find( '.opal-map-longitude' );
|
||||
var latLng = new google.maps.LatLng( 54.800685, -4.130859 );
|
||||
var zoom = 5;
|
||||
|
||||
// If we have saved values, let's set the position and zoom level
|
||||
if ( latitude.val().length > 0 && longitude.val().length > 0 ) {
|
||||
latLng = new google.maps.LatLng( latitude.val(), longitude.val() );
|
||||
zoom = 17;
|
||||
}
|
||||
|
||||
// Map
|
||||
var mapOptions = {
|
||||
center: latLng,
|
||||
zoom: zoom
|
||||
};
|
||||
var map = new google.maps.Map( mapCanvas[0], mapOptions );
|
||||
|
||||
latitude.on('change', function() {
|
||||
map.setCenter( new google.maps.LatLng( latitude.val(), longitude.val() ) );
|
||||
});
|
||||
|
||||
longitude.on('change', function() {
|
||||
map.setCenter( new google.maps.LatLng( latitude.val(), longitude.val() ) );
|
||||
});
|
||||
|
||||
// Marker
|
||||
var markerOptions = {
|
||||
map: map,
|
||||
draggable: true,
|
||||
title: 'Drag to set the exact location'
|
||||
};
|
||||
var marker = new google.maps.Marker( markerOptions );
|
||||
|
||||
//if ( latitude.val().length > 0 && longitude.val().length > 0 ) {
|
||||
marker.setPosition( latLng );
|
||||
// }
|
||||
|
||||
// Search
|
||||
var autocomplete = new google.maps.places.Autocomplete( searchInput[0] );
|
||||
autocomplete.bindTo( 'bounds', map );
|
||||
|
||||
google.maps.event.addListener( autocomplete, 'place_changed', function() {
|
||||
var place = autocomplete.getPlace();
|
||||
if ( ! place.geometry ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( place.geometry.viewport ) {
|
||||
map.fitBounds( place.geometry.viewport );
|
||||
} else {
|
||||
map.setCenter( place.geometry.location );
|
||||
map.setZoom( 17 );
|
||||
}
|
||||
|
||||
marker.setPosition( place.geometry.location );
|
||||
|
||||
latitude.val( place.geometry.location.lat() );
|
||||
longitude.val( place.geometry.location.lng() );
|
||||
});
|
||||
|
||||
$( searchInput ).keypress( function( event ) {
|
||||
if ( 13 === event.keyCode ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
// Allow marker to be repositioned
|
||||
google.maps.event.addListener( marker, 'drag', function() {
|
||||
latitude.val( marker.getPosition().lat() );
|
||||
longitude.val( marker.getPosition().lng() );
|
||||
});
|
||||
|
||||
maps.push( map );
|
||||
}
|
||||
|
||||
// Resize map when meta box is opened
|
||||
if ( typeof postboxes !== 'undefined' ) {
|
||||
postboxes.pbshow = function () {
|
||||
var arrayLength = maps.length;
|
||||
for (var i = 0; i < arrayLength; i++) {
|
||||
var mapCenter = maps[i].getCenter();
|
||||
google.maps.event.trigger( maps[i], 'resize' );
|
||||
maps[i].setCenter( mapCenter );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// When a new row is added, reinitialize Google Maps
|
||||
$( '.cmb-repeatable-group' ).on( 'cmb2_add_row', function( event, newRow ) {
|
||||
var groupWrap = $( newRow ).closest( '.cmb-repeatable-group' );
|
||||
groupWrap.find( '.cmb-type-opal-map' ).each( function() {
|
||||
initializeMap( $( this ) );
|
||||
});
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
116
inc/vendors/cmb2-plugins/custom-fields/map/map.php
vendored
Executable file
116
inc/vendors/cmb2-plugins/custom-fields/map/map.php
vendored
Executable file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* $Desc$
|
||||
*
|
||||
* @version $Id$
|
||||
* @package opalestate
|
||||
* @author Opal Team <info@wpopal.com >
|
||||
* @copyright Copyright (C) 2019 wpopal.com. All Rights Reserved.
|
||||
* @license GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* @website http://www.wpopal.com
|
||||
* @support http://www.wpopal.com/support/forum.html
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
class Opalestate_Field_Map {
|
||||
|
||||
/**
|
||||
* Current version number
|
||||
*/
|
||||
const VERSION = '1.0.0';
|
||||
|
||||
/**
|
||||
* Initialize the plugin by hooking into CMB2
|
||||
*/
|
||||
public function __construct() {
|
||||
add_filter( 'cmb2_render_opal_map', array( $this, 'render_map' ), 10, 5 );
|
||||
add_filter( 'cmb2_sanitize_opal_map', array( $this, 'sanitize_map' ), 10, 4 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render field
|
||||
*/
|
||||
public function render_map( $field, $field_escaped_value, $field_object_id, $field_object_type, $field_type_object ) {
|
||||
$this->setup_admin_scripts();
|
||||
$address = (isset( $field_escaped_value['address'] ) ? $field_escaped_value['address'] : '');
|
||||
|
||||
echo '<div class="'.apply_filters('opalestate_row_container_class', 'row opal-row').'">
|
||||
<div class="opalestate-map-wrap col-sm-6">
|
||||
<div class="opal-map"></div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label>'.__( 'Map Address', 'opalestate-pro' ).'</label>
|
||||
<input type="text" class="large-text regular-text opal-map-search form-control" id="' . $field->args( 'id' ) . '"
|
||||
name="'.$field->args( '_name' ).'[address]" value="'.$address.'"/>';
|
||||
echo '</div>';
|
||||
|
||||
$field_type_object->_desc( true, true );
|
||||
|
||||
echo ' <div class="form-group">';
|
||||
echo '<label>'.__( 'Latitude', 'opalestate-pro' ).'</label>';
|
||||
echo $field_type_object->input( array(
|
||||
'type' => 'text',
|
||||
'name' => $field->args( '_name' ) . '[latitude]',
|
||||
'value' => isset( $field_escaped_value['latitude'] ) ? $field_escaped_value['latitude'] : '',
|
||||
'class' => 'opal-map-latitude form-control',
|
||||
'desc' => '',
|
||||
) );
|
||||
echo '</div>';
|
||||
echo ' <div class="form-group">';
|
||||
echo '<label>'.__( 'Longitude', 'opalestate-pro' ).'</label>';
|
||||
echo $field_type_object->input( array(
|
||||
'type' => 'text',
|
||||
'name' => $field->args( '_name' ) . '[longitude]',
|
||||
'value' => isset( $field_escaped_value['longitude'] ) ? $field_escaped_value['longitude'] : '',
|
||||
'class' => 'opal-map-longitude form-control',
|
||||
'desc' => '',
|
||||
) );
|
||||
echo '</div>';
|
||||
echo '<p class="opal-map-desc">' . __( 'You need to register <a href="https://developers.google.com/maps/documentation/javascript/get-api-key" target="_blank">Google API Key</a>, then put the key in plugin setting.',
|
||||
'opalestate-pro' ) . '</p>';
|
||||
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally save the latitude/longitude values into two custom fields
|
||||
*/
|
||||
public function sanitize_map( $override_value, $value, $object_id, $field_args ) {
|
||||
if ( isset( $field_args['split_values'] ) && $field_args['split_values'] ) {
|
||||
if ( ! empty( $value['latitude'] ) ) {
|
||||
update_post_meta( $object_id, $field_args['id'] . '_latitude', $value['latitude'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $value['longitude'] ) ) {
|
||||
update_post_meta( $object_id, $field_args['id'] . '_longitude', $value['longitude'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $value['address'] ) ) {
|
||||
update_post_meta( $object_id, $field_args['id'] . '_address', $value['address'] );
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue scripts and styles
|
||||
*/
|
||||
public function setup_admin_scripts() {
|
||||
$api = opalestate_get_map_api_uri();
|
||||
|
||||
wp_enqueue_script("opalestate-google-maps", $api, null, "0.0.1", false);
|
||||
|
||||
wp_enqueue_script( 'opalestate-google-maps-js', plugins_url( 'js/script.js', __FILE__ ), array( ) );
|
||||
wp_enqueue_style( 'opalestate-google-maps', plugins_url( 'css/style.css', __FILE__ ), array() );
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
new Opalestate_Field_Map();
|
||||
39
inc/vendors/cmb2-plugins/custom-fields/map/readme.md
vendored
Executable file
39
inc/vendors/cmb2-plugins/custom-fields/map/readme.md
vendored
Executable file
@@ -0,0 +1,39 @@
|
||||
# CMB2 Field Type: Google Maps
|
||||
|
||||
## Description
|
||||
|
||||
Google Maps field type for [CMB2](https://github.com/WebDevStudios/CMB2).
|
||||
|
||||
The `pw_map` field stores the latitude/longitude values which you can then use to display a map in your theme.
|
||||
|
||||
## Installation
|
||||
|
||||
You can install this field type as you would a WordPress plugin:
|
||||
|
||||
1. Download the plugin
|
||||
2. Place the plugin folder in your `/wp-content/plugins/` directory
|
||||
3. Activate the plugin in the Plugin dashboard
|
||||
|
||||
## Usage
|
||||
|
||||
### `pw_map`
|
||||
|
||||
Save a location on a map. Example:
|
||||
|
||||
```php
|
||||
array(
|
||||
'name' => 'Location',
|
||||
'desc' => 'Drag the marker to set the exact location',
|
||||
'id' => $prefix . 'location',
|
||||
'type' => 'pw_map',
|
||||
// 'split_values' => true, // Save latitude and longitude as two separate fields
|
||||
),
|
||||
```
|
||||
|
||||
#### Extra Parameters:
|
||||
|
||||
* `split_values` Save the latitude/longitude values into two custom fields, they will be stored as `$id . '_latitude'` and `$id . '_longitude'`.
|
||||
|
||||
## Screenshot
|
||||
|
||||

|
||||
BIN
inc/vendors/cmb2-plugins/custom-fields/map/screenshot-1.png
vendored
Executable file
BIN
inc/vendors/cmb2-plugins/custom-fields/map/screenshot-1.png
vendored
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 87 KiB |
49
inc/vendors/cmb2-plugins/custom-fields/user/assets/script.js
vendored
Executable file
49
inc/vendors/cmb2-plugins/custom-fields/user/assets/script.js
vendored
Executable file
@@ -0,0 +1,49 @@
|
||||
(function( $ ) {
|
||||
'use strict';
|
||||
$( document ).ready( function() {
|
||||
|
||||
|
||||
$( ".adduser-team" ).delegate( ".remove-user", "click", function() {
|
||||
if( confirm( $(this).data('alert') ) ){
|
||||
$(this).parents( '.user-team' ).remove();
|
||||
}
|
||||
});
|
||||
|
||||
$( '.opalestate-add-user-field' ).each( function() {
|
||||
var $this = $(this);
|
||||
$('.button', this).click( function () {
|
||||
|
||||
|
||||
var user_search = $( '.opalestate-adduser-search', $(this).parent().parent() ).val();
|
||||
|
||||
|
||||
$('.opalestate-ajax').show();
|
||||
|
||||
var data = {
|
||||
action: 'opalestate_ajax_search_username',
|
||||
user_name: user_search,
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: data,
|
||||
dataType: "json",
|
||||
url: ajaxurl,
|
||||
success: function ( response ) {
|
||||
if( response.status == true ){
|
||||
var template = wp.template( 'adduser-team-template' );
|
||||
$('.adduser-team', $this ).append( template( response.user ) );
|
||||
}else {
|
||||
alert( response.message );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
||||
})( jQuery );
|
||||
29
inc/vendors/cmb2-plugins/custom-fields/user/assets/style.css
vendored
Executable file
29
inc/vendors/cmb2-plugins/custom-fields/user/assets/style.css
vendored
Executable file
@@ -0,0 +1,29 @@
|
||||
.adduser-team{
|
||||
width: 80%;
|
||||
}
|
||||
.user-team{
|
||||
padding: 12px 10px;
|
||||
display: block;
|
||||
border-bottom: solid 1px #f3f3f3
|
||||
}
|
||||
.user-team > div{
|
||||
display: inline-block;
|
||||
width: 33%;
|
||||
|
||||
}
|
||||
|
||||
.user-team > div img{
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border: solid 3px #CCC;
|
||||
border-radius: 50%;
|
||||
float: left;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.remove-user {
|
||||
cursor: pointer;
|
||||
}
|
||||
.remove-user:hover {
|
||||
color: red;
|
||||
}
|
||||
95
inc/vendors/cmb2-plugins/custom-fields/user/user.php
vendored
Executable file
95
inc/vendors/cmb2-plugins/custom-fields/user/user.php
vendored
Executable file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* Opalestate_Field_Adduser
|
||||
*
|
||||
* @package opalestate
|
||||
* @author Opal Team <info@wpopal.com >
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Opalestate_Field_Adduser {
|
||||
|
||||
/**
|
||||
* Current version number
|
||||
*/
|
||||
const VERSION = '1.0.0';
|
||||
|
||||
/**
|
||||
* Initialize the plugin by hooking into CMB2
|
||||
*/
|
||||
public static function init() {
|
||||
add_filter( 'cmb2_render_adduser', [ __CLASS__, 'render_map' ], 10, 5 );
|
||||
add_filter( 'cmb2_sanitize_adduser', [ __CLASS__, 'sanitize_map' ], 10, 4 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render field
|
||||
*/
|
||||
public static function render_map( $field, $field_escaped_value, $field_object_id, $field_object_type, $field_type_object ) {
|
||||
self::setup_admin_scripts();
|
||||
|
||||
$users = $field->value;
|
||||
|
||||
echo '<div class="opalestate-add-user-field ' . apply_filters( 'opalestate_row_container_class', 'row opal-row' ) . '"> '; ?>
|
||||
<div class="col-lg-12">
|
||||
<h5 class=""><?php esc_html_e( 'As an author, you can add other users to your agency.', 'opalestate-pro' ); ?></h5>
|
||||
<div>
|
||||
<p><?php esc_html_e( 'Add someone to your agency, please enter extractly username in below input:', 'opalestate-pro' ); ?></p>
|
||||
|
||||
<div class="<?php echo apply_filters( 'opalestate_row_container_class', 'row opal-row' ); ?>">
|
||||
|
||||
<div class="col-lg-8"><input class="regular-text opalestate-adduser-search" name="opalestate_adduser_search" id="opalestate_adduser_search" value="" type="text"></div>
|
||||
<div class="col-lg-4"><input name="search" class="button button-primary button-large pull-left" id="publish" value="<?php esc_html_e( 'add', 'opalestate-pro' ); ?>" type="button">
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear clearfix"></div>
|
||||
</div>
|
||||
<div class="adduser-team">
|
||||
<?php if ( $users ): $users = array_unique( $users ); ?>
|
||||
<?php foreach ( $users as $user_id ): $user = get_user_by( 'id', $user_id );
|
||||
$user = $user->data ?>
|
||||
<div class="user-team">
|
||||
<input type="hidden" name="<?php echo $field->args( '_name' ) ?>[]" value="<?php echo $user_id; ?>">
|
||||
<div>
|
||||
<img src="<?php echo get_avatar_url( $user_id ); ?>">
|
||||
<a href="<?php get_author_posts_url( $user_id ); ?>" target="_blank"> <?php echo $user->user_login; ?> </a></div>
|
||||
<div><span class="remove-user" data-alert="<?php esc_html_e( 'Are you sure to delete this', 'opalestate-pro' ); ?>"><?php esc_html_e( 'Remove',
|
||||
'opalestate-pro' ); ?></span></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="tmpl-adduser-team-template">
|
||||
<div class="user-team">
|
||||
<input type="hidden" name="<?php echo $field->args( '_name' ) ?>[]" value="{{{data.ID}}}">
|
||||
<div><img src="{{{data.avatar}}}"> <a href="{{{data.author_link}}}" target="_blank"> {{{data.user_login}}} </a></div>
|
||||
<div><span class="remove-user" data-alert="<?php esc_html_e( 'Are you sure to delete this', 'opalestate-pro' ); ?>"><?php esc_html_e( 'Remove', 'opalestate-pro' ); ?></span></div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<?php echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally save the latitude/longitude values into two custom fields
|
||||
*/
|
||||
public static function sanitize_map( $override_value, $value, $object_id, $field_args ) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue scripts and styles
|
||||
*/
|
||||
public static function setup_admin_scripts() {
|
||||
wp_enqueue_script( 'opalestate-adduser', plugins_url( 'assets/script.js', __FILE__ ), [], self::VERSION );
|
||||
wp_enqueue_style( 'opalestate-adduser', plugins_url( 'assets/style.css', __FILE__ ), [], self::VERSION );
|
||||
}
|
||||
}
|
||||
|
||||
Opalestate_Field_Adduser::init();
|
||||
Reference in New Issue
Block a user