Skip to content

Instantly share code, notes, and snippets.

View imatteh's full-sized avatar

Haitham AlMahdi imatteh

  • iMatteh Web Design
  • Libya
  • X @imatteh
View GitHub Profile
@DiegoSalazar
DiegoSalazar / validate_credit_card.js
Last active April 24, 2024 12:51
Luhn algorithm in Javascript. Check valid credit card numbers
// Takes a credit card string value and returns true on valid number
function valid_credit_card(value) {
// Accept only digits, dashes or spaces
if (/[^0-9-\s]+/.test(value)) return false;
// The Luhn Algorithm. It's so pretty.
let nCheck = 0, bEven = false;
value = value.replace(/\D/g, "");
for (var n = value.length - 1; n >= 0; n--) {
@norcross
norcross / cpt-rss.php
Created December 17, 2012 12:21
add custom post type to RSS
function cpt_feed_request($qv) {
if (isset($qv['feed']))
$qv['post_type'] = get_post_types();
return $qv;
}
add_filter('request', 'cpt_feed_request');
@TCotton
TCotton / wordpress-breadcrumb-advanced.php
Last active November 20, 2017 17:37
Code for creating Wordpress breadcrumbs in a theme including custom taxonomy
<?php
// --> http://www.suburban-glory.com/blog?page=170
/*
* based on http://snipplr.com/view/57988/
*/
function get_term_parents($id, $taxonomy, $link = false, $separator = '/', $nicename = false, $visited = array()) {
$chain = '';
$parent = &get_term($id, $taxonomy);
@achoukah
achoukah / blank-html-page.html
Last active June 24, 2024 00:16
html blank page
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="description" content="Webpage description goes here" />
<meta charset="utf-8">
<title>Change_me</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="">
<link rel="stylesheet" href="css/style.css">
@irazasyed
irazasyed / Install Composer using MAMP's PHP.md
Last active April 2, 2024 18:45
Instructions on how to change preinstalled Mac OS X PHP to MAMP's PHP Installation and then install Composer Package Management

Change default Mac OS X PHP to MAMP's PHP Installation and Install Composer Package Management


Instructions to Change PHP Installation


First, Lets find out what version of PHP we're running (To find out if it's the default version).

To do that, Within the terminal, Fire this command:

which php

@egeorjon
egeorjon / add_remove_class_with_js.md
Last active October 13, 2023 23:06
Add or Remove css class with Javascript

From: StackOverflow

To change all classes for an element:

document.getElementById("MyElement").className = "MyClass";

To add an additional class to an element:

document.getElementById("MyElement").className += " MyClass";

To remove a class from an element:

@srikat
srikat / functions.php
Last active November 12, 2017 19:54
Displaying custom menu with menu descriptions and icons in a WordPress widget. http://sridharkatakam.com/display-custom-menu-menu-descriptions-icons-wordpress-widget/
//* Add walker class that displays menu item descriptions
class Menu_With_Description extends Walker_Nav_Menu {
function start_el(&$output, $item, $depth, $args) {
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
@Zodiac1978
Zodiac1978 / .htaccess
Last active June 23, 2024 17:39
Safer WordPress with these .htaccess additions
# Don't show errors which contain full path diclosure (FPD)
# Use that line only if PHP is installed as a module and not per CGI
# try using a php.ini in that case.
# Change mod_php5.c to mod_php7.c if you are running PHP7
<IfModule mod_php5.c>
php_flag display_errors Off
</IfModule>
# Don't list directories
<IfModule mod_autoindex.c>
@bacalj
bacalj / gist:18dac320b5d32b249207
Last active May 22, 2018 23:03
getting acf repeater into bootstrap tabs
<?php if (have_posts()) : while(have_posts()) :the_post();?>
<div class="post-single" id="post-<?php the_ID(); ?>">
<div class="post-body">
<!-- START CONTENT -->
<?php the_content();
//if there are tabs - open up a tabset ul
if( get_field('tab') ) {
echo ('<ul class="nav nav-tabs" role="tablist">');
@BluePraise
BluePraise / functions.php
Last active April 14, 2018 12:21
Remove Contactform7 scripts from WP pages
// Put this script in your functions.php
// I have very little pages, and I am sure it can be improved
// or adjusted to suit your own project.
//Deregister the scripts.
function deregister_contact_form() {
// You can put here all the pages where there is no contact form
if ( ! is_page( 'contact' ) ) {
remove_action('wp_enqueue_scripts', 'wpcf7_enqueue_scripts');
}