Changeset 3200916
- Timestamp:
- 12/02/2024 01:08:36 PM (15 months ago)
- Location:
- local-magic
- Files:
-
- 4 edited
-
tags/2.5.0/activate.php (modified) (1 diff)
-
tags/2.5.0/admin/setting.php (modified) (9 diffs)
-
trunk/activate.php (modified) (1 diff)
-
trunk/admin/setting.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
local-magic/tags/2.5.0/activate.php
r3200897 r3200916 361 361 } 362 362 } 363 364 365 366 // OK 367 function create_lm_page_new($lm_setting, $lm_city, $lm_page_url, $lm_post_ID = NULL){ 368 369 global $wpdb; 370 371 // now we will create page for each city 372 $lm_parent_post_id = url_to_postid($lm_page_url); 373 374 $lm_post_id = $lm_post_ID > 0 ? $lm_post_ID : url_to_postid($lm_page_url.$lm_city->lm_url_slug); 375 376 if($lm_city->lm_parent_id > 0){ 377 $lm_sql = "SELECT * FROM {$wpdb->prefix}mrylm_cities WHERE lm_city_id = '$lm_city->lm_parent_id'"; 378 $lm_city_2 = $wpdb->get_row($lm_sql); 379 $lm_parent_post_id = url_to_postid($lm_page_url.$lm_city_2->lm_url_slug); 380 } 381 382 // If there are no sub page then we hv to parent post id 0 383 if ($lm_setting->lm_page_type == 'base_page') { 384 $lm_parent_post_id = 0; 385 } 386 387 $mrylm_post = array( 388 'ID'=> $lm_post_id, 389 'post_title' => $lm_city->lm_city, 390 'post_name' => $lm_city->lm_slug, 391 'post_content' => '', 392 'post_status' => 'publish', 393 'post_type' => 'page', 394 'post_parent' => $lm_parent_post_id, 395 'post_author' => 1, 396 'post_category' => array() 397 ); 398 399 400 //Insert the post into the database 401 $lm_insert_id = $lm_post_id > 0 ? wp_update_post($mrylm_post) : wp_insert_post( $mrylm_post ); 402 403 // to set template for the page 404 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 return $lm_insert_id; 409 } 410 411 // OK 412 function create_lm_topic_pages_new($lm_parent_post_id, $lm_setting, $lm_city_obj){ 413 414 415 if($lm_setting->lm_is_topic && $lm_city_obj->lm_topics != ''){ 416 417 $topic_arr = explode('=',$lm_city_obj->lm_topics); 418 419 if(is_array($topic_arr)){ 420 foreach($topic_arr AS $topic){ 421 422 $data_arr = explode('|', $topic); 423 if(is_array($data_arr)){ 424 425 // $lm_setting->lm_page_url == same as org_url + url type 426 $lm_post_id = url_to_postid($lm_setting->lm_page_url.$lm_city_obj->lm_url_slug.'/'.$data_arr[0]); 427 428 $mrylm_post = array( 429 'ID'=> $lm_post_id, 430 'post_title' => $data_arr[1], 431 'post_name' => $data_arr[0], 432 'post_content' => '', 433 'post_status' => 'publish', 434 'post_type' => 'page', 435 'post_parent' => $lm_parent_post_id, 436 'post_author' => 1, 437 'post_category' => array() 438 ); 439 440 // $lm_insert_id = wp_insert_post( $mrylm_post ); 441 $lm_insert_id = $lm_post_id > 0 ? wp_update_post($mrylm_post) : wp_insert_post( $mrylm_post ); 442 // to set template for the page 443 if ( ! add_post_meta( $lm_insert_id, '_wp_page_template', 'local-magic.php', true )) { 444 update_post_meta( $lm_insert_id, '_wp_page_template', 'local-magic.php' ); 445 } 446 } 447 } 448 } 449 } 450 } 451 -
local-magic/tags/2.5.0/admin/setting.php
r3200723 r3200916 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 10 25 function mrylm_check_key_format($mrylm_key){ 11 26 … … 21 36 } 22 37 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 city42 $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 052 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 database67 $lm_insert_id = wp_insert_post( $mrylm_post );68 69 // to set template for the page70 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 76 38 function mrylm_process_pages(){ 77 39 … … 83 45 if($lm_setting->lm_url_type == 'wp_remote_get'){ 84 46 $mrylm_response = wp_remote_get('https://localmagic.reviewmanager.app/plugin/cities/' . $lm_setting->lm_unique_id); 85 $mrylm_cities = json_decode($mrylm_response['body']); 86 47 $mrylm_cities = json_decode($mrylm_response['body']); 87 48 }else{ 88 49 $mrylm_response = file_get_contents('https://localmagic.reviewmanager.app/plugin/cities/' . $lm_setting->lm_unique_id); … … 90 51 } 91 52 92 if(!empty($mrylm_cities)){53 if(!empty($mrylm_cities)){ 93 54 94 55 // Trancating existing Cities table … … 125 86 'lm_historic_landmark' => $obj->historic_landmark, 126 87 'lm_assisted_living' => $obj->assisted_living, 127 'lm_restaurant' => $obj->restaurant 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 128 94 ); 129 95 … … 133 99 $lm_city = array(); 134 100 $lm_city['lm_parent_id'] = $obj->parent_id; 101 $lm_city['lm_type'] = $obj->lm_type; 102 $lm_city['lm_slug'] = $obj->slug; 135 103 $lm_city['lm_url_slug'] = $obj->url_slug; 136 104 $lm_city['lm_city'] = $obj->city; 105 $lm_city['lm_topics'] = $obj->topics; 137 106 $lm_obj_city = (object) $lm_city; 138 107 139 108 // need to process multi type 140 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != '' ){109 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != '' && $lm_setting->lm_types == 'multi-type'){ 141 110 142 111 $lm_multi_titles = get_multi_type_formatted_data($lm_setting->lm_multi_title); … … 144 113 145 114 $lm_page_url = $lm_setting->lm_org_url.$key.'/'; 146 create_lm_pages($lm_setting, $lm_obj_city, $lm_page_url); 115 $insert_id = create_lm_page_new($lm_setting, $lm_obj_city, $lm_page_url); 116 $lm_setting->lm_page_url = $lm_page_url; 117 create_lm_topic_pages_new($insert_id, $lm_setting, $lm_obj_city); 147 118 } 148 119 149 }else{ 150 create_lm_pages($lm_setting, $lm_obj_city, $lm_setting->lm_page_url); 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_new($lm_setting, $lm_obj_city, $lm_page_url); 125 $lm_setting->lm_page_url = $lm_page_url; 126 create_lm_topic_pages_new($insert_id, $lm_setting, $lm_obj_city); 127 } 128 129 }else{ // single type city 130 131 $insert_id = create_lm_page_new($lm_setting, $lm_obj_city, $lm_setting->lm_page_url); 132 create_lm_topic_pages_new($insert_id, $lm_setting, $lm_obj_city); 151 133 } 152 134 } … … 158 140 } 159 141 } 160 161 142 162 143 if (isset($_POST['submit']) && is_user_logged_in()) { … … 245 226 'lm_multi_keyword' => $lm_setting->multi_keyword, 246 227 'lm_multi_head' => $lm_setting->multi_head, 247 'lm_multi_near_me' => $lm_setting->multi_near_me 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 248 231 ); 249 232 -
local-magic/trunk/activate.php
r3200897 r3200916 361 361 } 362 362 } 363 364 365 366 // OK 367 function create_lm_page_new($lm_setting, $lm_city, $lm_page_url, $lm_post_ID = NULL){ 368 369 global $wpdb; 370 371 // now we will create page for each city 372 $lm_parent_post_id = url_to_postid($lm_page_url); 373 374 $lm_post_id = $lm_post_ID > 0 ? $lm_post_ID : url_to_postid($lm_page_url.$lm_city->lm_url_slug); 375 376 if($lm_city->lm_parent_id > 0){ 377 $lm_sql = "SELECT * FROM {$wpdb->prefix}mrylm_cities WHERE lm_city_id = '$lm_city->lm_parent_id'"; 378 $lm_city_2 = $wpdb->get_row($lm_sql); 379 $lm_parent_post_id = url_to_postid($lm_page_url.$lm_city_2->lm_url_slug); 380 } 381 382 // If there are no sub page then we hv to parent post id 0 383 if ($lm_setting->lm_page_type == 'base_page') { 384 $lm_parent_post_id = 0; 385 } 386 387 $mrylm_post = array( 388 'ID'=> $lm_post_id, 389 'post_title' => $lm_city->lm_city, 390 'post_name' => $lm_city->lm_slug, 391 'post_content' => '', 392 'post_status' => 'publish', 393 'post_type' => 'page', 394 'post_parent' => $lm_parent_post_id, 395 'post_author' => 1, 396 'post_category' => array() 397 ); 398 399 400 //Insert the post into the database 401 $lm_insert_id = $lm_post_id > 0 ? wp_update_post($mrylm_post) : wp_insert_post( $mrylm_post ); 402 403 // to set template for the page 404 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 return $lm_insert_id; 409 } 410 411 // OK 412 function create_lm_topic_pages_new($lm_parent_post_id, $lm_setting, $lm_city_obj){ 413 414 415 if($lm_setting->lm_is_topic && $lm_city_obj->lm_topics != ''){ 416 417 $topic_arr = explode('=',$lm_city_obj->lm_topics); 418 419 if(is_array($topic_arr)){ 420 foreach($topic_arr AS $topic){ 421 422 $data_arr = explode('|', $topic); 423 if(is_array($data_arr)){ 424 425 // $lm_setting->lm_page_url == same as org_url + url type 426 $lm_post_id = url_to_postid($lm_setting->lm_page_url.$lm_city_obj->lm_url_slug.'/'.$data_arr[0]); 427 428 $mrylm_post = array( 429 'ID'=> $lm_post_id, 430 'post_title' => $data_arr[1], 431 'post_name' => $data_arr[0], 432 'post_content' => '', 433 'post_status' => 'publish', 434 'post_type' => 'page', 435 'post_parent' => $lm_parent_post_id, 436 'post_author' => 1, 437 'post_category' => array() 438 ); 439 440 // $lm_insert_id = wp_insert_post( $mrylm_post ); 441 $lm_insert_id = $lm_post_id > 0 ? wp_update_post($mrylm_post) : wp_insert_post( $mrylm_post ); 442 // to set template for the page 443 if ( ! add_post_meta( $lm_insert_id, '_wp_page_template', 'local-magic.php', true )) { 444 update_post_meta( $lm_insert_id, '_wp_page_template', 'local-magic.php' ); 445 } 446 } 447 } 448 } 449 } 450 } 451 -
local-magic/trunk/admin/setting.php
r3200723 r3200916 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 10 25 function mrylm_check_key_format($mrylm_key){ 11 26 … … 21 36 } 22 37 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 city42 $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 052 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 database67 $lm_insert_id = wp_insert_post( $mrylm_post );68 69 // to set template for the page70 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 76 38 function mrylm_process_pages(){ 77 39 … … 83 45 if($lm_setting->lm_url_type == 'wp_remote_get'){ 84 46 $mrylm_response = wp_remote_get('https://localmagic.reviewmanager.app/plugin/cities/' . $lm_setting->lm_unique_id); 85 $mrylm_cities = json_decode($mrylm_response['body']); 86 47 $mrylm_cities = json_decode($mrylm_response['body']); 87 48 }else{ 88 49 $mrylm_response = file_get_contents('https://localmagic.reviewmanager.app/plugin/cities/' . $lm_setting->lm_unique_id); … … 90 51 } 91 52 92 if(!empty($mrylm_cities)){53 if(!empty($mrylm_cities)){ 93 54 94 55 // Trancating existing Cities table … … 125 86 'lm_historic_landmark' => $obj->historic_landmark, 126 87 'lm_assisted_living' => $obj->assisted_living, 127 'lm_restaurant' => $obj->restaurant 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 128 94 ); 129 95 … … 133 99 $lm_city = array(); 134 100 $lm_city['lm_parent_id'] = $obj->parent_id; 101 $lm_city['lm_type'] = $obj->lm_type; 102 $lm_city['lm_slug'] = $obj->slug; 135 103 $lm_city['lm_url_slug'] = $obj->url_slug; 136 104 $lm_city['lm_city'] = $obj->city; 105 $lm_city['lm_topics'] = $obj->topics; 137 106 $lm_obj_city = (object) $lm_city; 138 107 139 108 // need to process multi type 140 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != '' ){109 if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != '' && $lm_setting->lm_types == 'multi-type'){ 141 110 142 111 $lm_multi_titles = get_multi_type_formatted_data($lm_setting->lm_multi_title); … … 144 113 145 114 $lm_page_url = $lm_setting->lm_org_url.$key.'/'; 146 create_lm_pages($lm_setting, $lm_obj_city, $lm_page_url); 115 $insert_id = create_lm_page_new($lm_setting, $lm_obj_city, $lm_page_url); 116 $lm_setting->lm_page_url = $lm_page_url; 117 create_lm_topic_pages_new($insert_id, $lm_setting, $lm_obj_city); 147 118 } 148 119 149 }else{ 150 create_lm_pages($lm_setting, $lm_obj_city, $lm_setting->lm_page_url); 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_new($lm_setting, $lm_obj_city, $lm_page_url); 125 $lm_setting->lm_page_url = $lm_page_url; 126 create_lm_topic_pages_new($insert_id, $lm_setting, $lm_obj_city); 127 } 128 129 }else{ // single type city 130 131 $insert_id = create_lm_page_new($lm_setting, $lm_obj_city, $lm_setting->lm_page_url); 132 create_lm_topic_pages_new($insert_id, $lm_setting, $lm_obj_city); 151 133 } 152 134 } … … 158 140 } 159 141 } 160 161 142 162 143 if (isset($_POST['submit']) && is_user_logged_in()) { … … 245 226 'lm_multi_keyword' => $lm_setting->multi_keyword, 246 227 'lm_multi_head' => $lm_setting->multi_head, 247 'lm_multi_near_me' => $lm_setting->multi_near_me 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 248 231 ); 249 232
Note: See TracChangeset
for help on using the changeset viewer.