Skip to content

Instantly share code, notes, and snippets.

@patrickposner
patrickposner / functions.php
Last active May 25, 2022 12:41
Add custom columns to FILR libraries
<?php
add_filter( 'filr_header_columns', function( $columns ) {
$columns['custom'] = array(
'title' => esc_html__( 'Custom', 'filr' ),
'hide' => 'off',
);
return $columns;
});
@patrickposner
patrickposner / functions.php
Last active May 16, 2022 19:04
Run Simply Static Pro with WP-Cron
<?php
register_activation_hook( __FILE__, 'ssp_setup_static_export_cron' );
/**
* Setup a cron job to run daily.
*
* @return void
*/
function ssp_setup_static_export_cron() {
@patrickposner
patrickposner / functions.php
Last active March 28, 2022 08:55
Passster: Send e-mail once password was used.
<?php
add_action( 'passster_validation_success_list', function( $password, $password_list_id, $post_id ) {
// prepare and send the e-mail.
$to = '[email protected]';
$subject = 'Password ' . $password . 'was used';
$headers = array( 'Content-Type: text/html; charset=UTF-8' );
$body = 'Password ' . $password . ' form passwords list ' . get_the_title( $password_list_id ) . ' was used to unlock content on ' . get_permalink( $post_id );
// Now we can send the e-mail.
@patrickposner
patrickposner / functions.php
Created March 25, 2022 13:02
Passster: Send e-mail one day before password expires.
<?php
add_action( 'passster_compare_expiration_date', function( $password, $difference, $password_list_id ) {
if ( $difference == 1 ) {
// prepare and send the e-mail.
$to = '[email protected]';
$subject = 'Password ' . $password . 'was used';
$headers = array( 'Content-Type: text/html; charset=UTF-8' );
$body = 'Password ' . $password . ' form passwords list ' . $password_list_id . ' will expire tomorrow';
@patrickposner
patrickposner / functions.php
Created March 15, 2022 10:30
FILR disallow additional file types for the upload
<?php
add_filter('filr_disallowed_file_extensions', function( $extensions ) {
// Extensions contains an array by default which looks like this: array( 'htaccess', 'php', 'php3', 'php4', 'php5', 'phtml' ).
// Lets exclude HTML files here.
$extensions[] = 'html';
return $extensions;
});
@patrickposner
patrickposner / functions.php
Last active September 1, 2022 13:20
Simply Static - GitHub Webhook with webhook event
<?php
add_filter( 'ssp_webhook_args', function( $args ) {
// Get access token.
$options = get_option( 'simply-static' );
$access_token = $options['github-personal-access-token'];
// Setup body.
$body = array(
'event_type' => 'repository_dispatch',
@patrickposner
patrickposner / functions.php
Created March 9, 2022 10:33
Simply Static - GitHub send Webhook with Authentication
<?php
add_filter( 'ssp_webhook_args', function( $args ) {
// Get access token.
$options = get_option( 'simply-static' );
$acccess_token = $options['github-personal-access-token'];
// Modify arguments for POST request.
$args = array(
'headers' => array(
@patrickposner
patrickposner / functions.php
Created March 8, 2022 09:01
Restrict FILR file download link with Passster cookie
<?php
add_action( 'filr_allow_file_access', function( $file_id ) {
$access = $_COOKIE['passster'];
if ( ! isset( $access ) || empty( $access ) ) {
exit;
}
});
<?php
namespace sshm;
/**
* Class to handle Lemon_Squeezy.
*/
class Lemon_Squeezy {
/**
* Contains instance or null
@patrickposner
patrickposner / functions.php
Created January 26, 2022 16:01
Passster - Track password usages.
<?php
add_action( 'passster_validation_success', function( $password ) {
// Here you can save user meta or add the data to a new table.
});