maybeEnsureCompatibility();
add_action('wp_ajax_dgwt_wcas_bc_keep_latest', array($this, 'wipeAllAjax'));
add_action('wp_ajax_dgwt_wcas_bc_toggle', array($this, 'toggleAjax'));
add_action('wp_ajax_dgwt_wcas_bc_remind_me_later', array($this, 'remindMeLaterAjax'));
add_action('wp_ajax_dgwt_wcas_bc_dismiss_ar_notice', array($this, 'dismissActionRequiredNotice'));
add_action('admin_notices', array($this, 'actionRequiredNotice'));
}
/**
* Show admin notice
*
* @return void
*/
public function actionRequiredNotice()
{
if (defined('DISABLE_NAG_NOTICES') && DISABLE_NAG_NOTICES) {
return;
}
if(get_option('dgwt_wcas_dismiss_bc_action_required_notice')){
return;
}
$cs = get_current_screen();
$views = array(
'dashboard',
'update-core',
'plugins'
);
if ( ! empty($cs->id) && in_array($cs->id, $views) && $this->canShowNotice()) {
?>
[]
- Go to the plugin page.', 'sample-text-domain'), '(v' . DGWT_WCAS_VERSION . ')', Helpers::getSettingsUrl()); ?>
enable();
break;
case 'disable':
$status = $this->disable();
break;
}
}
if ($status) {
wp_send_json_success();
}
wp_send_json_error();
}
/**
* Set transient (one week) for remind me later in notice
*
* @return void
*/
public function remindMeLaterAjax()
{
if (set_transient($this->remindMeLaterTransient, true, (60 * 60 * 24 * 3))) {
wp_send_json_success();
}
wp_send_json_error();
}
/**
* Dismiss extra notice to inform about manually updating
*
* @return void
*/
public function dismissActionRequiredNotice()
{
if (add_option('dgwt_wcas_dismiss_bc_action_required_notice', true)) {
wp_send_json_success();
}
wp_send_json_error();
}
/**
* Check if backward compatibility options exist.
*
* @return bool
*/
public function optionsExists()
{
$optBc = get_option('dgwt_wcas_backward_compatibility');
$optBcVersion = get_option('dgwt_wcas_backward_compatibility_version');
return ! empty($optBc) && ! empty($optBcVersion);
}
/**
* Check if backward compatibility is enabled
*
* @return bool
*/
private function isEnabled()
{
$opt = get_option('dgwt_wcas_backward_compatibility');
return ! empty($opt) && $opt === 'on';
}
/**
* Load backward asstes and partials if it is necessary
*
* @return bool true if loading backward compatible files was necessary
*/
private function maybeEnsureCompatibility()
{
$ensured = false;
$cv = self::getCompatibleVersion();
if (
$this->isEnabled()
&& $cv
&& version_compare($cv, '0.0.1', '>=') >= 0 // Check if version is correct
&& version_compare(DGWT_WCAS_VERSION, $cv, '>')
) {
$methodName = 'compatibleWith_' . str_replace('.', '_', $cv);
if (method_exists($this, $methodName)) {
$this->$methodName();
$ensured = true;
}
}
return $ensured;
}
/**
* Wipe all information about backward compatibility
*
* @return bool true on success
*/
private function wipeAll()
{
$bc = delete_option('dgwt_wcas_backward_compatibility');
$bcv = delete_option('dgwt_wcas_backward_compatibility_version');
return ($bc && $bcv);
}
public function wipeAllAjax()
{
$status = $this->wipeAll();
wp_send_json_success($status);
}
/**
* Load v1.1.7 assets and partials
* style.css, jquery.dgwt-wcas.min.js and search-form.php
*
* @return void
*/
public function compatibleWith_1_1_7()
{
// CSS
add_filter('dgwt/wcas/scripts/css_style_url', function ($url) {
return DGWT_WCAS_URL . 'backward-compatibility/1-1-7/style.css';
});
// JS
add_filter('dgwt/wcas/scripts/js_url', function ($url) {
return DGWT_WCAS_URL . 'backward-compatibility/1-1-7/jquery.dgwt-wcas.min.js';
});
// Form partial path
add_filter('dgwt/wcas/form/partial_path', function ($url) {
return DGWT_WCAS_DIR . 'backward-compatibility/1-1-7/search-form.php';
});
// Body classes
add_filter('body_class', function ($classes) {
$classes[] = 'dgwt-wcas-bc-1-1-7';
return $classes;
});
}
/**
*
*/
public function canShowNotice()
{
$canShow = false;
$optBc = get_option('dgwt_wcas_backward_compatibility');
$optVersion = get_option('dgwt_wcas_backward_compatibility_version');
$remindMeLater = get_transient($this->remindMeLaterTransient);
if ($remindMeLater) {
return false;
}
if (
! empty($optBc)
&& ! empty($optVersion)
&& in_array($optBc, array('on', 'off'))
&& version_compare($optVersion, '0.0.1', '>=') >= 0
&& version_compare(DGWT_WCAS_VERSION, $optVersion, '>')
) {
$canShow = true;
} else {
$this->wipeAll();
}
return $canShow;
}
/**
* Notice
*
* @return void
*/
public function notice()
{
if ( ! $this->canShowNotice()) {
return;
}
$theme = wp_get_theme();
$themeName = $theme->get('Name');
$themeUri = $theme->get('ThemeURI');
$themeAuthor = $theme->get('Author');
$themeAuthorURL = $theme->get('Author URI');
$themeLink = ! empty($themeUri) ? '' . esc_html($themeName) . '' : '"' . esc_html($themeName) . '"';
$vompatibleVersion = self::getCompatibleVersion();
$troubleshootingLink = '' . __('troubleshooting',
'ajax-search-for-woocommerce') . '';
add_thickbox();
ob_start();
?>
Complete the update process', 'ajax-search-for-woocommerce'); ?>-
- store', 'ajax-search-for-woocommerce'), get_permalink(wc_get_page_id('shop'))); ?>
- ' . __('finish the update', 'ajax-search-for-woocommerce') . ''); ?>
- previous version %s and see %s', 'ajax-search-for-woocommerce'), '(v' . $vompatibleVersion . ')', $troubleshootingLink); ?>
#1
|
|
' . $themeName . '';
} else {
echo $themeName;
}
?>
|
|
' . $themeAuthor . '';
} else {
echo $themeAuthor;
}
?>
|
I use your %s theme with AJAX Search for WooCommerce plugin - (https://wordpress.org/plugins/ajax-search-for-woocommerce/)
In the lates version of AJAX Search for WooCommerce %s they have changed the search form on the frontend (CSS, HTML etc.).
Could you check it and update your CSS if necessary?", 'ajax-search-for-woocommerce'),
$themeName,
'(v' . DGWT_WCAS_VERSION . ')');
?>
our support or write on the WordPress.org Support.', 'ajax-search-for-woocommerce'); ?>
Plugin Version: ' . DGWT_WCAS_VERSION;
echo '
Enabled: ' . ($this->isEnabled() ? 'yes' : 'no');
echo '
Last compatible version: ' . (! empty($cv) ? $cv : 'not set');
echo '
Can ensure: ' . ($this->maybeEnsureCompatibility() ? 'yes' : 'no');
$optBc = get_option('dgwt_wcas_backward_compatibility');
echo '
Option [dgwt_wcas_backward_compatibility]: ';
if (empty($optBc)) {
echo 'not set';
} else {
echo $optBc;
}
$optVersion = get_option('dgwt_wcas_backward_compatibility_version');
echo '
Option [dgwt_wcas_backward_compatibility_version]: ';
if (empty($optVersion)) {
echo 'not set';
} else {
echo $optVersion;
}
}
}