WordPress child theme for admin only (development) - php

I'd like to restrict a child theme to only being visible to me, the admin, for development purposes. Then I can make changes, upload and view them live and on the site without other people seeing those unfinished changes. Once I'm done, I take the affected files and move them to the Parent Theme's folder to make the changes visible to everyone.
Is this possible with some kind of script through functions.php?
And I'm not just talking about enqueuing the style.css file, I'm talking about setting up a complete child theme with sidebar.php, header.php etc. and only have the child theme files being loaded for me, the admin, for development purposes. Perhaps a way to define the child theme directory, embedded inside a condition that checks whether the user is admin.
Thank you :)

There is a plugin that does what you are looking for called Theme Test Drive. I haven't used it before but I think it uses some filters to update the theme at runtime for logged-in admin users.
Essentially, you install your new theme and activate it using the plugin instead of the theme switcher in the admin.

Related

How to bypass a theme editor block?

I have downloaded a theme but would like to edit the PHP files, but there is a theme editor block. I can't access it by typing the theme editor into the url, I just wondered if there is a way of getting around it.
It is highly discouraged to edit themes like that, because any changes made that way will be deleted upon update. The recommended way is to create a child theme and edit your PHP CSS and HTML there.
By using a child theme you will ensure that your modifications are
preserved.
Using a child theme can speed up development time.
Using a child theme is a great way to learn about WordPress theme development.
all the documentation to create a child theme is here Wordpress Codex
You will have to open functions.php for that theme outside of wp-admin. Like in a text editor or ide and upload it back to your themes folder.

Drupal theme does not change when it is modified

I am creating a drupal theme and use role theme switcher to change the theme according to user role
for the the role anonymous I've created a custom theme
the theme html script does not change whatever the changes I make
I've cleared the cache from performance
remove the cache from administrator->performance clear cache
change the default theme to new and fresh theme ( I am using zen) and run module and its custom theme
it may need modification in css or js files
Heed Drupal's unofficial moto when developing a theme:
Also, there are many base themes (Zen for instance) which have a setting to clear the cache on every page request during theme development. You turn this off once the theme is completed, but it's a nice feature when you're still working on things to avoid caching issues.

How to prevent to lose a theme modification in WordPress when the thme will update?

I have the following problem. I have to modify a JQuery function into a file named custom.js into the theme that I am using for my website.
I have no problem to implement my customization to the function but my doubt is: What will happen when the theme will be updated in the future?
I am pretty sure that the file will be overwrite and that I will lost my customization.
How can I prevent this situation and maintein my customization?
What you're doing is forking the theme. Nothing complicated to deal with.
You should consider using a VCS like git or svn to monitor the changes you've made from the original theme, so you can apply them more easily to the latest released versions that the theme might have in the future.
You're right! All changes made to the parent theme will be lost on updating. Nevertheless, it is not a good practice to mess with the parent theme / core WordPress files. You never know where one may go wrong.
WordPress recommends the use of Child Themes for modifying an existing theme.
Note that this method is easier compared to the Version Control mechanisms like git or SVN. Moreover you could keep track of all the changes made by you.
Now that you're using the child theme, its easier to dequeue the custom.js file included by your parent theme using the wp_dequeue_script function. Then, use wp_enqueue_script to enqueue the file in your child theme with the necessary customization made.

Update WP theme without delete the old version first

I'm currently host my site with managed WP hosting (I have no access to my file directory). I use child theme that contains only style.css file (aimed to store the customization only) and I do not activate WP editor for security reason.
When I want to update my parent theme I should delete the old version first and my site automatically changes to other existing theme which is completely different.
To upload my new version theme it takes time about 1 minute and that means users will see my site with different theme while the uploading process.
My question:
How to update my theme without delete it first or is there a plugin I can use?
If there is no such a way, how to show error message ("Hey we'r currently customizing our site ...") during the uploading process?
Thanks.
if you are using the child theme then you can directly update as it does not effect your changes for child theme
and for showing maintenance there are many plugins that provides the maintenance mode functionality.one of theme is
https://wordpress.org/plugins/wp-maintenance-mode/
its show a template while you are in maintenance mode once done change deactivate the maintenance mode

Wordpress Child Theme vs Copying existing theme

I'm new to WordPress but realize that themes can be updated which will cause you to loose any customization you have made.
For the site I'm working on at the moment, I have copied the theme, by changing it's folder name & the name at the top of the style.css in the comments. I then uploaded it to the server.
Since then I have learnt that you can make child themes.
Which is better practice, is their any advantages or disadvantages to either approach? Is it possible that the changes which I have made to my copied theme will get over ridden? The only major changes I have made to my copied theme have been to the style.css & header.php.
If you're only making minor changes, then you should use a child theme. This has several advantages:
You get free updates whenever the parent theme is updated. This includes security updates, which could be very important.
Your code base will be much more manageable.
You will also find it easier to apply your alterations to other themes.

Categories