Skip to content

Instantly share code, notes, and snippets.

View tiendungdev's full-sized avatar

Tien Dung Dao tiendungdev

View GitHub Profile
@tiendungdev
tiendungdev / performance.php
Created December 9, 2024 13:31 — forked from devinsays/performance.php
Dequeue scripts and styles
<?php
namespace DevPress\Frontend;
/**
* Class Performance
*
* @package DevPress\Performance
*/
class Performance {
@tiendungdev
tiendungdev / delete-customers-without-orders.php
Created December 9, 2024 13:30 — forked from devinsays/delete-customers-without-orders.php
Deletes users with customer role in WooCommerce that do not have orders.
<?php
/**
* Deletes customers without orders
*
* To run the script:
* wp eval-file delete-customers-without-orders.php
*/
// Query for customers registered since this date.
$date_after = '2000-01-01';
@tiendungdev
tiendungdev / example-ajax-enqueue.php
Created December 9, 2024 13:29 — forked from devinsays/example-ajax-enqueue.php
Simple WordPress Ajax Example
<?php
function example_ajax_enqueue() {
// Enqueue javascript on the frontend.
wp_enqueue_script(
'example-ajax-script',
get_template_directory_uri() . '/js/simple-ajax-example.js',
array( 'jquery' )
);
@tiendungdev
tiendungdev / fstab
Last active August 21, 2024 11:06
Fstab AlmaLinux 8.10
[root@upcode ~]# sudo blkid
/dev/vda1: UUID="927497f9-eae9-4a2b-bd8b-162997d80076" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="318ba904-01"
/dev/vda2: UUID="9876e00b-695e-4170-b66b-e53928eac854" TYPE="swap" PARTUUID="318ba904-02"
[root@upcode ~]# cat /etc/fstab
/dev/vda1 / ext4 defaults,usrquota 1 1
/dev/vda2 swap swap defaults 0 0
[root@upcode ~]# cat /etc/default/grub
GRUB_TIMEOUT=5
@tiendungdev
tiendungdev / functions.php
Created September 25, 2022 06:52
Thêm đơn hàng bằng PHP - Woocommerce
add_action('woocommerce_checkout_process', 'create_vip_order');
function create_vip_order() {
global $woocommerce;
$address = array(
'first_name' => 'Tien Dung',
'last_name' => 'Dao',
'company' => 'TTV',
@tiendungdev
tiendungdev / function.php
Created July 11, 2022 09:58
Simple shortcode with ob_start
<?php
function vts_shortcode_box(){
ob_start();
?>
<div class="box">Content blabla</div>
<?php
$result = ob_get_contents();
ob_end_clean();
return $result;
}
@tiendungdev
tiendungdev / style.css
Created April 8, 2022 09:31
Beautiful 404 error page - Flatsome theme
/*404*/
.error-404{padding:0; margin:0}
.error-404 .medium-3 {
max-width: 100%;
-ms-flex-preferred-size: 100%;
flex-basis: 100%;
text-align: center;
font-size: 45px!important;
padding: 0;
margin: 0
@tiendungdev
tiendungdev / functions.php
Created February 4, 2022 05:43
Strong password
<?php
/**
* Enforce strong passwords (ESP) for all website users.
*
* To disable enforcing strong passwords:
* define('ESP_IS_ENABLED', false);
*/
if (!defined('WPINC')) {
exit('Do NOT access this file directly.');
@tiendungdev
tiendungdev / header.php
Created August 26, 2021 08:15
follow, noindex
<?php if(is_paged()){ echo '<meta name="robots" content="follow, noindex"/>'; } ?>
<?php
//check url neu co tu page thi cho noindex
$url = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if (strpos($url,'page') !== false) {
echo '<meta name="robots" content="follow, noindex"/>';
}
?>
@tiendungdev
tiendungdev / functions.php
Created August 14, 2021 03:24
Preload Image WP
function preload_featured_image(){
if (has_post_thumbnail()) {
$attachment_image = wp_get_attachment_url( get_post_thumbnail_id() );
echo '<link rel="preload" as="image" href="'.$attachment_image.'">';
}
}
add_action('wp_head', 'preload_featured_image');