-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-sms-auth-nic.php
81 lines (68 loc) · 2.88 KB
/
wp-sms-auth-nic.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/**
* Plugin Name: WP SMS Auth Nic
* Text Domain: wp-sms-auth-nic
* Description: A WordPress plugin for SMS-based OTP authentication.
* Version: 1.0
* Author: Hosein Nikmaram
*/
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly
}
// Enqueue scripts and styles
function wp_sms_auth_nic_enqueue_scripts() {
wp_enqueue_script('wp-sms-auth-script', plugin_dir_url(__FILE__) . 'public/js/script.js', array('jquery'), '1.0', true);
wp_enqueue_style('wp-sms-auth-style', plugin_dir_url(__FILE__) . 'public/css/style.css');
wp_enqueue_style('vazirmatn-font', 'https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');
wp_enqueue_script('notyf-script','https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.js');
wp_enqueue_style('notyf-style', 'https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.css');
wp_localize_script('wp-sms-auth-script', 'myAjax', array(
'ajaxurl' => admin_url('admin-ajax.php'),
'someNonce' => wp_create_nonce('my_ajax_nonce'),
));
}
add_action('wp_enqueue_scripts', 'wp_sms_auth_nic_enqueue_scripts');
// Include admin settings and other necessary files
require_once plugin_dir_path(__FILE__) . 'includes/functions.php';
require_once plugin_dir_path(__FILE__) . 'includes/form-handler.php';
require_once plugin_dir_path(__FILE__) . 'includes/admin-settings.php'; // Admin settings functionality
// Shortcodes for registration and login forms
function wp_sms_auth_registration_form_shortcode() {
ob_start();
if ( is_user_logged_in() ) {
echo '<script type="text/javascript">
window.location = "/my-account/"
</script>';
}
include plugin_dir_path(__FILE__) . 'public/register.php';
return ob_get_clean();
}
add_shortcode('wp_sms_auth_register', 'wp_sms_auth_registration_form_shortcode');
function wp_sms_auth_login_form_shortcode() {
ob_start();
if ( is_user_logged_in() ) {
echo '<script type="text/javascript">
window.location = "/my-account/"
</script>';
}
include plugin_dir_path(__FILE__) . 'public/login.php';
return ob_get_clean();
}
add_shortcode('wp_sms_auth_login', 'wp_sms_auth_login_form_shortcode');
function wp_sms_auth_both_form_shortcode() {
ob_start();
if ( is_user_logged_in() ) {
echo '<script type="text/javascript">
window.location = "/my-account/"
</script>';
}
include plugin_dir_path(__FILE__) . 'public/both.php';
return ob_get_clean();
}
add_shortcode('wp_sms_auth_both', 'wp_sms_auth_both_form_shortcode');
function wp_sms_auth_nic_add_settings_link($links) {
$settings_link = '<a href="' . admin_url('admin.php?page=wp_sms_auth_nic') . '">تنظیمات</a>';
array_push($links, $settings_link);
return $links;
}
add_filter("plugin_action_links_wp-sms-auth-nic/wp-sms-auth-nic.php", 'wp_sms_auth_nic_add_settings_link');