Skip to content

Instantly share code, notes, and snippets.

View codename065's full-sized avatar
🐢

Shahnur Alam codename065

🐢
View GitHub Profile
$email_template = file_get_contents(LF_BASE_DIR.'emails/generic-email.html');
$vars = array('[mail_headline]', '[banner_image_url]','[email_message]','[button_link]', '[button_text]');
$vals = array('We Received Your Query!', 'https://www.evernote.com/l/AV3XAO0XEA9GZrYqCTRLH_IKrrz_HLOmmxwB/image.jpg', $user_email_data['message'],'http://liveforms.org/query-status/', 'Check Query Status');
$email_message = str_replace($vars, $vals, $email_template);
wp_mail($email, $user_email_data['subject'], $email_message, $headers);
@codename065
codename065 / tempStorage.js
Created February 3, 2018 10:18
JavaScript local storage handler with expiration time
var tempStorage = {
get: function (name) {
var now = Math.floor(Date.now() / 1000);
var _lsd = localStorage.getItem(name);
if(_lsd == null) return null;
var obj = JSON.parse(_lsd);
if(obj.expire >= now){
return obj.data;
} else {
localStorage.removeItem(name);
define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
define('AUTH_SALT', 'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT', 'put your unique phrase here');
define('NONCE_SALT', 'put your unique phrase here');
@codename065
codename065 / testpay.php
Created February 2, 2020 18:04
Sample payment gateway code for promembership plugin
<?php
if (!class_exists('wpmps_testpay')) {
class wpmps_testpay {
var $TestMode;
var $GatewayUrl = "https://test.pay/purchase";
var $Account;
var $ReturnUrl;
@codename065
codename065 / download-count-display.php
Last active April 5, 2023 02:01
Display downloads count as 1000 as 1K, 1,000,000 1M
<?php
function wpdm__number_format($number, $plus = true){
$origin_number = $number;
if($number > 1000000){
$number = number_format(($number/1000000), 1);
$number = $origin_number > $number && $plus ? $number.'M+':$number.'M';
return $number;
}
if($number > 1000){
$number = number_format(($number/1000), 1);
@codename065
codename065 / remove-from-search.php
Created April 5, 2020 05:44
Remove Download Manager Packages from search
<?php
function wpdm_remove_search($query) {
if ($query->is_search) {
$post_type = array('post', 'page');
$query->set('post_type', $post_type);
};
return $query;
};
add_filter('pre_get_posts', 'wpdm_remove_search');
@codename065
codename065 / send-update-notifications.php
Created May 16, 2020 17:29
Send update notification to the users who previously downloaded the package
<?php
function wpdm_send_update_notification($ID, $post, $update){
global $wpdb;
if (get_post_type() != 'wpdmpro' || wp_is_post_revision( $ID ) || $post->post_status !== 'publish') return;
$users = $wpdb->get_results("select uid from {$wpdb->prefix}ahm_download_stats where pid = '{$ID}' and uid != 0");
$emails = [];
foreach ($users as $user){
if((int)$user->uid > 0)
$emails[] = get_user_by('ID', $user->uid)->user_email;
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets",
"s3:GetBucketLocation"
],
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form>
<label>Due Date</label>
<input type="datetime-local" id="test-date">
<button id="btn" onclick='convertdate()'>Convert</button>