Skip to content

Instantly share code, notes, and snippets.

View codename065's full-sized avatar
🐢

Shahnur Alam codename065

🐢
View GitHub Profile
@codename065
codename065 / disable scripts.php
Last active July 14, 2023 12:52
Disable scripts
<?php
add_filter("wpdm_disable_scripts", function ($disabled_scripts) {
// $disabled_scripts = ['wpdm-bootstrap-js', 'wpdm-bootstrap-css', 'wpdm-font-awesome', 'wpdm-front'];
// by default $disabled_scripts = [], means all scripts are enabled,
// if you want to disable 'wpdm-bootstrap-css' push it to $disabled_scripts, like $disabled_scripts[] = 'wpdm-bootstrap-css';
// example to disable scripts on page id 123
if(get_the_ID() === 123) {
$disabled_scripts[] = 'wpdm-bootstrap-css';
$disabled_scripts[] = 'wpdm-bootstrap-js';
}
@codename065
codename065 / hide category.php
Last active June 28, 2023 17:05
hide category when user does not have access
<?php
add_filter("get_terms", function ($terms, $tax, $ta, $tz){
$_terms = [];
if($tax[0] === 'wpdmcategory') {
foreach ($terms as $term) {
if(WPDM()->categories::userHasAccess($term->term_id)) {
$_terms[] = $term;
}
}
}
@codename065
codename065 / wpdmpp_as_you_pay_label.php
Last active January 8, 2023 14:46
Using filter hook "wpdmpp_as_you_pay_label" to change label "Name Your Price" in premium packages
<?php
add_filter( "wpdmpp_as_you_pay_label", function ( $str, $product_id ) {
$str = "Your custom text";
return $str;
}, 10, 2 );
@codename065
codename065 / link-template-featured.php
Created December 11, 2022 03:59
WPDM Link Template
@codename065
codename065 / WordPress Download Manager - Bulk generate master key.php
Created December 9, 2022 09:30
WordPress Download Manager - Bulk generate master key
<?php
//www.wpdownloadmanager.com
$all_packages = get_posts(['post_type' => 'wpdmpro', 'posts_per_page' => -1]);
foreach($all_packages as $package){
$masterKey = \WPDM\__\Crypt::encrypt( [ 'id' => $package->ID, 'time' => time() ] );
update_post_meta($package->ID, '__wpdm_masterkey', $masterKey);
}
@codename065
codename065 / show form entries.php
Created September 20, 2022 17:56
show form entries
<?php
add_action("PrivateMessage/Message/Views/OpenMessage/BeforeSenderAbout", function (){
?>
<div id="pm-sidebar-extended" style="margin: 10px">
<div class="card" style="margin: 0">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" data-target="#sein" href="#sein">Sender Info</a>
</li>
<script>
jQuery(function($){
$('body').on('click', '.btn-clps', function(e){
e.preventDefault();
$($(this).attr('href')).toggleClass('show');
});
});
</script>
@codename065
codename065 / new-window.js
Created August 16, 2021 06:14
Open In New Window
<script>
jQuery(function($){
$('.wpdm-download-link').each(function(){
$(this).attr('target','_blank');
});
});
</script>
<?php
global $wpdb;
$files = $wpdb->get_var("select meta_value from {$wpdb->prefix}postmeta where meta_key = '__wpdm_files' and post_id = '{$package['ID']}'");
preg_match_all("/i\:([0-9]+)/", $files, $matches);
$find = $matches[0];
$replace = [];
foreach($matches[1] as $index) {
$replace[] = "s:".strlen($index).':"'.$index.'"';
}
$files = str_replace($find, $replace, $files);
@codename065
codename065 / introduce-new-file-type.php
Created May 20, 2021 13:43
Introduce new file type
<?php
add_filter("wp_check_filetype_and_ext", function ($mime_type, $file, $filename, $mimes, $real_mime){
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$ext = strtolower($ext);
if($ext === 'gpg')
return ['ext' => 'gpg', 'type' => 'application/gpg', 'proper_filename' => $filename ];
}, 10, 5);