Skip to content

Instantly share code, notes, and snippets.

View 1shiharat's full-sized avatar
💭
I may be slow to respond.

ishihara takashi 1shiharat

💭
I may be slow to respond.
View GitHub Profile
@kodie
kodie / wp_custom_orderby.php
Last active November 24, 2020 06:49
Create a custom query 'orderby' type that uses data from other tables in WordPress
<?php
// Fetch data required for custom orderby types and left join it into the query
add_filter('posts_join_paged', 'custom_orderby_joiner', 10, 2);
function custom_orderby_joiner($join_paged_statement, $wp_query) {
$orderby = $wp_query->query_vars['orderby'];
if ($orderby === 'popularity') {
$join_paged_statement .= " INNER JOIN (SELECT postid, pageviews FROM wp_popularpostsdata) popularpostsdata ON popularpostsdata.postid = wp_posts.ID";
}
@kenmori
kenmori / JavaScript.md
Last active May 4, 2024 12:34
JavaScript練習問題集(ECMAScript2015,2016,2017,2018,2019,2020,other Library)

JavaScript練習問題集

JavaScript

更新情報

・問題を追加(2024/4/12)
・リファクタリング(2023/4/22)
・Decoratorsに関する問題を追加(2020/6/6)
@bdsexton
bdsexton / csv-trees.md
Last active July 25, 2022 03:50
Generate File System Trees in CSV Format with "tree" and "sed"

Generate File System Trees in CSV Format with "tree" and "sed"

Description

I don't know whether this will be useful to anyone else, but I wanted to use the Linux tree command to generate file system trees in CSV format on OS X. This should work pretty much as is on Linux, although you may need or want to change the paths and optimize the usage of sed.

Dependency

This uses the Linux "tree" command, which is not standard on OS X.

@fabrizim
fabrizim / acf-customizer-patch.php
Last active January 17, 2024 02:30
Plugin to allow for Advanced Custom Fields to be used in widgets within the Customizer
<?php
/*
Plugin Name: ACF Customizer Patch
Plugin URI: https://gist.github.com/fabrizim/9c0f36365f20705f7f73
Description: A class to allow acf widget fields to be stored with normal widget settings and allow for use in customizer.
Author: Mark Fabrizio
Version: 1.0
Author URI: http://owlwatch.com/
*/
class acf_customizer_patch
@a-axton
a-axton / build.scss
Created June 30, 2014 01:51
Bootstrap style grid using neat and SASS maps
// replace map keys with whatever you want
// creats classes as .grid-$keyname-$col
$breakpoint-widths: (xs: 480px, sm: 768px, md: 992px, lg: 1200px);
$grid-columns: 12
// media query mixin
@mixin mq($search) {
@media (min-width: map-get($breakpoint-widths, $search)){
@content
}
@scottzirkel
scottzirkel / install-wp.sh
Created June 27, 2014 20:26
Custom WordPress install script
#!/bin/bash
echo "What is the theme name? (no spaces)"
read THEME
echo Installing Wordpress
git clone git@github.com:scottzirkel/wordpress-base.git website ## This pulls down my WordPress starter template
cd website
echo Installing Composer ## I use Composer to manage the backend dependencies (ie: WordPress, public plugins, etc)
composer install
cd app/themes
echo Setting up "$THEME"
@mala
mala / gist:9086206
Created February 19, 2014 04:49
CSRF対策用トークンの値にセッションIDそのものを使ってもいい時代なんて、そもそも無かった

概要

http://co3k.org/blog/csrf-token-should-not-be-session-id について。

この記事では触れられていませんが、

  • むかし、セッションIDをHTMLソース中に埋め込んでも脅威は変わらないと主張した人がいました
  • 正確には「hiddenの値のみ漏れやすいような特殊な脆弱性が無ければ」という前提であったけれど、実際にそのようなバグはあったし、予見されていた。
  • とても影響のある人だったので、色々なサイトや書籍がその方法を紹介し、安全なウェブサイトの作り方にも載ってしまいました

この際ハッキリ言っておくべきだと思うので書きますが、そもそもセッションIDを(HTMLソース中に埋め込む)CSRF対策トークンとして使うのは間違いでした。最初から間違っていたのです。正確に言うとCSRFの話は関係ないですね。CSRF関係なく、特に「単体で」セッションハイジャックが可能になるような値を、HTMLソース中に埋め込むべきではありません。

@claudiosanches
claudiosanches / functions.php
Last active January 2, 2016 13:09
WordPress - Gulp
<?php
/**
* Load site scripts.
*
* @since 1.0.0
*
* @return void
*/
function wpgulp_enqueue_scripts() {
@bomberstudios
bomberstudios / sketch-plugins.md
Last active February 26, 2024 07:02
A list of Sketch plugins hosted at GitHub, in no particular order.
@DevinWalker
DevinWalker / theme-tour.php
Last active March 27, 2018 17:57
Theme activation welcome message
<?php
/**
* Theme Activation Tour
*
* This class handles the pointers used in the introduction tour.
* @package Popup Demo
*
*/
class WordImpress_Theme_Tour {