Skip to content

Instantly share code, notes, and snippets.

View web-elite's full-sized avatar
🤙
A small point in the world of 0 and 1

Alireza Yaghouti web-elite

🤙
A small point in the world of 0 and 1
View GitHub Profile
@web-elite
web-elite / input-filter-script.js
Last active December 31, 2022 12:18
filter inputs with only number or only alphabet or only persian letters.
$(document).ready(function() {
$('input.number-filter,.number-filter [type="number"],.number-filter [type="tel"]').on("keydown contextmenu drop", function(event) {
const valid = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "ArrowRight", "Backspace", "ArrowLeft", "ArrowUp", "ArrowDown"];
if (!valid.includes(event.key)) {
event.preventDefault();
}
})
$('.persian-filter input[type*="text"],.persian-filter textarea, input.persian-filter').on("keydown contextmenu drop", function(event) {
const valid = ["الف", "ب", "پ", "ت", "ث", "ج", "چ", "ح", "خ", "د", "ذ", "ر", "ز", "ژ", "س", "ش", "ص", "ض", "ط", "ظ", "ع", "غ", "ف", "ق", "ک", "گ", "ل", "م", "ن", "و", "ه", "ی", "َ", "ُ", "ِ", "ّ", "ۀ", "آ", "ـ", ",", "،", "ريال", "ٍ", "ٌ", "ً", "ة", "ؤ", "؛", "إ", "أ", "ء", " ", "ArrowRight", "Backspace", "ArrowLeft", "ArrowUp", "ArrowDown"];
if (!valid.includes(event.key)) {
@web-elite
web-elite / filter-input-only-numbers.html
Created December 24, 2022 14:09
filter inputs with numbers only
<script>
var inputNumberElite = document.querySelectorAll('input[type="number"]');
for (var i = 0, len = inputNumberElite.length; i < len; i++) {
inputNumberElite[i].addEventListener("keypress", function(evt) {
if (evt.which != 8 && evt.which != 0 && evt.which < 48 || evt.which > 57) {
evt.preventDefault();
}
})
}
</script>
@web-elite
web-elite / iran-car-list.php
Last active December 5, 2022 08:48
List of public cars available in Iran. لیست ماشین های عمومی موجود در ایران
<?php
$car_list = array (
0 => '550 ام جی MG ',
1 => 'گریت وال H2هاوال',
2 => 'گریت وال M4هاوال',
3 => '۲۰۵SLX',
4 => '۲۰۶',
5 => '۲۰۷',
6 => '۲۰۷ صندوق دار',
@web-elite
web-elite / get-post-rest-api-wordpress-full
Last active March 25, 2022 12:24
get post from rest api with full information ,
<?php
/**
* Add a Formatted Date to the WordPress REST API JSON Post Object
*/
add_action('rest_api_init', function () {
register_rest_field(
'post',
'formatted_date',
array(
'get_callback' => function () {
@web-elite
web-elite / convert-checkbox-to-imagebox-selector.css
Created March 8, 2022 11:27
Convert checkboxes to select photos using Css only
//remove checkbox
input[type=checkbox]~label:after, input[type=checkbox]~span:after,input[type=checkbox]~label:before, input[type=checkbox]~span:before{
all:'';
}
#checkBoxInputs {
visibility: hidden;
}
//add image to input
@web-elite
web-elite / csf-parent-child-sub-section.php
Created March 4, 2022 12:53
parent section or sub section or child section for codestar framework code snippet PHP
if( class_exists( 'CSF' ) ) {
$prefix = 'my_framework';
CSF::createOptions( $prefix, array(
'menu_title' => 'MyFramework',
'menu_slug' => 'my-framework',
'menu_icon' => 'dashicons-star-filled',
'framework_title' => 'MyFramework'
) );
@web-elite
web-elite / generate random hash in php
Created February 19, 2022 13:24
generate random hash in php in one line code
/*
* x = hash lenght
*/
substr(md5(openssl_random_pseudo_bytes(20)), $x);