Esempio n. 1
1
function piratenkleider_make_link_relative($url)
{
    if (piratenkleider_is_internal_link($url)) {
        $url = wp_make_link_relative($url);
    }
    return $url;
}
Esempio n. 2
1
							<?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>
Esempio n. 3
0
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);
}
Esempio n. 4
0
 /**
  * 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;
     }
 }
Esempio n. 5
0
 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;
 }
Esempio n. 6
0
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;
    }
}
Esempio n. 7
0
/**
 * 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 <*****@*****.**>
 */
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;
    }
}
Esempio n. 8
0
 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;
 }
Esempio n. 9
0
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);
    }
}
Esempio n. 10
0
 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;
     }
 }
Esempio n. 11
0
 /**
  * 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');
 }
Esempio n. 12
0
/**
 * 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;
}
Esempio n. 13
0
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 = '&nbsp;' . 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;
}
Esempio n. 14
0
    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 = '&amp;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 
    }
Esempio n. 15
0
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) . '&amp;w=415&amp;h=92&amp;zc=C';
}
?>

	<div class="moduleStatus">
		<span>Posted <?php 
the_time('l, F jS, Y');
?>
 at <?php 
the_time();
?>
</span>
	</div>

	<div class="inside"> 
		
	/**
	 * Register scripts and styles for Backups Controller
	 *
	 * @return void
	 */
	public function register_backups_scripts_and_styles() {
		do_action( 'ai1mw-register-backups-scripts-and-styles' );

		wp_enqueue_script(
			'ai1wm-js-backups',
			Ai1wm_Template::asset_link( 'javascript/backups.min.js' ),
			array( 'jquery' )
		);
		wp_enqueue_style(
			'ai1wm-css-backups',
			Ai1wm_Template::asset_link( 'css/backups.min.css' )
		);
		wp_localize_script( 'ai1wm-js-backups', 'ai1wm_feedback', array(
			'ajax' => array(
				'url' => wp_make_link_relative( admin_url( 'admin-ajax.php?action=ai1wm_feedback' ) ),
			),
		) );
		wp_localize_script( 'ai1wm-js-backups', 'ai1wm_report', array(
			'ajax' => array(
				'url' => wp_make_link_relative( admin_url( 'admin-ajax.php?action=ai1wm_report' ) ),
			),
		) );
		wp_localize_script( 'ai1wm-js-backups', 'ai1wm_backups', array(
			'ajax' => array(
				'url' => wp_make_link_relative( admin_url( 'admin-ajax.php?action=ai1wm_backups' ) ),
			),
		) );
		wp_localize_script( 'ai1wm-js-backups', 'ai1wm_import', array(
			'ajax' => array(
				'url' => wp_make_link_relative( admin_url( 'admin-ajax.php?action=ai1wm_import' ) ),
			),
			'status' => array(
				'php' => wp_make_link_relative( plugins_url( 'status.php', AI1WM_PLUGIN_BASENAME ) ),
				'js'  => wp_make_link_relative( plugins_url( 'storage/status.js', AI1WM_PLUGIN_BASENAME ) ),
			),
			'secret_key' => get_option( AI1WM_SECRET_KEY ),
		) );
	}
 /**
  * @ticket 26819
  */
 function test_wp_make_link_relative_with_no_path()
 {
     $link = 'http://example.com';
     $relative_link = wp_make_link_relative($link);
     $this->assertEquals('', $relative_link);
 }
Esempio n. 18
0
}
?>
			<?php 
