• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_upload_dir函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __construct

 /**
  * Constructor for the Anthologize class
  *
  * This constructor does the following:
  * - Checks minimum PHP and WP version, and bails if they're not met
  * - Includes Anthologize's main files
  * - Sets up the basic hooks that initialize Anthologize's post types and UI
  *
  * @since 0.7
  */
 public function __construct()
 {
     // Bail if PHP version is not at least 5.0
     if (!self::check_minimum_php()) {
         add_action('admin_notices', array('Anthologize', 'phpversion_nag'));
         return;
     }
     // Bail if WP version is not at least 3.3
     if (!self::check_minimum_wp()) {
         add_action('admin_notices', array('Anthologize', 'wpversion_nag'));
     }
     // If we've made it this far, start initializing Anthologize
     register_activation_hook(__FILE__, array($this, 'activation'));
     register_deactivation_hook(__FILE__, array($this, 'deactivation'));
     // @todo WP's functions plugin_basename() etc don't work
     //   correctly on symlinked setups, so I'm implementing my own
     $bn = explode(DIRECTORY_SEPARATOR, dirname(__FILE__));
     $this->basename = array_pop($bn);
     $this->plugin_dir = plugin_dir_path(__FILE__);
     $this->plugin_url = plugin_dir_url(__FILE__);
     $this->includes_dir = trailingslashit($this->plugin_dir . 'includes');
     $upload_dir = wp_upload_dir();
     $this->cache_dir = trailingslashit($upload_dir['basedir'] . '/anthologize-cache');
     $this->cache_url = trailingslashit($upload_dir['baseurl'] . '/anthologize-cache');
     $this->setup_constants();
     $this->includes();
     $this->setup_hooks();
 }
开发者ID:webremote,项目名称:anthologize,代码行数:38,代码来源:anthologize.php


示例2: cherry_plugin_settings

 function cherry_plugin_settings()
 {
     global $wpdb;
     if (!function_exists('get_plugin_data')) {
         require_once ABSPATH . 'wp-admin/includes/plugin.php';
     }
     $upload_dir = wp_upload_dir();
     $plugin_data = get_plugin_data(plugin_dir_path(__FILE__) . 'cherry-plugin.php');
     //Cherry plugin constant variables
     define('CHERRY_PLUGIN_DIR', plugin_dir_path(__FILE__));
     define('CHERRY_PLUGIN_URL', plugin_dir_url(__FILE__));
     define('CHERRY_PLUGIN_DOMAIN', $plugin_data['TextDomain']);
     define('CHERRY_PLUGIN_DOMAIN_DIR', $plugin_data['DomainPath']);
     define('CHERRY_PLUGIN_VERSION', $plugin_data['Version']);
     define('CHERRY_PLUGIN_NAME', $plugin_data['Name']);
     define('CHERRY_PLUGIN_SLUG', plugin_basename(__FILE__));
     define('CHERRY_PLUGIN_DB', $wpdb->prefix . CHERRY_PLUGIN_DOMAIN);
     define('CHERRY_PLUGIN_REMOTE_SERVER', esc_url('http://tmbhtest.com/cherryframework.com/components_update/'));
     //Other constant variables
     define('CURRENT_THEME_DIR', get_stylesheet_directory());
     define('CURRENT_THEME_URI', get_stylesheet_directory_uri());
     define('UPLOAD_BASE_DIR', str_replace("\\", "/", $upload_dir['basedir']));
     define('UPLOAD_DIR', str_replace("\\", "/", $upload_dir['path'] . '/'));
     // if ( !defined('API_URL') ) {
     // 	define( 'API_URL', esc_url( 'http://updates.cherry.template-help.com/cherrymoto/v3/api/' ) );
     // }
     load_plugin_textdomain(CHERRY_PLUGIN_DOMAIN, false, dirname(plugin_basename(__FILE__)) . '/' . CHERRY_PLUGIN_DOMAIN_DIR);
     do_action('cherry_plugin_settings');
 }
开发者ID:drupalninja,项目名称:schome_org,代码行数:29,代码来源:cherry-plugin.php


