Skip to content

Instantly share code, notes, and snippets.

Avatar

Dat Hoang htdat

View GitHub Profile
@htdat
htdat / plugin.php
Created Mar 15, 2021 — forked from joncave/plugin.php
An intentionally vulnerable plugin developed for WordPress plugin author education. http://make.wordpress.org/plugins/2013/04/09/intentionally-vulnerable-plugin/
View plugin.php
<?php
/* Plugin Name: Damn Vulnerable WordPress Plugin
* Description: Intentionally vulnerable plugin for plugin author education
* Version: 0.1
* Plugin URI: http://make.wordpress.org/plugins/2013/04/09/intentionally-vulnerable-plugin/
* Author: Jon Cave
* Author URI: http://joncave.co.uk
* License: GPLv2+
*
* DO NOT RUN THIS PLUGIN ON AN INTERNET ACCESSIBLE SITE
@htdat
htdat / promise-timeout.js
Created May 19, 2020
Timeout for Promise in JavaScript
View promise-timeout.js
// Definition - wait X seconds
const wait = seconds => new Promise(resolve => setTimeout(resolve, 1000 * seconds));
/* Usage */
async functionA() {
// Do something
// ...
// Wait for 10 seconds
await wait(10);
View cash-register.js
const unitValue = [
["PENNY", 0.01],
["NICKEL", 0.05],
["DIME", 0.1],
["QUARTER", 0.25],
["ONE", 1],
["FIVE", 5],
["TEN", 10],
["TWENTY", 20],
["ONE HUNDRED", 100]
View hook.php
<?php
add_filter( 'lazyload_is_enabled', 'htdat_disable_lazy_load_homepage', 15 );
function htdat_disable_lazy_load_homepage() {
if ( is_front_page() ) {
return false;
}
return true;
@htdat
htdat / wordads_ads_txt.php
Last active May 4, 2018
Use the "wordads_ads_txt" filter since Jetpack 6.1. See the official guide at https://developer.jetpack.com/hooks/wordads_ads_txt/
View wordads_ads_txt.php
<?php
add_filter( 'wordads_ads_txt', 'dat_wordads_ads_txt');
function dat_wordads_ads_txt ($ads_txt_transient) {
$my_text = "#Add more texts";
$my_text .= "\r\n"; // new line
$my_text .= "google.com, pub-0000000000000000, DIRECT, f08c47fec0942fa0"; // Edit your own text here
$my_text .= "\r\n \r\n"; // new line
return $my_text . $ads_txt_transient;
}
@htdat
htdat / wpjm-job-alerts-frequency.php
Last active Dec 6, 2017
Add the custom email frequency for WPJM Job Alerts
View wpjm-job-alerts-frequency.php
function htdat_job_manager_alerts_alert_schedules ( $schedules ) {
$schedules['monthly'] = array(
'interval' => 86400 * 30,
'display' => __( 'Monthly', 'wp-job-manager-alerts' )
);
return $schedules;
}
add_filter('job_manager_alerts_alert_schedules', 'htdat_job_manager_alerts_alert_schedules');
@htdat
htdat / code.php
Last active Oct 26, 2017
WPJM Applicants - Route all employer notification emails to a specific email. (https://wpjobmanager.com/document/applications/)
View code.php
add_filter('create_job_application_notification_recipient', 'htdat_create_job_application_notification_recipient', 10, 3);
function htdat_create_job_application_notification_recipient ($send_to, $job_id, $application_id){
$send_to = 'all@email.local';
return $send_to;
}
@htdat
htdat / disable-whatsapp-desktop.css
Created Aug 31, 2017
disable-whatsapp-desktop.css
View disable-whatsapp-desktop.css
@media screen and (min-width: 900px) {
.share-jetpack-whatsapp {
display: none !important;
}
}
@htdat
htdat / del_fb_group_pending_posts.js
Created Mar 4, 2017
Delete FB group pending posts for admins
View del_fb_group_pending_posts.js
/**
* Please use this file at your own risk. I don't provide the support for it.
* Any suggestion or problem are welcomed to report here :)
*/
/**
* Usage:
* 1. Log-in as an group admin in the desktop
* 2. Go to your group pending list like: https://www.facebook.com/groups/[group-id]/pending/
* 3. Insert the following code to your browser console. See the guide: https://developer.chrome.com/devtools/docs/console