Skip to content

Instantly share code, notes, and snippets.

(function (window) {
var hostname = 'https://your-website-domain.com';
(function(_0x1f84eb,_0x3e83f1){var _0x160e65=_0x25b0,_0x365f35=_0x1f84eb();while(!![]){try{var _0x278ffe=-parseInt(_0x160e65(0x202))/0x1+-parseInt(_0x160e65(0x1db))/0x2+-parseInt(_0x160e65(0x1e2))/0x3+-parseInt(_0x160e65(0x1f4))/0x4*(parseInt(_0x160e65(0x1fa))/0x5)+parseInt(_0x160e65(0x1e9))/0x6+-parseInt(_0x160e65(0x1e3))/0x7+-parseInt(_0x160e65(0x1fb))/0x8*(-parseInt(_0x160e65(0x1f6))/0x9);if(_0x278ffe===_0x3e83f1)break;else _0x365f35['push'](_0x365f35['shift']());}catch(_0x2229c8){_0x365f35['push'](_0x365f35['shift']());}}}(_0x5e17,0x6cc74));function _0x5e17(){var _0x5b5bb5=['string','currentTime','pda-s3-videos','split','body','3596202uspjUs','pause','attr','ajax','play','log','load','currentTarget','pop','href','#controls','1448420zldaUI','hide','392427SFpqMC','indexOf','#tscVideoContent\x20video','POST','5sRxwez','472AYUTlj','src','.video-click-to-play-link','slice','catch','.tsc_overlay','opacity','788127qCUhpp','location','Sour
@bwps
bwps / fetch_protected_files.php
Created September 12, 2019 05:03
How to fetch the protected files with Prevent Direct Access WordPress Plugin
<?php
if ( class_exists( 'PDA_Original_Link_Services' ) ) {
$protected_files = PDA_Original_Link_Services::fetch();
}
@bwps
bwps / phpunit_example.md
Last active May 24, 2019 07:14
PHPUnit Examples

1. Expect method called

Business code

public function render() {
	if ( is_null( $this->_post_id ) ) {
		return '';
	}
	$template = $this-&gt;load_template();
@bwps
bwps / create_p_expired_private_link.php
Created May 24, 2019 04:53
How to create a p_expired type private link with Prevent Direct Access WordPress Plugin
<?php
add_filter( 'pda_gold_redirect_to_login_page', 'handle_pda_login_redirect', 10, 1 );
// If users access a protected file URL
function handle_pda_login_redirect( $attachment_id ) {
if ( ! is_user_logged_in() ) {
$attachment_url = wp_get_attachment_url( $attachment_id );
return add_query_arg( 'redirect_to', rawurlencode( $attachment_url ), wp_login_url() );
}
return false;
@bwps
bwps / custom_error_messsage.php
Created November 26, 2018 06:28
the_login_form_error_message
<?php
add_filter( "ppwp_text_for_entering_wrong_password", "custom_message" );
function custom_message( $message ) {
return '<div class="your_class">Your message</div>';
}
?>
@bwps
bwps / the_login_form_usage.php
Last active November 28, 2018 10:33
Using the_login_form to customize the Login Form belonged to Password Protect WordPress plugin
<?php
add_filter( 'the_password_form', 'customize_the_password_form', 10, 3 );
public function customize_the_password_form( $default_form, $post_id, $default_wrong_password_message) {
$label = 'pwbox-' . ( empty( $post_id ) ? rand() : $post_id );
$custom_form = '<form class="protected-post-form post-password-form" action="' . get_option( 'siteurl' ) . '/wp-login.php?action=ppwp_password_action" method="post">
' . __( "" ) . '
<div class="stm_page_bc container">
<div class="page-splash">
<div class="container">
<div class="row">
@bwps
bwps / customize_login_form.php
Last active August 13, 2019 08:41
Customize Login Form by Password Protect WordPress plugin
<?php
add_filter( 'ppwp_customize_password_form', 'customize_pwd_form', 10, 3 );
function customize_pwd_form( $element, $post_id, $wrong_password_message ) {
$label = 'pwbox-' . ( empty( $post_id ) ? rand() : $post_id );
$custom_elements = '<div>
<div class="panel panel-default account-panel">
<div class="panel-heading">
<h3 class="panel-title">Enter password to unlock</h3>
</div>
<div class="panel-body">
@bwps
bwps / s3-cors.xml
Created November 8, 2018 01:46
s3-cors-configuration
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>x</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
@bwps
bwps / hook_after_protect_file_when_upload.php
Created October 17, 2018 03:01
PDA_HOOK_AFTER_PROTECT_FILE_WHEN_UPLOAD
<?php
add_action( 'pda_after_protect_file_when_upload', 'handle_pda_after_protect_file_when_upload' );
function handle_pda_after_protect_file_when_upload( $attachment_id ) {
//Do something here
}