I want to load my style-sheet's and script's inside wordpress header to show documentation in my front-page/homepage for specific condition supply by wordpress option setting get_option('my_main_scripts').
Pool of values for this option setting are javascript library, javascript yui, javascript jquery, javascript dojo and so on. All option value consist with common word javascript.
and want to load css if any one value is selected from the pool which contains word javascript.
So writing condition with each option using OR (||) , I think its better to grab the common word from the value and write down the condition .here is javascript how can I get this?
<?php if ( is_home() || is_front_page() ) { ?>
<?php if (get_option('my_main_scripts') == "javascript library"): ?>
<link rel="stylesheet" href="<?php bloginfo("template_url"); ?>/css/javadoc.css" type="text/css" media="screen" />
<link rel="stylesheet" href="<?php bloginfo("template_url"); ?>/js/javadoc.dojo.css" type="text/css" media="screen" />
<link rel="stylesheet" href="<?php bloginfo("template_url"); ?>/js/javadoc.yui.css" type="text/css" media="screen" />
<link rel="stylesheet" href="<?php bloginfo("template_url"); ?>/js/javadoc.jquery.css" type="text/css" media="screen" />
<?php get_template_part('documation'); ?>
<?php endif; ?>
<?php } ?>
Use strpos.
if(strpos(get_option('my_main_scripts'),'javascript') !== false )
Also have a look at preg_match.
if(preg_match('/javascript/',get_option('my_main_scripts')))
Related
I am trying to change the default style based on title of the page.I found that as the easiest way to accomplish needs.
I load the default styling option in header.php file:
<link rel="stylesheet" data-them="" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="all" />
I suppose <?php bloginfo('stylesheet_url'); ?> loads style.css which is on same path as header.php
I commented out this the line <link rel="stylesheet" data-them="" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="all" /> and tried to check title with php, based on that condition I wanted to load different style.css file.
<?php
$title = get_the_title();
if($title === "Title1"){
?><link rel="stylesheet" data-them="" href="style.css" type="text/css" media="all" /><?php
}
elseif($title === "Title2"){
?><link rel="stylesheet" data-them="" href="style2.css" type="text/css" media="all" /><?php
}
else{
?><link rel="stylesheet" data-them="" href="style3.css" type="text/css" media="all" /><?php
}
?>
This code does not work for me and not sure why.. Styling is messed up
Please find below style in your theme. Mostly enqueue in functions.php file.
EX:
wp_enqueue_style( 'twentynineteen-style', get_stylesheet_uri(), array(),
wp_get_theme()->get( 'Version' ) );
Please add below line after your theme's default style.
(get_stylesheet_uri())
wp_dequeue_style('twentynineteen-style');
After that check it your issue.
Please dequeue default style using below function.
wp_dequeue_style('default-style');
<?php if($_COOKIE['lang'] != 'en') echo '<link rel="stylesheet" href="css/'.$_COOKIE['lang'].'.css"/>'; ?>
With this above script you get the stylesheet for the language that is selected.
Like if you select France you get the stylesheet fr.css
But now I want the same for IE so I thought something like this.
<?php if($_COOKIE['lang'] != 'en') echo '<link rel="stylesheet" href="css/'.$_COOKIE['lang'].'ie.css"/>'; ?>
So now when you click on France it also opens frie.css
But what do I write in here to make it only for IE
<!--[if IE]><style>#import url('/css/ie.css');</style><![endif]-->
Thanks!
<?php
if($_COOKIE['lang'] != 'en'){
printf('<!--[if IE]><style>#import url(\'/css/%sie.css\');</style><![endif]-->', $_COOKIE['lang']);
}
?>
This is what you need to write. You can also check in PHP headers if browser is Internet Explorer.
You can use $_SERVER['HTTP_USER_AGENT'] or get_browser() function to check it in PHP.
You can use this :
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="all-ie-only.css" />
<![endif]-->
You can refer to below line :
https://css-tricks.com/how-to-create-an-ie-only-stylesheet/
I have developed a PHP application and I am using ajax in it. I have a strange issue that when I use a code in another file it runs nice but when the code runs, some html tag is produced and in one location some empty string is generated. I don't know why this empty text is echo-ed between the tags.
url of pic: picture of issue
this is my code inside the ajax file:
<script language="javascript" src="<?php echo $baseurl; ?>js/app.js"></script>
<link rel="stylesheet" href="<?php echo $baseurl; ?>css/style.css">
<link rel="stylesheet" href="<?php echo $baseurl; ?>css/grid.css">
<link rel="stylesheet" href="<?php echo $baseurl; ?>css/layout.css">
<link rel="stylesheet" href="<?php echo $baseurl; ?>css/elements.css">
<link rel="stylesheet" href="<?php echo $baseurl; ?>css/forms.css">
<link rel="stylesheet" href="<?php echo $baseurl; ?>css/typographics.css">
<link rel="stylesheet" href="<?php echo $baseurl; ?>css/ie-fixes.css">
<?php //دریافت درخواست های کوئری استرینگ
if(!empty($_GET['mBLID'])) $mBLID = $_GET['mBLID'];
if(!empty($_GET['ctID'])) $ctID = $_GET['ctID'];
if(!empty($_GET['crID'])) $crID=$_GET['crID'];
if(!empty($_GET['loadingID'])) $loadingID = $_GET['loadingID'];
if(!empty($_GET['borderTitle'])) $borderTitle=$_GET['borderTitle'];
if(!empty($_GET['value'])) $receivedValue = $_GET['value'];
...?>
I totally go crazy for this problem because it creates an empty space between the input and makes it ugly
You should not end a PHP file with ?>. The following newline (as added by editors) is then "printed" to the client
Just remove the closing ?>, and PHP will end processing the file automatically.
Also see here: Why would one omit the close tag?
i am using transposh to translate my website from English to Arabic but when i switch language to Arabic it switches the style.css and it reverse the layout of my website leading to a mess, so i made a new style.css which works with the Arabic version very well but now i don't know how to link them together i mean i want to know how to make it switch the css file when it switches the language.
i tried this code but it didn't work
<?php if(MY_CUR_LANG == 'en'){?>
<link rel="stylesheet" href="http://localhost/wordpress/wp-content/themes/style.css" type="text/css" media="screen" />
<?php }elseif(MY_CUR_LANG == 'ar'){?>
<link rel="stylesheet" href="http://localhost/wordpress/wp-content/themes/arabic.css" type="text/css" media="screen" />
<?php } ?>
You cannot jump in and out php code. Try
<?php
if(MY_CUR_LANG == 'en'){
echo'<link rel="stylesheet" href="http://localhost/wordpress/wp-content/themes/style.css" type="text/css" media="screen" />';
}elseif(MY_CUR_LANG == 'ar'){
echo'<link rel="stylesheet" href="http://localhost/wordpress/wp-content/themes/arabic.css" type="text/css" media="screen" />';
}
?>
I have script which uses absolute addressing in most areas, now I need to change them to relative addressing. But then the issue I am facing here is that, if for instance I have a website named www.example.com Now I want to change the links in php from
<link href="<?php print $theme; ?>style.css" type="text/css" rel="stylesheet" />
<link href="<?php print $theme; ?>css/colorpicker.css" type="text/css" rel="stylesheet" />
to
<link href="http://www.example.com/<?php print $theme; ?>style.css" type="text/css" rel="stylesheet" />
<link href="http://www.example.com/<?php print $theme; ?>css/colorpicker.css" type="text/css" rel="stylesheet" />
But I end up getting this result
<link href="http://www.example.com/http://www.example.com/themes/in/style.css" type="text/css" rel="stylesheet" />
<link href="http://www.example.com/http://www.example.com/themes/in/css/colorpicker.css" type="text/css" rel="stylesheet" />
I know something is wrong somewhere, but I still can't get it to work.. Any help with correct formatting will be highly appreciated. Sorry if my title for question is inappropriate.
Judging by the url setup:
<?php
$path = explode('/', $theme);
$theme = end($path);
?>
<link href="http://www.example.com/themes/<?= $theme ?>/style.css" type="text/css" rel="stylesheet" />
This will split the url in pieces and picks the last item which is I think is the theme name you want.
Your $theme contains this url 'http://www.example.com/themes/in/'. So if you just want the url to be like this
http://www.example.com/style.css instead of
http://www.example.com/http://www.example.com/themes/in/style.css
then remove the $theme from the href section.
hope this helps
Their would be two possible solutions, either you remove the
http://www.example.com/
from starting of <?php print $theme; ?> OR only include
theme name rather than with base bath.