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


PHP wp_upload_dir函数代码示例

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


在下文中一共展示了wp_upload_dir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 <lgrandicelli@gmail.com>
  * @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


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