Skip to content

Instantly share code, notes, and snippets.

@bwps
bwps / hook_after_unprotect_file.php
Created October 16, 2018 06:52
PDA_HOOK_AFTER_UN_PROTECT_FILE
<?php
add_action( 'pda_after_un_protected', 'handle_after_unprotect_file' );
function handle_after_unprotect_file( $attachment_id ) {
//Do something here
}
@bwps
bwps / hook_after_protect_file.php
Created October 16, 2018 06:31
PDA_HOOK_AFTER_PROTECT_FILE
<?php
add_action( 'pda_after_protected', 'handle_after_protect_file' );
function handle_after_protect_file( $attachment_id ) {
//Do something here
}
@bwps
bwps / policy.json
Last active November 26, 2018 02:46
policy_for_full_permission_to_specific_bucket
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "POLICYPDAS3",
"Effect": "Allow",
"Action": [
"s3:List*",
"s3:Get*",
"s3:Put*",
@bwps
bwps / protect_wp_file.php
Created September 28, 2018 03:24 — forked from gaupoit/protect_wp_file.php
How to protect WordPress attachment's file with Prevent Direct Access service
<?php
if ( class_exists( 'PDA_Private_Link_Services' ) ) {
//669 is attachment's id.
$result = PDA_Private_Link_Services::protect_file( 669 );
if ( is_wp_error( $result ) ) {
echo $result->get_error_message();
}
}
@bwps
bwps / hook_before_sending_file.php
Created September 28, 2018 03:23 — forked from gaupoit/hook_before_sending_file.php
PDA_HOOK_BEFORE_SENDING_FILE
<?php
function handle_pda_before_sending_file_hook( $server_data, $link_data ) {
//Write code to handle data here
}
add_action( 'PDA_HOOK_BEFORE_SENDING_FILE', 'handle_pda_before_sending_file_hook', 10, 2 );
?>
@bwps
bwps / create_private_link.php
Last active May 2, 2021 15:07 — forked from gaupoit/create_private_link.php
How to create a private link with Prevent Direct Access WordPress Plugin