示例3: __construct

 /**
  * Instantiates Env Manager object
  * 
  */
 protected function __construct()
 {
     $uploads_data = wp_upload_dir();
     $template_url = get_bloginfo('template_url');
     // Instantiate paths collection object
     $this->__urls = new Collection(array('home' => home_url(), 'admin' => admin_url(), 'plugins' => plugins_url(), 'content' => content_url(), 'uploads' => $uploads_data['baseurl'], 'themes' => str_replace('/' . basename($template_url), '', $template_url), 'theme' => $template_url));
 }
开发者ID:ponticlaro,项目名称:bebop-common,代码行数:11,代码来源:UrlManager.php


示例4: grayscale_check_grayscale_image

function grayscale_check_grayscale_image($metadata, $attachment_id)
{
    global $_wp_additional_image_sizes;
    $attachment = get_post($attachment_id);
    if (preg_match('!image!', get_post_mime_type($attachment))) {
        require_once 'class-grayscale-image-editor.php';
        foreach ($_wp_additional_image_sizes as $size => $size_data) {
            if (isset($size_data['grayscale']) && $size_data['grayscale']) {
                if (is_array($metadata['sizes']) && isset($metadata['sizes'][$size])) {
                    $file = pathinfo(get_attached_file($attachment_id));
                    $filename = $file['dirname'] . '/' . $metadata['sizes'][$size]['file'];
                    $metadata['sizes'][$size . '-gray'] = $metadata['sizes'][$size];
                } else {
                    // this size has no image attached, probably because the original is too small
                    // create the grayscale image from the original file
                    $file = wp_upload_dir();
                    $filename = $file['basedir'] . '/' . $metadata['file'];
                    $metadata['sizes'][$size . '-gray'] = array('width' => $metadata['width'], 'height' => $metadata['height']);
                }
                $image = new Grayscale_Image_Editor($filename);
                $image->load();
                $image->make_grayscale();
                $result = $image->save($image->generate_filename('gray'));
                $metadata['sizes'][$size . '-gray']['file'] = $result['file'];
            }
        }
    }
    return $metadata;
}
开发者ID:jeffhertzler,项目名称:grayscale,代码行数:29,代码来源:grayscale.php


示例5: __construct

 /**
  * __construct()
  *
  * The main SRP Class constructor
  *
  * @author Luca Grandicelli <[email protected]>
  * @copyright (C) 2011-2014 Luca Grandicelli
  * @package special-recent-posts-free
  * @version 2.0.4
  * @access public
  * @global $srp_default_widget_values The global default widget presets.
  * @global $post The global $post WP object.
  * @param array $args The widget instance configuration values.
  * @param string The current Widget ID.
  * @return boolean true
  */
 public function __construct($args = array(), $widget_id = NULL)
 {
     // Setting up uploads dir for multi-site hack.
     $this->uploads_dir = wp_upload_dir();
     // Including global default widget values.
     global $srp_default_widget_values;
     // Setting up plugin options to be available throughout the plugin.
     $this->plugin_args = get_option('srp_plugin_options');
     // Double check if $args is an array.
     $args = !is_array($args) ? array() : SpecialRecentPostsFree::srp_version_map_check($args);
     // Setting up widget options to be available throughout the plugin.
     $this->widget_args = array_merge($srp_default_widget_values, $args);
     // Setting up post/page ID when on a single post/page.
     if (is_single() || is_page()) {
         // Including global $post object.
         global $post;
         // Assigning post ID.
         $this->singleID = $post->ID;
     }
     // Setting up Cache Folder Base Path.
     $this->cache_basepath = SRP_CACHE_DIR;
     // Setting up current widget instance id.
     $this->widget_id = $widget_id ? $widget_id : false;
     // Returning true.
     return true;
 }
开发者ID:alenteria,项目名称:vitrari,代码行数:42,代码来源:class-main.php


