';
93 | });
94 | }
95 | }
96 | }
97 | }
--------------------------------------------------------------------------------
/custom-wordpress-shortcode/public/class-custom-wordpress-shortcode-public.php:
--------------------------------------------------------------------------------
1 |
22 | */
23 | class Custom_Wordpress_Shortcode_Public {
24 |
25 | /**
26 | * The ID of this plugin.
27 | *
28 | * @since 1.0.0
29 | * @access private
30 | * @var string $plugin_name The ID of this plugin.
31 | */
32 | private $plugin_name;
33 |
34 | /**
35 | * The version of this plugin.
36 | *
37 | * @since 1.0.0
38 | * @access private
39 | * @var string $version The current version of this plugin.
40 | */
41 | private $version;
42 |
43 | /**
44 | * Initialize the class and set its properties.
45 | *
46 | * @since 1.0.0
47 | * @param string $plugin_name The name of the plugin.
48 | * @param string $version The version of this plugin.
49 | */
50 | public function __construct( $plugin_name, $version ) {
51 |
52 | $this->plugin_name = $plugin_name;
53 | $this->version = $version;
54 |
55 | }
56 |
57 | /**
58 | * Register the stylesheets for the public-facing side of the site.
59 | *
60 | * @since 1.0.0
61 | */
62 | public function enqueue_styles() {
63 |
64 | /**
65 | * This function is provided for demonstration purposes only.
66 | *
67 | * An instance of this class should be passed to the run() function
68 | * defined in Custom_Wordpress_Shortcode_Loader as all of the hooks are defined
69 | * in that particular class.
70 | *
71 | * The Custom_Wordpress_Shortcode_Loader will then create the relationship
72 | * between the defined hooks and the functions defined in this
73 | * class.
74 | */
75 |
76 | wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/custom-wordpress-shortcode-public.css', array(), $this->version, 'all' );
77 |
78 | }
79 |
80 | /**
81 | * Register the JavaScript for the public-facing side of the site.
82 | *
83 | * @since 1.0.0
84 | */
85 | public function enqueue_scripts() {
86 |
87 | /**
88 | * This function is provided for demonstration purposes only.
89 | *
90 | * An instance of this class should be passed to the run() function
91 | * defined in Custom_Wordpress_Shortcode_Loader as all of the hooks are defined
92 | * in that particular class.
93 | *
94 | * The Custom_Wordpress_Shortcode_Loader will then create the relationship
95 | * between the defined hooks and the functions defined in this
96 | * class.
97 | */
98 |
99 | wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/custom-wordpress-shortcode-public.js', array( 'jquery' ), $this->version, false );
100 |
101 | }
102 |
103 | // Display Static message
104 | public function cws_display_message(){
105 |
106 | return "
This is a very basic message.
";
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/custom-wordpress-shortcode/admin/class-custom-wordpress-shortcode-admin.php:
--------------------------------------------------------------------------------
1 |
22 | */
23 | class Custom_Wordpress_Shortcode_Admin {
24 |
25 | /**
26 | * The ID of this plugin.
27 | *
28 | * @since 1.0.0
29 | * @access private
30 | * @var string $plugin_name The ID of this plugin.
31 | */
32 | private $plugin_name;
33 |
34 | /**
35 | * The version of this plugin.
36 | *
37 | * @since 1.0.0
38 | * @access private
39 | * @var string $version The current version of this plugin.
40 | */
41 | private $version;
42 |
43 | /**
44 | * Initialize the class and set its properties.
45 | *
46 | * @since 1.0.0
47 | * @param string $plugin_name The name of this plugin.
48 | * @param string $version The version of this plugin.
49 | */
50 | public function __construct( $plugin_name, $version ) {
51 |
52 | $this->plugin_name = $plugin_name;
53 | $this->version = $version;
54 |
55 | }
56 |
57 | /**
58 | * Register the stylesheets for the admin area.
59 | *
60 | * @since 1.0.0
61 | */
62 | public function enqueue_styles() {
63 |
64 | /**
65 | * This function is provided for demonstration purposes only.
66 | *
67 | * An instance of this class should be passed to the run() function
68 | * defined in Custom_Wordpress_Shortcode_Loader as all of the hooks are defined
69 | * in that particular class.
70 | *
71 | * The Custom_Wordpress_Shortcode_Loader will then create the relationship
72 | * between the defined hooks and the functions defined in this
73 | * class.
74 | */
75 |
76 | wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/custom-wordpress-shortcode-admin.css', array(), $this->version, 'all' );
77 |
78 | }
79 |
80 | /**
81 | * Register the JavaScript for the admin area.
82 | *
83 | * @since 1.0.0
84 | */
85 | public function enqueue_scripts() {
86 |
87 | /**
88 | * This function is provided for demonstration purposes only.
89 | *
90 | * An instance of this class should be passed to the run() function
91 | * defined in Custom_Wordpress_Shortcode_Loader as all of the hooks are defined
92 | * in that particular class.
93 | *
94 | * The Custom_Wordpress_Shortcode_Loader will then create the relationship
95 | * between the defined hooks and the functions defined in this
96 | * class.
97 | */
98 |
99 | wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/custom-wordpress-shortcode-admin.js', array( 'jquery' ), $this->version, false );
100 |
101 | }
102 |
103 | // Display Admin Notices
104 | public function cws_display_admin_notices(){
105 |
106 | echo '
This is our first message
';
107 | }
108 |
109 | // Register Menu
110 | public function cws_add_admin_menu_page(){
111 |
112 | add_menu_page("CWS Custom Menu", "CWS Custom Menu", "manage_options", "cws-custom-menu",[ $this, "cws_handle_menu_event" ], "", 8);
113 | }
114 |
115 | public function cws_handle_menu_event(){
116 |
117 | echo "
This is plugin menu static message.
";
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/csv-data-uploader/csv-data-uploader.php:
--------------------------------------------------------------------------------
1 | prefix;
39 | $table_name = $table_prefix . "students_data";
40 |
41 | $table_collate = $wpdb->get_charset_collate();
42 |
43 | $sql_command = "
44 | CREATE TABLE `".$table_name."` (
45 | `id` int(11) NOT NULL AUTO_INCREMENT,
46 | `name` varchar(50) DEFAULT NULL,
47 | `email` varchar(50) DEFAULT NULL,
48 | `age` int(5) DEFAULT NULL,
49 | `phone` varchar(30) DEFAULT NULL,
50 | `photo` varchar(120) DEFAULT NULL,
51 | PRIMARY KEY (`id`)
52 | ) ".$table_collate."
53 | ";
54 |
55 | require_once(ABSPATH."/wp-admin/includes/upgrade.php");
56 |
57 | dbDelta($sql_command);
58 | }
59 |
60 | // To add Script File
61 | add_action("wp_enqueue_scripts", "cdu_add_script_file");
62 |
63 | function cdu_add_script_file(){
64 |
65 | wp_enqueue_script("cdu-script-js", plugin_dir_url(__FILE__) . "assets/script.js", array("jquery"));
66 | wp_localize_script("cdu-script-js", "cdu_object", array(
67 | "ajax_url" => admin_url("admin-ajax.php")
68 | ));
69 | }
70 |
71 | // Capture Ajax REquest
72 | add_action("wp_ajax_cdu_submit_form_data", "cdu_ajax_handler"); // When user is logged in
73 | add_action("wp_ajax_nopriv_cdu_submit_form_data", "cdu_ajax_handler"); // when user is logged out
74 |
75 | function cdu_ajax_handler(){
76 |
77 | if($_FILES['csv_data_file']){
78 |
79 | $csvFile = $_FILES['csv_data_file']['tmp_name'];
80 |
81 | $handle = fopen($csvFile, "r");
82 |
83 | global $wpdb;
84 | $table_name = $wpdb->prefix."students_data";
85 |
86 | if($handle){
87 |
88 | $row = 0;
89 | while( ($data = fgetcsv($handle, 1000, ",")) !== FALSE ){
90 |
91 | if($row == 0){
92 | $row++;
93 | continue;
94 | }
95 |
96 | // Insert data into Table
97 | $wpdb->insert($table_name, array(
98 | "name" => $data[1],
99 | "email" => $data[2],
100 | "age" => $data[3],
101 | "phone" => $data[4],
102 | "photo" => $data[5]
103 | ));
104 | }
105 |
106 | fclose($handle);
107 |
108 | echo json_encode([
109 | "status" => 1,
110 | "message" => "Data uploaded successfully"
111 | ]);
112 | }
113 | }else{
114 |
115 | echo json_encode(array(
116 | "status" => 0,
117 | "message" => "No File Found"
118 | ));
119 | }
120 |
121 | exit;
122 | }
--------------------------------------------------------------------------------
/wp-login-customizer/wp-login-customizer.php:
--------------------------------------------------------------------------------
1 |
60 |
61 |
68 |
69 |
76 |
77 |
90 |
122 | ` in your templates
49 |
50 | == Frequently Asked Questions ==
51 |
52 | = A question that someone might have =
53 |
54 | An answer to that question.
55 |
56 | = What about foo bar? =
57 |
58 | Answer to foo bar dilemma.
59 |
60 | == Screenshots ==
61 |
62 | 1. This screen shot description corresponds to screenshot-1.(png|jpg|jpeg|gif). Note that the screenshot is taken from
63 | the /assets directory or the directory that contains the stable readme.txt (tags or trunk). Screenshots in the /assets
64 | directory take precedence. For example, `/assets/screenshot-1.png` would win over `/tags/4.3/screenshot-1.png`
65 | (or jpg, jpeg, gif).
66 | 2. This is the second screen shot
67 |
68 | == Changelog ==
69 |
70 | = 1.0 =
71 | * A change since the previous version.
72 | * Another change.
73 |
74 | = 0.5 =
75 | * List versions from most recent at top to oldest at bottom.
76 |
77 | == Upgrade Notice ==
78 |
79 | = 1.0 =
80 | Upgrade notices describe the reason a user should upgrade. No more than 300 characters.
81 |
82 | = 0.5 =
83 | This version fixes a security related bug. Upgrade immediately.
84 |
85 | == Arbitrary section ==
86 |
87 | You may provide arbitrary sections, in the same format as the ones above. This may be of use for extremely complicated
88 | plugins where more information needs to be conveyed that doesn't fit into the categories of "description" or
89 | "installation." Arbitrary sections will be shown below the built-in sections outlined above.
90 |
91 | == A brief Markdown Example ==
92 |
93 | Ordered list:
94 |
95 | 1. Some feature
96 | 1. Another feature
97 | 1. Something else about the plugin
98 |
99 | Unordered list:
100 |
101 | * something
102 | * something else
103 | * third thing
104 |
105 | Here's a link to [WordPress](http://wordpress.org/ "Your favorite software") and one to [Markdown's Syntax Documentation][markdown syntax].
106 | Titles are optional, naturally.
107 |
108 | [markdown syntax]: http://daringfireball.net/projects/markdown/syntax
109 | "Markdown is what the parser uses to process much of the readme file"
110 |
111 | Markdown uses email style notation for blockquotes and I've been told:
112 | > Asterisks for *emphasis*. Double it up for **strong**.
113 |
114 | ``
--------------------------------------------------------------------------------
/wp-crud-employees/template/employee_form.php:
--------------------------------------------------------------------------------
1 |
";
97 |
98 | wp_reset_postdata();
99 | }else{
100 |
101 | echo "No Post Found";
102 | }
103 | }
104 |
105 | echo $args['after_widget'];
106 | }
107 | }
--------------------------------------------------------------------------------
/custom-wordpress-shortcode/includes/class-custom-wordpress-shortcode-loader.php:
--------------------------------------------------------------------------------
1 |
23 | */
24 | class Custom_Wordpress_Shortcode_Loader {
25 |
26 | /**
27 | * The array of actions registered with WordPress.
28 | *
29 | * @since 1.0.0
30 | * @access protected
31 | * @var array $actions The actions registered with WordPress to fire when the plugin loads.
32 | */
33 | protected $actions;
34 |
35 | /**
36 | * The array of filters registered with WordPress.
37 | *
38 | * @since 1.0.0
39 | * @access protected
40 | * @var array $filters The filters registered with WordPress to fire when the plugin loads.
41 | */
42 | protected $filters;
43 |
44 | /**
45 | * Initialize the collections used to maintain the actions and filters.
46 | *
47 | * @since 1.0.0
48 | */
49 | public function __construct() {
50 |
51 | $this->actions = array();
52 | $this->filters = array();
53 |
54 | }
55 |
56 | /**
57 | * Add a new action to the collection to be registered with WordPress.
58 | *
59 | * @since 1.0.0
60 | * @param string $hook The name of the WordPress action that is being registered.
61 | * @param object $component A reference to the instance of the object on which the action is defined.
62 | * @param string $callback The name of the function definition on the $component.
63 | * @param int $priority Optional. The priority at which the function should be fired. Default is 10.
64 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
65 | */
66 | public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
67 | $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
68 | }
69 |
70 | /**
71 | * Add a new filter to the collection to be registered with WordPress.
72 | *
73 | * @since 1.0.0
74 | * @param string $hook The name of the WordPress filter that is being registered.
75 | * @param object $component A reference to the instance of the object on which the filter is defined.
76 | * @param string $callback The name of the function definition on the $component.
77 | * @param int $priority Optional. The priority at which the function should be fired. Default is 10.
78 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1
79 | */
80 | public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
81 | $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
82 | }
83 |
84 | /**
85 | * A utility function that is used to register the actions and hooks into a single
86 | * collection.
87 | *
88 | * @since 1.0.0
89 | * @access private
90 | * @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
91 | * @param string $hook The name of the WordPress filter that is being registered.
92 | * @param object $component A reference to the instance of the object on which the filter is defined.
93 | * @param string $callback The name of the function definition on the $component.
94 | * @param int $priority The priority at which the function should be fired.
95 | * @param int $accepted_args The number of arguments that should be passed to the $callback.
96 | * @return array The collection of actions and filters registered with WordPress.
97 | */
98 | private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
99 |
100 | $hooks[] = array(
101 | 'hook' => $hook,
102 | 'component' => $component,
103 | 'callback' => $callback,
104 | 'priority' => $priority,
105 | 'accepted_args' => $accepted_args
106 | );
107 |
108 | return $hooks;
109 |
110 | }
111 |
112 | /**
113 | * Register the filters and actions with WordPress.
114 | *
115 | * @since 1.0.0
116 | */
117 | public function run() {
118 |
119 | foreach ( $this->filters as $hook ) {
120 | add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
121 | }
122 |
123 | foreach ( $this->actions as $hook ) {
124 | add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
125 | }
126 |
127 | }
128 |
129 | }
130 |
--------------------------------------------------------------------------------
/wp-crud-apis/wp-crud-apis.php:
--------------------------------------------------------------------------------
1 | prefix . "students_table";
21 | $collate = $wpdb->get_charset_collate();
22 |
23 | $students_table = "
24 | CREATE TABLE `".$table_name."` (
25 | `id` int(11) NOT NULL AUTO_INCREMENT,
26 | `name` varchar(50) NOT NULL,
27 | `email` varchar(50) NOT NULL,
28 | `phone` varchar(25) DEFAULT NULL,
29 | PRIMARY KEY (`id`)
30 | ) ".$collate."
31 | ";
32 |
33 | include_once ABSPATH . "wp-admin/includes/upgrade.php";
34 |
35 | dbDelta($students_table);
36 | }
37 |
38 | // Action hook for APIs registration
39 | add_action("rest_api_init", function(){
40 |
41 | // Registration of API Routes
42 |
43 | // List Students (GET)
44 | register_rest_route("students/v1", "students", array(
45 | "methods" => "GET",
46 | "callback" => "wcp_handle_get_students_routes"
47 | ));
48 |
49 | // Add Student (POST)
50 | register_rest_route("students/v1", "student", array(
51 | "methods" => "POST",
52 | "callback" => "wcp_handle_post_student",
53 | "args" => array(
54 | "name" => array(
55 | "type" => "string",
56 | "required" => true
57 | ),
58 | "email" => array(
59 | "type" => "string",
60 | "required" => true
61 | ),
62 | "phone" => array(
63 | "type" => "string",
64 | "required" => false
65 | )
66 | )
67 | ));
68 |
69 | // Update Student (PUT)
70 | register_rest_route("students/v1", "student/(?P\d+)", array(
71 | "methods" => "PUT",
72 | "callback" => "wcp_handle_put_update_student",
73 | "args" => array(
74 | "name" => array(
75 | "type" => "string",
76 | "required" => true
77 | ),
78 | "email" => array(
79 | "type" => "string",
80 | "required" => true
81 | ),
82 | "phone" => array(
83 | "type" => "string",
84 | "required" => false
85 | )
86 | )
87 | ));
88 |
89 | // Delete Student (DELETE)
90 | register_rest_route("students/v1", "student/(?P\d+)", array(
91 | "methods" => "DELETE",
92 | "callback" => "wcp_handle_delete_student"
93 | ));
94 | });
95 |
96 | // List all Students
97 | function wcp_handle_get_students_routes(){
98 |
99 | global $wpdb;
100 | $table_name = $wpdb->prefix . "students_table";
101 |
102 | $students = $wpdb->get_results(
103 | "SELECT * FROM {$table_name}", ARRAY_A
104 | );
105 |
106 | return rest_ensure_response([
107 | "status" => true,
108 | "message" => "Students List",
109 | "data" => $students
110 | ]);
111 | }
112 |
113 | // Add Student
114 | function wcp_handle_post_student($request){
115 |
116 | global $wpdb;
117 | $table_name = $wpdb->prefix . "students_table";
118 |
119 | $name = $request->get_param("name");
120 | $email = $request->get_param("email");
121 | $phone = $request->get_param("phone");
122 |
123 | $wpdb->insert($table_name, array(
124 | "name"=> $name,
125 | "email" => $email,
126 | "phone" => $phone
127 | ));
128 |
129 | if($wpdb->insert_id > 0){
130 |
131 | return rest_ensure_response([
132 | "status" => true,
133 | "message" => "student Created Successfully",
134 | "data" => $request->get_params()
135 | ]);
136 | }else{
137 |
138 | return rest_ensure_response([
139 | "status" => false,
140 | "message" => "Failed to create student",
141 | "data" => $request->get_params()
142 | ]);
143 | }
144 | }
145 |
146 | // Update Student
147 | function wcp_handle_put_update_student($request){
148 |
149 | global $wpdb;
150 | $table_name = $wpdb->prefix . "students_table";
151 |
152 | $id = $request['id'];
153 |
154 | $student = $wpdb->get_row(
155 | "SELECT * FROM {$table_name} WHERE id = {$id}"
156 | );
157 |
158 | if(!empty($student)){
159 |
160 | $wpdb->update($table_name, [
161 | "name" => $request->get_param("name"),
162 | "email" => $request->get_param("email")
163 | ], [
164 | "id" => $id
165 | ]);
166 |
167 | return rest_ensure_response([
168 | "status" => true,
169 | "message" => "Student data updated successfully"
170 | ]);
171 | }else{
172 |
173 | return rest_ensure_response([
174 | "status" => false,
175 | "message" => "Student doesn't exists"
176 | ]);
177 | }
178 | }
179 |
180 | // Delete Student
181 | function wcp_handle_delete_student($request){
182 |
183 | global $wpdb;
184 | $table_name = $wpdb->prefix . "students_table";
185 |
186 | $id = $request['id'];
187 |
188 | $student = $wpdb->get_row( "SELECT * FROM {$table_name} WHERE id = {$id}" );
189 |
190 | if(!empty($student)){
191 |
192 | $wpdb->delete($table_name, [
193 | "id" => $id
194 | ]);
195 |
196 | return rest_ensure_response([
197 | "status" => true,
198 | "message" => "Student deleted successfully"
199 | ]);
200 | }else{
201 |
202 | return rest_ensure_response([
203 | "status" => false,
204 | "message" => "Student doesn't exists"
205 | ]);
206 | }
207 | }
--------------------------------------------------------------------------------
/wp-crud-employees/assets/script.js:
--------------------------------------------------------------------------------
1 | jQuery(document).ready(function(){
2 |
3 | console.log("Welcome to CRUD Plugin of Employees");
4 |
5 | // Add Form Validation
6 | jQuery("#frm_add_employee").validate();
7 |
8 | // form Submit
9 | jQuery("#frm_add_employee").on("submit", function(event){
10 |
11 | event.preventDefault();
12 |
13 | var formdata = new FormData(this);
14 |
15 | jQuery.ajax({
16 | url: wce_object.ajax_url,
17 | data: formdata,
18 | method: "POST",
19 | dataType: "json",
20 | contentType: false,
21 | processData: false,
22 | success: function(response){
23 | if(response.status){
24 | alert(response.message);
25 | setTimeout(function(){
26 | location.reload();
27 | }, 1500);
28 | }
29 | }
30 | })
31 | });
32 |
33 | // Render Employees
34 | loadEmployeeData();
35 |
36 | // Delete Function
37 | jQuery(document).on("click", ".btn_delete_employee", function(){
38 |
39 | var employeeId = jQuery(this).data("id");
40 |
41 | if(confirm("Are you sure want to delete")){ // true
42 | jQuery.ajax({
43 | url: wce_object.ajax_url,
44 | data: {
45 | action: "wce_delete_employee",
46 | empId: employeeId
47 | },
48 | method: "GET",
49 | dataType: "json",
50 | success: function(response){
51 | if(response){
52 | alert(response.message);
53 | setTimeout(function(){
54 | location.reload();
55 | }, 1500);
56 | }
57 | }
58 | })
59 | }
60 | // false
61 | });
62 |
63 | // Open Add Employee Form
64 | jQuery(document).on("click", "#btn_open_add_employee_form", function(){
65 | jQuery(".add_employee_form").toggleClass("hide_element");
66 | jQuery(this).addClass("hide_element");
67 | });
68 |
69 | // Close Add Employee Form
70 | jQuery(document).on("click", "#btn_close_add_employee_form", function(){
71 | jQuery(".add_employee_form").toggleClass("hide_element");
72 | jQuery("#btn_open_add_employee_form").removeClass("hide_element");
73 | });
74 |
75 | // Open Edit Layout
76 | jQuery(document).on("click", ".btn_edit_employee", function(){
77 | jQuery(".edit_employee_form").removeClass("hide_element");
78 | jQuery("#btn_open_add_employee_form").addClass("hide_element");
79 | // Get Existing data of an Employee by Employee ID
80 | var employeeId = jQuery(this).data("id"); // jQuery(this).attr("data-id");
81 | jQuery.ajax({
82 | url: wce_object.ajax_url,
83 | data: {
84 | action: "wce_get_employee_data",
85 | empId: employeeId
86 | },
87 | method: "GET",
88 | dataType: "json",
89 | success: function(response){
90 | jQuery("#employee_name").val(response?.data?.name);
91 | jQuery("#employee_email").val(response?.data?.email);
92 | jQuery("#employee_designation").val(response?.data?.designation);
93 | jQuery("#employee_id").val(response?.data?.id);
94 | jQuery("#employee_profile_icon").attr("src", response?.data?.profile_image);
95 | }
96 | })
97 | });
98 |
99 | // Close Edit Layout
100 | jQuery(document).on("click", "#btn_close_edit_employee_form", function(){
101 | jQuery(".edit_employee_form").toggleClass("hide_element");
102 | jQuery("#btn_open_add_employee_form").removeClass("hide_element");
103 | });
104 |
105 | // Submit Edit Form
106 | jQuery(document).on("submit", "#frm_edit_employee", function(event){
107 | event.preventDefault();
108 | var formdata = new FormData(this);
109 | jQuery.ajax({
110 | url: wce_object.ajax_url,
111 | data: formdata,
112 | method: "POST",
113 | contentType: false,
114 | processData: false,
115 | dataType: "json",
116 | success: function(response){
117 | if(response){
118 | alert(response?.message);
119 | setTimeout(function(){
120 | location.reload();
121 | }, 1500);
122 | }
123 | }
124 | })
125 | });
126 | });
127 |
128 | // Load All Employees From DB Table
129 | function loadEmployeeData(){
130 | jQuery.ajax({
131 | url: wce_object.ajax_url,
132 | data: {
133 | action: "wce_load_employees_data"
134 | },
135 | method: "GET",
136 | dataType: "json",
137 | success: function(response){
138 | var employeesDataHTML = "";
139 | jQuery.each(response.employees, function(index, employee){
140 |
141 | let employeeProfileImage = "--";
142 |
143 | if(employee.profile_image){
144 | employeeProfileImage = ``;
145 | }
146 |
147 | employeesDataHTML += `
148 |
149 |
${employee.id}
150 |
${employee.name}
151 |
${employee.email}
152 |
${employee.designation}
153 |
${employeeProfileImage}
154 |
155 |
156 |
157 |
158 |
159 | `;
160 | });
161 |
162 | // Bind data with Table
163 | jQuery("#employees_data_tbody").html(employeesDataHTML);
164 | }
165 | })
166 | }
--------------------------------------------------------------------------------
/custom-wordpress-shortcode/includes/class-custom-wordpress-shortcode.php:
--------------------------------------------------------------------------------
1 |
29 | */
30 | class Custom_Wordpress_Shortcode {
31 |
32 | /**
33 | * The loader that's responsible for maintaining and registering all hooks that power
34 | * the plugin.
35 | *
36 | * @since 1.0.0
37 | * @access protected
38 | * @var Custom_Wordpress_Shortcode_Loader $loader Maintains and registers all hooks for the plugin.
39 | */
40 | protected $loader;
41 |
42 | /**
43 | * The unique identifier of this plugin.
44 | *
45 | * @since 1.0.0
46 | * @access protected
47 | * @var string $plugin_name The string used to uniquely identify this plugin.
48 | */
49 | protected $plugin_name;
50 |
51 | /**
52 | * The current version of the plugin.
53 | *
54 | * @since 1.0.0
55 | * @access protected
56 | * @var string $version The current version of the plugin.
57 | */
58 | protected $version;
59 |
60 | /**
61 | * Define the core functionality of the plugin.
62 | *
63 | * Set the plugin name and the plugin version that can be used throughout the plugin.
64 | * Load the dependencies, define the locale, and set the hooks for the admin area and
65 | * the public-facing side of the site.
66 | *
67 | * @since 1.0.0
68 | */
69 | public function __construct() {
70 | if ( defined( 'CUSTOM_WORDPRESS_SHORTCODE_VERSION' ) ) {
71 | $this->version = CUSTOM_WORDPRESS_SHORTCODE_VERSION;
72 | } else {
73 | $this->version = '1.0.0';
74 | }
75 | $this->plugin_name = 'custom-wordpress-shortcode';
76 |
77 | $this->load_dependencies();
78 | $this->set_locale();
79 | $this->define_admin_hooks();
80 | $this->define_public_hooks();
81 |
82 | }
83 |
84 | /**
85 | * Load the required dependencies for this plugin.
86 | *
87 | * Include the following files that make up the plugin:
88 | *
89 | * - Custom_Wordpress_Shortcode_Loader. Orchestrates the hooks of the plugin.
90 | * - Custom_Wordpress_Shortcode_i18n. Defines internationalization functionality.
91 | * - Custom_Wordpress_Shortcode_Admin. Defines all hooks for the admin area.
92 | * - Custom_Wordpress_Shortcode_Public. Defines all hooks for the public side of the site.
93 | *
94 | * Create an instance of the loader which will be used to register the hooks
95 | * with WordPress.
96 | *
97 | * @since 1.0.0
98 | * @access private
99 | */
100 | private function load_dependencies() {
101 |
102 | /**
103 | * The class responsible for orchestrating the actions and filters of the
104 | * core plugin.
105 | */
106 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-custom-wordpress-shortcode-loader.php';
107 |
108 | /**
109 | * The class responsible for defining internationalization functionality
110 | * of the plugin.
111 | */
112 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-custom-wordpress-shortcode-i18n.php';
113 |
114 | /**
115 | * The class responsible for defining all actions that occur in the admin area.
116 | */
117 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-custom-wordpress-shortcode-admin.php';
118 |
119 | /**
120 | * The class responsible for defining all actions that occur in the public-facing
121 | * side of the site.
122 | */
123 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-custom-wordpress-shortcode-public.php';
124 |
125 | $this->loader = new Custom_Wordpress_Shortcode_Loader();
126 |
127 | }
128 |
129 | /**
130 | * Define the locale for this plugin for internationalization.
131 | *
132 | * Uses the Custom_Wordpress_Shortcode_i18n class in order to set the domain and to register the hook
133 | * with WordPress.
134 | *
135 | * @since 1.0.0
136 | * @access private
137 | */
138 | private function set_locale() {
139 |
140 | $plugin_i18n = new Custom_Wordpress_Shortcode_i18n();
141 |
142 | $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
143 |
144 | }
145 |
146 | /**
147 | * Register all of the hooks related to the admin area functionality
148 | * of the plugin.
149 | *
150 | * @since 1.0.0
151 | * @access private
152 | */
153 | private function define_admin_hooks() {
154 |
155 | $plugin_admin = new Custom_Wordpress_Shortcode_Admin( $this->get_plugin_name(), $this->get_version() );
156 |
157 | $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
158 | $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
159 |
160 | // Admin Notice
161 | $this->loader->add_action("admin_notices", $plugin_admin, "cws_display_admin_notices");
162 |
163 | $this->loader->add_action("admin_menu", $plugin_admin, "cws_add_admin_menu_page");
164 | }
165 |
166 | /**
167 | * Register all of the hooks related to the public-facing functionality
168 | * of the plugin.
169 | *
170 | * @since 1.0.0
171 | * @access private
172 | */
173 | private function define_public_hooks() {
174 |
175 | $plugin_public = new Custom_Wordpress_Shortcode_Public( $this->get_plugin_name(), $this->get_version() );
176 |
177 | $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
178 | $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
179 |
180 | // Add Shortcode
181 | add_shortcode("cws-display-message", [$plugin_public, "cws_display_message"]);
182 | }
183 |
184 | /**
185 | * Run the loader to execute all of the hooks with WordPress.
186 | *
187 | * @since 1.0.0
188 | */
189 | public function run() {
190 | $this->loader->run();
191 | }
192 |
193 | /**
194 | * The name of the plugin used to uniquely identify it within the context of
195 | * WordPress and to define internationalization functionality.
196 | *
197 | * @since 1.0.0
198 | * @return string The name of the plugin.
199 | */
200 | public function get_plugin_name() {
201 | return $this->plugin_name;
202 | }
203 |
204 | /**
205 | * The reference to the class that orchestrates the hooks with the plugin.
206 | *
207 | * @since 1.0.0
208 | * @return Custom_Wordpress_Shortcode_Loader Orchestrates the hooks of the plugin.
209 | */
210 | public function get_loader() {
211 | return $this->loader;
212 | }
213 |
214 | /**
215 | * Retrieve the version number of the plugin.
216 | *
217 | * @since 1.0.0
218 | * @return string The version number of the plugin.
219 | */
220 | public function get_version() {
221 | return $this->version;
222 | }
223 |
224 | }
225 |
--------------------------------------------------------------------------------
/wp-crud-employees/MyEmployees.php:
--------------------------------------------------------------------------------
1 | wpdb = $wpdb;
13 | $this->table_prefix = $this->wpdb->prefix; // wp_
14 | $this->table_name = $this->table_prefix . "employees_table"; // wp_employees_table
15 | }
16 |
17 | // Create DB Table + WordPress Page
18 | public function callPluginActivationFunctions(){
19 |
20 | $collate = $this->wpdb->get_charset_collate();
21 |
22 | $createCommand = "
23 | CREATE TABLE `".$this->table_name."` (
24 | `id` int(11) NOT NULL AUTO_INCREMENT,
25 | `name` varchar(50) NOT NULL,
26 | `email` varchar(50) DEFAULT NULL,
27 | `designation` varchar(50) DEFAULT NULL,
28 | `profile_image` varchar(220) DEFAULT NULL,
29 | PRIMARY KEY (`id`)
30 | ) ".$collate."
31 | ";
32 |
33 | require_once (ABSPATH. "/wp-admin/includes/upgrade.php");
34 |
35 | dbDelta($createCommand);
36 |
37 | // Wp Page
38 | $page_title = "Employee CRUD System";
39 | $page_content = "[wp-employee-form]";
40 |
41 | if(!get_page_by_title($page_title)){
42 | wp_insert_post(array(
43 | "post_title" => $page_title,
44 | "post_content" => $page_content,
45 | "post_type" => "page",
46 | "post_status" => "publish"
47 | ));
48 | }
49 | }
50 |
51 | // Drop Table
52 | public function dropEmployeesTable(){
53 |
54 | $delete_command = "DROP TABLE IF EXISTS {$this->table_name}";
55 |
56 | $this->wpdb->query($delete_command);
57 | }
58 |
59 | // Render Employee Form Layout
60 | public function createEmployeesForm(){
61 |
62 | ob_start();
63 |
64 | include_once WCE_DIR_PATH . "template/employee_form.php";
65 |
66 | $template = ob_get_contents();
67 |
68 | ob_end_clean();
69 |
70 | return $template;
71 | }
72 |
73 | // Add CSS / JS
74 | public function addAssetsToPlugin(){
75 |
76 | // Style
77 | wp_enqueue_style("employee-crud-css", WCE_DIR_URL . "assets/style.css");
78 |
79 | // Validation
80 | wp_enqueue_script("wce-validation", WCE_DIR_URL . "assets/jquery.validate.min.js", array("jquery"));
81 |
82 | // JS
83 | wp_enqueue_script("employee-crud-js", WCE_DIR_URL . "assets/script.js", array("jquery"), "3.0");
84 |
85 | wp_localize_script("employee-crud-js", "wce_object", array(
86 | "ajax_url" => admin_url("admin-ajax.php")
87 | ));
88 | }
89 |
90 | // Process Ajax Request: Add Employee Form
91 | public function handleAddEmployeeFormData(){
92 |
93 | $name = sanitize_text_field($_POST['name']);
94 | $email = sanitize_text_field($_POST['email']);
95 | $designation = sanitize_text_field($_POST['designation']);
96 |
97 | $profile_url = "";
98 |
99 | /**
100 | *
101 | * array("test_form" => false) -> wp_handle_upload is not going to check any file attributes or even file submission
102 | *
103 | * array("test_form" => true) -> wp_handle_upload will validate form request, nonce value and other form parameters
104 | */
105 |
106 | // Check for File
107 | if(isset($_FILES['profile_image']['name'])){
108 |
109 | $UploadFile = $_FILES['profile_image'];
110 |
111 | // $UploadFile['name'] - employee-1.webp
112 |
113 | // Original File Name
114 | $originalFileName = pathinfo($UploadFile['name'], PATHINFO_FILENAME); // employee-1
115 |
116 | // File Extension
117 | $file_extension = pathinfo($UploadFile['name'], PATHINFO_EXTENSION); // webp
118 |
119 | // New Image Name
120 | $newImageName = $originalFileName."_".time().".".$file_extension; // employee-1_89465133.webp
121 |
122 | $_FILES['profile_image']['name'] = $newImageName;
123 |
124 | $fileUploaded = wp_handle_upload($_FILES['profile_image'], array("test_form" => false));
125 |
126 | $profile_url = $fileUploaded['url'];
127 | }
128 |
129 | $this->wpdb->insert($this->table_name, [
130 | "name" => $name,
131 | "email" => $email,
132 | "designation" => $designation,
133 | "profile_image" => $profile_url
134 | ]);
135 |
136 | $employee_id = $this->wpdb->insert_id;
137 |
138 | if($employee_id > 0){
139 |
140 | echo json_encode([
141 | "status" => 1,
142 | "message" => "Successfully, Employee created"
143 | ]);
144 | }else{
145 |
146 | echo json_encode([
147 | "status" => 0,
148 | "message" => "Failed to save employee"
149 | ]);
150 | }
151 |
152 | die;
153 | }
154 |
155 | /** Load DB Table Employees */
156 | public function handleLoadEmployeesData(){
157 |
158 | $employees = $this->wpdb->get_results(
159 | "SELECT * FROM {$this->table_name}",
160 | ARRAY_A
161 | );
162 |
163 | return wp_send_json([
164 | "status" => true,
165 | "message" => "Employees Data",
166 | "employees" => $employees
167 | ]);
168 | }
169 |
170 | // Delete Employee Data
171 | public function handleDeleteEmployeeData(){
172 |
173 | $employee_id = $_GET['empId'];
174 |
175 | $this->wpdb->delete($this->table_name, [
176 | "id" => $employee_id
177 | ]);
178 |
179 | return wp_send_json([
180 | "status" => true,
181 | "message" => "Employee Deleted Successfully"
182 | ]);
183 | }
184 |
185 | // Read Single Employee Data
186 | public function handleToGetSingleEmployeeData(){
187 |
188 | $employee_id = $_GET['empId'];
189 |
190 | if($employee_id > 0){
191 |
192 | $employeeData = $this->wpdb->get_row(
193 | "SELECT * FROM {$this->table_name} WHERE id = {$employee_id}", ARRAY_A
194 | );
195 |
196 | return wp_send_json([
197 | "status" => true,
198 | "message" => "Employee Data Found",
199 | "data" => $employeeData
200 | ]);
201 | }else{
202 |
203 | return wp_send_json([
204 | "status" => false,
205 | "message" => "Please pass employee ID"
206 | ]);
207 | }
208 | }
209 |
210 | // Update Employee Data
211 | public function handleUpdateEmployeeData(){
212 | $name = sanitize_text_field($_POST['employee_name']);
213 | $email = sanitize_text_field($_POST['employee_email']);
214 | $designation = sanitize_text_field($_POST['employee_designation']);
215 | $id = sanitize_text_field($_POST['employee_id']);
216 |
217 | $employeeData = $this->getEmployeeData($id);
218 |
219 | $profile_image_url = "";
220 |
221 | if(!empty($employeeData)){
222 |
223 | // Existing Profile Image
224 | $profile_image_url = $employeeData['profile_image'];
225 |
226 | // New File Image Object
227 | $profile_file_image = isset($_FILES['employee_profile_image']['name']) ? $_FILES['employee_profile_image']['name'] : "";
228 |
229 | // Check Image Exists
230 | if(!empty($profile_file_image)){
231 |
232 | if(!empty($profile_image_url)){
233 |
234 | // http://localhost/wp/wp_plugin_course/wp-content/uploads/2024/08/employee-1.webp
235 | $wp_site_url = get_site_url(); // http://localhost/wp/wp_plugin_course
236 | $file_path = str_replace($wp_site_url."/", "", $profile_image_url); // wp-content/uploads/2024/08/employee-1.webp
237 |
238 | if(file_exists(ABSPATH . $file_path)){
239 | // Remove that file from uploads folder
240 | unlink(ABSPATH . $file_path);
241 | }
242 | }
243 |
244 | $UploadFile = $_FILES['employee_profile_image'];
245 |
246 | // $UploadFile['name'] - employee-1.webp
247 |
248 | // Original File Name
249 | $originalFileName = pathinfo($UploadFile['name'], PATHINFO_FILENAME); // employee-1
250 |
251 | // File Extension
252 | $file_extension = pathinfo($UploadFile['name'], PATHINFO_EXTENSION); // webp
253 |
254 | // New Image Name
255 | $newImageName = $originalFileName."_".time().".".$file_extension; // employee-1_89465133.webp
256 |
257 | $_FILES['employee_profile_image']['name'] = $newImageName;
258 |
259 | $fileUploaded = wp_handle_upload($_FILES['employee_profile_image'], array("test_form" => false));
260 |
261 | $profile_image_url = $fileUploaded['url'];
262 | }
263 |
264 | $this->wpdb->update($this->table_name, [
265 | "name" => $name,
266 | "email" => $email,
267 | "designation" => $designation,
268 | "profile_image" => $profile_image_url
269 | ], [
270 | "id" => $id
271 | ]);
272 |
273 | return wp_send_json([
274 | "status" => true,
275 | "message" => "Employee Updated successfully"
276 | ]);
277 | }else{
278 |
279 | return wp_send_json([
280 | "status" => false,
281 | "message" => "No Employee found with this ID"
282 | ]);
283 | }
284 | }
285 |
286 | // Get employee Data
287 | private function getEmployeeData($employee_id){
288 |
289 | $employeeData = $this->wpdb->get_row(
290 | "SELECT * FROM {$this->table_name} WHERE id = {$employee_id}", ARRAY_A
291 | );
292 |
293 | return $employeeData;
294 | }
295 | }
--------------------------------------------------------------------------------
/custom-wordpress-shortcode/LICENSE.txt:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 |
294 | Copyright (C)
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | , 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
--------------------------------------------------------------------------------
/wp-crud-employees/assets/jquery.validate.min.js:
--------------------------------------------------------------------------------
1 | /*! jQuery Validation Plugin - v1.19.5 - 7/1/2022
2 | * https://jqueryvalidation.org/
3 | * Copyright (c) 2022 Jörn Zaefferer; Licensed MIT */
4 | !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){a.extend(a.fn,{validate:function(b){if(!this.length)return void(b&&b.debug&&window.console&&console.warn("Nothing selected, can't validate, returning nothing."));var c=a.data(this[0],"validator");return c?c:(this.attr("novalidate","novalidate"),c=new a.validator(b,this[0]),a.data(this[0],"validator",c),c.settings.onsubmit&&(this.on("click.validate",":submit",function(b){c.submitButton=b.currentTarget,a(this).hasClass("cancel")&&(c.cancelSubmit=!0),void 0!==a(this).attr("formnovalidate")&&(c.cancelSubmit=!0)}),this.on("submit.validate",function(b){function d(){var d,e;return c.submitButton&&(c.settings.submitHandler||c.formSubmitted)&&(d=a("").attr("name",c.submitButton.name).val(a(c.submitButton).val()).appendTo(c.currentForm)),!(c.settings.submitHandler&&!c.settings.debug)||(e=c.settings.submitHandler.call(c,c.currentForm,b),d&&d.remove(),void 0!==e&&e)}return c.settings.debug&&b.preventDefault(),c.cancelSubmit?(c.cancelSubmit=!1,d()):c.form()?c.pendingRequest?(c.formSubmitted=!0,!1):d():(c.focusInvalid(),!1)})),c)},valid:function(){var b,c,d;return a(this[0]).is("form")?b=this.validate().form():(d=[],b=!0,c=a(this[0].form).validate(),this.each(function(){b=c.element(this)&&b,b||(d=d.concat(c.errorList))}),c.errorList=d),b},rules:function(b,c){var d,e,f,g,h,i,j=this[0],k="undefined"!=typeof this.attr("contenteditable")&&"false"!==this.attr("contenteditable");if(null!=j&&(!j.form&&k&&(j.form=this.closest("form")[0],j.name=this.attr("name")),null!=j.form)){if(b)switch(d=a.data(j.form,"validator").settings,e=d.rules,f=a.validator.staticRules(j),b){case"add":a.extend(f,a.validator.normalizeRule(c)),delete f.messages,e[j.name]=f,c.messages&&(d.messages[j.name]=a.extend(d.messages[j.name],c.messages));break;case"remove":return c?(i={},a.each(c.split(/\s/),function(a,b){i[b]=f[b],delete f[b]}),i):(delete e[j.name],f)}return g=a.validator.normalizeRules(a.extend({},a.validator.classRules(j),a.validator.attributeRules(j),a.validator.dataRules(j),a.validator.staticRules(j)),j),g.required&&(h=g.required,delete g.required,g=a.extend({required:h},g)),g.remote&&(h=g.remote,delete g.remote,g=a.extend(g,{remote:h})),g}}});var b=function(a){return a.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};a.extend(a.expr.pseudos||a.expr[":"],{blank:function(c){return!b(""+a(c).val())},filled:function(c){var d=a(c).val();return null!==d&&!!b(""+d)},unchecked:function(b){return!a(b).prop("checked")}}),a.validator=function(b,c){this.settings=a.extend(!0,{},a.validator.defaults,b),this.currentForm=c,this.init()},a.validator.format=function(b,c){return 1===arguments.length?function(){var c=a.makeArray(arguments);return c.unshift(b),a.validator.format.apply(this,c)}:void 0===c?b:(arguments.length>2&&c.constructor!==Array&&(c=a.makeArray(arguments).slice(1)),c.constructor!==Array&&(c=[c]),a.each(c,function(a,c){b=b.replace(new RegExp("\\{"+a+"\\}","g"),function(){return c})}),b)},a.extend(a.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",pendingClass:"pending",validClass:"valid",errorElement:"label",focusCleanup:!1,focusInvalid:!0,errorContainer:a([]),errorLabelContainer:a([]),onsubmit:!0,ignore:":hidden",ignoreTitle:!1,onfocusin:function(a){this.lastActive=a,this.settings.focusCleanup&&(this.settings.unhighlight&&this.settings.unhighlight.call(this,a,this.settings.errorClass,this.settings.validClass),this.hideThese(this.errorsFor(a)))},onfocusout:function(a){this.checkable(a)||!(a.name in this.submitted)&&this.optional(a)||this.element(a)},onkeyup:function(b,c){var d=[16,17,18,20,35,36,37,38,39,40,45,144,225];9===c.which&&""===this.elementValue(b)||a.inArray(c.keyCode,d)!==-1||(b.name in this.submitted||b.name in this.invalid)&&this.element(b)},onclick:function(a){a.name in this.submitted?this.element(a):a.parentNode.name in this.submitted&&this.element(a.parentNode)},highlight:function(b,c,d){"radio"===b.type?this.findByName(b.name).addClass(c).removeClass(d):a(b).addClass(c).removeClass(d)},unhighlight:function(b,c,d){"radio"===b.type?this.findByName(b.name).removeClass(c).addClass(d):a(b).removeClass(c).addClass(d)}},setDefaults:function(b){a.extend(a.validator.defaults,b)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",equalTo:"Please enter the same value again.",maxlength:a.validator.format("Please enter no more than {0} characters."),minlength:a.validator.format("Please enter at least {0} characters."),rangelength:a.validator.format("Please enter a value between {0} and {1} characters long."),range:a.validator.format("Please enter a value between {0} and {1}."),max:a.validator.format("Please enter a value less than or equal to {0}."),min:a.validator.format("Please enter a value greater than or equal to {0}."),step:a.validator.format("Please enter a multiple of {0}.")},autoCreateRanges:!1,prototype:{init:function(){function b(b){var c="undefined"!=typeof a(this).attr("contenteditable")&&"false"!==a(this).attr("contenteditable");if(!this.form&&c&&(this.form=a(this).closest("form")[0],this.name=a(this).attr("name")),d===this.form){var e=a.data(this.form,"validator"),f="on"+b.type.replace(/^validate/,""),g=e.settings;g[f]&&!a(this).is(g.ignore)&&g[f].call(e,this,b)}}this.labelContainer=a(this.settings.errorLabelContainer),this.errorContext=this.labelContainer.length&&this.labelContainer||a(this.currentForm),this.containers=a(this.settings.errorContainer).add(this.settings.errorLabelContainer),this.submitted={},this.valueCache={},this.pendingRequest=0,this.pending={},this.invalid={},this.reset();var c,d=this.currentForm,e=this.groups={};a.each(this.settings.groups,function(b,c){"string"==typeof c&&(c=c.split(/\s/)),a.each(c,function(a,c){e[c]=b})}),c=this.settings.rules,a.each(c,function(b,d){c[b]=a.validator.normalizeRule(d)}),a(this.currentForm).on("focusin.validate focusout.validate keyup.validate",":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'], [type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], [type='radio'], [type='checkbox'], [contenteditable], [type='button']",b).on("click.validate","select, option, [type='radio'], [type='checkbox']",b),this.settings.invalidHandler&&a(this.currentForm).on("invalid-form.validate",this.settings.invalidHandler)},form:function(){return this.checkForm(),a.extend(this.submitted,this.errorMap),this.invalid=a.extend({},this.errorMap),this.valid()||a(this.currentForm).triggerHandler("invalid-form",[this]),this.showErrors(),this.valid()},checkForm:function(){this.prepareForm();for(var a=0,b=this.currentElements=this.elements();b[a];a++)this.check(b[a]);return this.valid()},element:function(b){var c,d,e=this.clean(b),f=this.validationTargetFor(e),g=this,h=!0;return void 0===f?delete this.invalid[e.name]:(this.prepareElement(f),this.currentElements=a(f),d=this.groups[f.name],d&&a.each(this.groups,function(a,b){b===d&&a!==f.name&&(e=g.validationTargetFor(g.clean(g.findByName(a))),e&&e.name in g.invalid&&(g.currentElements.push(e),h=g.check(e)&&h))}),c=this.check(f)!==!1,h=h&&c,c?this.invalid[f.name]=!1:this.invalid[f.name]=!0,this.numberOfInvalids()||(this.toHide=this.toHide.add(this.containers)),this.showErrors(),a(b).attr("aria-invalid",!c)),h},showErrors:function(b){if(b){var c=this;a.extend(this.errorMap,b),this.errorList=a.map(this.errorMap,function(a,b){return{message:a,element:c.findByName(b)[0]}}),this.successList=a.grep(this.successList,function(a){return!(a.name in b)})}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){a.fn.resetForm&&a(this.currentForm).resetForm(),this.invalid={},this.submitted={},this.prepareForm(),this.hideErrors();var b=this.elements().removeData("previousValue").removeAttr("aria-invalid");this.resetElements(b)},resetElements:function(a){var b;if(this.settings.unhighlight)for(b=0;a[b];b++)this.settings.unhighlight.call(this,a[b],this.settings.errorClass,""),this.findByName(a[b].name).removeClass(this.settings.validClass);else a.removeClass(this.settings.errorClass).removeClass(this.settings.validClass)},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(a){var b,c=0;for(b in a)void 0!==a[b]&&null!==a[b]&&a[b]!==!1&&c++;return c},hideErrors:function(){this.hideThese(this.toHide)},hideThese:function(a){a.not(this.containers).text(""),this.addWrapper(a).hide()},valid:function(){return 0===this.size()},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{a(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").trigger("focus").trigger("focusin")}catch(b){}},findLastActive:function(){var b=this.lastActive;return b&&1===a.grep(this.errorList,function(a){return a.element.name===b.name}).length&&b},elements:function(){var b=this,c={};return a(this.currentForm).find("input, select, textarea, [contenteditable]").not(":submit, :reset, :image, :disabled").not(this.settings.ignore).filter(function(){var d=this.name||a(this).attr("name"),e="undefined"!=typeof a(this).attr("contenteditable")&&"false"!==a(this).attr("contenteditable");return!d&&b.settings.debug&&window.console&&console.error("%o has no name assigned",this),e&&(this.form=a(this).closest("form")[0],this.name=d),this.form===b.currentForm&&(!(d in c||!b.objectLength(a(this).rules()))&&(c[d]=!0,!0))})},clean:function(b){return a(b)[0]},errors:function(){var b=this.settings.errorClass.split(" ").join(".");return a(this.settings.errorElement+"."+b,this.errorContext)},resetInternals:function(){this.successList=[],this.errorList=[],this.errorMap={},this.toShow=a([]),this.toHide=a([])},reset:function(){this.resetInternals(),this.currentElements=a([])},prepareForm:function(){this.reset(),this.toHide=this.errors().add(this.containers)},prepareElement:function(a){this.reset(),this.toHide=this.errorsFor(a)},elementValue:function(b){var c,d,e=a(b),f=b.type,g="undefined"!=typeof e.attr("contenteditable")&&"false"!==e.attr("contenteditable");return"radio"===f||"checkbox"===f?this.findByName(b.name).filter(":checked").val():"number"===f&&"undefined"!=typeof b.validity?b.validity.badInput?"NaN":e.val():(c=g?e.text():e.val(),"file"===f?"C:\\fakepath\\"===c.substr(0,12)?c.substr(12):(d=c.lastIndexOf("/"),d>=0?c.substr(d+1):(d=c.lastIndexOf("\\"),d>=0?c.substr(d+1):c)):"string"==typeof c?c.replace(/\r/g,""):c)},check:function(b){b=this.validationTargetFor(this.clean(b));var c,d,e,f,g=a(b).rules(),h=a.map(g,function(a,b){return b}).length,i=!1,j=this.elementValue(b);"function"==typeof g.normalizer?f=g.normalizer:"function"==typeof this.settings.normalizer&&(f=this.settings.normalizer),f&&(j=f.call(b,j),delete g.normalizer);for(d in g){e={method:d,parameters:g[d]};try{if(c=a.validator.methods[d].call(this,j,b,e.parameters),"dependency-mismatch"===c&&1===h){i=!0;continue}if(i=!1,"pending"===c)return void(this.toHide=this.toHide.not(this.errorsFor(b)));if(!c)return this.formatAndAdd(b,e),!1}catch(k){throw this.settings.debug&&window.console&&console.log("Exception occurred when checking element "+b.id+", check the '"+e.method+"' method.",k),k instanceof TypeError&&(k.message+=". Exception occurred when checking element "+b.id+", check the '"+e.method+"' method."),k}}if(!i)return this.objectLength(g)&&this.successList.push(b),!0},customDataMessage:function(b,c){return a(b).data("msg"+c.charAt(0).toUpperCase()+c.substring(1).toLowerCase())||a(b).data("msg")},customMessage:function(a,b){var c=this.settings.messages[a];return c&&(c.constructor===String?c:c[b])},findDefined:function(){for(var a=0;aWarning: No message defined for "+b.name+""),e=/\$?\{(\d+)\}/g;return"function"==typeof d?d=d.call(this,c.parameters,b):e.test(d)&&(d=a.validator.format(d.replace(e,"{$1}"),c.parameters)),d},formatAndAdd:function(a,b){var c=this.defaultMessage(a,b);this.errorList.push({message:c,element:a,method:b.method}),this.errorMap[a.name]=c,this.submitted[a.name]=c},addWrapper:function(a){return this.settings.wrapper&&(a=a.add(a.parent(this.settings.wrapper))),a},defaultShowErrors:function(){var a,b,c;for(a=0;this.errorList[a];a++)c=this.errorList[a],this.settings.highlight&&this.settings.highlight.call(this,c.element,this.settings.errorClass,this.settings.validClass),this.showLabel(c.element,c.message);if(this.errorList.length&&(this.toShow=this.toShow.add(this.containers)),this.settings.success)for(a=0;this.successList[a];a++)this.showLabel(this.successList[a]);if(this.settings.unhighlight)for(a=0,b=this.validElements();b[a];a++)this.settings.unhighlight.call(this,b[a],this.settings.errorClass,this.settings.validClass);this.toHide=this.toHide.not(this.toShow),this.hideErrors(),this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return a(this.errorList).map(function(){return this.element})},showLabel:function(b,c){var d,e,f,g,h=this.errorsFor(b),i=this.idOrName(b),j=a(b).attr("aria-describedby");h.length?(h.removeClass(this.settings.validClass).addClass(this.settings.errorClass),h.html(c)):(h=a("<"+this.settings.errorElement+">").attr("id",i+"-error").addClass(this.settings.errorClass).html(c||""),d=h,this.settings.wrapper&&(d=h.hide().show().wrap("<"+this.settings.wrapper+"/>").parent()),this.labelContainer.length?this.labelContainer.append(d):this.settings.errorPlacement?this.settings.errorPlacement.call(this,d,a(b)):d.insertAfter(b),h.is("label")?h.attr("for",i):0===h.parents("label[for='"+this.escapeCssMeta(i)+"']").length&&(f=h.attr("id"),j?j.match(new RegExp("\\b"+this.escapeCssMeta(f)+"\\b"))||(j+=" "+f):j=f,a(b).attr("aria-describedby",j),e=this.groups[b.name],e&&(g=this,a.each(g.groups,function(b,c){c===e&&a("[name='"+g.escapeCssMeta(b)+"']",g.currentForm).attr("aria-describedby",h.attr("id"))})))),!c&&this.settings.success&&(h.text(""),"string"==typeof this.settings.success?h.addClass(this.settings.success):this.settings.success(h,b)),this.toShow=this.toShow.add(h)},errorsFor:function(b){var c=this.escapeCssMeta(this.idOrName(b)),d=a(b).attr("aria-describedby"),e="label[for='"+c+"'], label[for='"+c+"'] *";return d&&(e=e+", #"+this.escapeCssMeta(d).replace(/\s+/g,", #")),this.errors().filter(e)},escapeCssMeta:function(a){return void 0===a?"":a.replace(/([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g,"\\$1")},idOrName:function(a){return this.groups[a.name]||(this.checkable(a)?a.name:a.id||a.name)},validationTargetFor:function(b){return this.checkable(b)&&(b=this.findByName(b.name)),a(b).not(this.settings.ignore)[0]},checkable:function(a){return/radio|checkbox/i.test(a.type)},findByName:function(b){return a(this.currentForm).find("[name='"+this.escapeCssMeta(b)+"']")},getLength:function(b,c){switch(c.nodeName.toLowerCase()){case"select":return a("option:selected",c).length;case"input":if(this.checkable(c))return this.findByName(c.name).filter(":checked").length}return b.length},depend:function(a,b){return!this.dependTypes[typeof a]||this.dependTypes[typeof a](a,b)},dependTypes:{"boolean":function(a){return a},string:function(b,c){return!!a(b,c.form).length},"function":function(a,b){return a(b)}},optional:function(b){var c=this.elementValue(b);return!a.validator.methods.required.call(this,c,b)&&"dependency-mismatch"},startRequest:function(b){this.pending[b.name]||(this.pendingRequest++,a(b).addClass(this.settings.pendingClass),this.pending[b.name]=!0)},stopRequest:function(b,c){this.pendingRequest--,this.pendingRequest<0&&(this.pendingRequest=0),delete this.pending[b.name],a(b).removeClass(this.settings.pendingClass),c&&0===this.pendingRequest&&this.formSubmitted&&this.form()&&0===this.pendingRequest?(a(this.currentForm).trigger("submit"),this.submitButton&&a("input:hidden[name='"+this.submitButton.name+"']",this.currentForm).remove(),this.formSubmitted=!1):!c&&0===this.pendingRequest&&this.formSubmitted&&(a(this.currentForm).triggerHandler("invalid-form",[this]),this.formSubmitted=!1)},previousValue:function(b,c){return c="string"==typeof c&&c||"remote",a.data(b,"previousValue")||a.data(b,"previousValue",{old:null,valid:!0,message:this.defaultMessage(b,{method:c})})},destroy:function(){this.resetForm(),a(this.currentForm).off(".validate").removeData("validator").find(".validate-equalTo-blur").off(".validate-equalTo").removeClass("validate-equalTo-blur").find(".validate-lessThan-blur").off(".validate-lessThan").removeClass("validate-lessThan-blur").find(".validate-lessThanEqual-blur").off(".validate-lessThanEqual").removeClass("validate-lessThanEqual-blur").find(".validate-greaterThanEqual-blur").off(".validate-greaterThanEqual").removeClass("validate-greaterThanEqual-blur").find(".validate-greaterThan-blur").off(".validate-greaterThan").removeClass("validate-greaterThan-blur")}},classRuleSettings:{required:{required:!0},email:{email:!0},url:{url:!0},date:{date:!0},dateISO:{dateISO:!0},number:{number:!0},digits:{digits:!0},creditcard:{creditcard:!0}},addClassRules:function(b,c){b.constructor===String?this.classRuleSettings[b]=c:a.extend(this.classRuleSettings,b)},classRules:function(b){var c={},d=a(b).attr("class");return d&&a.each(d.split(" "),function(){this in a.validator.classRuleSettings&&a.extend(c,a.validator.classRuleSettings[this])}),c},normalizeAttributeRule:function(a,b,c,d){/min|max|step/.test(c)&&(null===b||/number|range|text/.test(b))&&(d=Number(d),isNaN(d)&&(d=void 0)),d||0===d?a[c]=d:b===c&&"range"!==b&&(a["date"===b?"dateISO":c]=!0)},attributeRules:function(b){var c,d,e={},f=a(b),g=b.getAttribute("type");for(c in a.validator.methods)"required"===c?(d=b.getAttribute(c),""===d&&(d=!0),d=!!d):d=f.attr(c),this.normalizeAttributeRule(e,g,c,d);return e.maxlength&&/-1|2147483647|524288/.test(e.maxlength)&&delete e.maxlength,e},dataRules:function(b){var c,d,e={},f=a(b),g=b.getAttribute("type");for(c in a.validator.methods)d=f.data("rule"+c.charAt(0).toUpperCase()+c.substring(1).toLowerCase()),""===d&&(d=!0),this.normalizeAttributeRule(e,g,c,d);return e},staticRules:function(b){var c={},d=a.data(b.form,"validator");return d.settings.rules&&(c=a.validator.normalizeRule(d.settings.rules[b.name])||{}),c},normalizeRules:function(b,c){return a.each(b,function(d,e){if(e===!1)return void delete b[d];if(e.param||e.depends){var f=!0;switch(typeof e.depends){case"string":f=!!a(e.depends,c.form).length;break;case"function":f=e.depends.call(c,c)}f?b[d]=void 0===e.param||e.param:(a.data(c.form,"validator").resetElements(a(c)),delete b[d])}}),a.each(b,function(a,d){b[a]="function"==typeof d&&"normalizer"!==a?d(c):d}),a.each(["minlength","maxlength"],function(){b[this]&&(b[this]=Number(b[this]))}),a.each(["rangelength","range"],function(){var a;b[this]&&(Array.isArray(b[this])?b[this]=[Number(b[this][0]),Number(b[this][1])]:"string"==typeof b[this]&&(a=b[this].replace(/[\[\]]/g,"").split(/[\s,]+/),b[this]=[Number(a[0]),Number(a[1])]))}),a.validator.autoCreateRanges&&(null!=b.min&&null!=b.max&&(b.range=[b.min,b.max],delete b.min,delete b.max),null!=b.minlength&&null!=b.maxlength&&(b.rangelength=[b.minlength,b.maxlength],delete b.minlength,delete b.maxlength)),b},normalizeRule:function(b){if("string"==typeof b){var c={};a.each(b.split(/\s/),function(){c[this]=!0}),b=c}return b},addMethod:function(b,c,d){a.validator.methods[b]=c,a.validator.messages[b]=void 0!==d?d:a.validator.messages[b],c.length<3&&a.validator.addClassRules(b,a.validator.normalizeRule(b))},methods:{required:function(b,c,d){if(!this.depend(d,c))return"dependency-mismatch";if("select"===c.nodeName.toLowerCase()){var e=a(c).val();return e&&e.length>0}return this.checkable(c)?this.getLength(b,c)>0:void 0!==b&&null!==b&&b.length>0},email:function(a,b){return this.optional(b)||/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(a)},url:function(a,b){return this.optional(b)||/^(?:(?:(?:https?|ftp):)?\/\/)(?:(?:[^\]\[?\/<~#`!@$^&*()+=}|:";',>{ ]|%[0-9A-Fa-f]{2})+(?::(?:[^\]\[?\/<~#`!@$^&*()+=}|:";',>{ ]|%[0-9A-Fa-f]{2})*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(a)},date:function(){var a=!1;return function(b,c){return a||(a=!0,this.settings.debug&&window.console&&console.warn("The `date` method is deprecated and will be removed in version '2.0.0'.\nPlease don't use it, since it relies on the Date constructor, which\nbehaves very differently across browsers and locales. Use `dateISO`\ninstead or one of the locale specific methods in `localizations/`\nand `additional-methods.js`.")),this.optional(c)||!/Invalid|NaN/.test(new Date(b).toString())}}(),dateISO:function(a,b){return this.optional(b)||/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(a)},number:function(a,b){return this.optional(b)||/^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(a)},digits:function(a,b){return this.optional(b)||/^\d+$/.test(a)},minlength:function(a,b,c){var d=Array.isArray(a)?a.length:this.getLength(a,b);return this.optional(b)||d>=c},maxlength:function(a,b,c){var d=Array.isArray(a)?a.length:this.getLength(a,b);return this.optional(b)||d<=c},rangelength:function(a,b,c){var d=Array.isArray(a)?a.length:this.getLength(a,b);return this.optional(b)||d>=c[0]&&d<=c[1]},min:function(a,b,c){return this.optional(b)||a>=c},max:function(a,b,c){return this.optional(b)||a<=c},range:function(a,b,c){return this.optional(b)||a>=c[0]&&a<=c[1]},step:function(b,c,d){var e,f=a(c).attr("type"),g="Step attribute on input type "+f+" is not supported.",h=["text","number","range"],i=new RegExp("\\b"+f+"\\b"),j=f&&!i.test(h.join()),k=function(a){var b=(""+a).match(/(?:\.(\d+))?$/);return b&&b[1]?b[1].length:0},l=function(a){return Math.round(a*Math.pow(10,e))},m=!0;if(j)throw new Error(g);return e=k(d),(k(b)>e||l(b)%l(d)!==0)&&(m=!1),this.optional(c)||m},equalTo:function(b,c,d){var e=a(d);return this.settings.onfocusout&&e.not(".validate-equalTo-blur").length&&e.addClass("validate-equalTo-blur").on("blur.validate-equalTo",function(){a(c).valid()}),b===e.val()},remote:function(b,c,d,e){if(this.optional(c))return"dependency-mismatch";e="string"==typeof e&&e||"remote";var f,g,h,i=this.previousValue(c,e);return this.settings.messages[c.name]||(this.settings.messages[c.name]={}),i.originalMessage=i.originalMessage||this.settings.messages[c.name][e],this.settings.messages[c.name][e]=i.message,d="string"==typeof d&&{url:d}||d,h=a.param(a.extend({data:b},d.data)),i.old===h?i.valid:(i.old=h,f=this,this.startRequest(c),g={},g[c.name]=b,a.ajax(a.extend(!0,{mode:"abort",port:"validate"+c.name,dataType:"json",data:g,context:f.currentForm,success:function(a){var d,g,h,j=a===!0||"true"===a;f.settings.messages[c.name][e]=i.originalMessage,j?(h=f.formSubmitted,f.resetInternals(),f.toHide=f.errorsFor(c),f.formSubmitted=h,f.successList.push(c),f.invalid[c.name]=!1,f.showErrors()):(d={},g=a||f.defaultMessage(c,{method:e,parameters:b}),d[c.name]=i.message=g,f.invalid[c.name]=!0,f.showErrors(d)),i.valid=j,f.stopRequest(c,j)}},d)),"pending")}}});var c,d={};return a.ajaxPrefilter?a.ajaxPrefilter(function(a,b,c){var e=a.port;"abort"===a.mode&&(d[e]&&d[e].abort(),d[e]=c)}):(c=a.ajax,a.ajax=function(b){var e=("mode"in b?b:a.ajaxSettings).mode,f=("port"in b?b:a.ajaxSettings).port;return"abort"===e?(d[f]&&d[f].abort(),d[f]=c.apply(this,arguments),d[f]):c.apply(this,arguments)}),a});
--------------------------------------------------------------------------------