Skip to content

Instantly share code, notes, and snippets.

@timersys
timersys / class-frontend-box.php
Created August 30, 2014 14:38
Wordpress Front end notifications
<?php
/**
* Frontend_box class will help you to create bootstrap style alert boxes on your theme
* @author Damian Logghe <info@timersys.com>
* @license GPL-2.0+
* @link http://wp.timersys.com/how-to-create-bootstraps-style-alert-boxes-in-your-theme/
* @version 1.0
*/
class Frontend_box {
@timersys
timersys / functions.php
Created September 11, 2014 22:23
Adding a custom rule to Wordpress Popups Plugin
/* http://wordpress.org/plugins/popups/
* Adding a custom rule to display popup only on
* single posts of certain category
* /
add_filter('spu/rules/rule_match/post_category', 'spu_rule_match_post_category', 12, 2);
function spu_rule_match_post_category($match, $rule){
global $post;
// validate
if( !$post->ID )
@timersys
timersys / functions.php
Last active August 29, 2015 14:07
Wordpress Social Invitations share custom url for logged user
add_filter( 'wsi/placeholders/custom_url', 'wsi_my_custom_link' );
function wsi_my_custom_link() {
global $current_user;
get_currentuserinfo();
//return home url with ref username
return site_url('?mref='.$current_user->user_login);
//return the same shortened with goo.gl
@timersys
timersys / jetpack.php
Last active August 29, 2015 14:07
WordPress Jetpack subscription form shortcode
[jetpack_subscription_form show_subscribers_total="true"]
@timersys
timersys / gist:a5a8d733ddb96e229954
Created December 4, 2014 12:02
Display a shortcode code without parsing it
/**
* If you need to show a shortcode code and double
* brackets ar enot working for you [[]]
* you can always try this
*/
add_shortcode('raw','raw_fc');
function raw_fc($atts, $content){
remove_filter( 'the_content', 'do_shortcode', 11 );
return '<code>'.$content.'</code>';
add_filter( 'the_content', 'do_shortcode', 11 );
@timersys
timersys / gist:759afb8352a662a47be9
Created December 13, 2014 13:23
Hybridauth - You cannot access this page directly
/******* IN wp-config.php add the following: ******/
/* WSI HYBRIDAUTH SESSIONS HANDLING */
define('WSI_PHP_SESSION', dirname(__FILE__) . '/phpsession');
session_save_path(WSI_PHP_SESSION);
/******* wp-content/plugins/wordpress-social-inivtations/wp-social-invitations.php and wp-content/plugins/wordpress-social-inivtations/hybridauth/index.php add the following: ******/
/* WSI HYBRIDAUTH SESSIONS HANDLING */
session_save_path(WSI_PHP_SESSION);
@timersys
timersys / gist:948088de7187dcf8c31a
Created January 9, 2015 12:25
Laravel pass model to create dropdown in views
/**
* IF you have a States model and you want to create a simple dropdown in your views you can pass the array very easily doing:
**/
public function create()
{
// first parameter is option label and second the option value
$states = State::lists('state', 'id');
return View::make('anuncios.create', compact('states'));
}
@timersys
timersys / anti-poodle
Last active August 29, 2015 14:15
wp_remote_get filter to avoid ssl connection problems
/**
* As many of you know after Poodle was released sslv3 was deactivated all over the internet and new problems arises
* when ciphers mismatch. If you get with wp_remote_ errors like: routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
* routines:SSL3_READ_BYTES:sslv3 alert handshake failure or Cannot communicate securely with peer: no common encryption algorithm(s).
* Try to add the following action to modify curl.
**/
add_action( 'http_api_curl', 'timersys_api_curl', 10, 3 );
function timersys_api_curl(&$handle, $args, $url){
@timersys
timersys / gist:82434b7e81b81e62dbba
Created February 16, 2015 14:01
serving icon fonts from CDN
# Apache config
<FilesMatch ".(eot|ttf|otf|woff)">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
@timersys
timersys / bp.php
Created February 19, 2015 12:32
add text to wordpress social invitations buddypress screen
// hook to wsi bp screen
add_action('wsi/bp/screen_one' , 'attach_my_screen');
function attach_my_screen() {
// hook to bp template
add_action( 'bp_template_content' , 'bp_template_content_func',9 );
}
// My actual text
function bp_template_content_func() {
echo "My content goes here";
}