示例6: getImage

 public function getImage($id)
 {
     $image_fields = array("ID" => "ID", "guid" => "file", "post_mime_type" => "mime_type");
     $indexable_image_size = get_intermediate_image_sizes();
     $uploadDir = wp_upload_dir();
     $uploadBaseUrl = $uploadDir['baseurl'];
     $image = new \stdClass();
     $post = get_post($id);
     foreach ($image_fields as $key => $value) {
         $image->{$value} = $post->{$key};
     }
     $metas = get_post_meta($post->ID, '_wp_attachment_metadata', true);
     $image->width = $metas["width"];
     $image->height = $metas["height"];
     $image->file = sprintf('%s/%s', $uploadBaseUrl, $metas["file"]);
     $image->sizes = $metas["sizes"] ? $metas["sizes"] : array();
     foreach ($image->sizes as $size => &$sizeAttrs) {
         if (in_array($size, $indexable_image_size) == false) {
             unset($image->sizes[$size]);
             continue;
         }
         $baseFileUrl = str_replace(wp_basename($metas['file']), '', $metas['file']);
         $sizeAttrs['file'] = sprintf('%s/%s%s', $uploadBaseUrl, $baseFileUrl, $sizeAttrs['file']);
     }
     return $image;
 }
开发者ID:PoNote,项目名称:algoliasearch-wordpress,代码行数:26,代码来源:WordpressFetcher.php


示例7: export

 /**
  * Export data
  * @param string $format
  * @param array $options
  * @throws Exception
  */
 public function export($format = self::EXPORT_DISPLAY, $options = array())
 {
     global $wpdb;
     $options = array();
     $options['upload_dir'] = wp_upload_dir();
     $options['options'] = array();
     $options['options']['permalink_structure'] = get_option('permalink_structure');
     $widgets = $wpdb->get_results("SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE 'widget_%'");
     foreach ($widgets as $widget) {
         $options['options'][$widget->option_name] = $this->compress(get_option($widget->option_name));
     }
     $options['options']['sidebars_widgets'] = $this->compress(get_option('sidebars_widgets'));
     $current_template = get_option('stylesheet');
     $options['options']["theme_mods_{$current_template}"] = $this->compress(get_option("theme_mods_{$current_template}"));
     $data = serialize($options);
     if ($format == self::EXPORT_DISPLAY) {
         echo '<textarea>' . $data . '</textarea>';
     }
     //export settings to file
     if ($format == self::EXPORT_FILE) {
         $path = isset($options['path']) ? $options['path'] : self::getWpOptionsPath();
         if (!file_put_contents($path, $data)) {
             throw new Exception("Cannot save settings to: " . $path);
         }
     }
 }
开发者ID:clevervaughn,项目名称:dottiesbiscuitbarn,代码行数:32,代码来源:ctDemoExporterImporter.class.php


示例8: get_avatar_from_meta

 private static function get_avatar_from_meta($url, $user_id)
 {
     static $caches = [];
     if (isset($caches[$user_id])) {
         return $caches[$user_id];
     }
     $meta = get_user_meta($user_id, self::$user_meta_key['avatar'], true);
     if (empty($meta)) {
         $caches[$user_id] = $url;
         return $caches[$user_id];
     }
     /**
      * if is /12/2015/xx.jpg format, add upload baseurl
      */
     if (strpos($meta, 'http') === false || strpos($meta, '//') === false) {
         static $baseurl;
         if (!$baseurl) {
             $baseurl = wp_upload_dir()['baseurl'];
         }
         $caches[$user_id] = $baseurl . $meta;
     } else {
         $caches[$user_id] = $meta;
     }
     return $caches[$user_id];
 }
开发者ID:ClayMoreBoy,项目名称:mx,代码行数:25,代码来源:custom-avatar.php


