Plugin Directory

Changeset 138256


Ignore:
Timestamp:
07/23/2009 08:58:15 AM (17 years ago)
Author:
sakuratan
Message:

Spaces for following the wordPress coding standards.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • external-css/trunk/external-css.php

    r136987 r138256  
    3434 * Returns path of the css file.
    3535 */
    36 function external_css_path($base) {
     36function external_css_path( $base ) {
    3737    return "{$base}/wp-content/cache/external-css/custom.css";
    3838}
     
    4242 */
    4343function external_css_embed_link_tag() {
    44     $url = htmlspecialchars(external_css_path(get_option('siteurl')));
     44    $url = htmlspecialchars( external_css_path( get_option( 'siteurl' ) ) );
    4545    echo "<link href=\"{$url}\" rel=\"stylesheet\" type=\"text/css\" media=\"screen,projection\" />";
    4646}
     
    4949 * Display errors.
    5050 */
    51 function external_css_error($s) {
     51function external_css_error( $s ) {
    5252    echo '<p class="error">';
    53     echo htmlspecialchars($s);
     53    echo htmlspecialchars( $s );
    5454    echo '</p>';
    5555}
     
    5858 * Save the css file.
    5959 */
    60 function external_css_save($css) {
    61     $path = external_css_path(ABSPATH);
    62     $dir = dirname($path);
    63     if (!is_dir($dir)) {
    64     if (!mkdir($dir, 0755, true)) {
    65         external_css_error(__('Failed to create directory', 'external-css'));
     60function external_css_save( $css ) {
     61    $path = external_css_path( ABSPATH );
     62    $dir = dirname( $path );
     63    if ( !is_dir( $dir ) ) {
     64    if ( !mkdir( $dir, 0755, true ) ) {
     65        external_css_error( __( 'Failed to create directory', 'external-css' ) );
    6666        return;
    6767    }
    6868    }
    6969
    70     $tmpfile = tempnam($dir, 'tmp');
    71     if (!$tmpfile) {
    72     external_css_error(__('Failed to create temporary file', 'external-css'));
     70    $tmpfile = tempnam( $dir, 'tmp' );
     71    if ( !$tmpfile ) {
     72    external_css_error( __( 'Failed to create temporary file', 'external-css' ) );
    7373    return false;
    7474    }
    7575
    76     $fh = fopen($tmpfile, 'wb');
    77     if (!$fh) {
    78     external_css_error(__('Failed to open temporary file', 'external-css'));
     76    $fh = fopen( $tmpfile, 'wb' );
     77    if ( !$fh ) {
     78    external_css_error( __( 'Failed to open temporary file', 'external-css' ) );
    7979    return false;
    8080    }
    81     fwrite($fh, $css);
    82     fclose($fh);
     81    fwrite( $fh, $css );
     82    fclose( $fh );
    8383
    84     if (!chmod($tmpfile, 0644)) {
    85     external_css_error(__('Failed to chmod temporary file', 'external-css'));
     84    if ( !chmod( $tmpfile, 0644 ) ) {
     85    external_css_error( __( 'Failed to chmod temporary file', 'external-css' ) );
    8686    return false;
    8787    }
    8888
    8989    /* Update css with POSIX atomic function */
    90     if (!rename($tmpfile, $path)) {
    91     external_css_error(__('Failed to rename CSS', 'external-css'));
     90    if ( !rename( $tmpfile, $path ) ) {
     91    external_css_error( __( 'Failed to rename CSS', 'external-css' ) );
    9292    return false;
    9393    }
     
    100100 */
    101101function external_css_theme_page() {
    102     $path = external_css_path(ABSPATH);
    103     if (array_key_exists('external_css', $_POST)) {
    104     if (external_css_save(stripslashes($_POST['external_css']))) {
     102    $path = external_css_path( ABSPATH );
     103    if ( array_key_exists( 'external_css', $_POST ) ) {
     104    if ( external_css_save( stripslashes( $_POST['external_css'] ) ) ) {
    105105        echo '<div class="updated"><p><strong>';
    106         _e('Options saved.', 'external-css' );
     106        _e( 'Options saved.', 'external-css' );
    107107        echo '</strong></p></div>';
    108108    }
    109109    } else {
    110     $dir = dirname($path);
    111     if (!is_dir($dir) || !is_writable($dir)) {
    112         if (!mkdir($dir, 0755, true)) {
    113         external_css_error(sprintf(__('External CSS cannot continue the process because missing permissions for %s. Add the read and write permissions of the directory to the user of the web server to fix the problem.', 'external-css'), $dir));
     110    $dir = dirname( $path );
     111    if ( !is_dir( $dir ) || !is_writable( $dir ) ) {
     112        if ( !mkdir( $dir, 0755, true ) ) {
     113        external_css_error( sprintf( __( 'External CSS cannot continue the process because missing permissions for %s. Add the read and write permissions of the directory to the user of the web server to fix the problem.', 'external-css' ), $dir ) );
    114114        return;
    115115        }
    116116    }
    117     if (!file_exists($path)) {
    118         external_css_save('/* Edit this css file */');
     117    if ( !file_exists( $path ) ) {
     118        external_css_save( '/* Edit this css file */' );
    119119    }
    120120    }
     
    123123<h2>External CSS Options</h2>
    124124
    125 <form method="post" action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']) ?>">
     125<form method="post" action="<?php echo htmlspecialchars( $_SERVER['REQUEST_URI'] ) ?>">
    126126
    127127<textarea cols="70" rows="25" name="external_css" style="overflow-y:scroll"><?php
    128     readfile($path);
     128    readfile( $path );
    129129?></textarea>
    130130
    131 <p class="submit"><input type="submit" class="button-primary" value="<?php _e('Save Changes', 'external-css') ?>" /></p>
     131<p class="submit"><input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'external-css' ) ?>" /></p>
    132132
    133133</form>
     
    139139 */
    140140function external_css_admin_menu() {
    141     add_theme_page('External CSS Options', 'External CSS', 'switch_themes',
    142            __FILE__, 'external_css_theme_page');
     141    add_theme_page( 'External CSS Options', 'External CSS', 'switch_themes',
     142           __FILE__, 'external_css_theme_page' );
    143143}
    144144
     
    147147 */
    148148function external_css_init() {
    149     load_plugin_textdomain('external-css',
    150                'wp-content/plugins/external-css/po',
    151                'external-css/po');
    152     add_action('admin_menu', 'external_css_admin_menu');
    153     add_action('wp_head', 'external_css_embed_link_tag', 100);
     149    load_plugin_textdomain( 'external-css',
     150                'wp-content/plugins/external-css/po',
     151                'external-css/po' );
     152    add_action( 'admin_menu', 'external_css_admin_menu' );
     153    add_action( 'wp_head', 'external_css_embed_link_tag', 100 );
    154154}
    155155
    156 add_action('init', 'external_css_init');
     156add_action( 'init', 'external_css_init' );
    157157
    158158?>
Note: See TracChangeset for help on using the changeset viewer.