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


PHP path_is_absolute函数代码示例

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


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

示例1: test_path_is_not_absolute

 function test_path_is_not_absolute()
 {
     if (!is_callable('path_is_absolute')) {
         $this->markTestSkipped();
     }
     $relative_paths = array('', '.', '..', '../foo', '../', '../foo.bar', 'foo/bar', 'foo', 'FOO', '..\\WINDOWS');
     foreach ($relative_paths as $path) {
         $this->assertFalse(path_is_absolute($path), "path_is_absolute('{$path}') should return false");
     }
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:10,代码来源:functions.php

示例2: get_certificate_path_setting

 /**
  * Gets the value of the option that stores the path to the certificate file.
  * Relative paths will be converted to absolute, as if relative to WP root.
  * 
  * @since 4.7
  * @return string Absolute path to the certificate file.
  */
 public function get_certificate_path_setting()
 {
     $path = wprss_get_general_setting(self::SETTING_KEY_CERTIFICATE_PATH);
     if (empty($path)) {
         return $path;
     }
     if (!path_is_absolute($path)) {
         $path = ABSPATH . $path;
     }
     return $path;
 }
开发者ID:wangshijun101,项目名称:morketing.cn,代码行数:18,代码来源:feed-access.php

示例3: render

 public static function render($view, $arguments = array(), $return = false, $loop = null)
 {
     global $post, $posts, $post_id, $current_user, $wpdb, $wp_query, $pagenow, $typenow, $hook_suffix, $current_screen, $wp_version, $wp_did_header, $wp_rewrite, $wp, $wp_post_statuses, $comment, $user_ID;
     $_windows_os = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
     $_path_seperator = '/';
     $_backtrace = debug_backtrace();
     if (isset($_backtrace[1]['file'])) {
         $_origin = $_backtrace[1]['file'];
         if (is_string($_origin) && (!$_windows_os && substr($_origin, 0, 1) == $_path_seperator || $_windows_os && substr($_origin, 1, 1) == ':')) {
             $view .= strstr($view, '.php') ? '' : '.php';
             $_path = substr($_origin, 0, strrpos($_origin, $_path_seperator));
             foreach (array(STYLESHEETPATH, TEMPLATEPATH) as $_theme_path) {
                 if ($_path == $_theme_path && file_exists($_theme_path . $_path_seperator . $view)) {
                     $_file = path_is_absolute($view) ? $view : $_theme_path . $_path_seperator . $view;
                 }
             }
         }
     }
     if (!isset($_file)) {
         foreach (self::$paths as $_display => $_path) {
             $_file = (path_is_absolute($view) ? $view : self::$paths[$_display] . $_path_seperator . 'parts' . $_path_seperator . $view) . (strstr($view, '.php') ? '' : '.php');
             // Check for theme overrides
             if (stristr($_file, '/parts/')) {
                 $_part = '';
                 $_directories = explode($_path_seperator, $_file);
                 for ($i = count($_directories); $i >= 0; $i--) {
                     if (isset($_directories[$i])) {
                         $_part = $_directories[$i] . (empty($_part) ? '' : $_path_seperator) . $_part;
                         if ($_directories[$i] == 'parts') {
                             $_part = $_path_seperator . $_directories[$i - 1] . $_path_seperator . $_part;
                             break;
                         }
                     }
                 }
             }
             if (!path_is_absolute($_file)) {
                 foreach (array('theme', 'parent-theme') as $_theme) {
                     $_path = isset(self::$paths[$_theme]) ? self::$paths[$_theme] : null;
                     if (isset(self::$paths[$_theme]) && isset($_path)) {
                         $_path = substr($_path, 0, strlen($_path) - 8);
                         if (file_exists($_path . $_part)) {
                             $_file = $_path . $_part;
                             break;
                         }
                     }
                 }
             }
             if (file_exists($_file)) {
                 break;
             }
         }
     }
     if ($return) {
         ob_start();
     }
     $_arguments = array($wp_query->query_vars);
     if (isset($arguments) && !empty($arguments)) {
         array_push($_arguments, $arguments);
     }
     foreach ($_arguments as $_object) {
         foreach ($_object as $_key => $_value) {
             ${$_key} = $_value;
         }
     }
     $_file = apply_filters('piklist_render', $_file, $view, $arguments);
     if ($_file) {
         if ($loop && self::is_associative_array($arguments[$loop])) {
             $_depth = 1;
             foreach ($arguments[$loop] as $_key => $_value) {
                 $_depth = is_array($_value) ? count($_value) > $_depth ? count($_value) : $_depth : 1;
             }
             for ($i = 0; $i < $_depth; $i++) {
                 $_loop = array();
                 foreach ($arguments[$loop] as $_key => $_value) {
                     $_loop[$_key] = isset($_value[$i]) ? $_value[$i] : null;
                 }
                 ${$loop} = $_loop;
                 include $_file;
             }
         } elseif ($loop) {
             for ($i = 0; $i < count($arguments[$loop]); $i++) {
                 ${$loop} = $arguments[$loop][$i];
                 include $_file;
             }
         } elseif (file_exists($_file)) {
             include $_file;
         }
     }
     if ($return) {
         $output = ob_get_contents();
         ob_end_clean();
         return $output;
     }
 }
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:94,代码来源:class-piklist.php

示例4: Display


//.........这里部分代码省略.........
                if (empty($options[$opt_tag])) {
                    $options[$opt_tag] = '';
                    continue;
                }
                $lines = explode("\n", $options[$opt_tag]);
                $lines2 = array();
                for ($i = 0; $i < count($lines); $i++) {
                    $lines[$i] = str_replace('||', '|', trim($lines[$i], "|\r"));
                    if (empty($lines[$i]) || $lines[$i] == '|') {
                        continue;
                    }
                    $pos = strpos($lines[$i], '|');
                    if ($pos <= 0) {
                        $lines[$i] .= '|' . sanitize_key(substr($lines[$i], 0, min(8, strlen($lines[$i]))));
                    }
                    $lines2[] = $lines[$i];
                }
                $options[$opt_tag] = implode("\n", $lines2);
            }
            $old_options = get_option(WPFB_OPT_NAME);
            update_option(WPFB_OPT_NAME, $options);
            WPFB_Core::$settings = (object) $options;
            $messages = array_merge($messages, WPFB_Admin::SettingsUpdated($old_options, $options));
            if (count($errors) == 0) {
                $messages[] = __('Settings updated.', WPFB);
            }
            //refresh any description which can contain opt values
            $option_fields = WPFB_Admin::SettingsSchema();
        }
        if (WPFB_Core::$settings->allow_srv_script_upload) {
            $messages[] = __('WARNING: Script upload enabled!', WPFB);
        }
        $upload_path = WPFB_Core::$settings->upload_path;
        if (!empty($old_options) && path_is_absolute($upload_path) && !path_is_absolute($old_options['upload_path'])) {
            $rel_path = str_replace('\\', '/', $upload_path);
            $rel_path = substr($rel_path, strpos($rel_path, '/') + 1);
            $messages[] = __(sprintf('NOTICE: The upload path <code>%s</code> is rooted to the filesystem. You should remove the leading slash if you want to use a folder inside your Wordpress directory (i.e: <code>%s</code>)', $upload_path, $rel_path), WPFB);
        }
        $action_uri = admin_url('admin.php') . '?page=' . $_GET['page'] . '&amp;updated=true';
        if (!empty($messages)) {
            $message = '';
            foreach ($messages as $msg) {
                $message .= '<p>' . $msg . '</p>';
            }
            ?>
<div id="message" class="updated fade"><?php 
            echo $message;
            ?>
</div>
<?php 
        }
        if (!empty($errors)) {
            $error = '';
            foreach ($errors as $err) {
                $error .= '<p>' . $err . '</p>';
            }
            ?>
<div id="message" class="error fade"><?php 
            echo $error;
            ?>
</div>
<?php 
        }
        ?>
