Skip to content

Instantly share code, notes, and snippets.

View maniaks's full-sized avatar

jmcg maniaks

  • Maniaks Interactive
  • Montpellier, France
View GitHub Profile
$(document).ready(function () {
//called when key is pressed in textbox
$("#quantity").keypress(function (e) {
//if the letter is not digit then display error and don't type anything
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
//display error message
$("#errmsg").html("Digits Only").show().fadeOut("slow");
return false;
}
});
@maniaks
maniaks / functions.php
Created June 30, 2014 13:01
Anti spam bot for WordPress
// Antispambot
// From http://www.guylabbe.ca/blog/wp-antispambot.html
function asb($content){
return preg_replace('/([_a-zA-Z0-9.\-]*@[a-zA-Z0-9]([_a-zA-Z0-9\-]+\.)+[a-zA-Z]{2,10})/e',"antispambot('\\1')",$content);
}
add_filter('the_content','asb');
@maniaks
maniaks / Filet-autour-dun-h1.markdown
Created September 12, 2013 23:30
A Pen by Jean-Marc Caillat-Grenier.

Filet autour d'un h1

h1 dont le texte est centré horizontalement acec une barre horizontale qui s’affiche à gauche et à droite du texte, centrée verticalement par rapport au texte. Compatible Ie8+.

A Pen by Jean-Marc Caillat-Grenier on CodePen.

License.

@maniaks
maniaks / add_setting_cpt.php
Created September 10, 2013 07:33
WordPress: Add Settings page to custom post type
<?php
//Example from Codex page : http://codex.wordpress.org/Function_Reference/add_submenu_page
//Add this in your functions.php file, or use it in your plugin
add_action('admin_menu', 'register_my_custom_submenu_page');
function register_my_custom_submenu_page() {
add_submenu_page( 'edit.php?post_type=book', 'My Custom Submenu Page', 'My Custom Submenu Page', 'manage_options', 'my-custom-submenu-page', 'my_custom_submenu_page_callback' );
}
@maniaks
maniaks / ctpArchives_in_menu.php
Last active December 22, 2015 15:59
WordPress: Custom Post Type Archives In Menus
<?php
// WordPress Snippet from http://www.catswhocode.com/blog/snippets/custom-post-type-archives-in-wordpress-menus
//Place this code as a plugin or in functions.php
add_action( 'admin_head-nav-menus.php', 'inject_cpt_archives_menu_meta_box');
function inject_cpt_archives_menu_meta_box( $object ) {
add_meta_box( 'add-cpt', __( 'CPT Archives' ), 'wp_nav_menu_cpt_archives_meta_box', 'nav-menus', 'side', 'default' );
return $object; /* pass */
}