Skip to content

Instantly share code, notes, and snippets.

View MartinL83's full-sized avatar
🤷‍♂️
wat

Martin Lindgren MartinL83

🤷‍♂️
wat
View GitHub Profile
@MartinL83
MartinL83 / Create page on theme activation
Created July 23, 2013 07:15
Wordpress - Create page on theme activation
if (isset($_GET['activated']) && is_admin()){
$new_page_title = 'This is the page title';
$new_page_content = 'This is the page content';
$new_page_template = ''; //ex. template-custom.php. Leave blank if you don't want a custom page template.
$page_check = get_page_by_title($new_page_title);
$new_page = array(
'post_type' => 'page',
'post_title' => $new_page_title,
'post_content' => $new_page_content,
'post_status' => 'publish',
@MartinL83
MartinL83 / react-ts-recursive.js
Last active November 14, 2022 17:37
React Typescript - Recursive component
import React, { useState } from "react";
type ItemType = {
id: Number;
title: String;
children: Array<Number>;
};
// Each "ItemType" element in the array have a array of children ID's. These refer
// to a ItemType.