<script type="text/javascript">
/* Option tabs */
开发者ID:bruno-barros,项目名称:w.eloquent.light,代码行数:67,代码来源:AdminGuiSettings.php

示例5: audiotheme_encode_svg

/**
 * Return a base64 encoded SVG icon for use as a data URI.
 *
 * @since 1.4.3
 *
 * @param string $path Path to SVG icon.
 * @return string
 */
function audiotheme_encode_svg($path)
{
    $path = path_is_absolute($path) ? $path : AUDIOTHEME_DIR . $path;
    if (!file_exists($path) || 'svg' !== pathinfo($path, PATHINFO_EXTENSION)) {
        return '';
    }
    return 'data:image/svg+xml;base64,' . base64_encode(file_get_contents($path));
}
开发者ID:TyRichards,项目名称:ty_the_band,代码行数:16,代码来源:functions.php

示例6: scan

 public function scan($no_echo)
 {
     $string_settings = apply_filters('wpml_get_setting', false, 'st');
     if (isset($_POST['wpml_st_theme_localization_type_wpml_td']) && $_POST['wpml_st_theme_localization_type_wpml_td']) {
         $string_settings['use_header_text_domains_when_missing'] = 1;
     } else {
         $string_settings['use_header_text_domains_when_missing'] = 0;
     }
     do_action('wpml_set_setting', 'st', $string_settings, true);
     $this->current_plugin_file = null;
     $this->current_type = 'plugin';
     set_time_limit(0);
     if (preg_replace('#M$#', '', ini_get('memory_limit')) < 128) {
         ini_set('memory_limit', '128M');
     }
     $plugins = array();
     if (!empty($_POST['plugin'])) {
         foreach ($_POST['plugin'] as $plugin) {
             $plugins[] = array('file' => $plugin, 'mu' => 0);
             // regular plugins
         }
     }
     if (!empty($_POST['mu-plugin'])) {
         foreach ($_POST['mu-plugin'] as $plugin) {
             $plugins[] = array('file' => $plugin, 'mu' => 1);
             //mu plugins
         }
     }
     foreach ($plugins as $p) {
         $plugin = $p['file'];
         $this->current_plugin_file = $p['file'];
         $this->scan_starting($plugin);
         if (false !== strpos($plugin, '/') && !$p['mu']) {
             $plugin = dirname($plugin);
         }
         if (!path_is_absolute($plugin)) {
             if ($p['mu']) {
                 $plugin_path = WPMU_PLUGIN_DIR . '/' . $plugin;
                 $this->current_plugin_file = WPMU_PLUGIN_DIR . '/' . $p['file'];
             } else {
                 $plugin_path = WP_PLUGIN_DIR . '/' . $plugin;
                 $this->current_plugin_file = WP_PLUGIN_DIR . '/' . $p['file'];
             }
         } else {
             $this->current_plugin_file = $p['file'];
             $plugin_path = $plugin;
         }
         if (wpml_st_file_path_is_valid($plugin_path) && wpml_st_file_path_is_valid($this->current_plugin_file)) {
             $this->current_path = $plugin_path;
             $text_domain = $this->get_plugin_text_domain();
             $this->init_text_domain($text_domain);
             $this->add_stat(PHP_EOL . sprintf(__('Scanned files from %s:', 'wpml-string-translation'), $plugin));
             $this->scan_plugin_files();
             $this->current_type = 'plugin';
             if (isset($_POST['icl_load_mo']) && $_POST['icl_load_mo'] && !$p['mu']) {
                 $this->add_translations(array_keys($this->get_domains_found()), '');
             }
             $this->copy_old_translations(array_keys($this->get_domains_found()), 'plugin');
             $this->cleanup_wrong_contexts();
             $string_settings = apply_filters('wpml_get_setting', false, 'st');
             $string_settings['plugin_localization_domains'][$p['file']] = $this->get_domains_found();
             do_action('wpml_set_setting', 'st', $string_settings, true);
         } else {
             $this->add_stat(sprintf(__('Invalid file: %s', 'wpml-string-translation'), "/" . $plugin_path));
         }
     }
     $this->add_scan_stat_summary();
     if ($this->current_plugin_file) {
         $plugin_data = get_plugin_data($this->current_plugin_file);
         if ($plugin_data && !is_wp_error($plugin_data)) {
             $this->remove_notice($plugin_data['Name']);
         }
     }
     if (!$no_echo) {
         $this->scan_response();
     }
 }
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:77,代码来源:wpml-plugin-string-scanner.class.php

