本文整理汇总了PHP中wp_make_link_relative函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_make_link_relative函数的具体用法?PHP wp_make_link_relative怎么用?PHP wp_make_link_relative使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_make_link_relative函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: piratenkleider_make_link_relative
function piratenkleider_make_link_relative($url)
{
if (piratenkleider_is_internal_link($url)) {
$url = wp_make_link_relative($url);
}
return $url;
}
示例2: while
<?php
if (have_posts()) {
while (have_posts()) {
the_post();
?>
<?php
$post = get_the_ID();
include 'small-catalog.php';
?>
<section class="category-lead container">
<div class="row">
<div class="col-xs-3 category-lead__icon">
<?php
$current_thumb = ltrim(wp_make_link_relative(wp_get_attachment_url(get_post_thumbnail_id($post))), '/');
include $current_thumb;
?>
</div>
<div class="col-xs-9">
<h1 class="category-lead__title page-title"><?php
the_title();
?>
</h1>
<div class="category-lead__content">
<?php
the_content();
?>
</div>
</div>
</div>
示例3: wpbc_make_link_absolute
function wpbc_make_link_absolute($link)
{
if ($link != get_option('siteurl') && strpos($link, 'http') !== 0) {
$link = get_option('siteurl') . '/' . trim(wp_make_link_relative($link), '/');
}
return esc_js($link);
}
示例4: valid_image
/**
* make sure the image is valid, has a src and has an height and width
* @param type $post_image
* @return null
*/
public function valid_image($post_image)
{
if (!isset($post_image['src']) && isset($post_image['url'])) {
$post_image['src'] = $post_image['url'];
}
if (isset($post_image['src'])) {
// check that height & width have been set, if not try to calculate
if (empty($post_image['height']) || empty($post_image['width']) || empty($post_image['height']) && empty($post_image['width'])) {
try {
$image_info = getimagesize($post_image['src']);
if ($image_info !== false) {
$post_image['width'] = $image_info[0];
$post_image['height'] = $image_info[1];
} else {
// if allow_url_fopen is off we need to convert the url image into a local file
$image_src = dirname(dirname(dirname(WYSIJA_UPLOADS_DIR))) . wp_make_link_relative($post_image['src']);
$image_info = getimagesize($image_src);
if ($image_info !== false) {
$post_image['width'] = $image_info[0];
$post_image['height'] = $image_info[1];
}
}
} catch (Exception $e) {
return null;
}
}
return $post_image;
} else {
return null;
}
}
示例5: root_relative_url
function root_relative_url($input)
{
preg_match('|https?://([^/]+)(/.*)|i', $input, $matches);
if (isset($matches[1]) && isset($matches[2]) && $matches[1] === $_SERVER['SERVER_NAME']) {
return wp_make_link_relative($input);
}
return $input;
}
示例6: proper_icon
function proper_icon($name)
{
if (isset($name)) {
$svg_root = get_stylesheet_directory_uri() . '/_/svg/symbols.svg';
$svg_relative_root = wp_make_link_relative($svg_root);
$use_format = '<use xlink:href="%1$s#%2$s"/>';
return sprintf($use_format, $svg_relative_root, $name);
} else {
return null;
}
}
示例7: i4web_root_relative_url
/**
* Root relative URLs
*
* WordPress likes to use absolute URLs on everything - let's clean that up.
* Inspired by http://www.456bereastreet.com/archive/201010/how_to_make_wordpress_urls_root_relative/
*
* You can enable/disable this feature in config.php:
* current_theme_supports('root-relative-urls');
*
* @author Scott Walkinshaw <scott.walkinshaw@gmail.com>
*/
function i4web_root_relative_url($input)
{
preg_match('|https?://([^/]+)(/.*)|i', $input, $matches);
if (!isset($matches[1]) || !isset($matches[2])) {
return $input;
} elseif ($matches[1] === $_SERVER['SERVER_NAME'] || $matches[1] === $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) {
return wp_make_link_relative($input);
} else {
return $input;
}
}
示例8: asset_path
function asset_path($type, $filename)
{
$theme_location = get_stylesheet_directory_uri();
$url = wp_make_link_relative($theme_location);
$manifest_path = ".{$url}/resources/{$type}/rev-manifest.json";
if (file_exists($manifest_path)) {
$manifest = json_decode(file_get_contents($manifest_path), TRUE);
} else {
$manifest = [];
}
if (array_key_exists($filename, $manifest)) {
return $manifest[$filename];
}
return $filename;
}
示例9: relative_url
function relative_url()
{
$filters = array('bloginfo_url', 'the_permalink', 'wp_list_pages', 'wp_list_categories', 'the_content_more_link', 'the_tags', 'the_author_posts_link', 'post_link', 'post_type_link', 'page_link', 'attachment_link', 'get_shortlink', 'post_type_archive_link', 'get_pagenum_link', 'get_comments_pagenum_link', 'term_link', 'search_link', 'day_link', 'month_link', 'year_link', 'option_siteurl', 'blog_option_siteurl', 'option_home', 'admin_url', 'get_admin_url', 'get_site_url', 'network_admin_url', 'home_url', 'includes_url', 'site_url', 'site_option_siteurl', 'network_home_url', 'network_site_url', 'get_the_author_url', 'get_comment_link', 'wp_get_attachment_image_src', 'wp_get_attachment_thumb_url', 'wp_get_attachment_url', 'wp_login_url', 'wp_logout_url', 'wp_lostpassword_url', 'get_stylesheet_uri', 'get_locale_stylesheet_uri', 'script_loader_src', 'style_loader_src', 'get_theme_root_uri');
// Thanks to https://wordpress.org/support/topic/request-only-replace-local-urls
$home_url = home_url();
$filter_fn = function ($link) use($home_url) {
if (!is_array($link) && strpos($link, $home_url) === 0) {
return wp_make_link_relative($link);
} else {
return $link;
}
};
foreach ($filters as $filter) {
add_filter($filter, $filter_fn);
}
}
示例10: handleLogoChange
function handleLogoChange()
{
$uploadedfile = $_FILES['logo'];
$upload_overrides = array('test_form' => false, 'action' => 'logo_upload');
$movefile = wp_handle_upload($uploadedfile, $upload_overrides);
if ($movefile && !isset($movefile['error'])) {
return wp_make_link_relative($movefile['url']);
} else {
/**
* Error generated by _wp_handle_upload()
* @see _wp_handle_upload() in wp-admin/includes/file.php
*/
echo $movefile['error'];
die;
}
}
示例11: load_all_scripts
/**
* Hooks into wp_enqueue_scripts to bring everything to the front-end.
*
* Loads in our main styles and scripts for the /Me front-end.
* Uses wp_localize_script to pass along a few parameters to our Marionette app.
*
* @since 0.1.0
*
* @uses wp_enqueue_scripts()
*
* @see localize_modules
*
*/
function load_all_scripts()
{
// This clears all current scripts and styles. Open to more elegant solutions here
global $wp_scripts;
global $wp_styles;
$adminBar = $wp_styles->registered['admin-bar'];
$openSans = $wp_styles->registered['open-sans'];
$dashicons = $wp_styles->registered['dashicons'];
$wp_scripts->registered = array();
$wp_styles->queue = array("admin-bar");
wp_enqueue_style('grids', ME__PLUGIN_URL . 'front/css/lib/flexboxgrid.css');
wp_enqueue_style('me_css', ME__PLUGIN_URL . 'front/css/style.css');
wp_enqueue_script('vendors', ME__PLUGIN_URL . '/front/app/vendor/vendor.min.js', '', '', true);
wp_register_script('main', ME__PLUGIN_URL . '/front/app/build/index.bundle.js', '', '', true);
wp_localize_script('main', 'meVars', array('js_url' => ME__PLUGIN_URL . '/app/js', 'root_url' => wp_make_link_relative(home_url('/me')) . '/', 'api_url' => home_url('/wp-json/me/v1'), 'active_modules' => Me_Utils::localize_modules(), 'plugin_url' => ME__PLUGIN_URL));
wp_enqueue_script('main');
}
示例12: root_relative_url
/**
* Make a URL relative
*/
function root_relative_url($input)
{
$url = parse_url($input);
if (!isset($url['host']) || !isset($url['path'])) {
return $input;
}
$site_url = parse_url(network_site_url());
// falls back to site_url
if (!isset($url['scheme'])) {
$url['scheme'] = $site_url['scheme'];
}
$hosts_match = $site_url['host'] === $url['host'];
$schemes_match = $site_url['scheme'] === $url['scheme'];
$ports_exist = isset($site_url['port']) && isset($url['port']);
$ports_match = $ports_exist ? $site_url['port'] === $url['port'] : true;
if ($hosts_match && $schemes_match && $ports_match) {
return wp_make_link_relative($input);
}
return $input;
}
示例13: wp_upload_display
function wp_upload_display($dims = false, $href = '')
{
global $post;
$id = get_the_ID();
$attachment_data = wp_get_attachment_metadata($id);
$is_image = (int) wp_attachment_is_image();
$filesystem_path = get_attached_file($id);
if (!isset($attachment_data['width']) && $is_image) {
if ($image_data = getimagesize($filesystem_path)) {
$attachment_data['width'] = $image_data[0];
$attachment_data['height'] = $image_data[1];
wp_update_attachment_metadata($id, $attachment_data);
}
}
if (isset($attachment_data['width'])) {
list($width, $height) = wp_shrink_dimensions($attachment_data['width'], $attachment_data['height'], 171, 128);
}
$post_title = attribute_escape(the_title('', '', false));
$post_content = attribute_escape(apply_filters('content_edit_pre', $post->post_content));
$class = 'text';
$innerHTML = get_attachment_innerHTML($id, false, $dims);
if ($image_src = get_attachment_icon_src()) {
$image_rel = wp_make_link_relative($image_src);
$innerHTML = ' ' . str_replace($image_src, $image_rel, $innerHTML);
$class = 'image';
}
$src_base = wp_get_attachment_url();
$src = wp_make_link_relative($src_base);
$src_base = str_replace($src, '', $src_base);
if (!trim($post_title)) {
$post_title = basename($src);
}
$r = '';
if ($href) {
$r .= "<a id='file-link-{$id}' href='{$href}' title='{$post_title}' class='file-link {$class}'>\n";
}
if ($href || $image_src) {
$r .= "\t\t\t{$innerHTML}";
}
if ($href) {
$r .= "</a>\n";
}
$size = @filesize($filesystem_path);
if (!empty($size)) {
$r .= "\t\t\t\t<span class='upload-file-size'>" . size_format($size) . "</span>\n";
}
$r .= "\n\t\t<div class='upload-file-data'>\n\t\t\t<p>\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-url-{$id}' id='attachment-url-{$id}' value='{$src}' />\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-url-base-{$id}' id='attachment-url-base-{$id}' value='{$src_base}' />\n";
if (!($thumb_base = wp_get_attachment_thumb_url())) {
$thumb_base = wp_mime_type_icon();
}
if ($thumb_base) {
$thumb_rel = wp_make_link_relative($thumb_base);
$thumb_base = str_replace($thumb_rel, '', $thumb_base);
$r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-{$id}' id='attachment-thumb-url-{$id}' value='{$thumb_rel}' />\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-base-{$id}' id='attachment-thumb-url-base-{$id}' value='{$thumb_base}' />\n";
}
$r .= "\t\t\t\t<input type='hidden' name='attachment-is-image-{$id}' id='attachment-is-image-{$id}' value='{$is_image}' />\n";
if (isset($width)) {
$r .= "\t\t\t\t<input type='hidden' name='attachment-width-{$id}' id='attachment-width-{$id}' value='{$width}' />\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-height-{$id}' id='attachment-height-{$id}' value='{$height}' />\n";
}
$r .= "\t\t\t\t<input type='hidden' name='attachment-page-url-{$id}' id='attachment-page-url-{$id}' value='" . get_attachment_link($id) . "' />\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-title-{$id}' id='attachment-title-{$id}' value='{$post_title}' />\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-description-{$id}' id='attachment-description-{$id}' value='{$post_content}' />\n";
$r .= "\t\t\t</p>\n\t\t</div>\n";
return $r;
}
示例14: comicpress_show_control_panel
function comicpress_show_control_panel()
{
global $user_login;
if (!is_user_logged_in()) {
$args = array('label_username' => __('Username', 'comicpress'), 'label_password' => __('Password', 'comicpress'));
wp_login_form($args);
?>
<ul>
<?php
if (is_multisite()) {
?>
<li><a href="<?php
echo home_url();
?>
/wp-signup.php"><?php
_e('Register', 'comicpress');
?>
</a></li>
<?php
} else {
?>
<li><a href="<?php
echo home_url();
?>
/wp-register.php"><?php
_e('Register', 'comicpress');
?>
</a></li>
<?php
}
?>
<li><a href="<?php
echo home_url();
?>
/wp-login.php?action=lostpassword"><?php
_e('Recover password', 'comicpress');
?>
</a></li>
</ul>
<?php
} else {
?>
<ul>
<?php
$redirect = '&redirect_to=' . urlencode(wp_make_link_relative(site_url()));
$uri = wp_nonce_url(site_url("wp-login.php?action=logout{$redirect}", 'login'), 'log-out');
?>
<li><a href="<?php
echo $uri;
?>
"><?php
_e('Logout', 'comicpress');
?>
</a></li>
<?php
wp_register();
?>
<li><a href="<?php
echo home_url();
?>
/wp-admin/profile.php"><?php
_e('Profile', 'comicpress');
?>
</a></li>
</ul>
<?php
}
?>
<?php
}
示例15: get_posts
if ($featuredCat) {
$featuredPost = get_posts('category=' . $featuredCat->term_id . '&numberposts=1');
}
if (empty($featuredPost) || strtotime($featuredPost[0]->post_date) < time() - 1209600) {
$articleCat = get_bloginfo('articles_cat', 'display');
$articleCat = get_category_by_slug($articleCat);
$featuredPost = get_posts('category=' . $articleCat->term_id . '&numberposts=1&orderby=RAND()');
}
setup_postdata($featuredPost[0]);
global $post;
$post = $featuredPost[0];
$featuredPic = get_post_meta($post->ID, 'featured_image', true);
if (empty($featuredPic)) {
$featuredPic = nm_get_photo('415', '92', false, false);
} else {
$featuredPic = get_bloginfo('wpurl') . '/images/phpThumb.php?src=' . wp_make_link_relative($featuredPic) . '&w=415&h=92&zc=C';
}
?>
<div class="moduleStatus">
<span>Posted <?php
the_time('l, F jS, Y');
?>
at <?php
the_time();
?>
</span>
</div>
<div class="inside">