Plugin Directory

Changeset 548366


Ignore:
Timestamp:
05/24/2012 03:54:42 AM (14 years ago)
Author:
claytantor
Message:

release 1.2.22 Support for Multiple Custom Post Types

Location:
welocally-places/trunk
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • welocally-places/trunk/WelocallyWPPagination.class.php

    r544331 r548366  
    272272            foreach($fields as $field){
    273273                $field = trim($field);
    274                 $content = str_replace("%$field%", $row[$field], $content);
     274               
     275               
     276                if($field == "place"){
     277                    $val = str_replace("'", "\'", $row[$field]);
     278                    $content = str_replace("%$field%", "'".$val."'", $content);
     279                } else {
     280                    $content = str_replace("%$field%", $row[$field], $content);
     281                }
     282               
     283               
    275284            }
    276285            return $content;
  • welocally-places/trunk/help/options-general-help.php

    r544571 r548366  
    1 <h1>Welocally Places Basic For Wordpress Guide</h1>
     1<h1>Welocally Places Core For Wordpress Guide</h1>
    22<a title="welocally places wordpress" href="http://wordpress.org/extend/plugins/welocally-places/">Welocally Places Plugin</a> for wordpress is intended to help site authors link real places to their content quickly, and then help their readers find those places quickly. This document is intended to help the blog owner or wordpress developer install, configure and use the plugin. It is structured by the administrative and user components associated with the plugin.
    33
  • welocally-places/trunk/menu.php

    r543560 r548366  
    11<?php
     2/**
     3 * this stuff should all be moved into the class.
     4 *
     5 */
     6
    27function wl_menu_initialise() {
     8   
     9    //jquery ui
     10    wp_register_style( 'jquery-ui-style', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/smoothness/jquery-ui.css' );
    311
    412    $main_slug = add_menu_page( 'Welocally Places Options', 'Welocally Places', 'manage_options', 'welocally-places-general', 'wl_general_options', WP_PLUGIN_URL . '/welocally-places/resources/images/welocally_places_button_color.png' );
     
    614    add_contextual_help( $main_slug, __( $main_content ) );
    715   
    8     wl_add_submenu( 'Welocally Places About', 'About', 'welocally-places-about', 'wl_support_about' );
    9     wl_add_submenu( 'Welocally Places Manager', 'Places Manager', 'welocally-places-manager', 'wl_places_manager' );
     16    $about_slug = wl_add_submenu( 'Welocally Places About', 'About', 'welocally-places-about', 'wl_support_about' );
     17    $placesmgr_slug = wl_add_submenu( 'Welocally Places Manager', 'Places Manager', 'welocally-places-manager', 'wl_places_manager' );
    1018
    1119    add_filter( 'plugin_action_links', 'wl_places_add_settings_link', 10, 2 );
     20   
     21    //hook so only the admin placemgr screen get jquery ui, conflicts were occurring
     22    add_action( 'admin_print_styles-' . $placesmgr_slug, 'wl_placesmgr_plugin_admin_styles' );
    1223       
    1324}
     25
    1426add_action( 'admin_menu','wl_menu_initialise' );
    1527add_filter( 'plugin_row_meta', 'wl_set_plugin_meta', 10, 2 );
    1628
     29function wl_placesmgr_plugin_admin_styles() {   
     30    wp_enqueue_style( 'jquery-ui-style' );     
     31}
    1732
    1833function wl_general_options() {
     
    96111    add_contextual_help( $profile_slug, __( $help_text ) );
    97112
    98     return;
     113    return $profile_slug;
    99114}
    100115
  • welocally-places/trunk/options/about.php

    r544331 r548366  
    1313<h2>Welocally Places About</h2>
    1414<div style="margin-top:20px;">
    15 <table class="form-table">
     15<table class="wl-form-table">
    1616    <tr valign="top">
    1717        <th scope="row"><?php _e( 'Version' ); ?></th>
  • welocally-places/trunk/options/options-general.php

    r544331 r548366  
    2626        $options['show_letters'] = 'off';
    2727    }
     28    $options[ 'widget_post_type' ] = $_POST[ 'welocally_widget_post_type' ];
    2829   
    2930    //welocally_show_letters
     
    7475
    7576<form method="post" action="<?php echo bloginfo( 'wpurl' ).'/wp-admin/admin.php?page=welocally-places-general' ?>">
    76 <table class="form-table" style="margin-top:20px;">
     77<table class="wl-form-table" style="margin-top:20px;">
    7778    <tr valign="top">
    7879        <th scope="row"><?php _e('General Map Options' ); ?></th>
     
    9091                <li><input type="checkbox" id="welocally_show_selection" name="welocally_show_selection" <?php if($options[ 'show_selection' ]=='on') { echo 'checked';  }  ?>>Show Selection Item List</li>
    9192                <li>Selection Item Style<br /><input style="width:400px" type="text" id="welocally_widget_selection_style" name="welocally_widget_selection_style" value="<?php echo $options[ 'widget_selection_style' ];?>"></li>
     93                <li>Post Types (comma separated) <br /><input style="width:400px" type="text" id="welocally_widget_post_type" name="welocally_widget_post_type" value="<?php echo $options[ 'widget_post_type' ];?>"></li>
    9294            </ul>
    9395        </td>
  • welocally-places/trunk/options/options-infobar.php

    r543527 r548366  
    33$options = $wlPlaces->getOptions();
    44?>
    5 <div id="action_bar">
     5<div id="wl_action_bar">
    66    <div class="rollover" id="btn_support">
    77    <a href="http://support.welocally.com/categories/welocally-places-wp-basic" target="_new">
     
    2323    </div>                                 
    2424</div>
     25<?php
     26$reqsMissing = $wlPlaces->databaseRequirementsMissing();
     27if (count($reqsMissing)>0) {
     28    $showReqsMissing = print_r($reqsMissing,true);
     29    echo ('<div id="wl_info_bar"><div class="wl_error" style="margin 10px;">Reactivation is required to properly support required database changes for version '.WelocallyPlaces::VERSION.'. Please deactivate and re-activate now. '.$showReqsMissing.'</div></div>');             
     30}
     31?> 
  • welocally-places/trunk/options/places-manager.php

    r544331 r548366  
    11<?php
    2 global $wlPlaces;
     2global $wlPlaces,$wpdb;
    33$places = $wlPlaces->getPlacesNew();
    44?> 
    55<script type="text/javascript">
    6 
    7 
    8 function setPlaceRow(i, place){
     6function setPlaceRow(i, placeJSON){
     7    var place = jQuery.parseJSON(placeJSON);
    98    window.wlPlacesManager.setPlaceRow(i, place, jQuery('#wl_placemgr_place_'+i));
    109}
    11 
    1210</script>
    1311<?php
     
    5452                  new WELOCALLY_PlaceManager();         
    5553            window.wlPlacesManager.initCfg(cfg);
    56             jQuery('#wl_places_mgr_wrapper' ).html(window.wlPlacesManager.makeWrapper());
    57                        
     54            jQuery('#wl_places_mgr_wrapper' ).html(window.wlPlacesManager.makeWrapper());       
    5855         
    5956             </script>
  • welocally-places/trunk/quickhelp.html

    r544571 r548366  
    55<head>
    66    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    7     <title>Welocally Places Basic Quick Help</title>
     7    <title>Welocally Places Core Quick Help</title>
    88    <meta name="author" content="Welocally">
    99    <link rel="stylesheet" href="css/wl_pager_admin.css" media="all">   
     
    1818<div class="wrap wl_pager_admin">
    1919    <div class="header section">
    20         <div class="header-title">Welocally Places Basic Quick Help</div>
     20        <div class="header-title">Welocally Places Core For Wordpress Quick Help</div>
    2121        <div class="header-subtitle">Quick Help Guide</div>
    22         <div>version 1.2.19</div>               
    23         <div>Last Updated May 7, 2012</div>     
     22        <div>version 1.2.22</div>               
     23        <div>Last Updated May 21, 2012</div>       
    2424    </div>
    25 <h1>Welocally Places Basic For Wordpress Guide</h1>
     25<h1>Welocally Places Core For Wordpress Guide</h1>
    2626<a title="welocally places wordpress" href="http://wordpress.org/extend/plugins/welocally-places/">Welocally Places Plugin</a> for wordpress is intended to help site authors link real places to their content quickly, and then help their readers find those places quickly. This document is intended to help the blog owner or wordpress developer install, configure and use the plugin. It is structured by the administrative and user components associated with the plugin.
    2727
     
    6060</li>
    6161</ol>
     62<h3>Manual Upgrading</h3>
     63If you are upgrading and an install this manually make sure to re-activate the plugin, activation does important database updates.
     64
    6265<h2><a name="User_Components"></a>User Components</h2>
    6366<h3>Basics</h3>
     
    7174
    7275It acts identically like the Category Tag Map by making a map with selectable markers and a list which can also be selected. When a user selects either a marker or a list item an infobox will pop up at the location of the selected item on the map.
    73 
    74 <span style="font-size: 15px; font-weight: bold; clear: both;">Category Map Tag</span>
    75 
    76 <a href="http://welocally.com/wp-content/uploads/2011/07/Screen-Shot-2012-04-09-at-4.06.56-PM.png"><img class="alignleft size-full wp-image-1029" style="margin-top: 10px;" title="Screen Shot 2012-04-09 at 4.06.56 PM" src="http://welocally.com/wp-content/uploads/2011/07/Screen-Shot-2012-04-09-at-4.06.56-PM.png" alt="" width="207" height="354" /></a>
     76<div style="clear: both;">&nbsp;</div>
     77<h4>Category Map Tag</h4>
    7778The category map allows your users to filter the posts associated with specific categories on a single map, just like the Map Widget. This is helpful if you want to segment different places by type and show them to your readers on a page. making a directory? Just insert the tag "Shopping" or "Bars &amp; Pubs" on a page and you have a simple map for a shopping guide of all the places you have written about.
     79<div style="clear: both;">&nbsp;</div>
     80<p style="text-align: center;"><a href="http://welocally.com/wp-content/uploads/2011/07/Screen-Shot-2012-04-09-at-4.06.56-PM.png"><img class="aligncenter size-full wp-image-1029" style="margin-top: 10px;" title="Screen Shot 2012-04-09 at 4.06.56 PM" src="http://welocally.com/wp-content/uploads/2011/07/Screen-Shot-2012-04-09-at-4.06.56-PM.png" alt="" width="207" height="354" /></a></p>
    7881<p style="text-align: center;"><a href="http://welocally.com/wp-content/uploads/2012/04/Screen-Shot-2012-04-09-at-5.37.34-PM.png"><img class="aligncenter size-full wp-image-1064" title="Screen Shot 2012-04-09 at 5.37.34 PM" src="http://welocally.com/wp-content/uploads/2012/04/Screen-Shot-2012-04-09-at-5.37.34-PM.png" alt="" width="354" height="24" /></a></p>
    7982For example; if you had a pizza blog you might assign The Ugly Duck Pizza with the "Thin Cust" and "Rustic Wood Oven" categories. When your reader was looking for the pizzas of the New York Style only the pizza restaurants that had thin crust pizzas would show as ordered markers, and it would link the places back to the posts where you wrote about them. When a user selects a specific post excerpt, an info box identifying that place on the map will appear.
     
    9093<p style="text-align: center;"><a href="http://welocally.com/wp-content/uploads/2011/09/Screen-Shot-2012-05-12-at-11.52.38-AM.png"><img class="aligncenter size-full wp-image-1263" title="Screen Shot 2012-05-12 at 11.52.38 AM" src="http://welocally.com/wp-content/uploads/2011/09/Screen-Shot-2012-05-12-at-11.52.38-AM.png" alt="" width="482" height="43" /></a></p>
    9194
     95<h4>Custom Post Types</h4>
     96<p>Many wordpress themes such as <a href="http://themeforest.net/item/swagmag-wordpress-magazinereview-theme/1576310">SwagMag - WordPress Magazine/Review Theme</a> use the concept of custom post types to manage an maintain posts. Welocally Places supports one or many custom post types, but you must use the post type name in the database for it to work properly. <strong>Multiple custom post types are supported byt they must be comma delimitated no spaces.</strong></p>
     97<p><a href="http://welocally.com/wp-content/uploads/2011/09/tag_custom_post.png"><img class="aligncenter size-full wp-image-1323" title="tag_custom_post" src="http://welocally.com/wp-content/uploads/2011/09/tag_custom_post.png" alt="" width="500" height="30" /></a></p>
     98<p style="text-align: left;">You can configure the widget to use custom post types in the same way using the options.</p>
     99<p style="text-align: center;"><img class="aligncenter size-full wp-image-1324" title="Screen Shot 2012-05-23 at 7.13.51 PM" src="http://welocally.com/wp-content/uploads/2011/09/Screen-Shot-2012-05-23-at-7.13.51-PM.png" alt="" width="618" height="344" /></p>
     100
     101
    92102<h2>Administration</h2>
    93103Options allow you to control the plugin, and we have created a custom option. We have a custom sidebar options tab, so in setting up welocally places just select the side tab item.
     
    101111</ul>
    102112<h3><strong>Welocally Places General Options</strong></h3>
    103 <p style="text-align: center;"><a href="http://welocally.com/wp-content/uploads/2011/09/Screen-Shot-2012-05-12-at-11.33.10-AM.png"><img class="aligncenter size-full wp-image-1259" title="Screen Shot 2012-05-12 at 11.33.10 AM" src="http://welocally.com/wp-content/uploads/2011/09/Screen-Shot-2012-05-12-at-11.33.10-AM.png" alt="" width="602" height="255" /></a></p>
     113<p style="text-align: center;"><img class="aligncenter size-full wp-image-1324" title="Screen Shot 2012-05-23 at 7.13.51 PM" src="http://welocally.com/wp-content/uploads/2011/09/Screen-Shot-2012-05-23-at-7.13.51-PM.png" alt="" width="618" height="344" /></p>
    104114
    105115<h4 style="text-align: left;">General Map Options, Infobox Place Links</h4>
  • welocally-places/trunk/readme.txt

    r544571 r548366  
    1 === Welocally Places Basic ===
     1=== Welocally Places Core ===
    22Contributors: claytantor
    33Tags: hyperlocal, geocoding, places, maps, foodie, travel, real estate, business directories
     
    77License: GPL v2 (GNU General Public License v2)
    88
    9 The Welocally Places Basic plugin lets easily associate places with rich maps and place info with your wordpress content.
     9The Welocally Places Core plugin lets easily associate places with rich maps and place info with your wordpress content.
    1010
    1111== Description ==
     
    2020* Integrated driving directions
    2121* Category based map tags help you make directories quickly
     22* Support for custom post types
    2223
    2324Product Overview: http://welocally.com/?page_id=2
     
    3536
    3637Q:What Browsers Do You Support?
    37 A:For Publishers we have tested creating places for and recommend versions starting at least Chrome 17.0.963.56, Safari Version 5.1.2 and Firefox 10.0.2. We *do not* reccomend the use of IE for site owners using welocally places, but we have tested site vistors successfully using Welocally Places with IE 5.3.2 or greater.
     38A:For Publishers we have tested creating places for and recommend versions starting at least Chrome 17.0.963.56, Safari Version 5.1.2 and Firefox 10.0.2. We *do not* recommend the use of IE for site owners using welocally places, but we have tested site vistors successfully using Welocally Places with IE 5.3.2 or greater.
    3839 
    3940Q:What is a POI?
     
    5152
    5253== Changelog ==
     541.2.22
     55222 Add activation notice if missing 1.2.22 fields 
     56221 jQuery UI override 
     57220 Change Name To Welocally Places Core   
     58219 Support for Multiple Custom Post Types 
     59218 Edit broken
     60217 Apostrophe in place json causes places manager to fail.
     61213 Refactor shortcode handler 
     62209 Custom post types   
     63208 University Offices, Wellington Square, Oxford, OX1 2JD, United Kingdom 
     64206 Places manager breaks on null place
     65
    53661.2.21
    5467203 Update documentation to include proper version requirements
     
    6275
    63761.2.19
    64 196 Feature Remove Registration Requirement
    65 195 Feature Remove any CURL Concepts   
    66 194 Feature Pagination 
    67 192 Feature Local Category Tag 
    68 191 Feature Local Place Tag
    69 190 Feature No key geocoding
    70 189 Feature Local Database 
    71 186 Bug Refactor options   
    72 185 Bug Category and fields showing on add place.
     77196 Remove Registration Requirement
     78195 Remove any CURL Concepts   
     79194 Pagination 
     80192 Local Category Tag 
     81191 Local Place Tag
     82190 No key geocoding
     83189 Local Database 
     84186 Refactor options   
     85185 Category and fields showing on add place.
    7386
    74871.1.18
    75 Feature #56: Welocally Namespace Javascript Refactoring
    76 Feature #87: Widgetize Place Finder
    77 Feature #100: Refactor wp_postmeta to remove obsolete concepts
    78 Feature #128: Category Map Tag Support
    79 Feature #140: API Keys incorporated into web services
    80 Feature #152: Widgetize Places
    81 Feature #154: Remove Font Customization
    82 Feature #156: Support for post links as title anchors
    83 Feature #160: Multi widget support for style overrides
    84 Feature #161: Use sprited markers
    85 Feature #169: Widgetize Registration
    86 Feature #170: Multisite licensing
    87 Feature #171: Map selector improvements
    88 Feature #174: Catgerory map widget should be context aware
     8856: Welocally Namespace Javascript Refactoring
     8987: Widgetize Place Finder
     90100: Refactor wp_postmeta to remove obsolete concepts
     91128: Category Map Tag Support
     92140: API Keys incorporated into web services
     93152: Widgetize Places
     94154: Remove Font Customization
     95156: Support for post links as title anchors
     96160: Multi widget support for style overrides
     97161: Use sprited markers
     98169: Widgetize Registration
     99170: Multisite licensing
     100171: Map selector improvements
     101174: Catgerory map widget should be context aware
    89102
    901031.1.17
     
    92105
    931061.1.16
    94 99  "Places DB Tool In Options"
    95 94  "Place Finder for Pages"
    96 71  "Share Tag Support"
    97 54  "Refactor Metadata Approach for Place Persistence"
    98 53  "Extended Tag Support"
    99 43  "Places Support On Pages"
    100 42  "Transform Post Save Approach to Tags and Place Metadata"
    101 41  "Custom Theme Support For List Widget"
    102 40  "Custom Theme Support For Map Widget"
    103 38  "Add Custom Theme Options Settings"
    104 36  "iFeature Theme Support"
    105 34  "zBench Theme Support"
    106 21  "Add Change Login/Key Support"
    107 10  "Theme Support for Delicate "
    108 3   "Integrate New Add Place Workflow"
    109 
    110 1.0.13
    111 361 Options settings to suppress the display of the the "sele...   
    112 360 Infobox close deselects peer infoboxes.
    113 363 Support Thumbnails in Map Infobox
    114 364 Sight Theme Support
    115 
    116 1.0.12
    117 354 critical    P1  Archive summaries are showing javascript for theme.
    118 353 critical    P1  Setting "Yes" to place with no selection should not persist on Update
    119 352 enhancement P1  Picman still broken in some themes
    120 351 enhancement P2  Improve theme support in About options
    121 
    122 1.0.11
    123 349 maj P1  Map is Showing Up On Category Archive   1.0.11
    124 346 maj P2  Add Place Appends Extra to website prefix   ---
    125 344 cri P1  Place Name Links To Incorrect Post  1.0.11
    126 343 enh P1  Bypass Filter When No Category Hits 1.0.11
    127 341 enh P2  Some theme img css effects map tiles    1.0.11
    128 
    129 1.0.10
    130 333 FIXE    1.0.9   Need to quote templated javascript
    131 334 FIXE    1.0.9   Where marker not showing up on non custom maps
    132 336 FIXE    1.0.9   HTTPS support for all ajax calls
    133 337 FIXE    1.0.9   Url and Website Confusion
    134 338 WORK    1.0.9   Cannot exit add place mode
    135 340 FIXE    1.0.9   Plugin causes problem when inserting images
    136 
    137 1.0.9
    138 332 FIXE    1.0.8   Jquery version < 1.4 is not parsing JSON
    139 304 WONT    1.0.7   Seachability for Simple Geo Store
    140 327 FIXE    1.0.7   Improve subscription prompting and workflow
    141 331 LATE    1.0.8   Post excerpts are not full text
    142 
    143 1.0.8 
    144 320 FIXE    Post map not showing up on new posts   
    145 321 FIXE    Infobox missing URL link for places
    146 327 FIXE    Improve subscription prompting and workflow
    147 
    148 1.0.7 Initial version. Includes: Places List Widget, Places Map Widget and 
    149 Category Browser for supported themes
     10799  Places DB Tool In Options
     10894  Place Finder for Pages
     10971  Share Tag Support
     11054  Refactor Metadata Approach for Place Persistence
     11153  Extended Tag Support
     11243  Places Support On Pages
     11342  Transform Post Save Approach to Tags and Place Metadata
     11441  Custom Theme Support For List Widget
     11540  Custom Theme Support For Map Widget
     11638  Add Custom Theme Options Settings
     11736  iFeature Theme Support
     11834  zBench Theme Support
     11921  Add Change Login/Key Support
     12010  Theme Support for Delicate
     1213   Integrate New Add Place Workflow
    150122
    151123== Upgrade Notice ==
    152 No notices at this time.
     124If you are upgrading and an install this manually make sure to re-activate the plugin, activation does important database updates.
    153125
    154126== Screenshots ==
  • welocally-places/trunk/resources/javascripts/wl_addplace_wp.js

    r544331 r548366  
    531531      type: 'POST',       
    532532      url: ajaxurl,
     533      datatype: 'json',
    533534      data: data,
    534535      beforeSend: function(jqXHR){
     
    540541        }       
    541542      },         
    542       success : function(data, textStatus, jqXHR) {
     543      success : function(data, textStatus, jqXHR, dataType) {
    543544        if(data != null && data.errors != null) {
    544545            _instance.setStatus(_instance.statusArea,'ERROR:'+WELOCALLY.util.getErrorString(data.errors), 'wl_error', false);
     
    546547            _instance.setStatus(_instance.statusArea,'Could not save place:'+WELOCALLY.util.getErrorString(data.errors), 'wl_error', false);
    547548        } else {
    548             var response = jQuery.parseJSON(data);
    549             var tag = '[welocally id="'+response.id+'"/]';
    550            
    551             _instance.setStatus(_instance.statusArea,'Your place has been saved! <br/><span class="wl_placemgr_place_tag">'+tag+'</span>', 'wl_message', false);
    552             _instance.savedPlace = selectedPlace;
     549            try{
     550                var response = jQuery.parseJSON(data);
     551                var tag = '[welocally id="'+response.id+'"/]';             
     552                _instance.setStatus(_instance.statusArea,'Your place has been saved! <br/><span class="wl_placemgr_place_tag">'+tag+'</span>', 'wl_message', false);
     553                _instance.savedPlace = selectedPlace;
     554            } catch(e) {
     555                _instance.setStatus(_instance.statusArea,'ERROR: Can Not Parse Response.'+data, 'wl_error', false);
     556            }
     557           
     558           
     559           
    553560        }
    554561      }
     
    626633   
    627634    var hasAll = _instance.hasType("country", geocode.address_components);
    628     hasAll = hasAll && _instance.hasType("street_number", geocode.address_components);
    629635    hasAll = hasAll && _instance.hasType("route", geocode.address_components);
    630636    hasAll = hasAll && _instance.hasType("locality", geocode.address_components);
  • welocally-places/trunk/resources/javascripts/wl_pager_wp.js

    r543528 r548366  
    268268        content: _instance.cfg.content
    269269    };
    270            
     270   
     271    jQuery(_instance.wrapper).show();   
     272   
    271273    _instance.jqxhr = jQuery.ajax({
    272274      type: 'POST',       
     
    285287          _instance.setStatus(_instance.statusArea,'', 'wl_message', false);
    286288          jQuery(_instance.wrapper).find('.wl_pager_content').html(res);
    287           jQuery(_instance.wrapper).show();
    288289      }
    289290    });
  • welocally-places/trunk/resources/javascripts/wl_placemgr.js

    r544331 r548366  
    8484WELOCALLY_PlaceManager.prototype.setPlaceRow = function(i, place, row) {
    8585   
    86     jQuery(this.wrapper).find('#wl_placesmgr_searchterm').show();
    87    
    88    
    89     var placeRowContent = jQuery('<div></div>');   
    90     jQuery(placeRowContent).append('<div class="wl_placemgr_place_tag">[welocally id="'+place._id+'" /]</div>');   
    91    
    92     var placeInfo = jQuery('<div class="wl_placemgr_place_info"></div>');
    93 
    94     jQuery(placeInfo).append('<div class="place_field">'+place.properties.name+'</div>');
    95     jQuery(placeInfo).append('<div class="place_field">'+place.properties.address+'</div>');
    96     jQuery(placeInfo).append('<div class="place_field">'+place.properties.city+'</div>');
    97     jQuery(placeInfo).append('<div class="place_field">'+place.properties.province+'</div>');
    98     jQuery(placeInfo).append('<div class="place_field">'+place.properties.postcode+'</div>');
    99     if(place.properties.website)
    100         jQuery(placeInfo).append('<div class="place_field">'+place.properties.website+'</div>');
    101     if(place.properties.phone)
    102         jQuery(placeInfo).append('<div class="place_field">'+place.properties.phone+'</div>');
    103     jQuery(placeRowContent).append(placeInfo);
    104    
    105     var actions = jQuery('<div class="wl_placemgr_actions"></div>');
    106     var btnEdit = jQuery('<a class="wl_placemgr_button" href="#">edit</a>');
    107     jQuery(btnEdit).bind('click',{instance: this, place: place, index: i, row: row}, this.editHandler);
    108 
    109     var btnDelete = jQuery('<a class="wl_placemgr_button" href="#">delete</a>');
    110    
    111     jQuery(btnDelete).bind('click',{instance: this, place: place, index: i, row: row}, this.deleteDialogHandler);
    112    
    113     jQuery(actions).append(btnEdit);
    114     jQuery(actions).append(btnDelete);     
    115     jQuery(placeRowContent).append(actions);
    116        
    117     jQuery(row).html(placeRowContent);
     86    if(place){
     87        jQuery(this.wrapper).find('#wl_placesmgr_searchterm').show();
     88       
     89       
     90        var placeRowContent = jQuery('<div></div>');   
     91        jQuery(placeRowContent).append('<div class="wl_placemgr_place_tag">[welocally id="'+place._id+'" /]</div>');   
     92       
     93        var placeInfo = jQuery('<div class="wl_placemgr_place_info"></div>');
     94
     95        jQuery(placeInfo).append('<div class="place_field">'+place.properties.name+'</div>');
     96        jQuery(placeInfo).append('<div class="place_field">'+place.properties.address+'</div>');
     97        jQuery(placeInfo).append('<div class="place_field">'+place.properties.city+'</div>');
     98        jQuery(placeInfo).append('<div class="place_field">'+place.properties.province+'</div>');
     99        jQuery(placeInfo).append('<div class="place_field">'+place.properties.postcode+'</div>');
     100        if(place.properties.website)
     101            jQuery(placeInfo).append('<div class="place_field">'+place.properties.website+'</div>');
     102        if(place.properties.phone)
     103            jQuery(placeInfo).append('<div class="place_field">'+place.properties.phone+'</div>');
     104        jQuery(placeRowContent).append(placeInfo);
     105       
     106        var actions = jQuery('<div class="wl_placemgr_actions"></div>');
     107        var btnEdit = jQuery('<a class="wl_placemgr_button" href="#">edit</a>');
     108        jQuery(btnEdit).bind('click',{instance: this, place: place, index: i, row: row}, this.editHandler);
     109
     110        var btnDelete = jQuery('<a class="wl_placemgr_button" href="#">delete</a>');
     111       
     112        jQuery(btnDelete).bind('click',{instance: this, place: place, index: i, row: row}, this.deleteDialogHandler);
     113       
     114        jQuery(actions).append(btnEdit);
     115        jQuery(actions).append(btnDelete);     
     116        jQuery(placeRowContent).append(actions);
     117           
     118        jQuery(row).html(placeRowContent);
     119    } else {
     120       
     121        jQuery(this.wrapper).find('#wl_placesmgr_searchterm').show();
     122       
     123       
     124        var placeRowContent = jQuery('<div></div>');   
     125       
     126        var placeInfo = jQuery('<div class="wl_placemgr_place_info">PLACE EMPTY PLEASE DELETE AND ADD A NEW ONE</div>');
     127        jQuery(placeRowContent).append(placeInfo);
     128       
     129        var actions = jQuery('<div class="wl_placemgr_actions"></div>');
     130        var btnDelete = jQuery('<a class="wl_placemgr_button" href="#">delete</a>');
     131       
     132        jQuery(btnDelete).bind('click',{instance: this, place: place, index: i, row: row}, this.deleteDialogHandler);
     133       
     134        jQuery(actions).append(btnDelete);     
     135        jQuery(placeRowContent).append(actions);
     136           
     137        jQuery(row).html(placeRowContent);
     138    }
     139   
    118140};
    119141
     
    192214            event.data,
    193215            _instance.deleteHandler);
    194     jQuery( _instance.deleteDialog).html('Please confirm that you would like to delete '+
    195             event.data.place.properties.name+' at '+event.data.place.properties.address+
    196             '. <strong>This action can not be undone.</strong> You will also need to delete the tag from your post.');
     216    var title = 'Delete Place?';
     217    if(event.data.place) {
     218        jQuery( _instance.deleteDialog).html('Please confirm that you would like to delete '+
     219                event.data.place.properties.name+' at '+event.data.place.properties.address+
     220                '. <strong>This action can not be undone.</strong> You will also need to delete the tag from your post.');
     221        title = 'Delete '+event.data.place.properties.name+'?'
     222    } else {
     223        jQuery( _instance.deleteDialog).html('The place is missing from this record, you should go ahead and delete it and add a new place');
     224    }
     225   
    197226    jQuery( _instance.deleteDialog).dialog({
    198227        resizable: false,
    199         title: 'Delete '+event.data.place.properties.name+'?',
     228        title: title,
    200229        width: 400,
    201230        height:200,
     
    224253    var data = {
    225254            action: 'delete_place',
    226             id: event.data.index,
    227             wl_id: event.data.place._id
     255            id: event.data.index
    228256    };
    229257           
  • welocally-places/trunk/resources/stylesheets/ie/wl_places_admin.css

    r543527 r548366  
    55text-transform:uppercase}
    66
    7 .form-table { 
     7.wl-form-table { 
    88    border-collapse: separate;
    99    -webkit-border-radius: 4px;
     
    2424}
    2525
    26 #action_bar {  width:100%; text-align:right; }
     26#wl_action_bar {  width:100%; text-align:right; }
     27#wl_info_bar {  width:95%;  text-align:center; padding:10px; }
    2728 
    2829#btn_support a{
  • welocally-places/trunk/resources/stylesheets/wl_places_admin.css

    r543527 r548366  
    77text-transform:uppercase}
    88
    9 .form-table { 
     9.wl-form-table { 
    1010    border-collapse: separate;
    1111    -webkit-border-radius: 4px;
     
    1616    border: 1px solid #034D96;
    1717    background: #DFEFF2; padding: 5px; }
    18        
     18   
     19table.wl-form-table tr  > td {
     20    padding-bottom: 1.2em;
     21}
     22   
     23table.wl-form-table tr  > th {
     24    vertical-align: top;
     25    text-align: right;
     26    padding-right: 5px;
     27    width: 250px;
     28}
     29   
     30           
    1931.rollover {
    2032    display: inline-block;
     
    2638}
    2739
    28 #action_bar {  width:100%; text-align:right; }
     40#wl_action_bar {  width:100%; text-align:right; }
     41#wl_info_bar {  width:95%;  text-align:center; padding:10px; }
    2942 
    3043#btn_support a{
     
    166179text-transform:uppercase}
    167180
    168 .form-table { 
    169     border-collapse: separate;
    170     -webkit-border-radius: 4px;
    171     -moz-border-radius: 4px;
    172     border-radius: 4px;
    173     padding: 4px;
    174     width:98%; margin-bottom:10px; 
    175     border: 1px solid #034D96;
    176     background: #DFEFF2; padding: 5px; }
    177181       
    178182.rollover {
     
    185189}
    186190
    187 #action_bar {  width:100%; text-align:right; }
    188  
     191
    189192#btn_support a{
    190193width: 80px; height: 30px;
  • welocally-places/trunk/template-tags.php

    r543814 r548366  
    1919        $wlPlaces->saveOptions($options);
    2020       
    21         //update places
    22         if ( array_key_exists( 'update_places', $options )) {
    23             update_places();
    24         }
    2521    }
    2622   
     
    8379   
    8480   
    85     function update_places(){
    86         global $wlPlaces;
    87         $cat_ID = $wlPlaces->placeCategory();       
    88         $places_in_category_posts = $wlPlaces->getPlacePostsInCategory($cat_ID, null);
    89        
    90         $index = 0;
    91         foreach( $places_in_category_posts as $post ) {
    92            
    93            
    94             $placeJsonRaw = str_replace(
    95                         "\'", "",
    96                         get_post_meta( $post->ID, '_PlaceSelected', true ));       
    97                                            
    98             $placeJson =
    99                 json_decode($placeJsonRaw, true);
    100            
    101             $pname = str_replace("\\'", "'", $placeJson{'name'});
    102            
    103             if($pname != null){
    104                 $newPlaceJson = convert_legacy_place($placeJsonRaw);
    105                 update_post_meta( $post->ID, '_PlaceSelected',  $newPlaceJson);
    106             }
    107                    
    108         }       
    109        
    110     }
     81
    11182   
    11283    /**
     
    235206        return $wlPlaces->getPlacePostsInCategory($categoryId, 'post');
    236207    }
    237    
    238    
    239     /*function get_places_for_category($categoryId){
    240         global $wlPlaces;
    241         $options = $wlPlaces->getOptions();
    242         $result = array();
    243         $places_in_category_posts = $wlPlaces->getPlacePostsInCategory($categoryId, 'post');
    244         foreach( $places_in_category_posts as $post ){
    245             $places = get_post_places($post->ID); 
    246             foreach ($places as $place){
    247                 if($options['infobox_title_link']=='on'){
    248                     $place->properties->titlelink=get_permalink( $post->ID ) ; 
    249                 }                           
    250                 array_push($result, $place);
    251             }
    252         }       
    253         return json_encode($result);       
    254     }*/
    255    
    256        
     208           
    257209    function get_legacy_place_by_post_id( $postId = null) {
    258210        global $wpdb;
     
    289241    }
    290242   
    291    
    292     /*function wl_get_post_excerpt( $postId = null) {
    293         global $wpdb;
    294        
    295         $query = "
    296             SELECT $wpdb->posts.*
    297                 FROM $wpdb->posts
    298             WHERE $wpdb->posts.post_status = 'publish'
    299             AND $wpdb->posts.ID = $postId
    300             GROUP BY $wpdb->posts.ID LIMIT 1";
    301            
    302         $queryResult = $wpdb->get_results($query, OBJECT);
    303        
    304         $excerpt = wl_trim_excerpt($queryResult[0]->post_content, $queryResult[0]->post_excerpt);   
    305         $excerpt = WelocallyPlaces_Tag::searchAndReplace($excerpt, create_function('$tag,$tag_str', 'return "";'));
    306         $excerpt = str_replace( '\'', '', $excerpt );
    307         $excerpt = trim( preg_replace( '/\s+/', ' ', $excerpt ) );
    308        
    309         return $excerpt;
    310     }*/
    311    
    312     /*function wl_trim_excerpt($text, $excerpt)
    313     {
    314         if ($excerpt) return $excerpt;
    315    
    316         $text = strip_shortcodes( $text );
    317    
    318         $text = str_replace(']]>', ']]&gt;', $text);
    319         $text = strip_tags($text);
    320         $excerpt_length = apply_filters('excerpt_length', 55);
    321         $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
    322         $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
    323         if ( count($words) > $excerpt_length ) {
    324                 array_pop($words);
    325                 $text = implode(' ', $words);
    326                 $text = $text . $excerpt_more;
    327         } else {
    328                 $text = implode(' ', $words);
    329         }
    330    
    331         return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
    332     }*/
    333    
    334243    function places_get_mapview_link( ) {
    335244        global $wlPlaces;
  • welocally-places/trunk/views/category-map-content-template.php

    r544571 r548366  
    55 <div class="wl_category_container_tag">
    66    <div id="wl_category_map">
    7       <script type="text/javascript">
    8 //<![CDATA[
    9        
    10         var placeSelected = new WELOCALLY_PlaceWidget({hidePlaceSectionMap: true}).init();
    11         var cfg = {
    12                 id:'multi_<?php echo $t->uid; ?>',
    13                 hideDistance: true,                 
    14                 <?php if($options['show_letters_tag']=='on'):?> showLetters: true,<?php else: ?>showLetters: false,<?php endif;?>
    15                 <?php if(!empty($options['tag_selection_style'])):?> overrideSelectableStyle:<?php echo('\''.$options['tag_selection_style'].'\''.',');?><?php else: ?>overrideSelectableStyle: 'margin: 3px; padding: 2px; float: left; width: 150px; height: 60px;',<?php endif;?>
    16                 imagePath:'<?php echo($marker_image_path); ?>',
    17                 endpoint:'<?php echo($endpoint); ?>',
    18                 <?php if($options['show_selection_tag']=='on'):?>showSelection: true,<?php else: ?>showSelection: false,<?php endif;?>
    19                 observers:[placeSelected],
    20                 <?php if(isset($custom_style)):?> styles:<?php echo($custom_style.','); endif;?>
    21                 places: <?php echo json_encode($t->places); ?>
    22         };
    23         var placesMulti =
    24               new WELOCALLY_PlacesMultiWidget(cfg)
    25                 .init();
    26        
    27         //now register the display for the place
    28         placeSelected.initCfg(cfg);
    29         placesMulti.getSelectedArea().append(placeSelected.makeWrapper());         
    30      
    31       //]]>
    32       </script>
     7<script type="text/javascript">
     8var placeSelected = new WELOCALLY_PlaceWidget({hidePlaceSectionMap: true}).init();
     9var cfg = {
     10        id:'multi_<?php echo $t->uid; ?>',
     11        hideDistance: true,                 
     12        <?php if($options['show_letters_tag']=='on'):?> showLetters: true,<?php else: ?>showLetters: false,<?php endif;?>
     13        <?php if(!empty($options['tag_selection_style'])):?> overrideSelectableStyle:<?php echo('\''.$options['tag_selection_style'].'\''.',');?><?php else: ?>overrideSelectableStyle: 'margin: 3px; padding: 2px; float: left; width: 150px; height: 60px;',<?php endif;?>
     14        imagePath:'<?php echo($marker_image_path); ?>',
     15        endpoint:'<?php echo($endpoint); ?>',
     16        <?php if($options['show_selection_tag']=='on'):?>showSelection: true,<?php else: ?>showSelection: false,<?php endif;?>
     17        observers:[placeSelected],
     18        <?php if(isset($custom_style)):?> styles:<?php echo($custom_style.','); endif;?>
     19        places: <?php echo json_encode($t->places); ?>
     20    };
     21    var placesMulti =
     22          new WELOCALLY_PlacesMultiWidget(cfg)
     23            .init();
     24    placeSelected.initCfg(cfg);
     25    placesMulti.getSelectedArea().append(placeSelected.makeWrapper());         
     26</script>
    3327    </div>
    3428  </div>
  • welocally-places/trunk/views/place-content-template.php

    r543527 r548366  
    2020
    2121?>
    22 
    23 <script type="text/javascript">
    24 jQuery(document).ready(function() {
    25    
    26 
    27 });
    28 </script>
    29 
    3022<div id="wl-place-content-<?php echo $t->uid; ?>" class="wl-place-content">
    3123    <div class="template-wrapper">
    3224        <div>
    33         <script type="text/javascript" charset="utf-8">
    34         var place<?php echo $t->uid; ?> = <?php echo $t->placeJSON; ?>;
    35         var cfg = {
    36             id:  place<?php echo $t->uid; ?>._id,
    37             imagePath:'<?php echo($marker_image_path); ?>',
    38             endpoint:'<?php echo($endpoint); ?>',
    39             <?php if(isset($custom_style)):?> styles:<?php echo($custom_style.','); endif;?>
    40             showShare: false,
    41             placehoundPath: 'http://placehound.com'
    42         };
    43                        
    44         var placeWidget<?php echo $t->uid; ?> =
    45               new WELOCALLY_PlaceWidget(cfg)
    46                 .init();
    47        
    48         placeWidget<?php echo $t->uid; ?>.load(place<?php echo $t->uid; ?>);     
    49        
    50         </script>
     25<script type="text/javascript" charset="utf-8">
     26var place<?php echo $t->uid; ?> = <?php echo $t->placeJSON; ?>;
     27var cfg = {
     28    id:  place<?php echo $t->uid; ?>._id,
     29    imagePath:'<?php echo($marker_image_path); ?>',
     30    endpoint:'<?php echo($endpoint); ?>',
     31    <?php if(isset($custom_style)):?> styles:<?php echo($custom_style.','); endif;?>
     32    showShare: false,
     33    placehoundPath: 'http://placehound.com'
     34};
     35var placeWidget<?php echo $t->uid; ?> =
     36      new WELOCALLY_PlaceWidget(cfg)
     37        .init();
     38placeWidget<?php echo $t->uid; ?>.load(place<?php echo $t->uid; ?>);           
     39</script>
    5140        </div>
    5241    </div>
  • welocally-places/trunk/views/welocally-places-map-widget-display.php

    r544571 r548366  
    66 <div class="wl_category_container_widget"> 
    77    <div id="main">
    8       <script type="text/javascript">
    9 //<![CDATA[
    10                
    11         var placeSelected = new WELOCALLY_PlaceWidget({hidePlaceSectionMap: true}).init();
    12         var cfg = {
    13                 id:'multi_<?php echo $t->uid; ?>', 
    14                 <?php if($options['show_letters']=='on'):?> showLetters: true,<?php else: ?>showLetters: false,<?php endif;?>
    15                 <?php if(!empty($options['widget_selection_style'])):?> overrideSelectableStyle:<?php echo('\''.$options['widget_selection_style'].'\''.',');?><?php else: ?>overrideSelectableStyle: 'width:98%;',<?php endif;?>
    16                 imagePath:'<?php echo($marker_image_path); ?>',
    17                 endpoint:'<?php echo($endpoint); ?>',
    18                 <?php if($options['show_selection']=='on'):?>showSelection: true,<?php else: ?>showSelection: false,<?php endif;?>
    19                 observers:[placeSelected],
    20                 <?php if(isset($custom_style)):?> styles:<?php echo($custom_style.','); endif;?>
    21                 places: <?php echo json_encode($t->places); ?>
    22         };
    23        
    24         var placesMulti =
    25               new WELOCALLY_PlacesMultiWidget(cfg)
    26                 .init();
    27        
    28         //now register the display for the place
    29         placeSelected.initCfg(cfg);
    30         placesMulti.getSelectedArea().append(placeSelected.makeWrapper());           
    31      
    32       //]]>
    33       </script>
     8<script type="text/javascript">
     9var placeSelected = new WELOCALLY_PlaceWidget({hidePlaceSectionMap: true}).init();
     10var cfg = {
     11        id:'multi_<?php echo $t->uid; ?>', 
     12        <?php if($options['show_letters']=='on'):?> showLetters: true,<?php else: ?>showLetters: false,<?php endif;?>
     13        <?php if(!empty($options['widget_selection_style'])):?> overrideSelectableStyle:<?php echo('\''.$options['widget_selection_style'].'\''.',');?><?php else: ?>overrideSelectableStyle: 'width:98%;',<?php endif;?>
     14        imagePath:'<?php echo($marker_image_path); ?>',
     15        endpoint:'<?php echo($endpoint); ?>',
     16        <?php if($options['show_selection']=='on'):?>showSelection: true,<?php else: ?>showSelection: false,<?php endif;?>
     17        observers:[placeSelected],
     18        <?php if(isset($custom_style)):?> styles:<?php echo($custom_style.','); endif;?>
     19        places: <?php echo json_encode($t->places); ?>
     20    };     
     21    var placesMulti =
     22          new WELOCALLY_PlacesMultiWidget(cfg)
     23            .init();
     24    placeSelected.initCfg(cfg);
     25    placesMulti.getSelectedArea().append(placeSelected.makeWrapper());           
     26</script>
    3427    </div>
    3528  </div>
  • welocally-places/trunk/welocally-places-map-widget.class.php

    r529351 r548366  
    2525            }
    2626       
     27       
     28            /**
     29             * needs to be refactored
     30             *
     31             */
    2732            function widget( $args, $instance ) {
    28                 global $wp_query,$wlPlaces;
     33               
     34                global $wlPlaces;
    2935                $options = $wlPlaces->getOptions();
    3036                extract( $args );
    3137
    32                 /* User-selected settings. */
    33                 $title = $instance['title'];
    34                 $limit = $instance['limit'];
     38   
     39                $post_type = $options['widget_post_type'];                 
    3540               
    36                 if( function_exists( 'get_places' ) ) {
    37                     $old_display = $wp_query->get('placeMapDisplay');
    38                     $wp_query->set('placeMapDisplay', 'places');
    39                     $posts = get_places($limit, null, null);
    40                 }
     41                $cat = $wlPlaces->placeCategory();
    4142               
    42                 if( $posts ) {
    43                     /* Display list of places. */
    44                         if( function_exists( 'get_places' ) ) {
    45                             //$templateLoc = apply_filters('map_widget_template','');
    46                             //view
    47                             //include( $templateLoc );
    48                            
    49                             $currentCat = get_query_var( 'cat' );
    50                            
    51                             if(!$currentCat){
    52                                 $currentCat = $wlPlaces->placeCategory();
     43                $cat_var = get_query_var('cat');
     44               
     45               
     46                if (!empty($cat_var) && !(is_home() || is_front_page())) {         
     47                    $cat = get_category(intval($cat_var));
     48                }                   
     49                elseif (isset($post) && !(is_home() || is_front_page())){
     50                    //try to get category for post if possible
     51                    $post_categories = wp_get_post_categories( $post->ID );
     52                    if($post_categories){       
     53                        foreach ($post_categories as $postCatId) {
     54                            $catObj = get_category( $postCatId );
     55                            if($catObj->name != 'Uncategorized' && $catObj->name != 'Place'){
     56                                $cat = $postCatId;
    5357                            }
    54                             echo($wlPlaces->getCategoryMapMarkup(
    55                                 $currentCat,
    56                                 dirname( __FILE__ ).'/views/welocally-places-map-widget-display.php',
    57                                 true));
    58                            
    59                            
    60                            
    61                             $wp_query->set('placeMapDisplay', $old_display);
    6258                        }
     59                    }
     60                }               
    6361                   
    64                        
    65                 } else if( !$posts ) _e('There are no places.', $this->pluginDomain);
    66 
     62               
     63                if(!isset($post_type))
     64                    $post_type = 'post';
     65   
     66                //add support for custom post type
     67                echo $wlPlaces->getCategoryMapMarkup(
     68                    $cat,
     69                    dirname( __FILE__ ).'/views/welocally-places-map-widget-display.php',
     70                    true,
     71                    25,
     72                    $post_type);   
    6773               
    6874            }   
    6975       
    7076            function update( $new_instance, $old_instance ) {
    71                     $instance = $old_instance;
    72 
    73                     /* Strip tags (if needed) and update the widget settings. */
    74                     $instance['title'] = strip_tags( $new_instance['title'] );                 
    75                     $instance['limit'] = strip_tags( $new_instance['limit'] );
    76                     /*if(eval($instance['limit'])>25)
    77                         $instance['limit'] = '25';*/
    78                    
    79 
     77                    $instance = $old_instance;                 
    8078                    return $instance;
    8179            }
     
    8381            function form( $instance ) {
    8482                /* Set up default widget settings. */
    85                 $defaults = array( 'style'=>'aside', 'title' => 'Published Places', 'limit' => '25');
     83                $defaults = array( 'style'=>'aside', 'title' => 'Published Places', 'limit' => '25', 'post_type'=>'post');
    8684                $instance = wp_parse_args( (array) $instance, $defaults );         
    8785                include( dirname( __FILE__ ) . '/views/welocally-places-map-widget-admin.php' );
  • welocally-places/trunk/welocally-places-tag-processor.class.php

    r543527 r548366  
    77        }
    88       
    9         private function queryPlace($tag) {
    10             if (!$tag->id)
    11                 return false;
    12                
    13 //            $response = json_decode($json_response);
    14 //            return $response[0];
    15         }
    16        
    179        public function processTag($tag, $postId=0) {
    1810           
     
    2012            global $wlPlaces;
    2113           
    22            
    23             if (!$tag->id || $tag->type != 'post')
    24                 return false;
    25                
    2614            $postId = intval($postId);
    2715           
    2816            $place = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wl_places WHERE wl_id = %s", $tag->id));
    2917           
    30                      
    31             if ($place == null) {
    32                 $place_info = $this->queryPlace($tag);
    33 
    34                 if ($wpdb->insert("{$wpdb->prefix}wl_places", array('wl_id' => $tag->id,
    35                                                                     'place' => json_encode($place_info))) ) {
    36                                                                        
    37                     $place = $wpdb->get_row(
    38                         $wpdb->prepare("SELECT * FROM {$wpdb->prefix}wl_places WHERE wl_id = %s", $tag->id) );
    39                 }
    40                
    41             }
    42            
    43             if (!$place)
    44                 return false;
    45            
    46             if ($postId) {
     18            if ($place && $postId) {
    4719                $wpdb->insert("{$wpdb->prefix}wl_places_posts", array('place_id' => $place->id,
    4820                                                                      'post_id' => $postId));
    49                 //make sure its categorized as place no matter what
     21               
     22                //make sure its categorized as place no matter what
    5023                $postCategories = wp_get_post_categories($postId);                                                     
    5124                $customCategories = array();
     
    6134                $newCategories = array_merge($postCategories, $customCategories);
    6235                wp_set_post_categories($postId, $newCategories);
    63                
    64                 update_post_meta($this->postId, '_isWLPlace', true);
    65                
    66                 // delete post metadata from previous versions of the plugin
    67                 delete_post_meta($postId, '_PlaceSelected');
    68                 delete_post_meta($postId, '_WLPlaces');
    69             } else {
    70                
    71             }
    7236           
    73             return $place;
    74 
     37            }
     38           
     39           
     40           
    7541        }
    7642       
  • welocally-places/trunk/welocally-places.class.php

    r544571 r548366  
    99    class WelocallyPlaces {
    1010       
    11         const VERSION               = '1.2.21';
     11        const VERSION               = '1.2.22';
    1212        const DB_VERSION            = '2.0';
    1313        const WLERROROPT            = '_welocally_errors';
     
    2424        public $pluginUrl;
    2525        public $pluginDomain = 'welocallyPlaces';
    26        
    27         public $metaTags = array(
    28                     '_isWLPlace',
    29                     '_PlaceSelected',
    30                     '_ShowPlaceAddress',
    31                     self::WLERROROPT
    32                     );
    33        
    3426       
    3527        /**
     
    6254            add_action( 'admin_enqueue_scripts',        array( $this, 'loadAdminDomainStylesScripts' ) );
    6355            add_action( 'admin_menu',       array( $this, 'addPlaceBox' ) );
    64             add_action( 'save_post',        array( $this, 'tagHandling'));
     56            add_action( 'save_post',        array( $this, 'handlePublish'));
    6557           
    6658            add_action( 'sp_places_post_errors', array( 'WLPLACES_Post_Exception', 'displayMessage' ) );
    6759            add_action( 'sp_places_options_top', array( 'WLPLACES_Options_Exception', 'displayMessage') );
    6860
    69             add_filter( 'the_content', array( $this, 'replaceTagsInContent') );
     61            add_shortcode('welocally', array ($this,'handleWelocallyPlacesShortcode'));
    7062           
    71            
    72                        
     63                           
    7364        }
    7465       
     
    8071        function wl_admin_message($message='empty message', $error = false) {
    8172            echo '<div class="updated fade"><p>'.$message.'</p></div>';
    82 
    83         }
    84        
    85                
     73        }
     74                       
    8675        /**
    8776         * @return
    8877         */
    89         public function in_category() {
    90            
     78        public function in_category() {         
    9179            $cat_id = get_query_var( 'cat' );
    9280           
     
    9482                return true;
    9583            }
    96 
    9784        }
    9885       
     
    129116            wp_enqueue_script( 'jquery' );
    130117            wp_enqueue_script('jquery-ui-all' , 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js');
    131                                
    132                    
    133             //jquery ui
    134             wp_register_style( 'jquery-ui-style', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/smoothness/jquery-ui.css' );
    135             wp_enqueue_style( 'jquery-ui-style' ); 
    136            
     118                                                   
    137119            //welocally
    138120            wp_enqueue_script('wl_base_script', WP_PLUGIN_URL.'/welocally-places/resources/javascripts/wl_base.js', array('jquery'), WelocallyPlaces::VERSION);
     
    176158            wp_enqueue_script('jquery-ui-all' , 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js');
    177159                                                   
    178             //jquery ui
    179             wp_register_style( 'jquery-ui-style', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/smoothness/jquery-ui.css' );
    180             wp_enqueue_style( 'jquery-ui-style' ); 
    181            
    182                                    
     160                                               
    183161            wp_enqueue_script('media-upload');
    184162            wp_enqueue_script('thickbox');
     
    192170            //add places
    193171            wp_enqueue_style( 'wl_places_addplace_style',WP_PLUGIN_URL.'/welocally-places/resources/stylesheets/wl_places_addplace.css',array(), WelocallyPlaces::VERSION, 'screen' ); 
    194            
    195            
     172                       
    196173            global $wp_styles;
    197174       
     
    218195           
    219196        }
     197       
     198        public function handleWelocallyPlacesShortcode($attrs,$content = null) {
     199           
     200            global $post;
     201           
     202            extract(shortcode_atts(array (
     203                'categories' => null,
     204                'category' => null,
     205                'id' => null,
     206                'post_type'=> null             
     207            ), $attrs));           
     208           
     209            //strip paragragh tags if exists this is required
     210            if ( '</p>' == substr( $content, 0, 4 )
     211            and '<p>' == substr( $content, strlen( $content ) - 3 ) )
     212                $content = substr( $content, 4, strlen( $content ) - 7 );
     213           
     214            //template for javscript
     215            $t = new StdClass();
     216            $t->uid = uniqid();
     217           
     218            if(!empty($id)) {
     219                //this is a place
     220                $t->wl_id = $id;
     221               
     222                $this->processPlaceTag($t, $post->ID);
     223               
     224                if(isset($t->place)){
     225                    ob_start();
     226                    include(dirname(__FILE__) . '/views/place-content-template.php');
     227                    $resultContent = ob_get_contents();
     228                    ob_end_clean();                     
     229                    $t = null;               
     230                    return $resultContent;                     
     231                } else {
     232                    return false;
     233                }                   
     234            }
     235           
     236            //right now only one is supported
     237            $catsSlug = array();                       
     238            if(!empty($categories))
     239                $catsSlug = explode(",", $categories);
     240            else if(!empty($category))
     241                $catsSlug = explode(",", $category);
     242               
     243            $string = preg_replace('/&(?!amp;)/', '&amp;', $catsSlug[0]);
     244            $string = preg_replace('/#038;/', '', $string);
     245       
     246            $term = get_term_by('name',$string,'category');
     247            if(!isset($post_type))
     248                $post_type = 'post';
     249
     250            return $this->getCategoryMapMarkup($term->term_id, null, null, 25, $post_type);     
     251
     252        }
     253       
     254       
     255        public function processPlaceTag($tag, $postId=0) {
     256           
     257            global $wpdb;
     258            global $wlPlaces;
     259                       
     260            if (!$tag->wl_id)
     261                return false;
     262               
     263            $postId = intval($postId);
     264           
     265            $place = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wl_places WHERE wl_id = %s", $tag->wl_id));
     266           
     267            //there is a problem
     268            if (!$place)
     269                return false;
     270            else {
     271                $tag->place = $place;
     272                $tag->placeJSON = $place->place;
     273               
     274            }
     275           
     276            return $place;
     277
     278        }
    220279       
    221280        public function makeUniqueGoogleFontList($fontList){
     
    253312       
    254313        /**
    255          * Creates the category and sets up the theme resource folder with sample config files. Calls updateMapPostMeta().
     314         * Creates the category and sets up the theme resource folder with sample
     315         * config files. Calls updateMapPostMeta(). Does all the hard work of figuring out
     316         * what the database should look like.
    256317         *
    257318         * @return void
     
    263324            $firstTime = $now - ($now % 66400);
    264325            $this->create_category_if_not_exists( );
    265            
    266             // create places table
    267             $db_version = get_option('Welocally_DBVersion');
    268            
    269             if ($db_version != self::DB_VERSION) {
    270                 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
     326                       
     327           
     328            //never created before
     329            if (!$this->tableExists($wpdb->prefix.'wl_places')) {
     330                require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    271331               
    272332                $sql = "CREATE TABLE {$wpdb->prefix}wl_places (
    273333                    id INT PRIMARY KEY AUTO_INCREMENT,
    274334                    wl_id VARCHAR(255) NOT NULL,
    275                     place TEXT NULL,
     335                    place TEXT NULL, " .
     336                    "likes INT NULL DEFAULT 0, ".
     337                    "lat DOUBLE NULL, " .
     338                    "lng DOUBLE NULL,
    276339                    created DATETIME NOT NULL
    277340                );";
    278                 dbDelta($sql);
    279 
     341                dbDelta($sql);             
     342            }
     343           
     344            if (!$this->tableExists($wpdb->prefix.'wl_places_posts')) {
     345                require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
     346               
    280347                $sql = "CREATE TABLE {$wpdb->prefix}wl_places_posts (
    281348                    id INT PRIMARY KEY AUTO_INCREMENT,
     
    284351                    created DATETIME NOT NULL
    285352                );";
    286                 dbDelta($sql);
    287             }
    288            
    289             update_option('Welocally_DBVersion', self::DB_VERSION);
    290            
    291            
     353                dbDelta($sql);         
     354            }
     355           
     356            //version 1.2.21 and earler had places table but not geo
     357            if (!$this->columnExists($wpdb->prefix.'wl_places', 'likes')) {
     358               
     359                $sql = "ALTER TABLE {$wpdb->prefix}wl_places ".
     360                    "ADD COLUMN likes INT NULL DEFAULT 0 AFTER place";
     361
     362                $wpdb->query($sql);               
     363            }
     364           
     365            $upgrade_g1 = false;
     366            if (!$this->columnExists($wpdb->prefix.'wl_places', 'lat')) {
     367                $upgrade_g1 = true;
     368               
     369                $sql = "ALTER TABLE {$wpdb->prefix}wl_places " .
     370                        "ADD COLUMN lat DOUBLE NULL AFTER likes";
     371                $wpdb->query($sql);     
     372            }
     373       
     374            if (!$this->columnExists($wpdb->prefix.'wl_places', 'lng')) {
     375                               
     376                $upgrade_g1 = true;
     377               
     378                $sql = "ALTER TABLE {$wpdb->prefix}wl_places " .
     379                        "ADD COLUMN lng DOUBLE NULL AFTER lat";
     380               
     381                $wpdb->query($sql);
     382            }
     383           
     384            //put the latlng for all the places in the table
     385            if(true){
     386                $query = "SELECT id,place FROM {$wpdb->prefix}wl_places";
     387                $results = $wpdb->get_results($query, ARRAY_A);
     388                $count = count($results);
     389                for ($i = 0; $i < $count; $i++) {
     390                    $row = $results[$i];
     391                    $place = json_decode($row['place']);
     392                   
     393                    $lat = $place->geometry->coordinates[1];
     394                    $lng = $place->geometry->coordinates[0];
     395                   
     396                    //update row
     397                    $wpdb->update(
     398                        $wpdb->prefix.'wl_places',
     399                        array(
     400                            'lat' => $lat,  // float
     401                            'lng' => $lng   // float
     402                        ),
     403                        array( 'id' => $row['id'] ),
     404                        array(
     405                            '%s',   // value1
     406                            '%s'    // value2
     407                        ),
     408                        array( '%d' )
     409                    );
     410                                       
     411                }
     412            }
     413                           
     414        }
     415       
     416        //checks all schema changes and makes sure all is ok.
     417        public function databaseRequirementsMissing(){
     418            global $wpdb;
     419            $reqs = array();
     420            if(!$this->tableExists($wpdb->prefix.'wl_places'))
     421                array_push($reqs,'table missing '.$wpdb->prefix.'wl_places');
     422            if(!$this->tableExists($wpdb->prefix.'wl_places_posts'))
     423                array_push($reqs,'table missing '.$wpdb->prefix.'wl_places_posts');
     424            if(!$this->columnExists($wpdb->prefix.'wl_places', 'likes'))
     425                array_push($reqs,'column missing '.$wpdb->prefix.'wl_places.likes');
     426            if(!$this->columnExists($wpdb->prefix.'wl_places', 'lat'))
     427                array_push($reqs,'column missing '.$wpdb->prefix.'wl_places.lat');
     428            if(!$this->columnExists($wpdb->prefix.'wl_places', 'lng'))
     429                array_push($reqs,'column missing '.$wpdb->prefix.'wl_places.lng');
     430               
     431
     432            return $reqs;
     433                       
     434        }
     435       
     436        function showTables() {
     437            global $wpdb;
     438            $return = $wpdb->get_results("show tables", ARRAY_A);
     439            foreach ( $return as $row ) {
     440                echo("<div><pre>");
     441                echo($row["Tables_in_wordpress"]); 
     442                echo("</pre></div>");   
     443            }
     444            return $return;
     445        }
     446       
     447        function describeTable($table_name) {
     448            global $wpdb;
     449            $return = $wpdb->get_results(sprintf("describe %s",$table_name), ARRAY_A);
     450            foreach ( $return as $row ) {
     451                echo("<div><pre>");
     452                echo($row["Field"]);
     453                echo("\t"); 
     454                echo($row["Type"]);
     455                echo("</pre></div>");   
     456            }
     457            return $return;
     458        }
     459       
     460        public function tableExists($tableName){
     461            global $wpdb;
     462            $query = sprintf("SHOW TABLES LIKE '%s' ",$tableName);
     463            $result = $wpdb->get_var( $wpdb->prepare( $query ) );
     464           
     465            if($result == $tableName){
     466                return true;
     467            } else {
     468                return false;
     469            }
     470        }
     471       
     472        public function columnExists($tableName, $columnName){
     473
     474            global $wpdb;
     475            $query = sprintf("SHOW COLUMNS FROM %s LIKE '%s'",$tableName, $columnName);
     476            $result = $wpdb->get_var( $wpdb->prepare( $query ) );
     477            if($result == $columnName){
     478                return true;
     479            } else {
     480                return false;
     481            }
    292482        }
    293483
     
    320510        public function addPlaceMetaBox() {
    321511            global $post;
    322            
    323             $options = '';
    324             $style = '';
    325             $postId = $post->ID;
    326             foreach ( $this->metaTags as $tag ) {
    327                 if ( $postId ) {
    328                     $$tag = get_post_meta( $postId, $tag, true );
    329                 } else {
    330                     $$tag = '';
    331                 }
    332             }
    333            
    334             $isWLPlace = get_post_meta( $postId, '_isWLPlace', true );
    335             $ShowPlaceAddress = get_post_meta( $postId, '_ShowPlaceAddress', true );
    336            
    337             $isPlaceChecked     = ( $isWLPlace == 'true' ) ? 'checked' : '';
    338             $isNotPlaceChecked      = ( $isWLPlace == 'false' || $isWLPlace == '' || is_null(  $isWLPlace ) ) ? 'checked' : '';
    339             $PlaceSelected = get_post_meta( $postId, '_PlaceSelected', true );
    340                        
    341512            include( dirname( __FILE__ ) . '/views/addplace-meta-box.php' );
    342513        }
    343514
    344         public function replaceTagsInContent($content) {
    345             return WelocallyPlaces_Tag::searchAndReplace($content, array($this, 'addTagMarkup'));
    346         }
    347 
    348         public function addTagMarkup($tag, $str) {
    349             switch ($tag->type) {
    350                 case 'post':
    351                 default:
    352                     /* handle [welocally id="..." /] tags */
    353                     if (!$tag->id) return $str;
    354 
    355                     return $this->getPlaceMapMarkup($tag);
    356                     break;
    357                 case 'category':
    358                     /* handle [welocally categories="..." /] tag */
    359 
    360                     $categoryIds = array();
    361 
    362                     if (!$tag->categories):
    363                         $categoryIds = array(get_query_var('cat')); // fetch category from request
    364                     else:
    365                         $newcats = array();
    366                         //required for special chars
    367                         foreach ( $tag->categories as $cat ) {
    368 
    369                             //this seems rediculous to have to do
    370                             $string = preg_replace('/&(?!amp;)/', '&amp;', $cat);
    371                             $string = preg_replace('/#038;/', '', $string);
    372 
    373                             array_push($categoryIds, get_cat_ID($string));
    374                         }                   
    375 
    376                     endif;
    377 
    378                     if (!$categoryIds) return $str;
    379 
    380                     $html = '';
    381                     foreach ($categoryIds as $cat)
    382                         $html .= $this->getCategoryMapMarkup(
    383                             $cat,
    384                             dirname(__FILE__) . '/views/category-map-content-template.php',
    385                             false,
    386                             25
    387                             );
    388 
    389                     return $html;
    390 
    391                     break;
    392             }
    393         }
    394515
    395516        /**
     
    402523            global $wpdb;
    403524            static $placecount = 0;
    404            
    405             //$place = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wl_places WHERE wl_id = %s", $tag->id));
    406            
     525                       
    407526            //changing this to join so it actually must be in post places, someone please
    408527            //use your sprintf magic!
     
    473592            return $result;     
    474593       
    475 //          $places = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT place FROM {$wpdb->prefix}wl_places p"));
    476 //         
    477 //          if ($places)
    478 //              return array_map('json_decode', $places);
    479            
    480        
    481         }
    482        
    483         public function getPlaces($cat=null, $maxElements=25, $filter=true) {
     594        }
     595       
     596       
     597        /**
     598         * this takes the category name, consider consolidating getplacesnew and this
     599         */
     600        public function getPlaces($cat=null, $maxElements=25, $filter=true, $post_type='post') {
     601           
    484602           
    485603            global $post;           
     
    494612                //try to get category for post if possible
    495613                $post_categories = wp_get_post_categories( $post->ID );
    496                 if($post_categories){
    497        
     614                if($post_categories){       
    498615                    foreach ($post_categories as $postCatId) {
    499616                        $catObj = get_category( $postCatId );
     
    504621                }
    505622            }
    506 
    507             $posts = $this->getPlacePostsInCategory($cat);
     623                   
     624            $posts = $this->getPlacePostsInCategory($cat,$post_type);
    508625
    509626            $t = new StdClass();
     
    522639
    523640                foreach ($post_places as $place) {
     641                   
    524642                   
    525643                    //determin if we are filtering
     
    543661                }
    544662            }   
    545                                
     663                   
    546664            return $t;
    547665        }
     
    553671         */
    554672        public function getCategoryMapMarkup(
    555             $cat=null, $template=null, $showIfEmpty=null, $maxElements=25) {
    556            
    557            
    558             $t = $this->getPlaces($cat, $maxElements);     
     673            $cat=null, $template=null, $showIfEmpty=null, $maxElements=25, $post_type='post') {
     674           
     675           
     676            $t = $this->getPlaces($cat, $maxElements, true, $post_type);
     677               
    559678                   
    560679            //setup options
     
    583702                //this is being done so we can show all places if none are found in the cat
    584703                if($showIfEmpty && ($cat != $this->placeCategory())){
    585                     return $this->getCategoryMapMarkup($this->placeCategory(), $template, false);                   
     704                    return $this->getCategoryMapMarkup($this->placeCategory(), $template, false, $post_type);                   
    586705                } else {
    587706                    include(dirname(__FILE__) . '/views/category-map-content-empty.php');
     
    683802            }
    684803           
    685    
    686         }
    687        
    688         public function tagHandling($post_id) {
     804        }
     805
     806        /**
     807         * we do this instead of using the shortcode handler because if we didnt
     808         * we would have an extra database call on every tag hit
     809         */
     810        public function handlePublish($post_id) {           
    689811            if (!wp_is_post_revision($post_id)) {
    690812                $post = get_post($post_id);
     
    696818            }
    697819        }
     820       
    698821       
    699822       
     
    721844       
    722845            $default_marker_icon = plugins_url() . "/welocally-places/resources/images/marker_all_base.png";
    723             $default_update_places = 'off';
    724846           
    725847            $default_show_letters = 'on';
     
    733855            $default_show_selection_tag = 'on';         
    734856            $default_infobox_title_link_tag = 'on';
     857           
     858            $default_widget_post_type = 'post';
     859                       
    735860                   
    736861            // Set current version level. Because this can be used to detect version changes (and to what extent), this
     
    745870            if ( !array_key_exists( 'show_selection', $options ) ) { $options[ 'show_selection' ] = $default_show_selection; $changed = true; }
    746871            if ( !array_key_exists( 'infobox_title_link', $options ) ) { $options[ 'infobox_title_link' ] = $default_infobox_title_link; $changed = true; }
     872            if ( !array_key_exists( 'widget_post_type', $options ) ) { $options[ 'widget_post_type' ] = $default_widget_post_type; $changed = true; }
    747873                   
    748874            //tag
     
    9441070            global $wpdb, $wlPlaces;
    9451071            $wlPlaces->setOptions();
     1072           
     1073            $post_type = explode(",",$post_type);
    9461074
    9471075            $post_type_and = '1=1';
     
    9651093                                    ON $wpdb->posts.ID = {$wpdb->prefix}wl_places_posts.post_id
    9661094                                    GROUP BY $wpdb->posts.ID)";
     1095           
    9671096
    9681097            $return = $wpdb->get_results($categories_query, OBJECT);
     
    9711100       
    9721101        public function generatePlaceId($lat,$lng) {
    973             //WL_10RyqzlSSjAd gMCImmeXYj_37.801379_-122.263600@1303263345
    9741102            $guid = substr(uniqid().uniqid(), 0, 22);
    9751103            $parts = explode(" ", microtime());
  • welocally-places/trunk/welocally-places.php

    r544571 r548366  
    22
    33/*
    4 Plugin Name: Welocally Places Basic
     4Plugin Name: Welocally Places Core
    55Plugin URI: http://www.welocally.com/wordpress/?page_id=2
    6 Description: Great maps that link to your content. The Welocally Places plugin lets easily associate places to your content without manual geocoding. Add any place to your database and link it to your posts and categories with simple shortcodes. The map widget makes it easy for your users to find the places your are writing about on a map and is smart enough to automatically relate places by category.
    7 Version: 1.2.21
     6Description: Great maps that link to your content. The Welocally Places plugin lets easily associate places to your content without manual geocoding. Add any place to your database and link it to your posts and categories with simple shortcodes. The map widget makes it easy for your users to find the places your are writing about on a map and is smart enough to automatically relate places by category. If you are upgrading and an install this manually make sure to re-activate the plugin, activation does important database updates.
     7Version: 1.2.22
    88Author: Welocally 
    99Author URI: http://welocally.com
     
    6868}
    6969
     70/**
     71 * consider moving core impl to the class
     72 */
    7073function welocally_save_place() {
    7174   
     
    8285        $mysqldate = date( 'Y-m-d H:i:s', time() );
    8386        $placeToSave['_id'] = $wlPlaces->generatePlaceId($placeToSave['geometry']['coordinates'][1],$placeToSave['geometry']['coordinates'][0]);
    84    
     87                   
    8588            //save to places table
    8689        if ($wpdb->insert("{$wpdb->prefix}wl_places",
    87             array('wl_id' => $placeToSave['_id'], 'place' => json_encode($placeToSave), 'created' =>$mysqldate )) ) {
     90            array('wl_id' => $placeToSave['_id'], 'place' => json_encode($placeToSave), 'lat' =>  $placeToSave['geometry']['coordinates'][1], 'lng' =>  $placeToSave['geometry']['coordinates'][0], 'created' =>$mysqldate )) ) {
    8891                $place = $wpdb->get_row(
    8992                $wpdb->prepare("SELECT * FROM {$wpdb->prefix}wl_places WHERE wl_id = %s", $placeToSave['_id']) );
     
    9598       
    9699        $placeId = $placeToSave['_id'];
    97         $statement = "UPDATE {$wpdb->prefix}wl_places SET place='".json_encode($placeToSave)."' WHERE wl_id = '".$placeId."'";
     100        $placeJSON = addslashes(json_encode($placeToSave));
     101       
     102        $statement = "UPDATE {$wpdb->prefix}wl_places SET place='".$placeJSON."' WHERE wl_id = '".$placeId."'";
    98103        $wpdb->query($wpdb->prepare($statement));
     104       
     105        echo '{ "id": "'.$placeToSave['_id'].'"}';
    99106    }   
    100107
     
    157164    global $wpdb, $wlPlaces;
    158165
    159     $placeId = $_POST['wl_id'];
     166    //$placeId = $_POST['wl_id'];
    160167    $recordId = $_POST['id'];
    161     $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}wl_places WHERE wl_id = %s", $placeId));
     168    $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}wl_places WHERE id = %d", $recordId));
    162169       
    163170    echo '{ "id":'.$recordId.',"status": "SUCCEED", "action": "DELETE" }';
Note: See TracChangeset for help on using the changeset viewer.