custom widgets > preserved after plugin updates?
-
Hello,
I’m planning to write a custom widget to display languages names as iso codes (i.e. en, fr, it…) and without flagsI’ve found the documentation to write a custom widget here: https://trac.transposh.org/wiki/WidgetWritingGuide
Just wanted to ask advice about preserving custom widgets when updating transposh (using wordpress plugin update functionality)
Many thanks
Guido
-
Hi Guido,
You may place your widgets in the wp-content/uploads/transposh/widgets directory – where they will be protected from upgrades.
Good luck
Many thanks Ofer
I’m sorry but my custom widget is not loaded when I save it in the directory:
wp-content/uploads/transposh/widgets
the default widget appears instead.It works perfectly when I save it in
wp-content/plugins/transposh-translation-filter-for-wordpress/widgets
Unfortunately it is not protected from updates there.I’ve named the widget file “tpw_list_with_iso_codes.php”
This is the line of code that calls the custom widget in my theme (the above php file is placed inside the “iso_codes” dir)
if(function_exists("transposh_widget")) { transposh_widget(array(), array('title' => '', 'widget_file' => 'iso_codes/tpw_list_with_iso_codes.php'));}?>
This is the content of the file
<?php /* Plugin Name: List with iso codes Plugin URI: http://transposh.org/ Description: Widget with languages ISO codes Author: GB Version: 1.0 Author URI: http://www.theboxitaly.com */ /* * Transposh v1.0.4.1 * http://transposh.org/ * * Copyright 2018, Team Transposh * Licensed under the GPL Version 2 or higher. * http://transposh.org/license * * Date: Mon, 31 Dec 2018 13:56:20 +0200 */ class tpw_list_with_iso_codes extends transposh_base_widget { /** * Creates the list of iso codes * @global transposh_plugin $my_transposh_plugin * @param array $args - http://trac.transposh.org/wiki/WidgetWritingGuide#functiontp_widgets_doargs */ static function tp_widget_do($args) { echo "<div class=\"" . NO_TRANSLATE_CLASS . " transposh_iso_codes\" >"; echo "<ul>"; foreach ($args as $langrecord) { echo "<li> <a href=\"{$langrecord['url']}\"" . ($langrecord['active'] ? ' class="tr_active"' : '' ) . '>' . "{$langrecord['isocode']} </a> </li>"; } echo "</ul>"; echo "</div>"; } } ?>
Please do you see anything wrong in my code or setup?
Many thanks
GuidoHi,
First, you must be using the full version. Not supported on the wordpress.org version, but since I see 1.0.4.1 I think that you already have this,
Just make sure that the webserver user has permission for that directory, I suggest placing the code in a sub directory
You can test that its working by copying the current widgets to that directory, they should be listed with a (*) in the widget appearance selection box
Good luck,
I’m a bit confused by the “full version” concept.
A few days ago I was given this website to mantain, and it had transposh plugin v 0.9.9.0 installed. As part of a normal maintenance plan, using wordpress (.org) update I updated the plugin to the latest version available, as a result now I have 1.0.4.1.
Am I on the full version now? I think so, because of the .1 at the end.
Should I reinstall 1.0.4.1 after downloading it from the transposh website?
If so it’s very important for me to preserve existing settings and translations.As for the webserver setup it looks fine:
the uploads/transposh/widget dir is owned by the webserver user and has 0755 permissions
if I put a test file in the same dir of my custom widget, I can see it using a web browser on a client.Thanks again
Guido-
This reply was modified 6 years, 1 month ago by
guidobras.
Yes, it seems like you are on the last full version,
Is the widget file inside a directory in the uploads/transposh/widgets (mind the s) dir? or is it just there, both should work, but I rarely tested the dirless method
Did you try copying a current widget there?
The custom widget is inside a dir:
uploads transposh widgets iso_codes tpw_list_with_iso_codes.php
Yes, I uploaded some current widgets to that directory, but I could not find “the widget appearance selection box” to check for the asterisk you mentioned. Where is that selection box supposed to appear?
-
This reply was modified 6 years, 1 month ago by
guidobras.
Please contact me via the form, its getting late here so I will only be able to get back to you in a few hours, this should have worked, but I don’t know.
After contact we’ll try and setup a debug session to make this work
As I’m trying to write a custom plugin as well, and chance you can explain what is going on? I’ve having the exact same problem. My custom widget is not loading. I tried putting in one of the existing widgets, but they don’t show up with * either. Do I need to do anything other than putting the widget .php file in the correct directory?
-
This reply was modified 6 years, 1 month ago by
- The topic ‘custom widgets > preserved after plugin updates?’ is closed to new replies.