Skip to content

Instantly share code, notes, and snippets.

View DevWael's full-sized avatar
👨‍💻
WordPress-ing

Ahmad Wael DevWael

👨‍💻
WordPress-ing
View GitHub Profile
@webmandesign
webmandesign / gutenberg-wide-alignement-wrapper.php
Last active September 9, 2020 17:14
Wrapping aligned Gutenberg blocks with additional div on a WordPress website front-end.
<?php
// IMPORTANT UPDATE 20190307:
// Since WordPress 5.0.0 we can actually use much simpler solution:
/**
* Applies wrapper div around aligned blocks.
*
* Copy this function into your WordPress theme's `functions.php` file
* and change the `themeprefix` accordingly.
@giodc
giodc / wordpress-check-if-image-is-gif
Last active June 23, 2022 03:54
Check if WordPress featured image is gif, and output full size image to allow animated gif in Loop
<?php
$url = wp_get_attachment_url( get_post_thumbnail_id() );
$filetype = wp_check_filetype($url);
if ($filetype[ext] == 'gif')
{the_post_thumbnail('full', array('class' => 'img-responsive')); }
else
@justintadlock
justintadlock / font-awesome.php
Last active September 28, 2021 11:09
PHP array of Font Awesome icons.
<?php
// Font Awesome v. 4.6.
function jt_get_font_icons() {
return array(
'fa-glass' => 'f000',
'fa-music' => 'f001',
'fa-search' => 'f002',
'fa-envelope-o' => 'f003',
@LiamBailey
LiamBailey / Woocommerce Bookings Dropdown
Created March 10, 2016 18:25
Changes out the Woocommerce Bookings date picker fields for a nice dropdown showing only available dates
<?php
/*
Plugin Name: Woocommerce Bookings Dropdown
Description: Swaps the date picker for a dropdown of dates
Version: 1.0.0
Author: Webby Scots
Author URI: http://webbyscots.com/
*/
$wswp_dates_built = false;
add_filter('booking_form_fields','wswp_booking_form_fields');
@mikaelz
mikaelz / delete-all-woocommerce-products.php
Last active April 30, 2024 06:07
Remove all WooCommerce products from database via SQL
<?php
require dirname(__FILE__).'/wp-blog-header.php';
$wpdb->query("DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%')");
$wpdb->query("DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%'");
$wpdb->query("DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)");
$wpdb->query("DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_posts WHERE post_type IN ('product','product_variation')");
@josephilipraja
josephilipraja / countries.php
Last active April 17, 2024 05:42
List of Countries with Country code & Telephone (Dial) Code as a PHP Array. Bonus: PHP function to list all Countries as HTML Select Tag Options with their 2 character Country code as values
<?php
$countryArray = array(
'AD'=>array('name'=>'ANDORRA','code'=>'376'),
'AE'=>array('name'=>'UNITED ARAB EMIRATES','code'=>'971'),
'AF'=>array('name'=>'AFGHANISTAN','code'=>'93'),
'AG'=>array('name'=>'ANTIGUA AND BARBUDA','code'=>'1268'),
'AI'=>array('name'=>'ANGUILLA','code'=>'1264'),
'AL'=>array('name'=>'ALBANIA','code'=>'355'),
'AM'=>array('name'=>'ARMENIA','code'=>'374'),
'AN'=>array('name'=>'NETHERLANDS ANTILLES','code'=>'599'),
<aside id="complementary">
<?php
//get the titles of the most popular (by number of comments) 5 published posts
$query_popular = 'SELECT posts.title, posts.post_id, COUNT(*) AS numcomments
FROM posts, comments
WHERE posts.is_published = 1
AND posts.post_id = comments.post_id
GROUP BY posts.post_id
ORDER BY numcomments DESC
@jameskoster
jameskoster / functions.php
Created January 12, 2013 16:01
WooCommerce - hide ratings on product loop
// Remove the product rating display on product loops
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
@damienalexandre
damienalexandre / tool.php
Created October 3, 2011 09:47
Download large file from the web via php
<?php
/**
* Download a large distant file to a local destination.
*
* This method is very memory efficient :-)
* The file can be huge, PHP doesn't load it in memory.
*
* /!\ Warning, the return value is always true, you must use === to test the response type too.
*
* @author dalexandre
@vxnick
vxnick / gist:380904
Created April 27, 2010 15:52
Array of country codes (ISO 3166-1 alpha-2) and corresponding names
<?php
$countries = array
(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',