// LOOP
$args = array('post_type' => 'article', 'tax_query' => array(array('taxonomy' => 'issue', 'field' => 'slug', 'terms' => current_taxonomy())));
$query = new WP_Query($args);
if ($query->have_posts()) {
    echo '<h2>' . custom_taxonomies_terms_links() . '</h2>';
    echo '<ul class="toc-item-list">';
    if (isset($mast)) {
        echo $mast;
    }
    while ($query->have_posts()) {
        $query->the_post();
        $link = get_permalink();
        $rel = wp_make_link_relative($link);
        echo '<li class="toc-item">';
        echo '<a class="toc-link webapp" href="' . $rel . '">' . get_the_title() . '</a>';
        echo '</li>';
    }
    echo '</ul>';
}
?>
		</div>
	</div>
	<div class="row option-menu submenu">
		<div class="small-12 column">
<!-- 			<div class="option-title">
				<div class="option-title-link">Options</div>
			</div>
 -->			<ul class="option-item-list">
 /**
  * Register scripts and styles for Import Controller
  *
  * @return void
  */
 public function register_import_scripts_and_styles()
 {
     do_action('ai1mw-register-import-scripts-and-styles');
     // we don't want heartbeat to occur when importing
     wp_deregister_script('heartbeat');
     wp_enqueue_script('ai1wm-js-import', Ai1wm_Template::asset_link('javascript/import.min.js'), array('plupload-all', 'jquery'));
     wp_enqueue_style('ai1wm-css-import', Ai1wm_Template::asset_link('css/import.min.css'));
     wp_localize_script('ai1wm-js-import', 'ai1wm_uploader', array('runtimes' => 'html5,silverlight,flash,html4', 'browse_button' => 'ai1wm-import-file', 'container' => 'ai1wm-plupload-upload-ui', 'drop_element' => 'ai1wm-drag-drop-area', 'file_data_name' => 'upload-file', 'chunk_size' => apply_filters('ai1wm_max_chunk_size', AI1WM_MAX_CHUNK_SIZE), 'max_retries' => apply_filters('ai1wm_max_chunk_retries', AI1WM_MAX_CHUNK_RETRIES), 'url' => wp_make_link_relative(admin_url('admin-ajax.php?action=ai1wm_import')), 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'multiple_queues' => false, 'multi_selection' => false, 'urlstream_upload' => true, 'unique_names' => true, 'multipart' => true, 'multipart_params' => array('provider' => 'file', 'method' => 'import', 'secret_key' => get_site_option(AI1WM_SECRET_KEY, false, false)), 'filters' => array('ai1wm_archive_extension' => array('wpress', 'bin'), 'ai1wm_archive_size' => apply_filters('ai1wm_max_file_size', AI1WM_MAX_FILE_SIZE))));
     wp_localize_script('ai1wm-js-import', 'ai1wm_feedback', array('ajax' => array('url' => wp_make_link_relative(admin_url('admin-ajax.php?action=ai1wm_leave_feedback')))));
     wp_localize_script('ai1wm-js-import', 'ai1wm_report', array('ajax' => array('url' => wp_make_link_relative(admin_url('admin-ajax.php?action=ai1wm_report_problem')))));
     wp_localize_script('ai1wm-js-import', 'ai1wm_maintenance', array('ajax' => array('url' => wp_make_link_relative(admin_url('admin-ajax.php?action=ai1wm_disable_maintenance')))));
     wp_localize_script('ai1wm-js-import', 'ai1wm_import', array('ajax' => array('url' => wp_make_link_relative(admin_url('admin-ajax.php?action=ai1wm_import'))), 'status' => array('url' => wp_make_link_relative(AI1WM_STORAGE_URL)), 'secret_key' => get_site_option(AI1WM_SECRET_KEY, false, false), 'oversize' => sprintf(__('The file that you are trying to import is over the maximum upload file size limit of <strong>%s</strong>.' . '<br />You can remove this restriction by purchasing our ' . '<a href="https://servmask.com/products/unlimited-extension" target="_blank">Unlimited Extension</a>.', AI1WM_PLUGIN_NAME), size_format(apply_filters('ai1wm_max_file_size', AI1WM_MAX_FILE_SIZE))), 'invalid_extension' => sprintf(__('Version 2.1.1 of All in One WP Migration introduces new compression algorithm. ' . 'It makes exporting and importing 10 times faster.' . '<br />Unfortunately, the new format is not back compatible with backups made with earlier ' . 'versions of the plugin.' . '<br />You can either create a new backup with the latest version of the ' . 'plugin, or convert the archive to the new format using our tools ' . '<a href="%s" target="_blank">here</a>.', AI1WM_PLUGIN_NAME), AI1WM_ARCHIVE_TOOLS_URL)));
 }
