Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* An helper file for Laravel 4, to provide autocomplete information to your IDE
* Generated for Laravel 4.2.16 on 2014-12-24.
*
* @author Barry vd. Heuvel <[email protected]>
* @see https://github.com/barryvdh/laravel-ide-helper
*/
namespace {
@afuggetta
afuggetta / CustomTemplate.php
Last active August 29, 2015 14:15
Custom post type template loading
<?php
add_filter( 'single_template', array(
__CLASS__,
'get_custom_post_type_template'
), 10, 1 );
public function get_custom_post_type_template( $single_template ) {
global $post;
@afuggetta
afuggetta / gist:f55a3360467235d65124
Created February 13, 2015 16:17
Ad temp solution
.ad {
background-color: $grey;
&.box-728x90 {
height: 90px;
width: 728px;
}
&.box-300x600 {
height: 600px;
}
&.box-300x250 {
<?php
//Add guest authors metaboxes
add_action( 'add_meta_boxes', array( $this, 'bps_add_metaboxes' ), 10, 2 );
//Adding custom fields to guest authors
add_filter( 'coauthors_guest_author_fields', array( $this, 'bps_filter_guest_author_fields' ), 10, 2 );
/**
* Adding metaboxes
*/
public function bps_add_metaboxes() {
<?php
//Update profile for WP Users
add_action( 'profile_update', array( $this, 'bps_users_save_metadata' ), 10, 2 );
//Adding fields to normal user profile
add_action( 'show_user_profile', array( $this, 'bps_custom_user_profile_fields' ) );
add_action( 'edit_user_profile', array( $this, 'bps_custom_user_profile_fields' ) );
/**
/**
* THOSE FUNCTIONS ARE TEMPORARY @todo: TO REMOVE
*/
/*
* Creating Guest authors from users
*/
$users = get_users();
$created = 0;
$skipped = 0;
foreach( $users as $user ) {
//Setting Ajax handlers
add_action( 'wp_ajax_nopriv_get_author_info', array( $this, 'bps_get_author_info_cb' ) );
add_action( 'wp_ajax_get_author_info', array( $this, 'bps_get_author_info_cb' ) );
/**
* Function used to get author info for popup on article
*/
public function bps_get_author_info_cb() {
global $coauthors_plus;
//Checking nonce
@afuggetta
afuggetta / media.js
Created June 25, 2015 19:44
Javascript to handle a media upload
/* global jQuery, wp */
/**
* To enqueue in admin:
* $template_dir = get_template_directory_uri();
* //Enqueue necessary scripts for using WP JS media library
* wp_enqueue_media();
* //Custom JS for admin
* wp_enqueue_script( 'coresales-admin-scripts', $template_dir . '/javascripts/coresales_media_admin.min.js', array( 'jquery' ), 1.0, true );
*/
@afuggetta
afuggetta / taxonomies.php
Last active August 29, 2015 14:25
Hook into taxonomies
<?php
//Categories hooks
add_action( 'edit_category_form_fields', [ $this, 'coresales_category_custom_fields' ] );
add_action( 'category_add_form_fields', [
$this,
'coresales_category_custom_fields'
] ); //@see https://developer.wordpress.org/reference/hooks/taxonomy_add_form_fields/
add_action( 'create_category', [ $this, 'coresales_category_save' ] );
add_action( 'edit_category', [ $this, 'coresales_category_save' ] );
@afuggetta
afuggetta / twitterembed.js
Created August 13, 2015 21:39
Check twitter embed iframe is loaded
//Load/Enqueue the twitter widgets.js
window.twttr.ready(function (twttr) {
// At this point the widget.js file had been loaded.
// We can now make use of the twttr events
twttr.events.bind('rendered', function (event) {
// At this point the tweet as been fully loaded
// and rendered and you we can proceed with our Javascript
window.console.log("Created widget", event.target.id);
});
});