Skip to content

Instantly share code, notes, and snippets.

Avatar

okcharlo charleslouis

View GitHub Profile
View imath-pm-friends-only.php
<?php
/*** beginning of the code to paste in your functions.php ***/
function imath_pm_button_only_if_friends( $button ) {
if( is_super_admin() )
return $button;
if( 'is_friend' != friends_check_friendship_status( bp_displayed_user_id(), bp_loggedin_user_id() ) )
return false;
View functions.php
<?php
/*
Description: Adds a taxonomy filter in the admin list page for a custom post type.
Written for: http://wordpress.stackexchange.com/posts/582/
By: Mike Schinkel - http://mikeschinkel.com/custom-workpress-plugins
Instructions: Put this code in your theme's functions.php file or inside your own plugin. Edit to suite your post types and taxonomies. Hope this helps...
*/
add_filter('manage_listing_posts_columns', 'add_businesses_column_to_listing_list');
function add_businesses_column_to_listing_list( $posts_columns ) {
if (!isset($posts_columns['author'])) {
@charleslouis
charleslouis / add_menuclass
Last active December 15, 2015 03:39
add menu-class to wordpress menu
View add_menuclass
function add_menuclass($ulclass) {
return preg_replace('/<a/', '<a class="resalf"', $ulclass, 1);
}
add_filter('wp_nav_menu','add_menuclass');
@charleslouis
charleslouis / page-404.css
Created March 19, 2013 12:30
Structure for a 404 Error page with no image
View page-404.css
/* ==========================================================================
PAGE 404 ERROR
========================================================================== */
#text-404{
width: 66.6%;
margin: 2.5% auto;
text-align: center;
}
#container-404{
width: 100%;
@charleslouis
charleslouis / cssTransitionModernizr.js
Created March 19, 2013 12:32
cssTransitionModernizr - If Css animation are not supported : apply jQuery.animate(). Requires Modernizr
View cssTransitionModernizr.js
function cssTransitionModernizr(){
if(!Modernizr.csstransitions) { // Test if CSS transitions are supported
$(function() {
$('a').hover(function(){
$(this).animate({padding:'34.277% 0 0'},{queue:false,duration:500});
$(this).find('p').animate({top:'0', opacity:'1'},{queue:false,duration:500});
}, function(){
$(this).animate({padding:'36% 0 0'},{queue:false,duration:500});
$(this).find('p').animate({top:'100px',opacity:'0'},{queue:false,duration:500});
});
@charleslouis
charleslouis / hack resalf - lafourchette.js
Created March 19, 2013 12:35
Require Modernizr. If Touch screen : open in new window Else : open as lightbox
View hack resalf - lafourchette.js
//hack-resalf.js
//septembre 2012 - lasouris et le piano
//use the resalf popin if not on a touch device, or redirect to a new page if on a touch device
//based on modernizr.touch
//this avoids having to remove class resalf
// 1rst : Include this modernizr custom built before the plugin code
@charleslouis
charleslouis / ElementsByClassName_For_IE.js
Last active December 15, 2015 03:39
add getElementsByClassName method to IE browsers (<9) that do not support it
View ElementsByClassName_For_IE.js
//add getElementsByClassName method to IE browsers that do not support it
if (!document.getElementsByClassName) {
document.getElementsByClassName = function (cn) {
var rx = new RegExp("\\b" + cn + "\\b"), allT = document.getElementsByTagName("*"), allCN = [], i = 0, a;
while (a = allT[i++]) {
if (a.className && a.className.indexOf(cn) + 1) {
if(a.className===cn){ allCN[allCN.length] = a; continue; }
rx.test(a.className) ? (allCN[allCN.length] = a) : 0;
}
}
View touch-icons.html
<base href="http://www.monsite.com/base/" />
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="apple-touch-icon-114x114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="apple-touch-icon-72x72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-precomposed.png">
<link rel="icon" type="image/png" href="speed-dial-icon.png">
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<link rel="shortcut icon" type="image/png" href="favicon.png" />
@charleslouis
charleslouis / array_swap_back.php
Created March 20, 2013 14:19
enable swapping position of a key=>value pair backward. ie, if applied on "swap", [0]=>bar, [1]=>foo, [2]=>swap would become [0]=>bar, [1]=>swap, [2]=>foo
View array_swap_back.php
function array_swap_back($arr,$elem){
$ndx = array_search($elem,$arr);
$b4 = array_slice($arr,0,$ndx);
$mid = array_reverse(array_slice($arr,$ndx,2));
$after = array_slice($arr,$ndx + 2);
return array_merge($b4,$mid,$after);
}
@charleslouis
charleslouis / list_hooked_functions.php
Created March 20, 2013 14:21
list all the hooked function in wordpres (if no $tag provided)
View list_hooked_functions.php
function list_hooked_functions($tag=false){
global $wp_filter;
if ($tag) {
$hook[$tag]=$wp_filter[$tag];
if (!is_array($hook[$tag])) {
trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
return;
}
}
else {