Plugin Directory

Changeset 1460203


Ignore:
Timestamp:
07/25/2016 12:37:20 PM (10 years ago)
Author:
Alghost
Message:

Update 1.2v

Location:
wp-naver-map-in-post/trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • wp-naver-map-in-post/trunk/alghost_navermap.php

    r1197313 r1460203  
    3838    curl_setopt($ch, CURLOPT_URL, $url);
    3939    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);       
     40
     41    $client_id= esc_attr(get_option('alghost-navermap-client-id'));
     42    $client_id= trim($client_id);
     43    $client_secret= esc_attr(get_option('alghost-navermap-client-secret'));
     44    $client_secret= trim($client_secret);
     45
     46    $headers = array();
     47    $headers[] = "X-Naver-Client-Id: ".$client_id;
     48    $headers[] = "X-Naver-Client-Secret: ".$client_secret;
     49    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     50
    4051    $data = curl_exec($ch);
    4152    curl_close($ch);
     
    5061    update_post_meta(0, 'keyword', $keyword);
    5162
    52     $api_key = esc_attr(get_option('alghost-navermap-search-key'));
    53     $api_key = trim($api_key);
    54 
    55     $url = "http://openapi.naver.com/search?key=".$api_key."&query=".$keyword."&target=local&start=1&display=10";
     63    $url = "https://openapi.naver.com/v1/search/local.xml?query=".urlencode($keyword)."&start=1&display=10&sort=random";
    5664
    5765    $response = alghost_file_get_contents_curl($url);
    5866    $object = simplexml_load_string($response);
    59 
    6067    $channel = $object->channel;
    6168    $key=0;
     
    93100                "mapy" => "0",
    94101                "title" => "None"
    95                 ), $atts);
    96     $all_script = file_get_contents(plugin_dir_path(__FILE__).".SCRIPT_LAYOUT");
    97     $api_key = esc_attr(get_option('alghost-navermap-map-key'));
    98     $api_key = trim($api_key);
    99     $all_script = "<script type=\"text/javascript\" src=\"http://openapi.map.naver.com/openapi/naverMap.naver?ver=2.0&key=".$api_key."\"></script>";
     102            ), $atts);
     103
     104    $client_id= esc_attr(get_option('alghost-navermap-client-id'));
     105    $client_id= trim($client_id);
     106    $all_script = "<script type=\"text/javascript\" src=\"http://openapi.map.naver.com/openapi/v3/maps.js?clientId=".$client_id."\"></script>";
    100107    $all_script .= "<script type=\"text/javascript\" src=\"".plugins_url()."/wp-naver-map-in-post/conv_loc/lib/geocent.js\"></script>";
    101108    $all_script .= "<script type=\"text/javascript\" src=\"".plugins_url()."/wp-naver-map-in-post/conv_loc/lib/tmerc.js\"></script>";
     
    111118    $all_script .= "var convPtr = new PT(".$location['mapx'].",".$location['mapy'].");";
    112119    $all_script .= "cs_transform(TM128, WGS84, convPtr);";
    113     $all_script .= "var objCenterPtr = new nhn.api.map.LatLng(convPtr.y, convPtr.x);";
    114     $all_script .= "var defaultLevel = 11;";
    115     $all_script .= "var objMap = new nhn.api.map.Map(document.getElementById(\"alghostMap\"), {";
    116     $all_script .= "        point: objCenterPtr,";
    117     $all_script .= "       zoom: defaultLevel,";
    118     $all_script .= "       enableWheelZoom: true,";
    119     $all_script .= "       enableDragPan: true,";
    120     $all_script .= "       enableDblClickZoom: false,";
    121     $all_script .= "       mapMode: 0,";
    122     $all_script .= "       activateTrafficMap: false,";
    123     $all_script .= "       activateBicycleMap: false,";
    124     $all_script .= "       minMaxLevel: [1,14],";
    125     $all_script .= "       size: new nhn.api.map.Size(300, 300)";
     120    $all_script .= "var HOME_PATH = window.HOME_PATH || '.';";
     121    $all_script .= "var objCenterPtr = new naver.maps.LatLng(convPtr.y, convPtr.x);";
     122    $all_script .= "var objMap = new naver.maps.Map(document.getElementById(\"alghostMap\"), {";
     123    $all_script .= "       center: objCenterPtr,";
     124    $all_script .= "       size: new naver.maps.Size(300, 300)";
    126125    $all_script .= "   });";
    127     $all_script .= "var infoWindow = new nhn.api.map.InfoWindow();";
    128     $all_script .= "   objMap.addOverlay(infoWindow);";
    129     $all_script .= "   var objMapSlider = new nhn.api.map.ZoomControl();";
    130     $all_script .= "   objMap.addControl(objMapSlider);";
    131     $all_script .= "   objMapSlider.setPosition({";
    132     $all_script .= "       top: 10,";
    133     $all_script .= "       left: 10";
     126    $all_script .= "var marker = new naver.maps.Marker({";
     127    $all_script .= "       position: objCenterPtr,";
     128    $all_script .= "       map: objMap,";
     129    $all_script .= "       icon: {url: HOME_PATH + '/icon/pin_spot2.png',";
     130    $all_script .= "           size: new naver.maps.Size(22,35),";
     131    $all_script .= "           origin: new naver.maps.Point(0,0),";
     132    $all_script .= "           anchor: new naver.maps.Point(11,35)}";
    134133    $all_script .= "   });";
    135     $all_script .= "   var objIconSize = new nhn.api.map.Size(28, 37);";
    136     $all_script .= "   var objIconOffset = new nhn.api.map.Size(14,37);";
    137     $all_script .= "   var objMarkerIcon = new nhn.api.map.Icon(\"http://static.naver.com/maps2/icons/pin_spot2.png\", objIconSize, objIconOffset);";
    138     $all_script .= "   var objMarker = new nhn.api.map.Marker(objMarkerIcon, {title: \"".strip_tags($location['title'])."\"});";
    139     $all_script .= "   objMarker.setPoint(objCenterPtr);";
    140     $all_script .= "   objMap.addOverlay(objMarker);";
    141     $all_script .= "   var objMarkerLabel = new nhn.api.map.MarkerLabel();";
    142     $all_script .= "   objMap.addOverlay(objMarkerLabel);";
    143     $all_script .= "   objMarkerLabel.setVisible(true, objMarker);";
     134    $all_script .= "var contentString = [";
     135    $all_script .= "  '<div class=\"iw_inner\">',";
     136    $all_script .= "  '<b align=\"center\">".strip_tags($location['title'])."</b>',";
     137    $all_script .= "  '</div>'].join('');";
     138    $all_script .= "var infowindow = new naver.maps.InfoWindow({content: contentString, maxWidth: 200});";
     139    $all_script .= "naver.maps.Event.addListener(marker, \"click\", function(e) {";
     140    $all_script .= "   if (infowindow.getMap()){ infowindow.close(); }";
     141    $all_script .= "   else { infowindow.open(objMap, marker); }";
     142    $all_script .= "});";
     143    $all_script .= "infowindow.open(objMap, marker);";
    144144    $all_script .= "   var mobile_url = \"navermaps://?menu=location&lat=\"+convPtr.y+\"&lng=\"+convPtr.x+\"&title=".strip_tags($location['title'])."&mLevel=11\";";
    145145    $all_script .= "   document.getElementById(\"alghostMobileLink\").href = mobile_url;";
     
    155155}
    156156function alghost_navermap_admin_form_setup(){
    157     register_setting('alghost-navermap-keys', 'alghost-navermap-search-key');
    158     register_setting('alghost-navermap-keys', 'alghost-navermap-map-key');
     157    register_setting('alghost-navermap-keys', 'alghost-navermap-client-id');
     158    register_setting('alghost-navermap-keys', 'alghost-navermap-client-secret');
    159159}
    160160
     
    168168    echo '<table class="form-table">';
    169169    echo '  <tr valign="top">';
    170     echo '      <th scope="row">검색 API</th>';
    171     echo '      <td><input type="text" name="alghost-navermap-search-key" value="'.esc_attr(get_option('alghost-navermap-search-key')).'" style="max-width:70%;"/></td>';
     170    echo '      <th scope="row">Client ID</th>';
     171    echo '      <td><input type="text" name="alghost-navermap-client-id" value="'.esc_attr(get_option('alghost-navermap-client-id')).'" style="max-width:70%;"/></td>';
    172172    echo '  </tr>';
    173173    echo '  <tr valign="top">';
    174     echo '      <th scope="row">지도 API</th>';
    175     echo '      <td><input type="text" name="alghost-navermap-map-key" value="'.esc_attr(get_option('alghost-navermap-map-key')).'" style="max-width:70%;" /></td>';
     174    echo '      <th scope="row">Client Secret</th>';
     175    echo '      <td><input type="text" name="alghost-navermap-client-secret" value="'.esc_attr(get_option('alghost-navermap-client-secret')).'" style="max-width:70%;" /></td>';
    176176    echo '  </tr>';
    177177    echo '</table>';
  • wp-naver-map-in-post/trunk/readme.txt

    r1289043 r1460203  
    44Tags: naver,map,useful,
    55Requires at least: 3.0.1
    6 Tested up to: 4.4
     6Tested up to: 4.5
    77Stable tag: 4.3
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    10 Version 1.1
     10Version 1.2
    1111
    12 검색  API/지도 API를 이용하여 네이버 지도를 손쉽게 추가할 수 있도록 도와주는 플러그인입니다.
     12검색  PI/지도 API를 이용하여 네이버 지도를 손쉽게 추가할 수 있도록 도와주는 플러그인입니다.
    1313
    1414== Description ==
     15
     16!!!!중요!!!!!
     17
     18* 1.2 업데이트 이후로 기존에 본 플러그인을 사용한 글은 재발행 하셔야 지도가 제대로 보일 수 있습니다.
     19* 지도 표기 방법이 변경되어 글만 재저장(재발행) 하시면 정상 동작합니다.
     20* 1.2 버전으로 업데이트 하시면 기존에 API KEY는 사용하지 않으니 CLIENT-ID, CLIENT-SECRET을 미리 준비하신 후 업데이트 하시길 바랍니다.
    1521
    1622이 플러그인은 포스트에 네이버 지도를 손쉽게 추가할 수 있도록 도와주는 플러그인입니다.
     
    3844= API 키는 어디서 얻죠? =
    3945
    40 네이버 OpenAPI ( http://developer.naver.com/wiki/pages/OpenAPI )에 방문하셔서 검색 API와 지도 API를 발급 받으시면 됩니다.
     46네이버 OpenAPI ( http://developer.naver.com/)에 방문하셔서 Client-ID, Client-Secret를 발급 받으시면 됩니다.
     47발급 받으실 때에는 지도 API와 검색 API을 활성화 하셔야 합니다.
    4148
    4249== Screenshots ==
     
    6269== Changelog ==
    6370
     71= 1.2 =
     72* 네이버 API 활용 방법이 변경됨에 따라 기존 KEY 사용 방식이 아닌 CLIENT-ID, CLIENT-SECRET 방식으로 변경
     73
    6474= 1.1 =
    6575* 보안상의 이슈로 file_get_contents 사용불가인 상황을 위해 함수변경(CURL 이용)
     
    7080== Upgrade Notice ==
    7181
     82= 1.2 =
     83* 네이버 API 활용 방법이 변경됨에 따라 기존 KEY 사용 방식이 아닌 CLIENT-ID, CLIENT-SECRET 방식으로 변경
     84
    7285= 1.1 =
    7386* 보안상의 이슈로 file_get_contents 사용불가인 상황을 위해 함수변경(CURL 이용)
Note: See TracChangeset for help on using the changeset viewer.