示例9: migrate_attachment_to_s3

 /**
  * Migrate a single attachment's files to S3
  *
  * @subcommand migrate-attachment
  * @synopsis <attachment-id> [--delete-local]
  */
 public function migrate_attachment_to_s3($args, $args_assoc)
 {
     // Ensure things are active
     $instance = S3_Uploads::get_instance();
     if (!s3_uploads_enabled()) {
         $instance->setup();
     }
     $old_upload_dir = $instance->get_original_upload_dir();
     $upload_dir = wp_upload_dir();
     $files = array(get_post_meta($args[0], '_wp_attached_file', true));
     $meta_data = wp_get_attachment_metadata($args[0]);
     if (!empty($meta_data['sizes'])) {
         foreach ($meta_data['sizes'] as $file) {
             $files[] = path_join(dirname($meta_data['file']), $file['file']);
         }
     }
     foreach ($files as $file) {
         if (file_exists($path = $old_upload_dir['basedir'] . '/' . $file)) {
             if (!copy($path, $upload_dir['basedir'] . '/' . $file)) {
                 WP_CLI::line(sprintf('Failed to moved %s to S3', $file));
             } else {
                 if (!empty($args_assoc['delete-local'])) {
                     unlink($path);
                 }
                 WP_CLI::success(sprintf('Moved file %s to S3', $file));
             }
         } else {
             WP_CLI::line(sprintf('Already moved to %s S3', $file));
         }
     }
 }
开发者ID:iamlos,项目名称:S3-Uploads,代码行数:37,代码来源:class-s3-uploads-wp-cli-command.php


示例10: __construct

 /**
  * Sets up a log directory. Assumed to be in uploads/___PluginName___ unless it's explicitly passed
  * Not much we can do if we get errors trying to find somewhere to write the log file
  *
  * @param string $logDirectory
  */
 function __construct($logDirectory = '')
 {
     if (!empty($logDirectory)) {
         $this->logDirectory = $logDirectory;
     } else {
         $uploadDirectory = wp_upload_dir();
         if ($uploadDirectory['error'] !== false) {
             return;
         }
         /**
          * Normalize the path just in case we're running on a Windows server
          */
         $this->logDirectory = rtrim(str_replace('\\', '/', $uploadDirectory['basedir']) . "/EasyRecipePlus", '/');
     }
     /**
      * If the log directory isn't present and a directory, try to create it
      */
     if (!file_exists($this->logDirectory)) {
         @mkdir($this->logDirectory, 0777, true);
     }
     /**
      * If the log directory doesn't exist, isn't writeable and/or isn't a directory, then we're screwed
      */
     if (!file_exists($this->logDirectory) || !is_writable($this->logDirectory) || !is_dir($this->logDirectory)) {
         $this->logDirectory = null;
     }
     /**
      * Just in case we have a server with autoindexing set ON, write a dummy index.html so the log file names can't be accessed from the web
      */
     if (!file_exists($this->logDirectory . "/index.html")) {
         file_put_contents($this->logDirectory . "/index.html", "<html><body></body></html>");
     }
 }
开发者ID:Bakerpedia,项目名称:Development_Site5,代码行数:39,代码来源:EasyRecipePlusDebugLog.php


示例11: uploads_proxy

/**
 * Get uploads from the production site and store them
 * in the local filesystem if they don't already exist.
 *
 * @return  void
 */
function uploads_proxy()
{
    global $wp_filesystem;
    WP_Filesystem();
    // The relative request path
    $requestPath = $_SERVER['REQUEST_URI'];
    // The relative uploads path
    $uploadsPath = str_replace(get_bloginfo('url'), '', wp_upload_dir()['baseurl']);
    // Check if a upload was requested
    if (strpos($requestPath, $uploadsPath) === 0) {
        // The absolute remote path to the upload
        $remotePath = UP_SITEURL . $requestPath;
        // Get the remote upload file
        $response = wp_remote_get($remotePath);
        // Check the response code
        if ($response['response']['code'] === 200) {
            // The file path relative to the uploads path to store the upload file to
            $relativeUploadFile = str_replace($uploadsPath, '', $_SERVER['REQUEST_URI']);
            // The absolute file path to store the upload file to
            $absoluteUploadFile = wp_upload_dir()['basedir'] . $relativeUploadFile;
            // Make sure the upload directory exists
            wp_mkdir_p(pathinfo($absoluteUploadFile)['dirname']);
            if ($wp_filesystem->put_contents(urldecode($absoluteUploadFile), $response['body'], FS_CHMOD_FILE)) {
                // Redirect to the stored upload
                wp_redirect($requestPath);
            }
        }
    }
}
开发者ID:betawax,项目名称:uploads-proxy,代码行数:35,代码来源:uploads-proxy.php


