Skip to content

Instantly share code, notes, and snippets.

View ms-studio's full-sized avatar

Manuel Schmalstieg ms-studio

View GitHub Profile
@ms-studio
ms-studio / inc-name-regex.php
Created October 21, 2012 22:54
Lastname-Firstname Inversion
// a little snippet instead of the_title()
$mystring = get_the_title();
$findme = ',';
$pos = strpos($mystring, $findme);
if ($pos === false) {
$regex_name = $mystring;
} else {
$firstname = strstr($mystring, ',');
@ms-studio
ms-studio / mem-query-relative-1.php
Created November 7, 2012 10:29
Query for relative time range
<?php
// test if we have a date
if ($orig_start_date !== "" ) {
// the next event
$meta_query = new WP_Query( array(
'meta_key' => '_mem_start_date',
'meta_value' => $orig_start_date,
'meta_compare' => '>',
@ms-studio
ms-studio / Contract-Killer-3-fr_FR.md
Created November 8, 2012 15:04 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Le contrat de la mort, version 3

Date de révision: 07/11/2012

Etabli entre nous [company name] et vous [customer name]

En résumé:

Nous ferons toujours tout notre possible pour atteindre vos objectifs, mais il est important de poser les choses sur papier, afin que chacun sache à quoi s'en tenir. Dans ce contrat, vous ne trouverez pas de vocabulaire légal compliqué, ou de longs passages en caractères illisibles. Nous n'avons pas l'intention de vous faire signer quelque chose que vous regretterez plus tard. Ce document servira l'intéret commun des deux parties, maintenant et dans l'avenir.

@ms-studio
ms-studio / WP-nofollow-rules.php
Last active December 15, 2015 21:39
nofollow rules for wordpress
<?php // ** SEO OPTIMIZATION v.0.2 **
if ( is_attachment() ) {
?><meta name="robots" content="noindex,follow" /><?php
} else if( is_single() || is_page() || is_home() ) {
?><meta name="robots" content="all,index,follow" /><?php
} elseif ( is_category() || is_archive() ) {
?><meta name="robots" content="noindex,follow" /><?php }
?>
@ms-studio
ms-studio / SPIP-boucles-de-dates
Last active December 19, 2015 05:59
Des boucles d'écriture de date, pour des EVENEMENTS du plugin SPIP Agenda...
Exemple 1:
Format souhaité:
- si un seul jour: "24.10.13"
- si plusieurs jours: "08.10 - 20.10.13"
- si les années sont différentes: "18.12.13 - 10.01.14"
le code:
[(#DATE_DEBUT|jour|=={[(#DATE_FIN|jour)]}|?{
[(#DATE_DEBUT|affdate{'d.m.y'})],
@ms-studio
ms-studio / search-for-customfield.php
Last active December 19, 2015 16:39
A WordPress loops that allows to quickly search for posts that have a certain custom field. Useful if you see "phantom" custom fields, and want to see where they come from.
<?php
// query by custom field...
if ( is_user_logged_in() ) {
$search_cfield = new WP_Query( array(
'posts_per_page' => -1,
'meta_key' => 'custom_field_name',
'orderby' => 'title',
'order' => 'ASC',
@ms-studio
ms-studio / event-date.php
Last active December 19, 2015 19:48
Event date generator for MEM (minimalistic event manager) plugin. In French.
<?php
$start_date = get_post_meta($post->ID, '_mem_start_date', true);
$end_date = get_post_meta($post->ID, '_mem_end_date', true);
$start_date_iso = $start_date;
if (strlen($start_date_iso) > 10) {
$start_date_iso = substr_replace($start_date_iso, 'T', 10 , 1);
@ms-studio
ms-studio / recent-posts-wp-dashboard.php
Last active December 20, 2015 04:09
Adds the 5 most recently published posts to the dashboard. Code from http://wpsnipp.com/index.php/functions-php/create-most-recent-posts-dashboard-widget/ - slightly modified.
<?php
/**
* Show recent posts :
* https://gist.github.com/ms-studio/6069116
*/
function wps_recent_posts_dw() {
?>
<ul style="list-style-type: disc;padding-left: 1.5em;">
# BEGIN CACHIFY
<IfModule mod_rewrite.c>
# ENGINE ON
RewriteEngine On
# GZIP FILE
<IfModule mod_mime.c>
RewriteCond %{REQUEST_URI} /$
RewriteCond %{REQUEST_URI} !^/wp-admin/.*
RewriteCond %{REQUEST_METHOD} !=POST