dashed-slug.net › Forums › General discussion › Plugin Overrides
Tagged: filter, frontend, knockout, plugin overrides, templates, UI, views, wallets, wallets_views_dir
- This topic has 10 replies, 2 voices, and was last updated 6 years, 5 months ago by alexg.
-
AuthorPosts
-
July 23, 2018 at 6:54 am #3821alexgKeymaster
Hi,
Any reason I cannot override the views of the wallet in /my-child-theme/wallets/include/views. ?
Thanks 🙂
July 23, 2018 at 7:16 am #3826alexgKeymasterHello,
Did you follow the instructions in the documentation about overriding the views directory?
Instructions are given under “Frontend” -> “Frontend UI WordPress Filters” -> “Alternative knockout templates”.
Essentially you need to use the
wallets_views_dir
filter to point to your new views directory.kind regards
July 23, 2018 at 7:37 am #3830alexgKeymasterI just saw it : function my_wallets_views_dir_override( $dir ) {
return ‘/path/to/the/directory/where/the/new/templates/are/copied’;
}
add_filter( ‘wallets_views_dir’, ‘my_wallets_views_dir_override’ );My apologies ..
July 23, 2018 at 7:53 am #3831alexgKeymasterSo, like this:
function my_wallets_views_dir_override( $dir ) {
return get_stylesheet_directory_uri() . ‘/wallets/include/views/’;
}
add_filter( ‘wallets_views_dir’, ‘my_wallets_views_dir_override’ );But you say:
wp-content/plugins/wallets/includes/views/balance.php
wp-content/plugins/wallets/includes/views/move.php
wp-content/plugins/wallets/includes/views/deposit.php
wp-content/plugins/wallets/includes/views/withdraw.php
wp-content/plugins/wallets/includes/views/transactions.phpShould this not be:
wp-content/plugins/wallets/includes/views/balance/default.php
wp-content/plugins/wallets/includes/views/move/default.php
wp-content/plugins/wallets/includes/views/deposit/default.php
wp-content/plugins/wallets/includes/views/withdraw/default.php
wp-content/plugins/wallets/includes/views/transactions/default.phpWhat about account value ?
wp-content/plugins/wallets/includes/views/account_value/default.php
Graeme
July 23, 2018 at 7:56 am #3832alexgKeymasterYes thank you. I must update the documentation.
These paths were from before each view got its own directory.
Views now have their own directory so that they can have alternative templates.
The correct paths are the longer ones.
July 23, 2018 at 8:06 am #3834alexgKeymasterBut then what about the function:
function my_wallets_views_dir_override( $dir ) {
return get_stylesheet_directory_uri() . ‘/wallets/include/views/’;
}
add_filter( ‘wallets_views_dir’, ‘my_wallets_views_dir_override’ );?
July 23, 2018 at 8:13 am #3835alexgKeymasterpublic function shortcode( $atts, $content = ”, $tag ) {
$view = preg_replace( ‘/^wallets_/’, ”, $tag );$atts = shortcode_atts(
array(
‘template’ => ‘default’,
‘views_dir’ => apply_filters( ‘wallets_views_dir’, __DIR__ . ‘/views’ ),
), $atts, “wallets_$view”
);July 23, 2018 at 9:13 am #3844alexgKeymasterI believe you were looking at an old version of the documentation. In the latest version 3.5.6 the paths are already up-to-date.
–
wp-content/plugins/wallets/includes/views/balance/default.php
–wp-content/plugins/wallets/includes/views/move/default.php
–wp-content/plugins/wallets/includes/views/deposit/default.php
–wp-content/plugins/wallets/includes/views/withdraw/default.php
–wp-content/plugins/wallets/includes/views/transactions/default.php
–wp-content/plugins/wallets/includes/views/account_value/default.php
What is your question about the functions you posted?
July 23, 2018 at 10:09 am #3847alexgKeymasterNope:
function my_wallets_views_dir_override( $dir ) {
return get_stylesheet_directory_uri() . ‘/wallets/include/views/’;
}
add_filter( ‘wallets_views_dir’, ‘my_wallets_views_dir_override’ );I place list.php inside /wallets/includes/views/balance/ (in my child theme folder)
does not work ..
July 23, 2018 at 10:25 am #3848alexgKeymasterHere’s some things that might help:
1. Make sure you have the WordPress debug log enabled so you know what files the system looks for in case it cannot find them. You might need to debug the path.
2. You can avoid hooking to the filter altogether, if you use the views_dir argument in your shortcode. This is implemented in 3.2.0 and is discussed in the documentation. It might allow you to do more tests quicker and easier.
3. It could be some issue with the file permissions. Make sure that your files are readable by your webserver and that their directories are scannable (execute permission).
4. You can, but you do not need the directory structure
wallets/includes/views
. Just call your directory anything, such aswallet_views
.July 23, 2018 at 11:05 am #3849alexgKeymasterThanks Alex, will do and let you know. You have an account inside the system, when I’m done you should have a look 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.