Skip to content

Instantly share code, notes, and snippets.

View ibrahim-kardi's full-sized avatar

Mohammad Ibrahim ibrahim-kardi

View GitHub Profile
@ibrahim-kardi
ibrahim-kardi / gist:0788baced1b27f80b82a7896c8d63a2f
Created January 26, 2024 11:20
Load delay any section by CSS
@keyframes delay {
0% { opacity: 0; }
100% { opacity: 1; }
}
/* Apply animation to the section */
section {
opacity: 0; /* Initially hide the section */
animation: delay 2s ease forwards; /* Apply animation with 2-second delay */
}
<div class="slider">
<div>
<div class="text">
This is the worst kind of discrimination: the kind against me! You don't know how to do any of those. You are the last hope of the universe. Yes, except the Dave Matthews Band doesn't rock.
</div>
</div>
<div>
<div class="text">
This is the worst kind of discrimination: the kind against me! You don't know how to do any of those. You are the last hope of the universe. Yes, except the Dave Matthews Band doesn't rock.
</div>
@ibrahim-kardi
ibrahim-kardi / gist:4fb0d018864772bce6ea436ba194b94a
Created November 4, 2023 17:58
how to handle currency switcher
window.addEventlistener(DOMcontentloaded,()=>{
function currencyFormhandler(event){
event.target.form.submit();
}
document.querySelectorAll(.selecclass).forEach((elm)=>{
elm.addEventlistener('change'.currencyFormhandler)
})
})
@ibrahim-kardi
ibrahim-kardi / docker-compose.yaml
Created November 1, 2023 17:24
Docker with WordPress
# YAML is a human-readable data-serialization language. It is commonly used for configuration files and in applications where data is being stored or transmitted.
version: '3.1' # Compose file versions
services:
#Database
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
<?php
/**
* Plugin Name: Demo Plugin
* Plugin URI: https://smalltowndev.com
* Description: A demo plugin to show how to WordPress.
* Author: kardi
* Version: 1.0.0
* Author URI: https://kardi.com
*
* @package wordpress-reset
@ibrahim-kardi
ibrahim-kardi / gist:54d23c88047cdadcd260d66613d12916
Created August 19, 2023 06:53
Registers wordpress dashboard widget
<?php
add_action( 'wp_dashboard_setup', 'test_dashboard_widget' );
/**
* Registers dashboard widget.
*/
function test_dashboard_widget() {
wp_add_dashboard_widget(
'test_dashboard_widget',
esc_html( 'Test widget' ),
add_filter(
'user_has_cap',
function( $allcaps, $caps, $args, WP_User $user ) {
$current_user = wp_get_current_user();
$requested_cap = $args[0];
if ( $user->ID === $current_user->ID && in_array( 'customer', (array) $current_user->roles ) ) {
if ( 'upload_files' === $requested_cap ) {
return $allcaps;
}
}
@ibrahim-kardi
ibrahim-kardi / gist:ccb671f1deb27e5f2a15680e007f81c7
Created July 7, 2023 07:53
override specific gutenberg block function
if (has_block("gallery", get_the_content()))
{
$post_blocks = parse_blocks(get_the_content());
foreach ($post_blocks as $post_block)
{
if ("core/gallery" == $post_block["blockName"])
{
$ids = $post_block["attrs"]["ids"];
}
}
@ibrahim-kardi
ibrahim-kardi / gist:707dca5a00574753fcec16b397cc8101
Created June 23, 2023 10:46
get woocommerce state under the country
$valid_states = WC()->countries->get_states( $country );
$for_country = isset( $args['country'] ) ? $args['country'] : WC()->checkout->get_value( 'billing_state' === $key ? 'billing_country' : 'shipping_country' );
$states = WC()->countries->get_states( $for_country );
@ibrahim-kardi
ibrahim-kardi / function.php
Created April 3, 2023 15:55
regsiter pattern in the block theme
<?php
register_block_pattern(
'starter/custom-button-pattern',
array(
'title' => __( 'Custom buttons', 'starter' ),
'description' => _x( 'Two horizontal buttons, the left button is filled in, and the right button is outlined.', 'Block pattern description', 'starter' ),
'categories' => array( 'buttons' ),
'content' => '<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button {"backgroundColor":"vivid-green-cyan"} -->