wp_enqueue_style Does Not Behave As Documented - html

I have the following written in a driver:
add_action( 'wp_enqueue_scripts', 'add_css_file' );
function add_css_file()
{
// Tried this prior:
// $path = ABSPATH . "/wp-content/plugins/this_plugin/css/";
// wp_register_style( 'css_file', $path.'css_file.css' );
wp_register_style( 'css_file', 'http://subdomain.mysite.com/wp-content/plugins/this_plugin/css/css_file.css' );
wp_enqueue_style( 'css_file' );
}
The string "css_file" does not appear in the View Source HTML and the CSS rules defined therein do not take effect.

Have you included wp_head() in the <head> of your page? wp_head() will add your queued styles and scripts to the page.

The problem for me lay in the fact that I am modifying the Admin screen rather than the display of a Page or Post to viewers.
Replace:
wp_enqueue_script(...)
With:
admin_enqueue_script(...)
Best of luck.

I have just tried this snippet in my site, and it is working properly. You may get conflict with some other plugin/code.
Also make sure you don't have any Cache enabled, and if so, try to clean up the cache. Also try to clean out your browser cache.
Finally, if non of the above works for you, try to de-activate your plugins, one by one in order to see if some of the plugins conflicts with this function, and in last step try to change theme, also to make sure the current theme doesn't conflict with this function.

Related

wordpress - site not update after update style.css

When I updated the style.css in Appearance > Theme Editor > stylesheet(style.css),
I refresh my site, then I see that the style is not applied.
I've also tried clear cache in browser and use cmd + shift + r to re-download the resources but still not working.
Is there any way to make the site live for development, or is there any preferred way for development?
In style.css
...
/*
Author: xxx Limited
Description: This is the template for xxx
Version: 1.0.0. // tried to update the version here but not working
...
*/
.....
Need to check few things.
upload style.css through ftp or cpanel again to check whether it is properly saved or not,
Remove cache , check in private window to make sure that there is no cache.
check in console for error if above 2 doesn't work.
If the CSS file has been updated, the problem is because of caching. There are different levels of cache.
Clear Cloudflare cache if you are using it.
Clear any caching mechanism that your Webhosting offered.
Clear all plugins cache
Salman and PHP Geek are right, do the steps they mention that should solve your problem. If the problem continues then...
In function.php find wp_enqueue_style function it would look something like this. There can be multiples of them so look for the 'style.css' inside them
wp_enqueue_style('yourtheme-style', get_template_directory_uri() . '/style.css', '', '1.1.0');
see the last argument '1.1.0' this could be anything on your case, this can also be a variable. Change this to something else like '1.1.1' (anything other then 1.1.0)
OR
replace the line with the below code (doing this will change your version automatically whenever you change something in the style.css)
$ver = filemtime(get_template_directory().'/style.css');
wp_enqueue_style('yourtheme-style', get_template_directory_uri() . '/style.css', '', $ver);

I am enqueuing stylesheet main while my images are not showing

I am converting HTML to Wordpress theme. I am enqueuing stylesheet. but some of the images are not showing.
Maybe its could be subfolder issue
It is almost certainly a pathing issue -- without being able to see any of your file structure or code, I suspect get_template_directory_uri() is the missing piece. Here's a simplified example of what you need to do.
function itc_wp_enqueue_scripts() {
wp_enqueue_style('bootstrap-style', get_template_directory_uri() . '/css/bootstrap.min.css');
}
add_action('wp_enqueue_scripts', 'itc_wp_enqueue_scripts');
You should replace itc_ with your own prefix on the function name.

HTML anchors not working on server

My links to anchors aren´t working and I don´t know why. I guess it is something about the server where I have my site uploaded.
I tested my page on a free server and localhost and there are no troubles, it only happens on the server. Any idea why this might be happening?
The sidebar at the right contains the links that get you to spots on the same page, just works once, but when the page finish loading, doesn't work anymore
This is the page:
http://www.fumigacionesmillenium.com.ve/
I am inspecting the source and JS console, there seems to be lots of JS errors after I click the link on the right. Attaching a screenshot:
i think meta tag is not closing proper.Please check below image
I installed a plugin called Slideshow, i´m using Wordpress, the reason of the error:
TypeError: jQuery.easing[jQuery.easing.def] is not a function
It was a conflict between the Jquery that loads the plugin and the Jquery that loads from functions.php, solved it this way:
code before:
if( !is_admin()){
wp_deregister_script('jquery');
wp_enqueue_script( 'material-jquery', 'http://code.jquery.com/jquery-2.1.3.min.js', array(), '1.0', false );
}
code after:
if( !is_admin()){
wp_deregister_script('jquery');
wp_register_script('jquery', ("http://code.jquery.com/jquery-2.1.3.min.js"), false, '2.1.3');
wp_enqueue_script( 'jquery');
}
Now i can use the plugin without problems, and my anchors are working perfectly.

Using dependencies in wp_register_style() for wordpress

I am trying to get a custom css file to load after the plugin stylesheets. I was thinking I could use the $deps parameter of wp_register_style(), but the css file does not load at all when I add the array(). This happens no matter what is included in the $deps array(), ie (array('style')
, array('style.css')).
Is there an issue with the call, or a better way of doing this?
In my functions.php
// Load custom css
add_action('wp_enqueue_scripts', 'prefix_add_my_stylesheet');
function prefix_add_my_stylesheet() {
wp_register_style( 'custom-supersized-styles', get_template_directory_uri(). '/css/custom-supersized-styles.css', array('style','supersized');
wp_enqueue_style( 'custom-supersized-styles' );
}
If you're using the WP Supersized plugin try registering your function like so:
// Load custom css
add_action('wp_enqueue_scripts', 'prefix_add_my_stylesheet', 999);
The dependencies array (the parameter you're attempting to use to add supersized with) depends on supersized having already been registered by WordPress. If you set the priority of your own prefix_add_my_stylesheet to a higher number, it should then load after the plugin has registered and loaded its CSS (and thus will be available).
In addition, you can remove the style as a dependency. (style is never registered by WordPress as a dependency handler, and your enqueued scripts / css should be loading after style.css loads anyway).
Hope that helps!

remove duplicate login link in MediaWiki using Shibboleth plugin

I've added shibboleth authentication (ShibAuthPlugin 1.2.3) to a MediaWiki site (mw 1.17). That turned out to be pretty straightforward, but I now have another related problem: I have two login links. I want only the Shibboleth login link to be available.
I can alter the CSS to hide the unwanted link, but that only makes it invisible. I want to disable it. The documented ways of disabling login links disables all login links. I'm new to MediaWiki and would expect to be able to make this change in the configuration and not have to hack the code to get what I want.
Perhaps someone familiar with MediaWiki can tell me if such a configuration setting exists, or if code modification is the best practice for solving this kind of problem.
Thank you in advance,
Peter
To just remove the login link, I suspect this FAQ entry may help; it seems to be more or less how the Shibboleth auth extension does its own login/logout link mangling. For convenience, let me copy the code here:
$wgHooks['PersonalUrls'][] = 'lfRemoveLoginLink';
function lfRemoveLoginLink( &$personal_urls, $title ) {
unset( $personal_urls['login'] );
unset( $personal_urls['anonlogin'] );
unset( $personal_urls['createaccount'] );
return true;
}
If you want to completely disable local login/logout, even if the user deliberately goes to Special:UserLogin, this solution might do the trick. Again, let me copy the relevant part of the code below:
function LessSpecialPages(&$list) {
unset( $list['Userlogout'] );
unset( $list['Userlogin'] );
return true;
}
$wgHooks['SpecialPage_initList'][]='LessSpecialPages';