Skip to content

Instantly share code, notes, and snippets.

View delaBruyne's full-sized avatar

Laetitia Debruyne delaBruyne

View GitHub Profile
@gmmedia
gmmedia / functions.php
Last active January 17, 2024 13:56
Enable Gutenberg editor for WooCommerce
<?php
// Find the description at https://bloggerpilot.com/en/gutenberg-for-woocommerce/
// Disable new WooCommerce product template (from Version 7.7.0)
function bp_reset_product_template($post_type_args) {
if (array_key_exists('template', $post_type_args)) {
unset($post_type_args['template']);
}
return $post_type_args;
}
@jhedstrom
jhedstrom / FeatureContext.php
Created July 30, 2015 20:01
Organic Groups Behat step-definition examples
<?php
/**
* @Given /^I am logged in as a user in the "(?P<group>[^"]*)" group$/
*/
public function iAmLoggedInAsAUserInTheGroup($group) {
// Create user.
$account = (object) array(
'pass' => $this->getDrupal()->random->name(),
'name' => $this->getDrupal()->random->name(),
);
@IslandUsurper
IslandUsurper / gist:12723643dddc9315ff71
Created March 10, 2015 18:50
Behat Step to select an autocomplete suggestion
<?php
use Behat\Mink\Extension\ElementNotFoundException;
use Drupal\DrupalExtension\Context\DrupalContext;
class FeatureContext extends DrupalContext {
/**
* @When I select the first autocomplete option for :prefix on the :field field
*/
@salcode
salcode / .gitignore
Last active July 10, 2024 14:28
Please see https://salferrarello.com/wordpress-gitignore/ for the canonical version of this WordPress .gitignore file. Note: I do not receive notifications for comments here (because GitHub does not send notifications on Gists)
# -----------------------------------------------------------------
# .gitignore for WordPress @salcode
# ver 20180808
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/salcode/b515f520d3f8207ecd04/raw/.gitignore
# to download this file
#
# By default all files are ignored. You'll need to whitelist
# any mu-plugins, plugins, or themes you want to include in the repo.
@imath
imath / bp-custom.php
Created January 29, 2015 19:06
Code Snippet to put in your bp-custom.php file to be able to filter the BuddyPress members directory by member types (requires BuddyPress version 2.2-beta1)
<?php
/**
* Using BuddyPress Member types API
*
* see codex: https://codex.buddypress.org/developer/member-types/
*
* Required config:
* - WordPress 4.1
* - BuddyPress 2.2
*
@eliza411
eliza411 / gist:67d2aa93cfa9a31b65ad
Created December 6, 2014 17:40
Behat step for Drupal batch-api support
<?php
/**
* @Given /^I follow meta refresh$/
*/
public function iFollowMetaRefresh() {
while ($refresh = $this->getMainContext()->getSession()->getPage()->find('css', 'meta[http-equiv="Refresh"]')) {
$content = $refresh->getAttribute('content');
$url = str_replace('0; URL=', '', $content);
$this->getMainContext()->getSession()->visit($url);
}
@pbuyle
pbuyle / MODULE.install.php
Last active November 9, 2022 18:19
Drupal - Migrate existing field content from language "undefined" to entity language in a single hook_update_N() implementation.
<?php
/**
* Migrate existing field content from language "undefined" to entity language.
*/
function MODULE_update_N(&$sandbox) {
// Number of entities to be processed for each step.
$messages = array();
if (!isset($sandbox['fields'])) {
// Initialize the array of field to process.
@chrisvanpatten
chrisvanpatten / custom-tinymce-0.php
Last active October 18, 2016 16:03
Register custom style formats to TinyMCE in WordPress
<?php
/**
* custom_tinymce
*/
function vpm_custom_tinymce( $settings ) {
// Define our custom formats
$style_formats = array(
array(
@spivurno
spivurno / gw-gravity-forms-minimum-characters.php
Last active December 28, 2022 09:17
Gravity Wiz // Require Minimum Character Limit for Gravity Forms
<?php
/**
* WARNING! THIS SNIPPET MAY BE OUTDATED.
* The latest version of this snippet can be found in the Gravity Wiz Snippet Library:
* https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-min-and-max-character-limit.php
*/
/**
* Gravity Wiz // Require Minimum Character Limit for Gravity Forms
*
* Adds support for requiring a minimum number of characters for text-based Gravity Form fields.
@pbuyle
pbuyle / FeatureContext.php
Last active January 25, 2024 23:25
Behat step-definition to verify visibility (not just presence) of Drupal form elements.
<?php
use Behat\Behat\Context\ClosuredContextInterface,
Behat\Behat\Context\TranslatedContextInterface,
Behat\Behat\Context\BehatContext,
Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode,
Behat\Gherkin\Node\TableNode;
/**