WordPress.org

Making WordPress.org

Changeset 3045


Ignore:
Timestamp:
04/29/2016 12:41:35 AM (6 years ago)
Author:
kovshenin
Message:

WordCamp.org: Attempt to fix the uploads directory when pushing out global sponsors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-new-site.php

    r3044 r3045  
    182182        }
    183183
     184        add_filter( 'upload_dir', array( $this, '_fix_wc_upload_dir' ) );
     185
    184186        foreach ( $sponsors as $sponsor ) {
    185187            // Skip existing sponsors.
     
    220222        }
    221223
     224        remove_filter( 'upload_dir', array( $this, '_fix_wc_upload_dir' ) );
     225
    222226        restore_current_blog();
     227    }
     228
     229    /**
     230     * Fix upload directories when in a switched to blog context.
     231     *
     232     * WordCamp.org runs with WordPress in its own directory (mu) as an external.
     233     * When switching to a subsite, WordPress thinks the upload directory is
     234     * relative to ABSPATH, so we need so trip out the /mu part.
     235     *
     236     * @param array $data Data from wp_upload_dir().
     237     *
     238     * @return array Result.
     239     */
     240    public function _fix_wc_upload_dir( $data ) {
     241        $data['path'] = str_replace( '/home/wordcamp/public_html/mu/wp-content',
     242            '/home/wordcamp/public_html/wp-content', $data['path'] );
     243
     244        $data['basedir'] = str_replace( '/home/wordcamp/public_html/mu/wp-content',
     245            '/home/wordcamp/public_html/wp-content', $data['basedir'] );
     246
     247        return $data;
    223248    }
    224249
Note: See TracChangeset for help on using the changeset viewer.