Skip to content

Instantly share code, notes, and snippets.

@gmutschler
gmutschler / get_domain.php
Last active August 29, 2015 14:05
return the TLD and Domain on any Wordpress install. (Usefull for mailer for example)
<?php
function domain_url() {
//get the full domain
$urlparts = parse_url(site_url());
$domain = $urlparts [host];
//get the TLD and domain
$domainparts = explode(".", $domain);
@gmutschler
gmutschler / validation_messages.css
Created August 8, 2014 14:37
Basic styling from form validation messages
.error {
color: #ee0000;
border: 1px solid #ee6767;
background: #ffe7e7;
}
.success {
color: #11aa11;
border: 1px solid #67cc67;
background: #e7f7e7;
}
@gmutschler
gmutschler / load_wordpress.php
Created August 8, 2014 16:03
File to include at the top of a script in order to access wordpress core variable and functions (Path relative from "theme_folder/inc")
<?php require_once('../../../../wp-load.php'); ?>
@gmutschler
gmutschler / wp-detect-dev.php
Created August 11, 2014 16:47
Detect if the current wordpress is in production stage. Usefull to loas minified file on prod.
<?php
function is_production(){
// Define Environments
$environments = array(
'local' => array('.local', 'local.','localhost','127.0.0.1'),
'development' => 'dev.',
'staging' => 'stage.',
'preview' => 'preview.',
);
@gmutschler
gmutschler / wp-remove-comment.php
Last active August 29, 2015 14:05
Disable comments except for all post types except for the ones specified in $enablecomments
<?php
global $enablecomments;
$enablecomments = array('');
// Removes from post, pages and custom posts
add_action('init', 'remove_comment_support', 100);
function remove_comment_support() {
global $enablecomments;
@gmutschler
gmutschler / editor-styles.css
Created August 13, 2014 15:36
Customize tinyMCE in wordpress with selfdefined styles
.red {
color: #89191e;
font-weight: bold;
}
@gmutschler
gmutschler / colored-bullets.css
Created August 13, 2014 16:24
Color the bullets and numbers of lists
ul, ol {
counter-reset: the_counter;
list-style: none;
padding:0;
margin:0;
}
li {
line-height: 1.8em;
letter-spacing: -0.005em;
@gmutschler
gmutschler / wp_get-bloginfo-shortcode.php
Created August 14, 2014 16:43
Add a shortcode to tinymce that echoes bloginfo's values. (example: [bloginfo key='template_directory'])
function my_bloginfo_shortcode( $atts ) {
extract(shortcode_atts(array(
'key' => '',
), $atts));
return get_bloginfo($key);
}
add_shortcode('bloginfo', 'my_bloginfo_shortcode');
@gmutschler
gmutschler / validateiban.php
Last active August 29, 2015 14:05
isValidBic($bic) => Return true if $bic has a BIC/SWIFT formatisValidIban($iban) => Return true if $iban has a IBAN formatmatchingBicIban($bic, $iban) => Return true $bic and $iban have the same country code
<?php
//WARNING: MAKE SURE THAT $RULES AND $COUNTRYISO ARRAYS ARE UP TO DATE!
function isValidBic ($bic) {
$countryISO = array (
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
<?php
// WARNING STILL NEED TO SANITIZE
class MyContactPage {
/** Holds the values to be used in the fields callbacks */
private $options;
private $my_option_name = 'contact_infos';
private $my_option_admin_slug = 'contact-informations';