. */ defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); define('DEVVN_IHOTSPOT_VER', '1.2.1'); define('DEVVN_IHOTSPOT_DEV_MOD', false); define('DEVVN_IHOTSPOT_POINT_DEFAULT',serialize(array( 'countPoint' => '', 'content' => '', 'left' => '', 'top' => '', 'linkpins' => '', 'link_target' => '', 'placement' => '', 'pins_id' => '', 'pins_class' => '' ))); define('DEVVN_IHOTSPOT_PINS_DEFAULT',serialize(array( 'countPoint' => '', 'imgPoint' => '', 'top' => '', 'left' => '' ))); //include include 'admin/inc/cpt-ihotspot.php'; include 'admin/inc/add_shortcode_devvn_ihotspot.php'; include 'admin/inc/metabox-donate.php'; load_textdomain('devvn-image-hotspot', dirname(__FILE__) . '/languages/devvn-image-hotspot-' . get_locale() . '.mo'); load_plugin_textdomain( 'devvn-image-hotspot', false, plugin_basename( dirname( __FILE__ ) ) . '/i18n/languages' ); //metabox function devvn_ihotspot_meta_box() { //post type $screens = array( 'points_image' ); foreach ( $screens as $screen ) { add_meta_box( 'devvn-ihotspot-metabox', __( 'Image Hotspot', 'devvn-image-hotspot' ), 'devvn_ihotspot_meta_box_callback', $screen, 'normal', 'high' ); add_meta_box( 'devvn-ihotspot-shortcode', __( 'Image Hotspot Shortcode', 'devvn-image-hotspot' ), 'devvn_ihotspot_shortcode_callback', $screen, 'side', 'high' ); } } add_action( 'add_meta_boxes', 'devvn_ihotspot_meta_box' ); function devvn_wp_default_editor(){ return "tinymce"; } function devvn_ihotspot_meta_box_callback( $post ) { add_filter( 'wp_default_editor', 'devvn_wp_default_editor' ); //add none field wp_nonce_field( 'maps_points_save_meta_box_data', 'maps_points_meta_box_nonce' ); $data_post = get_post_meta($post->ID, 'hotspot_content', true); if(!$data_post){ $data_post = maybe_unserialize( $post->post_content ); } $maps_images = (isset($data_post['maps_images']))?$data_post['maps_images']:''; $data_points = (isset($data_post['data_points']))?$data_post['data_points']:''; $pins_image = (isset($data_post['pins_image']))?$data_post['pins_image']:''; $pins_image_hover = (isset($data_post['pins_image_hover']))?$data_post['pins_image_hover']:''; $pins_more_option = (isset($data_post['pins_more_option']))?$data_post['pins_more_option']:array(); $pins_more_option = wp_parse_args($pins_more_option,array( 'position' => 'center_center', 'custom_top' => 0, 'custom_left' => 0, 'custom_hover_top' => 0, 'custom_hover_left' => 0, 'pins_animation' => 'none' )); ?>
x
x