示例7: path_is_absolute

 /**
  * path_is_absolute
  * Determine whether a path is relative or absolute
  *
  * @param string $path path to check
  *
  * @return bool
  *
  * @access public
  * @static
  * @since 1.0
  */
 public static function path_is_absolute($path)
 {
     return path_is_absolute($path) || 1 === preg_match('~^[a-z]+://~i', $path);
 }
开发者ID:a42,项目名称:piklist,代码行数:16,代码来源:class-piklist.php

示例8: is_subdir

 /**
  * Finds out if a path is a subdirectory of another path.
  *
  * @param  string  $dir The absolute path that might be a subdirectory.
  * @param  string  $of  The absolute path to check against.
  * @return boolean      Returns TRUE if the path is a subdirectory, FALSE otherwise.
  */
 function is_subdir($dir, $of)
 {
     if (!@is_dir($dir) || !@is_dir($of)) {
         return false;
     }
     if (!path_is_absolute($dir) || !path_is_absolute($of)) {
         return false;
     }
     if (0 === strpos($dir, $of)) {
         return true;
     }
     return false;
 }
开发者ID:DylanGroenewoud,项目名称:PVNG,代码行数:20,代码来源:functions.php

示例9: array

 			Does the download contain the wpurl or url? */
 if ($localURI) {
     // the URI is local, replace the WordPress url OR blog url with WordPress's absolute path.
     //$patterns = array( '|^'. get_bloginfo('wpurl') . '/' . '|', '|^'. get_bloginfo('url') . '/' . '|');
     $patterns = array('|^' . get_bloginfo('wpurl') . '/' . '|');
     $path = preg_replace($patterns, '', $thefile);
     // account for multisite/network installations since they each have their own upload directory
     if (is_multisite() && $blog_id != 1) {
         // Main site uses the "standard" upload directory so leave that as-is
         $path = '/wp-content/blogs.dir/' . $blog_id . '/' . $path;
     }
     // this is joining the ABSPATH constant, changing any slashes to local filesystem slashes, and then finally getting the real path.
     $thefile = str_replace('/', DIRECTORY_SEPARATOR, path_join(ABSPATH, $path));
     // Local File System path
 } else {
     if (!path_is_absolute($thefile)) {
         //$thefile = path_join( ABSPATH, $thefile );
         // Get the absolute path
         if (!isset($_SERVER['DOCUMENT_ROOT'])) {
             $_SERVER['DOCUMENT_ROOT'] = str_replace('\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0 - strlen($_SERVER['PHP_SELF'])));
         }
         // Now substitute the domain for the absolute path in the file url
         $thefile = str_replace('/', DIRECTORY_SEPARATOR, path_join($_SERVER['DOCUMENT_ROOT'], $thefile));
     }
 }
 // If the path wasn't a URI and not absolute, then it made it all the way to here without manipulation, so now we do this...
 // By the way, realpath() returns NOTHING if is does not exist.
 $testfile = realpath($thefile);
 // now do a long condition check, it should not be emtpy, a directory, and should be readable.
 $willDownload = empty($testfile) ? false : !is_file($testfile) ? false : is_readable($testfile);
 if (!$willDownload) {
开发者ID:pankajsinghjarial,项目名称:SYLC,代码行数:31,代码来源:download.php

示例10: export

 /**
  * Inject static code/markup
  *
  * @return string
  */
 public function export()
 {
     // the code that will be returned
     $code = null;
     // handle callbacks
     if ($this->has_callbacks()) {
         // loop em
         foreach ($this->callbacks as $callback) {
             // execute callback with myself as only argument
             call_user_func($callback, $this);
         }
     }
     // have any files?
     if ($this->files_export->count()) {
         // loop through all files
         foreach ($this->files_export as $file) {
             // resolve file path
             if (path_is_absolute($file)) {
                 // its absolute already, which is good
                 $filename = $file;
             } else {
                 // relative path, need to locate it
                 $filename = $this->component()->locate_file($file);
             }
             // only import each file once!
             if (self::$files_imported->contains($filename)) {
                 // already imported that one
                 continue;
             } else {
                 // push it on to imported stack
                 self::$files_imported->push($filename);
             }
             // inject helpful comment ;)
             //$code .= '/*+++ import source: ' . $filename . ' */' . PHP_EOL;
             // make sure file actually exists
             if (ICE_Files::cache($filename)->is_readable()) {
                 // get entire contents of file
                 $code .= $this->get_file_contents($filename) . PHP_EOL;
                 // success
                 //$code .= '/*--- import complete! */' . PHP_EOL . PHP_EOL;
             } else {
                 //$code .= '/*!!! import failed! */' . PHP_EOL . PHP_EOL;
             }
         }
     }
     // handle strings
     if ($this->has_strings()) {
         //$code .= '/*--- importing strings */' . PHP_EOL;
         $code .= implode(PHP_EOL, $this->strings->to_array()) . str_repeat(PHP_EOL, 2);
         //$code .= '/*!!! importing strings complete */' . PHP_EOL;
     }
     // all done
     return $code;
 }
开发者ID:nxtclass,项目名称:NXTClass-themes,代码行数:59,代码来源:asset.php

示例11: info

 /**
  * Returns image metadata.
  *
  * NOTE: The image must be within the WP_CONTENT/UPLOADS folder or within the STYLESHEETPATH folder.
  *
  * @access public
  * @since  8.1.2
  * @static
  *
  * @param  string $source URL or absolute path to an image.
  *
  * @return mixed          array | object An associative array of image meta or an instance of WP_Error.
  */
 public static function info($source)
 {
     // Define upload path & dir.
     $upload_info = cnUpload::info();
     $theme_url = get_stylesheet_directory_uri();
     $theme_dir = get_stylesheet_directory();
     if (path_is_absolute($source)) {
         // Ensure the supplied path is in either the WP_CONTENT/UPLOADS directory or
         // the STYLESHEETPATH directory.
         if (strpos($source, $upload_info['base_path']) !== FALSE || strpos($source, $theme_dir) !== FALSE) {
             $img_path = $source;
         } else {
             $img_path = FALSE;
         }
     } else {
         // find the path of the image. Perform 2 checks:
         // #1 check if the image is in the uploads folder
         if (strpos($source, $upload_info['base_url']) !== FALSE) {
             $rel_path = str_replace($upload_info['base_url'], '', $source);
             $img_path = $upload_info['base_path'] . $rel_path;
             // #2 check if the image is in the current theme folder
         } else {
             if (strpos($source, $theme_url) !== FALSE) {
                 $rel_path = str_replace($theme_url, '', $source);
                 $img_path = $theme_dir . $rel_path;
             }
         }
     }
     // Fail if we can't find the image in our WP local directory
     if (empty($img_path) || !@file_exists($img_path)) {
         if (empty($img_path)) {
             return new WP_Error('image_path_not_set', esc_html__('The $img_path variable has not been set.', 'connections'));
         } else {
             return new WP_Error('image_path_not_found', __(sprintf('Image path %s does not exist.', $img_path), 'connections'), $img_path);
         }
     }
     // Check if img path exists, and is an image.
     if (($image_info = getimagesize($img_path)) === FALSE) {
         return new WP_Error('image_not_image', __(sprintf('The file %s is not an image.', basename($img_path)), 'connections'), basename($img_path));
     }
     $image_info['path'] = $img_path;
     $image_info['modified'] = filemtime($img_path);
     $image_info = array_merge(pathinfo($img_path), $image_info);
     return $image_info;
 }
开发者ID:VacantFuture,项目名称:Connections,代码行数:58,代码来源:class.image.php

示例12: Display

    static function Display()
    {
        global $wpdb, $user_ID;
        wpfb_loadclass('Admin', 'Output');
        $_POST = stripslashes_deep($_POST);
        $_GET = stripslashes_deep($_GET);
        $action = !empty($_POST['action']) ? $_POST['action'] : (!empty($_GET['action']) ? $_GET['action'] : '');
        $clean_uri = remove_query_arg(array('message', 'action', 'file_id', 'cat_id', 'deltpl', 'hash_sync'));
        // keep search keyword
        ?>
	<div class="wrap">
	<?php 
        $upload_path = WPFB_Core::$settings->upload_path;
        if (path_is_absolute($upload_path)) {
            echo '<div class="updated fade"><p>';
            printf(__('Custom CSS does only work if upload path is relative to WordPress path. It is currently set to <code>%s</code>, so <b>custom CSS will not work!</b>', WPFB), $upload_path);
            echo "</p></div>";
        }
        switch ($action) {
            default:
                if (!current_user_can('edit_themes')) {
                    wp_die(__('Cheatin&#8217; uh?'));
                }
                // try to use default wp upload path
                $wp_upload = wp_upload_dir();
                $wp_upload_ok = empty($wp_upload['error']) && is_writable($wp_upload['basedir']);
                // if no file at wp upload, fallback to Old custom css path
                $css_path_edit = $wp_upload_ok && (is_file($wp_upload['basedir'] . '/wp-filebase.css') || !empty($_POST['newcontent'])) ? $wp_upload['basedir'] . '/wp-filebase.css' : WPFB_Core::GetOldCustomCssPath();
                $css_path_default = WPFB_PLUGIN_ROOT . 'wp-filebase.css';
                $exists = file_exists($css_path_edit) && is_file($css_path_edit);
                if ($exists && !is_writable($css_path_edit) || !$exists && !is_writable(dirname($css_path_edit))) {
                    ?>
<div class="error default-password-nag"><p><?php 
                    printf(__('%s is not writable!', WPFB), $css_path_edit);
                    ?>
</p></div><?php 
                    break;
                }
                if (!empty($_POST['restore_default'])) {
                    update_option('wpfb_css', WPFB_PLUGIN_URI . 'wp-filebase.css?t=' . time());
                    @unlink($css_path_edit);
                    $exists = false;
                } elseif (!empty($_POST['submit']) && !empty($_POST['newcontent'])) {
                    // write
                    $newcontent = stripslashes($_POST['newcontent']);
                    $newcontent = self::MakeCssUrlsAbsolute($newcontent);
                    $exists = file_put_contents($css_path_edit, $newcontent) !== false;
                    update_option('wpfb_css', $wp_upload_ok ? $wp_upload['baseurl'] . '/wp-filebase.css?t=' . time() : false);
                }
                $fpath = $exists ? $css_path_edit : $css_path_default;
                $content = esc_html(file_get_contents($fpath));
                ?>
<form name="csseditor" id="csseditor" action="<?php 
                echo $clean_uri;
                ?>
&amp;action=edit_css" method="post">
		 <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1" class="codepress css" style="width: 98%;"><?php 
                echo $content;
                ?>
</textarea>
		 <input type="hidden" name="action" value="edit_css" />
		<p class="submit">
		<?php 
                echo "<input type='submit' name='submit' class='button-primary' value='" . esc_attr__('Update File', WPFB) . "' tabindex='2' />";
                ?>
		<?php 
                if ($exists) {
                    echo "<input type='submit' name='restore_default' class='button' onclick=\"return confirm('Sure?')\" value='" . esc_attr__('Restore Default', WPFB) . "' tabindex='3' />";
                }
                ?>
		</p>
		</div>
</form>
<?php 
                break;
                // edit_css
        }
        ?>
</div> <!-- wrap -->
<?php 
    }
开发者ID:Seravo,项目名称:WP-Filebase,代码行数:81,代码来源:AdminGuiCss.php

示例13: get_size

 function get_size()
 {
     global $wpdb, $wp_dlm_db_meta;
     $thefile = $this->filename;
     $urlparsed = parse_url($thefile);
     $isURI = array_key_exists('scheme', $urlparsed);
     $localURI = (bool) strstr($thefile, get_bloginfo('wpurl'));
     /* Local TO WORDPRESS!! */
     $filesize = '';
     if ($isURI && $localURI || !$isURI && !$localURI) {
         if ($localURI) {
             // the URI is local, replace the WordPress url OR blog url with WordPress's absolute path.
             //$patterns = array( '|^'. get_bloginfo('wpurl') . '/' . '|', '|^'. get_bloginfo('url') . '/' . '|');
             $patterns = array('|^' . get_bloginfo('wpurl') . '/' . '|');
             $path = preg_replace($patterns, '', $thefile);
             // this is joining the ABSPATH constant, changing any slashes to local filesystem slashes, and then finally getting the real path.
             $thefile = str_replace('/', DIRECTORY_SEPARATOR, path_join(ABSPATH, $path));
             if (@file_exists($thefile)) {
                 $filesize = filesize($thefile);
             }
             // Local File System path
         } elseif (!path_is_absolute($thefile)) {
             //$thefile = path_join( ABSPATH, $thefile );
             // Get the absolute path
             if (!isset($_SERVER['DOCUMENT_ROOT'])) {
                 $_SERVER['DOCUMENT_ROOT'] = str_replace('\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0 - strlen($_SERVER['PHP_SELF'])));
             }
             $dir_path = $_SERVER['DOCUMENT_ROOT'];
             // Now substitute the domain for the absolute path in the file url
             $thefile = str_replace('/', DIRECTORY_SEPARATOR, path_join($dir_path, $thefile));
             if (@file_exists($thefile)) {
                 $filesize = filesize($thefile);
             }
         } else {
             if (@file_exists($thefile)) {
                 $filesize = filesize($thefile);
             }
         }
     } elseif ($isURI && ini_get('allow_url_fopen')) {
         // Absolute path outside of wordpress
         if (!function_exists('remote_filesize')) {
             function remote_filesize($url)
             {
                 ob_start();
                 $ch = curl_init($url);
                 curl_setopt($ch, CURLOPT_HEADER, 1);
                 curl_setopt($ch, CURLOPT_NOBODY, 1);
                 $ok = curl_exec($ch);
                 curl_close($ch);
                 $head = ob_get_contents();
                 ob_end_clean();
                 $regex = '/Content-Length:\\s([0-9].+?)\\s/';
                 $count = preg_match($regex, $head, $matches);
                 return isset($matches[1]) ? $matches[1] : "";
             }
         }
         $isHTTP = (bool) ($urlparsed['scheme'] == 'http' || $urlparsed['scheme'] == 'https');
         if (function_exists('get_headers') && $isHTTP) {
             $ary_header = @get_headers($thefile, 1);
             if (is_array($ary_header) && array_key_exists("Content-Length", $ary_header)) {
                 $filesize = $ary_header["Content-Length"];
             }
         } else {
             if (function_exists('curl_init')) {
                 $filesize = remote_filesize($thefile);
                 // I wonder, is this returning something non-numeric?
             } else {
                 $filesize = @filesize($thefile);
             }
         }
     }
     if ($filesize && is_numeric($filesize)) {
         $bytes = array('bytes', 'kB', 'MB', 'GB', 'TB');
         foreach ($bytes as $val) {
             if ($filesize > 1024) {
                 $filesize = $filesize / 1024;
             } else {
                 break;
             }
         }
         $this->size = round($filesize, 2) . " " . $val;
         // Add to DB for quick loading in future
         $wpdb->query("INSERT INTO {$wp_dlm_db_meta} (meta_name, meta_value, download_id) VALUES ('filesize', '" . $wpdb->escape($this->size) . "', '" . $this->id . "')");
     } else {
         // Could not get size, but insert anyway to prevent slow page loads
         $wpdb->query("INSERT INTO {$wp_dlm_db_meta} (meta_name, meta_value, download_id) VALUES ('filesize', '', '" . $this->id . "')");
     }
 }
开发者ID:nickpeirson,项目名称:download-monitor,代码行数:88,代码来源:downloadable_file.class.php

示例14: pl_locate_less

/**
 * Get the first found less file
 * Checks child theme first, then parent
 *
 * @since	2.4.6
 * 
 * @param  [type] $filename [description]
 * @return [type]           [description]
 */
function pl_locate_less($filename)
{
    if (path_is_absolute($filename) && file_exists($filename)) {
        return $filename;
    } else {
        return locate_template(array("less/{$filename}", "less/{$filename}.less"));
    }
}
开发者ID:aaemnnosttv,项目名称:pagelines,代码行数:17,代码来源:less.functions.php

示例15: InitClass

 static function InitClass()
 {
     self::$ajax_url = admin_url('admin-ajax.php?action=wpfilebase');
     self::$ajax_url_public = home_url('/?wpfilebase_ajax=1');
     if (defined('WPFB_NO_CORE_INIT')) {
         return;
     }
     // on activation
     self::$settings = (object) get_option(WPFB_OPT_NAME);
     // load lang
     $lang_dir = defined('WPFB_LANG_DIR') ? '../../' . WPFB_LANG_DIR : basename(WPFB_PLUGIN_ROOT) . '/languages';
     load_plugin_textdomain('wp-filebase', false, $lang_dir);
     add_action('parse_query', array(__CLASS__, 'ParseQuery'));
     // search
     add_action('wp_enqueue_scripts', array(__CLASS__, 'EnqueueScripts'));
     add_action('wp_footer', array(__CLASS__, 'Footer'));
     add_action('generate_rewrite_rules', array(__CLASS__, 'GenRewriteRules'));
     add_action(WPFB . '_cron', array(__CLASS__, 'Cron'));
     add_action('wpfilebase_sync', array(__CLASS__, 'Sync'));
     // for Developers: New wp-filebase actions
     add_action('wp_ajax_nopriv_wpfilebase', array(__CLASS__, 'AjaxPublic'));
     add_action('wp_ajax_wpfilebase', array(__CLASS__, 'AjaxAdmin'));
     add_shortcode('wpfilebase', array(__CLASS__, 'ShortCode'));
     // for attachments and file browser
     add_filter('the_content', array(__CLASS__, 'ContentFilter'), 10);
     // must be lower than 11 (before do_shortcode) and after wpautop (>9)
     add_filter('ext2type', array(__CLASS__, 'Ext2TypeFilter'));
     add_filter('pre_set_site_transient_update_plugins', array(__CLASS__, 'PreSetPluginsTransientFilter'));
     add_filter('plugins_api', array(__CLASS__, 'PluginsApiFilter'), 10, 3);
     // register treeview stuff
     wp_register_script('jquery-treeview', WPFB_PLUGIN_URI . 'extras/jquery/treeview/jquery.treeview.js', array('jquery'), WPFB_VERSION);
     wp_register_script('jquery-treeview-edit', WPFB_PLUGIN_URI . 'extras/jquery/treeview/jquery.treeview.edit.js', array('jquery-treeview'), WPFB_VERSION);
     wp_register_script('jquery-treeview-async', WPFB_PLUGIN_URI . 'extras/jquery/treeview/jquery.treeview.async.js', array('jquery-treeview-edit'), WPFB_VERSION);
     wp_register_style('jquery-treeview', WPFB_PLUGIN_URI . 'extras/jquery/treeview/jquery.treeview.css', array(), WPFB_VERSION);
     // DataTables
     wp_register_script('jquery-dataTables', WPFB_PLUGIN_URI . 'extras/jquery/dataTables/js/jquery.dataTables.min.js', array('jquery'), WPFB_VERSION);
     wp_register_style('jquery-dataTables', WPFB_PLUGIN_URI . 'extras/jquery/dataTables/css/jquery.dataTables.css', array(), WPFB_VERSION);
     wp_register_script('jquery-dataTables-columnFilter', WPFB_PLUGIN_URI . 'extras/jquery/dataTables/js/jquery.dataTables.columnFilter.js', array('jquery-dataTables'), WPFB_VERSION);
     wp_register_script(WPFB, WPFB_PLUGIN_URI . 'js/common.js', array('jquery'), WPFB_VERSION);
     // cond loading (see Footer)
     if (empty(WPFB_Core::$settings->disable_css)) {
         $wpfb_css = get_option('wpfb_css');
         if ($wpfb_css) {
             // static file?
             wp_enqueue_style(WPFB, strstr($wpfb_css, '//'), array(), WPFB_VERSION, 'all');
         } else {
             $upload_path = path_is_absolute(WPFB_Core::$settings->upload_path) ? '' : WPFB_Core::$settings->upload_path;
             wp_enqueue_style(WPFB, WPFB_Core::PluginUrl("wp-filebase_css.php?rp={$upload_path}"), array(), WPFB_VERSION, 'all');
         }
     }
     $wpfb_admin_page = is_admin() && !empty($_GET['page']) && strpos($_GET['page'], 'wpfilebase_') !== false || defined('WPFB_EDITOR_PLUGIN');
     if ($wpfb_admin_page) {
         wpfb_loadclass('Admin');
     }
     // live admin
     if ($wpfb_admin_page && @$_GET['page'] == 'wpfilebase_filebrowser' || (WPFB_Core::CurUserCanCreateCat() || WPFB_Core::CurUserCanUpload()) && !is_admin()) {
         wp_enqueue_script(WPFB . '-live-admin', WPFB_PLUGIN_URI . 'js/live-admin.js', array('jquery'), WPFB_VERSION);
         if (self::GetOpt('admin_bar')) {
             add_action('admin_bar_menu', array(__CLASS__, 'AdminBar'), 80);
         }
         if (self::GetOpt('file_context_menu')) {
             wp_enqueue_script('jquery-contextmenu', WPFB_PLUGIN_URI . 'extras/jquery/contextmenu/jquery.contextmenu.js', array('jquery'));
             wp_enqueue_style('jquery-contextmenu', WPFB_PLUGIN_URI . 'extras/jquery/contextmenu/jquery.contextmenu.css', array(), WPFB_VERSION);
         }
         wp_enqueue_style('wpfb-live-admin', WPFB_PLUGIN_URI . 'css/live-admin.css', array(), WPFB_VERSION);
     }
     // for admin
     if (current_user_can('edit_posts') || current_user_can('edit_pages')) {
         self::MceAddBtns();
     }
     self::DownloadRedirect();
     if ((WPFB_Core::$settings->frontend_upload || current_user_can('upload_files')) && (!empty($_GET['wpfb_upload_file']) || !empty($_GET['wpfb_add_cat']))) {
         wpfb_call('Admin', empty($_GET['wpfb_upload_file']) ? 'ProcessWidgetAddCat' : 'ProcessWidgetUpload');
     }
     if (isset($_GET['wpfilebase_ajax'])) {
         define('DOING_AJAX', true);
         wpfb_loadclass('Ajax');
         WPFB_Ajax::PublicRequest();
     }
 }
开发者ID:TishoTM,项目名称:WP-Filebase,代码行数:80,代码来源:Core.php


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