*/ class Subscribe extends Notice { use User_Data; public $color = 'warning'; /** * Construct method * * @author Jewel Theme */ public function __construct() { parent::__construct(); add_action('wp_ajax_jltma_subscribe', array($this, 'jltma_subscribe')); } /** * Subscribe method * * @author Jewel Theme */ public function jltma_subscribe() { check_ajax_referer('jltma_subscribe_nonce'); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( [ 'message' => __( 'Insufficient permissions', 'master-addons' ) ] ); } $name = !empty($_POST['name']) ? sanitize_text_field(wp_unslash($_POST['name'])) : ''; $email = !empty($_POST['email']) ? sanitize_email(wp_unslash($_POST['email'])) : ''; if (!is_email($email)) { $email = get_bloginfo('admin_email'); } $author_obj = get_user_by('email', get_bloginfo('admin_email')); $user_id = $author_obj->ID; // First Name & Last name . if (!empty($name)) { $full_name = $name; } else { $full_name = $author_obj->display_name; } $response = $this->get_collect_data($user_id, array( 'first_name' => $full_name, 'email' => $email, )); if (!is_wp_error($response) && 200 === $response['response']['code'] && 'OK' === $response['response']['message']) { wp_send_json_success('Thanks for Subscribe!'); } else { wp_send_json_error("Couldn't Subscribe"); } } /** * Notice Header * * @author Jewel Theme */ public function notice_header() { return ''; } /** * Notice footer * * @author Jewel Theme */ public function notice_footer() { return ''; } /** * Set Title * * @author Jewel Theme */ public function set_title() { printf( '

Wanna get some discount for %1$s? No Worries!! We got you!! Enter your email, we will send you the discount code?

', esc_html__('Master Addons', 'master-addons') ); } /** * Notice Content * * @author Jewel Theme */ public function notice_content() { $userdata = \wp_get_current_user(); ?>
<?php esc_attr_e('Logo', 'master-addons'); ?>
set_title(); ?>
*/ public function plugin_rate_url() { return 'https://wordpress.org/plugins/' . JLTMA_SLUG; } /** * Footer content * * @author Jewel Theme */ public function footer_content() { ?> */ public function intervals() { return array(5, 4, 10, 20, 15, 25, 30); } /** * Core Script * * @param [type] $trigger_time . * * @return void * @author Jewel Theme */ public function core_script($trigger_time) { parent::core_script($trigger_time); ?>