Skip to content

Instantly share code, notes, and snippets.

View ibrahim-kardi's full-sized avatar

Mohammad Ibrahim ibrahim-kardi

  • Mirpur, Dhaka -1216,Bangladesh
View GitHub Profile
@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"} -->
@ibrahim-kardi
ibrahim-kardi / gist:77e6b8d14b12150681bf7ff265710859
Created March 9, 2023 06:16
add to cart woocommerce product list
<?php global $woocommerce;
$items = $woocommerce->cart->get_cart();
foreach($items as $item => $values) {
$_product = wc_get_product( $values['data']->get_id());
echo "<b>".$_product->get_title().'</b> <br> Quantity: '.$values['quantity'].'<br>';
$price = get_post_meta($values['product_id'] , '_price', true);
echo " Price: ".$price."<br>";
}
@ibrahim-kardi
ibrahim-kardi / multi-image
Last active March 8, 2023 15:36
multi-image.php view
<div class="multi-image-container">
<div class="multi-image">
<?php if ($data['multis']) :
foreach ($data['multis'] as $singleimg) :
$image = wp_get_attachment_image_url($singleimg['multi_image']['id'], $data['thumbnail_size']);
if (!$image) {
<?php
/**
* @author none
* @since 1.0
* @version 1.0
*/
namespace WPC\Widgets;
@ibrahim-kardi
ibrahim-kardi / elementor-extensions.php
Created March 8, 2023 15:30
for theme elementor widgets loader
//elementor includes
include get_template_directory() . '/includes/elements/elementor-extensions.php';
<?php
namespace WPC;
class Widget_Loader
{
@ibrahim-kardi
ibrahim-kardi / hide student menu for instructor
Created August 25, 2022 14:51
instructor not able to see regular bar
$user = wp_get_current_user();
if ( !in_array( 'tutor_instructor', (array) $user->roles ) ) {
$nav_items = apply_filters( 'tutor_dashboard/nav_items', $this->default_menus() );
}
else{
$nav_items=[];
}
<?php
include("simple_html_dom.php");
$html = file_get_html('https://www.laundrycare.biz/locations/');
echo $html ->find('.container .location-state-list-container',0)->innertext;
<?php
/**
* Class Email Notification
*
* @package TUTOR
*
* @since v.1.0.0
*/