示例12: uploads_wordpress_url

 public static function uploads_wordpress_url()
 {
     if ($upload_dir = wp_upload_dir()) {
         return $upload_dir['baseurl'];
     }
     return site_url() . '/wp-content/uploads';
 }
开发者ID:jedoson,项目名称:slideshowjedogallery,代码行数:7,代码来源:SlideshowJedoGallery.php


示例13: generate_event_page

function generate_event_page()
{
    ob_start();
    $ical = new ICal(get_option('nev-file_path'));
    $events = $ical->events();
    $FORMAT = 'd-m-Y';
    $time = time();
    echo '<ul>';
    foreach ($events as $event) {
        $eventTime = strtotime($event['DTSTART']);
        //those in a past are not bolded
        if ($time - 60 * 60 * 24 > $eventTime) {
            echo '<li><p>';
            $date = substr($event['DTSTART'], 6, 2) . "/" . substr($event['DTSTART'], 4, 2) . "/" . substr($event['DTSTART'], 0, 4);
            echo $date . ': ' . $event['SUMMARY'] . ", " . @$event['DESCRIPTION'];
            echo '</p></li>';
        } else {
            echo '<li><p><strong>';
            $date = substr($event['DTSTART'], 6, 2) . "/" . substr($event['DTSTART'], 4, 2) . "/" . substr($event['DTSTART'], 0, 4);
            echo $date . ':</strong>  ' . $event['SUMMARY'] . ", " . @$event['DESCRIPTION'];
            echo '</p></li>';
        }
    }
    echo '</ul>';
    //Show link to download ical file
    $file_name = get_option('nev-file_path');
    $upload_path = wp_upload_dir()['url'] . substr($file_name, strripos($file_name, '/'));
    echo '<p>Download <a href="' . $upload_path . '" download>.ics file</a></p>';
    return ob_get_clean();
}
开发者ID:pmarki,项目名称:next_events,代码行数:30,代码来源:parser.php


示例14: _commands_for_files

 protected function _commands_for_files(&$commands)
 {
     extract($this->params);
     $dir = wp_upload_dir();
     $dist_path = constant(WP_Deploy_Flow_Command::config_constant('path')) . '/';
     $remote_path = $dist_path;
     $local_path = ABSPATH;
     $excludes = array_merge($excludes, array('.git', '.sass-cache', 'wp-content/cache', 'wp-content/_wpremote_backups', 'wp-config.php'));
     if (!$ssh_host) {
         // in case the source env is in a subfolder of the destination env, we exclude the relative path to the source to avoid infinite loop
         $remote_local_path = realpath($local_path);
         if ($remote_local_path) {
             $remote_path = realpath($remote_path);
             $remote_local_path = str_replace($remote_path . '/', '', $remote_local_path);
             $excludes[] = $remote_locale_path;
         }
     }
     $excludes = array_reduce($excludes, function ($acc, $value) {
         $acc .= "--exclude \"{$value}\" ";
         return $acc;
     });
     if ($ssh_host) {
         $commands[] = array("rsync -avz -e 'ssh -p {$ssh_port}' {$ssh_user}@{$ssh_host}:{$remote_path} {$local_path} {$excludes}", true);
     } else {
         $commands[] = array("rsync -avz {$remote_path} {$local_path} {$excludes}", true);
     }
 }
开发者ID:livsi,项目名称:wp-deploy-flow,代码行数:27,代码来源:puller.php


