Skip to content

Instantly share code, notes, and snippets.

View stefanledin's full-sized avatar

Stefan Ledin stefanledin

View GitHub Profile
<?php
add_filter('img_caption_shortcode', function( $output, $attr, $content ) {
return '<figure>' . $content . '<figcaption>' . $attr['caption'] . '</figcaption></figure>';
}, 10, 3);
<?php
// (Laravel)
use Tests\TestCase;
use Carbon\Carbon;
class TimeCounterTest extends TestCase
{
public function test_duration()
{
$counter = new TimeCounter();
<div class="toolbox-item"><h3 class="active">Filtrera journalhändelser <span class="icon-chevrondown"></span></h3> <div class="toolbox-item_content toolbox-item_content--expanded"><div class="toolbox-item_content--row"><div class="w-100"><label for="show-all" class="toolbox-filter-label">Visa alla</label></div> <div class="flex-shrink-1"><div class="form-check form-check-inline"><input type="checkbox" id="show-all" class="form-check-input"></div></div></div> <div class="toolbox-item_content--row level-2"><div class="w-100"><h3 class="active">
Besök
<span class="form-check-label"></span><span class="icon-chevrondown"></span></h3> <div class="toolbox-item_content toolbox-item_content--expanded"><div class="toolbox-item_content--row no-border"><div class="w-100"><label for="entry_type-1" class="toolbox-filter-label">Alla</label></div> <div class="flex-shrink-1"><div class="form-check form-check-inline"><span class="form-check-label"></span> <input id="entry_type-1" type="
(function () {
// An object with options for the IntersectionObserver.
const options = {
// 0.5 = The callback is fired when 50% of the element is visible
// We can add more values to the array, like 0.25, 0.75 or 1.0
threshold: [0.5]
};
// Instantiate the IntersectionObserver class
const observer = new IntersectionObserver((entries, observer) => {
var results = [
{
answer: "2",
question: "12"
},
{
answer: "1",
question: "13"
},
{
<?php
/**
* Register the custom taxonomy.
*/
add_action( 'init', 'register_taxonomy_article_type' );
function register_taxonomy_article_type() {
register_taxonomy( 'article_type', 'post', array(
'label' => 'Article type',
'hierarchical' => true,
export const pageQuery = graphql`
query($slug: String) {
allWordpressPost(sort: {order: ASC, fields: date}) {
edges {
node {
featured_media {
localFile {
childImageSharp {
fluid(sizes: "(min-width: 1280px) 327px, (min-width: 768px) 39vw, 81vw") {
src
// Does not work! 😕
export default {
props: ['todo'],
data() {
const data = this.todo;
data.isComplete = false;
return data;
},
watch: {
isComplete: function(value) {
<?php
add_action( 'pre_get_posts', function( $query ) {
if ( ! is_admin() && is_post_type_archive( 'articles' ) ) {
$query->set('posts_per_page', 1);
}
} );
<?php
/*
Template name: My custom archive page
*/
$posts = new WP_Query( array(
'post_type' => 'articles',
'posts_per_page' => 1,
'paged' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1
) );