View docker-compose.yml
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
my-wpdb: | |
image: mariadb | |
ports: | |
- "8081:3306" | |
environment: | |
MYSQL_ROOT_PASSWORD: root | |
my-wp: | |
image: wordpress | |
volumes: | |
- ./:/var/www/html |
View template.php
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 | |
# Credit: https://wordpress.stackexchange.com/questions/5047/how-to-check-if-a-user-is-in-a-specific-role | |
$user = wp_get_current_user(); | |
if ( in_array( 'author', (array) $user->roles ) ) { | |
//The user has the "author" role | |
} | |
?> |
View new-post.php
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 | |
# Credits: https://wordpress.stackexchange.com/questions/106973/wp-insert-post-or-similar-for-custom-post-type | |
$post_id = wp_insert_post(array ( | |
'post_type' => 'your_post_type', | |
'post_title' => $your_title, | |
'post_content' => $your_content, | |
'post_status' => 'publish', | |
'comment_status' => 'closed', // if you prefer |
View react-instagram-embed.js
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
export default class BlogPost extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
'instagram': false | |
}; | |
} |
View gatsby-image-example.js
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
import React, { Component } from "react"; | |
import Img from "gatsby-image"; | |
export default class Frontpage extends Component { | |
render() { | |
return ( | |
<div className="Frontpage pt2"> | |
<Img resolutions={this.props.data.PeaceEmoji.resolutions} alt="Peace sign emoji" /> | |
</div> | |
); |
View laravel-eager-load-model-relationships.php
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 | |
namespace YourApp; | |
use Illuminate\Database\Eloquent\Model; | |
class Posts extends Model | |
{ | |
/** | |
* Automagically eager load any Model relationships |
View incrementing-slugs.php
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 | |
protected function create(array $data) | |
{ | |
$slug = str_slug($data['first_name'] . '.' . $data['last_name']); | |
$next = 2; | |
// Loop until we can query for the slug and it returns false | |
while (User::where('slug', '=', $slug)->first()) { | |
$slug = $slug . '-' . $next; | |
$next++; |
View array-destructuring-in-php7-specific.php
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 | |
$members = [ | |
['id' => 1, 'name'=> 'Seb', 'twitter' => '@sebdedeyne' ], | |
['id' => 2, 'name'=> 'Alex', 'twitter' => '@alexvanderbist'], | |
['id' => 3, 'name'=> 'Brent', 'twitter' => '@brendt_gd'], | |
]; | |
foreach ($members as ['twitter' => $twitterHandle, 'name' => $firstName]) { | |
// do stuff with $twitterHandle and $firstName |
View array-destructuring-in-php7.php
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 | |
$members = [ | |
[1, 'Seb'], | |
[2, 'Alex'], | |
[3, 'Brent'], | |
]; | |
foreach ($members as [$id, $name]) { | |
// do stuff with $id and $name |
View semantic-ui-state-search-dropdown.html
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
<form class="ui form"> | |
<section class="field"> | |
<label for="shipper_state_state"> | |
State: | |
</label> | |
<div class="ui fluid search selection dropdown"> | |
<input type="hidden" name="shipper_state_state"> | |
<i class="dropdown icon"></i> | |
<div class="default text">Select State</div> | |
<div class="menu"> |
OlderNewer