当前位置: 首页>>代码示例>>PHP>>正文


PHP bp_upload_dir函数代码示例

本文整理汇总了PHP中bp_upload_dir函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_upload_dir函数的具体用法?PHP bp_upload_dir怎么用?PHP bp_upload_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了bp_upload_dir函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: bp_attachments_uploads_dir_get

/**
 * Get the Attachments Uploads dir data
 *
 * @since  2.4.0
 *
 * @param  string        $data The data to get. Possible values are: 'dir', 'basedir' & 'baseurl'
 *                       Leave empty to get all datas.
 * @return string|array  The needed Upload dir data.
 */
function bp_attachments_uploads_dir_get($data = '')
{
    $attachments_dir = 'buddypress';
    $retval = '';
    if ('dir' === $data) {
        $retval = $attachments_dir;
    } else {
        $upload_data = bp_upload_dir();
        // Build the Upload data array for BuddyPress attachments
        foreach ($upload_data as $key => $value) {
            if ('basedir' === $key || 'baseurl' === $key) {
                $upload_data[$key] = trailingslashit($value) . $attachments_dir;
            } else {
                unset($upload_data[$key]);
            }
        }
        // Add the dir to the array
        $upload_data['dir'] = $attachments_dir;
        if (empty($data)) {
            $retval = $upload_data;
        } elseif (isset($upload_data[$data])) {
            $retval = $upload_data[$data];
        }
    }
    /**
     * Filter here to edit the Attachments upload dir data.
     *
     * @since  2.4.0
     *
     * @param  string|array $retval      The needed Upload dir data or the full array of data
     * @param  string       $data        The data requested
     */
    return apply_filters('bp_attachments_uploads_dir_get', $retval, $data);
}
开发者ID:enlacee,项目名称:anb.platicom.com.pe,代码行数:43,代码来源:bp-core-attachments.php

