Plugin Directory

Changeset 3200723


Ignore:
Timestamp:
12/02/2024 09:03:52 AM (15 months ago)
Author:
matthewrubin
Message:

Version update

Location:
local-magic
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • local-magic/tags/2.5.0/activate.php

    r3199499 r3200723  
    5454                lm_multi_head text CHARACTER SET utf8 NULL,   
    5555                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',   
    5856                PRIMARY KEY (id)
    5957        );";
     
    8987                lm_assisted_living TEXT CHARACTER SET utf8 NULL,
    9088                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,
    9689                PRIMARY KEY (id)
    9790        );";
     
    202195            ;";
    203196            $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        }
    230198    }
    231199
     
    277245            $wpdb->query($cities_alter_sql_2);
    278246        }
    279        
    280        
    281         $cities_table_exist_3 = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
    282             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_cities
    285             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.COLUMNS
    291             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_cities
    294             ADD `lm_type` VARCHAR(30) NULL AFTER `lm_topics`
    295             ;";
    296             $wpdb->query($cities_alter_sql_4);
    297         }
    298        
    299        
    300         // city last update
    301         $cities_table_exist_5 = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
    302             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_cities
    305             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 update
    312         $cities_table_exist_6 = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
    313             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_cities
    316             ADD `lm_neighbour_id` int(11) NULL DEFAULT '0' AFTER `lm_other_info`
    317             ;";
    318             $wpdb->query($cities_alter_sql_6);
    319         }
    320        
    321247    }
    322248
    323249    mrylm_create_tables();
    324    
    325250}
    326251
    327 // OK
    328 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 city 
    333         $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 0
    344         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 database           
    362         $lm_insert_id =  $lm_post_id > 0 ? wp_update_post($mrylm_post) : wp_insert_post( $mrylm_post );
    363 
    364         // to set template for the page
    365         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 // OK
    373 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 type
    387                      $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 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             }
    409         }
    410     }   
    411 }
    412 
    413 // OK
    414 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 // OK
    438252function create_service_area_page($lm_setting) {
    439253
     
    453267        'post_type' => 'page',
    454268        'post_parent' => 0,
    455         'post_author'   => 1,
    456269        'post_category' => array()
    457270    );
  • local-magic/tags/2.5.0/admin/setting.php

    r3199499 r3200723  
    88$mrylm_msg = "";
    99
    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 
    2510function mrylm_check_key_format($mrylm_key){
    2611   
     
    3621}
    3722
     23function 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
     37function 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
    3876function mrylm_process_pages(){
    3977   
     
    4583    if($lm_setting->lm_url_type == 'wp_remote_get'){       
    4684        $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       
    4887    }else{                 
    4988        $mrylm_response = file_get_contents('https://localmagic.reviewmanager.app/plugin/cities/' . $lm_setting->lm_unique_id);
     
    5190    }
    5291     
    53     if(!empty($mrylm_cities)){           
     92       if(!empty($mrylm_cities)){           
    5493         
    5594         // Trancating existing Cities table
     
    86125                'lm_historic_landmark' => $obj->historic_landmark,
    87126                '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
    94128            );
    95129
     
    99133            $lm_city = array();
    100134            $lm_city['lm_parent_id'] = $obj->parent_id;
    101             $lm_city['lm_type'] = $obj->lm_type;
    102             $lm_city['lm_slug'] = $obj->slug;
    103135            $lm_city['lm_url_slug'] = $obj->url_slug;
    104136            $lm_city['lm_city'] = $obj->city;
    105             $lm_city['lm_topics'] = $obj->topics;
    106137            $lm_obj_city = (object) $lm_city;
    107138           
    108139            // 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 != ''){
    110141
    111142                $lm_multi_titles = get_multi_type_formatted_data($lm_setting->lm_multi_title);
     
    113144
    114145                    $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);   
    118147                }
    119148
    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);
    133151            }           
    134152        }
     
    140158    }   
    141159}
     160
    142161
    143162if (isset($_POST['submit']) && is_user_logged_in()) {
     
    226245                    'lm_multi_keyword' => $lm_setting->multi_keyword,
    227246                    '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
    231248                );
    232249
  • local-magic/tags/2.5.0/include/function.php

    r3199499 r3200723  
    99}
    1010
    11 
    1211function get_multi_type_data($multi_type_data = null){
    1312   
     
    2423}
    2524
    26 
    2725function mrylm_get_city(){
    2826   
    2927    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;
    3035   
    3136    $lm_setting_sql = "SELECT * FROM {$wpdb->prefix}mrylm_setting";
    3237    $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 format
    43     if($lm_setting->lm_is_topic){
    44         if(count($arr) > 4){ // there are topic
    45             $slug = $arr[4]; 
    46         }   
    47     }
    48      
    4938    if ($lm_setting->lm_org_url == $url) {
    50         $slug = $lm_setting->lm_default_city;
     39        $full_slug = $lm_setting->lm_default_city;
    5140    }   
    5241   
    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);
    5648    }
    57     $lm_city = $wpdb->get_row($lm_sql);     
    5849   
    5950    return $lm_city;
     
    311302 
    312303        $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    }   
    350305   
    351306   
     
    406361    $reviews = mrylm_review_testimonial($lm_city);
    407362    $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   
    409371    return $content; 
    410372   
     
    484446
    485447            // 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);
    487449            $image->setAttribute('alt', $title_text);
    488450            $image->setAttribute('title', $title_text);
     
    700662        // get news data as per keyword   
    701663        $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        }
    704670
    705671        $style =  '<style>';
     
    832798}
    833799   
     800function 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   
    834869function mrylm_review_testimonial($lm_city = null){     
    835870   
     
    14051440
    14061441/* Job End */
     1442
    14071443
    14081444/* POI Start */
  • local-magic/tags/2.5.0/local-magic.php

    r3200713 r3200723  
    1212 * Plugin Name:       Local Magic
    1313 * Plugin URI:        https://www.mrmarketingres.com/local-magic
    14  * Description:       The Local Magic&#169; WordPress plugin extends the functionality of the SaaS Local Magic&#169; to WordPress so that the local news feed can be displayed on the WordPress website. The plugin is for customers of Local Magic&#169; 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.
    1515 * Version:           2.5.0
    1616 * Requires at least: 3.5.1
    17  * Tested up to:      6.3.0
     17 * Tested up to:      6.7.1
    1818 * Requires PHP:      5.6.0
    1919 * Author:            matthewrubin
     
    2727    exit; // Exit if accessed directly
    2828
    29 
    30 define('MRYLM_VERSION', '2.4.0');
     29define('MRYLM_VERSION', '2.5.0');
    3130
    3231define('MRYLM_PLUGIN_DIR', plugin_dir_path(__FILE__));
     
    5150/* ACTION START */
    5251
    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');   
     52function mrylm_enqueue_scripts() {   
    5853}
    5954add_action('wp_enqueue_scripts', 'mrylm_enqueue_scripts');
    60 
    6155
    6256function mrylm_admin_menu() {
     
    6761add_action('admin_menu', 'mrylm_admin_menu');
    6862
    69 
    7063function mrylm_options() {
    7164
     
    7972
    8073/* UPDATE ACTION START */
     74add_action( 'upgrader_process_complete', 'mrylm_upgrade_function',10, 2);
    8175function mrylm_upgrade_function( $upgrader_object, $options ) {
    8276   
    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}
    8780/* UPDATE ACTION END */
    8881
     
    9487add_shortcode('mrylm-article', 'mrylm_article_shortcode');
    9588
    96 
    9789function mrylm_dropdown_menu_shortcode($attr, $content) {
    9890    return mrylm_dropdown_menu($content);
     
    127119/* SHORT CODE END */
    128120
    129 
    130121// DESTROY LM
    131 /* Manage/ Destroy Page data Start  Done*/
     122/* Manage/ Destroy Page data Start */
    132123add_action('wp_ajax_nopriv_mrylm-manage-pages', 'mrylm_manage_pages');
    133 
    134124function mrylm_manage_pages() {
    135125
    136126    global $wpdb;
    137     require_once(MRYLM_PLUGIN_DIR . 'activate.php' );
    138     mrylm_update_tables();
    139127   
    140128    $mrylm_setting_sql = "SELECT * FROM {$wpdb->prefix}mrylm_setting";
     
    146134    if (isset($lm_cities) && $lm_cities != '') {
    147135       
    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 != ''){
    150137            $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title);
    151138            foreach($lm_multi_titles AS $key=>$lm_title){
     
    153140                    $postid = url_to_postid($lm_setting->lm_org_url. $key.'/'. $obj->lm_url_slug);
    154141                    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);
    157142                        wp_delete_post($postid, true);
    158143                    }
     
    160145            }
    161146           
    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            
    173147        }else{
    174148            foreach ($lm_cities as $obj) {
    175149                $postid = url_to_postid($lm_setting->lm_page_url . $obj->lm_url_slug);
    176150                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);
    180152                }
    181153            }
     
    209181
    210182
    211 /* Update Setting data Start Done */
     183/* Update Setting data Start */
    212184add_action('wp_ajax_nopriv_mrylm-update-setting', 'mrylm_update_setting');
    213185
     
    275247            'lm_multi_keyword' => $lm_setting->multi_keyword,
    276248            '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
    280250        );
    281251
     
    290260
    291261
    292 /* Manage Cities data Start Pore Hobe */
     262/* Manage Cities data Start */
    293263add_action('wp_ajax_nopriv_mrylm-manage-cities', 'mrylm_manage_cities');
    294264function mrylm_manage_cities() {
    295    
     265
     266    // functional code will go here   
     267    $lm_cities = $_POST['cities'];
    296268    require_once(MRYLM_PLUGIN_DIR . 'activate.php' );
    297269    mrylm_update_tables();
    298     $lm_cities = $_POST['cities'];
    299270     
    300271    if (isset($lm_cities)) {
     
    338309                'lm_historic_landmark' => $obj->historic_landmark,
    339310                '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
    346312            );
    347313
     
    351317            $lm_city = array();
    352318            $lm_city['lm_parent_id'] = $obj->parent_id;
    353             $lm_city['lm_type'] = $obj->lm_type;
    354             $lm_city['lm_slug'] = $obj->slug;
    355319            $lm_city['lm_url_slug'] = $obj->url_slug;
    356320            $lm_city['lm_city'] = $obj->city;
    357             $lm_city['lm_topics'] = $obj->topics;
    358321            $lm_obj_city = (object) $lm_city;
    359322
    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 != ''){
    361324
    362325                $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title);
     
    364327
    365328                    $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);   
    369330                }
    370331
    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);
    383334            }
    384         }       
     335
     336        }
     337       
    385338    }
    386339   
     
    396349
    397350
    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 */
     352add_action('wp_ajax_nopriv_mrylm-manage-single-types', 'mrylm_manage_single_types');
     353function mrylm_manage_single_types() {
     354
     355    // functional code will go here   
    404356    $lm_cities = $_POST['cities'];
    405     $lm_type = $_POST['lm_type'];
    406        
     357    $lm_url_type = $_POST['lm_type'];
     358     
     359
    407360    if (isset($lm_cities)) {
    408361
     
    411364        $lm_cities = json_decode($lm_cities);
    412365       
    413         $lm_del_sql = "DELETE FROM {$wpdb->prefix}mrylm_cities WHERE lm_type = '$lm_type'";
    414         $wpdb->query($lm_del_sql);
    415 
    416366        $mrylm_setting_sql = "SELECT * FROM {$wpdb->prefix}mrylm_setting";
    417367        $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
    500370        require_once(MRYLM_PLUGIN_DIR . 'activate.php' );
    501371        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         
    509374        foreach ($lm_cities as $obj) {
    510375           
     
    512377            $city = array();
    513378            $city['lm_parent_id'] = $obj->parent_id;
    514             $city['lm_type'] = $obj->lm_type;
    515             $city['lm_slug'] = $obj->slug;
    516379            $city['lm_url_slug'] = $obj->url_slug;
    517380            $city['lm_city'] = $city_name;
    518             $city['lm_topics'] = $obj->topics;;
    519381            $lm_city = (object) $city;
    520382
    521383            if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != ''){
    522384               
    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);
    527386            }
    528387        }       
     
    534393
    535394
    536 /* Add City data Start Done */
     395/* Add City data Start*/
    537396add_action('wp_ajax_nopriv_mrylm-add-city', 'mrylm_add_city');
    538397function mrylm_add_city() {
    539398
    540399    $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());
    547401   
    548402    if (isset($lm_city)) {
     
    550404        $lm_city = json_decode($lm_city);
    551405
     406        global $wpdb;
    552407
    553408        $mrylm_setting_sql = "SELECT * FROM {$wpdb->prefix}mrylm_setting";
     
    581436            'lm_historic_landmark' => $lm_city->historic_landmark,
    582437            '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
    589439        );
    590440        $mrylm_table_name = $wpdb->prefix . "mrylm_cities";
     
    594444        $obj = array();
    595445        $obj['lm_parent_id'] = $lm_city->parent_id;
    596         $obj['lm_slug'] = $lm_city->slug;
    597446        $obj['lm_url_slug'] = $lm_city->url_slug;
    598447        $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       
    603450        // 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 != ''){
    605452
    606453            $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title);
    607            
    608454            foreach($lm_multi_titles AS $key=>$lm_title){
    609455
    610456                $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);   
    615458            }
    616459
    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                    
    628460        }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);
    631462        }
    632463    }
     
    634465/* Add City data End*/
    635466
    636 
    637 /* Update City data Start Done*/
     467function 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*/
    638506add_action('wp_ajax_nopriv_mrylm-update-city', 'mrylm_update_city');
    639507function mrylm_update_city() {
    640508
    641509    $lm_city = $_POST['city'];
    642    
    643     require_once(MRYLM_PLUGIN_DIR . 'activate.php' );
    644     mrylm_update_tables();   
     510    mrylm_upgrade_function(array(), array());
    645511   
    646512    if (isset($lm_city)) {
     
    659525       
    660526        // 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();
    700558        $obj['lm_parent_id'] = $lm_city->parent_id;
    701         $obj['lm_slug'] = $lm_city->slug;
    702559        $obj['lm_url_slug'] = $lm_city->url_slug;
    703560        $obj['lm_city'] = $lm_city->city;
    704         $obj['lm_type'] = $lm_city->lm_type;
    705         $obj['lm_topics'] = $lm_city->topics;
    706561        $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 != ''){
    709564                   
    710565            $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title);
     
    713568                $lm_page_url = $lm_setting->lm_org_url.$key.'/';             
    714569                $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);   
    717571            }
    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                 }
    728572
    729573        }else{           
    730574           
    731575            $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       
    735581    }
    736582}
    737583/* Update City data End */
    738584
    739 /* Manage News data Start  */
     585function 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 */
    740624add_action('wp_ajax_nopriv_mrylm-manage-news', 'mrylm_manage_news');
    741625function mrylm_manage_news() {
     
    787671    }
    788672
    789     echo TRUE;   
     673    echo TRUE;
     674   
    790675}
    791676/* Manage News data End */
    792677
    793678
    794 /* Delete a City Start Done */
     679/* Delete a City Start */
    795680add_action('wp_ajax_nopriv_mrylm-delete-city', 'mrylm_delete_city');
    796681function mrylm_delete_city() {
    797682
    798683    global $wpdb;
    799    
    800     require_once(MRYLM_PLUGIN_DIR . 'activate.php' );
    801684    $lm_city_id = $_POST['city_id'];
    802685
     
    813696    $wpdb->query($lm_del_news_sql);
    814697   
    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 != ''){
    816699               
    817700        $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title);
     
    819702           $postid = url_to_postid($lm_setting->lm_org_url. $key.'/'. $lm_city->lm_url_slug);
    820703            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);               
    824705            }
    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             }
    837706        }
    838707       
     
    841710        $postid = url_to_postid($lm_setting->lm_page_url . $lm_city->lm_url_slug);
    842711        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);           
    846713        }       
    847714    }
  • local-magic/tags/2.5.0/readme.txt

    r3200711 r3200723  
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 The Local Magic&#169; WordPress plugin extends the functionality of the SaaS Local Magic&#169; to WordPress so that the local magic can be displayed on the WordPress website. The plugin is for customers of Local Magic&#169; that have an active subscription with the company.
     11The 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.
    1212
    1313== Description ==
    1414
    15 The Local Magic&#169; WordPress plugin extends the functionality of the SaaS Local Magic&#169; to WordPress so that the local magic can be displayed on the WordPress website. The plugin is for customers of Local Magic&#169; that have an active subscription with the company.
     15The 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.
    1616
    1717 
     
    103103=2.3.0=
    1041041. Bug fixing and Some minor functionality added
    105 =2.4.0=
    106 1. Topic feature added
    107 =2.5.0=
    108 1. Re-arrange functionality
  • local-magic/trunk/activate.php

    r3199499 r3200723  
    5454                lm_multi_head text CHARACTER SET utf8 NULL,   
    5555                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',   
    5856                PRIMARY KEY (id)
    5957        );";
     
    8987                lm_assisted_living TEXT CHARACTER SET utf8 NULL,
    9088                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,
    9689                PRIMARY KEY (id)
    9790        );";
     
    202195            ;";
    203196            $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        }
    230198    }
    231199
     
    277245            $wpdb->query($cities_alter_sql_2);
    278246        }
    279        
    280        
    281         $cities_table_exist_3 = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
    282             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_cities
    285             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.COLUMNS
    291             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_cities
    294             ADD `lm_type` VARCHAR(30) NULL AFTER `lm_topics`
    295             ;";
    296             $wpdb->query($cities_alter_sql_4);
    297         }
    298        
    299        
    300         // city last update
    301         $cities_table_exist_5 = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
    302             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_cities
    305             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 update
    312         $cities_table_exist_6 = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
    313             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_cities
    316             ADD `lm_neighbour_id` int(11) NULL DEFAULT '0' AFTER `lm_other_info`
    317             ;";
    318             $wpdb->query($cities_alter_sql_6);
    319         }
    320        
    321247    }
    322248
    323249    mrylm_create_tables();
    324    
    325250}
    326251
    327 // OK
    328 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 city 
    333         $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 0
    344         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 database           
    362         $lm_insert_id =  $lm_post_id > 0 ? wp_update_post($mrylm_post) : wp_insert_post( $mrylm_post );
    363 
    364         // to set template for the page
    365         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 // OK
    373 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 type
    387                      $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 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             }
    409         }
    410     }   
    411 }
    412 
    413 // OK
    414 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 // OK
    438252function create_service_area_page($lm_setting) {
    439253
     
    453267        'post_type' => 'page',
    454268        'post_parent' => 0,
    455         'post_author'   => 1,
    456269        'post_category' => array()
    457270    );
  • local-magic/trunk/admin/setting.php

    r3199499 r3200723  
    88$mrylm_msg = "";
    99
    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 
    2510function mrylm_check_key_format($mrylm_key){
    2611   
     
    3621}
    3722
     23function 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
     37function 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
    3876function mrylm_process_pages(){
    3977   
     
    4583    if($lm_setting->lm_url_type == 'wp_remote_get'){       
    4684        $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       
    4887    }else{                 
    4988        $mrylm_response = file_get_contents('https://localmagic.reviewmanager.app/plugin/cities/' . $lm_setting->lm_unique_id);
     
    5190    }
    5291     
    53     if(!empty($mrylm_cities)){           
     92       if(!empty($mrylm_cities)){           
    5493         
    5594         // Trancating existing Cities table
     
    86125                'lm_historic_landmark' => $obj->historic_landmark,
    87126                '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
    94128            );
    95129
     
    99133            $lm_city = array();
    100134            $lm_city['lm_parent_id'] = $obj->parent_id;
    101             $lm_city['lm_type'] = $obj->lm_type;
    102             $lm_city['lm_slug'] = $obj->slug;
    103135            $lm_city['lm_url_slug'] = $obj->url_slug;
    104136            $lm_city['lm_city'] = $obj->city;
    105             $lm_city['lm_topics'] = $obj->topics;
    106137            $lm_obj_city = (object) $lm_city;
    107138           
    108139            // 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 != ''){
    110141
    111142                $lm_multi_titles = get_multi_type_formatted_data($lm_setting->lm_multi_title);
     
    113144
    114145                    $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);   
    118147                }
    119148
    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);
    133151            }           
    134152        }
     
    140158    }   
    141159}
     160
    142161
    143162if (isset($_POST['submit']) && is_user_logged_in()) {
     
    226245                    'lm_multi_keyword' => $lm_setting->multi_keyword,
    227246                    '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
    231248                );
    232249
  • local-magic/trunk/include/function.php

    r3199499 r3200723  
    99}
    1010
    11 
    1211function get_multi_type_data($multi_type_data = null){
    1312   
     
    2423}
    2524
    26 
    2725function mrylm_get_city(){
    2826   
    2927    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;
    3035   
    3136    $lm_setting_sql = "SELECT * FROM {$wpdb->prefix}mrylm_setting";
    3237    $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 format
    43     if($lm_setting->lm_is_topic){
    44         if(count($arr) > 4){ // there are topic
    45             $slug = $arr[4]; 
    46         }   
    47     }
    48      
    4938    if ($lm_setting->lm_org_url == $url) {
    50         $slug = $lm_setting->lm_default_city;
     39        $full_slug = $lm_setting->lm_default_city;
    5140    }   
    5241   
    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);
    5648    }
    57     $lm_city = $wpdb->get_row($lm_sql);     
    5849   
    5950    return $lm_city;
     
    311302 
    312303        $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    }   
    350305   
    351306   
     
    406361    $reviews = mrylm_review_testimonial($lm_city);
    407362    $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   
    409371    return $content; 
    410372   
     
    484446
    485447            // 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);
    487449            $image->setAttribute('alt', $title_text);
    488450            $image->setAttribute('title', $title_text);
     
    700662        // get news data as per keyword   
    701663        $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        }
    704670
    705671        $style =  '<style>';
     
    832798}
    833799   
     800function 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   
    834869function mrylm_review_testimonial($lm_city = null){     
    835870   
     
    14051440
    14061441/* Job End */
     1442
    14071443
    14081444/* POI Start */
  • local-magic/trunk/local-magic.php

    r3200713 r3200723  
    1212 * Plugin Name:       Local Magic
    1313 * Plugin URI:        https://www.mrmarketingres.com/local-magic
    14  * Description:       The Local Magic&#169; WordPress plugin extends the functionality of the SaaS Local Magic&#169; to WordPress so that the local news feed can be displayed on the WordPress website. The plugin is for customers of Local Magic&#169; 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.
    1515 * Version:           2.5.0
    1616 * Requires at least: 3.5.1
    17  * Tested up to:      6.3.0
     17 * Tested up to:      6.7.1
    1818 * Requires PHP:      5.6.0
    1919 * Author:            matthewrubin
     
    2727    exit; // Exit if accessed directly
    2828
    29 
    30 define('MRYLM_VERSION', '2.4.0');
     29define('MRYLM_VERSION', '2.5.0');
    3130
    3231define('MRYLM_PLUGIN_DIR', plugin_dir_path(__FILE__));
     
    5150/* ACTION START */
    5251
    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');   
     52function mrylm_enqueue_scripts() {   
    5853}
    5954add_action('wp_enqueue_scripts', 'mrylm_enqueue_scripts');
    60 
    6155
    6256function mrylm_admin_menu() {
     
    6761add_action('admin_menu', 'mrylm_admin_menu');
    6862
    69 
    7063function mrylm_options() {
    7164
     
    7972
    8073/* UPDATE ACTION START */
     74add_action( 'upgrader_process_complete', 'mrylm_upgrade_function',10, 2);
    8175function mrylm_upgrade_function( $upgrader_object, $options ) {
    8276   
    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}
    8780/* UPDATE ACTION END */
    8881
     
    9487add_shortcode('mrylm-article', 'mrylm_article_shortcode');
    9588
    96 
    9789function mrylm_dropdown_menu_shortcode($attr, $content) {
    9890    return mrylm_dropdown_menu($content);
     
    127119/* SHORT CODE END */
    128120
    129 
    130121// DESTROY LM
    131 /* Manage/ Destroy Page data Start  Done*/
     122/* Manage/ Destroy Page data Start */
    132123add_action('wp_ajax_nopriv_mrylm-manage-pages', 'mrylm_manage_pages');
    133 
    134124function mrylm_manage_pages() {
    135125
    136126    global $wpdb;
    137     require_once(MRYLM_PLUGIN_DIR . 'activate.php' );
    138     mrylm_update_tables();
    139127   
    140128    $mrylm_setting_sql = "SELECT * FROM {$wpdb->prefix}mrylm_setting";
     
    146134    if (isset($lm_cities) && $lm_cities != '') {
    147135       
    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 != ''){
    150137            $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title);
    151138            foreach($lm_multi_titles AS $key=>$lm_title){
     
    153140                    $postid = url_to_postid($lm_setting->lm_org_url. $key.'/'. $obj->lm_url_slug);
    154141                    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);
    157142                        wp_delete_post($postid, true);
    158143                    }
     
    160145            }
    161146           
    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            
    173147        }else{
    174148            foreach ($lm_cities as $obj) {
    175149                $postid = url_to_postid($lm_setting->lm_page_url . $obj->lm_url_slug);
    176150                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);
    180152                }
    181153            }
     
    209181
    210182
    211 /* Update Setting data Start Done */
     183/* Update Setting data Start */
    212184add_action('wp_ajax_nopriv_mrylm-update-setting', 'mrylm_update_setting');
    213185
     
    275247            'lm_multi_keyword' => $lm_setting->multi_keyword,
    276248            '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
    280250        );
    281251
     
    290260
    291261
    292 /* Manage Cities data Start Pore Hobe */
     262/* Manage Cities data Start */
    293263add_action('wp_ajax_nopriv_mrylm-manage-cities', 'mrylm_manage_cities');
    294264function mrylm_manage_cities() {
    295    
     265
     266    // functional code will go here   
     267    $lm_cities = $_POST['cities'];
    296268    require_once(MRYLM_PLUGIN_DIR . 'activate.php' );
    297269    mrylm_update_tables();
    298     $lm_cities = $_POST['cities'];
    299270     
    300271    if (isset($lm_cities)) {
     
    338309                'lm_historic_landmark' => $obj->historic_landmark,
    339310                '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
    346312            );
    347313
     
    351317            $lm_city = array();
    352318            $lm_city['lm_parent_id'] = $obj->parent_id;
    353             $lm_city['lm_type'] = $obj->lm_type;
    354             $lm_city['lm_slug'] = $obj->slug;
    355319            $lm_city['lm_url_slug'] = $obj->url_slug;
    356320            $lm_city['lm_city'] = $obj->city;
    357             $lm_city['lm_topics'] = $obj->topics;
    358321            $lm_obj_city = (object) $lm_city;
    359322
    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 != ''){
    361324
    362325                $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title);
     
    364327
    365328                    $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);   
    369330                }
    370331
    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);
    383334            }
    384         }       
     335
     336        }
     337       
    385338    }
    386339   
     
    396349
    397350
    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 */
     352add_action('wp_ajax_nopriv_mrylm-manage-single-types', 'mrylm_manage_single_types');
     353function mrylm_manage_single_types() {
     354
     355    // functional code will go here   
    404356    $lm_cities = $_POST['cities'];
    405     $lm_type = $_POST['lm_type'];
    406        
     357    $lm_url_type = $_POST['lm_type'];
     358     
     359
    407360    if (isset($lm_cities)) {
    408361
     
    411364        $lm_cities = json_decode($lm_cities);
    412365       
    413         $lm_del_sql = "DELETE FROM {$wpdb->prefix}mrylm_cities WHERE lm_type = '$lm_type'";
    414         $wpdb->query($lm_del_sql);
    415 
    416366        $mrylm_setting_sql = "SELECT * FROM {$wpdb->prefix}mrylm_setting";
    417367        $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
    500370        require_once(MRYLM_PLUGIN_DIR . 'activate.php' );
    501371        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         
    509374        foreach ($lm_cities as $obj) {
    510375           
     
    512377            $city = array();
    513378            $city['lm_parent_id'] = $obj->parent_id;
    514             $city['lm_type'] = $obj->lm_type;
    515             $city['lm_slug'] = $obj->slug;
    516379            $city['lm_url_slug'] = $obj->url_slug;
    517380            $city['lm_city'] = $city_name;
    518             $city['lm_topics'] = $obj->topics;;
    519381            $lm_city = (object) $city;
    520382
    521383            if($lm_setting->lm_is_multi_type && $lm_setting->lm_multi_title != ''){
    522384               
    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);
    527386            }
    528387        }       
     
    534393
    535394
    536 /* Add City data Start Done */
     395/* Add City data Start*/
    537396add_action('wp_ajax_nopriv_mrylm-add-city', 'mrylm_add_city');
    538397function mrylm_add_city() {
    539398
    540399    $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());
    547401   
    548402    if (isset($lm_city)) {
     
    550404        $lm_city = json_decode($lm_city);
    551405
     406        global $wpdb;
    552407
    553408        $mrylm_setting_sql = "SELECT * FROM {$wpdb->prefix}mrylm_setting";
     
    581436            'lm_historic_landmark' => $lm_city->historic_landmark,
    582437            '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
    589439        );
    590440        $mrylm_table_name = $wpdb->prefix . "mrylm_cities";
     
    594444        $obj = array();
    595445        $obj['lm_parent_id'] = $lm_city->parent_id;
    596         $obj['lm_slug'] = $lm_city->slug;
    597446        $obj['lm_url_slug'] = $lm_city->url_slug;
    598447        $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       
    603450        // 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 != ''){
    605452
    606453            $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title);
    607            
    608454            foreach($lm_multi_titles AS $key=>$lm_title){
    609455
    610456                $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);   
    615458            }
    616459
    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                    
    628460        }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);
    631462        }
    632463    }
     
    634465/* Add City data End*/
    635466
    636 
    637 /* Update City data Start Done*/
     467function 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*/
    638506add_action('wp_ajax_nopriv_mrylm-update-city', 'mrylm_update_city');
    639507function mrylm_update_city() {
    640508
    641509    $lm_city = $_POST['city'];
    642    
    643     require_once(MRYLM_PLUGIN_DIR . 'activate.php' );
    644     mrylm_update_tables();   
     510    mrylm_upgrade_function(array(), array());
    645511   
    646512    if (isset($lm_city)) {
     
    659525       
    660526        // 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();
    700558        $obj['lm_parent_id'] = $lm_city->parent_id;
    701         $obj['lm_slug'] = $lm_city->slug;
    702559        $obj['lm_url_slug'] = $lm_city->url_slug;
    703560        $obj['lm_city'] = $lm_city->city;
    704         $obj['lm_type'] = $lm_city->lm_type;
    705         $obj['lm_topics'] = $lm_city->topics;
    706561        $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 != ''){
    709564                   
    710565            $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title);
     
    713568                $lm_page_url = $lm_setting->lm_org_url.$key.'/';             
    714569                $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);   
    717571            }
    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                 }
    728572
    729573        }else{           
    730574           
    731575            $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       
    735581    }
    736582}
    737583/* Update City data End */
    738584
    739 /* Manage News data Start  */
     585function 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 */
    740624add_action('wp_ajax_nopriv_mrylm-manage-news', 'mrylm_manage_news');
    741625function mrylm_manage_news() {
     
    787671    }
    788672
    789     echo TRUE;   
     673    echo TRUE;
     674   
    790675}
    791676/* Manage News data End */
    792677
    793678
    794 /* Delete a City Start Done */
     679/* Delete a City Start */
    795680add_action('wp_ajax_nopriv_mrylm-delete-city', 'mrylm_delete_city');
    796681function mrylm_delete_city() {
    797682
    798683    global $wpdb;
    799    
    800     require_once(MRYLM_PLUGIN_DIR . 'activate.php' );
    801684    $lm_city_id = $_POST['city_id'];
    802685
     
    813696    $wpdb->query($lm_del_news_sql);
    814697   
    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 != ''){
    816699               
    817700        $lm_multi_titles = get_multi_type_data($lm_setting->lm_multi_title);
     
    819702           $postid = url_to_postid($lm_setting->lm_org_url. $key.'/'. $lm_city->lm_url_slug);
    820703            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);               
    824705            }
    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             }
    837706        }
    838707       
     
    841710        $postid = url_to_postid($lm_setting->lm_page_url . $lm_city->lm_url_slug);
    842711        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);           
    846713        }       
    847714    }
  • local-magic/trunk/readme.txt

    r3200711 r3200723  
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 The Local Magic&#169; WordPress plugin extends the functionality of the SaaS Local Magic&#169; to WordPress so that the local magic can be displayed on the WordPress website. The plugin is for customers of Local Magic&#169; that have an active subscription with the company.
     11The 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.
    1212
    1313== Description ==
    1414
    15 The Local Magic&#169; WordPress plugin extends the functionality of the SaaS Local Magic&#169; to WordPress so that the local magic can be displayed on the WordPress website. The plugin is for customers of Local Magic&#169; that have an active subscription with the company.
     15The 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.
    1616
    1717 
     
    103103=2.3.0=
    1041041. Bug fixing and Some minor functionality added
    105 =2.4.0=
    106 1. Topic feature added
    107 =2.5.0=
    108 1. Re-arrange functionality
Note: See TracChangeset for help on using the changeset viewer.