Skip to content

Instantly share code, notes, and snippets.

@smatplacid
Last active August 5, 2021 12:54
Show Gist options
  • Save smatplacid/f0d9a6e27d772312d03c2e2922c7e7b4 to your computer and use it in GitHub Desktop.
Save smatplacid/f0d9a6e27d772312d03c2e2922c7e7b4 to your computer and use it in GitHub Desktop.
Oxygen Child Theme Support

Oxygen 'Child Theme' Support

This function is for developers, which use Oxygen and still want to override plugin-files when it reads in their documentation such as

  1. Create a folder in your theme folder called search-filter.
  2. Copy the file wp-content\plugins\search-filter\templates\results.php from the templates folder in to the newly created folder in your theme – wp-content\themes\your-theme-name\search-filter\results.php

Where to put such files, if Oxygen is not a theme and won't uses themes ?

Usage

Put the code in the root-file of your custom plugin, like wp-content\plugins\your-custom-plugin\plugin.php

Now you can copy the "child-theme-files" to wp-content\plugins\your-custom-plugin\oxygen-child-theme\<respective-folder> or change the value in the oxygen_child_theme_dir_name = 'oxygen-child-theme'; variable.

Tested with

  • WordPress 5+
  • Oxygen 2+ and Oxygen 3+

and the plugins

  • Search & Filter Pro 2+
  • Shortcodes Ultimate 5+
  • WooCommerce 3+

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

<?php
/**
* @since 01/09/2019
*/
add_filter( 'stylesheet_directory', 'oxygen_filter_stylesheet_directory', 10, 3 );
function oxygen_filter_stylesheet_directory( $stylesheet_dir, $stylesheet, $theme_root )
{
$oxygen_child_theme_dir_name = 'oxygen-child-theme'; // CHANGE IT TO YOUR NEEDS
$stylesheet_dir = trailingslashit( dirname( __FILE__ ) ) . $oxygen_child_theme_dir_name;
defined('STYLESHEETPATH') or define('STYLESHEETPATH', $stylesheet_dir);
return $stylesheet_dir;
}
@erropix
Copy link

erropix commented Sep 2, 2019

What files can we replace? all the PHP/JS files or components templates?

@smatplacid
Copy link
Author

What files can we replace? all the PHP/JS files or components templates?

All files which are child-theme ready. It's not meant to override Oxygen itself in any way.

@uhlhosting
Copy link

@smatplacid can you provide some example of woocommerce themes replacements within the code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment