PluginProbe
CBX Map for Google Map & OpenStreetMap / 2.0.2
CBX Map for Google Map & OpenStreetMap v2.0.2
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.2, at includes/CBXGoogleMapMisc.php

254 lines 11.4 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 /**
29 * Show a notice to anyone who has just installed the plugin for the first time
30 * This notice shouldn't display to anyone who has just updated this plugin
31 */
32 public function plugin_activate_upgrade_notices() {
33 $activation_notice_shown = false;
34
35 $kiss_html_arr = [
36 'strong' => [],
37 'a' => [
38 'href' => [],
39 'class' => []
40 ]
41 ];
42
43 if ( get_option( 'cbxgooglemap_flush_rewrite_rules' ) == 'true' ) {
44 flush_rewrite_rules();
45 delete_option( 'cbxgooglemap_flush_rewrite_rules' );
46 }
47
48 // Check the transient to see if we've just activated the plugin
49 if ( get_transient( 'cbxgooglemap_activated_notice' ) ) {
50 echo '<div class="notice notice-success is-dismissible" style="border-color: #2153cc !important;">';
51 /* translators: %s: Plugin Version */
52 echo '<p>' . sprintf( wp_kses( __( 'Thanks for installing/deactivating <strong>CBX Map for Google Map & OpenStreetMap</strong> V%s - Codeboxr Team',
53 'cbxgooglemap' ), $kiss_html_arr ),
54 esc_attr( CBXGOOGLEMAP_PLUGIN_VERSION ) ) . '</p>';
55 /* translators: 1: Admin URL 2: Admin URL */
56 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>',
57 'cbxgooglemap' ), $kiss_html_arr ),
58 'https://codeboxr.com/doc/cbxmap-doc/',
59 esc_url( admin_url( 'post-new.php?post_type=cbxgooglemap' ) )
60 ) . '</p>';
61
62 // Delete the transient so we don't keep displaying the activation message
63 delete_transient( 'cbxgooglemap_activated_notice' );
64
65 $this->pro_addon_compatibility_campaign();
66
67 $activation_notice_shown = true;
68 }
69
70 // Check the transient to see if we've just activated the plugin
71 if ( get_transient( 'cbxgooglemap_upgraded_notice' ) ) {
72 if ( ! $activation_notice_shown ) {
73 echo '<div class="notice notice-success is-dismissible" style="border-color: #2153cc !important;">';
74 /* translators: %s: Plugin Version */
75 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',
76 'cbxgooglemap' ), $kiss_html_arr ),
77 esc_attr( CBXGOOGLEMAP_PLUGIN_VERSION ) ) . '</p>';
78
79 /* translators: 1: Admin URL 2: Admin URL */
80 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' => [] ] ] ),
81 'https://codeboxr.com/doc/cbxmap-doc/',
82 esc_url( admin_url( 'post-new.php?post_type=cbxgooglemap' ) )
83 ) . '</p>';
84 echo '</div>';
85
86 $this->pro_addon_compatibility_campaign();
87 }
88
89 // Delete the transient so we don't keep displaying the activation message
90 delete_transient( 'cbxgooglemap_upgraded_notice' );
91 }//end cbxgooglemap_upgraded_notice
92
93 if ( get_transient( 'cbxgooglemappro_deactivated_notice' ) ) {
94 echo '<div class="notice notice-error is-dismissible" style="border-color: red !important;">';
95 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',
96 'cbxgooglemap' ), $kiss_html_arr ) . '</p>';
97 echo '</div>';
98
99 delete_transient( 'cbxgooglemappro_deactivated_notice' );
100 }//end checking cbxgooglemappro_deactivated_notice
101 }//end plugin_activate_upgrade_notices
102
103 /**
104 * Check plugin compatibility and pro addon install campaign
105 */
106 public function pro_addon_compatibility_campaign() {
107 if ( ! function_exists( 'is_plugin_active' ) ) {
108 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
109 }
110
111 //if the pro addon is active or installed
112 //phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
113 if ( defined( 'CBXGOOGLEMAPPRO_PLUGIN_NAME' ) || in_array( 'cbxgooglemappro/cbxgooglemappro.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
114 //plugin is activated
115
116 $plugin_version = CBXGOOGLEMAPPRO_PLUGIN_VERSION;
117 $pro_min_version = '2.0.0';
118
119 if ( version_compare( $plugin_version, $pro_min_version, '<' ) ) {
120 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>';
121 }
122
123 } else {
124 /* translators: %s: Plugin Link */
125 $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/' ) );
126 echo '<div class="notice notice-success is-dismissible"><p>' . wp_kses_post( $message ) . '</p></div>';
127 }
128 }//end pro_addon_compatibility_campaign
129
130 /**
131 * Pro Addon update message
132 */
133 public function plugin_update_message_pro_addon() {
134 /* translators: 1: Plugin Manual Download Link 2: Plugin Manual Download Link */
135 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/' );
136 }//end plugin_update_message_pro_addon
137
138 /**
139 * If we need to do something in upgrader process is completed
140 *
141 */
142 public function plugin_upgrader_process_complete() {
143 $saved_version = get_option( 'cbxgooglemap_version' );
144
145 if ( $saved_version === false || version_compare( $saved_version, CBXGOOGLEMAP_PLUGIN_VERSION, '<' ) ) {
146 set_transient( 'cbxgooglemap_flush_rewrite_rules', 1 );
147 set_transient( 'cbxgooglemap_upgraded_notice', 1 );
148 update_option( 'cbxgooglemap_version', CBXGOOGLEMAP_PLUGIN_VERSION );
149
150
151 //pro addon compatibility
152 $this->check_pro_addon();
153 }
154 }//end plugin_upgrader_process_complete
155
156 /**
157 * Show notice about pro addon deactivation
158 *
159 * @return void
160 * @since 2.0.0
161 */
162 public function check_pro_addon() {
163 cbxgooglemap_check_and_deactivate_plugin( 'cbxgooglemappro/cbxgooglemappro.php', '2.0.0', 'cbxgooglemap_proaddon_deactivated' );
164 }//end method check_pro_addon
165
166 /**
167 * Add settings action link to the plugins page.
168 *
169 * @since 1.0.0
170 */
171 public function plugin_listing_setting_link( $links ) {
172 return array_merge( [
173 '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>'
174 ], $links );
175
176 }//end plugin_listing_setting_link
177
178 /**
179 * Filters the array of row meta for each/specific plugin in the Plugins list table.
180 * Appends additional links below each/specific plugin on the plugins page.
181 *
182 * @access public
183 *
184 * @param array $links_array An array of the plugin's metadata
185 * @param string $plugin_file_name Path to the plugin file
186 * @param array $plugin_data An array of plugin data
187 * @param string $status Status of the plugin
188 *
189 * @return array $links_array
190 * @since 1.0.0
191 */
192 public function custom_plugin_row_meta( $links_array, $plugin_file_name, $plugin_data, $status ) {
193 if ( strpos( $plugin_file_name, CBXGOOGLEMAP_BASE_NAME ) !== false ) {
194 if ( ! function_exists( 'is_plugin_active' ) ) {
195 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
196 }
197
198
199 $links_array[] = '<a style="color:#39A96B; font-weight: bold;" href="https://wordpress.org/support/plugin/cbxgooglemap/" target="_blank">' . esc_attr__( 'Free Support', 'cbxgooglemap' ) . '</a>';
200 $links_array[] = '<a style="color:#39A96B; font-weight: bold;" href="https://wordpress.org/plugins/cbxgooglemap/#reviews" target="_blank">' . esc_attr__( 'Reviews', 'cbxgooglemap' ) . '</a>';
201 $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>';
202
203 //phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
204 if ( in_array( 'cbxgooglemappro/cbxgooglemappro.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) || defined( 'CBXGOOGLEMAPPRO_PLUGIN_NAME' ) ) {
205 $links_array[] = '<a style="color:#39A96B; font-weight: bold;" href="https://codeboxr.com/contact-us/" target="_blank">' . esc_attr__( 'Pro Support', 'cbxgooglemap' ) . '</a>';
206 } else {
207 $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>';
208 }
209 }
210
211 return $links_array;
212 }//end custom_plugin_row_meta
213
214 /**
215 * Show plugin update
216 *
217 * @param $plugin_file
218 * @param $plugin_data
219 *
220 * @return void
221 */
222 public function custom_message_after_plugin_row_proaddon( $plugin_file, $plugin_data ) {
223 if ( $plugin_file !== 'cbxgooglemappro/cbxgooglemappro.php' ) {
224 return;
225 }
226
227 if ( defined( 'CBXGOOGLEMAPPRO_PLUGIN_NAME' ) ) {
228 return;
229 }
230
231 $pro_addon_version = CBXGooglemapHelper::get_any_plugin_version( 'cbxgooglemappro/cbxgooglemappro.php' );
232 $pro_latest_version = '2.0.2';
233
234 if ( $pro_addon_version != '' && version_compare( $pro_addon_version, $pro_latest_version, '<' ) ) {
235 // Custom message to display
236
237 $plugin_manual_update = 'https://codeboxr.com/manual-update-pro-addon/';
238
239
240 /* translators:translators: %s: plugin setting url for licence */
241 $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 ),
242 $pro_latest_version ), [ 'strong' => [ 'style' => [] ], 'a' => [ 'href' => [], 'target' => [] ] ] );
243
244 // Output a row with custom content
245 echo '<tr class="plugin-update-tr">
246 <td colspan="3" class="plugin-update colspanchange">
247 <div class="notice notice-warning inline">
248 ' . wp_kses_post( $custom_message ) . '
249 </div>
250 </td>
251 </tr>';
252 }
253 }//end method custom_message_after_plugin_row_proaddon
254 }//end class ComfortInvoiceMisc