| 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( 'cbxgooglemap_proaddon_deactivated' ) ) { |
| 94 |
echo '<div class="notice notice-warning is-dismissible" style="border-color: #6648fe !important;">'; |
| 95 |
|
| 96 |
echo '<p>'; |
| 97 |
esc_html_e( 'Current version of CBX Map Pro Addon is not compatible with core CBX Map. CBX Map Pro Addon is forced deactivate. Update CBX Map Pro Addon to V2.0.0 or later.', 'cbxgooglemap' ); |
| 98 |
|
| 99 |
echo '</p>'; |
| 100 |
echo '</div>'; |
| 101 |
|
| 102 |
delete_transient( 'cbxgooglemap_proaddon_deactivated' ); |
| 103 |
}//end checking cbxgooglemappro_deactivated_notice |
| 104 |
}//end plugin_activate_upgrade_notices |
| 105 |
|
| 106 |
/** |
| 107 |
* Check plugin compatibility and pro addon install campaign |
| 108 |
*/ |
| 109 |
public function pro_addon_compatibility_campaign() { |
| 110 |
//if the pro addon is active or installed |
| 111 |
if ( !defined( 'CBXGOOGLEMAPPRO_PLUGIN_NAME' )) { |
| 112 |
|
| 113 |
/* translators: %s: Plugin Link */ |
| 114 |
$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/' ) ); |
| 115 |
echo '<div class="notice notice-success is-dismissible"><p>' . wp_kses_post( $message ) . '</p></div>'; |
| 116 |
} |
| 117 |
}//end pro_addon_compatibility_campaign |
| 118 |
|
| 119 |
/** |
| 120 |
* Pro Addon update message |
| 121 |
*/ |
| 122 |
public function plugin_update_message_pro_addon() { |
| 123 |
/* translators: 1: Plugin Manual Download Link 2: Plugin Manual Download Link */ |
| 124 |
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/' ); |
| 125 |
}//end plugin_update_message_pro_addon |
| 126 |
|
| 127 |
/** |
| 128 |
* If we need to do something in upgrader process is completed |
| 129 |
* |
| 130 |
*/ |
| 131 |
public function plugin_upgrader_process_complete() { |
| 132 |
$saved_version = get_option( 'cbxgooglemap_version' ); |
| 133 |
|
| 134 |
if ( $saved_version === false || version_compare( $saved_version, CBXGOOGLEMAP_PLUGIN_VERSION, '<' ) ) { |
| 135 |
set_transient( 'cbxgooglemap_flush_rewrite_rules', 1 ); |
| 136 |
set_transient( 'cbxgooglemap_upgraded_notice', 1 ); |
| 137 |
update_option( 'cbxgooglemap_version', CBXGOOGLEMAP_PLUGIN_VERSION ); |
| 138 |
|
| 139 |
|
| 140 |
//pro addon compatibility |
| 141 |
$this->check_pro_addon(); |
| 142 |
} |
| 143 |
}//end plugin_upgrader_process_complete |
| 144 |
|
| 145 |
/** |
| 146 |
* Show notice about pro addon deactivation |
| 147 |
* |
| 148 |
* @return void |
| 149 |
* @since 2.0.0 |
| 150 |
*/ |
| 151 |
public function check_pro_addon() { |
| 152 |
cbxgooglemap_check_and_deactivate_plugin( 'cbxgooglemappro/cbxgooglemappro.php', '2.0.0', 'cbxgooglemap_proaddon_deactivated' ); |
| 153 |
}//end method check_pro_addon |
| 154 |
|
| 155 |
/** |
| 156 |
* Add settings action link to the plugins page. |
| 157 |
* |
| 158 |
* @since 1.0.0 |
| 159 |
*/ |
| 160 |
public function plugin_listing_setting_link( $links ) { |
| 161 |
return array_merge( [ |
| 162 |
'settings' => '<a style="color:#5d5dff; font-weight: bold;" href="' . esc_url( admin_url( 'edit.php?post_type=cbxgooglemap&page=cbxgooglemap_settings' ) ) . '">' . esc_attr__( 'Settings', 'cbxgooglemap' ) . '</a>' |
| 163 |
], $links ); |
| 164 |
|
| 165 |
}//end plugin_listing_setting_link |
| 166 |
|
| 167 |
/** |
| 168 |
* Filters the array of row meta for each/specific plugin in the Plugins list table. |
| 169 |
* Appends additional links below each/specific plugin on the plugins page. |
| 170 |
* |
| 171 |
* @access public |
| 172 |
* |
| 173 |
* @param array $links_array An array of the plugin's metadata |
| 174 |
* @param string $plugin_file_name Path to the plugin file |
| 175 |
* @param array $plugin_data An array of plugin data |
| 176 |
* @param string $status Status of the plugin |
| 177 |
* |
| 178 |
* @return array $links_array |
| 179 |
* @since 1.0.0 |
| 180 |
*/ |
| 181 |
public function custom_plugin_row_meta( $links_array, $plugin_file_name, $plugin_data, $status ) { |
| 182 |
if ( strpos( $plugin_file_name, CBXGOOGLEMAP_BASE_NAME ) !== false ) { |
| 183 |
|
| 184 |
$links_array[] = '<a style="color:#5d5dff; font-weight: bold;" href="https://wordpress.org/support/plugin/cbxgooglemap/" target="_blank">' . esc_attr__( 'Free Support', 'cbxgooglemap' ) . '</a>'; |
| 185 |
$links_array[] = '<a style="color:#5d5dff; font-weight: bold;" href="https://wordpress.org/plugins/cbxgooglemap/#reviews" target="_blank">' . esc_attr__( 'Reviews', 'cbxgooglemap' ) . '</a>'; |
| 186 |
$links_array[] = '<a target="_blank" style="color:#5d5dff !important; font-weight: bold;" href="https://codeboxr.com/doc/cbxmap-doc/" aria-label="' . esc_attr__( 'Documentation', 'cbxgooglemap' ) . '">' . esc_html__( 'Documentation', 'cbxgooglemap' ) . '</a>'; |
| 187 |
$links_array[] = '<a style="color:#5d5dff; font-weight: bold;" href="https://codeboxr.com/contact-us/" target="_blank">' . esc_attr__( 'Pro Support', 'cbxgooglemap' ) . '</a>'; |
| 188 |
$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>'; |
| 189 |
} |
| 190 |
|
| 191 |
return $links_array; |
| 192 |
}//end custom_plugin_row_meta |
| 193 |
|
| 194 |
/** |
| 195 |
* Show plugin update |
| 196 |
* |
| 197 |
* @param $plugin_file |
| 198 |
* @param $plugin_data |
| 199 |
* |
| 200 |
* @return void |
| 201 |
*/ |
| 202 |
public function custom_message_after_plugin_row_proaddon( $plugin_file, $plugin_data ) { |
| 203 |
if ( $plugin_file !== 'cbxgooglemappro/cbxgooglemappro.php' ) { |
| 204 |
return; |
| 205 |
} |
| 206 |
|
| 207 |
if ( defined( 'CBXGOOGLEMAPPRO_PLUGIN_NAME' ) ) { |
| 208 |
return; |
| 209 |
} |
| 210 |
|
| 211 |
$pro_addon_version = CBXGooglemapHelper::get_any_plugin_version( 'cbxgooglemappro/cbxgooglemappro.php' ); |
| 212 |
$pro_latest_version = CBXGOOGLEMAP_PRO_VERSION; |
| 213 |
|
| 214 |
if ( $pro_addon_version != '' && version_compare( $pro_addon_version, $pro_latest_version, '<' ) ) { |
| 215 |
// Custom message to display |
| 216 |
|
| 217 |
$plugin_manual_update = 'https://codeboxr.com/manual-update-pro-addon/'; |
| 218 |
|
| 219 |
|
| 220 |
/* translators:translators: %s: plugin setting url for licence */ |
| 221 |
$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 ), |
| 222 |
$pro_latest_version ), [ 'strong' => [ 'style' => [] ], 'a' => [ 'href' => [], 'target' => [] ] ] ); |
| 223 |
|
| 224 |
// Output a row with custom content |
| 225 |
echo '<tr class="plugin-update-tr"> |
| 226 |
<td colspan="3" class="plugin-update colspanchange"> |
| 227 |
<div class="notice notice-warning inline"> |
| 228 |
' . wp_kses_post( $custom_message ) . ' |
| 229 |
</div> |
| 230 |
</td> |
| 231 |
</tr>'; |
| 232 |
} |
| 233 |
}//end method custom_message_after_plugin_row_proaddon |
| 234 |
}//end class ComfortInvoiceMisc |