Changeset 3200723
- Timestamp:
- 12/02/2024 09:03:52 AM (15 months ago)
- Location:
- local-magic
- Files:
-
- 10 edited
-
tags/2.5.0/activate.php (modified) (5 diffs)
-
tags/2.5.0/admin/setting.php (modified) (9 diffs)
-
tags/2.5.0/include/function.php (modified) (8 diffs)
-
tags/2.5.0/local-magic.php (modified) (30 diffs)
-
tags/2.5.0/readme.txt (modified) (2 diffs)
-
trunk/activate.php (modified) (5 diffs)
-
trunk/admin/setting.php (modified) (9 diffs)
-
trunk/include/function.php (modified) (8 diffs)
-
trunk/local-magic.php (modified) (30 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
local-magic/tags/2.5.0/activate.php
r3199499 r3200723 54 54 lm_multi_head text CHARACTER SET utf8 NULL, 55 55 lm_multi_near_me text CHARACTER SET utf8 NULL, 56 lm_is_topic tinyint(1) DEFAULT '0',57 lm_types varchar(20) CHARACTER SET utf8 DEFAULT 'single-type',58 56 PRIMARY KEY (id) 59 57 );"; … … 89 87 lm_assisted_living TEXT CHARACTER SET utf8 NULL, 90 88 lm_restaurant TEXT CHARACTER SET utf8 NULL, 91 lm_topics TEXT CHARACTER SET utf8 NULL,92 lm_type varchar(50) CHARACTER SET utf8 NULL,93 lm_is_default varchar(100) CHARACTER SET utf8 NULL,94 lm_other_info TEXT CHARACTER SET utf8 NULL,95 lm_neighbour_id int(11) NULL,96 89 PRIMARY KEY (id) 97 90 );"; … … 202 195 ;"; 203 196 $wpdb->query($setting_alter_sql_3); 204 205 } 206 } 207 208 //V 2.3 209 if ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $mrylm_setting_table)) === $mrylm_setting_table) { 210 211 $setting_table_exist_4 = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS 212 WHERE table_name = '$mrylm_setting_table' AND column_name = 'lm_is_topic'"); 213 if (empty($setting_table_exist_4)) { 214 $setting_alter_sql_4 = "ALTER TABLE {$wpdb->prefix}mrylm_setting 215 ADD `lm_is_topic` tinyint(1) NULL DEFAULT '0' AFTER `lm_multi_near_me` 216 ;"; 217 $wpdb->query($setting_alter_sql_4); 218 219 } 220 221 $setting_table_exist_5 = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS 222 WHERE table_name = '$mrylm_setting_table' AND column_name = 'lm_types'"); 223 if (empty($setting_table_exist_5)) { 224 $setting_alter_sql_5 = "ALTER TABLE {$wpdb->prefix}mrylm_setting 225 ADD `lm_types` VARCHAR(30) NULL DEFAULT 'single-type' AFTER `lm_is_topic` 226 ;"; 227 $wpdb->query($setting_alter_sql_5); 228 229 } 197 } 230 198 } 231 199 … … 277 245 $wpdb->query($cities_alter_sql_2); 278 246 } 279 280 281 $cities_table_exist_3 = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS282 WHERE table_name = '$mrylm_cities_table' AND column_name = 'lm_topics'");283 if (empty($cities_table_exist_3)) {284 $cities_alter_sql_3 = "ALTER TABLE {$wpdb->prefix}mrylm_cities285 ADD `lm_topics` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `lm_restaurant`286 ;";287 $wpdb->query($cities_alter_sql_3);288 }289 290 $cities_table_exist_4 = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS291 WHERE table_name = '$mrylm_cities_table' AND column_name = 'lm_type'");292 if (empty($cities_table_exist_4)) {293 $cities_alter_sql_4 = "ALTER TABLE {$wpdb->prefix}mrylm_cities294 ADD `lm_type` VARCHAR(30) NULL AFTER `lm_topics`295 ;";296 $wpdb->query($cities_alter_sql_4);297 }298 299 300 // city last update301 $cities_table_exist_5 = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS302 WHERE table_name = '$mrylm_cities_table' AND column_name = 'lm_is_default'");303 if (empty($cities_table_exist_5)) {304 $cities_alter_sql_5 = "ALTER TABLE {$wpdb->prefix}mrylm_cities305 ADD `lm_is_default` tinyint(1) NULL DEFAULT '0' AFTER `lm_type`,306 ADD `lm_other_info` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `lm_is_default`307 ;";308 $wpdb->query($cities_alter_sql_5);309 }310 311 // city last 2 update312 $cities_table_exist_6 = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS313 WHERE table_name = '$mrylm_cities_table' AND column_name = 'lm_neighbour_id'");314 if (empty($cities_table_exist_6)) {315 $cities_alter_sql_6 = "ALTER TABLE {$wpdb->prefix}mrylm_cities316 ADD `lm_neighbour_id` int(11) NULL DEFAULT '0' AFTER `lm_other_info`317 ;";318 $wpdb->query($cities_alter_sql_6);319 }320 321 247 } 322 248 323 249 mrylm_create_tables(); 324 325 250 } 326 251 327 // OK328 function create_lm_page($lm_setting, $lm_city, $lm_page_url, $lm_post_ID = NULL){329 330 global $wpdb;331 332 // now we will create page for each city333 $lm_parent_post_id = url_to_postid($lm_page_url);334 335 $lm_post_id = $lm_post_ID > 0 ? $lm_post_ID : url_to_postid($lm_page_url.$lm_city->lm_url_slug);336 337 if($lm_city->lm_parent_id > 0){338 $lm_sql = "SELECT * FROM {$wpdb->prefix}mrylm_cities WHERE lm_city_id = '$lm_city->lm_parent_id'";339 $lm_city_2 = $wpdb->get_row($lm_sql);340 $lm_parent_post_id = url_to_postid($lm_page_url.$lm_city_2->lm_url_slug);341 }342 343 // If there are no sub page then we hv to parent post id 0344 if ($lm_setting->lm_page_type == 'base_page') {345 $lm_parent_post_id = 0;346 }347 348 $mrylm_post = array(349 'ID'=> $lm_post_id,350 'post_title' => $lm_city->lm_city,351 'post_name' => $lm_city->lm_slug,352 'post_content' => '',353 'post_status' => 'publish',354 'post_type' => 'page',355 'post_parent' => $lm_parent_post_id,356 'post_author' => 1,357 'post_category' => array()358 );359 360 361 //Insert the post into the database362 $lm_insert_id = $lm_post_id > 0 ? wp_update_post($mrylm_post) : wp_insert_post( $mrylm_post );363 364 // to set template for the page365 if ( ! add_post_meta( $lm_insert_id, '_wp_page_template', 'local-magic.php', true )) {366 update_post_meta( $lm_insert_id, '_wp_page_template', 'local-magic.php' );367 }368 369 return $lm_insert_id;370 }371 372 // OK373 function create_lm_topic_pages($lm_parent_post_id, $lm_setting, $lm_city_obj){374 375 376 if($lm_setting->lm_is_topic && $lm_city_obj->lm_topics != ''){377 378 $topic_arr = explode('=',$lm_city_obj->lm_topics);379 380 if(is_array($topic_arr)){381 foreach($topic_arr AS $topic){382 383 $data_arr = explode('|', $topic);384 if(is_array($data_arr)){385 386 // $lm_setting->lm_page_url == same as org_url + url type387 $lm_post_id = url_to_postid($lm_setting->lm_page_url.$lm_city_obj->lm_url_slug.'/'.$data_arr[0]);388 389 $mrylm_post = array(390 'ID'=> $lm_post_id,391 'post_title' => $data_arr[1],392 'post_name' => $data_arr[0],393 'post_content' => '',394 'post_status' => 'publish',395 'post_type' => 'page',396 'post_parent' => $lm_parent_post_id,397 'post_author' => 1,398 'post_category' => array()399 );400 401 // $lm_insert_id = wp_insert_post( $mrylm_post );402 $lm_insert_id = $lm_post_id > 0 ? wp_update_post($mrylm_post) : wp_insert_post( $mrylm_post );403 // to set template for the page404 if ( ! add_post_meta( $lm_insert_id, '_wp_page_template', 'local-magic.php', true )) {405 update_post_meta( $lm_insert_id, '_wp_page_template', 'local-magic.php' );406 }407 }408 }409 }410 }411 }412 413 // OK414 function delete_lm_topic_pages($lm_topics, $lm_page_url) {415 416 if ($lm_topics != '') {417 418 $topic_arr = explode('=',$lm_topics);419 420 if (is_array($topic_arr)) {421 422 foreach ($topic_arr AS $topic) {423 424 $data_arr = explode('|', $topic);425 426 if (is_array($data_arr)) {427 $postid = url_to_postid($lm_page_url . '/'.$data_arr[0]);428 if ($postid) {429 wp_delete_post($postid, true);430 }431 }432 }433 }434 }435 }436 437 // OK438 252 function create_service_area_page($lm_setting) { 439 253 … … 453 267 'post_type' => 'page', 454 268 'post_parent' => 0, 455 'post_author' => 1,456 269 'post_category' => array() 457 270 ); -
local-magic/tags/2.5.0/admin/setting.php
r3199499 r3200723 8 8 $mrylm_msg = ""; 9 9 10 11 function get_multi_type_formatted_data($multi_type_data = null){12 13 $array_data = array();14 $text_data = json_decode($multi_type_data, true);15 $array = explode('|', $text_data);16 foreach($array as $value){17 18 $arr = explode('=>', $value);19 $array_data[$arr[0]] = $arr[1];20 }21 22 return $array_data;23 }24 25 10 function mrylm_check_key_format($mrylm_key){ 26 11 … … 36 21 } 37 22 23 function get_multi_type_formatted_data($multi_type_data = null){ 24 25 $array_data = array(); 26 $text_data = json_decode($multi_type_data, true); 27 $array = explode('|', $text_data); 28 foreach($array as $value){ 29 30 $arr = explode('=>', $value); 31 $array_data[$arr[0]] = $arr[1]; 32 } 33 34 return $array_data; 35 } 36 37 function create_lm_pages($lm_setting, $lm_city, $lm_page_url){ 38 39 global $wpdb; 40 41 // now we will create page for each city 42 $lm_parent_post_id = url_to_postid($lm_page_url); 43 $lm_post_id = url_to_postid($lm_page_url.$lm_city->lm_url_slug); 44 45 if($lm_city->lm_parent_id > 0){ 46 $lm_sql = "SELECT * FROM {$wpdb->prefix}mrylm_cities WHERE lm_city_id = '$lm_city->lm_parent_id'"; 47 $lm_city_2 = $wpdb->get_row($lm_sql); 48 $lm_parent_post_id = url_to_postid($lm_page_url.$lm_city_2->lm_url_slug); 49 } 50 51 // If there are no sub page then we hv to parent post id 0 52 if ($lm_setting->lm_page_type == 'base_page') { 53 $lm_parent_post_id = 0; 54 } 55 56 $mrylm_post = array( 57 'ID'=> $lm_post_id, 58 'post_title' => $lm_city->lm_city, 59 'post_content' => '', 60 'post_status' => 'publish', 61 'post_type' => 'page', 62 'post_parent' => $lm_parent_post_id, 63 'post_category' => array() 64 ); 65 66 //Insert the post into the database 67 $lm_insert_id = wp_insert_post( $mrylm_post ); 68 69 // to set template for the page 70 if ( ! add_post_meta( $lm_insert_id, '_wp_page_template', 'local-magic.php', true )) { 71 update_post_meta( $lm_insert_id, '_wp_page_template', 'local-magic.php' ); 72 } 73 } 74 75 38 76 function mrylm_process_pages(){ 39 77 … … 45 83 if($lm_setting->lm_url_type == 'wp_remote_get'){ 46 84 $mrylm_response = wp_remote_get('https://localmagic.reviewmanager.app/plugin/cities/' . $lm_setting->lm_unique_id); 47 $mrylm_cities = json_decode($mrylm_response['body']); 85 $mrylm_cities = json_decode($mrylm_response['body']); 86 48 87 }else{ 49 88 $mrylm_response = file_get_contents('https://localmagic.reviewmanager.app/plugin/cities/' . $lm_setting->lm_unique_id); … … 51 90 } 52 91 53 if(!empty($mrylm_cities)){92 if(!empty($mrylm_cities)){ 54 93 55 94 // Trancating existing Cities table … … 86 125 'lm_historic_landmark' => $obj->historic_landmark, 87 126 'lm_assisted_living' => $obj->assisted_living, 88 'lm_restaurant' => $obj->restaurant, 89 'lm_topics' => $obj->topics, 90 'lm_type' => $obj->lm_type, 91 'lm_is_default' => $obj->is_default, 92 'lm_other_info' => $obj->other_info, 93 'lm_neighbour_id' => $obj->neighbour_id 127 'lm_restaurant' => $obj->restaurant 94 128 ); 95 129 … … 99 133 $lm_city = array(); 100 134 $lm_city['lm_parent_id'] = $obj->parent_id; 101 $lm_city['lm_type'] = $obj->lm_type;102 $lm_city['lm_slug'] = $obj->slug;103 135 $lm_city['lm_url_slug'] = $obj->url_slug; 104 136 $lm_city['lm_city'] = $obj->city; 105 $lm_city['lm_topics'] = $obj->topics;106 137 $lm_obj_city = (object) $lm_city; 107 138 108 139 // need to process multi type 109 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != '' && $lm_setting->lm_types == 'multi-type'){140 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != ''){ 110 141 111 142 $lm_multi_titles = get_multi_type_formatted_data($lm_setting->lm_multi_title); … … 113 144 114 145 $lm_page_url = $lm_setting->lm_org_url.$key.'/'; 115 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_page_url); 116 $lm_setting->lm_page_url = $lm_page_url; 117 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 146 create_lm_pages($lm_setting, $lm_obj_city, $lm_page_url); 118 147 } 119 148 120 }else if($lm_setting->lm_types == 'type-wise'){ 121 122 if($lm_obj_city->lm_type){ 123 $lm_page_url = $lm_setting->lm_org_url.$lm_obj_city->lm_type.'/'; 124 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_page_url); 125 $lm_setting->lm_page_url = $lm_page_url; 126 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 127 } 128 129 }else{ // single type city 130 131 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_setting->lm_page_url); 132 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 149 }else{ 150 create_lm_pages($lm_setting, $lm_obj_city, $lm_setting->lm_page_url); 133 151 } 134 152 } … … 140 158 } 141 159 } 160 142 161 143 162 if (isset($_POST['submit']) && is_user_logged_in()) { … … 226 245 'lm_multi_keyword' => $lm_setting->multi_keyword, 227 246 'lm_multi_head' => $lm_setting->multi_head, 228 'lm_multi_near_me' => $lm_setting->multi_near_me, 229 'lm_is_topic' => $lm_setting->is_topic, 230 'lm_types' => $lm_setting->lm_types 247 'lm_multi_near_me' => $lm_setting->multi_near_me 231 248 ); 232 249 -
local-magic/tags/2.5.0/include/function.php
r3199499 r3200723 9 9 } 10 10 11 12 11 function get_multi_type_data($multi_type_data = null){ 13 12 … … 24 23 } 25 24 26 27 25 function mrylm_get_city(){ 28 26 29 27 global $wpdb; 28 29 $url = get_permalink(); 30 $arr = explode('/', trim($url, '/')); 31 $slug = end($arr); 32 $prev = prev($arr); 33 34 $full_slug = $prev.'/'.$slug; 30 35 31 36 $lm_setting_sql = "SELECT * FROM {$wpdb->prefix}mrylm_setting"; 32 37 $lm_setting = $wpdb->get_row($lm_setting_sql); 33 34 $url = get_permalink();35 $arr = explode('/', trim($url, '/'));36 37 $slug = end($arr);38 $prev = prev($arr);39 $lm_type = ''; //$arr[4];40 41 42 // This [4] is depends on url format43 if($lm_setting->lm_is_topic){44 if(count($arr) > 4){ // there are topic45 $slug = $arr[4];46 }47 }48 49 38 if ($lm_setting->lm_org_url == $url) { 50 $ slug = $lm_setting->lm_default_city;39 $full_slug = $lm_setting->lm_default_city; 51 40 } 52 41 53 $lm_sql = "SELECT * FROM {$wpdb->prefix}mrylm_cities WHERE lm_slug = '$slug'"; 54 if($lm_type){ 55 $lm_sql = "SELECT * FROM {$wpdb->prefix}mrylm_cities WHERE lm_slug = '$slug' AND lm_type = '$lm_type'"; 42 $lm_sql = "SELECT * FROM {$wpdb->prefix}mrylm_cities WHERE lm_url_slug = '$full_slug'"; 43 $lm_city = $wpdb->get_row($lm_sql); 44 45 if(empty($lm_city)){ 46 $lm_sql = "SELECT * FROM {$wpdb->prefix}mrylm_cities WHERE lm_url_slug = '$slug'"; 47 $lm_city = $wpdb->get_row($lm_sql); 56 48 } 57 $lm_city = $wpdb->get_row($lm_sql);58 49 59 50 return $lm_city; … … 311 302 312 303 $content = file_get_contents($lm_setting->lm_template_other_path.'/lm-'.$url_slug.'-content.php'); 313 } 314 315 316 // Widget Part 317 if($lm_setting->lm_is_topic && $lm_city->lm_topics != ''){ 318 319 $topic_widget = ''; 320 $topic_arr = json_decode($lm_city->lm_topics); 321 322 if(is_array($topic_arr)){ 323 foreach($topic_arr AS $topic){ 324 $data_arr = explode('|', $topic); 325 $topic_url = $lm_setting->lm_page_url . $lm_city->lm_url_slug . '/' .$data_arr[0]; 326 $topic_widget .= '<a class="btn lm-hero-btn" href="'.$topic_url.'"><span>'.$data_arr[1].'</span></a>'; 327 } 328 } 329 330 if($topic_widget != ''){ 331 $content = str_replace('TOPIC_WIDGET', $topic_widget, $content); 332 }else{ 333 $content = str_replace('TOPIC_WIDGET', '', $content); 334 } 335 336 } 337 // URL CUSTOM END 338 339 340 341 // process POI widget 342 if($lm_setting->lm_is_point_of_interest){ 343 344 345 $poi_data = mrylm_poi($type = ''); 346 $content = str_replace('POI_FEED', $poi_data, $content); 347 348 } 349 304 } 350 305 351 306 … … 406 361 $reviews = mrylm_review_testimonial($lm_city); 407 362 $content = str_replace('REVIEW_FEED', $reviews, $content); 408 363 364 365 // process POI widget 366 if($lm_setting->lm_is_point_of_interest){ 367 $poi_data = mrylm_poi($type = ''); 368 $content = str_replace('POI_FEED', $poi_data, $content); 369 } 370 409 371 return $content; 410 372 … … 484 446 485 447 // Set img title and alt attributes 486 $title_text = ucwords( trim($img_keyword_arr[$counter]).' '.$city.', '.$state);448 $title_text = ucwords($img_keyword_arr[$counter].' '.$city.', '.$state); 487 449 $image->setAttribute('alt', $title_text); 488 450 $image->setAttribute('title', $title_text); … … 700 662 // get news data as per keyword 701 663 $lm_news = mrylm_get_news_list($lm_setting, $lm_city); 702 $data .= mrylm_get_list_data($lm_setting, $lm_news, $lm_city); 703 664 665 if($lm_setting->lm_display_type == 'list'){ 666 $data .= mrylm_get_list_data($lm_setting, $lm_news, $lm_city); 667 }else if($lm_setting->lm_display_type == 'accordion'){ 668 $data .= mrylm_get_accordion_data($lm_setting, $lm_news, $lm_city); 669 } 704 670 705 671 $style = '<style>'; … … 832 798 } 833 799 800 function mrylm_get_accordion_data($lm_setting, $lm_news, $lm_city){ 801 802 $separator = 'in'; 803 $data = ''; 804 805 $data .= '<div class="lm-accordion-container">'; 806 807 if(isset($lm_news) && !empty($lm_news)){ 808 809 $data .= '<h2 class="lm-widget-title">'.$lm_setting->lm_head_line.' '.$separator.' '. $lm_city->lm_city .', '. $lm_city->lm_state .'</h2>'; 810 811 // foreach start 812 $data .= '<div class="lm-accordion-inner">'; 813 814 foreach($lm_news as $obj){ 815 816 $detail = trim(preg_replace("/<figure[^>]*>(.+?)<\/figure>/", "", $obj->lm_news)); 817 $detail = trim(preg_replace("/<iframe[^>]*>(.+?)<\/iframe>/", "", $detail)); 818 $detail = trim(preg_replace("/<img[^>]*>(.+?)<\/img>/", "", $detail)); 819 $detail = preg_replace('/(<a\b[^><]*)>/i', '$1 rel="nofollow;" target="_blank">',$detail); 820 821 $active = 'none;'; 822 $active_class = ''; 823 824 if($key == 0){$active_class = 'lm-active'; $active = 'block;'; } 825 826 $author = $obj->lm_author ? $obj->lm_author : $obj->lm_source; 827 $source = $obj->lm_source ? $obj->lm_source : $lm_setting->lm_org_name; 828 829 $data .= '<div class="lm-accordion-item" itemscope itemtype="http://schema.org/NewsArticle">'; 830 $data .= '<meta itemscope itemprop="mainEntityOfPage" itemType="https://schema.org/WebPage" itemid="'.$obj->lm_detail_url.'"/>'; 831 $data .= '<h2 class="lm-accordion-title '.$active_class.'" itemprop="headline">'.$obj->lm_title.'</h2>'; 832 $data .= '<h3 style="display:none;" itemprop="author" itemscope itemtype="https://schema.org/Person">'; 833 $data .= '<span itemprop="name">'.$author.'</span>'; 834 $data .= '<span itemprop="url">'.$obj->lm_detail_url.'</span>'; 835 $data .= '</h3>'; 836 $data .= '<div class="lm-accordion-content" style="display:'.$active.'">'; 837 $data .= '<div class="lm-read-less"><p>'. strip_tags(substr($detail, 0, 550)). '...</p></div>'; 838 $data .= '<div class="lm-read-more" itemprop="description">'. $detail. '</div>'; 839 $data .= '<button class="lm-btn">Read more</button>'; 840 $data .= '</div>'; 841 842 $data .= '<div itemprop="image" itemscope itemtype="https://schema.org/ImageObject"> 843 <meta itemprop="url" content="'.$lm_setting->lm_org_logo_url.'"> 844 </div>'; 845 $data .= '<div itemprop="publisher" itemscope itemtype="https://schema.org/Organization"> 846 <div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject"> 847 <meta itemprop="url" content="'.$lm_setting->lm_org_logo_url.'"> 848 </div> 849 <meta itemprop="name" content="'.$source.'"> 850 </div>'; 851 $data .= '<meta itemprop="datePublished" content="'.date('Y-m-d H:i:s', strtotime($obj->lm_created_at)).'"/>'; 852 $data .= '<meta itemprop="dateModified" content="'.date('Y-m-d H:i:s', strtotime($obj->lm_updated_at)).'"/>'; 853 854 $data .= '</div>'; 855 } 856 857 $data .= '</div>'; 858 859 }else{ 860 $data .= ''; '<div class="news-block">No news data found.</div>'; 861 } 862 863 $data .= '</div>'; 864 865 return $data; 866 867 } 868 834 869 function mrylm_review_testimonial($lm_city = null){ 835 870 … … 1405 1440 1406 1441 /* Job End */ 1442 1407 1443 1408 1444 /* POI Start */ -
local-magic/tags/2.5.0/local-magic.php
r3200713 r3200723 12 12 * Plugin Name: Local Magic 13 13 * Plugin URI: https://www.mrmarketingres.com/local-magic 14 * Description: The Local Magic © WordPress plugin extends the functionality of the SaaS Local Magic© to WordPress so that the local news feed can be displayed on the WordPress website. The plugin is for customers of Local Magic©that have an active subscription with the company.14 * Description: The Local Magic® WordPress plugin extends the functionality of the SaaS Local Magic® to WordPress so that the local news feed can be displayed on the WordPress website. The plugin is for customers of Local Magic® that have an active subscription with the company. 15 15 * Version: 2.5.0 16 16 * Requires at least: 3.5.1 17 * Tested up to: 6. 3.017 * Tested up to: 6.7.1 18 18 * Requires PHP: 5.6.0 19 19 * Author: matthewrubin … … 27 27 exit; // Exit if accessed directly 28 28 29 30 define('MRYLM_VERSION', '2.4.0'); 29 define('MRYLM_VERSION', '2.5.0'); 31 30 32 31 define('MRYLM_PLUGIN_DIR', plugin_dir_path(__FILE__)); … … 51 50 /* ACTION START */ 52 51 53 function mrylm_enqueue_scripts() { 54 55 // wp_enqueue_style('owl.carousel.min.css', plugin_dir_url(__FILE__) . 'assets/css/owl.carousel.min.css', array(), '0.1.0', 'all'); 56 // wp_register_script('owl.carousel.min.js', plugin_dir_url(__FILE__) . 'assets/js/owl.carousel.min.js', '', FALSE, TRUE); 57 // wp_enqueue_script('owl.carousel.min.js'); 52 function mrylm_enqueue_scripts() { 58 53 } 59 54 add_action('wp_enqueue_scripts', 'mrylm_enqueue_scripts'); 60 61 55 62 56 function mrylm_admin_menu() { … … 67 61 add_action('admin_menu', 'mrylm_admin_menu'); 68 62 69 70 63 function mrylm_options() { 71 64 … … 79 72 80 73 /* UPDATE ACTION START */ 74 add_action( 'upgrader_process_complete', 'mrylm_upgrade_function',10, 2); 81 75 function mrylm_upgrade_function( $upgrader_object, $options ) { 82 76 83 // require_once(MRYLM_PLUGIN_DIR . 'activate.php' ); 84 // mrylm_update_tables(); 85 } 86 add_action( 'upgrader_process_complete', 'mrylm_upgrade_function',10, 2); 77 require_once(MRYLM_PLUGIN_DIR . 'activate.php' ); 78 mrylm_update_tables(); 79 } 87 80 /* UPDATE ACTION END */ 88 81 … … 94 87 add_shortcode('mrylm-article', 'mrylm_article_shortcode'); 95 88 96 97 89 function mrylm_dropdown_menu_shortcode($attr, $content) { 98 90 return mrylm_dropdown_menu($content); … … 127 119 /* SHORT CODE END */ 128 120 129 130 121 // DESTROY LM 131 /* Manage/ Destroy Page data Start Done*/122 /* Manage/ Destroy Page data Start */ 132 123 add_action('wp_ajax_nopriv_mrylm-manage-pages', 'mrylm_manage_pages'); 133 134 124 function mrylm_manage_pages() { 135 125 136 126 global $wpdb; 137 require_once(MRYLM_PLUGIN_DIR . 'activate.php' );138 mrylm_update_tables();139 127 140 128 $mrylm_setting_sql = "SELECT * FROM {$wpdb->prefix}mrylm_setting"; … … 146 134 if (isset($lm_cities) && $lm_cities != '') { 147 135 148 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != '' && $lm_setting->lm_types == 'multi-type'){ 149 136 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != ''){ 150 137 $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title); 151 138 foreach($lm_multi_titles AS $key=>$lm_title){ … … 153 140 $postid = url_to_postid($lm_setting->lm_org_url. $key.'/'. $obj->lm_url_slug); 154 141 if ($postid) { 155 $parent_url = $lm_setting->lm_org_url. $key.'/'. $obj->lm_url_slug;156 delete_lm_topic_pages($obj->lm_topics, $parent_url);157 142 wp_delete_post($postid, true); 158 143 } … … 160 145 } 161 146 162 }else if($lm_setting->lm_types == 'type-wise'){163 164 foreach ($lm_cities as $obj) {165 $lm_page_url = $lm_setting->lm_org_url.$obj->lm_type.'/'.$obj->lm_url_slug;166 $postid = url_to_postid($lm_page_url);167 if ($postid) {168 delete_lm_topic_pages($obj->lm_topics, $lm_page_url);169 wp_delete_post($postid, true);170 }171 }172 173 147 }else{ 174 148 foreach ($lm_cities as $obj) { 175 149 $postid = url_to_postid($lm_setting->lm_page_url . $obj->lm_url_slug); 176 150 if ($postid) { 177 $parent_url = $lm_setting->lm_page_url . $obj->lm_url_slug; 178 delete_lm_topic_pages($obj->lm_topics, $parent_url); 179 wp_delete_post($postid, true); 151 wp_delete_post($postid, true); 180 152 } 181 153 } … … 209 181 210 182 211 /* Update Setting data Start Done*/183 /* Update Setting data Start */ 212 184 add_action('wp_ajax_nopriv_mrylm-update-setting', 'mrylm_update_setting'); 213 185 … … 275 247 'lm_multi_keyword' => $lm_setting->multi_keyword, 276 248 'lm_multi_head' => $lm_setting->multi_head, 277 'lm_multi_near_me' => $lm_setting->multi_near_me, 278 'lm_is_topic' => $lm_setting->is_topic, 279 'lm_types' => $lm_setting->lm_types 249 'lm_multi_near_me' => $lm_setting->multi_near_me 280 250 ); 281 251 … … 290 260 291 261 292 /* Manage Cities data Start Pore Hobe*/262 /* Manage Cities data Start */ 293 263 add_action('wp_ajax_nopriv_mrylm-manage-cities', 'mrylm_manage_cities'); 294 264 function mrylm_manage_cities() { 295 265 266 // functional code will go here 267 $lm_cities = $_POST['cities']; 296 268 require_once(MRYLM_PLUGIN_DIR . 'activate.php' ); 297 269 mrylm_update_tables(); 298 $lm_cities = $_POST['cities'];299 270 300 271 if (isset($lm_cities)) { … … 338 309 'lm_historic_landmark' => $obj->historic_landmark, 339 310 'lm_assisted_living' => $obj->assisted_living, 340 'lm_restaurant' => $obj->restaurant, 341 'lm_topics' => $obj->topics, 342 'lm_type' => $obj->lm_type, 343 'lm_is_default' => $obj->is_default, 344 'lm_other_info' => $obj->other_info, 345 'lm_neighbour_id' => $obj->neighbour_id 311 'lm_restaurant' => $obj->restaurant 346 312 ); 347 313 … … 351 317 $lm_city = array(); 352 318 $lm_city['lm_parent_id'] = $obj->parent_id; 353 $lm_city['lm_type'] = $obj->lm_type;354 $lm_city['lm_slug'] = $obj->slug;355 319 $lm_city['lm_url_slug'] = $obj->url_slug; 356 320 $lm_city['lm_city'] = $obj->city; 357 $lm_city['lm_topics'] = $obj->topics;358 321 $lm_obj_city = (object) $lm_city; 359 322 360 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != '' && $lm_setting->lm_types == 'multi-type'){323 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != ''){ 361 324 362 325 $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title); … … 364 327 365 328 $lm_page_url = $lm_setting->lm_org_url.$key.'/'; 366 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_page_url); 367 $lm_setting->lm_page_url = $lm_page_url; 368 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 329 create_lm_page($lm_setting, $lm_obj_city, $lm_page_url); 369 330 } 370 331 371 }else if($lm_setting->lm_types == 'type-wise'){ 372 if($lm_obj_city->lm_type){ 373 $lm_page_url = $lm_setting->lm_org_url.$lm_obj_city->lm_type.'/'; 374 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_page_url); 375 $lm_setting->lm_page_url = $lm_page_url; 376 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 377 } 378 379 }else{ 380 381 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_setting->lm_page_url); 382 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 332 }else{ 333 create_lm_page($lm_setting, $lm_obj_city, $lm_setting->lm_page_url); 383 334 } 384 } 335 336 } 337 385 338 } 386 339 … … 396 349 397 350 398 /* Manage Typewise city Start */ 399 add_action('wp_ajax_nopriv_mrylm-manage-typewise-cities', 'mrylm_manage_typewise_cities'); 400 function mrylm_manage_typewise_cities() { 401 402 require_once(MRYLM_PLUGIN_DIR . 'activate.php' ); 403 mrylm_update_tables(); 351 /* Add single type cities data Start */ 352 add_action('wp_ajax_nopriv_mrylm-manage-single-types', 'mrylm_manage_single_types'); 353 function mrylm_manage_single_types() { 354 355 // functional code will go here 404 356 $lm_cities = $_POST['cities']; 405 $lm_type = $_POST['lm_type']; 406 357 $lm_url_type = $_POST['lm_type']; 358 359 407 360 if (isset($lm_cities)) { 408 361 … … 411 364 $lm_cities = json_decode($lm_cities); 412 365 413 $lm_del_sql = "DELETE FROM {$wpdb->prefix}mrylm_cities WHERE lm_type = '$lm_type'";414 $wpdb->query($lm_del_sql);415 416 366 $mrylm_setting_sql = "SELECT * FROM {$wpdb->prefix}mrylm_setting"; 417 367 $lm_setting = $wpdb->get_row($mrylm_setting_sql); 418 419 foreach ($lm_cities as $obj) { 420 421 $city = stripslashes($obj->city); 422 $data_arr = array( 423 'lm_city_id' => $obj->id, 424 'lm_parent_id' => $obj->parent_id, 425 'lm_city' => $city, 426 'lm_state' => $obj->state, 427 'lm_slug' => $obj->slug, 428 'lm_url_slug' => $obj->url_slug, 429 'lm_google_map_id' => $obj->google_map_id, 430 'lm_form_id' => $obj->form_id, 431 'lm_city_keyword_separator' => $obj->city_keyword_separator, 432 'lm_location' => $obj->location, 433 'lm_city_phone' => $obj->city_phone, 434 'lm_city_mayor' => $obj->city_mayor, 435 'lm_population' => $obj->population, 436 'lm_avg_home_value' => $obj->avg_home_value, 437 'lm_avg_household_income' => $obj->avg_household_income, 438 'lm_avg_temperature' => $obj->avg_temperature, 439 'lm_price_range' => $obj->price_range, 440 'lm_image' => $obj->image, 441 'lm_description' => $obj->description, 442 'lm_telephone' => $obj->telephone, 443 'lm_educational_institution' => $obj->educational_institution, 444 'lm_state_park' => $obj->state_park, 445 'lm_historic_landmark' => $obj->historic_landmark, 446 'lm_assisted_living' => $obj->assisted_living, 447 'lm_restaurant' => $obj->restaurant, 448 'lm_topics' => $obj->topics, 449 'lm_type' => $obj->lm_type, 450 'lm_is_default' => $obj->is_default, 451 'lm_other_info' => $obj->other_info, 452 'lm_neighbour_id' => $obj->neighbour_id 453 ); 454 455 $mrylm_table_name = $wpdb->prefix . "mrylm_cities"; 456 $wpdb->insert($mrylm_table_name, $data_arr); 457 458 $lm_city = array(); 459 $lm_city['lm_parent_id'] = $obj->parent_id; 460 $lm_city['lm_type'] = $obj->lm_type; 461 $lm_city['lm_slug'] = $obj->slug; 462 $lm_city['lm_url_slug'] = $obj->url_slug; 463 $lm_city['lm_city'] = $obj->city; 464 $lm_city['lm_topics'] = $obj->topics; 465 $lm_obj_city = (object) $lm_city; 466 467 468 $lm_page_url = $lm_setting->lm_org_url.$lm_type.'/'; 469 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_page_url); 470 471 $lm_setting->lm_page_url = $lm_page_url; 472 // need to delete old/existing topic pages before create Topic page 473 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 474 475 } 476 } 477 478 // for service area page page 479 if($lm_setting->lm_is_service_area_page){ 480 create_service_area_page($lm_setting); 481 } 482 483 echo TRUE; 484 } 485 486 /* Manage Typewise city Start End */ 487 488 489 /* Add single type cities data Start */ 490 add_action('wp_ajax_nopriv_mrylm-manage-single-types', 'mrylm_manage_single_types'); 491 function mrylm_manage_single_types() { 492 493 // functional code will go here 494 $lm_cities = $_POST['cities']; 495 $lm_url_type = $_POST['lm_type']; 496 497 if (isset($lm_cities)) { 498 499 global $wpdb; 368 369 // we can create parent page , LM type page 500 370 require_once(MRYLM_PLUGIN_DIR . 'activate.php' ); 501 371 mrylm_update_tables(); 502 503 $lm_cities = stripcslashes(str_replace('\"', '"', $lm_cities)); 504 $lm_cities = json_decode($lm_cities); 505 506 $mrylm_setting_sql = "SELECT * FROM {$wpdb->prefix}mrylm_setting"; 507 $lm_setting = $wpdb->get_row($mrylm_setting_sql); 508 372 $lm_page_url = $lm_setting->lm_org_url.$lm_url_type.'/'; 373 509 374 foreach ($lm_cities as $obj) { 510 375 … … 512 377 $city = array(); 513 378 $city['lm_parent_id'] = $obj->parent_id; 514 $city['lm_type'] = $obj->lm_type;515 $city['lm_slug'] = $obj->slug;516 379 $city['lm_url_slug'] = $obj->url_slug; 517 380 $city['lm_city'] = $city_name; 518 $city['lm_topics'] = $obj->topics;;519 381 $lm_city = (object) $city; 520 382 521 383 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != ''){ 522 384 523 $lm_page_url = $lm_setting->lm_org_url.$lm_url_type.'/'; 524 $insert_id = create_lm_page($lm_setting, $lm_city, $lm_page_url); 525 $lm_setting->lm_page_url = $lm_page_url; 526 create_lm_topic_pages($insert_id, $lm_setting, $lm_city); 385 create_lm_page($lm_setting, $lm_city, $lm_page_url); 527 386 } 528 387 } … … 534 393 535 394 536 /* Add City data Start Done*/395 /* Add City data Start*/ 537 396 add_action('wp_ajax_nopriv_mrylm-add-city', 'mrylm_add_city'); 538 397 function mrylm_add_city() { 539 398 540 399 $lm_city = $_POST['city']; 541 542 // we can create parent page , LM type page 543 global $wpdb; 544 require_once(MRYLM_PLUGIN_DIR . 'activate.php' ); 545 mrylm_update_tables(); 546 400 mrylm_upgrade_function(array(), array()); 547 401 548 402 if (isset($lm_city)) { … … 550 404 $lm_city = json_decode($lm_city); 551 405 406 global $wpdb; 552 407 553 408 $mrylm_setting_sql = "SELECT * FROM {$wpdb->prefix}mrylm_setting"; … … 581 436 'lm_historic_landmark' => $lm_city->historic_landmark, 582 437 'lm_assisted_living' => $lm_city->assisted_living, 583 'lm_restaurant' => $lm_city->restaurant, 584 'lm_topics' => $lm_city->topics, 585 'lm_type' => $lm_city->lm_type, 586 'lm_is_default' => $lm_city->is_default, 587 'lm_other_info' => $lm_city->other_info, 588 'lm_neighbour_id' => $lm_city->neighbour_id 438 'lm_restaurant' => $lm_city->restaurant 589 439 ); 590 440 $mrylm_table_name = $wpdb->prefix . "mrylm_cities"; … … 594 444 $obj = array(); 595 445 $obj['lm_parent_id'] = $lm_city->parent_id; 596 $obj['lm_slug'] = $lm_city->slug;597 446 $obj['lm_url_slug'] = $lm_city->url_slug; 598 447 $obj['lm_city'] = $lm_city->city; 599 $obj['lm_type'] = $lm_city->lm_type; 600 $obj['lm_topics'] = $lm_city->topics; 601 $lm_obj_city = (object) $obj; 602 448 $lm_obj_city = (object) $obj; 449 603 450 // now process multi page 604 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != '' && $lm_setting->lm_types == 'multi-type'){451 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != ''){ 605 452 606 453 $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title); 607 608 454 foreach($lm_multi_titles AS $key=>$lm_title){ 609 455 610 456 $lm_page_url = $lm_setting->lm_org_url.$key.'/'; 611 612 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_page_url); 613 $lm_setting->lm_page_url = $lm_page_url; 614 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 457 create_lm_page($lm_setting, $lm_obj_city, $lm_page_url); 615 458 } 616 459 617 }else if($lm_setting->lm_types == 'type-wise'){618 619 620 if($lm_obj_city->lm_type){621 $lm_page_url = $lm_setting->lm_org_url.$lm_obj_city->lm_type.'/';622 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_page_url);623 $lm_setting->lm_page_url = $lm_page_url;624 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city);625 }626 627 628 460 }else{ 629 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_setting->lm_page_url); 630 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 461 create_lm_page($lm_setting, $lm_obj_city, $lm_setting->lm_page_url); 631 462 } 632 463 } … … 634 465 /* Add City data End*/ 635 466 636 637 /* Update City data Start Done*/ 467 function create_lm_page($lm_setting, $lm_city, $lm_page_url){ 468 469 global $wpdb; 470 471 // now we will create page for each city 472 $lm_parent_post_id = url_to_postid($lm_page_url); 473 $lm_post_id = url_to_postid($lm_page_url . $lm_city->lm_url_slug); 474 475 if ($lm_city->lm_parent_id > 0) { 476 $lm_sql = "SELECT * FROM {$wpdb->prefix}mrylm_cities WHERE lm_city_id = '$lm_city->lm_parent_id'"; 477 $lm_city_2 = $wpdb->get_row($lm_sql); 478 $lm_parent_post_id = url_to_postid($lm_page_url. $lm_city_2->lm_url_slug); 479 } 480 481 // If there are no sub page then we hv to parent post id 0 482 if ($lm_setting->lm_page_type == 'base_page') { 483 $lm_parent_post_id = 0; 484 } 485 486 $mrylm_post = array( 487 'ID' => $lm_post_id, 488 'post_title' => $lm_city->lm_city, 489 'post_content' => '', 490 'post_status' => 'publish', 491 'post_type' => 'page', 492 'post_parent' => $lm_parent_post_id, 493 'post_category' => array() 494 ); 495 496 //Insert the post into the database 497 $lm_insert_id = wp_insert_post($mrylm_post); 498 499 // to set template for the page 500 if (!add_post_meta($lm_insert_id, '_wp_page_template', 'local-magic.php', true)) { 501 update_post_meta($lm_insert_id, '_wp_page_template', 'local-magic.php'); 502 } 503 } 504 505 /* Update City data Start*/ 638 506 add_action('wp_ajax_nopriv_mrylm-update-city', 'mrylm_update_city'); 639 507 function mrylm_update_city() { 640 508 641 509 $lm_city = $_POST['city']; 642 643 require_once(MRYLM_PLUGIN_DIR . 'activate.php' ); 644 mrylm_update_tables(); 510 mrylm_upgrade_function(array(), array()); 645 511 646 512 if (isset($lm_city)) { … … 659 525 660 526 // Update city data 661 $city = stripslashes($lm_city->city); 662 663 $wpdb->update( 664 $wpdb->prefix.'mrylm_cities', 665 array( 666 'lm_parent_id' => $lm_city->parent_id, 667 'lm_city' => $city, 668 'lm_state' => $lm_city->state, 669 'lm_slug' => $lm_city->slug, 670 'lm_url_slug' => $lm_city->url_slug, 671 'lm_google_map_id' => $lm_city->google_map_id, 672 'lm_form_id' => $lm_city->form_id, 673 'lm_city_keyword_separator' => $lm_city->city_keyword_separator, 674 'lm_location' => $lm_city->location, 675 'lm_city_phone' => $lm_city->city_phone, 676 'lm_city_mayor' => $lm_city->city_mayor, 677 'lm_population' => $lm_city->population, 678 'lm_avg_home_value' => $lm_city->avg_home_value, 679 'lm_avg_household_income' => $lm_city->avg_household_income, 680 'lm_avg_temperature' => $lm_city->avg_temperature, 681 'lm_price_range' => $lm_city->price_range, 682 'lm_image' => $lm_city->image, 683 'lm_description' => $lm_city->description, 684 'lm_telephone' => $lm_city->telephone, 685 'lm_educational_institution' => $lm_city->educational_institution, 686 'lm_state_park' => $lm_city->state_park, 687 'lm_historic_landmark' => $lm_city->historic_landmark, 688 'lm_assisted_living' => $lm_city->assisted_living, 689 'lm_restaurant' => $lm_city->restaurant, 690 'lm_topics' => $lm_city->topics, 691 'lm_type' => $lm_city->lm_type, 692 'lm_is_default' => $lm_city->is_default, 693 'lm_other_info' => $lm_city->other_info, 694 'lm_neighbour_id' => $lm_city->neighbour_id 695 ), 696 array( 'lm_city_id' => $lm_city->id ) 697 ); 698 699 $obj = array(); 527 $city = stripslashes($lm_city->city); 528 $data_arr = "UPDATE {$wpdb->prefix}mrylm_cities 529 SET lm_parent_id = '" . $lm_city->parent_id . "', 530 lm_city = '" . $city . "', 531 lm_state = '" . $lm_city->state . "', 532 lm_slug = '" . $lm_city->slug . "', 533 lm_url_slug = '" . $lm_city->url_slug . "', 534 lm_google_map_id = '" . $lm_city->google_map_id . "', 535 lm_form_id = '" . $lm_city->form_id . "', 536 lm_city_keyword_separator = '" . $lm_city->city_keyword_separator . "', 537 lm_location = '" . $lm_city->location . "', 538 lm_city_phone = '" . $lm_city->city_phone . "', 539 lm_city_mayor = '" . $lm_city->city_mayor . "', 540 lm_population = '" . $lm_city->population . "', 541 lm_avg_home_value = '" . $lm_city->avg_home_value . "', 542 lm_avg_household_income = '" . $lm_city->avg_household_income . "', 543 lm_avg_temperature = '" . $lm_city->avg_temperature . "', 544 lm_price_range = '" . $lm_city->price_range . "', 545 lm_image = '" . $lm_city->image . "', 546 lm_description = '" . $lm_city->description . "', 547 lm_telephone = '" . $lm_city->telephone . "', 548 lm_educational_institution = '" . $lm_city->educational_institution . "', 549 lm_state_park = '" . $lm_city->state_park . "', 550 lm_historic_landmark = '" . $lm_city->historic_landmark . "', 551 lm_assisted_living = '" . $lm_city->assisted_living . "' , 552 lm_restaurant = '" . $lm_city->restaurant . "' 553 WHERE lm_city_id = " . $lm_city->id . ""; 554 555 $wpdb->query($data_arr); 556 557 $obj = array(); 700 558 $obj['lm_parent_id'] = $lm_city->parent_id; 701 $obj['lm_slug'] = $lm_city->slug;702 559 $obj['lm_url_slug'] = $lm_city->url_slug; 703 560 $obj['lm_city'] = $lm_city->city; 704 $obj['lm_type'] = $lm_city->lm_type;705 $obj['lm_topics'] = $lm_city->topics;706 561 $lm_obj_city = (object) $obj; 707 708 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != '' && $lm_setting->lm_types == 'multi-type'){562 563 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != ''){ 709 564 710 565 $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title); … … 713 568 $lm_page_url = $lm_setting->lm_org_url.$key.'/'; 714 569 $lm_post_id = url_to_postid($lm_page_url . $lm_city_old->lm_url_slug); 715 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_page_url, $lm_post_id); 716 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 570 update_lm_page($lm_setting, $lm_obj_city, $lm_page_url, $lm_post_id); 717 571 } 718 719 }else if($lm_setting->lm_types == 'type-wise'){720 721 if($lm_obj_city->lm_type){722 $lm_page_url = $lm_setting->lm_org_url.$lm_obj_city->lm_type.'/';723 $lm_post_id = url_to_postid($lm_page_url . $lm_city_old->lm_url_slug);724 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_page_url, $lm_post_id);725 $lm_setting->lm_page_url = $lm_page_url;726 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city);727 }728 572 729 573 }else{ 730 574 731 575 $lm_post_id = url_to_postid($lm_setting->lm_page_url . $lm_city_old->lm_url_slug); 732 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_setting->lm_page_url, $lm_post_id); 733 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 734 } 576 update_lm_page($lm_setting, $lm_obj_city, $lm_setting->lm_page_url, $lm_post_id); 577 } 578 579 // now we will create page for city 580 735 581 } 736 582 } 737 583 /* Update City data End */ 738 584 739 /* Manage News data Start */ 585 function update_lm_page($lm_setting, $lm_city, $lm_page_url, $lm_post_id){ 586 587 global $wpdb; 588 589 $lm_parent_post_id = url_to_postid($lm_page_url); 590 591 if($lm_city->lm_parent_id > 0){ 592 $lm_sql_2 = "SELECT * FROM {$wpdb->prefix}mrylm_cities WHERE lm_city_id = '$lm_city->lm_parent_id'"; 593 $lm_city_2 = $wpdb->get_row($lm_sql_2); 594 $lm_parent_post_id = url_to_postid($lm_page_url.$lm_city_2->lm_url_slug); 595 } 596 597 // If there are no sub page then we hv to parent post id 0 598 if ($lm_setting->lm_page_type == 'base_page') { 599 $lm_parent_post_id = 0; 600 } 601 602 $mrylm_post = array( 603 'ID' => $lm_post_id, 604 'post_title' => $lm_city->lm_city, 605 'post_name' => $lm_city->lm_url_slug, 606 'post_content' => '', 607 'post_status' => 'publish', 608 'post_type' => 'page', 609 'post_parent' => $lm_parent_post_id, 610 'post_category' => array() 611 ); 612 613 //Insert the post into the database 614 $lm_insert_id = wp_update_post($mrylm_post); 615 616 // to set template for the page 617 if (!add_post_meta($lm_insert_id, '_wp_page_template', 'local-magic.php', true)) { 618 update_post_meta($lm_insert_id, '_wp_page_template', 'local-magic.php'); 619 } 620 } 621 622 623 /* Manage News data Start */ 740 624 add_action('wp_ajax_nopriv_mrylm-manage-news', 'mrylm_manage_news'); 741 625 function mrylm_manage_news() { … … 787 671 } 788 672 789 echo TRUE; 673 echo TRUE; 674 790 675 } 791 676 /* Manage News data End */ 792 677 793 678 794 /* Delete a City Start Done*/679 /* Delete a City Start */ 795 680 add_action('wp_ajax_nopriv_mrylm-delete-city', 'mrylm_delete_city'); 796 681 function mrylm_delete_city() { 797 682 798 683 global $wpdb; 799 800 require_once(MRYLM_PLUGIN_DIR . 'activate.php' );801 684 $lm_city_id = $_POST['city_id']; 802 685 … … 813 696 $wpdb->query($lm_del_news_sql); 814 697 815 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != '' && $lm_setting->lm_types == 'multi-type'){698 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != ''){ 816 699 817 700 $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title); … … 819 702 $postid = url_to_postid($lm_setting->lm_org_url. $key.'/'. $lm_city->lm_url_slug); 820 703 if ($postid) { 821 $parent_url = $lm_setting->lm_org_url. $key.'/'. $lm_city->lm_url_slug; 822 delete_lm_topic_pages($lm_city->lm_topics, $parent_url); 823 wp_delete_post($postid, true); 704 wp_delete_post($postid, true); 824 705 } 825 }826 827 }else if($lm_setting->lm_types == 'type-wise'){828 829 if($lm_city->lm_type){830 831 $lm_page_url = $lm_setting->lm_org_url.$lm_city->lm_type.'/'.$lm_city->lm_url_slug;832 $postid = url_to_postid($lm_page_url);833 if ($postid) {834 delete_lm_topic_pages($lm_city->lm_topics, $lm_page_url);835 wp_delete_post($postid, true);836 }837 706 } 838 707 … … 841 710 $postid = url_to_postid($lm_setting->lm_page_url . $lm_city->lm_url_slug); 842 711 if ($postid) { 843 $parent_url = $lm_setting->lm_page_url . $lm_city->lm_url_slug; 844 delete_lm_topic_pages($lm_city->lm_topics, $parent_url); 845 wp_delete_post($postid, true); 712 wp_delete_post($postid, true); 846 713 } 847 714 } -
local-magic/tags/2.5.0/readme.txt
r3200711 r3200723 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 10 11 The Local Magic © WordPress plugin extends the functionality of the SaaS Local Magic© to WordPress so that the local magic can be displayed on the WordPress website. The plugin is for customers of Local Magic©that have an active subscription with the company.11 The Local Magic® WordPress plugin extends the functionality of the SaaS Local Magic® to WordPress so that the local magic can be displayed on the WordPress website. The plugin is for customers of Local Magic® that have an active subscription with the company. 12 12 13 13 == Description == 14 14 15 The Local Magic © WordPress plugin extends the functionality of the SaaS Local Magic© to WordPress so that the local magic can be displayed on the WordPress website. The plugin is for customers of Local Magic©that have an active subscription with the company.15 The Local Magic® WordPress plugin extends the functionality of the SaaS Local Magic® to WordPress so that the local magic can be displayed on the WordPress website. The plugin is for customers of Local Magic® that have an active subscription with the company. 16 16 17 17 … … 103 103 =2.3.0= 104 104 1. Bug fixing and Some minor functionality added 105 =2.4.0=106 1. Topic feature added107 =2.5.0=108 1. Re-arrange functionality -
local-magic/trunk/activate.php
r3199499 r3200723 54 54 lm_multi_head text CHARACTER SET utf8 NULL, 55 55 lm_multi_near_me text CHARACTER SET utf8 NULL, 56 lm_is_topic tinyint(1) DEFAULT '0',57 lm_types varchar(20) CHARACTER SET utf8 DEFAULT 'single-type',58 56 PRIMARY KEY (id) 59 57 );"; … … 89 87 lm_assisted_living TEXT CHARACTER SET utf8 NULL, 90 88 lm_restaurant TEXT CHARACTER SET utf8 NULL, 91 lm_topics TEXT CHARACTER SET utf8 NULL,92 lm_type varchar(50) CHARACTER SET utf8 NULL,93 lm_is_default varchar(100) CHARACTER SET utf8 NULL,94 lm_other_info TEXT CHARACTER SET utf8 NULL,95 lm_neighbour_id int(11) NULL,96 89 PRIMARY KEY (id) 97 90 );"; … … 202 195 ;"; 203 196 $wpdb->query($setting_alter_sql_3); 204 205 } 206 } 207 208 //V 2.3 209 if ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $mrylm_setting_table)) === $mrylm_setting_table) { 210 211 $setting_table_exist_4 = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS 212 WHERE table_name = '$mrylm_setting_table' AND column_name = 'lm_is_topic'"); 213 if (empty($setting_table_exist_4)) { 214 $setting_alter_sql_4 = "ALTER TABLE {$wpdb->prefix}mrylm_setting 215 ADD `lm_is_topic` tinyint(1) NULL DEFAULT '0' AFTER `lm_multi_near_me` 216 ;"; 217 $wpdb->query($setting_alter_sql_4); 218 219 } 220 221 $setting_table_exist_5 = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS 222 WHERE table_name = '$mrylm_setting_table' AND column_name = 'lm_types'"); 223 if (empty($setting_table_exist_5)) { 224 $setting_alter_sql_5 = "ALTER TABLE {$wpdb->prefix}mrylm_setting 225 ADD `lm_types` VARCHAR(30) NULL DEFAULT 'single-type' AFTER `lm_is_topic` 226 ;"; 227 $wpdb->query($setting_alter_sql_5); 228 229 } 197 } 230 198 } 231 199 … … 277 245 $wpdb->query($cities_alter_sql_2); 278 246 } 279 280 281 $cities_table_exist_3 = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS282 WHERE table_name = '$mrylm_cities_table' AND column_name = 'lm_topics'");283 if (empty($cities_table_exist_3)) {284 $cities_alter_sql_3 = "ALTER TABLE {$wpdb->prefix}mrylm_cities285 ADD `lm_topics` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `lm_restaurant`286 ;";287 $wpdb->query($cities_alter_sql_3);288 }289 290 $cities_table_exist_4 = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS291 WHERE table_name = '$mrylm_cities_table' AND column_name = 'lm_type'");292 if (empty($cities_table_exist_4)) {293 $cities_alter_sql_4 = "ALTER TABLE {$wpdb->prefix}mrylm_cities294 ADD `lm_type` VARCHAR(30) NULL AFTER `lm_topics`295 ;";296 $wpdb->query($cities_alter_sql_4);297 }298 299 300 // city last update301 $cities_table_exist_5 = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS302 WHERE table_name = '$mrylm_cities_table' AND column_name = 'lm_is_default'");303 if (empty($cities_table_exist_5)) {304 $cities_alter_sql_5 = "ALTER TABLE {$wpdb->prefix}mrylm_cities305 ADD `lm_is_default` tinyint(1) NULL DEFAULT '0' AFTER `lm_type`,306 ADD `lm_other_info` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `lm_is_default`307 ;";308 $wpdb->query($cities_alter_sql_5);309 }310 311 // city last 2 update312 $cities_table_exist_6 = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS313 WHERE table_name = '$mrylm_cities_table' AND column_name = 'lm_neighbour_id'");314 if (empty($cities_table_exist_6)) {315 $cities_alter_sql_6 = "ALTER TABLE {$wpdb->prefix}mrylm_cities316 ADD `lm_neighbour_id` int(11) NULL DEFAULT '0' AFTER `lm_other_info`317 ;";318 $wpdb->query($cities_alter_sql_6);319 }320 321 247 } 322 248 323 249 mrylm_create_tables(); 324 325 250 } 326 251 327 // OK328 function create_lm_page($lm_setting, $lm_city, $lm_page_url, $lm_post_ID = NULL){329 330 global $wpdb;331 332 // now we will create page for each city333 $lm_parent_post_id = url_to_postid($lm_page_url);334 335 $lm_post_id = $lm_post_ID > 0 ? $lm_post_ID : url_to_postid($lm_page_url.$lm_city->lm_url_slug);336 337 if($lm_city->lm_parent_id > 0){338 $lm_sql = "SELECT * FROM {$wpdb->prefix}mrylm_cities WHERE lm_city_id = '$lm_city->lm_parent_id'";339 $lm_city_2 = $wpdb->get_row($lm_sql);340 $lm_parent_post_id = url_to_postid($lm_page_url.$lm_city_2->lm_url_slug);341 }342 343 // If there are no sub page then we hv to parent post id 0344 if ($lm_setting->lm_page_type == 'base_page') {345 $lm_parent_post_id = 0;346 }347 348 $mrylm_post = array(349 'ID'=> $lm_post_id,350 'post_title' => $lm_city->lm_city,351 'post_name' => $lm_city->lm_slug,352 'post_content' => '',353 'post_status' => 'publish',354 'post_type' => 'page',355 'post_parent' => $lm_parent_post_id,356 'post_author' => 1,357 'post_category' => array()358 );359 360 361 //Insert the post into the database362 $lm_insert_id = $lm_post_id > 0 ? wp_update_post($mrylm_post) : wp_insert_post( $mrylm_post );363 364 // to set template for the page365 if ( ! add_post_meta( $lm_insert_id, '_wp_page_template', 'local-magic.php', true )) {366 update_post_meta( $lm_insert_id, '_wp_page_template', 'local-magic.php' );367 }368 369 return $lm_insert_id;370 }371 372 // OK373 function create_lm_topic_pages($lm_parent_post_id, $lm_setting, $lm_city_obj){374 375 376 if($lm_setting->lm_is_topic && $lm_city_obj->lm_topics != ''){377 378 $topic_arr = explode('=',$lm_city_obj->lm_topics);379 380 if(is_array($topic_arr)){381 foreach($topic_arr AS $topic){382 383 $data_arr = explode('|', $topic);384 if(is_array($data_arr)){385 386 // $lm_setting->lm_page_url == same as org_url + url type387 $lm_post_id = url_to_postid($lm_setting->lm_page_url.$lm_city_obj->lm_url_slug.'/'.$data_arr[0]);388 389 $mrylm_post = array(390 'ID'=> $lm_post_id,391 'post_title' => $data_arr[1],392 'post_name' => $data_arr[0],393 'post_content' => '',394 'post_status' => 'publish',395 'post_type' => 'page',396 'post_parent' => $lm_parent_post_id,397 'post_author' => 1,398 'post_category' => array()399 );400 401 // $lm_insert_id = wp_insert_post( $mrylm_post );402 $lm_insert_id = $lm_post_id > 0 ? wp_update_post($mrylm_post) : wp_insert_post( $mrylm_post );403 // to set template for the page404 if ( ! add_post_meta( $lm_insert_id, '_wp_page_template', 'local-magic.php', true )) {405 update_post_meta( $lm_insert_id, '_wp_page_template', 'local-magic.php' );406 }407 }408 }409 }410 }411 }412 413 // OK414 function delete_lm_topic_pages($lm_topics, $lm_page_url) {415 416 if ($lm_topics != '') {417 418 $topic_arr = explode('=',$lm_topics);419 420 if (is_array($topic_arr)) {421 422 foreach ($topic_arr AS $topic) {423 424 $data_arr = explode('|', $topic);425 426 if (is_array($data_arr)) {427 $postid = url_to_postid($lm_page_url . '/'.$data_arr[0]);428 if ($postid) {429 wp_delete_post($postid, true);430 }431 }432 }433 }434 }435 }436 437 // OK438 252 function create_service_area_page($lm_setting) { 439 253 … … 453 267 'post_type' => 'page', 454 268 'post_parent' => 0, 455 'post_author' => 1,456 269 'post_category' => array() 457 270 ); -
local-magic/trunk/admin/setting.php
r3199499 r3200723 8 8 $mrylm_msg = ""; 9 9 10 11 function get_multi_type_formatted_data($multi_type_data = null){12 13 $array_data = array();14 $text_data = json_decode($multi_type_data, true);15 $array = explode('|', $text_data);16 foreach($array as $value){17 18 $arr = explode('=>', $value);19 $array_data[$arr[0]] = $arr[1];20 }21 22 return $array_data;23 }24 25 10 function mrylm_check_key_format($mrylm_key){ 26 11 … … 36 21 } 37 22 23 function get_multi_type_formatted_data($multi_type_data = null){ 24 25 $array_data = array(); 26 $text_data = json_decode($multi_type_data, true); 27 $array = explode('|', $text_data); 28 foreach($array as $value){ 29 30 $arr = explode('=>', $value); 31 $array_data[$arr[0]] = $arr[1]; 32 } 33 34 return $array_data; 35 } 36 37 function create_lm_pages($lm_setting, $lm_city, $lm_page_url){ 38 39 global $wpdb; 40 41 // now we will create page for each city 42 $lm_parent_post_id = url_to_postid($lm_page_url); 43 $lm_post_id = url_to_postid($lm_page_url.$lm_city->lm_url_slug); 44 45 if($lm_city->lm_parent_id > 0){ 46 $lm_sql = "SELECT * FROM {$wpdb->prefix}mrylm_cities WHERE lm_city_id = '$lm_city->lm_parent_id'"; 47 $lm_city_2 = $wpdb->get_row($lm_sql); 48 $lm_parent_post_id = url_to_postid($lm_page_url.$lm_city_2->lm_url_slug); 49 } 50 51 // If there are no sub page then we hv to parent post id 0 52 if ($lm_setting->lm_page_type == 'base_page') { 53 $lm_parent_post_id = 0; 54 } 55 56 $mrylm_post = array( 57 'ID'=> $lm_post_id, 58 'post_title' => $lm_city->lm_city, 59 'post_content' => '', 60 'post_status' => 'publish', 61 'post_type' => 'page', 62 'post_parent' => $lm_parent_post_id, 63 'post_category' => array() 64 ); 65 66 //Insert the post into the database 67 $lm_insert_id = wp_insert_post( $mrylm_post ); 68 69 // to set template for the page 70 if ( ! add_post_meta( $lm_insert_id, '_wp_page_template', 'local-magic.php', true )) { 71 update_post_meta( $lm_insert_id, '_wp_page_template', 'local-magic.php' ); 72 } 73 } 74 75 38 76 function mrylm_process_pages(){ 39 77 … … 45 83 if($lm_setting->lm_url_type == 'wp_remote_get'){ 46 84 $mrylm_response = wp_remote_get('https://localmagic.reviewmanager.app/plugin/cities/' . $lm_setting->lm_unique_id); 47 $mrylm_cities = json_decode($mrylm_response['body']); 85 $mrylm_cities = json_decode($mrylm_response['body']); 86 48 87 }else{ 49 88 $mrylm_response = file_get_contents('https://localmagic.reviewmanager.app/plugin/cities/' . $lm_setting->lm_unique_id); … … 51 90 } 52 91 53 if(!empty($mrylm_cities)){92 if(!empty($mrylm_cities)){ 54 93 55 94 // Trancating existing Cities table … … 86 125 'lm_historic_landmark' => $obj->historic_landmark, 87 126 'lm_assisted_living' => $obj->assisted_living, 88 'lm_restaurant' => $obj->restaurant, 89 'lm_topics' => $obj->topics, 90 'lm_type' => $obj->lm_type, 91 'lm_is_default' => $obj->is_default, 92 'lm_other_info' => $obj->other_info, 93 'lm_neighbour_id' => $obj->neighbour_id 127 'lm_restaurant' => $obj->restaurant 94 128 ); 95 129 … … 99 133 $lm_city = array(); 100 134 $lm_city['lm_parent_id'] = $obj->parent_id; 101 $lm_city['lm_type'] = $obj->lm_type;102 $lm_city['lm_slug'] = $obj->slug;103 135 $lm_city['lm_url_slug'] = $obj->url_slug; 104 136 $lm_city['lm_city'] = $obj->city; 105 $lm_city['lm_topics'] = $obj->topics;106 137 $lm_obj_city = (object) $lm_city; 107 138 108 139 // need to process multi type 109 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != '' && $lm_setting->lm_types == 'multi-type'){140 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != ''){ 110 141 111 142 $lm_multi_titles = get_multi_type_formatted_data($lm_setting->lm_multi_title); … … 113 144 114 145 $lm_page_url = $lm_setting->lm_org_url.$key.'/'; 115 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_page_url); 116 $lm_setting->lm_page_url = $lm_page_url; 117 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 146 create_lm_pages($lm_setting, $lm_obj_city, $lm_page_url); 118 147 } 119 148 120 }else if($lm_setting->lm_types == 'type-wise'){ 121 122 if($lm_obj_city->lm_type){ 123 $lm_page_url = $lm_setting->lm_org_url.$lm_obj_city->lm_type.'/'; 124 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_page_url); 125 $lm_setting->lm_page_url = $lm_page_url; 126 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 127 } 128 129 }else{ // single type city 130 131 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_setting->lm_page_url); 132 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 149 }else{ 150 create_lm_pages($lm_setting, $lm_obj_city, $lm_setting->lm_page_url); 133 151 } 134 152 } … … 140 158 } 141 159 } 160 142 161 143 162 if (isset($_POST['submit']) && is_user_logged_in()) { … … 226 245 'lm_multi_keyword' => $lm_setting->multi_keyword, 227 246 'lm_multi_head' => $lm_setting->multi_head, 228 'lm_multi_near_me' => $lm_setting->multi_near_me, 229 'lm_is_topic' => $lm_setting->is_topic, 230 'lm_types' => $lm_setting->lm_types 247 'lm_multi_near_me' => $lm_setting->multi_near_me 231 248 ); 232 249 -
local-magic/trunk/include/function.php
r3199499 r3200723 9 9 } 10 10 11 12 11 function get_multi_type_data($multi_type_data = null){ 13 12 … … 24 23 } 25 24 26 27 25 function mrylm_get_city(){ 28 26 29 27 global $wpdb; 28 29 $url = get_permalink(); 30 $arr = explode('/', trim($url, '/')); 31 $slug = end($arr); 32 $prev = prev($arr); 33 34 $full_slug = $prev.'/'.$slug; 30 35 31 36 $lm_setting_sql = "SELECT * FROM {$wpdb->prefix}mrylm_setting"; 32 37 $lm_setting = $wpdb->get_row($lm_setting_sql); 33 34 $url = get_permalink();35 $arr = explode('/', trim($url, '/'));36 37 $slug = end($arr);38 $prev = prev($arr);39 $lm_type = ''; //$arr[4];40 41 42 // This [4] is depends on url format43 if($lm_setting->lm_is_topic){44 if(count($arr) > 4){ // there are topic45 $slug = $arr[4];46 }47 }48 49 38 if ($lm_setting->lm_org_url == $url) { 50 $ slug = $lm_setting->lm_default_city;39 $full_slug = $lm_setting->lm_default_city; 51 40 } 52 41 53 $lm_sql = "SELECT * FROM {$wpdb->prefix}mrylm_cities WHERE lm_slug = '$slug'"; 54 if($lm_type){ 55 $lm_sql = "SELECT * FROM {$wpdb->prefix}mrylm_cities WHERE lm_slug = '$slug' AND lm_type = '$lm_type'"; 42 $lm_sql = "SELECT * FROM {$wpdb->prefix}mrylm_cities WHERE lm_url_slug = '$full_slug'"; 43 $lm_city = $wpdb->get_row($lm_sql); 44 45 if(empty($lm_city)){ 46 $lm_sql = "SELECT * FROM {$wpdb->prefix}mrylm_cities WHERE lm_url_slug = '$slug'"; 47 $lm_city = $wpdb->get_row($lm_sql); 56 48 } 57 $lm_city = $wpdb->get_row($lm_sql);58 49 59 50 return $lm_city; … … 311 302 312 303 $content = file_get_contents($lm_setting->lm_template_other_path.'/lm-'.$url_slug.'-content.php'); 313 } 314 315 316 // Widget Part 317 if($lm_setting->lm_is_topic && $lm_city->lm_topics != ''){ 318 319 $topic_widget = ''; 320 $topic_arr = json_decode($lm_city->lm_topics); 321 322 if(is_array($topic_arr)){ 323 foreach($topic_arr AS $topic){ 324 $data_arr = explode('|', $topic); 325 $topic_url = $lm_setting->lm_page_url . $lm_city->lm_url_slug . '/' .$data_arr[0]; 326 $topic_widget .= '<a class="btn lm-hero-btn" href="'.$topic_url.'"><span>'.$data_arr[1].'</span></a>'; 327 } 328 } 329 330 if($topic_widget != ''){ 331 $content = str_replace('TOPIC_WIDGET', $topic_widget, $content); 332 }else{ 333 $content = str_replace('TOPIC_WIDGET', '', $content); 334 } 335 336 } 337 // URL CUSTOM END 338 339 340 341 // process POI widget 342 if($lm_setting->lm_is_point_of_interest){ 343 344 345 $poi_data = mrylm_poi($type = ''); 346 $content = str_replace('POI_FEED', $poi_data, $content); 347 348 } 349 304 } 350 305 351 306 … … 406 361 $reviews = mrylm_review_testimonial($lm_city); 407 362 $content = str_replace('REVIEW_FEED', $reviews, $content); 408 363 364 365 // process POI widget 366 if($lm_setting->lm_is_point_of_interest){ 367 $poi_data = mrylm_poi($type = ''); 368 $content = str_replace('POI_FEED', $poi_data, $content); 369 } 370 409 371 return $content; 410 372 … … 484 446 485 447 // Set img title and alt attributes 486 $title_text = ucwords( trim($img_keyword_arr[$counter]).' '.$city.', '.$state);448 $title_text = ucwords($img_keyword_arr[$counter].' '.$city.', '.$state); 487 449 $image->setAttribute('alt', $title_text); 488 450 $image->setAttribute('title', $title_text); … … 700 662 // get news data as per keyword 701 663 $lm_news = mrylm_get_news_list($lm_setting, $lm_city); 702 $data .= mrylm_get_list_data($lm_setting, $lm_news, $lm_city); 703 664 665 if($lm_setting->lm_display_type == 'list'){ 666 $data .= mrylm_get_list_data($lm_setting, $lm_news, $lm_city); 667 }else if($lm_setting->lm_display_type == 'accordion'){ 668 $data .= mrylm_get_accordion_data($lm_setting, $lm_news, $lm_city); 669 } 704 670 705 671 $style = '<style>'; … … 832 798 } 833 799 800 function mrylm_get_accordion_data($lm_setting, $lm_news, $lm_city){ 801 802 $separator = 'in'; 803 $data = ''; 804 805 $data .= '<div class="lm-accordion-container">'; 806 807 if(isset($lm_news) && !empty($lm_news)){ 808 809 $data .= '<h2 class="lm-widget-title">'.$lm_setting->lm_head_line.' '.$separator.' '. $lm_city->lm_city .', '. $lm_city->lm_state .'</h2>'; 810 811 // foreach start 812 $data .= '<div class="lm-accordion-inner">'; 813 814 foreach($lm_news as $obj){ 815 816 $detail = trim(preg_replace("/<figure[^>]*>(.+?)<\/figure>/", "", $obj->lm_news)); 817 $detail = trim(preg_replace("/<iframe[^>]*>(.+?)<\/iframe>/", "", $detail)); 818 $detail = trim(preg_replace("/<img[^>]*>(.+?)<\/img>/", "", $detail)); 819 $detail = preg_replace('/(<a\b[^><]*)>/i', '$1 rel="nofollow;" target="_blank">',$detail); 820 821 $active = 'none;'; 822 $active_class = ''; 823 824 if($key == 0){$active_class = 'lm-active'; $active = 'block;'; } 825 826 $author = $obj->lm_author ? $obj->lm_author : $obj->lm_source; 827 $source = $obj->lm_source ? $obj->lm_source : $lm_setting->lm_org_name; 828 829 $data .= '<div class="lm-accordion-item" itemscope itemtype="http://schema.org/NewsArticle">'; 830 $data .= '<meta itemscope itemprop="mainEntityOfPage" itemType="https://schema.org/WebPage" itemid="'.$obj->lm_detail_url.'"/>'; 831 $data .= '<h2 class="lm-accordion-title '.$active_class.'" itemprop="headline">'.$obj->lm_title.'</h2>'; 832 $data .= '<h3 style="display:none;" itemprop="author" itemscope itemtype="https://schema.org/Person">'; 833 $data .= '<span itemprop="name">'.$author.'</span>'; 834 $data .= '<span itemprop="url">'.$obj->lm_detail_url.'</span>'; 835 $data .= '</h3>'; 836 $data .= '<div class="lm-accordion-content" style="display:'.$active.'">'; 837 $data .= '<div class="lm-read-less"><p>'. strip_tags(substr($detail, 0, 550)). '...</p></div>'; 838 $data .= '<div class="lm-read-more" itemprop="description">'. $detail. '</div>'; 839 $data .= '<button class="lm-btn">Read more</button>'; 840 $data .= '</div>'; 841 842 $data .= '<div itemprop="image" itemscope itemtype="https://schema.org/ImageObject"> 843 <meta itemprop="url" content="'.$lm_setting->lm_org_logo_url.'"> 844 </div>'; 845 $data .= '<div itemprop="publisher" itemscope itemtype="https://schema.org/Organization"> 846 <div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject"> 847 <meta itemprop="url" content="'.$lm_setting->lm_org_logo_url.'"> 848 </div> 849 <meta itemprop="name" content="'.$source.'"> 850 </div>'; 851 $data .= '<meta itemprop="datePublished" content="'.date('Y-m-d H:i:s', strtotime($obj->lm_created_at)).'"/>'; 852 $data .= '<meta itemprop="dateModified" content="'.date('Y-m-d H:i:s', strtotime($obj->lm_updated_at)).'"/>'; 853 854 $data .= '</div>'; 855 } 856 857 $data .= '</div>'; 858 859 }else{ 860 $data .= ''; '<div class="news-block">No news data found.</div>'; 861 } 862 863 $data .= '</div>'; 864 865 return $data; 866 867 } 868 834 869 function mrylm_review_testimonial($lm_city = null){ 835 870 … … 1405 1440 1406 1441 /* Job End */ 1442 1407 1443 1408 1444 /* POI Start */ -
local-magic/trunk/local-magic.php
r3200713 r3200723 12 12 * Plugin Name: Local Magic 13 13 * Plugin URI: https://www.mrmarketingres.com/local-magic 14 * Description: The Local Magic © WordPress plugin extends the functionality of the SaaS Local Magic© to WordPress so that the local news feed can be displayed on the WordPress website. The plugin is for customers of Local Magic©that have an active subscription with the company.14 * Description: The Local Magic® WordPress plugin extends the functionality of the SaaS Local Magic® to WordPress so that the local news feed can be displayed on the WordPress website. The plugin is for customers of Local Magic® that have an active subscription with the company. 15 15 * Version: 2.5.0 16 16 * Requires at least: 3.5.1 17 * Tested up to: 6. 3.017 * Tested up to: 6.7.1 18 18 * Requires PHP: 5.6.0 19 19 * Author: matthewrubin … … 27 27 exit; // Exit if accessed directly 28 28 29 30 define('MRYLM_VERSION', '2.4.0'); 29 define('MRYLM_VERSION', '2.5.0'); 31 30 32 31 define('MRYLM_PLUGIN_DIR', plugin_dir_path(__FILE__)); … … 51 50 /* ACTION START */ 52 51 53 function mrylm_enqueue_scripts() { 54 55 // wp_enqueue_style('owl.carousel.min.css', plugin_dir_url(__FILE__) . 'assets/css/owl.carousel.min.css', array(), '0.1.0', 'all'); 56 // wp_register_script('owl.carousel.min.js', plugin_dir_url(__FILE__) . 'assets/js/owl.carousel.min.js', '', FALSE, TRUE); 57 // wp_enqueue_script('owl.carousel.min.js'); 52 function mrylm_enqueue_scripts() { 58 53 } 59 54 add_action('wp_enqueue_scripts', 'mrylm_enqueue_scripts'); 60 61 55 62 56 function mrylm_admin_menu() { … … 67 61 add_action('admin_menu', 'mrylm_admin_menu'); 68 62 69 70 63 function mrylm_options() { 71 64 … … 79 72 80 73 /* UPDATE ACTION START */ 74 add_action( 'upgrader_process_complete', 'mrylm_upgrade_function',10, 2); 81 75 function mrylm_upgrade_function( $upgrader_object, $options ) { 82 76 83 // require_once(MRYLM_PLUGIN_DIR . 'activate.php' ); 84 // mrylm_update_tables(); 85 } 86 add_action( 'upgrader_process_complete', 'mrylm_upgrade_function',10, 2); 77 require_once(MRYLM_PLUGIN_DIR . 'activate.php' ); 78 mrylm_update_tables(); 79 } 87 80 /* UPDATE ACTION END */ 88 81 … … 94 87 add_shortcode('mrylm-article', 'mrylm_article_shortcode'); 95 88 96 97 89 function mrylm_dropdown_menu_shortcode($attr, $content) { 98 90 return mrylm_dropdown_menu($content); … … 127 119 /* SHORT CODE END */ 128 120 129 130 121 // DESTROY LM 131 /* Manage/ Destroy Page data Start Done*/122 /* Manage/ Destroy Page data Start */ 132 123 add_action('wp_ajax_nopriv_mrylm-manage-pages', 'mrylm_manage_pages'); 133 134 124 function mrylm_manage_pages() { 135 125 136 126 global $wpdb; 137 require_once(MRYLM_PLUGIN_DIR . 'activate.php' );138 mrylm_update_tables();139 127 140 128 $mrylm_setting_sql = "SELECT * FROM {$wpdb->prefix}mrylm_setting"; … … 146 134 if (isset($lm_cities) && $lm_cities != '') { 147 135 148 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != '' && $lm_setting->lm_types == 'multi-type'){ 149 136 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != ''){ 150 137 $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title); 151 138 foreach($lm_multi_titles AS $key=>$lm_title){ … … 153 140 $postid = url_to_postid($lm_setting->lm_org_url. $key.'/'. $obj->lm_url_slug); 154 141 if ($postid) { 155 $parent_url = $lm_setting->lm_org_url. $key.'/'. $obj->lm_url_slug;156 delete_lm_topic_pages($obj->lm_topics, $parent_url);157 142 wp_delete_post($postid, true); 158 143 } … … 160 145 } 161 146 162 }else if($lm_setting->lm_types == 'type-wise'){163 164 foreach ($lm_cities as $obj) {165 $lm_page_url = $lm_setting->lm_org_url.$obj->lm_type.'/'.$obj->lm_url_slug;166 $postid = url_to_postid($lm_page_url);167 if ($postid) {168 delete_lm_topic_pages($obj->lm_topics, $lm_page_url);169 wp_delete_post($postid, true);170 }171 }172 173 147 }else{ 174 148 foreach ($lm_cities as $obj) { 175 149 $postid = url_to_postid($lm_setting->lm_page_url . $obj->lm_url_slug); 176 150 if ($postid) { 177 $parent_url = $lm_setting->lm_page_url . $obj->lm_url_slug; 178 delete_lm_topic_pages($obj->lm_topics, $parent_url); 179 wp_delete_post($postid, true); 151 wp_delete_post($postid, true); 180 152 } 181 153 } … … 209 181 210 182 211 /* Update Setting data Start Done*/183 /* Update Setting data Start */ 212 184 add_action('wp_ajax_nopriv_mrylm-update-setting', 'mrylm_update_setting'); 213 185 … … 275 247 'lm_multi_keyword' => $lm_setting->multi_keyword, 276 248 'lm_multi_head' => $lm_setting->multi_head, 277 'lm_multi_near_me' => $lm_setting->multi_near_me, 278 'lm_is_topic' => $lm_setting->is_topic, 279 'lm_types' => $lm_setting->lm_types 249 'lm_multi_near_me' => $lm_setting->multi_near_me 280 250 ); 281 251 … … 290 260 291 261 292 /* Manage Cities data Start Pore Hobe*/262 /* Manage Cities data Start */ 293 263 add_action('wp_ajax_nopriv_mrylm-manage-cities', 'mrylm_manage_cities'); 294 264 function mrylm_manage_cities() { 295 265 266 // functional code will go here 267 $lm_cities = $_POST['cities']; 296 268 require_once(MRYLM_PLUGIN_DIR . 'activate.php' ); 297 269 mrylm_update_tables(); 298 $lm_cities = $_POST['cities'];299 270 300 271 if (isset($lm_cities)) { … … 338 309 'lm_historic_landmark' => $obj->historic_landmark, 339 310 'lm_assisted_living' => $obj->assisted_living, 340 'lm_restaurant' => $obj->restaurant, 341 'lm_topics' => $obj->topics, 342 'lm_type' => $obj->lm_type, 343 'lm_is_default' => $obj->is_default, 344 'lm_other_info' => $obj->other_info, 345 'lm_neighbour_id' => $obj->neighbour_id 311 'lm_restaurant' => $obj->restaurant 346 312 ); 347 313 … … 351 317 $lm_city = array(); 352 318 $lm_city['lm_parent_id'] = $obj->parent_id; 353 $lm_city['lm_type'] = $obj->lm_type;354 $lm_city['lm_slug'] = $obj->slug;355 319 $lm_city['lm_url_slug'] = $obj->url_slug; 356 320 $lm_city['lm_city'] = $obj->city; 357 $lm_city['lm_topics'] = $obj->topics;358 321 $lm_obj_city = (object) $lm_city; 359 322 360 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != '' && $lm_setting->lm_types == 'multi-type'){323 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != ''){ 361 324 362 325 $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title); … … 364 327 365 328 $lm_page_url = $lm_setting->lm_org_url.$key.'/'; 366 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_page_url); 367 $lm_setting->lm_page_url = $lm_page_url; 368 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 329 create_lm_page($lm_setting, $lm_obj_city, $lm_page_url); 369 330 } 370 331 371 }else if($lm_setting->lm_types == 'type-wise'){ 372 if($lm_obj_city->lm_type){ 373 $lm_page_url = $lm_setting->lm_org_url.$lm_obj_city->lm_type.'/'; 374 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_page_url); 375 $lm_setting->lm_page_url = $lm_page_url; 376 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 377 } 378 379 }else{ 380 381 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_setting->lm_page_url); 382 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 332 }else{ 333 create_lm_page($lm_setting, $lm_obj_city, $lm_setting->lm_page_url); 383 334 } 384 } 335 336 } 337 385 338 } 386 339 … … 396 349 397 350 398 /* Manage Typewise city Start */ 399 add_action('wp_ajax_nopriv_mrylm-manage-typewise-cities', 'mrylm_manage_typewise_cities'); 400 function mrylm_manage_typewise_cities() { 401 402 require_once(MRYLM_PLUGIN_DIR . 'activate.php' ); 403 mrylm_update_tables(); 351 /* Add single type cities data Start */ 352 add_action('wp_ajax_nopriv_mrylm-manage-single-types', 'mrylm_manage_single_types'); 353 function mrylm_manage_single_types() { 354 355 // functional code will go here 404 356 $lm_cities = $_POST['cities']; 405 $lm_type = $_POST['lm_type']; 406 357 $lm_url_type = $_POST['lm_type']; 358 359 407 360 if (isset($lm_cities)) { 408 361 … … 411 364 $lm_cities = json_decode($lm_cities); 412 365 413 $lm_del_sql = "DELETE FROM {$wpdb->prefix}mrylm_cities WHERE lm_type = '$lm_type'";414 $wpdb->query($lm_del_sql);415 416 366 $mrylm_setting_sql = "SELECT * FROM {$wpdb->prefix}mrylm_setting"; 417 367 $lm_setting = $wpdb->get_row($mrylm_setting_sql); 418 419 foreach ($lm_cities as $obj) { 420 421 $city = stripslashes($obj->city); 422 $data_arr = array( 423 'lm_city_id' => $obj->id, 424 'lm_parent_id' => $obj->parent_id, 425 'lm_city' => $city, 426 'lm_state' => $obj->state, 427 'lm_slug' => $obj->slug, 428 'lm_url_slug' => $obj->url_slug, 429 'lm_google_map_id' => $obj->google_map_id, 430 'lm_form_id' => $obj->form_id, 431 'lm_city_keyword_separator' => $obj->city_keyword_separator, 432 'lm_location' => $obj->location, 433 'lm_city_phone' => $obj->city_phone, 434 'lm_city_mayor' => $obj->city_mayor, 435 'lm_population' => $obj->population, 436 'lm_avg_home_value' => $obj->avg_home_value, 437 'lm_avg_household_income' => $obj->avg_household_income, 438 'lm_avg_temperature' => $obj->avg_temperature, 439 'lm_price_range' => $obj->price_range, 440 'lm_image' => $obj->image, 441 'lm_description' => $obj->description, 442 'lm_telephone' => $obj->telephone, 443 'lm_educational_institution' => $obj->educational_institution, 444 'lm_state_park' => $obj->state_park, 445 'lm_historic_landmark' => $obj->historic_landmark, 446 'lm_assisted_living' => $obj->assisted_living, 447 'lm_restaurant' => $obj->restaurant, 448 'lm_topics' => $obj->topics, 449 'lm_type' => $obj->lm_type, 450 'lm_is_default' => $obj->is_default, 451 'lm_other_info' => $obj->other_info, 452 'lm_neighbour_id' => $obj->neighbour_id 453 ); 454 455 $mrylm_table_name = $wpdb->prefix . "mrylm_cities"; 456 $wpdb->insert($mrylm_table_name, $data_arr); 457 458 $lm_city = array(); 459 $lm_city['lm_parent_id'] = $obj->parent_id; 460 $lm_city['lm_type'] = $obj->lm_type; 461 $lm_city['lm_slug'] = $obj->slug; 462 $lm_city['lm_url_slug'] = $obj->url_slug; 463 $lm_city['lm_city'] = $obj->city; 464 $lm_city['lm_topics'] = $obj->topics; 465 $lm_obj_city = (object) $lm_city; 466 467 468 $lm_page_url = $lm_setting->lm_org_url.$lm_type.'/'; 469 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_page_url); 470 471 $lm_setting->lm_page_url = $lm_page_url; 472 // need to delete old/existing topic pages before create Topic page 473 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 474 475 } 476 } 477 478 // for service area page page 479 if($lm_setting->lm_is_service_area_page){ 480 create_service_area_page($lm_setting); 481 } 482 483 echo TRUE; 484 } 485 486 /* Manage Typewise city Start End */ 487 488 489 /* Add single type cities data Start */ 490 add_action('wp_ajax_nopriv_mrylm-manage-single-types', 'mrylm_manage_single_types'); 491 function mrylm_manage_single_types() { 492 493 // functional code will go here 494 $lm_cities = $_POST['cities']; 495 $lm_url_type = $_POST['lm_type']; 496 497 if (isset($lm_cities)) { 498 499 global $wpdb; 368 369 // we can create parent page , LM type page 500 370 require_once(MRYLM_PLUGIN_DIR . 'activate.php' ); 501 371 mrylm_update_tables(); 502 503 $lm_cities = stripcslashes(str_replace('\"', '"', $lm_cities)); 504 $lm_cities = json_decode($lm_cities); 505 506 $mrylm_setting_sql = "SELECT * FROM {$wpdb->prefix}mrylm_setting"; 507 $lm_setting = $wpdb->get_row($mrylm_setting_sql); 508 372 $lm_page_url = $lm_setting->lm_org_url.$lm_url_type.'/'; 373 509 374 foreach ($lm_cities as $obj) { 510 375 … … 512 377 $city = array(); 513 378 $city['lm_parent_id'] = $obj->parent_id; 514 $city['lm_type'] = $obj->lm_type;515 $city['lm_slug'] = $obj->slug;516 379 $city['lm_url_slug'] = $obj->url_slug; 517 380 $city['lm_city'] = $city_name; 518 $city['lm_topics'] = $obj->topics;;519 381 $lm_city = (object) $city; 520 382 521 383 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != ''){ 522 384 523 $lm_page_url = $lm_setting->lm_org_url.$lm_url_type.'/'; 524 $insert_id = create_lm_page($lm_setting, $lm_city, $lm_page_url); 525 $lm_setting->lm_page_url = $lm_page_url; 526 create_lm_topic_pages($insert_id, $lm_setting, $lm_city); 385 create_lm_page($lm_setting, $lm_city, $lm_page_url); 527 386 } 528 387 } … … 534 393 535 394 536 /* Add City data Start Done*/395 /* Add City data Start*/ 537 396 add_action('wp_ajax_nopriv_mrylm-add-city', 'mrylm_add_city'); 538 397 function mrylm_add_city() { 539 398 540 399 $lm_city = $_POST['city']; 541 542 // we can create parent page , LM type page 543 global $wpdb; 544 require_once(MRYLM_PLUGIN_DIR . 'activate.php' ); 545 mrylm_update_tables(); 546 400 mrylm_upgrade_function(array(), array()); 547 401 548 402 if (isset($lm_city)) { … … 550 404 $lm_city = json_decode($lm_city); 551 405 406 global $wpdb; 552 407 553 408 $mrylm_setting_sql = "SELECT * FROM {$wpdb->prefix}mrylm_setting"; … … 581 436 'lm_historic_landmark' => $lm_city->historic_landmark, 582 437 'lm_assisted_living' => $lm_city->assisted_living, 583 'lm_restaurant' => $lm_city->restaurant, 584 'lm_topics' => $lm_city->topics, 585 'lm_type' => $lm_city->lm_type, 586 'lm_is_default' => $lm_city->is_default, 587 'lm_other_info' => $lm_city->other_info, 588 'lm_neighbour_id' => $lm_city->neighbour_id 438 'lm_restaurant' => $lm_city->restaurant 589 439 ); 590 440 $mrylm_table_name = $wpdb->prefix . "mrylm_cities"; … … 594 444 $obj = array(); 595 445 $obj['lm_parent_id'] = $lm_city->parent_id; 596 $obj['lm_slug'] = $lm_city->slug;597 446 $obj['lm_url_slug'] = $lm_city->url_slug; 598 447 $obj['lm_city'] = $lm_city->city; 599 $obj['lm_type'] = $lm_city->lm_type; 600 $obj['lm_topics'] = $lm_city->topics; 601 $lm_obj_city = (object) $obj; 602 448 $lm_obj_city = (object) $obj; 449 603 450 // now process multi page 604 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != '' && $lm_setting->lm_types == 'multi-type'){451 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != ''){ 605 452 606 453 $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title); 607 608 454 foreach($lm_multi_titles AS $key=>$lm_title){ 609 455 610 456 $lm_page_url = $lm_setting->lm_org_url.$key.'/'; 611 612 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_page_url); 613 $lm_setting->lm_page_url = $lm_page_url; 614 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 457 create_lm_page($lm_setting, $lm_obj_city, $lm_page_url); 615 458 } 616 459 617 }else if($lm_setting->lm_types == 'type-wise'){618 619 620 if($lm_obj_city->lm_type){621 $lm_page_url = $lm_setting->lm_org_url.$lm_obj_city->lm_type.'/';622 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_page_url);623 $lm_setting->lm_page_url = $lm_page_url;624 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city);625 }626 627 628 460 }else{ 629 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_setting->lm_page_url); 630 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 461 create_lm_page($lm_setting, $lm_obj_city, $lm_setting->lm_page_url); 631 462 } 632 463 } … … 634 465 /* Add City data End*/ 635 466 636 637 /* Update City data Start Done*/ 467 function create_lm_page($lm_setting, $lm_city, $lm_page_url){ 468 469 global $wpdb; 470 471 // now we will create page for each city 472 $lm_parent_post_id = url_to_postid($lm_page_url); 473 $lm_post_id = url_to_postid($lm_page_url . $lm_city->lm_url_slug); 474 475 if ($lm_city->lm_parent_id > 0) { 476 $lm_sql = "SELECT * FROM {$wpdb->prefix}mrylm_cities WHERE lm_city_id = '$lm_city->lm_parent_id'"; 477 $lm_city_2 = $wpdb->get_row($lm_sql); 478 $lm_parent_post_id = url_to_postid($lm_page_url. $lm_city_2->lm_url_slug); 479 } 480 481 // If there are no sub page then we hv to parent post id 0 482 if ($lm_setting->lm_page_type == 'base_page') { 483 $lm_parent_post_id = 0; 484 } 485 486 $mrylm_post = array( 487 'ID' => $lm_post_id, 488 'post_title' => $lm_city->lm_city, 489 'post_content' => '', 490 'post_status' => 'publish', 491 'post_type' => 'page', 492 'post_parent' => $lm_parent_post_id, 493 'post_category' => array() 494 ); 495 496 //Insert the post into the database 497 $lm_insert_id = wp_insert_post($mrylm_post); 498 499 // to set template for the page 500 if (!add_post_meta($lm_insert_id, '_wp_page_template', 'local-magic.php', true)) { 501 update_post_meta($lm_insert_id, '_wp_page_template', 'local-magic.php'); 502 } 503 } 504 505 /* Update City data Start*/ 638 506 add_action('wp_ajax_nopriv_mrylm-update-city', 'mrylm_update_city'); 639 507 function mrylm_update_city() { 640 508 641 509 $lm_city = $_POST['city']; 642 643 require_once(MRYLM_PLUGIN_DIR . 'activate.php' ); 644 mrylm_update_tables(); 510 mrylm_upgrade_function(array(), array()); 645 511 646 512 if (isset($lm_city)) { … … 659 525 660 526 // Update city data 661 $city = stripslashes($lm_city->city); 662 663 $wpdb->update( 664 $wpdb->prefix.'mrylm_cities', 665 array( 666 'lm_parent_id' => $lm_city->parent_id, 667 'lm_city' => $city, 668 'lm_state' => $lm_city->state, 669 'lm_slug' => $lm_city->slug, 670 'lm_url_slug' => $lm_city->url_slug, 671 'lm_google_map_id' => $lm_city->google_map_id, 672 'lm_form_id' => $lm_city->form_id, 673 'lm_city_keyword_separator' => $lm_city->city_keyword_separator, 674 'lm_location' => $lm_city->location, 675 'lm_city_phone' => $lm_city->city_phone, 676 'lm_city_mayor' => $lm_city->city_mayor, 677 'lm_population' => $lm_city->population, 678 'lm_avg_home_value' => $lm_city->avg_home_value, 679 'lm_avg_household_income' => $lm_city->avg_household_income, 680 'lm_avg_temperature' => $lm_city->avg_temperature, 681 'lm_price_range' => $lm_city->price_range, 682 'lm_image' => $lm_city->image, 683 'lm_description' => $lm_city->description, 684 'lm_telephone' => $lm_city->telephone, 685 'lm_educational_institution' => $lm_city->educational_institution, 686 'lm_state_park' => $lm_city->state_park, 687 'lm_historic_landmark' => $lm_city->historic_landmark, 688 'lm_assisted_living' => $lm_city->assisted_living, 689 'lm_restaurant' => $lm_city->restaurant, 690 'lm_topics' => $lm_city->topics, 691 'lm_type' => $lm_city->lm_type, 692 'lm_is_default' => $lm_city->is_default, 693 'lm_other_info' => $lm_city->other_info, 694 'lm_neighbour_id' => $lm_city->neighbour_id 695 ), 696 array( 'lm_city_id' => $lm_city->id ) 697 ); 698 699 $obj = array(); 527 $city = stripslashes($lm_city->city); 528 $data_arr = "UPDATE {$wpdb->prefix}mrylm_cities 529 SET lm_parent_id = '" . $lm_city->parent_id . "', 530 lm_city = '" . $city . "', 531 lm_state = '" . $lm_city->state . "', 532 lm_slug = '" . $lm_city->slug . "', 533 lm_url_slug = '" . $lm_city->url_slug . "', 534 lm_google_map_id = '" . $lm_city->google_map_id . "', 535 lm_form_id = '" . $lm_city->form_id . "', 536 lm_city_keyword_separator = '" . $lm_city->city_keyword_separator . "', 537 lm_location = '" . $lm_city->location . "', 538 lm_city_phone = '" . $lm_city->city_phone . "', 539 lm_city_mayor = '" . $lm_city->city_mayor . "', 540 lm_population = '" . $lm_city->population . "', 541 lm_avg_home_value = '" . $lm_city->avg_home_value . "', 542 lm_avg_household_income = '" . $lm_city->avg_household_income . "', 543 lm_avg_temperature = '" . $lm_city->avg_temperature . "', 544 lm_price_range = '" . $lm_city->price_range . "', 545 lm_image = '" . $lm_city->image . "', 546 lm_description = '" . $lm_city->description . "', 547 lm_telephone = '" . $lm_city->telephone . "', 548 lm_educational_institution = '" . $lm_city->educational_institution . "', 549 lm_state_park = '" . $lm_city->state_park . "', 550 lm_historic_landmark = '" . $lm_city->historic_landmark . "', 551 lm_assisted_living = '" . $lm_city->assisted_living . "' , 552 lm_restaurant = '" . $lm_city->restaurant . "' 553 WHERE lm_city_id = " . $lm_city->id . ""; 554 555 $wpdb->query($data_arr); 556 557 $obj = array(); 700 558 $obj['lm_parent_id'] = $lm_city->parent_id; 701 $obj['lm_slug'] = $lm_city->slug;702 559 $obj['lm_url_slug'] = $lm_city->url_slug; 703 560 $obj['lm_city'] = $lm_city->city; 704 $obj['lm_type'] = $lm_city->lm_type;705 $obj['lm_topics'] = $lm_city->topics;706 561 $lm_obj_city = (object) $obj; 707 708 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != '' && $lm_setting->lm_types == 'multi-type'){562 563 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != ''){ 709 564 710 565 $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title); … … 713 568 $lm_page_url = $lm_setting->lm_org_url.$key.'/'; 714 569 $lm_post_id = url_to_postid($lm_page_url . $lm_city_old->lm_url_slug); 715 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_page_url, $lm_post_id); 716 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 570 update_lm_page($lm_setting, $lm_obj_city, $lm_page_url, $lm_post_id); 717 571 } 718 719 }else if($lm_setting->lm_types == 'type-wise'){720 721 if($lm_obj_city->lm_type){722 $lm_page_url = $lm_setting->lm_org_url.$lm_obj_city->lm_type.'/';723 $lm_post_id = url_to_postid($lm_page_url . $lm_city_old->lm_url_slug);724 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_page_url, $lm_post_id);725 $lm_setting->lm_page_url = $lm_page_url;726 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city);727 }728 572 729 573 }else{ 730 574 731 575 $lm_post_id = url_to_postid($lm_setting->lm_page_url . $lm_city_old->lm_url_slug); 732 $insert_id = create_lm_page($lm_setting, $lm_obj_city, $lm_setting->lm_page_url, $lm_post_id); 733 create_lm_topic_pages($insert_id, $lm_setting, $lm_obj_city); 734 } 576 update_lm_page($lm_setting, $lm_obj_city, $lm_setting->lm_page_url, $lm_post_id); 577 } 578 579 // now we will create page for city 580 735 581 } 736 582 } 737 583 /* Update City data End */ 738 584 739 /* Manage News data Start */ 585 function update_lm_page($lm_setting, $lm_city, $lm_page_url, $lm_post_id){ 586 587 global $wpdb; 588 589 $lm_parent_post_id = url_to_postid($lm_page_url); 590 591 if($lm_city->lm_parent_id > 0){ 592 $lm_sql_2 = "SELECT * FROM {$wpdb->prefix}mrylm_cities WHERE lm_city_id = '$lm_city->lm_parent_id'"; 593 $lm_city_2 = $wpdb->get_row($lm_sql_2); 594 $lm_parent_post_id = url_to_postid($lm_page_url.$lm_city_2->lm_url_slug); 595 } 596 597 // If there are no sub page then we hv to parent post id 0 598 if ($lm_setting->lm_page_type == 'base_page') { 599 $lm_parent_post_id = 0; 600 } 601 602 $mrylm_post = array( 603 'ID' => $lm_post_id, 604 'post_title' => $lm_city->lm_city, 605 'post_name' => $lm_city->lm_url_slug, 606 'post_content' => '', 607 'post_status' => 'publish', 608 'post_type' => 'page', 609 'post_parent' => $lm_parent_post_id, 610 'post_category' => array() 611 ); 612 613 //Insert the post into the database 614 $lm_insert_id = wp_update_post($mrylm_post); 615 616 // to set template for the page 617 if (!add_post_meta($lm_insert_id, '_wp_page_template', 'local-magic.php', true)) { 618 update_post_meta($lm_insert_id, '_wp_page_template', 'local-magic.php'); 619 } 620 } 621 622 623 /* Manage News data Start */ 740 624 add_action('wp_ajax_nopriv_mrylm-manage-news', 'mrylm_manage_news'); 741 625 function mrylm_manage_news() { … … 787 671 } 788 672 789 echo TRUE; 673 echo TRUE; 674 790 675 } 791 676 /* Manage News data End */ 792 677 793 678 794 /* Delete a City Start Done*/679 /* Delete a City Start */ 795 680 add_action('wp_ajax_nopriv_mrylm-delete-city', 'mrylm_delete_city'); 796 681 function mrylm_delete_city() { 797 682 798 683 global $wpdb; 799 800 require_once(MRYLM_PLUGIN_DIR . 'activate.php' );801 684 $lm_city_id = $_POST['city_id']; 802 685 … … 813 696 $wpdb->query($lm_del_news_sql); 814 697 815 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != '' && $lm_setting->lm_types == 'multi-type'){698 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != ''){ 816 699 817 700 $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title); … … 819 702 $postid = url_to_postid($lm_setting->lm_org_url. $key.'/'. $lm_city->lm_url_slug); 820 703 if ($postid) { 821 $parent_url = $lm_setting->lm_org_url. $key.'/'. $lm_city->lm_url_slug; 822 delete_lm_topic_pages($lm_city->lm_topics, $parent_url); 823 wp_delete_post($postid, true); 704 wp_delete_post($postid, true); 824 705 } 825 }826 827 }else if($lm_setting->lm_types == 'type-wise'){828 829 if($lm_city->lm_type){830 831 $lm_page_url = $lm_setting->lm_org_url.$lm_city->lm_type.'/'.$lm_city->lm_url_slug;832 $postid = url_to_postid($lm_page_url);833 if ($postid) {834 delete_lm_topic_pages($lm_city->lm_topics, $lm_page_url);835 wp_delete_post($postid, true);836 }837 706 } 838 707 … … 841 710 $postid = url_to_postid($lm_setting->lm_page_url . $lm_city->lm_url_slug); 842 711 if ($postid) { 843 $parent_url = $lm_setting->lm_page_url . $lm_city->lm_url_slug; 844 delete_lm_topic_pages($lm_city->lm_topics, $parent_url); 845 wp_delete_post($postid, true); 712 wp_delete_post($postid, true); 846 713 } 847 714 } -
local-magic/trunk/readme.txt
r3200711 r3200723 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 10 11 The Local Magic © WordPress plugin extends the functionality of the SaaS Local Magic© to WordPress so that the local magic can be displayed on the WordPress website. The plugin is for customers of Local Magic©that have an active subscription with the company.11 The Local Magic® WordPress plugin extends the functionality of the SaaS Local Magic® to WordPress so that the local magic can be displayed on the WordPress website. The plugin is for customers of Local Magic® that have an active subscription with the company. 12 12 13 13 == Description == 14 14 15 The Local Magic © WordPress plugin extends the functionality of the SaaS Local Magic© to WordPress so that the local magic can be displayed on the WordPress website. The plugin is for customers of Local Magic©that have an active subscription with the company.15 The Local Magic® WordPress plugin extends the functionality of the SaaS Local Magic® to WordPress so that the local magic can be displayed on the WordPress website. The plugin is for customers of Local Magic® that have an active subscription with the company. 16 16 17 17 … … 103 103 =2.3.0= 104 104 1. Bug fixing and Some minor functionality added 105 =2.4.0=106 1. Topic feature added107 =2.5.0=108 1. Re-arrange functionality
Note: See TracChangeset
for help on using the changeset viewer.