Adding Vimeo videos to WordPress via extra fields

I wanted an easy solution for people to add videos from Vimeo to their WordPress articles (without having to add them to the editor for several reasons) and I came up with the following:

  • a function to be added to the teme
  • a piece of code to add to one or more templates(s) of the theme
  • an extra field to fill in for each post or page by the editor of the website

The function

Add this to functions.php in your theme. It is based on the vimeo shortcode plugin for WordPress.

function insert_vimeo($clip_id) {
   $width = '640';
   $height = '360';
   if (empty($clip_id) || !is_numeric($clip_id)) return '<!-- Vimeo: Invalid clip_id -->';
   if ($height && !$width) $width = intval($height * 16 / 9);
   if (!$height && $width) $height = intval($width * 9 / 16);
   return "<iframe src='http://player.vimeo.com/video/$clip_id?title=0&amp;byline=0&amp;portrait=0'
           width='$width' height='$height' frameborder='0'></iframe>";
}

The piece of code for your template :

Put this in single.php or page.php, within the loop.

<?php
if ( get_post_meta($post->ID, 'vimeo', true) ) :
    $vimeo = get_post_meta($post->ID, 'vimeo', true);
    echo (insert_vimeo($vimeo));
endif;
?>

Now you just have to add an extra field called « vimeo » to your posts or pages and add as a value the ID of the clip, that means the numbers in the URL. If, for example, you want to add the video at http://vimeo.com/20732587 you would add 20732587 to the value of your field.

Automatically generate a RSS feed from static pages with PHP

This may sound a stupid thing to do, however, there are websites out there in plain and badly formatted HTML out there that need RSS feeds.

See the script in action here : http://airdeparis.com/rss.php

Here I am considering that we update some files every now and then and we want those updates  to appear in a dynamic RSS feed. In order to do so save the following code as a file called « rss.php », edit it to suit your needs and then upload it to your site. You may access the file like this : http://example.com/rss.php.

How does it work?

We declare the files we want to have in our PHP file in an array. We will use the last modification time of each of these files, filter out the <title> and contents and then create the feed.

(By the way, if you want this to work on PHP4 you will have to replace the html_entity_decode function otherwise it will not function.)

Continue reading

php-indexes – a file tree generator

php-inphp-indexes generates an index of files in a defined folder, similar to the Apache file listing. Files may be ordered by name or date. It also generates an RSS feed. It does not require a database and is configurable via a simple config file for:

  • title and description
  • search engine friendly permalink support (thank you Emmanuel)
  • defining the number of entries in RSS feed
  • modify style to your needs

php-indexes is distributed under the GNU Public License (GPL), version 3. Use at your own risk.

I’m happy with feedback & criticism.

Try a demo here.

download php-indexes-v1.1.tar.gz | php-indexes-v1.1.zip (mai 2010)

AC Matière

acmsmall

Le magasin AC Matière vend des peintures et des éléments décoratifs originaux.
Dans le cadre d’une restructuration du site web, conçu en 2005, toujours en collaboration avec design ex machina, nous sommes aussi revenus sur le développement original du site web. Le site a maintenant des URLs propres et peut être mis à jour plus facilement. Le graphisme original de design ex machina a été légèrement modifié.

AC Matière sells paints and original decorative elements.
In a collective effort with design ex machina, we have restructured the website we created originally in 2005, and abandoned our old PHP developments. The website has now search engine friendly URLs and can be updated more easily. The original design by design ex machina ahs been slightly modified.

http://acmatiere.fr

Air de Paris

docsmall
Pour la galerie parisienne «Air de Paris»j’ai développé un simple système de gestion d’accès public et semi-public aux documents et documentations sur les artistes. Une interface d’administration permet la génération de mots de passe, et l’édition de permissions d’accès à certains dossiers.

Für die Pariser Galerie « Air de Paris » habe ich ein einfaches System entwickelt, das es erlaubt öffentliche und halböffentliche Dokumente und Dokumentationen über die Künstler der Galerie zum Download bereitzustellen. Über ein Administrationsinterface können Paßwörter generiert werden, sowie Zugangsbeschränkungen für einzelne Verzeichnisse erstellt und editiert werden.