Skip to content

Commit

Permalink
Merge branch 'release/2.2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
jensstalder committed Mar 15, 2017
2 parents 4e3f3c5 + e073700 commit babe270
Show file tree
Hide file tree
Showing 27 changed files with 1,055 additions and 670 deletions.
17 changes: 16 additions & 1 deletion README.txt
Expand Up @@ -7,7 +7,7 @@ Tested up to: 4.3.1
Author: Casasoft AG
Author URI: https://casasoft.ch
License: GPL2
Stable tag: 2.2.3
Stable tag: 2.2.4

Import your properties directly from your real-estate management software!

Expand Down Expand Up @@ -38,6 +38,21 @@ Please refer to casasoft.ch[https://casasoft.ch/casagateway] for further instruc

== Changelog ==

= 2.2.4 =
* new: multiple OR kriterias for shortcode integrations
* new: BETA Ajax based archive filtering
* fix: resolved some legacy linking issues
* fix: CASAMAIL project_reference
* fix: Contact Form optional required fields
* fix: CASAMAIL offer mixup
* new: order by modified
* fix: Hiding custom categories works again
* fix: Main language installs other than German will work better now
* new: custom sorting based on import order
* update: updated the casasoft standard-modules
* new: custom field support with import


= 2.2.3 =
* fix: new CASMAIL domain service@casamail.com

Expand Down
4 changes: 2 additions & 2 deletions casawp.php
Expand Up @@ -5,7 +5,7 @@
* Description: Import your properties directly from your real-estate managment software!
* Author: Casasoft AG
* Author URI: https://casasoft.ch
* Version: 2.2.3
* Version: 2.2.4
* Text Domain: casawp
* Domain Path: languages/
* License: GPL2
Expand All @@ -15,7 +15,7 @@

//update system
require_once ( 'wp_autoupdate.php' );
$plugin_current_version = '2.2.3';
$plugin_current_version = '2.2.4';
$plugin_slug = plugin_basename( __FILE__ );
$plugin_remote_path = 'http://wp.casasoft.ch/casawp/update.php';
$license_user = 'user';
Expand Down
102 changes: 98 additions & 4 deletions classes/Import.php
Expand Up @@ -876,7 +876,12 @@ public function setOfferCategories($wp_post, $categories, $customCategories, $ca
$custom_categorylabels = array();
if (isset($customCategories)) {
foreach ($customCategories as $custom) {
$custom_categorylabels[$custom['slug']] = $custom['label'];
if (isset($custom['label'])) {
$custom_categorylabels[$custom['slug']] = $custom['label'];
} else {
$custom_categorylabels[$custom['slug']] = $custom['slug'];
}

}
}

Expand All @@ -887,6 +892,7 @@ public function setOfferCategories($wp_post, $categories, $customCategories, $ca
}

//add the new ones
$connect_term_ids = array();
$category_terms = get_terms( array('casawp_category'), array('hide_empty' => false));
foreach ($category_terms as $term) {
if (in_array($term->slug, $new_categories)) {
Expand Down Expand Up @@ -1597,7 +1603,12 @@ public function updateOffers(){
$xml = simplexml_load_file($this->getImportFile(), 'SimpleXMLElement', LIBXML_NOCDATA);

$found_posts = array();
//key is id value is rank!!!!
$ranksort = array();
$curRank = 0;
foreach ($xml->properties->property as $property) {
$curRank++;

$propertyData = $this->property2Array($property);
//make main language first and "single out" if not multilingual
$theoffers = array();
Expand Down Expand Up @@ -1641,6 +1652,7 @@ public function updateOffers(){
$the_post['post_content'] = 'unsaved property';
$the_post['post_status'] = 'publish';
$the_post['post_type'] = 'casawp_property';
$the_post['menu_order'] = $curRank;
$the_post['post_name'] = sanitize_title_with_dashes($casawp_id . '-' . $offerData['name'],'','save');

//use the casagateway creation date if its new
Expand All @@ -1653,6 +1665,9 @@ public function updateOffers(){
$wp_post = get_post($insert_id, OBJECT, 'raw');
$this->addToLog('new property: '. $casawp_id);
}

$ranksort[$wp_post->ID] = $curRank;

$found_posts[] = $wp_post->ID;

$this->updateOffer($casawp_id, $offer_pos, $propertyData, $offerData, $wp_post);
Expand All @@ -1661,10 +1676,10 @@ public function updateOffers(){
}
}

//3. remove all the unused properties
if ($found_posts) {

if ($found_posts) {

//3. remove all the unused properties
$properties_to_remove = get_posts( array(
'suppress_filters'=>true,
'language'=>'ALL',
Expand Down Expand Up @@ -1693,6 +1708,33 @@ public function updateOffers(){

}

//4. set property menu_order
$properties_to_sort = get_posts( array(
'suppress_filters'=>true,
'language'=>'ALL',
'numberposts' => 100,
'include' => $found_posts,
'post_type' => 'casawp_property',
'post_status' => 'publish'
)
);
$sortsUpdated = 0;
foreach ($properties_to_sort as $prop_to_sort) {
if (array_key_exists($prop_to_sort->ID, $ranksort)) {
if ($prop_to_sort->menu_order != $ranksort[$prop_to_sort->ID]) {
$sortsUpdated++;
$newPostID = wp_update_post(array(
'ID' => $prop_to_sort->ID,
'menu_order' => $ranksort[$prop_to_sort->ID]
));

}

}

}

$this->transcript['sorts_updated'] = $sortsUpdated;
$this->transcript['properties_found_in_xml'] = count($found_posts);
$this->transcript['properties_removed'] = count($properties_to_remove);
} else{
Expand Down Expand Up @@ -1854,6 +1896,9 @@ public function updateProject($sort, $casawp_id, $projectData, $wp_post, $parent
//set new hash;
$new_meta_data['last_import_hash'] = $curImportHash;

//set referenceId
$new_meta_data['last_import_hash'] = $projectData['referenceId'];



/* main post data */
Expand Down Expand Up @@ -2080,7 +2125,7 @@ public function updateOffer($casawp_id, $offer_pos, $property, $offer, $wp_post)
'post_status' => 'publish',
'post_type' => 'casawp_property',
'post_excerpt' => $offer['excerpt'],
'post_date' => $wp_post->post_date
'post_date' => $wp_post->post_date,
//'post_date' => ($property['creation'] ? $property['creation']->format('Y-m-d H:i:s') : $property['last_update']->format('Y-m-d H:i:s')),
/*'post_modified' => $property['last_update']->format('Y-m-d H:i:s'),*/
);
Expand Down Expand Up @@ -2309,6 +2354,55 @@ public function updateOffer($casawp_id, $offer_pos, $property, $offer, $wp_post)
//$new_meta_data = array_merge($new_meta_data, $integratedOffers);


//custom option metas
$custom_metas = array();
foreach ($publisher_options as $key => $value) {
if (strpos($key, 'custom_option') === 0) {
$parts = explode('_', $key);
$sort = (isset($parts[2]) && is_numeric($parts[2]) ? $parts[2] : false);
$meta_key = (isset($parts[3]) && $parts[3] == 'key' ? true : false);
$meta_value = (isset($parts[3]) && $parts[3] == 'value' ? true : false);

if ($meta_key) {
foreach ($publisher_options as $key2 => $value2) {
if (strpos($key2, 'custom_option') === 0) {
$parts2 = explode('_', $key2);
$sort2 = (isset($parts2[2]) && is_numeric($parts2[2]) ? $parts2[2] : false);
$meta_key2 = (isset($parts2[3]) && $parts2[3] == 'key' ? true : false);
$meta_value2 = (isset($parts2[3]) && $parts2[3] == 'value' ? true : false);
if ($meta_value2 && $sort2 == $sort) {
$custom_metas[$value[0]] = $value2[0];
break;
}
}
}
} elseif ($meta_value) {
foreach ($publisher_options as $key2 => $value2) {
if (strpos($key2, 'custom_option') === 0) {
$parts2 = explode('_', $key2);
$sort2 = (isset($parts2[2]) && is_numeric($parts2[2]) ? $parts2[2] : false);
$meta_key2 = (isset($parts2[3]) && $parts2[3] == 'key' ? true : false);
$meta_value2 = (isset($parts2[3]) && $parts2[3] == 'value' ? true : false);
if ($meta_key2 && $sort2 == $sort) {
$custom_metas[$value2[0]] = $value[0];
break;
}
}
}
}
}
}

if ($custom_metas) {
$this->addToLog('_options_================HERE====================');
$this->addToLog('_options_' . print_r($custom_metas, true));
}

foreach ($custom_metas as $key => $value) {
$new_meta_data['custom_option_'.$key] = $value;
$this->addToLog('custom_option_'.$key);
}

foreach ($new_meta_data as $key => $value) {
/* if (!$value) {
unset($new_meta_data[$key]);
Expand Down
21 changes: 16 additions & 5 deletions classes/Plugin.php
Expand Up @@ -702,13 +702,24 @@ public function getCategories(){

$unknown_category->setLabel($unknown_category->getKey());

$hidden = true;

foreach ($c_trans as $key => $trans) {
if ($key == $category_term->slug && array_key_exists($lang, $trans)) {
$unknown_category->setLabel($trans[$lang]);

if ($key == $category_term->slug) {
if (array_key_exists($lang, $trans)) {
$unknown_category->setLabel($trans[$lang]);
}

if (isset($c_trans[$category_term->slug]['show']) && $c_trans[$category_term->slug]['show']) {

$hidden = false;
}
}
}

$categories[] = $unknown_category;
if (!$hidden) {
$categories[] = $unknown_category;
}
}
}

Expand Down Expand Up @@ -1881,7 +1892,7 @@ public function setPostTypes(){
'rewrite' => array( 'slug' => 'immobilien' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'hierarchical' => true,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'custom-fields', 'page-attributes', 'revisions' ),
'menu_icon' => 'dashicons-admin-home',
Expand Down

0 comments on commit babe270

Please sign in to comment.