/**
 * Root-relative URLs
 *
 * Adapted from Roots
 *
 * Disabled for production per: https://yoast.com/relative-urls-issues/
 */
return function ($value) {
    if (is_admin() || in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'))) {
        return;
    }
    if (!defined('WP_ENV')) {
        return;
    }
    if (is_array($value) && !in_array(WP_ENV, $value)) {
        return;
    }
    $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', 'nav_menu_link_attributes', 'the_content_more_link', 'excerpt_more', 'get_pagenum_link', 'get_comments_pagenum_link', 'get_comment_link', 'month_link', 'day_link', 'year_link', 'tag_link', 'script_loader_src', 'style_loader_src');
    foreach ($filters as $filter) {
        add_filter($filter, function ($input) {
            if (!is_string($input)) {
                return $input;
            }
            // Do not filter external protocol-agnostic URLs
            if (strpos($input, home_url()) === false) {
                return $input;
            }
            return wp_make_link_relative($input);
        });
    }
};
         <?php 
    comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth'])));
    ?>
       </nav>
     </article>
    <!-- </li> is added by wordpress automatically -->
<?php 
}
automatic_feed_links();
// Widgetized Sidebar HTML5 Markup
if (function_exists('register_sidebar')) {
    register_sidebar(array('before_widget' => '<section>', 'after_widget' => '</section>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>'));
}
// Custom Functions for CSS/Javascript Versioning
$GLOBALS["TEMPLATE_URL"] = get_bloginfo('template_url') . "/";
$GLOBALS["TEMPLATE_RELATIVE_URL"] = wp_make_link_relative($GLOBALS["TEMPLATE_URL"]);
// Add ?v=[last modified time] to style sheets
function versioned_stylesheet($relative_url, $add_attributes = "")
{
    echo '<link rel="stylesheet" href="' . versioned_resource($relative_url) . '" ' . $add_attributes . '>' . "\n";
}
// Add ?v=[last modified time] to javascripts
function versioned_javascript($relative_url, $add_attributes = "")
{
    echo '<script src="' . versioned_resource($relative_url) . '" ' . $add_attributes . '></script>' . "\n";
}
// Add ?v=[last modified time] to a file url
function versioned_resource($relative_url)
{
    $file = $_SERVER["DOCUMENT_ROOT"] . $relative_url;
    $file_version = "";
Esempio n. 22
0
 /**
  * Handles a status update that includes an image.
  * @param type $url
  * @param type $args
  * @return boolean
  */
 function handleMediaRequest($url, $args = array())
 {
     /* Load tmhOAuth for Media uploads only when needed: https://github.com/themattharris/tmhOAuth */
     if (!class_exists('tmhOAuth')) {
         require_once 'tmhOAuth/tmhOAuth.php';
         require_once 'tmhOAuth/tmhUtilities.php';
     }
     $auth = $args['auth'];
     if (!$auth) {
         $ack = get_option('app_consumer_key');
         $acs = get_option('app_consumer_secret');
         $ot = get_option('oauth_token');
         $ots = get_option('oauth_token_secret');
     } else {
         $ack = get_user_meta($auth, 'app_consumer_key', true);
         $acs = get_user_meta($auth, 'app_consumer_secret', true);
         $ot = get_user_meta($auth, 'oauth_token', true);
         $ots = get_user_meta($auth, 'oauth_token_secret', true);
     }
     // when performing as a scheduled action, need to include file.php
     if (!function_exists('get_home_path')) {
         require_once ABSPATH . 'wp-admin/includes/file.php';
     }
     $connect = array('consumer_key' => $ack, 'consumer_secret' => $acs, 'user_token' => $ot, 'user_secret' => $ots);
     $tmhOAuth = new tmhOAuth($connect);
     $attachment = wpt_post_attachment($args['id']);
     // if install is at root, can query src path. Otherwise, need to take full image.
     $at_root = wp_make_link_relative(home_url()) == home_url() || wp_make_link_relative(home_url()) == '/' ? true : false;
     if ($at_root) {
         $image_sizes = get_intermediate_image_sizes();
         if (in_array('large', $image_sizes)) {
             $size = 'large';
         } else {
             $size = array_pop($image_sizes);
         }
         $upload = wp_get_attachment_image_src($attachment, apply_filters('wpt_upload_image_size', $size));
         $path = get_home_path() . wp_make_link_relative($upload[0]);
         $image = str_replace('//', '/', $path);
     } else {
         $image = get_attached_file($attachment);
     }
     $image = apply_filters('wpt_image_path', $image, $args);
     $mime_type = get_post_mime_type($attachment);
     if (!$mime_type) {
         $mime_type = 'image/jpeg';
     }
     $code = $tmhOAuth->request('POST', $url, array('media[]' => "@{$image};type={$mime_type};filename={$image}", 'status' => $args['status']), true, true);
     if (WPT_DEBUG && function_exists('wpt_pro_exists')) {
         $debug = array('media[]' => "@{$image};type={$mime_type};filename={$image}", 'status' => $args['status']);
         wpt_mail("Media Submitted - Post ID #{$args['id']}", print_r($debug, 1));
     }
     $response = $tmhOAuth->response['response'];
     if (is_wp_error($response)) {
         return false;
     }
     $this->http_code = $code;
     $this->last_api_call = $url;
     $this->format = 'json';
     $this->http_header = $response;
     return $response;
 }
Esempio n. 23
0
	/**
	 * @ticket 30373
	 */
	public function test_wp_make_link_relative_should_retain_URL_param_that_is_also_a_URL() {
		$link = 'https://example.com/this-is-a-test/?redirect=https://example.org/a-different-test-post/';
		$relative_link = wp_make_link_relative( $link );
		$this->assertEquals( '/this-is-a-test/?redirect=https://example.org/a-different-test-post/', $relative_link );
	}
Esempio n. 24
0
function bapi_get_slideshow($mode = 'raw')
{
    $slide1 = get_option('bapi_slideshow_image1');
    $slide2 = get_option('bapi_slideshow_image2');
    $slide3 = get_option('bapi_slideshow_image3');
    $slide4 = get_option('bapi_slideshow_image4');
    $slide5 = get_option('bapi_slideshow_image5');
    $slide6 = get_option('bapi_slideshow_image6');
    $slide1cap = get_option('bapi_slideshow_caption1');
    $slide2cap = get_option('bapi_slideshow_caption2');
    $slide3cap = get_option('bapi_slideshow_caption3');
    $slide4cap = get_option('bapi_slideshow_caption4');
    $slide5cap = get_option('bapi_slideshow_caption5');
    $slide6cap = get_option('bapi_slideshow_caption6');
    $slideshow = array();
    $i = 0;
    if (strlen($slide1) > 0) {
        $slideshow[$i] = array("url" => wp_make_link_relative($slide1), "caption" => $slide1cap, "thumb" => plugins_url('thumbs/timthumb.php?src=' . urlencode($slide1) . '&h=80', __FILE__));
        $i++;
    }
    if (strlen($slide2) > 0) {
        $slideshow[$i] = array("url" => wp_make_link_relative($slide2), "caption" => $slide2cap, "thumb" => plugins_url('thumbs/timthumb.php?src=' . urlencode($slide2) . '&h=80', __FILE__));
        $i++;
    }
    if (strlen($slide3) > 0) {
        $slideshow[$i] = array("url" => wp_make_link_relative($slide3), "caption" => $slide3cap, "thumb" => plugins_url('thumbs/timthumb.php?src=' . urlencode($slide3) . '&h=80', __FILE__));
        $i++;
    }
    if (strlen($slide4) > 0) {
        $slideshow[$i] = array("url" => wp_make_link_relative($slide4), "caption" => $slide4cap, "thumb" => plugins_url('thumbs/timthumb.php?src=' . urlencode($slide4) . '&h=80', __FILE__));
        $i++;
    }
    if (strlen($slide5) > 0) {
        $slideshow[$i] = array("url" => wp_make_link_relative($slide5), "caption" => $slide5cap, "thumb" => plugins_url('thumbs/timthumb.php?src=' . urlencode($slide5) . '&h=80', __FILE__));
        $i++;
    }
    if (strlen($slide6) > 0) {
        $slideshow[$i] = array("url" => wp_make_link_relative($slide6), "caption" => $slide6cap, "thumb" => plugins_url('thumbs/timthumb.php?src=' . urlencode($slide6) . '&h=80', __FILE__));
        $i++;
    }
    if ($mode == 'raw') {
        return $slideshow;
    }
    if ($mode == 'json') {
        $json = json_encode($slideshow);
        ?>
			<script>
				var slides_json = '<?php 
        echo $json;
        ?>
';
			</script>	
			<?php 
        return true;
    }
    if ($mode == 'divs') {
        foreach ($slideshow as $sl) {
            ?>
				<div>
					<a href=""><img src="<?php 
            echo $sl['url'];
            ?>
" title="<?php 
            echo $sl['caption'];
            ?>
" /></a>
				</div>
				<?php 
        }
        return true;
    }
}
Esempio n. 25
0
 public function widget($args, $instance)
 {
     global $defaultoptions;
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     $url = esc_url($instance['url']);
     $image_url = esc_url($instance['image_url']);
     $image_id = intval($instance['image_id']);
     $image_width = $defaultoptions['bannerlink-width'];
     $image_height = 0;
     if ($image_id > 0) {
         // Get Thumbnail instead of original
         $image_attributes = wp_get_attachment_image_src($image_id, $defaultoptions['bannerlink_name']);
         $image_url = $image_attributes[0];
         $image_width = $image_attributes[1];
         $image_height = $image_attributes[2];
     }
     $site_link = home_url();
     if (isset($url) && strpos($url, $site_link) !== false) {
         $url = wp_make_link_relative($url);
     }
     if ($image_id > 0 || isset($image_url) && strpos($image_url, $site_link) !== false) {
         $image_url = wp_make_link_relative($image_url);
     }
     if (!isset($url) && !isset($image_url)) {
         return;
     }
     echo $before_widget;
     echo '<p class="bannerlink">';
     if (isset($url) && strlen($url) > 0) {
         echo '<a href="' . $url . '">';
     }
     if ($image_url) {
         if ($image_height > 0) {
             echo '<img src="' . $image_url . '" width="' . $image_width . '" height="' . $image_height . '" alt="' . $title . '">';
         } else {
             echo '<img src="' . $image_url . '" style="max-width: ' . $defaultoptions['bannerlink-width'] . 'px; height: auto;" alt="' . $title . '">';
         }
     } else {
         echo $title;
     }
     if (isset($url) && strlen($url) > 0) {
         echo '</a>';
     }
     echo "</p>\n";
     echo $after_widget;
 }
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();
	if ( !isset($attachment_data['width']) && $is_image ) {
		if ( $image_data = getimagesize( get_attached_file( $id ) ) ) {
			$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);

	ob_start();
		the_title();
		$post_title = attribute_escape(ob_get_contents());
	ob_end_clean();
	$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 = '&nbsp;' . 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);

	$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";
	$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;
}
Esempio n. 27
0
function wr2x_get_pathinfo_from_image_src($image_src)
{
    $uploads_url = trailingslashit(wr2x_get_upload_root_url());
    if (strpos($image_src, $uploads_url) === 0) {
        return ltrim(substr($image_src, strlen($uploads_url)), '/');
    } else {
        if (strpos($image_src, wp_make_link_relative($uploads_url)) === 0) {
            return ltrim(substr($image_src, strlen(wp_make_link_relative($uploads_url))), '/');
        }
    }
    $img_info = parse_url($image_src);
    return ltrim($img_info['path'], '/');
}
Esempio n. 28
0
        <?php 
