Skip to content

Instantly share code, notes, and snippets.

View timiwahalahti's full-sized avatar
💻
Working hard, as usual

Timi Wahalahti timiwahalahti

💻
Working hard, as usual
View GitHub Profile
@timiwahalahti
timiwahalahti / snippets.cson
Created April 1, 2016 10:01
Atom snippet for basic WP_Query
'.source.php':
'WP_Query (simple args)':
'prefix': 'wpquery'
'body': """
$args = array(
'author' => 1,
'author__in' => array( 1 ),
'cat' => 5,
'category__in' => array( 2, 6 ),
@timiwahalahti
timiwahalahti / snippets.cson
Last active April 6, 2016 12:01
Atom snippet for register_post_type with labels and arguments
'.source.php':
'Register CPT with args':
'prefix': 'register_post_type'
'body': """
$labels = array(
'name' => _x( 'Examples', 'post type general name', 'textdomain' ),
'singular_name' => _x( 'Example', 'post type singular name', 'textdomain' ),
'menu_name' => _x( 'Examples', 'admin menu', 'textdomain' ),
'name_admin_bar' => _x( 'Example', 'add new on admin bar', 'textdomain' ),
'add_new' => _x( 'Add New', 'example', 'textdomain' ),
( function( $ ) {
// ******************************
// * facebook.js
// *
// * @author Digitoimisto Dude Oy
// * @version 03.11.2016
// ******************************
$(document).ready(function() {
<?php
use Carbon_Fields\Container;
use Carbon_Fields\Field;
/**
* Add metaboxes for single reference
*/
add_action( 'carbon_register_fields', 'timiwahalahti_metabox_reference' );
function timiwahalahti_metabox_reference() {
add_shortcode( 'wplfdynamicselect', 'wpfi_wplf_dynamic_select' );
function wpfi_wplf_dynamic_select( $atts ) {
$the_query = new WP_Query( array(
'post_type' => 'CPT',
'post_status' => 'publish',
'posts_per_page' => 100,
'order' => 'DESC',
'orderby' => 'title',
'no_found_rows' => true,
<?php if ( ! is_wp_error( $topics ) && ! empty( $topics ) ) : ?>
<div class="cats" data-filter="cat">
<h4><?php pll_e( 'Valitse aihe' ) ?></h4>
<ul>
<li><a href="<?php echo get_term_link( $term_id ); ?>"<?php echo ( ! isset( $_GET['cat'] ) ) ? ' class="selected"' : ''; ?>><?php _e( 'Kaikki' ) ?></a></li>
<?php foreach ( $topics as $topic ) : ?>
<li>
<a href="<?php echo yeahboy_make_filter_url( $base_url_term_id, 'cat', $topic->term_id ) ?>" data-id="<?php echo $topic->term_id ?>" <?php echo ( $_GET['cat'] == $topic->term_id ) ? ' class="selected"' : ''; ?>>
<?php echo $topic->name ?>
</a>
@timiwahalahti
timiwahalahti / GitHub-Forking.md
Created August 22, 2017 07:41 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@timiwahalahti
timiwahalahti / wp_mail.md
Created August 24, 2017 13:05 — forked from johnbillion/wp_mail.md
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This is accurate as of WordPress 4.8, and includes some upcoming changes in WordPress 4.9.

There are a few TODOs left. Please bear with me.

<?php
function wpfi_rest_api_search_init() {
register_rest_route( 'wpfi/v1', '/search', array(
'methods' => 'GET',
'callback' => 'wpfi_rest_api_search',
) );
}
add_action( 'rest_api_init', 'wpfi_rest_api_search_init' );