Skip to content

Instantly share code, notes, and snippets.

@LittleCoding
LittleCoding / myproject.es6.js
Last active August 30, 2023 12:51
Basic jQuery independent ES6 JS for Drupal 9.2+ project (module, theme)
/**
* @file
* Behaviors for My Project.
*/
((Drupal, settings, once) => {
/**
* Holds functions, methods, settings and other information for My Project.
*
* @namespace
@LittleCoding
LittleCoding / myproject.es6.js
Created November 10, 2021 21:05
Basic ES6 JS for Drupal 8/9 project (module, theme)
(($, Drupal, settings) => {
Drupal.myproject = {
preInit(context) {},
init(settings) {},
postInit() {},
};
Drupal.behaviors.myproject = {
attach(context, settings) {
// DOM loaded
Drupal.myproject.preInit(context);
@LittleCoding
LittleCoding / myproject.js
Created November 3, 2021 18:46
Basic JS for Drupal 8/9 project (module, theme)
window.Drupal = window.Drupal || { behaviors: {}, locale: {} };
(function ($, Drupal, settings) {
'use strict';
Drupal.myproject = {
preInit: function() {},
init: function(settings) {},
postInit: function() {}
@LittleCoding
LittleCoding / ApacheHTTPSConfig.md
Last active June 12, 2018 15:16 — forked from nrollr/ApacheHTTPSConfig.md
Enable SSL in Apache for 'localhost' (macOS, High Sierra)

Enable SSL in Apache (OSX)

The following will guide you through the process of enabling SSL on a Apache webserver

  • The instructions have been verified with macOS High Sierra (10.13.4) running Apache 2.4.29
  • The instructions assume you already have a basic Apache configuration enabled on OSX, if this is not the case feel free to consult Gist: "Enable Apache HTTP server (OSX)"

Apache SSL Configuration

Create a directory within /etc/apache2/ using Terminal.app: sudo mkdir /etc/apache2/ssl
Next, generate two host keys:

@LittleCoding
LittleCoding / functions.admin_bar_menu.dev_branding_in_wp_logo_menu.php
Created June 4, 2018 16:29
Add company link to the WordPress logo menu.
<?php
/**
* code to be placed in theme functions.php
* add_filter priority of 10 or greater.
*/
if ( ! function_exists( 'mytheme_admin_bar_menu' ) ) {
function mytheme_admin_bar_menu( $wp_admin_bar ) {
$wp_admin_bar->add_node( array(
'parent' => 'wp-logo-external',
@LittleCoding
LittleCoding / functions.admin_bar_menu.site_name_menu.php
Created January 30, 2018 16:59
Change "Site Name" menu in WordPress administration menu bar
<?php
/**
* code to be placed in theme functions.php
* Default behavior is to ellipse $blogname at 40 characters.
* add_filter priority of 30 or greater.
*/
if ( ! function_exists( 'mytheme_admin_bar_menu' ) ) {
function mytheme_admin_bar_menu( $wp_admin_bar ) {
$site_name = (object) $wp_admin_bar->get_node( 'site-name' );
@LittleCoding
LittleCoding / functions.admin_bar_menu.template_name.php
Last active January 30, 2018 17:00
Display current template filename in WordPress administration menu bar
<?php
/**
* code to be placed in theme functions.php
* add_filter priority of 200 or greater to display last.
*/
if ( ! function_exists( 'mytheme_admin_bar_menu' ) ) {
function mytheme_admin_bar_menu( $wp_admin_bar ) {
if ( defined( 'WP_DEBUG' ) && WP_DEBUG && ! is_admin() ) {
global $template;
@LittleCoding
LittleCoding / functions.admin_bar_menu.new_content.php
Last active January 30, 2018 17:01
Change default "+ New" content post type to page in WordPress administration menu bar
<?php
/**
* code to be placed in theme functions.php
* add_filter priority of 70 or greater.
*/
if ( ! function_exists( 'mytheme_admin_bar_menu' ) ) {
function mytheme_admin_bar_menu( $wp_admin_bar ) {
$new_content = (object) $wp_admin_bar->get_node( 'new-content' );
@LittleCoding
LittleCoding / node_edit_form_d8.php
Last active October 4, 2016 15:24 — forked from aklump/node_edit_form_d8.php
Programmatically embed an entity edit form in Drupal 8
<?php
// Without the use of D.I.
$form = \Drupal::service('entity.manager')
->getFormObject('{ENTITY_TYPE}', 'default')
->setEntity($entity);
$build[] = \Drupal::formBuilder()->getForm($form);
// Within a class using D.I.
class someClass {
@LittleCoding
LittleCoding / myelement.html.twig
Created September 27, 2016 13:37
Current URL path via Twig in Drupal 8
{#
/**
* @file
* Get the current URL path via Drupal 8 route name and twig function.
*/
#}
<a href="{{ url('<current>') }}">Current page</a>