Changeset 3392708 for wp-google-maps/trunk/includes/class.plugin.php
- Timestamp:
- 11/10/2025 06:44:33 AM (5 months ago)
- File:
-
- 1 edited
-
wp-google-maps/trunk/includes/class.plugin.php (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-google-maps/trunk/includes/class.plugin.php
r3169779 r3392708 9 9 wpgmza_require_once(WPGMZA_PLUGIN_DIR_PATH . 'includes/class.gdpr-compliance.php'); 10 10 wpgmza_require_once(WPGMZA_PLUGIN_DIR_PATH . 'includes/3rd-party-integration/class.wp-migrate-db-integration.php'); 11 12 wpgmza_require_once(WPGMZA_PLUGIN_DIR_PATH . 'includes/class.dynamic-translations.php'); 13 11 14 wpgmza_require_once(WPGMZA_PLUGIN_DIR_PATH . 'includes/open-layers/class.nominatim-geocode-cache.php'); 12 15 wpgmza_require_once(WPGMZA_PLUGIN_DIR_PATH . 'includes/class.maps-engine-dialog.php'); … … 44 47 const PAGE_ADVANCED = "advanced"; 45 48 const PAGE_CUSTOM_FIELDS = "custom-fields"; 49 const PAGE_INSIGHTS = "insights"; 46 50 47 51 const MARKER_PULL_DATABASE = "0"; … … 63 67 private $_pro7Compatiblity; 64 68 private $_pro9Compatibility; 69 private $_pro10Compatibility; 65 70 private $_dynamicTranslations; 66 71 private $_spatialFunctionPrefix = ''; … … 70 75 71 76 protected $_internalEngine; 77 protected $_previewMode; 72 78 protected $_scriptLoader; 73 79 … … 110 116 111 117 // Dynamic translation file 112 $this->_dynamicTranslations = new DynamicTranslations();118 $this->_dynamicTranslations = DynamicTranslations::createInstance(); 113 119 114 120 // Legacy settings … … 122 128 $this->_pro7Compatiblity = new Pro7Compatibility(); 123 129 $this->_pro9Compatibility = new Pro9Compatibility(); 130 $this->_pro10Compatibility = new Pro10Compatibility($this->_settings); 124 131 125 132 $this->_restAPI = RestAPI::createInstance(); … … 131 138 132 139 $this->_internalEngine = new InternalEngine($this->settings->internal_engine); 140 $this->_previewMode = new PreviewMode(); 133 141 $this->_shortcodes = Shortcodes::createInstance($this->_internalEngine); 134 142 … … 147 155 // Include nominatim for it's legacy AJAX hooks 148 156 // TODO: Use a RESTful approach here instead 149 if($this->settings->engine == 'open-layers') 157 if($this->settings->engine == 'open-layers' || $this->settings->engine === 'open-layers-latest' 158 || $this->settings->engine === 'leaflet' || $this->settings->engine === 'leaflet-zerocost' 159 || $this->settings->engine === 'leaflet-azure' || $this->settings->engine === 'leaflet-maptiler' 160 || $this->settings->engine === 'leaflet-stadia' || $this->settings->engine === 'leaflet-locationiq'){ 150 161 require_once(plugin_dir_path(__FILE__) . 'open-layers/class.nominatim-geocode-cache.php'); 162 } 151 163 152 164 … … 188 200 add_action('admin_init', function(){ 189 201 /* In admin area, has not seen welcome page, and not doing ajax right now */ 190 update_option('wpgmza_welcome_screen_done', true );202 update_option('wpgmza_welcome_screen_done', true, false); 191 203 wp_redirect(admin_url('admin.php?page=wp-google-maps-menu&action=welcome_page')); 192 204 exit; … … 239 251 case 'scriptLoader': 240 252 case 'internalEngine': 253 case 'previewMode': 241 254 case 'adminNotices': 242 255 return $this->{'_' . $name}; … … 296 309 /* Plugin is being activated in the background, we can't redirect in this case */ 297 310 /* We will pick this up when they refresh the page */ 298 update_option('wpgmza_welcome_screen_done', true );311 update_option('wpgmza_welcome_screen_done', true, false); 299 312 wp_redirect(admin_url('admin.php?page=wp-google-maps-menu&action=welcome_page')); 300 313 exit; … … 335 348 $this->database->onFirstRun(); 336 349 337 update_option('wpgmza-first-run', date(\DateTime::ISO8601) );350 update_option('wpgmza-first-run', date(\DateTime::ISO8601), false); 338 351 339 352 /* Developer Hook (Action) - Add to first run plugin logic */ … … 411 424 $resturl = preg_replace('#^http(s?):#', '', $resturl); 412 425 426 $tileServer = TileServers::getBySettings($settings); 427 428 $settings = apply_filters('wpgmza_plugin_get_localized_data_settings', $settings); 429 413 430 /* Developer Hook (Filter) - Add or alter localization variables */ 414 431 $result = apply_filters('wpgmza_plugin_get_localized_data', array( … … 434 451 'stylingSettings' => $stylingSettings, 435 452 'currentPage' => $this->getCurrentPage(), 453 'tileServer' => $tileServer, 436 454 437 455 'userCanAdministrator' => (current_user_can('administrator') ? 1 : 0), … … 535 553 case 'wp-google-maps-menu-custom-fields': 536 554 return Plugin::PAGE_CUSTOM_FIELDS; 555 break; 556 557 case 'wp-google-maps-menu-insights': 558 return Plugin::PAGE_INSIGHTS; 537 559 break; 538 560 } … … 625 647 $simulateFirstRun = false; 626 648 649 $byMapTables = array(); 650 $byMapTarget = false; 627 651 628 652 switch($type){ … … 713 737 $truncateTables[] = $WPGMZA_TABLE_NAME_POINT_LABELS; 714 738 $truncateTables[] = $WPGMZA_TABLE_NAME_IMAGE_OVERLAYS; 739 break; 740 case 'destroy_by_map': 741 /* By map does not truncate, but it target delets */ 742 if(!empty($_POST['data_type']) && !empty($_POST['map_id'])){ 743 $dataType = trim(strip_tags($_POST['data_type'])); 744 $byMapTarget = !empty(intval($_POST['map_id'])) ? intval($_POST['map_id']) : false; 745 if(!empty($dataType)){ 746 if($dataType === 'markers'){ 747 /* All markers */ 748 $byMapTables[] = $WPGMZA_TABLE_NAME_MARKERS; 749 } else if($dataType === 'shapes'){ 750 /* All shape related tables */ 751 $byMapTables[] = $WPGMZA_TABLE_NAME_POLYGONS; 752 $byMapTables[] = $WPGMZA_TABLE_NAME_POLYLINES; 753 $byMapTables[] = $WPGMZA_TABLE_NAME_CIRCLES; 754 $byMapTables[] = $WPGMZA_TABLE_NAME_RECTANGLES; 755 756 $byMapTables[] = $WPGMZA_TABLE_NAME_HEATMAPS; 757 $byMapTables[] = $WPGMZA_TABLE_NAME_POINT_LABELS; 758 $byMapTables[] = $WPGMZA_TABLE_NAME_IMAGE_OVERLAYS; 759 } 760 } 761 } 715 762 break; 716 763 default: … … 748 795 $wpdb->query("TRUNCATE TABLE `{$table}`"); 749 796 } 797 } 798 } 799 800 if(!empty($byMapTables) && !empty($byMapTarget)){ 801 /* Specific targeted maps - Usually only available with Pro as it supports multiple maps */ 802 foreach($byMapTables as $targetTable){ 803 $wpdb->query($wpdb->prepare("DELETE FROM `{$targetTable}` WHERE map_id = %d", array($byMapTarget))); 750 804 } 751 805 } … … 985 1039 986 1040 $data = implode("", array_reverse($data)); 987 update_option("wpgmza_temp_api", $data );1041 update_option("wpgmza_temp_api", $data, false); 988 1042 } 989 1043
Note: See TracChangeset
for help on using the changeset viewer.