$stt, 'imgPoint' => $pins_image, 'top' => $point['top'], 'left' => $point['left'], 'linkpins' => isset($point['linkpins'])?esc_url($point['linkpins']):'', 'link_target' => isset($point['link_target'])?esc_attr($point['link_target']):'_self', 'pins_image_custom' => isset($point['pins_image_custom'])?$point['pins_image_custom']:'', 'pins_image_hover_custom' => isset($point['pins_image_hover_custom'])?$point['pins_image_hover_custom']:'', 'placement' => isset($point['placement'])?$point['placement']:'', 'pins_id' => isset($point['pins_id'])?$point['pins_id']:'', 'pins_class' => isset($point['pins_class'])?$point['pins_class']:'' ); echo devvn_ihotspot_get_pins_default($data_input);?>
$stt, 'content' => $point['content'], 'left' => $point['left'], 'top' => $point['top'], 'linkpins' => isset($point['linkpins'])?esc_url($point['linkpins']):'', 'link_target' => isset($point['link_target'])?esc_attr($point['link_target']):'_self', 'pins_image_custom' => isset($point['pins_image_custom'])?$point['pins_image_custom']:'', 'pins_image_hover_custom' => isset($point['pins_image_hover_custom'])?$point['pins_image_hover_custom']:'', 'placement' => isset($point['placement'])?$point['placement']:'', 'pins_id' => isset($point['pins_id'])?$point['pins_id']:'', 'pins_class' => isset($point['pins_class'])?$point['pins_class']:'' ); echo devvn_ihotspot_get_input_point_default($data_input);?>
ID) == "publish"): ?> $choose_type, 'custom_top' => $custom_top, 'custom_left' => $custom_left, 'custom_hover_top' => $custom_hover_top, 'custom_hover_left' => $custom_hover_left, 'pins_animation' => $pins_animation ); if(is_array($pointdata)){ $dataPoints = devvn_ihotspot_convert_array_data($pointdata); } $data_post = array( 'maps_images' => $my_data, 'pins_image' => sanitize_text_field( (isset($_POST['pins_image']))?$_POST['pins_image']:'' ), 'pins_image_hover' => sanitize_text_field(isset($_POST['pins_image_hover'])?$_POST['pins_image_hover']:''), 'pins_more_option' => $pins_more_option, 'data_points' => $dataPoints ); update_post_meta($post_id, 'hotspot_content', $data_post); /*remove_action( 'save_post', 'devvn_ihotspot_save_meta_box_data' ); wp_update_post(array( 'ID' => $post_id, 'post_content' => maybe_serialize(wp_unslash($data_post)), 'post_type' => 'points_image' )); add_action( 'save_post', 'devvn_ihotspot_save_meta_box_data' );*/ } add_action( 'save_post', 'devvn_ihotspot_save_meta_box_data' ); function devvn_ihotspot_editor_styles(){ global $wp_version; $baseurl = includes_url( 'js/tinymce' ); $suffix = SCRIPT_DEBUG ? '' : '.min'; $version = 'ver=' . $wp_version; $dashicons = includes_url( "css/dashicons$suffix.css?$version" ); // WordPress default stylesheet and dashicons $mce_css = array( $dashicons, $baseurl . '/skins/wordpress/wp-content.css?' . $version ); $editor_styles = get_editor_stylesheets(); if ( ! empty( $editor_styles ) ) { foreach ( $editor_styles as $style ) { $mce_css[] = $style; } } $mce_css = trim( apply_filters( 'devvn_ihotspot_mce_css', implode( ',', $mce_css ) ), ' ,' ); if ( ! empty($mce_css) ) return $mce_css; else return false; } /*Add admin script*/ function devvn_ihotspot_admin_script() { global $typenow; if( $typenow == 'points_image' ) { wp_enqueue_media(); wp_enqueue_script( 'jquery-ui-core' ); wp_enqueue_script('jquery-ui-droppable'); /*wp_register_script( 'bootstrap-js', plugin_dir_url( __FILE__ ) . 'admin/js/bootstrap.min.js', array( 'jquery' ), DEVVN_IHOTSPOT_VER, true ); wp_enqueue_script( 'bootstrap-js' );*/ wp_register_script( 'maps_points', plugin_dir_url( __FILE__ ) . 'admin/js/maps_points.js', array( 'jquery' ), DEVVN_IHOTSPOT_VER, true ); wp_localize_script( 'maps_points', 'meta_image', array( 'title' => __( 'Select image', 'devvn-image-hotspot' ), 'button' => __( 'Select', 'devvn-image-hotspot' ), 'site_url' => home_url(), 'ajaxurl' => admin_url('admin-ajax.php'), 'editor_style' => devvn_ihotspot_editor_styles() ) ); wp_enqueue_script( 'maps_points' ); } } add_action( 'admin_enqueue_scripts','devvn_ihotspot_admin_script' ); /*Add admin style*/ function devvn_ihotspot_admin_styles(){ global $typenow; if( $typenow == 'points_image' ) { wp_enqueue_style( 'bootstrap', plugin_dir_url( __FILE__ ) . 'admin/css/bootstrap.css', array(), DEVVN_IHOTSPOT_VER, 'all' ); wp_enqueue_style( 'maps_points', plugin_dir_url( __FILE__ ) . 'admin/css/maps_points_style.css', array(),DEVVN_IHOTSPOT_VER, 'all' ); } } add_action( 'admin_print_styles', 'devvn_ihotspot_admin_styles' ); /*Add frontend scripts*/ function devvn_ihotspot_frontend_scripts() { if(DEVVN_IHOTSPOT_DEV_MOD){ wp_enqueue_style('powertip',plugin_dir_url( __FILE__ ) . 'frontend/css/jquery.powertip.min.css',array(),'1.2.0','all'); wp_enqueue_script( 'powertip', plugin_dir_url( __FILE__ ) . 'frontend/js/jquery.powertip.min.js', array('jquery'), '1.2.0', true ); wp_enqueue_style('maps-points',plugin_dir_url( __FILE__ ) . 'frontend/css/maps_points.css',array(), DEVVN_IHOTSPOT_VER,'all'); wp_enqueue_script( 'maps-points', plugin_dir_url( __FILE__ ) . 'frontend/js/maps_points.js', array('jquery'), DEVVN_IHOTSPOT_VER, true ); }else{ wp_enqueue_style('ihotspot',plugin_dir_url( __FILE__ ) . 'frontend/css/ihotspot.min.css',array(),DEVVN_IHOTSPOT_VER,'all'); wp_enqueue_script( 'ihotspot-js', plugin_dir_url( __FILE__ ) . 'frontend/js/jquery.ihotspot.min.js', array('jquery'), DEVVN_IHOTSPOT_VER, true ); } } add_action( 'wp_enqueue_scripts', 'devvn_ihotspot_frontend_scripts' ); function devvn_ihotspot_get_input_point_default($data = array()){ if(!is_array($data)) $data = array(); $data = wp_parse_args($data,unserialize(DEVVN_IHOTSPOT_POINT_DEFAULT)); $countPoint = isset($data['countPoint'])?$data['countPoint']:''; $pointContent = isset($data['content'])?$data['content']:''; $pointLeft = isset($data['left'])?$data['left']:''; $pointTop = isset($data['top'])?$data['top']:''; $pointLink = isset($data['linkpins'])?$data['linkpins']:''; $link_target = isset($data['link_target'])?$data['link_target']:'_self'; $pins_image_custom = isset($data['pins_image_custom'])?$data['pins_image_custom']:''; $pins_image_hover_custom = isset($data['pins_image_hover_custom'])?$data['pins_image_hover_custom']:''; $placement = isset($data['placement'])?$data['placement']:''; $pins_id = isset($data['pins_id'])?$data['pins_id']:''; $pins_class = isset($data['pins_class'])?$data['pins_class']:''; ob_start(); ?>
style="top:%; left:%;">
$countPoint, 'imgPoint' => $imgPin ); $data_input = array( 'countPoint' => $countPoint, ); wp_send_json_success(array( 'point_pins' => devvn_ihotspot_get_pins_default($datapin), 'point_data' => devvn_ihotspot_get_input_point_default($data_input) )); die(); } /* * by TanND * https://gist.github.com/levantoan/2a66dafad7a9a3a88468170ecce0cdab * */ function devvn_ihotspot_convert_array_data($inputArray = array()){ $aOutput = array(); $firstKey = null; foreach ($inputArray as $key => $value){ $firstKey = $key; break; } $nCountKey = count($inputArray[$firstKey]); for ($i =0; $i<$nCountKey;$i++){ $element = array(); foreach ($inputArray as $key => $value){ $element[$key] = wp_kses_post($value[$i]); } array_push($aOutput,$element); } return $aOutput; }