This file contains 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
/** | |
* Get an RSS pubDate from a Javascript Date instance. | |
* @param Date - optional | |
* @return String | |
*/ | |
function pubDate(date) { | |
if (typeof date === 'undefined') { | |
date = new Date(); | |
} |
This file contains 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
/** | |
* Returns the number rounded to the nearest interval. | |
* Example: | |
* | |
* roundToNearest(80, 100); // 100 | |
* roundToNearest(25, 15); // 30 | |
* | |
* @param {number} value The number to round | |
* @param {number} interval The numeric interval to round to | |
* @return {number} |
This file contains 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
var randomBgHex = '#' + ('000000' + Math.floor(Math.random()*16777215).toString(16)).slice(-6); |
This file contains 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 | |
// Drupal 7.22 | |
// If there's an easier way please let me know | |
/** | |
* Swap out a form error message. | |
* | |
* This must be done with the actual message comparison since error keys | |
* are not stored in drupal messages. | |
* |
This file contains 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
/** | |
* Get an array of users for a given role id. | |
* @param int $rid - The role id | |
* @return array | |
*/ | |
function users_by_role_id($rid) | |
{ | |
$users = array(); | |
$uids = array(); | |
$query = db_query("SELECT uid FROM users_roles WHERE rid = :role_id", array(':role_id' => $rid)); |
This file contains 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
/** | |
* Returns the simple, cleaned, translated value for a node or user field | |
* without extra Drupal markup. | |
* | |
* Examples: | |
* <?php print render_entity_field('user', $user, 'field_first_name'); ?> | |
* <?php print render_entity_field('node', $node, 'field_my_custom_field'); ?> | |
* | |
* @see http://www.computerminds.co.uk/articles/rendering-drupal-7-fields-right-way | |
* @param string $type 'node', 'user' |
This file contains 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
/** | |
* Returns the simple, cleaned, translated value for a node or user field | |
* without extra Drupal markup. | |
* | |
* Examples: | |
* <?php print render_entity_field('user', $user, 'field_first_name'); ?> | |
* <?php print render_entity_field('node', $node, 'field_my_custom_field'); ?> | |
* | |
* @see http://www.computerminds.co.uk/articles/rendering-drupal-7-fields-right-way | |
* @param string $type 'node', 'user' |
This file contains 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
/** | |
* Returns the simple, cleaned, translated value for a node or user field | |
* without extra Drupal markup. | |
* | |
* Examples: | |
* <?php print render_entity_field('user', $user, 'field_first_name'); ?> | |
* <?php print render_entity_field('node', $node, 'field_my_custom_field'); ?> | |
* | |
* @see http://www.computerminds.co.uk/articles/rendering-drupal-7-fields-right-way | |
* @param string $type 'node', 'user' |
This file contains 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 | |
/** | |
* NOTE: This gist is very old. You might want to check out recent forks | |
* like this one: https://github.com/Alexlytle/Wordpress_custom_route/blob/main/Wordpress_Custom_route.php | |
* (thanks @Alexlytle) If you have an improvement to this gist, please | |
* post a link in a comment for others who might benefit. Thanks! | |
* | |
* A class to create simple custom routes. | |
* |
This file contains 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
{% if entry is defined and currentUser and currentUser.can('editEntries:' ~ entry.id) %} | |
<a href="{{ entry.cpEditUrl }}" class="edit-this section-{{ entry.sectionId }}">Edit this</a> | |
{% endif %} |
OlderNewer