Skip to content

Instantly share code, notes, and snippets.

View dexit's full-sized avatar
🎯
Focusing

Rihards Mantejs dexit

🎯
Focusing
View GitHub Profile
@dexit
dexit / gw-gravity-forms-choice-counter.php
Created September 9, 2020 12:56 — forked from spivurno/gw-gravity-forms-choice-counter.php
Gravity Wiz // Gravity Forms // Choice Counter
<?php
/**
* Gravity Wiz // Gravity Forms // Choice Counter
*
* Get the total number of checkboxes checked or multi-select options selected. Useful when wanting to apply conditional
* logic based on those totals.
*
* @version 1.0
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+
<?php
/**
* Gravity Perks // Media Library // Set Upload Directory
* http://gravitywiz.com/documentation/gravity-forms-media-library/
*/
add_filter( 'gpml_media_data', function( $return ) {
add_filter( 'upload_dir', 'gpml_set_upload_dir' );
if( ! function_exists( 'gpml_set_upload_dir' ) ) {
function gpml_set_upload_dir( $upload_dir ) {
$upload_dir['path'] = ABSPATH . 'wp-content/uploads/paramountregistry';
/**
* Gravity Perks // Pay Per Word // Surprise, Pay Per Character!
* https://gravitywiz.com/documentation/gravity-forms-pay-per-word/
*/
gform.addFilter( 'gpppw_word_count', function( wordCount, text, gwppw, ppwField, formId ) {
// Pay per character instead of words.
var words = text.split( '' );
return words == null ? 0 : words.length;
} );
<?php
/**
* Gravity Wiz // Gravity Forms // Email Header to Identify Notification Source
*
* You've installed Gravity Forms on a ton of sites and now you're getting a ton of notifications. The problem is there
* is no clear indicator which site is sending the notification. How frustrating!
*
* This simple plugin automatically adds a custom header that identifies the URL that generated the Gravity Forms notification.
* This is most useful when installed as an MU plugin at the start of development on each site.
*
@dexit
dexit / allow-users-to-view-network.php
Created September 9, 2020 12:58 — forked from ronalfy/allow-users-to-view-network.php
WP Force Login - Multisite - Allow All Logged In Users to View Network
<?php
/*
* Multisite for https://wordpress.org/plugins/wp-force-login/
* Allows all users of the network to view all sites and posts on the network
* Intended to be used as an mu-plugin
*/
add_action( 'template_redirect', function() {
if ( is_user_logged_in() ) {
remove_action('template_redirect', 'v_forcelogin');
}
@dexit
dexit / gravity-forms-gtm.php
Created September 9, 2020 12:58 — forked from ronalfy/gravity-forms-gtm.php
Google Tag Manager for Gravity Forms
<?php
add_action( 'gform_after_submission', 'braums_after_submission', 10, 2 );
function braums_after_submission( $entry, $form ) {
?>
<script>
function braums_datalayer_push() {
var form_submission = sessionStorage.getItem('entry_<?php echo absint( $entry[ 'id' ] ); ?>');
if ( null == form_submission ) {
if ( typeof( dataLayer ) != 'undefined' ) {
dataLayer.push({'event': 'BWTrackEvent',
@dexit
dexit / cpt-template-init.php
Created September 9, 2020 12:59 — forked from ronalfy/cpt-template-init.php
Custom Post Types Template Init
<?php
public function init() {
add_action( 'add_meta_boxes', array( &$this, 'register_meta_boxes' ) );
$labels = array(
'name' => 'Galleries',
'singular_name' => 'Gallery',
'menu_name' => 'Galleries',
'name_admin_bar' => 'Galleries',
'add_new' => 'Add New',
'add_new_item' => 'Add New Gallery',
<?php
add_filter( 'gform_form_post_get_meta', __NAMESPACE__ . '\\enforce_gravity_forms_anti_spam_honeypot' );
/**
* Enforce anti-spam honeypot on all Gravity forms.
*
* @param array $form The current form to be filtered.
*
* @return array
*/
<script>
(function( $ ) {
$( '.et_pb_toggle' ).hover(function() {
$( this ).children( 'h5' ).trigger( 'click' );
});
})( jQuery );
</script>
#
# Required: Py3+, pip maildir2mbox
# Cpanel dovecot maildir to mbox converting on windows
$table = Get-ChildItem -Path "PATH TO MAILDIR ROOT" -Recurse -Directory -Include .* -Force -ErrorAction SilentlyContinue | Select-Object FullName, Name
foreach ($row in $table)
{
# Assuming that you want to dump it on C drive each folder as its own MBOX file
python -m maildir2mbox $($row.FullName) "C:\$($row.Name.substring(1)).mbox"
}