Skip to content

Instantly share code, notes, and snippets.

View drinkmaker's full-sized avatar
🏠
Working from home

Alexander Khmelnitskiy drinkmaker

🏠
Working from home
View GitHub Profile
@stianandreassen
stianandreassen / acf_wysiwyg_height.php
Last active March 4, 2025 09:16
Add a height field to ACF WYSIWYG Field
<?php
/**
* Add height field to ACF WYSIWYG
*/
function wysiwyg_render_field_settings( $field ) {
acf_render_field_setting( $field, array(
'label' => __('Height of Editor'),
'instructions' => __('Height of Editor after Init'),
'name' => 'wysiwyg_height',
'type' => 'number',
@jeromecoupe
jeromecoupe / webstoemp-gulpfile.js
Last active May 13, 2025 15:54
Gulp 4 sample gulpfile.js. For a full explanation, have a look at https://www.webstoemp.com/blog/switching-to-gulp4/
"use strict";
// Load plugins
const autoprefixer = require("autoprefixer");
const browsersync = require("browser-sync").create();
const cp = require("child_process");
const cssnano = require("cssnano");
const del = require("del");
const eslint = require("gulp-eslint");
const gulp = require("gulp");
@igorbenic
igorbenic / add_metabox.php
Last active February 26, 2025 20:47
How to use the WordPress Code Editor in your Plugins or Themes | https://www.ibenic.com/wordpress-code-editor
<?php
add_action( 'add_meta_boxes', 'add_page_scripts' );
/**
* Register the metabox
*/
function add_page_scripts() {
add_meta_box( 'page-scripts', __( 'Page Scripts & Styles', 'textdomain' ), 'add_page_metabox_scripts_html', 'page', 'advanced' );
}
@anonyco
anonyco / CodeMirror.Destroy().js
Created July 30, 2018 02:26
A Destroy Method On All CodeMirror Objects To Ensure Garbage Collection
if (!CodeMirror.prototype.destroy) (function(){
// A destroy extension. Absolutely positively beyond a shadow of a doubt obliterate a CodeMirror instance from memory.
function hasExclusion(stringArr, regexpArr){
return function(exclusion){
var iSA = stringArr.length, cur = null, iEL = 0, iC = 0, iRA = regexpArr.length;
if (isRegExp(exclusion)){
while (iRA--)
if (regexpArr[iRA].source === exclusion.source && regexpArr[iRA].flags === exclusion.flags)
return iRA;
} else {
@webmandesign
webmandesign / gutenberg-wide-alignement-wrapper.php
Last active September 9, 2020 17:14
Wrapping aligned Gutenberg blocks with additional div on a WordPress website front-end.
<?php
// IMPORTANT UPDATE 20190307:
// Since WordPress 5.0.0 we can actually use much simpler solution:
/**
* Applies wrapper div around aligned blocks.
*
* Copy this function into your WordPress theme's `functions.php` file
* and change the `themeprefix` accordingly.
@bacoords
bacoords / scrub-smart-quotes.php
Created February 21, 2019 21:35
Replaces smart quotes with quotation marks when adding shortcodes to WordPress content
/**
* Scrubs content for curly quotes
* @param string $content
* @return string
*/
function prefix_scrub_smart_quotes_from_shortcodes( $content ){
// Search for all smartquotes inside of shortcodes and replace them
$content = preg_replace('/(“|”)(?=[^\[]*\])/', '"', $content );
@iqbalrony
iqbalrony / wp-custom-reset-password-form.php
Last active September 27, 2024 16:27
WordPress custom reset password form
<?php
/*
*Example Follw:-https://code.tutsplus.com/tutorials/build-a-custom-wordpress-user-flow-part-3-password-reset--cms-23811
*/
// Create the custom pages at plugin activation
register_activation_hook( __FILE__, 'dgm_plugin_activated' );
function dgm_plugin_activated() {
// Information needed for creating the plugin's pages
$page_definitions = array(
@edlefebvre
edlefebvre / fragment-caching.php
Created October 8, 2019 13:27
Fragment caching function
<?php
/**
* Fragment caching function
* see: https://css-tricks.com/wordpress-fragment-caching-revisited/
*
* Usage:
* <?php fragment_cache('frc_footer', DAY_IN_SECONDS, function() { ?>
* code to cache (loops etc)
* <?php }); // end fragment_cache ?>
*/
@TimothyBJacobs
TimothyBJacobs / .env
Created December 19, 2019 03:18
Testing WordPress Plugins with Codeception on Bitbucket Pipelines using Docker Compose
DB_PORT=9119
WP_PORT=7253
WP_TAG=latest
@digisavvy
digisavvy / Is current page using Elementor?
Created May 28, 2020 01:00
A simple check if the current page is using ELementor
<?php // Do not include this line.
$post_id = get_the_ID(); // Set post ID var.
if ( Elementor\Plugin::instance()->db->is_built_with_elementor( $post_id ) ) {
echo 'fuck yeah it is!';
}