Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Shahnur Alam codename065

🎯
Focusing
View GitHub Profile
@codename065
codename065 / send-update-notifications.php
Created May 16, 2020
Send update notification to the users who previously downloaded the package
View send-update-notifications.php
<?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;
@codename065
codename065 / remove-from-search.php
Created Apr 5, 2020
Remove Download Manager Packages from search
View remove-from-search.php
<?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 / download-count-display.php
Last active Apr 8, 2020
Display downloads count as 1000 as 1K, 1,000,000 1M
View download-count-display.php
<?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 / testpay.php
Created Feb 2, 2020
Sample payment gateway code for promembership plugin
View testpay.php
<?php
if (!class_exists('wpmps_testpay')) {
class wpmps_testpay {
var $TestMode;
var $GatewayUrl = "https://test.pay/purchase";
var $Account;
var $ReturnUrl;
View keys.php
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 / tempStorage.js
Created Feb 3, 2018
JavaScript local storage handler with expiration time
View tempStorage.js
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);
View link-template-panel-1-3.php
View gist:3e7a43cbe2593b0dc030
$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);
You can’t perform that action at this time.