Skip to content

Instantly share code, notes, and snippets.

View mohammadYousefiDev's full-sized avatar
🙂
every thing is great

Mohammad Yousefi mohammadYousefiDev

🙂
every thing is great
View GitHub Profile
$('#_dlr_select_product').select2({
"language": {
"noResults": function(){
return 'هیچ محصولی یافت نشد!';
},
inputTooShort: function() {
return 'لطفا سه حرف اول عنوان محصول را وارد نمایید';
},
searching: function() {
return "در حال جستجو ...";
@mohammadYousefiDev
mohammadYousefiDev / gist:97cd48f90d3ea70db62ebedf15bd950e
Last active September 23, 2023 05:10
Display all roles with count like users.php in wordpress
global $role;
$wp_roles = wp_roles();
$count_users = ! wp_is_large_user_count();
$url = 'admin.php?page=dlrm-users-wallet';
$role_links = array();
$avail_roles = array();
@mohammadYousefiDev
mohammadYousefiDev / gist:015e219f1c5c2fb97c5f0bc1060eed3f
Last active June 27, 2022 12:03
Terawallet credit or debit ballance transactions programmatically
woo_wallet()->wallet->credit($user_id, $amount, $description);
woo_wallet()->wallet->debit($user_id, $amount, $description);
@mohammadYousefiDev
mohammadYousefiDev / gist:156617460d2279975f8b15a93072c29e
Last active December 22, 2021 06:35
Disable stats.wp.com request in woocommerce
in functions.php
function DV_deactive_jetpack() {
wp_dequeue_script( 'devicepx' );
wp_dequeue_script( 'woo-tracks' );
}
add_action( 'admin_enqueue_scripts', 'DV_deactive_jetpack' );
@mohammadYousefiDev
mohammadYousefiDev / gist:8cefa607d5c603f64df2b2a7991c3684
Created November 3, 2021 07:51
change external product url in woocommerce
function override_external_product_url( $url, $product )
{
if ( 'external' === $product->get_type() )
{
$url = 'https://biawp.ir';
}
return $url;
}
add_filter( 'woocommerce_product_add_to_cart_url', 'override_external_product_url', 10, 2 );
@mohammadYousefiDev
mohammadYousefiDev / gist:5752369ea877bc05cd41aad14abbb439
Created October 29, 2021 08:11
add options to "add new" custom field dropdown wordpress post type
add_filter( 'postmeta_form_keys', 'filter_function_name_1552', 10, 2 );
function filter_function_name_1552( $keys, $post ){
if($post->post_type == 'car') {
$keys[] = 'regular_price';
}
return $keys;
}
@mohammadYousefiDev
mohammadYousefiDev / gist:0e13a81cde02abc84c4f648878983db1
Last active October 2, 2021 15:29
laravel artisan test command falgs
php artisan make:test MyTest //create a feature test
php artisan make:test MyTest --unit //create a unit test
php artisan test --testsuite=Feature //run just features test
php artisan test --testsuite=Unit //run just unit test
php artisan --stop-on-failure //stop if a test failured
Go to phpunit.xml
before end tag, add This
<testsuites>
<testsuite name="Application Test Suite">
<testsuite name="Modules Test Suite">
<directory>./Modules/*/Tests</directory>
</testsuite>
</testsuite>
</testsuites>
@mohammadYousefiDev
mohammadYousefiDev / gist:4010190fb8a5d7f5a7c3d89b5fec9cdc
Created May 11, 2021 09:00
Products have thumbnail filter in product list in woocommece admin product list
function my_custom_product_filters( $post_type ) {
$value1 = '';
$value2 = '';
if( isset( $_GET['p_thumb'] ) ) {
switch( $_GET['p_thumb'] ) {
case 0:
@mohammadYousefiDev
mohammadYousefiDev / delete-orphans-usermeta.sql
Created April 1, 2021 13:48 — forked from carlosleopoldo/delete-orphans-usermeta.sql
Delete all orphans user meta in WordPress
DELETE FROM wp_usermeta
WHERE NOT EXISTS (
SELECT * FROM wp_users
WHERE wp_usermeta.user_id = wp_users.ID
)