WordPress.org

Make WordPress Core

Changeset 12734


Ignore:
Timestamp:
01/15/2010 10:25:40 PM (8 years ago)
Author:
ryan
Message:

Coding style cleanups

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-activate.php

    r12733 r12734  
    88require_once( ABSPATH . WPINC . '/registration.php');
    99
    10 if( is_object( $wp_object_cache ) )
     10if ( is_object( $wp_object_cache ) )
    1111    $wp_object_cache->cache_enabled = false;
    1212
     
    5353                <h2><?php _e('Your account is now active!'); ?></h2>
    5454                <?php
    55                 if( $signup->domain . $signup->path == '' ) {
     55                if ( $signup->domain . $signup->path == '' ) {
    5656                    printf(__('<p class="lead-in">Your account has been activated. You may now <a href="%1$s">login</a> to the site using your chosen username of "%2$s".  Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.</p>'), 'http://' . $current_site->domain . $current_site->path . 'wp-login.php', $signup->user_login, $signup->user_email, 'http://' . $current_site->domain . $current_site->path . 'wp-login.php?action=lostpassword');
    5757                } else {
     
    7676            </div>
    7777
    78             <?php if( $url != 'http://' . $current_site->domain . $current_site->path ) : ?>
     78            <?php if ( $url != 'http://' . $current_site->domain . $current_site->path ) : ?>
    7979                <p class="view"><?php printf(__('Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Login</a>'), $url, $url . 'wp-login.php' ); ?></p>
    8080            <?php else: ?>
  • trunk/wp-app.php

    r12587 r12734  
    266266        global $always_authenticate;
    267267
    268         if( !empty( $_SERVER['ORIG_PATH_INFO'] ) )
     268        if ( !empty( $_SERVER['ORIG_PATH_INFO'] ) )
    269269            $path = $_SERVER['ORIG_PATH_INFO'];
    270270        else
     
    279279
    280280        // exception case for HEAD (treat exactly as GET, but don't output)
    281         if($method == 'HEAD') {
     281        if ($method == 'HEAD') {
    282282            $this->do_output = false;
    283283            $method = 'GET';
     
    285285
    286286        // redirect to /service in case no path is found.
    287         if(strlen($path) == 0 || $path == '/') {
     287        if(strlen($path) == 0 || $path == '/')
    288288            $this->redirect($this->get_service_url());
    289         }
    290289
    291290        // check to see if AtomPub is enabled
    292         if( !get_option( 'enable_app' ) )
     291        if ( !get_option( 'enable_app' ) )
    293292            $this->forbidden( sprintf( __( 'AtomPub services are disabled on this blog.  An admin user can enable them at %s' ), admin_url('options-writing.php') ) );
    294293
    295294        // dispatch
    296         foreach($this->selectors as $regex => $funcs) {
    297             if(preg_match($regex, $path, $matches)) {
    298             if(isset($funcs[$method])) {
    299 
    300                 // authenticate regardless of the operation and set the current
    301                 // user. each handler will decide if auth is required or not.
    302                 if(!$this->authenticate()) {
    303                     if ($always_authenticate) {
    304                         $this->auth_required('Credentials required.');
     295        foreach ( $this->selectors as $regex => $funcs ) {
     296            if ( preg_match($regex, $path, $matches) ) {
     297                if ( isset($funcs[$method]) ) {
     298
     299                    // authenticate regardless of the operation and set the current
     300                    // user. each handler will decide if auth is required or not.
     301                    if ( !$this->authenticate() ) {
     302                        if ( $always_authenticate )
     303                            $this->auth_required('Credentials required.');
    305304                    }
     305
     306                    array_shift($matches);
     307                    call_user_func_array(array(&$this,$funcs[$method]), $matches);
     308                    exit();
     309                } else {
     310                    // only allow what we have handlers for...
     311                    $this->not_allowed(array_keys($funcs));
    306312                }
    307 
    308                 array_shift($matches);
    309                 call_user_func_array(array(&$this,$funcs[$method]), $matches);
    310                 exit();
    311             } else {
    312                 // only allow what we have handlers for...
    313                 $this->not_allowed(array_keys($funcs));
    314             }
    315313            }
    316314        }
     
    328326        log_app('function','get_service()');
    329327
    330         if( !current_user_can( 'edit_posts' ) )
     328        if ( !current_user_can( 'edit_posts' ) )
    331329            $this->auth_required( __( 'Sorry, you do not have the right to access this blog.' ) );
    332330
     
    339337        }
    340338        $atom_prefix="atom";
    341         $atom_blogname=get_bloginfo('name');
     339        $atom_blogname = get_bloginfo('name');
    342340        $service_doc = <<<EOD
    343341<service xmlns="$this->ATOMPUB_NS" xmlns:$atom_prefix="$this->ATOM_NS">
     
    369367        log_app('function','get_categories_xml()');
    370368
    371         if( !current_user_can( 'edit_posts' ) )
     369        if ( !current_user_can( 'edit_posts' ) )
    372370            $this->auth_required( __( 'Sorry, you do not have the right to access this blog.' ) );
    373371
     
    376374        $categories = "";
    377375        $cats = get_categories(array('hierarchical' => 0, 'hide_empty' => 0));
    378         foreach ((array) $cats as $cat) {
     376        foreach ( (array) $cats as $cat ) {
    379377            $categories .= "    <category term=\"" . esc_attr($cat->name) .  "\" />\n";
    380 }
     378        }
    381379        $output = <<<EOD
    382380<app:categories xmlns:app="$this->ATOMPUB_NS"
     
    386384</app:categories>
    387385EOD;
    388     $this->output($output, $this->CATEGORIES_CONTENT_TYPE);
    389 }
     386        $this->output($output, $this->CATEGORIES_CONTENT_TYPE);
     387    }
    390388
    391389    /**
     
    399397
    400398        $parser = new AtomParser();
    401         if(!$parser->parse()) {
     399        if ( !$parser->parse() )
    402400            $this->client_error();
    403         }
    404401
    405402        $entry = array_pop($parser->feed->entries);
     
    408405
    409406        $catnames = array();
    410         foreach($entry->categories as $cat)
     407        foreach ( $entry->categories as $cat ) {
    411408            array_push($catnames, $cat["term"]);
     409        }
    412410
    413411        $wp_cats = get_categories(array('hide_empty' => false));
     
    415413        $post_category = array();
    416414
    417         foreach($wp_cats as $cat) {
    418             if(in_array($cat->name, $catnames))
     415        foreach ( $wp_cats as $cat ) {
     416            if ( in_array($cat->name, $catnames) )
    419417                array_push($post_category, $cat->term_id);
    420418        }
     
    424422        $cap = ($publish) ? 'publish_posts' : 'edit_posts';
    425423
    426         if(!current_user_can($cap))
     424        if ( !current_user_can($cap) )
    427425            $this->auth_required(__('Sorry, you do not have the right to edit/publish new posts.'));
    428426
     
    449447            $this->internal_error($postID->get_error_message());
    450448
    451         if (!$postID)
     449        if ( !$postID )
    452450            $this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.'));
    453451
     
    476474        global $entry;
    477475
    478         if( !current_user_can( 'edit_post', $postID ) )
     476        if ( !current_user_can( 'edit_post', $postID ) )
    479477            $this->auth_required( __( 'Sorry, you do not have the right to access this post.' ) );
    480478
     
    499497
    500498        $parser = new AtomParser();
    501         if(!$parser->parse()) {
     499        if ( !$parser->parse() )
    502500            $this->bad_request();
    503         }
    504501
    505502        $parsed = array_pop($parser->feed->entries);
     
    511508        $this->set_current_entry($postID);
    512509
    513         if(!current_user_can('edit_post', $entry['ID']))
     510        if ( !current_user_can('edit_post', $entry['ID']) )
    514511            $this->auth_required(__('Sorry, you do not have the right to edit this post.'));
    515512
     
    534531        $result = wp_update_post($postdata);
    535532
    536         if (!$result) {
     533        if ( !$result )
    537534            $this->internal_error(__('For some strange yet very annoying reason, this post could not be edited.'));
    538         }
    539535
    540536        do_action( 'atompub_put_post', $ID, $parsed );
     
    557553        $this->set_current_entry($postID);
    558554
    559         if(!current_user_can('edit_post', $postID)) {
     555        if ( !current_user_can('edit_post', $postID) )
    560556            $this->auth_required(__('Sorry, you do not have the right to delete this post.'));
    561         }
    562 
    563         if ($entry['post_type'] == 'attachment') {
     557
     558        if ( $entry['post_type'] == 'attachment' ) {
    564559            $this->delete_attachment($postID);
    565560        } else {
    566561            $result = wp_delete_post($postID);
    567562
    568             if (!$result) {
     563            if ( !$result ) {
    569564                $this->internal_error(__('For some strange yet very annoying reason, this post could not be deleted.'));
    570565            }
     
    584579     */
    585580    function get_attachment($postID = null) {
    586         if( !current_user_can( 'upload_files' ) )
     581        if ( !current_user_can( 'upload_files' ) )
    587582            $this->auth_required( __( 'Sorry, you do not have permission to upload files.' ) );
    588583
    589         if (!isset($postID)) {
     584        if ( !isset($postID) ) {
    590585            $this->get_attachments();
    591586        } else {
     
    606601        $type = $this->get_accepted_content_type();
    607602
    608         if(!current_user_can('upload_files'))
     603        if ( !current_user_can('upload_files') )
    609604            $this->auth_required(__('You do not have permission to upload files.'));
    610605
    611606        $fp = fopen("php://input", "rb");
    612607        $bits = null;
    613         while(!feof($fp)) {
     608        while ( !feof($fp) ) {
    614609            $bits .= fread($fp, 4096);
    615610        }
     
    679674        $this->set_current_entry($postID);
    680675
    681         if(!current_user_can('edit_post', $entry['ID']))
     676        if ( !current_user_can('edit_post', $entry['ID']) )
    682677            $this->auth_required(__('Sorry, you do not have the right to edit this post.'));
    683678
     
    695690        $result = wp_update_post($postdata);
    696691
    697         if (!$result) {
     692        if ( !$result )
    698693            $this->internal_error(__('For some strange yet very annoying reason, this post could not be edited.'));
    699         }
    700694
    701695        log_app('function',"put_attachment($postID)");
     
    717711        $this->set_current_entry($postID);
    718712
    719         if(!current_user_can('edit_post', $postID)) {
     713        if ( !current_user_can('edit_post', $postID) )
    720714            $this->auth_required(__('Sorry, you do not have the right to delete this post.'));
    721         }
    722715
    723716        $location = get_post_meta($entry['ID'], '_wp_attached_file', true);
    724717        $filetype = wp_check_filetype($location);
    725718
    726         if(!isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext']))
     719        if ( !isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext']) )
    727720            $this->internal_error(__('Error ocurred while accessing post metadata for file location.'));
    728721
     
    733726        $result = wp_delete_post($postID);
    734727
    735         if (!$result) {
     728        if ( !$result )
    736729            $this->internal_error(__('For some strange yet very annoying reason, this post could not be deleted.'));
    737         }
    738730
    739731        log_app('function',"delete_attachment($postID). File '$location' deleted.");
     
    755747
    756748        // then whether user can edit the specific post
    757         if(!current_user_can('edit_post', $postID)) {
     749        if ( !current_user_can('edit_post', $postID) )
    758750            $this->auth_required(__('Sorry, you do not have the right to edit this post.'));
    759         }
    760751
    761752        $location = get_post_meta($entry['ID'], '_wp_attached_file', true);
     
    763754        $filetype = wp_check_filetype($location);
    764755
    765         if(!isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext']))
     756        if ( !isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext']) )
    766757            $this->internal_error(__('Error ocurred while accessing post metadata for file location.'));
    767758
     
    770761        header('Connection: close');
    771762
    772         if ($fp = fopen($location, "rb")) {
     763        if ( $fp = fopen($location, "rb") ) {
    773764            status_header('200');
    774765            header('Content-Type: ' . $entry['post_mime_type']);
    775766            header('Connection: close');
    776767
    777             while(!feof($fp)) {
     768            while ( !feof($fp) ) {
    778769                echo fread($fp, 4096);
    779770            }
     
    798789
    799790        // first check if user can upload
    800         if(!current_user_can('upload_files'))
     791        if ( !current_user_can('upload_files') )
    801792            $this->auth_required(__('You do not have permission to upload files.'));
    802793
     
    806797
    807798        // then whether user can edit the specific post
    808         if(!current_user_can('edit_post', $postID)) {
     799        if ( !current_user_can('edit_post', $postID) )
    809800            $this->auth_required(__('Sorry, you do not have the right to edit this post.'));
    810         }
    811801
    812802        $upload_dir = wp_upload_dir( );
     
    821811        $fp = fopen("php://input", "rb");
    822812        $localfp = fopen($location, "w+");
    823         while(!feof($fp)) {
     813        while ( !feof($fp) ) {
    824814            fwrite($localfp,fread($fp, 4096));
    825815        }
     
    838828        $result = wp_update_post($post_data);
    839829
    840         if (!$result) {
     830        if ( !$result )
    841831            $this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.'));
    842         }
    843832
    844833        wp_update_attachment_metadata( $postID, wp_generate_attachment_metadata( $postID, $location ) );
     
    857846     */
    858847    function get_entries_url($page = null) {
    859         if ( isset($GLOBALS['post_type']) && ( $GLOBALS['post_type'] == 'attachment' ) ) {
     848        if ( isset($GLOBALS['post_type']) && ( $GLOBALS['post_type'] == 'attachment' ) )
    860849            $path = $this->MEDIA_PATH;
    861         } else {
     850        else
    862851            $path = $this->ENTRIES_PATH;
    863         }
    864852        $url = $this->app_base . $path;
    865         if(isset($page) && is_int($page)) {
     853        if ( isset($page) && is_int($page) )
    866854            $url .= "/$page";
    867         }
    868855        return $url;
    869856    }
  • trunk/wp-includes/load.php

    r12732 r12734  
    272272
    273273function wp_not_installed() {
    274     if( is_multisite() ) {
    275             if ( !is_blog_installed() && !defined('WP_INSTALLING') ) {
     274    if ( is_multisite() ) {
     275            if ( !is_blog_installed() && !defined('WP_INSTALLING') )
    276276                    die( __( 'The blog you have requested is not installed properly. Please contact the system administrator.' ) ); // have to die here ~ Mark
    277             }
    278277    } elseif ( !is_blog_installed() && (strpos($_SERVER['PHP_SELF'], 'install.php') === false && !defined('WP_INSTALLING')) ) {
    279278        if ( defined('WP_SITEURL') )
     
    330329    }
    331330    unset($current_plugins);
    332 
    333331}
    334332
  • trunk/wp-settings.php

    r12732 r12734  
    6565include_once(ABSPATH . WPINC . '/pomo/mo.php');
    6666
    67 if( is_multisite() && SHORTINIT ) // stop most of WP being loaded, we just want the basics
     67if ( SHORTINIT ) // stop most of WP being loaded, we just want the basics
    6868    return false;
    6969
     
    111111wp_default_constants('wp_included');
    112112
    113 if( is_multisite() )
    114         ms_network_settings();
     113if ( is_multisite() )
     114    ms_network_settings();
    115115
    116116wp_default_constants('ms_network_settings_loaded');
     
    122122 * @since 3.0
    123123 */
    124 if( is_multisite() )
     124if ( is_multisite() )
    125125    ms_network_plugins();
    126126
     
    131131 * @since 3.0
    132132 */
    133 if( is_multisite() ) {
     133if ( is_multisite() ) {
    134134    ms_site_check();
    135135    ms_network_cookies();
Note: See TracChangeset for help on using the changeset viewer.