示例15: __construct

 function __construct()
 {
     //add_action( 'init', array($this,'init_addons'));
     $this->vc_template_dir = plugin_dir_path(__FILE__) . 'vc_templates/';
     $this->vc_dest_dir = get_template_directory() . '/vc_templates/';
     $this->module_dir = plugin_dir_path(__FILE__) . 'modules/';
     $this->assets_js = plugins_url('assets/js/', __FILE__);
     $this->assets_css = plugins_url('assets/css/', __FILE__);
     $this->admin_js = plugins_url('admin/js/', __FILE__);
     $this->admin_css = plugins_url('admin/css/', __FILE__);
     $this->paths = wp_upload_dir();
     $this->paths['fonts'] = 'smile_fonts';
     $this->paths['fonturl'] = set_url_scheme(trailingslashit($this->paths['baseurl']) . $this->paths['fonts']);
     add_action('init', array($this, 'aio_init'));
     add_action('admin_enqueue_scripts', array($this, 'aio_admin_scripts'));
     add_action('wp_enqueue_scripts', array($this, 'aio_front_scripts'));
     add_action('admin_init', array($this, 'toggle_updater'));
     if (!get_option('ultimate_row')) {
         update_option('ultimate_row', 'enable');
     }
     if (!get_option('ultimate_animation')) {
         update_option('ultimate_animation', 'disable');
     }
     //add_action('admin_init', array($this, 'aio_move_templates'));
 }
开发者ID:JackBrit,项目名称:Hudson-Fuggle,代码行数:25,代码来源:Ultimate_VC_Addons.php


示例16: wp_handle_upload_prefilter

 /**
  * @param $file
  * @uses wp_handle_upload_error
  * @return mixed|void
  */
 public static function wp_handle_upload_prefilter($file)
 {
     if (isset($file['name']) && isset($file['name'])) {
         $type_mime = explode('/', $file['type']);
         if ($type_mime[0] == 'video') {
             if ($_FILES['file']['size'] > 314572800) {
                 $uploads = wp_upload_dir(null);
                 $file_location = $uploads['path'] . "/{$file['name']}";
                 include __DIR__ . '/source/VideoInformation.php';
                 $videoInfo = VideoInformation::getVideoInfo($file_location);
                 if (!empty($videoInfo) && isset($videoInfo['duration'])) {
                     if (intval($videoInfo['duration']) > self::get_video_max_duration()) {
                         $file['error'] = __('Video File exceeds Specified Duration');
                         return $file;
                     }
                 } else {
                     $file['error'] = __("Video file information couldn't be read.");
                 }
             } else {
                 $file['error'] = __("File size exceeds 300 MB");
             }
         }
     }
     return apply_filters('wp_handle_upload_prefilter', $file);
 }
开发者ID:vladab,项目名称:video-attachment,代码行数:30,代码来源:video-attachmnet-settings.php


示例17: go

 public function go()
 {
     $this->upload_dir = wp_upload_dir();
     $parser = new Theme_Content_Parser(TEMPLATEPATH . '/content/content.xml');
     // parses content.xml
     $pages_info = $parser->get_pages();
     $posts_info = $parser->get_posts();
     $sidebars_info = $parser->get_sidebars();
     $collages_info = $parser->get_collages();
     // add content to the theme
     $this->move_images();
     if ($pages_info) {
         $this->insert_pages($pages_info);
     }
     if ($posts_info) {
         $this->insert_posts($posts_info);
     }
     $this->update_collages_meta($collages_info);
     $this->update_links_url();
     if ($sidebars_info) {
         theme_deactivate_all_widgets();
         $this->insert_sidebars($sidebars_info);
     }
     update_option('theme_sample_data', $this->sample_data);
 }
开发者ID:epiii,项目名称:Clean-Wordpress-theme,代码行数:25,代码来源:content-importer.php


示例18: __construct

 public function __construct()
 {
     // Look for the Losungen xml in the /uploads-Folder as well
     add_filter('herrnhuterlosung_filename_xml', array($this, 'xmlFileName'), 10, 2);
     $upload_dir = wp_upload_dir();
     $this->alternate_dir = $upload_dir['basedir'];
 }
开发者ID:spacegaier,项目名称:herrnhuter-losung-widget,代码行数:7,代码来源:xml_automatic_updater.php


