I just installed Wordpress, and one thing I discovered is that site URL appears to be hardcoded in all the generated HTML.
For example, I see things like:
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="stylesheet" type="text/css" media="all" href="http://www.mywebserver.com/wp- content/themes/twentyeleven/style.css" />
<link rel="pingback" href="http://www.mywebserver.com/xmlrpc.php" />
Is there a way to tell Wordpress to strip out the domain name in the generated URLs? For example, I would prefer:
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="stylesheet" type="text/css" media="all" href="/wp-content/themes/twentyeleven/style.css" />
<link rel="pingback" href="/xmlrpc.php" />
A couple links of code can fix it, in your functions file and header file: Fix absolute links in Wordpress
Functions.php
function fix_links($input) {
return preg_replace('!http(s)?://' . $_SERVER['SERVER_NAME'] . '/!', '/', $input);
}
Header.php -- before you output any HTML
ob_start('fix_links');
Related
I have create a new laravel 9 project and I have encounter an css and js assets connection problem
At first, I have run
php artisan serve
to see if my project is working , and seems like everything is fine .
but when I just simply remove an part from the view , the css/js just get disabled to the view
even I undo the changes , the css are still not working . did any know whats happen?
here is my code for the css, and I believe it was properly connected
<head>
<meta charset="utf-8" />
<title>Admin Dashboard </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="Premium Multipurpose Admin & Dashboard Template" name="description" />
<meta content="Themesdesign" name="author" />
<!-- App favicon -->
<link rel="shortcut icon" href="{{ asset('backend/assets/images/favicon.ico')}}">
<!-- jquery.vectormap css -->
<link href="{{ asset('backend/assets/libs/admin-resources/jquery.vectormap/jquery-jvectormap-1.2.2.css')}}" rel="stylesheet" type="text/css" />
<!-- DataTables -->
<link href="{{ asset('backend/assets/libs/datatables.net-bs4/css/dataTables.bootstrap4.min.css')}}" rel="stylesheet" type="text/css" />
<!-- Responsive datatable examples -->
<link href="{{ asset('backend/assets/libs/datatables.net-responsive-bs4/css/responsive.bootstrap4.min.css')}}" rel="stylesheet" type="text/css" />
<!-- Bootstrap Css -->
<link href="{{ asset('backend/assets/css/bootstrap.min.css')}}" id="bootstrap-style" rel="stylesheet" type="text/css" />
<!-- Icons Css -->
<link href="{{ asset('backend/assets/css/icons.min.css')}}" rel="stylesheet" type="text/css" />
<!-- App Css-->
<link href="{{ asset('backend/assets/css/app.min.css')}}" id="app-style" rel="stylesheet" type="text/css" />
</head>
codes for vite.config.js
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel({
input: [
'resources/css/app.css',
'resources/js/app.js'
],
refresh: true,
}),
],
});
I have already do some research and seems like it might be related to the "vite", but It was something very strange to me . Could anyone tell me what should I do . Thank you in advance
From version 9.19.0 Laravel has drop the webpack and added the vitejs
To add css and js, you need to configure the vite
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel([
'backend/assets/libs/admin-resources/jquery.vectormap/jquery-jvectormap-1.2.2.css',
'backend/assets/libs/datatables.net-bs4/css/dataTables.bootstrap4.min.css',
'backend/assets/libs/datatables.net-responsive-bs4/css/responsive.bootstrap4.min.css',
'backend/assets/css/bootstrap.min.css',
'backend/assets/css/icons.min.css',
'backend/assets/css/app.min.css',
]),
],
});
To run the dev serve npm run dev
In blade
#vite([
'backend/assets/libs/admin-resources/jquery.vectormap/jquery-jvectormap-1.2.2.css',
'backend/assets/libs/datatables.net-bs4/css/dataTables.bootstrap4.min.css',
'backend/assets/libs/datatables.net-responsive-bs4/css/responsive.bootstrap4.min.css',
'backend/assets/css/bootstrap.min.css',
'backend/assets/css/icons.min.css',
'backend/assets/css/app.min.css',
]);
For more information laravel vite doc
I'm trying to create a website MVC with PHP and TinyButStrong. Everything works just fine except that CSS code does not work with TinyButStrong. Anyone knows the problem here?
file example.html
<head>
<link rel="stylesheet" type="text/css" href="css/style.css" media="screen" />
</head>
<body>
<p>[onshow.msg]</p>
</body>
file php
<?php
include "tbs_class.php";
$tbs = new clsTinyButStrong;
$msg = "example tbs";
$tbs->LoadTemplate("example.html");
$tbs->Show();
?>
I have a simple MVC project and I want to start design it with CSS file,
I created a Style/StyleSheet.css file with this content:
body {
background-color:green;
}
and added the link to it inside _Layout.cshtml, with this line:
<link href="#Url.Content("~/Style/StyleSheet.css")" rel="stylesheet" type="text/css" />
I don't see any change of the background color, what am I doing wrong ?
Help will be Appreciated ! Thanks !
Try basic html:
<link href="/Style/StyleSheet.css" rel="stylesheet" type="text/css" />
or change "..." inside the string to '...' :
<link href="#Url.Content('~/Style/StyleSheet.css')" rel="stylesheet" type="text/css" />
I'm using Play framework.
In a template it is possible to do the following to include css.
<link rel="stylesheet" media="screen" href="#routes.Assets.at("stylesheets/main.css")">
But what I would like to do is to include the css right into the webpage
<style>#[include the static file contents]</style>
Is that possible?
As others mentioned it is NOT preferred way, anyway you can use common 'tags' technique for doing this,
just create a file views/tags/yourStyles.scala.html with content:
<style>
* {
background: orange;
}
</style>
so in your template/view you can use it as (sample):
<head>
<title>#title</title>
<link rel="stylesheet" media="screen" href="#routes.Assets.versioned("stylesheets/main.css")">
<link rel="shortcut icon" type="image/png" href="#routes.WebJarAssets.at("images/favicon.png")">
#tags.yourStyles() <!-- <-here ->
</head>
I need to force CSS changes to go live immediately and I found that add a version to CSS would help to do that as bellow.
<link rel="stylesheet" href="css/style.css?version=123456" media="all"/>
I need to automate this as it is difficult to change the main file always when need to do small change to css file.
So I found following line of code(sample) in PHP doing the same job.
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); echo '?' . filemtime( get_stylesheet_directory() . '/style.css'); ?>" type="text/css" media="screen, projection" />
I have tried to convert this line to Smarty, but it is giving error.
code :
<link rel="stylesheet" href="css/style.css?version={#filemtime:css/style.css} />
error:
syntax error: unrecognized tag: #filemtime:...........
Anybody has an idea how to do this ?
Thanks in advance
You can add this modifier to smarty plugin folder,
function smarty_modifier_filemtime($path){
$path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
return filemtime( YOUR_HOME_DIR.$path );
}
then call it like bellow,
<link rel="stylesheet" href="/css/style.css?v={'/css/style.css'|#filemtime}" type="text/css">