I use WordPress with the plugin "UserWP" to create a member area for logged in users. Everything is working and looking great but when i check the code i can see that on my pages (fronted) its loading tons of js and css that is used for the WordPress backend.
Example:
/wp-includes/js/media-views.min.js?ver=6.0.1
/wp-includes/js/dist/hooks.min.js?ver=c6d64f2cb8f5c6bb49caca37f8828ce3
And tons of other small scripts.
Is it possible to disable this for the pages i created and i use my frontend-template?
CSS & JS files from /wp-includes/ directory shouldn't be removed.
However, you can remove plugins and theme useless files using wp_dequeue_style or wp_dequeue_script functions.
These functions should be called inside your custom function and that custom plugin should be hooked with wp_enqueue_scripts action.
Related
Im using the WordPress Multisite MU-Plugins directory to run some custom functions which i need to be
available to ALL subsites in my network. When i run the function in the primary sites' functions.php
file it runs as expected but it obviously cannot access any subsites.
Is the problem with the loading order that WP utilises - i read here the order is:
the WordPress core code
mu-plugins
plugins
functions.php
the theme code for the specific template being displayed
I believe the issue may be that im trying to call wp funcs that are not yet loaded yet. Is there a way to defer the loading of 'Must-Use' -plugins until, say when functions.php runs??
You can't defer the load, no, but you can move the code in the mu-plugin that requires on other things to be loaded into action hooks for actions that are triggered later in the load order:
hook plugins_loaded to run code after all plugins have loaded
hook after_setup_theme to run code after the theme has loaded
(I guess that's what you mean by 'functions.php' ?)
However I think all of WordPress's own functions are loaded before mu-plugins are loaded, so this may not be your problem.
I have a custom PHP file on which I want to use some WordPress functions such as wp_get_current_user(). I've tried requiring wp-load.php, but that increases the load time significantly as it loads all WP functions.
Is there anyway I can use only the functions I need from WP?
Thanks, Emir
You can create page template or plugin then you able to access wp_get_currunt_user() function in you template file or plugin file
I have problem with running javascript codes in may pages.
I tried testing my code in xampp and it was working.
but I can not see them when I add them to my pages or my posts in my host and I installed wordpress again and it wasn't working.
Please help me
There are a few ways you can include JavaScript files in WordPress, I will give you one example using your child theme.
First you need to validate whether or not you actually have a child theme. Use FTP to login to you server and go to the wp-contents/themes directory. There you will see all your installed themes (in your case betheme). If you do not have a child theme follow these steps:
Create a new directory in your themes folder (betheme-child).
Upload your JavaScript file in this directory (for example script.js)
Create a new file called functions.php and add the following code to it: (surrounded by php opening and closing tags):
add_action('wp_enqueue_scripts', 'enqueue_child_scripts');
function enqueue_child_scripts() {
wp_enqueue_script('child-script', get_template_directory_uri() . '/script.js');
}
Login to your wp-admin and navigate to your themes
Enable your child theme instead of your normal theme.
Go to the front-page of your website, look at the page source and check if your JavaScript file is being loaded.
If you are using cloudflare, turn off minify JS.
I am working on a new project on WordPress.
I am developing a new website for a client based on their actual site (developed by an other team).
So, I decided to create a new WordPress theme and to use the existing content (client's request).
However, this supposes to reuse the custom plugins, in order to not re upload the pictures and the articles by hand.
I would like to include the custom plugins into the new theme. However, the plugins folder is outside the theme folder. So I was wondering if you have an idea on how I could transfer the code of a custom plugin into the new theme.
Thank you in advance.
What custom plugins are being used to handle pictures and articles? Uploaded files should go to /wp-content/uploads and all data is stored in the database. Removing the plugins might make the data inaccessible, but it shouldn't disappear.
Why are you moving functions from plugins to a theme? Or are these plugins inside of the /wp-content/themes/ folder? The way you handle the two cases is very different.
If you need to copy certain functions into a theme, you can move them into a functions.php file (or a functions.php file that calls to other files in that directory) in a child theme. The WordPress Codex has much better documentation on child themes than I could ever outline here. Placing the functions into your main theme is a permanent change and is not recommended when you're dealing with functions that are better-suited to plugins.
If you're copying plugins from one theme into another, you might want to look at plugin dependencies using TGM Plugin Activation.
I have an existing webapp created in PHP and would like to embed some of the PHP code into some WordPress pages.
What's the best WordPress plugin for that?
Pasting PHP code into a plugin isn't a good idea. There are three approaches to embedding PHP scripts into a WordPress site:
Placing the code directly into a
theme's main index template (messy)
Placing the code into a theme's
functions.php file and hooking it into
the site using the Plugin API.
(cleaner)
Fully encapsulating the code in a
plugin. (cleanest)
A lot of folks use EXEC-PHP. The Exec-PHP plugin executes code in your posts, pages and text widgets. One drawback may be that you will have to disable the WYSIWYG Editor but most people do that anyway.