PluginProbe
CBX Map for Google Map & OpenStreetMap / 2.0.1
CBX Map for Google Map & OpenStreetMap v2.0.1
trunk 1.1.10 1.1.11 1.1.12 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5
cbxgooglemap / includes / CBXGoogleMapMisc.php

CBXGoogleMapMisc.php in CBX Map for Google Map & OpenStreetMap 2.0.1, at includes/CBXGoogleMapMisc.php

261 lines 11.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Cbx\Googlemap;
4
5 // If this file is called directly, abort.
6
7 use Cbx\Googlemap\Helpers\CBXGooglemapHelper;
8
9
10 if ( ! defined( 'WPINC' ) ) {
11 die;
12 }
13
14 /**
15 * Misc Class
16 */
17 class CBXGoogleMapMisc {
18 /**
19 * Method for constructor
20 *
21 * @since v2.0.0
22 */
23 public function __construct() {
24
25 }//end constructor
26
27 /**
28 * Load the plugin text domain for translation.
29 *
30 * @since 1.0.0
31 */
32 public function load_plugin_textdomain() {
33 //load_plugin_textdomain('cbxgooglemap',false,CBXGOOGLEMAP_ROOT_PATH . 'languages/');
34 }//end method load_plugin_textdomain
35
36 /**
37 * Show a notice to anyone who has just installed the plugin for the first time
38 * This notice shouldn't display to anyone who has just updated this plugin
39 */
40 public function plugin_activate_upgrade_notices() {
41 $activation_notice_shown = false;
42
43 $kiss_html_arr = [
44 'strong' => [],
45 'a' => [
46 'href' => [],
47 'class' => []
48 ]
49 ];
50
51 if ( get_option( 'cbxgooglemap_flush_rewrite_rules' ) == 'true' ) {
52 flush_rewrite_rules();
53 delete_option( 'cbxgooglemap_flush_rewrite_rules' );
54 }
55
56 // Check the transient to see if we've just activated the plugin
57 if ( get_transient( 'cbxgooglemap_activated_notice' ) ) {
58 echo '<div class="notice notice-success is-dismissible" style="border-color: #2153cc !important;">';
59 /* translators: %s: Plugin Version */
60 echo '<p>' . sprintf( wp_kses( __( 'Thanks for installing/deactivating <strong>CBX Map for Google Map & OpenStreetMap</strong> V%s - Codeboxr Team',
61 'cbxgooglemap' ), $kiss_html_arr ),
62 esc_attr( CBXGOOGLEMAP_PLUGIN_VERSION ) ) . '</p>';
63 /* translators: 1: Admin URL 2: Admin URL */
64 echo '<p>' . sprintf( wp_kses( __( 'Check <a style="color: #6648fe !important; font-weight: bold;" href="%1$s" target="_blank">Documentation</a> | Create <a style="color: #6648fe !important; font-weight: bold;" href="%2$s" target="_blank">Map</a>',
65 'cbxgooglemap' ), $kiss_html_arr ),
66 'https://codeboxr.com/doc/cbxmap-doc/',
67 esc_url( admin_url( 'post-new.php?post_type=cbxgooglemap' ) )
68 ) . '</p>';
69
70 // Delete the transient so we don't keep displaying the activation message
71 delete_transient( 'cbxgooglemap_activated_notice' );
72
73 $this->pro_addon_compatibility_campaign();
74
75 $activation_notice_shown = true;
76 }
77
78 // Check the transient to see if we've just activated the plugin
79 if ( get_transient( 'cbxgooglemap_upgraded_notice' ) ) {
80 if ( ! $activation_notice_shown ) {
81 echo '<div class="notice notice-success is-dismissible" style="border-color: #2153cc !important;">';
82 /* translators: %s: Plugin Version */
83 echo '<p>' . sprintf( wp_kses( __( 'Thanks for upgrading <strong>CBX Map for Google Map & OpenStreetMap</strong> V%s , enjoy the new features and bug fixes - Codeboxr Team',
84 'cbxgooglemap' ), $kiss_html_arr ),
85 esc_attr( CBXGOOGLEMAP_PLUGIN_VERSION ) ) . '</p>';
86
87 /* translators: 1: Admin URL 2: Admin URL */
88 echo '<p>' . sprintf( wp_kses( __( 'Check <a style="color: #6648fe !important; font-weight: bold;" href="%1$s" target="_blank">Documentation</a> | Create <a style="color: #6648fe !important; font-weight: bold;" href="%2$s" target="_blank">Map</a>', 'cbxgooglemap' ), [ 'strong' => [], 'a' => [ 'href' => [], 'style' => [] ] ] ),
89 'https://codeboxr.com/doc/cbxmap-doc/',
90 esc_url( admin_url( 'post-new.php?post_type=cbxgooglemap' ) )
91 ) . '</p>';
92 echo '</div>';
93
94 $this->pro_addon_compatibility_campaign();
95 }
96
97 // Delete the transient so we don't keep displaying the activation message
98 delete_transient( 'cbxgooglemap_upgraded_notice' );
99 }//end cbxgooglemap_upgraded_notice
100
101 if ( get_transient( 'cbxgooglemappro_deactivated_notice' ) ) {
102 echo '<div class="notice notice-error is-dismissible" style="border-color: red !important;">';
103 echo '<p>' . wp_kses( __( 'Currently installed <strong>CBX Map for Google Map & OpenStreetMap Pro Addon</strong> version 1.0.5(or earlier) is not compatible with the latest version of core plugin CBX Map for Google Map & OpenStreetMap V1.1.12 or later. - Codeboxr Team',
104 'cbxgooglemap' ), $kiss_html_arr ) . '</p>';
105 echo '</div>';
106
107 delete_transient( 'cbxgooglemappro_deactivated_notice' );
108 }//end checking cbxgooglemappro_deactivated_notice
109 }//end plugin_activate_upgrade_notices
110
111 /**
112 * Check plugin compatibility and pro addon install campaign
113 */
114 public function pro_addon_compatibility_campaign() {
115 if ( ! function_exists( 'is_plugin_active' ) ) {
116 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
117 }
118
119 //if the pro addon is active or installed
120 if ( defined( 'CBXGOOGLEMAPPRO_PLUGIN_NAME' ) || in_array( 'cbxgooglemappro/cbxgooglemappro.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
121 //plugin is activated
122
123 $plugin_version = CBXGOOGLEMAPPRO_PLUGIN_VERSION;
124 $pro_min_version = '2.0.0';
125
126 if ( version_compare( $plugin_version, $pro_min_version, '<' ) ) {
127 echo '<div class="notice notice-success is-dismissible"><p>' . esc_html__( 'CBX Map Pro Addon current version is not compatible with the latest CBX Map core plugin. Please update CBX Map Pro Addon to version 2.0.0 or later - Codeboxr Team', 'cbxgooglemap' ) . '</p></div>';
128 }
129
130 } else {
131 /* translators: %s: Plugin Link */
132 $message = sprintf( __( 'CBX Map Pro Addon has distance search based listing, multiple marker in one map and more extra features, <a target="_blank" href="%s">try it</a> - Codeboxr Team', 'cbxgooglemap' ), esc_url( 'https://codeboxr.com/product/cbx-google-map-for-wordpress/' ) );
133 echo '<div class="notice notice-success is-dismissible"><p>' . wp_kses_post( $message ) . '</p></div>';
134 }
135 }//end pro_addon_compatibility_campaign
136
137 /**
138 * Pro Addon update message
139 */
140 public function plugin_update_message_pro_addon() {
141 /* translators: 1: Plugin Manual Download Link 2: Plugin Manual Download Link */
142 echo ' ' . sprintf( wp_kses( __( 'Check how to <a style="color:#9c27b0 !important; font-weight: bold;" href="%1$s"><strong>Update manually</strong></a> , download the latest version from <a style="color:#9c27b0 !important; font-weight: bold;" href="%2$s"><strong>My Account</strong></a> section of Codeboxr.com', 'cbxgooglemap' ), [ 'strong' => [], 'a' => [ 'href' => [], 'style' => [] ] ] ), 'https://codeboxr.com/manual-update-pro-addon/', 'https://codeboxr.com/my-account/' );
143 }//end plugin_update_message_pro_addon
144
145 /**
146 * If we need to do something in upgrader process is completed
147 *
148 */
149 public function plugin_upgrader_process_complete() {
150 $saved_version = get_option( 'cbxgooglemap_version' );
151
152 if ( $saved_version === false || version_compare( $saved_version, CBXGOOGLEMAP_PLUGIN_VERSION, '<' ) ) {
153 set_transient( 'cbxgooglemap_flush_rewrite_rules', 1 );
154 set_transient( 'cbxgooglemap_upgraded_notice', 1 );
155 update_option( 'cbxgooglemap_version', CBXGOOGLEMAP_PLUGIN_VERSION );
156
157
158 //pro addon compatibility
159 $this->check_pro_addon();
160 }
161 }//end plugin_upgrader_process_complete
162
163 /**
164 * Show notice about pro addon deactivation
165 *
166 * @return void
167 * @since 2.0.0
168 */
169 public function check_pro_addon() {
170 cbxgooglemap_check_and_deactivate_plugin( 'cbxgooglemappro/cbxgooglemappro.php', '2.0.0', 'cbxgooglemap_proaddon_deactivated' );
171 }//end method check_pro_addon
172
173 /**
174 * Add settings action link to the plugins page.
175 *
176 * @since 1.0.0
177 */
178 public function plugin_listing_setting_link( $links ) {
179 return array_merge( [
180 'settings' => '<a style="color:#39A96B; font-weight: bold;" target="_blank" href="' . esc_url( admin_url( 'edit.php?post_type=cbxgooglemap&page=cbxgooglemap_settings' ) ) . '">' . esc_attr__( 'Settings', 'cbxgooglemap' ) . '</a>'
181 ], $links );
182
183 }//end plugin_listing_setting_link
184
185 /**
186 * Filters the array of row meta for each/specific plugin in the Plugins list table.
187 * Appends additional links below each/specific plugin on the plugins page.
188 *
189 * @access public
190 *
191 * @param array $links_array An array of the plugin's metadata
192 * @param string $plugin_file_name Path to the plugin file
193 * @param array $plugin_data An array of plugin data
194 * @param string $status Status of the plugin
195 *
196 * @return array $links_array
197 * @since 1.0.0
198 */
199 public function custom_plugin_row_meta( $links_array, $plugin_file_name, $plugin_data, $status ) {
200 if ( strpos( $plugin_file_name, CBXGOOGLEMAP_BASE_NAME ) !== false ) {
201 if ( ! function_exists( 'is_plugin_active' ) ) {
202 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
203 }
204
205
206 $links_array[] = '<a style="color:#39A96B; font-weight: bold;" href="https://wordpress.org/support/plugin/cbxgooglemap/" target="_blank">' . esc_attr__( 'Free Support', 'cbxgooglemap' ) . '</a>';
207 $links_array[] = '<a style="color:#39A96B; font-weight: bold;" href="https://wordpress.org/plugins/cbxgooglemap/#reviews" target="_blank">' . esc_attr__( 'Reviews', 'cbxgooglemap' ) . '</a>';
208 $links_array[] = '<a target="_blank" style="color:#f44336 !important; font-weight: bold;" href="https://codeboxr.com/doc/cbxmap-doc/" aria-label="' . esc_attr__( 'Documentation', 'cbxgooglemap' ) . '">' . esc_html__( 'Documentation', 'cbxgooglemap' ) . '</a>';
209
210
211 if ( in_array( 'cbxgooglemappro/cbxgooglemappro.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) || defined( 'CBXGOOGLEMAPPRO_PLUGIN_NAME' ) ) {
212 $links_array[] = '<a style="color:#39A96B; font-weight: bold;" href="https://codeboxr.com/contact-us/" target="_blank">' . esc_attr__( 'Pro Support', 'cbxgooglemap' ) . '</a>';
213 } else {
214 $links_array[] = '<a target="_blank" style="color:#f44336 !important; font-weight: bold;" href="https://codeboxr.com/product/cbx-google-map-for-wordpress/#downloadarea" aria-label="' . esc_attr__( 'Try Pro Addon', 'cbxgooglemap' ) . '">' . esc_html__( 'Try Pro Addon', 'cbxgooglemap' ) . '</a>';
215 }
216 }
217
218 return $links_array;
219 }//end custom_plugin_row_meta
220
221 /**
222 * Show plugin update
223 *
224 * @param $plugin_file
225 * @param $plugin_data
226 *
227 * @return void
228 */
229 public function custom_message_after_plugin_row_proaddon( $plugin_file, $plugin_data ) {
230 if ( $plugin_file !== 'cbxgooglemappro/cbxgooglemappro.php' ) {
231 return;
232 }
233
234 if ( defined( 'CBXGOOGLEMAPPRO_PLUGIN_NAME' ) ) {
235 return;
236 }
237
238 $pro_addon_version = CBXGooglemapHelper::get_any_plugin_version( 'cbxgooglemappro/cbxgooglemappro.php' );
239 $pro_latest_version = '2.0.0';
240
241 if ( $pro_addon_version != '' && version_compare( $pro_addon_version, $pro_latest_version, '<' ) ) {
242 // Custom message to display
243
244 $plugin_manual_update = 'https://codeboxr.com/manual-update-pro-addon/';
245
246
247 /* translators:translators: %s: plugin setting url for licence */
248 $custom_message = wp_kses( sprintf( __( '<strong>Note:</strong> CBX Map Pro Addon is custom plugin. This plugin can not be auto update from dashboard/plugin manager. For manual update please check <a target="_blank" href="%1$s">documentation</a>. <strong style="color: red;">It seems this plugin\'s current version is older than %2$s . To get the latest pro addon features, this plugin needs to upgrade to %2$s or later.</strong>', 'cbxgooglemap' ), esc_url( $plugin_manual_update ),
249 $pro_latest_version ), [ 'strong' => [ 'style' => [] ], 'a' => [ 'href' => [], 'target' => [] ] ] );
250
251 // Output a row with custom content
252 echo '<tr class="plugin-update-tr">
253 <td colspan="3" class="plugin-update colspanchange">
254 <div class="notice notice-warning inline">
255 ' . wp_kses_post( $custom_message ) . '
256 </div>
257 </td>
258 </tr>';
259 }
260 }//end method custom_message_after_plugin_row_proaddon
261 }//end class ComfortInvoiceMisc