PluginProbe
Open User Map – Interactive Leaflet Maps / trunk
Open User Map – Interactive Leaflet Maps vtrunk
1.4.51 1.4.50 1.4.49 1.4.48 1.4.47 1.4.46 1.4.44 1.4.45 1.4.43 1.4.42 1.4.41 1.4.40 1.4.38 1.4.39 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 trunk 1.0.0 1.1.0 1.1.1 1.1.10 All 143 releases
open-user-map / open-user-map.php

open-user-map.php in Open User Map – Interactive Leaflet Maps trunk, at open-user-map.php

210 lines 8.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * @package OpenUserMapPlugin
5 */
6 /*
7 Plugin Name: Open User Map – Interactive Leaflet Maps
8 Plugin URI: https://www.open-user-map.com/
9 Description: Create custom interactive maps with free Leaflet-based styles, no Google Maps API key, frontend marker submissions, search and filters.
10 Author: 100plugins
11 Version: 1.4.51
12 Author URI: https://www.open-user-map.com/
13 License: GPLv3 or later
14 Text Domain: open-user-map
15 Domain Path: /languages/
16 */
17 /*
18 This program is free software: you can redistribute it and/or modify
19 it under the terms of the GNU General Public License as published by
20 the Free Software Foundation, either version 3 of the License, or
21 (at your option) any later version.
22
23 This program is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 GNU General Public License for more details.
27
28 You should have received a copy of the GNU General Public License
29 along with this program. If not, see <https://www.gnu.org/licenses/>.
30
31 Copyright 2026 100plugins
32 */
33 defined( 'ABSPATH' ) or die( 'Direct access is not allowed.' );
34 if ( function_exists( 'oum_fs' ) ) {
35 oum_fs()->set_basename( false, __FILE__ );
36 } else {
37 // FREEMIUS INTEGRATION CODE
38 if ( !function_exists( 'oum_fs' ) ) {
39 // Create a helper function for easy SDK access.
40 function oum_fs() {
41 global $oum_fs;
42 if ( !isset( $oum_fs ) ) {
43 // Include Freemius SDK.
44 require_once dirname( __FILE__ ) . '/vendor/freemius/start.php';
45 $oum_fs = fs_dynamic_init( array(
46 'id' => '9083',
47 'slug' => 'open-user-map',
48 'premium_slug' => 'open-user-map-pro',
49 'type' => 'plugin',
50 'public_key' => 'pk_e4bbeb52c0d44fa562ba49d2c632d',
51 'is_premium' => false,
52 'premium_suffix' => 'PRO',
53 'has_addons' => false,
54 'has_paid_plans' => true,
55 'trial' => array(
56 'days' => 7,
57 'is_require_payment' => false,
58 ),
59 'menu' => array(
60 'slug' => 'edit.php?post_type=oum-location',
61 'first-path' => 'edit.php?post_type=oum-location&page=open-user-map-settings',
62 'contact' => false,
63 'support' => false,
64 ),
65 'is_live' => true,
66 'is_org_compliant' => true,
67 ) );
68 }
69 return $oum_fs;
70 }
71
72 // Init Freemius.
73 oum_fs();
74 // Signal that SDK was initiated.
75 do_action( 'oum_fs_loaded' );
76 }
77 // Always show annual pricing instead of monthly pricing
78 oum_fs()->add_filter( 'pricing/show_annual_in_monthly', '__return_false' );
79 // Special uninstall routine with Freemius
80 function oum_fs_uninstall_cleanup() {
81 global $wpdb;
82 //delete posts
83 $wpdb->query( "DELETE FROM " . $wpdb->prefix . "posts WHERE post_type='oum-location'" );
84 //delete postmeta
85 $wpdb->query( "DELETE FROM " . $wpdb->prefix . "postmeta WHERE meta_key LIKE '%oum_%'" );
86 //delete options
87 $wpdb->query( "DELETE FROM " . $wpdb->prefix . "options WHERE option_name LIKE 'oum_%'" );
88 }
89
90 oum_fs()->add_action( 'after_uninstall', 'oum_fs_uninstall_cleanup' );
91 // Better Opt-In Screen
92 oum_fs()->add_action( 'connect/before', function () {
93 echo '<div class="oum-wizard">
94 <div class="hero">
95 <div class="logo">Open User Map</div>
96 <div class="overline">' . __( 'Quick Setup (1/3)', 'open-user-map' ) . '</div>
97 <h1>' . __( 'Hi! Thanks for using Open User Map', 'open-user-map' ) . '</h1>
98 <ul class="steps">
99 <li class="done"></li>
100 <li></li>
101 <li></li>
102 </ul>
103 </div>
104 <div class="step-content">';
105 } );
106 oum_fs()->add_action( 'connect/after', function () {
107 echo '</div></div>';
108 } );
109 // ... Your plugin's main file logic ...
110 // Initialize custom lightweight autoloader (replaces Composer)
111 // This autoloader ONLY loads OpenUserMapPlugin classes and prevents interference with other plugins
112 if ( file_exists( dirname( __FILE__ ) . '/inc/Autoloader.php' ) ) {
113 require_once dirname( __FILE__ ) . '/inc/Autoloader.php';
114 OpenUserMapPlugin\Autoloader::init( dirname( __FILE__ ) );
115 }
116 /**
117 * The code that runs during plugin activation
118 */
119 function oum_activate_plugin() {
120 OpenUserMapPlugin\Base\Activate::activate();
121 }
122
123 register_activation_hook( __FILE__, 'oum_activate_plugin' );
124 /**
125 * The code that runs during plugin deactivation
126 */
127 function oum_deactivate_plugin() {
128 OpenUserMapPlugin\Base\Deactivate::deactivate();
129 }
130
131 register_deactivation_hook( __FILE__, 'oum_deactivate_plugin' );
132 /**
133 * Initialize all the core classes of the plugin
134 */
135 if ( class_exists( 'OpenUserMapPlugin\\Init' ) ) {
136 // OpenUserMapPlugin\Init::register_services();
137 try {
138 OpenUserMapPlugin\Init::register_services();
139 } catch ( \Error $e ) {
140 return 'An error has occurred. Please look in the settings under Open User Map > Help > Debug Info.';
141 // Safe logging that works even when error_log is disabled
142 if ( function_exists( 'error_log' ) && !in_array( 'error_log', explode( ',', ( ini_get( 'disable_functions' ) ?: '' ) ) ) ) {
143 error_log( $e->getMessage() . '(' . $e->getFile() . ' Line: ' . $e->getLine() . ')' );
144 }
145 }
146 }
147 /**
148 * Get a value from a location (public function)
149 *
150 * possible attributes:
151 * - title
152 * - images
153 * - audio
154 * - video
155 * - type
156 * - type_icons
157 * - map
158 * - subtitle (preferred label, replaces the former "address" label)
159 * - lat
160 * - lng
161 * - geometry_type
162 * - geometry
163 * - route
164 * - text
165 * - notification
166 * - author_name
167 * - author_email
168 * - wp_author_id
169 * - CUSTOM FIELD LABEL
170 */
171 function oum_get_location_value( $attr, $post_id, $raw = false ) {
172 $location_controller = new OpenUserMapPlugin\Base\LocationController();
173 return $location_controller->get_location_value( $attr, $post_id, $raw );
174 }
175
176 /**
177 * Allow to get the template from the theme directory (template override)
178 *
179 * Just add a folder "open-user-map" in your theme directory and copy the template file you want to override.
180 * Be aware that new features may then not be available or even break the functionality!
181 */
182 function oum_get_template( $template_name ) {
183 // Define the paths to the template locations
184 $theme_template = get_stylesheet_directory() . '/open-user-map/' . $template_name;
185 $plugin_template = plugin_dir_path( __FILE__ ) . 'templates/' . $template_name;
186 // Check if the template exists in the theme directory
187 if ( file_exists( $theme_template ) ) {
188 return $theme_template;
189 } else {
190 return $plugin_template;
191 }
192 }
193
194 function oum_load_textdomain() {
195 load_plugin_textdomain( 'open-user-map', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
196 }
197
198 add_action( 'init', 'oum_load_textdomain', 1 );
199 // Redirect ?page=open-user-map to ?page=open-user-map-settings (for compatibility with Freemius Trial URL)
200 // This is necessary because the Freemius trial URL uses the plugin slug as default page
201 add_action( 'admin_menu', function () {
202 if ( is_admin() && isset( $_GET['fs_action'] ) && isset( $_GET['page'] ) && $_GET['page'] === 'open-user-map' && strpos( $_SERVER['PHP_SELF'], 'edit.php' ) !== false ) {
203 $query_args = $_GET;
204 $query_args['page'] = 'open-user-map-settings';
205 $new_url = add_query_arg( $query_args, admin_url( 'edit.php' ) );
206 wp_redirect( $new_url );
207 exit;
208 }
209 } );
210 }