Is there a way to access SCSS files from the Wordpress Theme editor UI? I have tried moving it to the root, next to my style.css and also leaving it in the SASS folder.
I am building a custom theme and already had SASS running on it locally and am now going to continue development in Wordpress.
You have to add the file extension before it will show up in the editor. You can do this with the wp_theme_editor_filetypes filter.
For example:
add_filter('wp_theme_editor_filetypes', function ($types) {
$types[] = 'scss';
return $types;
});
Related
I'm trying to make changes to a WordPress theme via FTP, and it doesn't appear to update on the live website.
In this case I made changes to a JavaScript file:
../wp-content/themes/Divi/includes/builder/scripts/frontend-builder-global-functions.js
Currently a child version of the theme is active on the site. Is there a process I'm missing to have my live website reflect the changes? Also, in Chrome developer tools, the file I tried to update has ?ver=3.17.6 at the end of the filename.
The easiest way would be to copy the updated JavaScript file from the parent into the child theme's folder, next in your child theme functions.php file use the built in WordPress functions wp_deregister_script and wp_register_script. Your code should be like this:
function new_child_script() {
// De-register the Divi default theme script
wp_deregister_script('frontend-builder-global'); //check the name of the default script in page source
// Register the updated script from the child theme
wp_register_script('frontend-builder-global-custom-script', get_template_directory_uri() . '/js/frontend-builder-global-functions.js',
array('jquery'));
// Enqueue the script
wp_enqueue_script('frontend-builder-global-custom-script');
}
add_action('wp_enqueue_scripts', 'new_child_script');
How to create a new file in my wordpress theme without using ftp client ?
thanks !
Using touch(); PHP function, which creates a new file in the specified directory. This is how I suggest doing it (and admittedly, there are cleaner ways, but this will get the job done, quickly and effectively)…
Open header.php — then write this code in the very top of the file:
<?php touch('wp-content/themes/YOUR_THEME_DIR/FILE_NAME.php');?>
Replace YOUR_THEME_DIR with the directory in which your WordPress theme lives.
Then, replace FILE_NAME with the name of the file you want to create.
Once that’s all done, save Header.php and go to the homepage of your site.
As soon as the homepage loads, it will create that new template or theme file.
Source :
https://www.webmechanix.com/how-to-create-a-new-theme-file-in-wordpress-without-ftp-access/
You can use a plugin called WPIDE found here https://wordpress.org/plugins/wpide/
This plugin will allow you to edit and add folder and files in your project.
I have directly modified the class-wc-checkout.php file from includes folder in woocommerce plugin to add custom line item meta data. Is there any way to override the class-wc-checkout.php file from my-theme folder as we override template files in woocommerce?
I was having this same issue. I don't have a need for reviews on my site, so I copied what I wanted to remove from a file inside of the includes folder and copied it into my functions.php file like so:
// Remove reviews from WooCommerce
if (! function_exists( 'woocommerce_default_product_tabs')) {
function woocommerce_default_product_tabs($tabs = array()) {
}
}
Works for me!
Only Templates folder files can be override by coping it into your child theme.
For all other files like in includes folder files you can either edit it or use hooks and filters to do so.
I'm not too sure what you are editing for the Woocommerce plugin but yes you can override the woocommerce plugin by adding these hooks and filters to your functions.php file in your theme:
http://docs.woothemes.com/document/hooks/
Example
You need to edit file: /plugins/woocommerce/includes/shortcodes/class-wc-shortcode-products.php
Copy this file to themes/YOURTHEME/inc/class-wc-shortcode-products.php
Add to function.php:
require 'inc/class-wc-shortcode-products.php';
What seems to work for me is to put the file here:
/wp-content/themes/YOURTHEME/includes/class-wc-checkout.php
The difference between the other suggestion and mine is that I don't have the 'woocommerce' folder in the path.
Yes you should be able to do this by uploading to this folder
/wp-content/themes/YOURTHEME/woocommerce/includes/class-wc-checkout.php
A WordPress theme I am developing has an integrated custom post type called "albums" which utilizes a few custom templates (archive-albums.php, content-albums.php, etc.). What I want to do is transfer this functionality, along with the template files, into a plugin for the sake of portability.
I transferred the CPT code from the functions.php with success, but when I try to move the template files from the theme folder to the plugin folder, things fall apart. I feel like it should be simple to somehow register the templates so WordPress knows to load them.
Can my WordPress custom templates be in plugin folder or only theme folder?
Things are falling apart because when you move those files, you're violating WP's native template hierarchy. You'll need to explicitly declare the location of those files. Using the archive as an example, you could add something like this to functions.php (to tell WP to look elsewhere):
add_filter('template_include', 'include_album_template', 1);
function include_album_template($template_path) {
if(get_post_type() == 'albums') {
if(!is_single()) {
$theme_file = 'path-to-your-plugin-directory';
$template_path = $theme_file;
}
}
return $template_path;
}
Obviously you'd use your own path, and I wrote this hastily so you might want to refactor.
I have the same issue. I'm already using add_filter ('template_include', ...) problem is that I need to specify a file to return, and in this case being it,index.php. This raises an issue with the theme not running entirely as if installed via themes folder, because what I need is to have WP selecting the appropriate file to render without any conditional logic from my part. So if it is a post it will select the single.php and so on. Another problem raised with this method is that in header.php the call get_header (); ignores the local file header.php and loads the default theme installed file instead.
I'm using wordpress 3.3.1 and it seems that jquery is there by default, all i need to do is to enqueue the file through wp_enqueue_script function. What if i want to put this function inside another plugin that is already installed. For example, i'm using jwplayer plugin for wordpress now if i want the jwplayer plugin to enqueue the jquery file for me where do i tell it to do this, the main plugin file for jwplayer is named as jwplayermodule.php and it's at the root of the jwplayer plugin directory.
Regards
You enqueue jquery like so:
// Function to perform any things that need to be done BEFORE the header is called
function my_wp_init() {
wp_enqueue_script('jquery');
}
// Enable the widgets, prepare the function for the head call, etc.
add_action('init', 'my_wp_init');
The best place to do this would be in your theme's functions.php file. This way, jQuery is always loaded in your theme.
ALTERNATIVELY, you can drop the same code into the plugin php file you mentioned - jwplayermodule.php