I need double logo in site identity of WordPress customizer. One on mobile view and other on desktop view. Both are different images. Please provide code for adding two logos.
I have code for adding one custom logo. and I need it on site identity itself
function lotus_flies_custom_logo_setup()
{
$defaults = array(
'height' => 139,
'width' => 176,
// 'flex-height' => true,
// 'flex-width' => true,
'header-text' => array( 'site-title', 'site-description' ),
);
add_theme_support('custom-logo', $defaults);
}
add_action('after_setup_theme', 'lotus_flies_custom_logo_setup');
The best way to have different logo according to screen size is to use #media queries in CSS.
So you could just find out a css selector for your current icon, and add some css to resize it according to screen size, in your inherited custom template.
Instead of resizing, you could also just completely change the source of the image in CSS.
( As an inspiration: Swap out 3 differently-sized logos with media queries? . Documentation: Using_media_queries )
The Wordpress WooCommerce StoreFront Theme queues styles in the header from the WooCommerce StoreFront Customiser;
<style id='storefront-woocommerce-style-inline-css' type='text/css'></style>
<style id='storefront-style-inline-css' type='text/css'></style>
I seem to spend more time over-righting these styles, than defining what I want. Does anyone know how to remove them or disable the Storefront customiser?
For anyone that is fighting with this, this is the solution I found:
function my_theme_remove_storefront_standard_functionality() {
//remove customizer inline styles from parent theme as I don't need it.
set_theme_mod('storefront_styles', '');
set_theme_mod('storefront_woocommerce_styles', '');
}
add_action( 'init', 'my_theme_remove_storefront_standard_functionality' );
The two of inline CSS was added in class-storefront-customizer.php.
For deregister storefront-style-inline-css:
add_filter('storefront_customizer_css', '__return_false');
For deregister storefront-woocommerce-style-inline-css:
add_filter('storefront_customizer_woocommerce_css', '__return_false');
I had to remove these recently, and the best way to do it is using Ngoc Nguyen's method.
Just put the below code in your functions.php
function wpcustom_deregister_scripts_and_styles(){
wp_deregister_style('storefront-woocommerce-style');
wp_deregister_style('storefront-style');
}
add_action( 'wp_print_styles', 'wpcustom_deregister_scripts_and_styles', 100 );
Is this working in Storefront 2.0.4?
Because i have these filters:
add_filter( 'storefront_customizer_enabled', '__return_false' );
add_filter( 'storefront_customizer_css', '__return_false' );
add_filter( 'storefront_customizer_woocommerce_css', '__return_false' );
but i have still inline css.
The first filter was mentioned in topic:
https://wordpress.org/support/topic/remove-inline-css-1?replies=8
Try this:
add_filter( 'storefront_customizer_enabled', 'woa_storefront_disable_customizer' );
function woa_storefront_disable_customizer() {
return false;
}
https://github.com/FrancySanchez/storefront-child/blob/master/functions.php
I had been having this problem and though my solution is quite specific to my own application, you may find use in it.
My problem was that I wanted white menu text with a hover color of a light grey. By default the inline css that you have a problem with seemed to take your menu text color, lighten it by a factor and set that color as the hover color. Obviously white cannot be lightened so my menu simply stayed the same on hover. Here is how I solved this:
In the file "class-storefront-customizer.php" located at wp-content/themes/storefront_child/inc/customizer there are functions defined on how the theme editor interface works. Firstly I took the following function:
public static function get_storefront_default_setting_values() {
return apply_filters( 'storefront_setting_default_values', $args = array(
'storefront_heading_color' => '#333333',
'storefront_text_color' => '#6d6d6d',
'storefront_accent_color' => '#aeaeae',
'storefront_header_background_color' => '#ffffff',
'storefront_header_text_color' => '#6d6d6d',
'storefront_header_link_color' => '#333333',
'storefront_footer_background_color' => '#f0f0f0',
'storefront_footer_heading_color' => '#333333',
'storefront_footer_text_color' => '#6d6d6d',
'storefront_footer_link_color' => '#333333',
'storefront_button_background_color' => '#eeeeee',
'storefront_button_text_color' => '#333333',
'storefront_button_alt_background_color' => '#333333',
'storefront_button_alt_text_color' => '#ffffff',
'storefront_layout' => 'right',
'background_color' => 'ffffff',
) );
}
And I set the storefront_accent_color var as the offset color I wanted, in my case #aeaeae. This set the default color to that value for the editor. This step is not necessary but does make it easier.
I also set this option to the same value as I was not sure which would really take effect...
$wp_customize->add_setting( 'storefront_accent_color', array(
'default' => apply_filters( 'storefront_default_accent_color', '#aeaeae' ),
'sanitize_callback' => 'sanitize_hex_color',
) );
On line 501 of this file is the definition of the function get_css() which sets up the inline css you see that you are trying to get rid of. For me, the value I needed to change was in this section:
.main-navigation ul li a:hover,
.main-navigation ul li:hover > a,
.site-title a:hover,
a.cart-contents:hover,
.site-header-cart .widget_shopping_cart a:hover,
.site-header-cart:hover > li > a,
.site-header ul.menu li.current-menu-item > a {
color: ' . storefront_adjust_color_brightness( $storefront_theme_mods['header_link_color'], 80 ) . ';
}
I changed the value of this css attribute to:
color: ' . $storefront_theme_mods['accent_color'] . ';
This did not change the set color of my offset on hover. What it did do however was change the editor.
So the final step is to go into the editor, go to the typography tab, select accent color, hit the default color button (which should now come up as my color) and then SAVE that. My menu worked fine after that.
This was a bit long and not quite what you were asking for, but I put it all in to illustrate how you can manipulate the values that are output into that inline css. Hopefully that info has helped you.
In case anyone else stumbles on this question here's how I managed to solve it:
Create a child theme from the parent storefront theme. (refer to this link to find out how to do that: https://developer.wordpress.org/themes/advanced-topics/child-themes/)
In the child theme's functions.php file put the following code:
remove_action( 'wp_enqueue_scripts', array( $storefront->customizer, 'add_customizer_css' ), 130 );
It basically grabs the function "add_customizer.css" from the class Storefront_Customizer, which adds the inline css, and removes that hooked function from the 'wp_enqueue_scripts'.
In the storefront theme's functions.php file there's the following code:
$storefront = (object) array(
'version' => $storefront_version,
/**
* Initialize all the things.
*/
'main' => require 'inc/class-storefront.php',
'customizer' => require 'inc/customizer/class-storefront-customizer.php',
);
What it does is it stores the class Storefront_Customizer from file 'class-storefront-customizer.php' in $storefront array and then converts the array into an object.
By creating a child theme you'll be able to update your parent storefront theme and the changes won't be lost.
after several trials I got a final solution to solve the problem!
It's to simple to believe :-)
Remove the following line in "class-storefront-customizer.php" and it works:
add_action( 'wp_enqueue_scripts',array( $this, 'add_customizer_css' ), 130 );
Regards
Herbert
For some reason I just can't get the styling to change on the class="widgettile". I don't get it ... please visit my site on look at sidebar http://www.curious-howto.com, we scroll down towards the bottom and see the 2 widget on the right side. The title is wrapped in
<class="widgettitle">This is title</class="widgettitle">
but when I add to my style sheet .widgettile {font-family:Lobster;} ... it doesnt style the class ... I usually don't have any problems styling things ... I just don't understand why this doesnt work ...
Please any advise would be much appreciated
You do not have the class assaigned to anything. This is your html <class="widgettitle">Most Viewed Posts In The Last 30 Days </class="widgettitle">
You need to add the class to a tag like so <h3 class="widgetittle">Title</h3> '' is invalid and does not exist.
I see you are usng wordpress so more than likely it is a problem with the function.
function widgets_init() {
register_sidebar( array(
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
Make sure the function is used properly. The code above will add an h3 around the widget title with a class of widget-title.
I just used mPDF on my project and now stuck on this problem. First let me describe my PDF structure:
First page is a cover page.
Second page is Table Of Content page.
Third page is content page.
So the problem is :
There is header,footer,page number in cover page and TOC page. How do I remove that?
The content page number start with no 3. How do I reset it to become no 1?
Below is the code is used to include header and footer
$mpdf->SetHeader('{DATE j-m-Y}|{PAGENO}/2|My document');
$mpdf->SetFooter('{PAGENO}'); /* defines footer for Odd and Even Pages - placed at Outer margin */
$mpdf->SetFooter(array(
'L' => array(
'content' => 'Text to go on the left',
'font-family' => 'sans-serif',
'font-style' => 'B', /* blank, B, I, or BI */
'font-size' => '10', /* in pts */
),
'C' => array(
'content' => '- {PAGENO} -',
'font-family' => 'serif',
'font-style' => 'BI',
'font-size' => '18', /* gives default */
),
'R' => array(
'content' => 'Printed # {DATE j-m-Y H:m}',
'font-family' => 'monospace',
'font-style' => '',
'font-size' => '10',
),
'line' => 1, /* 1 to include line below header/above footer */
), 'E' /* defines footer for Even Pages */
);
And for TOC page, I add this tag in the html
<tocpagebreak />
You can setup your footer to be invisible at first, and then reset it when you want the numbering to start.
For example (using html tags):
<!-- sets up the footer -->
<pagefooter name="footer" content-center="{PAGENO}"></pagefooter>
<!-- disables it -->
<setpagefooter value="off"></setpagefooter>
<p>Some content for the first pages</p>
<!-- activates the footer and resets the numbering -->
<pagebreak odd-footer-name="footer" odd-footer-value="on" resetpagenum="1"></pagebreak>
I'm pretty sure the same can be achieved using the equivalent mpdf methods.
I am having problems having my CSS applied when a menu item links to a specific record.
Take the simple menu below, the CSS as defined in Menu works just fine for 'Account' but when I click on 'My Account' it doesn't.
<div id="Menu">
<?php $this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('label'=>'Account', 'url'=>array('/account/view'),
// CSS works fine
array('label'=>'My Account', 'url'=>array('/account/view/id/'.Yii::app()->user->id),
// CSS applied to active link does not work
),
));
?>
</div>
CSS
#Menu ul li.active a {
color: #CCC;
text-decoration:none;
}
Any ideas???
Thanks
<div id="Menu">
<?php $this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('label'=>'Account', 'url'=>array('/account/view'),
// CSS works fine
array(
'label'=>'My Account',
'url'=>array('/account/view/id/'.Yii::app()->user->id),
'active'=>($this->getId() == 'account' && $this->getAction()->getId() == 'view' && isset($_GET['id'])))
// you have to set manually the rule for "active"
),
));
?>
</div>
Also you should correct your Url rules so you can create URLs properly like this:
'url'=>array('account/view', 'id'=>Yii::app()->user->id)
To obtain the correct url from this you should create URL rule in config file like this:
'rules'=>array(
....
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
....
),