This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Drush policies to restrict what is allowed for certain drush commands. | |
*/ | |
/** | |
* Prevent production databases from being overwritten using drush sql-sync. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* PLUPLOAD example form to showcase plupload. | |
*/ | |
function MYMODULE_some_cool_form() { | |
$form['file_upload'] = array( | |
'#type' => 'plupload', | |
'#title' => t('Upload Files'), | |
'#required' => TRUE, | |
'#description' => t('Allowed file extensions: doc docx pdf tif tiff xls xlsx'), | |
'#upload_validators' => array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_page_alter(). | |
* | |
* We want to provide more detail to New Relic on the transaction and late in | |
* the page build seemed like the simplest place. | |
*/ | |
function MYMODULE_page_alter(&$page) { | |
if (!extension_loaded('newrelic')) { | |
return; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
// Declare the theme function. | |
Drupal.theme.prototype.projectTeaser = function(image_url, title, url) { | |
return '<div class="teaser"><img class="teaser--image" src="' + image_url + '" /><h2 class="teaser--title">' + title + '</h2><a class="teaser--link" href="' + url +'">View Project</a>'; | |
} | |
Drupal.behaviors.gtpePurchaseOrder = { | |
attach: function (context, settings) { | |
// Call the theme function like so. It should return themed markup. | |
var teaser = Drupal.theme('projectTeaser', 'http://placehold.it/300x300', 'I did this fancy stuff', 'http://npr.org'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Filter out array keys that aren't numeric. | |
$lid_keys = array_filter(array_keys($values), function ($k) { | |
return is_numeric($k); | |
}); | |
$lid_values = array_intersect_key($values, array_flip($lid_keys)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* https://www.drupal.org/node/1966736#comment-8792051 | |
*/ | |
<?php | |
$per_page = 10; | |
// Initialize the pager | |
$current_page = pager_default_initialize(count($rows), $per_page); | |
// Split your list into page sized chunks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// https://steindom.com/articles/exporting-and-creating-field-definitions-drupal-7 | |
$entity_type = 'node'; | |
$field_name = 'field_name'; | |
$bundle_name = 'content_type'; | |
$info_config = field_info_field($field_name); | |
$info_instance = field_info_instance($entity_type, $field_name, $bundle_name); | |
unset($info_config['id']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_page_alter(). | |
*/ | |
function mymodule_page_alter(&$page) { | |
if (!extension_loaded('newrelic')) { | |
return; | |
} | |
$name = NULL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Apply redirect from old content to new content. | |
$old_alias = 'some/old/path'; | |
$new_alias = 'node/' . $node->nid; | |
$redirect = new stdClass(); | |
redirect_object_prepare($redirect); | |
$redirect->source = $old_alias; | |
$redirect->redirect = $new_alias; | |
redirect_save($redirect); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input.form-submit.button-small { | |
padding: 4px 8px; | |
font-weight: bold; | |
} | |
.container-inline input.form-submit.button-small + .ajax-progress.ajax-progress-throbber .throbber { | |
position: absolute; | |
left: 19px; | |
margin-top: 7px; | |
} |