示例2: set_upload_dir

 /**
  * Set Upload Dir data for avatars.
  *
  * @since 2.3.0
  *
  * @uses bp_core_avatar_upload_path()
  * @uses bp_core_avatar_url()
  * @uses bp_upload_dir()
  * @uses BP_Attachment::set_upload_dir()
  */
 public function set_upload_dir()
 {
     if (bp_core_avatar_upload_path() && bp_core_avatar_url()) {
         $this->upload_path = bp_core_avatar_upload_path();
         $this->url = bp_core_avatar_url();
         $this->upload_dir = bp_upload_dir();
     } else {
         parent::set_upload_dir();
     }
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:20,代码来源:class-bp-attachment-avatar.php

示例3: test_bp_attachment_set_upload_dir

 public function test_bp_attachment_set_upload_dir()
 {
     $upload_dir = bp_upload_dir();
     $attachment_class = new BPTest_Attachment_Extension(array('action' => 'attachment_action', 'file_input' => 'attachment_file_input'));
     $this->assertSame($attachment_class->upload_dir, bp_upload_dir());
     $attachment_class = new BPTest_Attachment_Extension(array('action' => 'attachment_action', 'file_input' => 'attachment_file_input', 'base_dir' => 'attachment_base_dir'));
     $this->assertTrue(file_exists($upload_dir['basedir'] . '/attachment_base_dir'));
     // clean up
     $this->clean_files();
 }
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:10,代码来源:class-bp-attachment.php

示例4: bp_attachments_uploads_dir_get

/**
 * Get the Attachments Uploads dir data.
 *
 * @since 2.4.0
 *
 * @param string $data The data to get. Possible values are: 'dir', 'basedir' & 'baseurl'.
 *                     Leave empty to get all datas.
 * @return string|array The needed Upload dir data.
 */
function bp_attachments_uploads_dir_get($data = '')
{
    $attachments_dir = 'buddypress';
    $retval = '';
    if ('dir' === $data) {
        $retval = $attachments_dir;
    } else {
        $upload_data = bp_upload_dir();
        // Return empty string, if Uploads data are not available.
        if (!$upload_data) {
            return $retval;
        }
        // Build the Upload data array for BuddyPress attachments.
        foreach ($upload_data as $key => $value) {
            if ('basedir' === $key || 'baseurl' === $key) {
                $upload_data[$key] = trailingslashit($value) . $attachments_dir;
                // Fix for HTTPS.
                if ('baseurl' === $key && is_ssl()) {
                    $upload_data[$key] = str_replace('http://', 'https://', $upload_data[$key]);
                }
            } else {
                unset($upload_data[$key]);
            }
        }
        // Add the dir to the array.
        $upload_data['dir'] = $attachments_dir;
        if (empty($data)) {
            $retval = $upload_data;
        } elseif (isset($upload_data[$data])) {
            $retval = $upload_data[$data];
        }
    }
    /**
     * Filter here to edit the Attachments upload dir data.
     *
     * @since 2.4.0
     *
     * @param string|array $retval The needed Upload dir data or the full array of data
     * @param string       $data   The data requested
     */
    return apply_filters('bp_attachments_uploads_dir_get', $retval, $data);
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:51,代码来源:bp-core-attachments.php

示例5: bp_core_get_upload_dir

/**
 * Fetch data from the BP root blog's upload directory.
 *
 * @since 1.8.0
 *
 * @param string $type The variable we want to return from the $bp->avatars object.
 *                     Only 'upload_path' and 'url' are supported. Default: 'upload_path'.
 *
 * @return string The avatar upload directory path.
 */
function bp_core_get_upload_dir($type = 'upload_path')
{
    $bp = buddypress();
    switch ($type) {
        case 'upload_path':
            $constant = 'BP_AVATAR_UPLOAD_PATH';
            $key = 'basedir';
            break;
        case 'url':
            $constant = 'BP_AVATAR_URL';
            $key = 'baseurl';
            break;
        default:
            return false;
            break;
    }
    // See if the value has already been calculated and stashed in the $bp global.
    if (isset($bp->avatar->{$type})) {
        $retval = $bp->avatar->{$type};
    } else {
        // If this value has been set in a constant, just use that.
        if (defined($constant)) {
            $retval = constant($constant);
        } else {
            // Use cached upload dir data if available.
            if (!empty($bp->avatar->upload_dir)) {
                $upload_dir = $bp->avatar->upload_dir;
                // No cache, so query for it.
            } else {
                // Get upload directory information from current site.
                $upload_dir = bp_upload_dir();
                // Stash upload directory data for later use.
                $bp->avatar->upload_dir = $upload_dir;
            }
            // Directory does not exist and cannot be created.
            if (!empty($upload_dir['error'])) {
                $retval = '';
            } else {
                $retval = $upload_dir[$key];
                // If $key is 'baseurl', check to see if we're on SSL
                // Workaround for WP13941, WP15928, WP19037.
                if ($key == 'baseurl' && is_ssl()) {
                    $retval = str_replace('http://', 'https://', $retval);
                }
            }
        }
        // Stash in $bp for later use.
        $bp->avatar->{$type} = $retval;
    }
    return $retval;
}
开发者ID:toby-bushell,项目名称:triumph,代码行数:61,代码来源:bp-core-avatars.php

示例6: set_upload_dir

 /**
  * Set upload path and url for the component.
  *
  * @since 2.3.0
  *
  */
 public function set_upload_dir()
 {
     // Set the directory, path, & url variables.
     $this->upload_dir = bp_upload_dir();
     if (empty($this->upload_dir)) {
         return false;
     }
     $this->upload_path = $this->upload_dir['basedir'];
     $this->url = $this->upload_dir['baseurl'];
     // Ensure URL is https if SSL is set/forced.
     if (is_ssl()) {
         $this->url = str_replace('http://', 'https://', $this->url);
     }
     /**
      * Custom base dir.
      *
      * If the component set this property, set the specific path, url and create the dir
      */
     if (!empty($this->base_dir)) {
         $this->upload_path = trailingslashit($this->upload_path) . $this->base_dir;
         $this->url = trailingslashit($this->url) . $this->base_dir;
         // Finally create the base dir.
         $this->create_dir();
     }
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:31,代码来源:class-bp-attachment.php

示例7: setUp

 public function setUp()
 {
     parent::setUp();
     $this->upload_data = bp_upload_dir();
 }
开发者ID:MrVibe,项目名称:buddydrive,代码行数:5,代码来源:functions.php

示例8: test_bp_attachment_avatar_shrink

 /**
  * @group shrink
  * @group avatars
  */
 public function test_bp_attachment_avatar_shrink()
 {
     $image = BP_TESTS_DIR . 'assets/upside-down.jpg';
     $dir_copy = bp_upload_dir();
     // in case cleaning files fails
     if (!is_dir($dir_copy['basedir'] . '/shrink')) {
         mkdir($dir_copy['basedir'] . '/shrink');
     }
     $abs_path_copy = $dir_copy['basedir'] . '/shrink/upside-down.jpg';
     copy($image, $abs_path_copy);
     add_filter('bp_core_avatar_original_max_width', array($this, 'limit_to_50px'));
     $shrink = BP_Attachment_Avatar::shrink($abs_path_copy);
     remove_filter('bp_core_avatar_original_max_width', array($this, 'limit_to_50px'));
     $this->assertTrue(50 === $shrink['width'] && 50 === $shrink['height']);
     // Cleanup
     $this->clean_files('shrink');
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:21,代码来源:class-bp-attachment.php

示例9: test_bp_upload_dir

 /**
  * @group bp_attachments
  * @group bp_upload_dir
  */
 public function test_bp_upload_dir()
 {
     $expected_upload_dir = wp_upload_dir();
     if (is_multisite()) {
         $b = $this->factory->blog->create();
         switch_to_blog($b);
     }
     $tested_upload_dir = bp_upload_dir();
     if (is_multisite()) {
         restore_current_blog();
     }
     $this->assertSame($expected_upload_dir, $tested_upload_dir);
 }
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:17,代码来源:functions.php

示例10: buddydrive_public_relative_path

/**
 * Change the relative path to match with WordPress upload organisation
 *
 * @since 1.3.0
 *
 * @param  string $new_path the relative path to the protected file
 * @return string           the path to the public file
 */
function buddydrive_public_relative_path($new_path = '', $path = '')
{
    $bp_upload_dir = bp_upload_dir();
    $bd_relative = ltrim(str_replace($bp_upload_dir['basedir'], '', buddydrive()->upload_dir), '/');
    return ltrim(str_replace($bd_relative, '', $new_path), '/');
}
开发者ID:MrVibe,项目名称:buddydrive,代码行数:14,代码来源:buddydrive-item-filters.php

示例11: test_bp_upload_dir_ms

 /**
  * @group bp_attachments
  * @group bp_upload_dir
  */
 public function test_bp_upload_dir_ms()
 {
     if (!is_multisite()) {
         $this->markTestSkipped(__METHOD__ . ' is a multisite-only test.');
     }
     $expected_upload_dir = wp_upload_dir();
     $b = $this->factory->blog->create();
     switch_to_blog($b);
     $tested_upload_dir = bp_upload_dir();
     restore_current_blog();
     $this->assertSame($expected_upload_dir, $tested_upload_dir);
 }
开发者ID:AceMedia,项目名称:BuddyPress,代码行数:16,代码来源:functions.php


注:本文中的bp_upload_dir函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。