Exguardi
Forum Replies Created
-
Hi,
Since I hadn’t heard back I had the thought that I could at least disable the showing of the ‘set as default language’ text using css– however I’m now realizing that applying CSS to the custom button does not seem to be working.
Even if I copy-paste some of the code from your other widget/css files directly it does not appear to be styled. I’m not sure how to troubleshoot this and would appreciate any insight.
For example, I have:
echo "<div class=\"" . NO_TRANSLATE_CLASS . " transposh_flags\" >HELLO WORLD</div>"; echo '<input type="button" class="tpw_image_toggle btn" ';In a css file with the same name as the PHP file (tpw_image_toggle), I have the following:
.transposh_flags { color: #FF69B4; } .btn { -webkit-border-radius: 15; -moz-border-radius: 15; border-radius: 15px; font-family: Arial; color: #000000; font-size: 20px; background: #dbeaff; padding: 10px 20px 10px 20px; text-decoration: none; } .btn:hover { background: #fff8dc; text-decoration: none; }But the content displays no styling. Based on the widget writing guidelines I thought maybe adding:
static function tp_widget_css($file, $dir, $url) { wp_enqueue_style("custom/tpw_image_toggle", "$url/widgets/custom/tpw_image_toggle.css", array(), TRANSPOSH_PLUGIN_VER); }to the PHP file might help, but to no avail. What am I missing?
OK, based on your suggestion and site examples I’ve got everything working as such to switch back and forth between my two languages:
static function tp_widget_do($args) { echo '<input type="button" '; foreach ($args as $langrecord) { if(!$langrecord['active']) { echo 'onclick="location.href=\'' . $langrecord['url'] . '\';" '; echo 'value="' . $langrecord['lang'] . '">'; } } echo '</button>'; }This works great to display a simple button with the name of the language to switch to printed on it.
However, I noticed that the ‘set this language as default’ text just kind of appears to the right of my button element; is it possible to style or alter this element? Or just automatically set the new language as the ‘default’ language for the user, so the next time they load the site it will default to that language? Maybe using the global plugin object?
So my methodology should be as follows:
1) Create a new widget directory and PHP file
2) echo the needed HTML in tp_widgets_do, e.g.echo ‘<button type=”button”>’
??? <– Now I am doing ‘something’ with the ‘args’ that contain data such as the list of languages and current language… how do I set a new language when that button is clicked?
echo ‘</button>’3) include any JavaScript or CSS content