Absolute File paths with Stylesheets CSS - php

Can anyone please tell me why the below will not and output the absolute filepath
<link rel="stylesheet" type="text/css" href=" <?php 'http://' . $_SERVER['HTTP_HOST'] . '/styles/styles.css'; ?> " />
I'm trying to create a constant link

you forgot to echo
<link rel="stylesheet" type="text/css" href=" <?php echo 'http://' . $_SERVER['HTTP_HOST'] . '/styles/styles.css'; ?> " />

Related

fetch wordpress post slug in header meta tag

let's say I have 2.. domain A and B
how do you fetch WordPress post URL (only the URL, not the domain part) from domain A so it points to domain B
<link rel="alternate" href="<?php the_permalink(); ?>" hreflang="en" />
<link rel="alternate" href="https://domainB<?php the_permalink(); ?>" hreflang="za" />
so the output will be printed something like this
<link rel="alternate" href="domainA/postname" hreflang="en" />
<link rel="alternate" href="domainB/postname" hreflang="za" />
These code https://domainB<?php the_permalink(); ?> gave me error, nonce_failure
If you want to dynamically change the link on each page. This might help -
$domains_1 = 'https://' . domainA . $_SERVER['REQUEST_URI'];
$domains_2 = 'https://' . domainB . $_SERVER['REQUEST_URI'];
echo "<link rel='alternate' href='".$domains_1."' hreflang='en'/>";
echo "<link rel='alternate' href='".$domains_2."' hreflang='za'/>";

How to add content-type to WordPress favicon

Good afternoon, there is a standard favicon output -
<link rel="icon" href="/wp-content/uploads/2016/04/MyLogo.png" sizes="32x32" />
Is there an example function and hook that would add type=" desired type" to the output in the link
<link rel="icon" type="image/png">
You can programatically change this through functions.php
function myfavicon() {
$path = get_bloginfo('wpurl') . "/wp-content/uploads/2016/04/MyLogo.png";
echo '<link rel="icon" type="image/png" href="' . $path . '" sizes="32x32" />';
}
add_action('wp_head', 'myfavicon');
I also have added the absolute path because for IE you need a fully qualified URL instead of a relative url.

How I can remove the link breaks or tabs in dynamically generated paths?

Can anyone please tell me that how I can remove the line breaks in dynamically generated paths?
See example given below;
I'm using this code to generate the dynamic paths in href.
$text = trim('<?php echo SITE_ROOT; ?>' . '/') . $currentProjectName . $defaultCssDir . $filename;
Output in HTML:
<link href="<?php echo SITE_ROOT; ?>
/sample-2/public/styles/style.css" rel="stylesheet" type="text/css" />
But I want output in this style:
<link href="<?php echo SITE_ROOT; ?>/sample-2/public/styles/style.css" rel="stylesheet" type="text/css" />
Thanks in advance!
Smac
Try this when you print or echo your $text variable:
echo str_replace(PHP_EOL, '', $text);

Fancybox JQuery not loading

I'm having trouble with loading the JQuery for Fancybox. I really have no idea what is going wrong.
<!-- FAVICON + CSS -->
<link href="<?php echo base_url() . APPPATH; ?>images/ftimagesoriginal/favicon.ico" rel="icon" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url() . APPPATH; ?>styles/layout.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo base_url() . APPPATH; ?>styles/menu.css"/>
<!-- JQUERY FANCYBOX + CSS -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo base_url() . APPPATH; ?>fancybox/jquery.fancybox.pack.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo base_url() . APPPATH; ?>fancybox/jquery.fancybox.css?"/>
<!-- JQUERY MENU -->
<script type="text/javascript" src="<?php echo base_url() . APPPATH; ?>js/jquery.easing.1.3.js"></script>
The code above is in my MAIN_MASTER page, in my 'home.php' page I'm requesting the .fancybox function.
<script type="text/javascript">
JQuery(document).ready(function(){
$('.fancybox').fancybox();
});
The code below is an example of an image with Fancybox.
<li><a class="fancybox" href="<?php echo base_url() . APPPATH; ?>images/ftimagesoriginal/ft1.jpg"><img src="<?php echo base_url() . APPPATH; ?>images/ftimagesresized/ft1174.jpg" alt="test"/></a></li>
I really have no idea what is going on. I checked the order of loading the JQuery libs, I checked the console in Chrome and I'm getting the 'Uncaught referenceError: JQuery is not defined' error. All of my JQuery libs are loading so the browser finds them on my server.
Can anyone help me resolving my problem? I'm affraid it's just a very stupid mistake, but I can't seem to find it.
Thanks for your help.
Try this code.
$(document).ready(function(){ //JQuery is replaced by $
$('.fancybox').fancybox();
});

CSS doesn't work when I add slash (/) at the end of my url

I'm new to code igniter and I wonder why my css doesn't work when I add slash ( / ) at the end of the url ..
Can someone help me why it doesn't work ? And help me make it work ?
Try this add code to your html head:
<link rel="stylesheet" href="<?php echo site_url('css/style.css');?>" type="text/css"/>
or
<link rel="stylesheet" href="<?php echo base_url();?>css/style.css" type="text/css"/>
CodeIgniter has method: site_url() - which generates your home url with '/' (slash) at the end.
To access public assets of your application
use this:
<link type="text/css" rel="stylesheet" href="<?php echo site_url(); ?>public/css/smoothness/jquery-ui-1.10.2.custom.min.css">
<script type="text/javascript" src="<?php echo site_url(); ?>public/js/custom.modernizr.js"></script>
Note: href="<?php echo site_url(); ?>public/css/smoothness/jquery-ui-1.10.2.custom.min.css"

Categories