Insert a CSS depends order total Woocommerce - woocommerce

I try to insert a CSS change depends cart total on woocommerce. For this I create a simple plugin that be used to on functions.php. But on this moment anything is not working. If anyone can share a solution based on this:
function billing_mp_installments( $cart_object ) {
if ( ! defined( 'DOING_AJAX' ) ) return;
if (WC()->cart->total >= 5000){
echo '<style type="text/css">
#mp-installments option:nth-child(3,6,12) {display: none; }
#mp-installments option[value="3"] {display:none !important;}
#mp-installments option[value="6"] {display:none !important;}
#mp-installments option[value="12"] {display:none !important;}
<style>';
} else if (WC()->cart->total >= 10000){
echo '<style type="text/css">
#mp-installments option:nth-child(3,6,12) {display: none; }
#mp-installments option[value="3"] {display:none !important;}
#mp-installments option[value="6"] {display:none !important;}
#mp-installments option[value="12"] {display:none !important;}
<style>';
} else if (WC()->cart->total > 15000){
echo '<style type="text/css">
#mp-installments option:nth-child(3,6,12) {display: none; }
#mp-installments option[value="3"] {display:none !important;}
#mp-installments option[value="6"] {display:none !important;}
#mp-installments option[value="12"] {display:none !important;}
<style>';
}
}
add_action( 'woocommerce_checkout_order_review', 'billing_mp_installments', 20,1 );

Related

how to show continue reading on excerpt in wordpress theme?

