This commit is contained in:
Lieu Le
2019-09-27 13:57:08 +07:00
parent 251eaf8ac5
commit 1815efd104
15 changed files with 213 additions and 106 deletions

View File

@@ -346,6 +346,17 @@ class Opalestate_Settings_Property_Tab extends Opalestate_Settings_Base_Tab {
],
];
$fields[] = [
'name' => esc_html__( 'Show Virtual Tour tab', 'opalestate-pro' ),
'desc' => esc_html__( 'Show Virtual Tour tab in the single property page.', 'opalestate-pro' ),
'id' => 'enable_single_virtual_tour',
'type' => 'switch',
'options' => [
'on' => esc_html__( 'Enable', 'opalestate-pro' ),
'off' => esc_html__( 'Disable', 'opalestate-pro' ),
],
];
$fields[] = [
'name' => esc_html__( 'Show Map tab', 'opalestate-pro' ),
'desc' => esc_html__( 'Show Map tab in the single property page.', 'opalestate-pro' ),

View File

@@ -62,7 +62,8 @@ class OpalEstate_Enqueue {
/**
* Enqueue 3rd.
*/
wp_enqueue_style( 'fontawesome', OPALESTATE_PLUGIN_URL . 'assets/3rd/fontawesome/css/all.min.css', null, '5.11.2', false );
wp_register_style( 'fontawesome', OPALESTATE_PLUGIN_URL . 'assets/3rd/fontawesome/css/all.min.css', null, '5.11.2', false );
wp_enqueue_style( 'fontawesome' );
wp_enqueue_style( 'hint', OPALESTATE_PLUGIN_URL . 'assets/3rd/hint/hint.min.css', null, '1.3', false );
wp_enqueue_style( 'select2', OPALESTATE_PLUGIN_URL . 'assets/3rd/select2/css/select2.min.css', null, '1.3', false );
wp_enqueue_script( 'select2', OPALESTATE_PLUGIN_URL . 'assets/3rd/select2/js/select2.min.js', null, '1.3', false );

View File

@@ -140,6 +140,7 @@ class Opalestate_Property {
'attachments',
'facilities',
'video',
'virtual_tour',
'map',
'nearby',
'walkscores',
@@ -189,7 +190,7 @@ class Opalestate_Property {
$value = get_post_meta( $this->post_id, $field['id'], true );
}
$value = isset( $field['unit'] ) ? $value . ' ' . $field['unit'] : $value;
$value = isset( $field['unit'] ) && $field['unit'] ? $value . ' ' . $field['unit'] : $value;
$this->metabox_info[ $id ] = [ 'label' => $field['name'], 'value' => $value ];
}

View File

@@ -27,7 +27,11 @@ function opalestate_single_property_layout_default() {
add_action( 'opalestate_after_single_property_summary', 'opalestate_property_views_statistics', 50 );
// add_action( 'opalestate_after_single_property_summary', '', 55 );
add_action( 'opalestate_after_single_property_summary', 'opalestate_property_tags', 60 );
add_action( 'opalestate_after_single_property_summary', 'comments_template', 65 );
if ( opalestate_get_option( 'enable_property_reviews' ) ) {
add_action( 'opalestate_after_single_property_summary', 'comments_template', 65 );
}
add_action( 'opalestate_after_single_property_summary_v2', 'opalestate_property_map_v2', 5 );
////// sidebar ////////
@@ -70,7 +74,11 @@ function opalestate_single_property_layout_v2() {
// add_action( 'opalestate_after_single_property_summary', 'opalestate_property_author', 55 );
add_action( 'opalestate_after_single_property_summary', 'opalestate_property_tags', 60 );
add_action( 'opalestate_after_single_property_summary', 'comments_template', 65 );
if ( opalestate_get_option( 'enable_property_reviews' ) ) {
add_action( 'opalestate_after_single_property_summary', 'comments_template', 65 );
}
add_action( 'opalestate_after_single_property_summary_v2', 'opalestate_property_map_v2', 5 );
@@ -107,7 +115,11 @@ function opalestate_single_property_layout_v3() {
// add_action( 'opalestate_after_single_property_summary', 'opalestate_property_author', 55 );
add_action( 'opalestate_after_single_property_summary', 'opalestate_property_tags', 60 );
add_action( 'opalestate_after_single_property_summary', 'comments_template', 65 );
if ( opalestate_get_option( 'enable_property_reviews' ) ) {
add_action( 'opalestate_after_single_property_summary', 'comments_template', 65 );
}
add_action( 'opalestate_after_single_property_summary_v2', 'opalestate_property_map_v2', 5 );
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_author_v2', 5 );
@@ -129,7 +141,6 @@ function opalestate_single_property_layout_v4() {
add_action( 'opalestate_single_property_summary', 'opalestate_property_facilities', 17 );
add_action( 'opalestate_single_property_summary', 'opalestate_property_attachments', 18 );
add_action( 'opalestate_after_single_property_summary', 'opalestate_property_video', 20 );
add_action( 'opalestate_after_single_property_summary', 'opalestate_property_virtual_tour', 25 );
add_action( 'opalestate_after_single_property_summary', 'opalestate_property_map', 30 );
@@ -139,9 +150,12 @@ function opalestate_single_property_layout_v4() {
add_action( 'opalestate_after_single_property_summary', 'opalestate_property_apartments', 45 );
add_action( 'opalestate_after_single_property_summary', 'opalestate_property_views_statistics', 50 );
// add_action( 'opalestate_after_single_property_summary', 'opalestate_property_author', 55 );
add_action( 'opalestate_after_single_property_summary', 'opalestate_property_tags', 60 );
add_action( 'opalestate_after_single_property_summary', 'comments_template', 65 );
if ( opalestate_get_option( 'enable_property_reviews' ) ) {
add_action( 'opalestate_after_single_property_summary', 'comments_template', 65 );
}
add_action( 'opalestate_after_single_property_summary_v2', 'opalestate_property_map_v2', 5 );
add_action( 'opalestate_single_property_sidebar', 'opalestate_property_author_v2', 5 );
@@ -176,7 +190,11 @@ function opalestate_single_property_layout_v5() {
add_action( 'opalestate_after_single_property_summary', 'opalestate_property_views_statistics', 50 );
add_action( 'opalestate_after_single_property_summary', 'opalestate_property_tags', 60 );
add_action( 'opalestate_after_single_property_summary', 'comments_template', 65 );
if ( opalestate_get_option( 'enable_property_reviews' ) ) {
add_action( 'opalestate_after_single_property_summary', 'comments_template', 65 );
}
add_action( 'opalestate_after_single_property_summary_v2', 'opalestate_property_map_v2', 5 );
add_filter( 'opalestate_thumbnail_nav_column', function () {
@@ -229,6 +247,7 @@ function opalestate_single_property_layout( $layout ) {
break;
}
}
add_action( 'opalestate_single_property_layout', 'opalestate_single_property_layout' );
/**

View File

@@ -17,7 +17,7 @@ class Opalestate_Field_Iconpicker {
const VERSION = '1.0.0';
/**
* Initialize the plugin by hooking into CMB2
* Initialize the plugin by hooking into CMB2.
*/
public function __construct() {
add_filter( 'cmb2_render_opal_iconpicker', [ $this, 'render_iconpicker' ], 10, 5 );
@@ -28,14 +28,16 @@ class Opalestate_Field_Iconpicker {
$fontawesome_key = 'opalestate_fontawesome_data';
$icon_data = [];
if ( false === ( $fontawesome_icons = get_transient( $fontawesome_key ) ) ) {
$fontawesome = new Opalestate_Iconpicker_Fontawesome();
$fontawesome = new Opalestate_Iconpicker_Fontawesome();
$fontawesome_icons = $fontawesome->get_icons();
set_transient( $fontawesome_key, $fontawesome_icons, 24 * 7 * HOUR_IN_SECONDS );
$icon_data[] = $fontawesome_icons;
}
var_dump($icon_data);
return $icon_data;
$icon_data = array_merge( $icon_data, $fontawesome_icons );
return apply_filters( 'opalestate_get_font_data', $icon_data );
}
/**
@@ -44,44 +46,44 @@ class Opalestate_Field_Iconpicker {
public function render_iconpicker( $field, $field_escaped_value, $field_object_id, $field_object_type, $field_type_object ) {
$this->setup_admin_scripts();
$users = $field->value;
$output = sprintf(
'<select id="%1$s" class="opalestate-iconpicker" name="%2$s">',
sanitize_key( $field->args['_id'] ),
esc_attr( $field->args['_id'] )
);
var_dump($this->get_icons());
foreach ( $this->get_icons() as $icon_item ) {
$full_icon_class = $icon_item['prefix'] . ' ' . $icon_item['class'];
$output .= '<option value="' . $full_icon_class . '" ' . selected( $full_icon_class, $field->escaped_value(), false ) . '>' . esc_html( $icon_item['class'] ) . '</option>';
}
// $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;
$output .= '</select>';
echo '<p class="description">' . $field->args( 'description' ) . '</p>';
echo $output;
}
/**
* Sanitize data.
*/
public function sanitize( $override_value, $value, $object_id, $field_args ) {
return $value;
return sanitize_text_field( $value );
}
/**
* Enqueue scripts and styles.
*/
public function setup_admin_scripts() {
wp_register_style( 'fontawesome', OPALESTATE_PLUGIN_URL . 'assets/3rd/fontawesome/css/all.min.css', null, '5.11.2', false );
// 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_register_style( 'fonticonpicker-grey-theme', plugins_url( 'assets/themes/grey-theme/jquery.fonticonpicker.grey.min.css', __FILE__ ), [ 'fontawesome' ], self::VERSION );
wp_enqueue_style( 'fonticonpicker' );
wp_enqueue_style( 'fonticonpicker-grey-theme' );
wp_enqueue_script( 'fonticonpicker', plugins_url( 'assets/js/jquery.fonticonpicker.min.js', __FILE__ ), [], '2.0.0' );
wp_enqueue_script( 'opalestate-fonticonpicker', plugins_url( 'assets/js/script.js', __FILE__ ), [ 'fonticonpicker' ], self::VERSION );
}
}