Skip to content

Instantly share code, notes, and snippets.

View lunule's full-sized avatar

lunule lunule

  • Vigilante One
  • Brno
View GitHub Profile
@lunule
lunule / wp--custom-fields--media-attachment-edit.php
Created May 25, 2023 16:59
[WordPress - Custom Field for Media/Attachment Edit Screen] #wp #core #custom-fields #meta #post-meta #media #attachment #credit #caption
<?php
/**
* This code base adds a custom media field named Image Credit.
*
* This example saves the value of the custom field on the media overlay
* screen via ajax, as well as the media edit screen (non ajax).
*
* Added nonce check and sanitization.
*
* TO-DO - this custom functionality and the various hooks it's based on is
@lunule
lunule / shell-setup.ps1
Created May 11, 2023 22:07 — forked from mikepruett3/shell-setup.ps1
Packages to install via scoop, winget, choco, and other tools...
<#
.SYNOPSIS
Script to Initialize my custom powershell setup.
.DESCRIPTION
Script uses scoop
.NOTES
**NOTE** Will configure the Execution Policy for the "CurrentUser" to Unrestricted.
Author: Mike Pruett
Date: October 18th, 2018
@lunule
lunule / membership_meta.php
Created September 6, 2022 19:47 — forked from saltnpixels/membership_meta.php
adding membership meta to rcp from ACF
<?php
/*--------------------------------------------------------------
# Saving Features to Membership Levels from an acf repeater field for RCP Pro
--------------------------------------------------------------*/
function some_feature_list( $level ) {
/**
* @var RCP_Levels $rcp_levels_db
*/
global $rcp_levels_db;
@lunule
lunule / wp-custom-excerpt--max-char.php
Last active August 10, 2022 16:09
[WP Core - Custom Excerpt with Max Chars] #wp #wordpress #core #excerpt #char #chars #character #characters
<?php
function wp_custom_excerpt_maxchar( $excerpt, $maxchar ) {
// If $maxchar is numeric and its numeric value is a positive integer, echo the trimmed excerpt.
// Otherwise return the untrimmed-but-stripped version.
$excerpt = (
is_numeric( $maxchar ) &&
( 0 < intval($maxchar) )
) ? mb_substr(
wp_strip_all_tags( $excerpt ),
@lunule
lunule / linkedin-bulk-unfollow.js
Last active July 29, 2022 17:22
[LinkedIn - Bulk Unfollow Script]
(() => {
let count = 0;
function getAllButtons() {
return document.querySelectorAll('button.is-following') || [];
}
async function unfollowAll() {
const buttons = getAllButtons();
for (let button of buttons) {
count = count + 1;
@lunule
lunule / wp_image_quality_reset.php
Created June 7, 2021 04:59
[WordPress - Reset Default Image Quality to 100%] #wordpress #wp #images #quality
<?php
/**
* Filters the image quality for thumbnails to be at the highest ratio possible.
*
* Supports the new 'wp_editor_set_quality' filter added in WP 3.5.
*
* @since 1.0.0
*
* @param int $quality The default quality (90)
* @return int $quality Amended quality (100)
@lunule
lunule / php_slugify.php
Last active June 7, 2021 00:22
[PHP - Slugify] #php
<?php
/**
* Helper function to slugify strings
* ----------------------------------
*
* @param string $text input string
* @param string $divider divider character
* @return string $text slugified string
*/
function slugify(string $text, string $divider = '-') {
@lunule
lunule / gforms-prevent-form-from-disappearing-after-ajax-submit.js
Last active May 23, 2021 00:17
[Gravity Forms - Prevent form from disappearing after AJAX form submission] #gravity #ajax
jQuery(document).ready(function($) {
const removeConfirmation = function( $thisForm ) {
console.log( $thisForm );
$thisForm.siblings('.gform_confirmation_wrapper').fadeOut(function() {
$(this).remove();
});
@lunule
lunule / jquery-detect-css3-animations-and-transitions-end.js
Last active May 29, 2023 17:12
[jQuery - Detect CSS3 Animations & Transitions End] #jquery #animation #transition #css #javascript
/**
* Using jQuery to Detect When CSS3 Animations and Transitions End
* @see https://blog.teamtreehouse.com/using-jquery-to-detect-when-css3-animations-and-transitions-end
*/
jQuery(document).ready(function($) {
'use strict';
const myButton = $('.my-button'),
@lunule
lunule / wp_list_post_types.php
Last active April 11, 2021 19:06
[WP - List Post Types] #post-types #wordpress #wp #core
<?php
function keto_list_post_types() {
$args = array(
'public' => true,
'_builtin' => false
);
$output = 'names'; // 'names' or 'objects' (default: 'names')