'' . esc_html__('Docs', 'woocommerce') . '', 'apidocs' => '' . esc_html__('API docs', 'woocommerce') . '', 'support' => '' . esc_html__('Premium support', 'woocommerce') . '', ); //unset($links[2]); return array_merge($links, $row_meta); } return (array) $links; } //----------------------------------------------------------------------------------------------------------------------------- function activate_plugin($plugin) { // Localisation $this->updateTransFile(); //nice code but give graceful failure in //https://plugintests.com/plugins/wporg/myfatoorah-woocommerce/latest //it is very important to say that the plugin is MyFatoorah /* $pluginsArr = apply_filters('active_plugins', get_option('active_plugins')); $siteWideArr = apply_filters('active_plugins', get_site_option('active_sitewide_plugins')); $isWooPlugActive = is_array($pluginsArr) && in_array('woocommerce/woocommerce.php', $pluginsArr); $isSiteWideActive = is_array($siteWideArr) && array_key_exists('woocommerce/woocommerce.php', $siteWideArr); if ($plugin == MYFATOORAH_WOO_PLUGIN && !$isWooPlugActive && !$isSiteWideActive) { $msg = __('WooCommerce plugin needs to be activated first to activate MyFatoorah plugin.', 'myfatoorah-woocommerce'); wp_die($msg, 403); } */ } //----------------------------------------------------------------------------------------------------------------------------- function upgrader_process_complete($upgraderObject, $options) { // If an update has taken place and the updated type is plugins and the plugins element exists if ($options['action'] == 'update' && $options['type'] == 'plugin' && isset($options['plugins'])) { foreach ($options['plugins'] as $plugin) { // Check to ensure it's my plugin if ($plugin == MYFATOORAH_WOO_PLUGIN) { $this->updateTransFile(); } } } } //----------------------------------------------------------------------------------------------------------------------------- function updateTransFile() { $arTrans = 'myfatoorah-woocommerce-ar'; if (is_dir(WP_LANG_DIR . '/plugins/')) { $filePath = WP_LANG_DIR . '/plugins/' . $arTrans; $moFileAr = $filePath . '.mo'; $poFileAr = $filePath . '.po'; $newFilePath = __DIR__ . '/languages/' . $arTrans; $moNewFileAr = $newFilePath . '.mo'; $poNewFileAr = $newFilePath . '.po'; copy($moNewFileAr, $moFileAr); copy($poNewFileAr, $poFileAr); } } //----------------------------------------------------------------------------------------------------------------------------- function admin_notices() { $msg = __('MyFatoorah - WooCommerce plugin needs WooCommerce plugin to be installed and active.', 'myfatoorah-woocommerce'); echo '

' . $msg . '

'; } //----------------------------------------------------------------------------------------------------------------------------- /** * Init localizations and files */ public function init() { // Localisation load_plugin_textdomain('myfatoorah-woocommerce', false, MYFATOORAH_WOO_PLUGIN_NAME . '/languages'); if (!class_exists('WooCommerce')) { add_action('admin_notices', [$this, 'admin_notices']); return; } //load payment require_once 'includes/PluginPaymentMyfatoorahWoocommerce.php'; new PluginPaymentMyfatoorahWoocommerce('v2'); new PluginPaymentMyfatoorahWoocommerce('embedded'); //load shipping require_once 'includes/PluginShippingMyfatoorahWoocommerce.php'; new PluginShippingMyfatoorahWoocommerce(); //load webhook require_once 'includes/PluginWebhookMyfatoorahWoocommerce.php'; new PluginWebhookMyfatoorahWoocommerce(); //load cron //https://www.codesmade.com/wordpress-add-cron-job-programmatically/ add_action('myfatoorah_backup_log_files', [$this, 'myfatoorah_backup_log_files']); if (!wp_next_scheduled('myfatoorah_backup_log_files')) { wp_schedule_event(time(), 'weekly', 'myfatoorah_backup_log_files'); } } //----------------------------------------------------------------------------------------------------------------------------------------- /** * Show important release note * @param type $data * @param type $response */ function prefix_plugin_update_message($data, $response) { $notice = null; if (!empty($data['upgrade_notice'])) { $notice = trim(strip_tags($data['upgrade_notice'])); } else if (!empty($response->upgrade_notice)) { $notice = trim(strip_tags($response->upgrade_notice)); } if (!empty($notice)) { printf( '

Important Upgrade Notice: %s', __($notice, 'myfatoorah-woocommerce') ); } //https://andidittrich.com/2015/05/howto-upgrade-notice-for-wordpress-plugins.html } //----------------------------------------------------------------------------------------------------------------------------- function myfatoorah_backup_log_files() { $codes = array_keys(apply_filters('myfatoorah_woocommerce_payment_gateways', [])); $codes[] = 'shipping'; $codes[] = 'webHook'; foreach ($codes as $code) { $this->myfatoorah_backup_log_file($code); } } function myfatoorah_backup_log_file($code) { $myfatoorahLogFile = WC_LOG_DIR . 'myfatoorah_' . $code . '.log'; if (file_exists($myfatoorahLogFile)) { $mfLogFolder = WC_LOG_DIR . 'mfOldLog'; if (!file_exists($mfLogFolder)) { mkdir($mfLogFolder); } $mfLogFolder .= '/' . $code; if (!file_exists($mfLogFolder)) { mkdir($mfLogFolder); } rename($myfatoorahLogFile, $mfLogFolder . '/' . date('Y-m-d') . '_myfatoorah_' . $code . '.log'); } } //----------------------------------------------------------------------------------------------------------------------------- function before_woocommerce_init() { if (class_exists(FeaturesUtil::class)) { //to remove mf from feature_id=custom_order_tables list //to disable waring message for High-Performance Order Storage features //http://wordpress-6.2.2.com/wp-admin/plugins.php?plugin_status=incompatible_with_feature&feature_id=custom_order_tables //https://github.com/woocommerce/woocommerce/wiki/High-Performance-Order-Storage-Upgrade-Recipe-Book FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true); //to remove mf from feature_id=cart_checkout_blocks //http://wordpress-6.2.2.com/wp-admin/plugins.php?plugin_status=incompatible_with_feature&feature_id=cart_checkout_blocks //https://woocommerce.com/document/cart-checkout-blocks-support-status/ //https://developer.woocommerce.com/2021/03/15/integrating-your-payment-method-with-cart-and-checkout-blocks/ //follow instruction here b4 enable it //https://developer.woo.com/2023/11/06/faq-extending-cart-and-checkout-blocks/ //https://github.com/woocommerce/woocommerce-blocks/blob/trunk/docs/third-party-developers/extensibility/checkout-payment-methods/payment-method-integration.md#registering-assets //FeaturesUtil::declare_compatibility('cart_checkout_blocks', __FILE__, true); } } //----------------------------------------------------------------------------------------------------------------------------- } new MyfatoorahWoocommerce();