Skip to content

Instantly share code, notes, and snippets.

View derweili's full-sized avatar

Julian Weiland derweili

  • Germany
  • 00:51 (UTC +01:00)
View GitHub Profile
@derweili
derweili / removeStylesFromHtmlMarkup.php
Created January 25, 2024 16:35
removeStylesFromHtmlMarkup.php
function removeStylesFromHtmlMarkup($markup) {
function removeElementsByTagName($tagName, $document) {
$nodeList = $document->getElementsByTagName($tagName);
for ($nodeIdx = $nodeList->length; --$nodeIdx >= 0; ) {
$node = $nodeList->item($nodeIdx);
$node->parentNode->removeChild($node);
}
}
@derweili
derweili / wp-share-a-draft-cpt-support.php
Last active January 28, 2022 09:51
WordPress Share a Draft Custom Post Type Support
<?php
/**
* Plugin Name: Share A Draft Helper
* Plugin URI: derweili.de
* Description: Add Custom Post Type Support to the Share A Draft Plugin
* Author: derweili
* Author URI: derweili.de
* Text Domain: share-a-draft-helper
* Domain Path: /languages
* Version: 0.1.0
mkdir ~/bin
mkdir ~/bin/wp-cli
cd ~/bin/wp-cli
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
echo "export COLUMNS" >> ~/.bashrc
echo "alias wp='php ~/bin/wp-cli/wp-cli.phar'" >> ~/.bashrc
echo "alias php='/usr/bin/php'" >> ~/.bashrc
source ~/.bashrc
echo "PATH=$HOME/bin:$PATH" >> ~/.bashrc
@derweili
derweili / cdn-enabler-cachify-compatibility.php
Created June 8, 2021 14:01
Add Cachify compatibility to CDN Enabler
remove_action( 'setup_theme', array( 'CDN_Enabler_Engine', 'start' ) );
add_action( 'template_redirect', array( 'CDN_Enabler_Engine', 'start' ), 20 );
@derweili
derweili / template-specific-editor-styles.js
Created February 17, 2020 10:55
Page Template specific editor styles for the WordPress Block Editor (Gutenberg)
const {
subscribe,
select
} = wp.data;
/**
* Add dark-mode class to block-editor based on selected page template
*/
wp.domReady( () => {
const postType = select( 'core/editor' ).getCurrentPostType();
@derweili
derweili / block-string-list-block.js
Created July 24, 2019 09:41
Example Gutenberg Block with array attribute
/**
* BLOCK: string-list-block
*
* Registering a basic block with Gutenberg.
* Simple block, renders and saves the same content without any interactivity.
*/
// Import CSS.
import './style.scss';
import './editor.scss';
@derweili
derweili / disable-acf-blocks-on-edit.js
Last active April 29, 2022 17:09
Disable Links in ACF Block-Edit Method
/*
* Wrap all ACF Blocks in Disabled block to disable all links in edit view
*/
const { createHigherOrderComponent } = wp.compose;
const { Fragment } = wp.element;
import { Disabled } from '@wordpress/components';
const withDisabledCompontent = createHigherOrderComponent( ( BlockEdit ) => {
return ( props ) => {
@derweili
derweili / social-share.php
Created February 12, 2019 09:38
WordPress Social Share Link
<?php
function get_shared_base_url(){
if( is_single() || is_page() ){
return get_permalink( get_the_id() );
}else{
global $wp;
$current_url = home_url(add_query_arg(array(),$wp->request));
return $current_url;
}
@derweili
derweili / wordpress-plugin-svn-to-git.md
Created March 2, 2018 14:23 — forked from kasparsd/wordpress-plugin-svn-to-git.md
Using Git with Subversion Mirroring for WordPress Plugin Development
@derweili
derweili / brew.log
Created February 22, 2018 10:14
Brew Log
d