On main blog page all excerpt is showing but there is no continue reading and Have coded very well?
on the content.php I have the code
<div class="post-excerpt">
<?php the_excerpt(); ?>
</div><!-- post-excerpt -->
On function.php I have place this code and the moretag class is not present in my style.css file and not in bootstrap is this is the reason.
/**
* Replaces the excerpt "more" text by a link.
*/
function new_excerpt_more($more) {
global $post;
return '... <a class="moretag" href="'. get_permalink($post->ID) . '"> continue reading »</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
I expect output on the main blog page every excerpt should have continue reading link and should clickable and show full post.
after 4 hour of struggle I have found answer to my question yahoooo!!
on content.php place this.
<div class="post-excerpt">
<?php the_excerpt(); ?>
<?php if (!is_home()): ?>
<div class="continue-reading">
<a href="<?php echo esc_url( get_permalink() ); ?>" rel="bookmark">
<?php
printf(
/* Translators: %s = Name of the current post. */
wp_kses( __( 'Continue reading', 'mano-theme' ), array( 'span' => array( 'class' => array() ) ) ),
the_title( '<span class="screen-reader-text">"', '"</span>', false )
);
?>
</a>
</div>
</div><!-- post-excerpt -->
<?php endif ?>
on function.php place this code.
/**
* Customize the excerpt read-more indicator
*/
function new_excerpt_more( $more ) {
return " …";
}
add_filter( 'excerpt_more', 'new_excerpt_more' );
On style.css paste this code
.continue-reading {
text-align: center;
}
.continue-reading a,
.entry-content .continue-reading a {
display: inline-block;
margin: 1em auto;
padding: 1em 2em;
font-family: "Fira Sans", sans-serif;
text-decoration: none;
border: 1px solid #c3c3c3;
}
.continue-reading a:hover,
.continue-reading a:focus,
.entry-content .continue-reading a:hover,
.entry-content .continue-reading a:focus {
border-color: #000;
border-width: 1px;
box-shadow: none;
}
.continue-reading a::after {
content: "…"
}
.continue-reading::after {
display: block;
content: "";
width: 7em;
border-bottom: 1px solid #c3c3c3;
margin: 4em auto 0;
}
.entry-content .continue-reading::after {
display: none;
}
OUTPUT:

Show images from folder php (horizontal)

I have this code to show my images from a folder, but the problem is that it shows the images vertically (there are 9000 images) so the scrolling is ending.
I would like to know if it's possible to make the images horizontally?
The code I use:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html">
<title>Show images in folder</title>
<style type="text/css">
body {
margin: 0 auto 20px;
padding: 0;
background: #acacac;
text-align: center;
}
td {
padding: 0 0 50px;
text-align: center;
font: 9px sans-serif;
}
table {
width: 100%;
}
img {
display: block;
margin: 20px auto 10px;
max-width: 900px;
outline: none;
}
img:active {
max-width: 100%;
}
a:focus {
outline: none;
}
</style>
</head>
<body>
<?php
$folder = 'album1584/';
$filetype = '*.*';
$files = glob($folder.$filetype);
$count = count($files);
$sortedArray = array();
for ($i=0; $i<count($files); $i++) {
$sortedArray[date ('YmdHis', filemtime($files[$i]))] = $files[$i];
}
krsort($sortedArray);
echo '<table>';
foreach ($sortedArray as &$filename) {
#echo '<br>' . $filename;
echo '<tr><td>';
echo '<a name="'.$filename.'" href="#'.$filename.'"><img src="'.$filename.'" /></a>';
echo substr($filename,strlen($folder),strpos($filename, '.')-strlen($folder));
echo '</td></tr>';
}
echo '</table>';
?>
</body>
</html>
Images are listed vertically because they are contained in individual rows of the table. Also, in your CSS you set them to display as a block.
Remove display: block for images and don't put them in a table.
Also, don't display 9000 images at once. Use pagination.
try changing display: block; to display: inline-block; by styles for img tag.
EDIT:
Ok i think I know where the problem may be. You put each image in a separate table row so try to put more in one row or do not use table for that but simple container with the css change I gave you.

wordpress navigation bar in mobile view

I`m using a bootstrap theme for my wordpress site. Here is the navigation bar code from header.php.
<?php
// Collapsed navbar menu toggle
global $xsbf_theme_options;
$navbar = '<div class="navbar '.$xsbf_theme_options['navbar_classes'] . '">'
.'<div class="container">'
.'<div class="navbar-header">'
.'<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">'
.'<span class="icon-bar"></span>'
.'<span class="icon-bar"></span>'
.'<span class="icon-bar"></span>'
.'</button>';
// Site title (Bootstrap "brand") in navbar. Hidden by default. Customizer will
// display it if user turns of the main site title and tagline.
$navbar .= '<a class="navbar-brand" href="'
.esc_url( home_url( '/' ) )
.'" rel="home">'
.get_bloginfo( 'name' )
.'</a>';
$navbar .= '</div><!-- navbar-header -->';
// Display the desktop navbar
$navbar .= wp_nav_menu(
array( 'theme_location' => 'primary',
'container_class' => 'navbar-collapse collapse', //<nav> or <div> class
'menu_class' => 'nav navbar-nav', //<ul> class
'walker' => new wp_bootstrap_navwalker(),
'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
'echo' => false
)
);
echo apply_filters( 'xsbf_navbar', $navbar );
?>
</div><!-- .container -->
</div><!-- .navbar -->
</nav><!-- #site-navigation -->
So far so good. My navigation child css:
.navbar {
margin-top: 20px;
margin-bottom: 10px;
background-color: #222;
width: 70%;
height: 40px;
border-radius: 10px;
font-family: 'PT Sans Narrow', sans-serif;
}
.navbar-nav >ul {
margin: 0 auto;
}
.navbar-brand {
display: none;
}
.navbar-default .navbar-brand {
color: #978476;
}
.navbar-default .navbar-brand:hover, .navbar-default .navbar-brand:focus {
color: #605F65;
}
.navbar-default .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:focus {
background-color: #605F65;
}
.navbar-default .navbar-nav > li > a {
background-color: #E7E4E4;
background-color: transparent;
}
My problem is that i can't change the navigation background when in mobile view. How can i do that? It remain transparent because of the:
.navbar-default .navbar-nav > li > a {
background-color: #E7E4E4;
background-color: transparent;
}
Thank you!
Write a media query which target mobile phones on bottom of css file and put background color.
Since bootstrap uses mobile first aproach, set that color as default, then for larger devices put transparent.
This is the media query I was referring to.
#media (max-width: 767px) {
.navbar {
background-color: #e7e4e4;
}
}
Make sure you call your custom styles after the Bootstrap stylesheet.

How to change the wordpress default logo from the Admin?

I want to create a custom logo so I need change the default logo of the wordpress logo.
Here is the function (inserted into functions.php) which will correctly override the admin logo:
/**
* customize the admin logo that appears in the header
* http://www.wpbeginner.com/wp-themes/adding-a-custom-dashboard-logo-in-wordpress-for- branding/
* #author Paul Bredenberg
*/
function htx_custom_logo() {
echo '
<style type="text/css">
#wp-admin-bar-wp-logo > .ab-item .ab-icon {
background-image: url(' . get_bloginfo('stylesheet_directory') . '/assets/images/dashboard-logo.png) !important;
background-position: 0 0;
}
#wpadminbar #wp-admin-bar-wp-logo.hover > .ab-item .ab-icon {
background-position: 0 0;
}
</style>
';
}
//hook into the administrative header output
add_action('admin_head', 'htx_custom_logo');
Take from Here: http://goo.gl/GuDZM6
HTH!
Here is a great plugin for this, and much more. White Label CMS
function my_login_logo() { ?>
<style type="text/css">
body.login div#login h1 a {
background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/images/site-login-logo.png);
padding-bottom: 30px;
}
</style>
Change your dashboard logo to custom logo with this code:
add_action('admin_head', 'my_custom_logo');
function my_custom_logo() {
echo '
<style type="text/css">
#header-logo { background-image: url('.get_bloginfo('template_directory').'/images/custom-logo.gif) !important; }
</style>
';
}
I did few arrangement:
- support the fullscreen mode
- use the favicon of the site so it is automatically customized for multisites, and you can put some default image if there is no favicon)
I put "width: 12px" to have a square shape for the favicon cover background
If it can help someone here is the code :
function my_custom_admin_logo() {
echo '
<style type="text/css">
#wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:before {content:none;}
#wpadminbar #wp-admin-bar-wp-logo > a {
background-image: url(' . get_site_icon_url() . ') !important;
background-size: cover !important;
}
#wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon {width: 12px;}
#media screen and (max-width:782px){ #wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon {width: 46px;} }
a.edit-post-fullscreen-mode-close.has-icon {
background-image: url(' . get_site_icon_url() . ');
background-size: cover;
}
.edit-post-fullscreen-mode-close.has-icon > svg > path { display: none;}
</style>
';
}
//hook into the administrative header output
add_action('wp_before_admin_bar_render', 'my_custom_admin_logo');
Sunny's answer only overrides the icon of the item. If you want to delete the item completely you can do this:
function htx_custom_logo() {
echo '
<style type="text/css">
#wpadminbar #wp-admin-bar-wp-logo>.ab-item {
display:none;
}
</style>
';
}
//hook into the administrative header output
add_action('admin_head', 'htx_custom_logo');

How to initialise CSS statements from the function.php file (Wordpress)?

I have the following CSS conditional statement in my function.php file:
function logo_exists() {
global $options;
?><style type="text/css">
#header h1 a {
<?php
if ( $options['logo'] == NULL ) { ?>
float: left;
text-indent: 0;
<?php } else { ?>
background: url(<?php echo $options['logo']; ?>) no-repeat scroll 0 0;
float: left;
text-indent: -9999px;
width: 160px;
height: 80px;
}
<?php } ?>
</style><?php
}
example:
(...same code as above...)
width: 160px;
height: 80px;
}
<?php } ?>
</style><?php
add_option('logo_exists');
}
I'm not sure how to "add" or "initialise" it.
I tried: add_option('logo_exists'); and add_action('logo_exists'); but it didn't work.
What's the Wordpress "add" command for conditional CSS statements in the function.php file?
Instead of using this variation, you could use wordpress conditions:
is_home() is_singular() (for page/article) is_single() is_page() ad so on.
Besides that, WP automatically add an extra class to body element and you can relate to that to build your css selectors.

Resources