示例19: my_save_extra_profile_fields

 function my_save_extra_profile_fields($user_id)
 {
     if (!current_user_can('edit_user', $user_id)) {
         return false;
     }
     $upload = $_FILES['profile_image'];
     $uploads = wp_upload_dir();
     if ($upload['tmp_name'] && file_is_displayable_image($upload['tmp_name'])) {
         // handle the uploaded file
         $overrides = array('test_form' => false);
         $file = wp_handle_upload($upload, $overrides);
         $file["file"] = $uploads["subdir"] . "/" . basename($file["url"]);
         if ($file) {
             //remove previous uploaded file
             $author_profile_image = $this->get_author_profile_image($user_id);
             @unlink($author_profile_image["file"]);
             update_user_meta($user_id, 'profile_image', $file);
         }
     }
     if (isset($_POST['remove_image'])) {
         $author_profile_image = $this->get_author_profile_image($user_id);
         @unlink($author_profile_image["file"]);
         update_user_meta($user_id, 'profile_image', false);
     }
 }
开发者ID:phucanh92,项目名称:vietlong,代码行数:25,代码来源:profile-image.php


示例20: ctfw_sermon_data

/**
 * Get sermon data
 *
 * @since 0.9
 * @param int $post_id Post ID to get data for; null for current post
 * @return array Sermon data
 */
function ctfw_sermon_data($post_id = null)
{
    // Get URL to upload directory
    $upload_dir = wp_upload_dir();
    $upload_dir_url = $upload_dir['baseurl'];
    // Get meta values
    $data = ctfw_get_meta_data(array('video', 'audio', 'pdf', 'has_full_text'), $post_id);
    // Get media player code
    // Embed code generated from uploaded file, URL for file on other site, page on oEmbed-supported site, or manual embed code (HTML or shortcode)
    $data['video_player'] = ctfw_embed_code($data['video']);
    $data['audio_player'] = ctfw_embed_code($data['audio']);
    // Get file data for media
    // Path and size will be populated for local files only
    $media_types = array('audio', 'video', 'pdf');
    foreach ($media_types as $media_type) {
        $data[$media_type . '_extension'] = '';
        $data[$media_type . '_path'] = '';
        $data[$media_type . '_size_bytes'] = '';
        $data[$media_type . '_size'] = '';
        // Get extension
        // This can be determined for local and external files
        // Empty for YouTube, SoundCloud, etc.
        $filetype = wp_check_filetype($data[$media_type]);
        $data[$media_type . '_extension'] = $filetype['ext'];
        // File is local, so can get path and size
        if ($data[$media_type] && ctfw_is_local_url($data[$media_type])) {
            // Local path
            $data[$media_type . '_path'] = $upload_dir['basedir'] . str_replace($upload_dir_url, '', $data[$media_type]);
            // Exists?
            if (!file_exists($data[$media_type . '_path'])) {
                $data[$media_type . '_path'] = '';
                // clear it
            } else {
                // File type
                $filetype = wp_check_filetype($data[$media_type]);
                $data[$media_type . '_extension'] = $filetype['ext'];
                // File size
                $data[$media_type . '_size_bytes'] = filesize($data[$media_type . '_path']);
                $data[$media_type . '_size'] = size_format($data[$media_type . '_size_bytes']);
                // 30 MB, 2 GB, 220 kB, etc.
            }
        }
    }
    // Get download URL's
    // URL is returned if is local or external and has an extension.
    // Those without an extension (YouTube, SoundCloud, etc. page URL) return empty (nothing to download).
    // If locally hosted, URL is changed to force "Save As" via headers.
    // Use <a href="" download="download"> to attempt Save As via limited browser support for externally hosted files.
    $data['video_download_url'] = ctfw_download_url($data['video']);
    $data['audio_download_url'] = ctfw_download_url($data['audio']);
    $data['pdf_download_url'] = ctfw_download_url($data['pdf']);
    // Has at least one downloadable file URL?
    $data['has_download'] = false;
    if ($data['video_download_url'] || $data['audio_download_url'] || $data['pdf_download_url']) {
        // path empty if doesn't exist
        $data['has_download'] = true;
    }
    // Return filtered
    return apply_filters('ctfw_sermon_data', $data);
}
开发者ID:pemiu01,项目名称:church-theme-framework,代码行数:67,代码来源:sermons.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_user_settings函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_upload_bits函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap