芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/www/wp-content/plugins/chaty/includes/class-affiliate.php
* @license : GPL2 * */ if (defined('ABSPATH') === false) { exit; } class Chaty_Affiliate_Program { /** * The Name of this plugin. * * @var string $pluginName The Name of this plugin. * @since 1.0.0 * @access public */ public $pluginName = "Chaty"; /** * The Slug of this plugin. * * @var string $pluginSlug The Slug of this plugin. * @since 1.0.0 * @access public */ public $pluginSlug = "chaty"; /** * __construct method initializes the object and adds action hooks. * * @return void */ public function __construct() { add_action("wp_ajax_".$this->pluginSlug."_affiliate_program", [$this, "affiliate_program"]); add_action('admin_notices', [$this, 'admin_notices']); }//end __construct() /** * affiliate_program method handles the affiliate program action. * * This method checks if the current user has the capability to manage options. * If the user has the capability, it retrieves the nonce and days values from the POST data. * Then, it verifies the nonce and performs the necessary actions based on the values. * If the days value is -1, it adds an option to hide the affiliate box. * Otherwise, it adds an option to set the date after which the affiliate box should be shown. * * @return void */ public function affiliate_program() { if (current_user_can('manage_options')) { $nonce = filter_input(INPUT_POST, 'nonce'); $days = filter_input(INPUT_POST, 'days'); if (!empty($nonce) && wp_verify_nonce($nonce, $this->pluginSlug."_affiliate_program")) { if ($days == -1) { add_option($this->pluginSlug."_hide_affiliate_box", "1"); } else { $date = gmdate("Y-m-d", strtotime("+".$days." days")); update_option($this->pluginSlug."_show_affiliate_box_after", $date); } } die; } }//end affiliate_program() /** * admin_notices method displays notices in the admin area for users with the 'manage_options' capability. * * @return void */ public function admin_notices() { if (current_user_can('manage_options')) { $isHidden = get_option($this->pluginSlug."_hide_affiliate_box"); if ($isHidden !== false) { return; } $dateToShow = get_option($this->pluginSlug."_show_affiliate_box_after"); if ($dateToShow === false || empty($dateToShow)) { $date = gmdate("Y-m-d", strtotime("+5 days")); update_option($this->pluginSlug."_show_affiliate_box_after", $date); return; } $currentDate = gmdate("Y-m-d"); if ($currentDate < $dateToShow) { return; } ?>
".esc_attr($this->pluginName)."", "
".esc_attr($this->pluginName)."
", "
25% lifetime commission
") ?>