├── custom ├── custom.js ├── functions.php └── style.css ├── readme.txt └── theme-customisations.php /custom/custom.js: -------------------------------------------------------------------------------- 1 | jQuery(document).ready(function($){ 2 | // Custom jQuery goes here 3 | }); 4 | -------------------------------------------------------------------------------- /custom/functions.php: -------------------------------------------------------------------------------- 1 | Editor in the Dashboard 22 | 3. Activate the plugin through the 'Plugins' menu in WordPress 23 | 4. Done! 24 | 25 | == Usage == 26 | 27 | * Add any CSS snippets to `custom/style.css`. This file is found in this plugin. 28 | * Add any PHP snippets to `custom/functions.php`. This file is found in this plugin. 29 | * Add any jQuery snippets to `custom/custom.js`. This file is found in this plugin. 30 | * Add custom top level template files (page.php, single.php etc) to `custom/templates/`. You will need to create the templates folder. 31 | * Add any WooCommerce template files to `custom/templates/woocommerce`. You will need to create the templates and woocommerce folders. 32 | * Activate the plugin. 33 | 34 | == Frequently Asked Questions == 35 | 36 | = Isn't this what child themes are for? = 37 | 38 | Well, kind of. Sure, you can put your modifications in a child theme, but there are many places (including woothemes.com and wordpress.org) to download and use child themes. If you decide to use a child theme built by a third party and make modifications there, you would lose them when performing updates. Also if you make all your modifications in your own custom child theme then realise that you want to use a child theme from your favorite theme vendor, you'll have to move all of your modifications somewhere else. To avoid that hassle, use this plugin. 39 | 40 | = What templates can I override via this plugin? = 41 | 42 | As you know, to override a parent themes template file via child theme you can just copy/paste it into your child theme. This is the one drawback of using this plugin - you can only override top level templates - not template partials. This means that you could add a `page.php` template file to the `/custom/templates/` dir of this plugin and it would work fine. You could not however add a `header.php` or `footer.php` template file. Those would not work. 43 | 44 | = Should I put all my customisations in this single plugin? = 45 | 46 | That's entirely up to you. There's nothing to stop you from duplicating this plugin and changing the name. That way you could theoretically keep each of your customisations in their own individual plugins. This can be very handy when debugging, or if you want to quickly enable/disable a specific customisations temporarily. 47 | -------------------------------------------------------------------------------- /theme-customisations.php: -------------------------------------------------------------------------------- 1 | /custom/templates/woocommerce/cart/cart.php 88 | * 89 | * @param string $located is the currently located template, if any was found so far. 90 | * @param string $template_name is the name of the template (ex: cart/cart.php). 91 | * @return string $located is the newly located template if one was found, otherwise 92 | * it is the previously found template. 93 | */ 94 | public function theme_customisations_wc_get_template( $located, $template_name, $args, $template_path, $default_path ) { 95 | $plugin_template_path = untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/custom/templates/woocommerce/' . $template_name; 96 | 97 | if ( file_exists( $plugin_template_path ) ) { 98 | $located = $plugin_template_path; 99 | } 100 | 101 | return $located; 102 | } 103 | } // End Class 104 | 105 | /** 106 | * The 'main' function 107 | * 108 | * @return void 109 | */ 110 | function theme_customisations_main() { 111 | new Theme_Customisations(); 112 | } 113 | 114 | /** 115 | * Initialise the plugin 116 | */ 117 | add_action( 'plugins_loaded', 'theme_customisations_main' ); 118 | --------------------------------------------------------------------------------