Skip to content

Instantly share code, notes, and snippets.

View thisbit's full-sized avatar

thisbit thisbit

View GitHub Profile
View duplicate_posts.php
<?php
/*
Duplicate Posts and Pages
Description: slightly modified wpcb repo snippet
*/
// Security
if ( ! defined( 'ABSPATH' ) ) : exit; endif;
function apuri_duplicate_post_as_draft(){
@thisbit
thisbit / cardWithModal.json
Created July 21, 2023 20:01
Builderius modal in a card
View cardWithModal.json
{"modules":{"u8488fbe2d":{"id":"u8488fbe2d","name":"HtmlElement","label":"article","settings":[{"name":"borderRadius","value":{"all":{"original":{"a1":"12","a2":"12","a3":"12","a4":"12","b1":"px","b2":"px","b3":"px","b4":"px"}}}},{"name":"border","value":{"all":{"original":{"d1":"#959595","c1":"dashed","d2":"#959595","b1":"px","c2":"dashed","d3":"#959595","b2":"px","c3":"dashed","d4":"#959595","a1":"3","b3":"px","c4":"dashed","a2":"3","b4":"px","a3":"3","a4":"3"}}}},{"name":"padding","value":{"all":{"original":{"a1":"2","a2":"2","a3":"2","a4":"2","b1":"rem","b2":"rem","b3":"rem","b4":"rem"}}}},{"name":"maxWidth","value":{"all":{"original":{"a1":"20","b1":"ch"}}}},{"name":"margin","value":{"all":{"original":{"b4":"auto","b2":"auto","a1":"2","b1":"rem","a3":"2","b3":"rem"}}}},{"name":"htmlElementTag","value":{"a1":"article"}},{"name":"isLinkWrapper","value":{"a1":false}}],"parent":""},"u75d9743bc":{"id":"u75d9743bc","name":"HtmlElement","label":"div","settings":[{"name":"gap","value":{"all":{"original":{"a1":"1
@thisbit
thisbit / googleSheetsEndpoint.js
Created July 15, 2023 07:51
Google Sheets as JSON, use this with Extensions > App Script in google sheets
View googleSheetsEndpoint.js
function getSheetDataAsJSON() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var range = sheet.getDataRange();
var values = range.getValues();
var headers = values[0];
var jsonData = [];
for (var i = 1; i < values.length; i++) {
var row = values[i];
var rowObj = {};
@thisbit
thisbit / email-obuscation.php
Created July 12, 2023 18:23
Old school email obfuscation
View email-obuscation.php
<?php
// Security
if ( ! defined( 'ABSPATH' ) ) : exit; endif;
function publication_email_link() {
global $post;
$title = get_the_title($post->ID);
$link = get_the_permalink($post->ID);
@thisbit
thisbit / sticky-accordions.css
Created June 28, 2023 10:44
Open generateblocks accordions when item becomes sticky
View sticky-accordions.css
.gb-accordion .gb-button {
position: sticky;
top: 100px;
z-index: 5;
background-color: var(--base);
}
.admin-bar .gb-accordion .gb-button {
top: 132px;
}
@thisbit
thisbit / html_cleanup_with_regexp.any
Created June 10, 2023 11:04
Regular Expression written with the use of ChatGPT to clean up html
View html_cleanup_with_regexp.any
<style\b[^<]*>[\s\S]*?<\/style\b[^<]*>|<((?!(?:a|h[1-6]|p|strong|em|img|span)\b)\w+[^>]*)>|<\/?(?:div|section|link|span)\b[^>]*>|class\s*=\s*"[^"]*"|id\s*=\s*"[^"]*"|style\s*=\s*"[^"]*"|data-[^=]+="[^"]*"|\s+$|\t|&nbsp;|<\w+\b[^>]*><\/\w+\b[^>]*>|<\w+\b[^>]*><\/\w+\b[^>]*>\s*|<\/span>
@thisbit
thisbit / remove_wpbakery_enfold_shortcodes.php
Last active June 11, 2023 01:47
Remove WP Bakery / Enfold (Avia Builder) shortcodes from the post on clicking update/save
View remove_wpbakery_enfold_shortcodes.php
<?php
function remove_shortcodes_from_post_content($content) {
// Define the pattern to match the shortcodes
$pattern = '/\[(\/)?(vc_|av_)[^\]]*\]/';
// Remove the shortcodes from the content using preg_replace
$clean_content = preg_replace($pattern, '', $content);
return $clean_content;
@thisbit
thisbit / gb-accordion-custom.js
Created June 9, 2023 08:50
Removing Default GenerateBlocks Accordion (variation on container) and creating my own Variant with predefined settings and styles
View gb-accordion-custom.js
// this file is a part of learning process so this file will be changed as I learn stuff :)
const iconAttributes = {
iconLocation: 'right',
columnGap: '0.5em',
iconSize: 0.8,
iconPaddingRight: '',
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
sizing: { width: '100%' },
@thisbit
thisbit / overlay.css
Last active June 5, 2023 20:13
Popupt that opens 5.5 seconds after load, and its removal gets stored in the cookie
View overlay.css
.overlay {
transform: scale(0);
}
.overlay.show {
transform: scale(1);
}
.overlay.show.not {
transform: scale(0);
}
@thisbit
thisbit / acf_postobject_controls_gb_query.php
Last active May 12, 2023 13:38
This is so clients can order manipulate query block output manually including the orderby
View acf_postobject_controls_gb_query.php
<?php
// remove the top function it is used only to inspect the array so one can figure it out
function apuri_get_your_elements() {
$post_obs = get_field('front_posts');
?>
<pre style="min-height: 100vh; display: flex; flex-direction: column; align-items: flex-start; text-align: left;">
<h2 style="margin-top: 90px" >Check the array content</h2>