File: /home/tsacademy/domains/tsacademy.ir/public_html/wp-content/plugins/Wallexio/wallexio.php
<?php
/*
Plugin Name: کیف پول هوشمند
Description: شارژ، برداشت، اعتبار بازگشتی، هدیه ثبتنام و ثبت نظر.
Author: Ali Mohammady
Version: 1.1.0
Author URI: https://zhaket.com/store/web/alixio/products
Plugin URI: https://zhaket.com/web/wallexio-plugin
Text Domain: wallexio
Domain Path: /languages
Requires at least: 6.0
Requires PHP: 7.4
*/
defined( 'ABSPATH' ) || exit;
define( 'WALLEXIO_VERSION', '1.1.0' );
define( 'WALLEXIO_BASENAME', plugin_basename( __FILE__ ) );
define( 'WALLEXIO_FILE', __FILE__ );
define( 'WALLEXIO_PATH', wp_normalize_path( plugin_dir_path( __FILE__ ) ) );
define( 'WALLEXIO_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
if ( ! function_exists( 'is_plugin_active' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
add_action( 'plugins_loaded', 'wallexio_on_plugins_loaded', 10 );
function wallexio_on_plugins_loaded() {
load_plugin_textdomain( 'wallexio', false, dirname( WALLEXIO_BASENAME ) . '/languages' );
}
add_action( 'before_woocommerce_init', 'wallexio_before_wc_init' );
function wallexio_before_wc_init() {
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, true );
}
}
if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
add_action( 'admin_notices', 'wallexio_admin_notice_no_wc' );
return;
}
function wallexio_admin_notice_no_wc() {
echo '<div class="notice notice-error is-dismissible"><p>' . esc_html__( 'کیف پول هوشمند به نصب و فعال بودن ووکامرس نیاز دارد.', 'wallexio' ) . '</p></div>';
}
require_once __DIR__.'/activatezhk/validate-locked.php';
require_once WALLEXIO_PATH . 'core/create-db.php';
require_once WALLEXIO_PATH . 'core/wallexio-core.php';
require_once WALLEXIO_PATH . 'core/sms.php';
require_once WALLEXIO_PATH . 'core/cashback.php';
require_once WALLEXIO_PATH . 'core/hooks.php';
require_once WALLEXIO_PATH . 'core/partial-payment.php';
require_once WALLEXIO_PATH . 'core/settings.php';
require_once WALLEXIO_PATH . 'core/ajax-settings.php';
require_once WALLEXIO_PATH . 'core/user-edit.php';
require_once WALLEXIO_PATH . 'core/menu.php';
require_once WALLEXIO_PATH . 'wallet/gateway.php';
require_once WALLEXIO_PATH . 'wallet/balance-func.php';
require_once WALLEXIO_PATH . 'wallet/withdraw-func.php';
require_once WALLEXIO_PATH . 'wallet/transaction-func.php';
require_once WALLEXIO_PATH . 'wallet/front.php';
require_once WALLEXIO_PATH . 'wallet/endpoints.php';
require_once WALLEXIO_PATH . 'wallet/hooks.php';
require_once WALLEXIO_PATH . 'wallet/checkout-partial.php';
require_once WALLEXIO_PATH . 'wallet/front-blocks.php';
require_once WALLEXIO_PATH . 'admin/withdrawals-table.php';
require_once WALLEXIO_PATH . 'core/ajax.php';
add_filter( 'plugin_action_links_' . WALLEXIO_BASENAME, 'wallexio_plugin_action_links' );
function wallexio_plugin_action_links( $links ) {
$settings_link = '<a href="' . esc_url( admin_url( 'admin.php?page=wallexio' ) ) . '">' . esc_html__( 'تنظیمات', 'wallexio' ) . '</a>';
array_unshift( $links, $settings_link );
return $links;
}
add_action( 'admin_init', 'wallexio_maybe_create_product' );
function wallexio_maybe_create_product() {
$product_id = get_option( 'wallexio_product_id', 0 );
if ( function_exists( 'icl_object_id' ) && $product_id ) {
$product_id = (int) apply_filters( 'wpml_object_id', $product_id, 'product', true );
}
if ( ! $product_id || ! wc_get_product( $product_id ) ) {
$product_id = wallexio_create_wallet_product();
if ( $product_id && ! is_wp_error( $product_id ) ) {
update_option( 'wallexio_product_id', $product_id );
}
}
}
function wallexio_create_wallet_product() {
$post_id = wp_insert_post( array(
'post_title' => __( 'شارژ کیف پول', 'wallexio' ),
'post_status' => 'private',
'post_type' => 'product',
'post_author' => get_current_user_id(),
) );
if ( is_wp_error( $post_id ) ) {
return $post_id;
}
$product = wc_get_product( $post_id );
if ( $product ) {
wp_set_object_terms( $post_id, 'simple', 'product_type' );
$product->set_virtual( true );
$product->set_sold_individually( true );
$product->set_catalog_visibility( 'hidden' );
$product->set_reviews_allowed( false );
$product->save();
}
return $post_id;
}