Skip to content

Instantly share code, notes, and snippets.

@igmoweb
igmoweb / ale.php
Last active August 29, 2015 14:27
functions.php
if ( ! function_exists('generate_concerts_post_type') ) {
// Register Custom Post Type
function generate_concerts_post_type() {
$labels = array(
'name' => _x( 'Concerts', 'Post Type General Name', 'ale' ),
'singular_name' => _x( 'Concert', 'Post Type Singular Name', 'ale' ),
'menu_name' => __( 'Concerts', 'ale' ),
@igmoweb
igmoweb / kirki-hooks.php
Created September 1, 2015 17:51
Repeater Kirki Hooks. First attempt in a good direction, maybe
<?php
add_action( 'customize_register', 'kirki_hooks_customize_register' );
function kirki_hooks_customize_register( $wp_customize ) {
class Kirki_Customize_Control_Repeater_Setting extends WP_Customize_Setting {
/**
* In Repeater, one setting is one row full of settings
* fields save all the fields and their types
@igmoweb
igmoweb / functions.php
Created September 4, 2015 10:20
Sparkling Child
<?php
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
@igmoweb
igmoweb / nbt-pro-sites.php
Last active October 23, 2015 15:04
NBT + Pro Sites integration
<?php
add_filter( 'psts_setting_checkout_url', 'katarzyna_nbt_pro_sites_checkout_url' );
function katarzyna_nbt_pro_sites_checkout_url( $value ) {
global $pagenow, $psts;
if ( ! is_object( $psts ) )
return $value;
$show_signup = $psts->get_setting( 'show_signup' );
<?php
function ignacio_import_hack( $value ) {
if ( ! post_type_exists( 'et_pb_layout' ) ) {
register_post_type( 'et_pb_layout' );
}
if ( ! taxonomy_exists( 'layout_type' ) ) {
register_taxonomy( 'layout_type', 'et_pb_layout' );
}
@igmoweb
igmoweb / site-new.php
Last active November 19, 2015 13:54
Custom query shortcode
<?php
add_shortcode( 'areas', 'custom_query_shortcode' );
function custom_query_shortcode( $atts ) {
// EXAMPLE USAGE:
// [areas show_posts="100" post_type="page" post_parent="246"]
// Defaults
$defaults = array(
"show_posts" => 100,
"post_type" => 'page',
@igmoweb
igmoweb / extend-site-new.php
Last active December 14, 2015 18:58
Extend Site New Use case
<?php
add_action( 'network_after_site_new_form', function() {
$themes = wp_get_themes();
?>
<table class="form-table">
<tr class="form-field">
<th scope="row"><label for="my-plugin-theme">Select your theme</label></th>
<td>
<select name="my-plugin-theme" id="my-plugin-theme">
@igmoweb
igmoweb / new-blog-templates-gf.php
Created November 25, 2015 17:50
Gravity Forms + New Blog Templates Integration
<?php
// This should add a new option in the form feed but it doesn't anymore because the action has dissappeared
add_action( 'gform_user_registration_add_option_section', 'nbt_add_blog_templates_user_registration_option', 15 );
function nbt_add_blog_templates_user_registration_option( $config ) {
// I don't know if this would be valid in the new version
$multisite_options = rgar($config['meta'], 'multisite_options');
$my_option = rgar( $multisite_options, 'blog_templates' );
?>
<input type="checkbox" id="gf_user_registration_multisite_blog_templates" name="gf_user_registration_multisite_blog_templates" value="1" <?php checked( rgar( $multisite_options, 'blog_templates' ) ); ?> />
<?php
@igmoweb
igmoweb / clips.php
Last active November 26, 2015 16:45
clips
<?php
$args = array(
'post_type' => 'clips',
'ignore_sticky_posts' => true,
'posts_per_page' => 1,
'cat' => 6
);
$clips_query = new WP_Query( $args );
@igmoweb
igmoweb / meta-query.php
Last active November 26, 2015 17:41
meta query
add_action( 'pre_get_posts', 'order_conciertos_by_date' );
function order_conciertos_by_date( $query ) {
if ( is_admin() )
return;
if ( $query->get( 'post_type' ) != 'concierto' )
return;
$today = current_time( 'timestamp' );
$today = date( 'Ymd', $today );