if (!is_home()) {
    ?>
                  <a itemprop="url" href="<?php 
    echo home_url('/');
    ?>
" title="<?php 
    echo $defaultoptions['default_text_title_home_backlink'];
    ?>
" rel="home" class="logo">
              <?php 
}
?>
                                                             
              <h1><img itemprop="logo" src="<?php 
echo wp_make_link_relative(get_header_image());
?>
" alt="<?php 
bloginfo('name');
?>
"></h1>
              <meta itemprop="name" content="<?php 
echo esc_attr(piratenkleider_tag_schema_org_name());
?>
" />              
              <?php 
if (!is_home()) {
    ?>
                  </a>
              <?php 
}
Esempio n. 29
-1
function wp_ozh_adminmenu_css()
{
    global $wp_ozh_adminmenu, $pagenow, $text_direction;
    // $submenu = ($wp_ozh_adminmenu['display_submenu'] or ($pagenow == "media-upload.php") ) ? 1 : 0;
    // Making links relative so they're more readable and shorter in the query string (also made relative in the .css.php)
    $plugin = WP_PLUGIN_URL . '/' . plugin_basename(dirname(__FILE__));
    // query vars
    $query = array('p' => wp_make_link_relative($plugin), 'i' => $wp_ozh_adminmenu['icons'], 'w' => $wp_ozh_adminmenu['wpicons'], 'm' => $wp_ozh_adminmenu['minimode'], 'c' => $wp_ozh_adminmenu['compact'], 'h' => $wp_ozh_adminmenu['hidebubble'], 'f' => $wp_ozh_adminmenu['displayfav'], 'g' => $wp_ozh_adminmenu['grad'], 'n' => $wp_ozh_adminmenu['nograd'], 'd' => $text_direction == 'rtl' ? 'right' : 'left');
    $query = http_build_query($query);
    echo "<link rel='stylesheet' href='{$plugin}/adminmenu.css.php?{$query}' type='text/css' media='all' />\n";
}
Esempio n. 30
-1
function wp_ozh_adminmenu_css()
{
    global $wp_ozh_adminmenu, $pagenow, $text_direction;
    // $submenu = ($wp_ozh_adminmenu['display_submenu'] or ($pagenow == "media-upload.php") ) ? 1 : 0;
    // Making links relative so they're more readable and shorter in the query string (also made relative in the .css.php)
    $plugin = wp_ozh_adminmenu_pluginurl() . 'inc/';
    // query vars
    $query = array('v' => OZH_MENU_VER, 'p' => wp_make_link_relative($plugin), 'a' => wp_make_link_relative(trailingslashit(get_admin_url())), 'i' => $wp_ozh_adminmenu['icons'], 'w' => $wp_ozh_adminmenu['wpicons'], 'm' => $wp_ozh_adminmenu['minimode'], 'c' => $wp_ozh_adminmenu['compact'], 'h' => $wp_ozh_adminmenu['hidebubble'], 'g' => $wp_ozh_adminmenu['grad'], 'n' => $wp_ozh_adminmenu['nograd'], 'd' => $text_direction == 'rtl' ? 'right' : 'left');
    $query = http_build_query($query);
    echo "<link rel='stylesheet' href='{$plugin}adminmenu.css.php?{$query}' type='text/css' media='all' />\n";
}