';
public $warning = '';
public $danger = '';
/**
* Get Status Page Info
* @return array
*/
public function get_woo_feed_status(){
$status = woo_feed_get_cached_data( 'woo_feed_status_page_info' );
if ( false === $status ) {
$status = [
$this->woocommerce_version(), // WooCommerce Version
$this->get_available_product_types(),
$this->total_products(), // Count Total Products
$this->product_per_batch(), // Product Per branch
$this->product_query_type(),
$this->default_customer_location(),
$this->server_info(),
$this->multi_language(),
$this->multi_currency(),
$this->wordpress_debug(),
$this->wordpress_cron(),
$this->upload_dir_writable(),
$this->exclude_feed_caching(),
$this->wordpress_multisite(),
];
$status = array_merge($status, $this->server_info());
woo_feed_set_cache_data('woo_feed_status_page_info', $status);
}
return $status;
}
/**
* Get CTX Feed Log.
*/
public function get_logs( ) {
$fatal_errors = Woo_Feed_Log_Handler_File::get_log_file_path('woo-feed-fatal-errors');
if ( file_exists($fatal_errors) && $fatal_errors ) {
return file_get_contents($fatal_errors); //phpcs:ignore
}
return "No Logs Found.";
}
/**
* Get Wordpress.org plugin information.
*
* @param $slug
*
* @return false|mixed
*/
private function plugin_info( $slug ) {
if ( empty($slug) ) {
return false;
}
$args = (object) array(
'slug' => $slug,
'fields' => array(
'sections' => false,
'screenshots' => false,
'versions' => false,
),
);
$request = array(
'action' => 'plugin_information',
'request' => serialize( $args), //phpcs:ignore
);
$url = 'http://api.wordpress.org/plugins/info/1.0/';
$response = wp_remote_post( $url, array( 'body' => $request ) );
if ( is_wp_error($response) ) {
return false;
}
return unserialize( $response['body']); //phpcs:ignore
}
/**
* Check WordPress multisite status.
*/
private function wordpress_multisite( ) {
$status = $this->success;
$message = 'No';
if ( defined( 'WOO_FEED_PRO_VERSION' ) && is_multisite() ) {
$message = "WordPress Multisite is enabled. If you have hosted your sites into subdomain like fr.example.com then you need a license for each site. If you have five subdomain then you need the Five site license.";
}
return [
'label' => 'WordPress Multi Site',
'status' => $status,
'message' => $message,
];
}
/**
* Get WooCommerce Version Status.
*/
private function woocommerce_version( ) {
$installed_version = (function_exists('WC')) ? WC()->version : '1.0.0';
$latest_version = $this->plugin_info('woocommerce');
if ( version_compare($installed_version,'3.0','<') ) {
$status = $this->danger;
$message = $installed_version." - You are using a old version of WooCommerce. To use our plugin your WooCommerce version should be 3.0 or later.";
}elseif ( version_compare($latest_version->version,$installed_version,'>') ) {
$status = $this->warning;
$message = $installed_version." - You are not using the latest version of WooCommerce. Update WooCommerce plugin to its latest version: ".$latest_version->version;
}else {
$status = $this->success;
$message = $installed_version." - You are using the latest version of WooCommerce.";
}
return [
'label' => 'WooCommerce Version',
'status' => $status,
'message' => $message,
];
}
/**
* Get Multi Language Status.
*/
private function multi_language( ) {
$status = $this->success;
$message = "No";
$doc = '';
$multi_lang_plugin = '';
/**
* polylang/polylang.php Polylang
* polylang-pro/polylang.php Polylang Pro
* gtranslate/gtranslate.php GTranslate
* translatepress-multilingual/index.php TranslatePress - Multilingual
* weglot/weglot.php Weglot Translate
* google-language-translator/google-language-translator.php Google Language Translator
* sitepress-multilingual-cms/sitepress.php WPML Multilingual CMS
*/
if ( is_plugin_active('sitepress-multilingual-cms/sitepress.php') ) {
$multi_lang_plugin = 'WPML';
$doc = "
You can read this doc about: How to make feed for WPML languages?";
}elseif ( is_plugin_active("polylang/polylang.php") ) {
$multi_lang_plugin = 'Polylang';
$doc = "
You can read this doc about: How to make feed for Polylang languages?";
}elseif ( is_plugin_active("polylang-pro/polylang.php") ) {
$multi_lang_plugin = 'Polylang Pro';
$doc = "
You can read this doc about: How to make feed for Polylang languages?";
}elseif ( is_plugin_active('gtranslate/gtranslate.php') ) {
$multi_lang_plugin = 'GTranslate';
}elseif ( is_plugin_active('translatepress-multilingual/index.php') ) {
$multi_lang_plugin = 'TranslatePress - Multilingual';
}elseif ( is_plugin_active('weglot/weglot.php') ) {
$multi_lang_plugin = 'Weglot Translate';
}elseif ( is_plugin_active('google-language-translator/google-language-translator.php') ) {
$multi_lang_plugin = 'Google Language Translator';
}
if ( ! empty($multi_lang_plugin) ) {
if ( ! in_array($multi_lang_plugin,[ 'WPML', 'Polylang', 'Polylang Pro', 'TranslatePress - Multilingual' ],true) ) {
$status = $this->warning;
$message = "$multi_lang_plugin is not compatible for multi-language feed. You can not make feed for each language. Supported multi-language plugins are WPML & Polylang.";
}elseif ( is_plugin_active('webappick-product-feed-for-woocommerce/woo-feed.php') ) {
$status = $this->warning;
$message = "You are using $multi_lang_plugin for multi language site. But the free version of this plugin is not compatible with $multi_lang_plugin. Using Woo Feed Pro you can make feed for each language.";
$message .= $doc;
}else {
$message = "$multi_lang_plugin";
}
}
return [
'label' => 'Multi Language Site',
'status' => $status,
'message' => $message,
];
}
/**
* Get Multi Currency Status.
*/
private function multi_currency( ) {
$status = $this->success;
$message = "No";
$free_version = is_plugin_active( 'webappick-product-feed-for-woocommerce/woo-feed.php' );
$supported_multi_currency = "Below Multi Currency Plugins are compatible with Woo Feed Pro. ";
$supported_multi_currency .= "
";
$supported_multi_currency .= "
wp-content/uploads/
directory file write permission so that the plugin can save the feed file.";
}
return [
'label' => 'Upload Directory',
'status' => $status,
'message' => $message,
];
}
/**
* Get Caching Status.
*/
private function exclude_feed_caching( ) {
$status = $this->success;
$message = "No.";
$cache_plugins = array(
'breeze/breeze.php' => 'Breeze',
'cache-cleaner/cache-cleaner.php' => 'Cache Cleaner - Scheduled',
'cache-enabler/cache-enabler.php' => 'Cache Enabler',
'cloudflare/cloudflare.php' => 'Cloudflare',
'comet-cache/comet-cache.php' => 'Comet Cache',
'hummingbird-performance/wp-hummingbird.php' => 'Hummingbird',
'hyper-cache/plugin.php' => 'Hyper Cache',
'litespeed-cache/litespeed-cache.php' => 'LiteSpeed Cache',
'speed-booster-pack/speed-booster-pack.php' => 'Speed Booster Pack',
'swift-performance-lite/performance.php' => 'Swift Performance Lite',
'w3-total-cache/w3-total-cache.php' => 'W3 Total Cache',
'wp-optimize/wp-optimize.php' => 'WP-Optimize - Clean, Compress, Cache',
'wp-cloudflare-page-cache/wp-cloudflare-super-page-cache.php' => 'WP Cloudflare Super Page Cache',
'wp-fastest-cache/wpFastestCache.php' => 'WP Fastest Cache',
'wp-rocket/wp-rocket.php' => 'WP Rocket',
'wp-super-cache/wp-cache.php' => 'WP Super Cache',
);
$active_plugins = get_option('active_plugins');
$cache_plugins_installed = false;
foreach ( $active_plugins as $key => $active_plugin ) {
if ( array_key_exists($active_plugin,$cache_plugins) ) {
$cache_plugins_installed = $cache_plugins[ $active_plugin ];
}
}
if ( $cache_plugins_installed ) {
$status = $this->warning;
$message = "$cache_plugins_installed plugin is installed on your site. Please make sure that feed file URL or directory is excluded from caching. If not excluded, your feed file may not be updated instantly after feed update. Please read this doc about: How to exclude feed file URL or Directory from caching?";
}
return [
'label' => 'Cache Plugin Installed',
'status' => $status,
'message' => $message,
];
}
/**
* Get available woocommerce product types
*/
private function get_available_product_types(){
$types = wc_get_product_types();
$status = $this->success;
$message = '';
if ( ! empty($types) ) {
foreach ( $types as $key => $type ) {
$message .= "☞ ". ucwords($type)." [".$key."]