Ticket #8188: 8188.r9683.diff

File 8188.r9683.diff, 1.5 KB (added by jacobsantos, 4 years ago)

Better standards for example plugin, includes style patch.

  • hello.php

     
    11<?php 
    22/** 
    33 * @package Hello_Dolly 
     4 * @author Matt Mullenweg 
     5 * @version 1.5 
    46 */ 
    57/* 
    68Plugin Name: Hello Dolly 
     
    1113Author URI: http://ma.tt/ 
    1214*/ 
    1315 
    14 /** These are the lyrics to Hello Dolly */ 
    15 $lyrics = "Hello, Dolly 
     16function hello_dolly_get_lyric() { 
     17        /** These are the lyrics to Hello Dolly */ 
     18        $lyrics = "Hello, Dolly 
    1619Well, hello, Dolly 
    1720It's so nice to have you back where you belong 
    1821You're lookin' swell, Dolly 
     
    4144Dolly'll never go away 
    4245Dolly'll never go away again"; 
    4346 
    44 // Here we split it into lines 
    45 $lyrics = explode("\n", $lyrics); 
    46 // And then randomly choose a line 
    47 $chosen = wptexturize( $lyrics[ mt_rand(0, count($lyrics) - 1) ] ); 
     47        // Here we split it into lines 
     48        $lyrics = explode("\n", $lyrics); 
    4849 
     50        // And then randomly choose a line 
     51        return wptexturize( $lyrics[ mt_rand(0, count($lyrics) - 1) ] ); 
     52} 
     53 
    4954// This just echoes the chosen line, we'll position it later 
    5055function hello_dolly() { 
    51         global $chosen; 
     56        $chosen = hello_dolly_get_lyric(); 
    5257        echo "<p id='dolly'>$chosen</p>"; 
    5358} 
    5459 
     
    6166        <style type='text/css'> 
    6267        #dolly { 
    6368                position: absolute; 
    64                 top: 2.3em; 
     69                top: 4.5em; 
    6570                margin: 0; 
    6671                padding: 0; 
    67                 right: 10px; 
    68                 font-size: 16px; 
    69                 color: #d54e21; 
     72                right: 215px; 
     73                font-size: 11px; 
    7074        } 
    7175        </style> 
    7276        "; 
     
    7478 
    7579add_action('admin_head', 'dolly_css'); 
    7680 
    77 ?> 
    78  No newline at end of file 
     81?>