tonyparera
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: End-to-End Cron setup.Hi Christine,
Thanks. It helps but I have two distinct question on the same ?
1. Where can I put my
add_filter( 'cron_schedules', 'cron_add_20mins' );
so It execute one time only ? I guess if I put in functions.php than it will call every time page loads.2. Which hook i should use to bind “add_action(‘my_hourly_event’, ‘do_this_20mins’);” , will “my_hourly_event” sufficient ?
Forum: Fixing WordPress
In reply to: How to change language in each page ?Discarding this question.
Forum: Hacks
In reply to: How to change language in each page ?After lots of hack and reading, I managed to solve this and getting it worked at https://www.oyetweet.com where it does translate to multiple languages in one post.
//tony: add all language related mo files to initiate the MO array. global $jwp_lang; $jwp_lang['textdomain'] = 'brazil_portuguese'; $domain = $jwp_lang['textdomain']; $mofile = ABSPATH . 'wp-content/languages/' . $jwp_lang['textdomain'] . '.mo'; load_textdomain($domain, $mofile);
than I simply select the textdomain based on country title.
$title = get_the_title(); if (strtolower($title) == 'brazil') $jwp_lang['textdomain'] = 'brazil_portuguese'; if (strtolower($title) == 'germany') $jwp_lang['textdomain'] = 'german_germany'; if (strtolower($title) == 'philippines') $jwp_lang['textdomain'] = 'philippines_filipino'; if (strtolower($title) == 'malaysia') $jwp_lang['textdomain'] = 'malaysia_malay';
and to display content, I use this
global $jwp_lang; __('Suggest Celebrity', $jwp_lang['textdomain'])
Hi,
Just to update, It’s my mistake.
Actually it was working as expected, the only issue was that text and background color was same so I couldn’t see the text.
Changed text color and issue resolved.
Thanks.
Case closed.
??
Hi,
Perfect, Works like a charm. Thanks.
Just one query, would it be expensive to add this controller file and initialize the class in every ajax callback functions ?
Cheers,
-TonyHi Tobias,
I tried this way but having one small issue,
Added in function.php
add_action('wp_ajax_my_action_wp_table_reload', 'my_action_callback'); add_action('wp_ajax_nopriv_my_action_wp_table_reload', 'my_action_callback'); function my_action_callback() { global $wpdb; // this is how you get access to the database $whatever = intval( $_POST['whatever'] ); //$whatever += 10; //echo $whatever; if (($status = tony_update_wp_table_reload_cols_with_fb_opengraph($whatever)) !== FALSE){ $status = tony_wp_table_reloaded_refresh($whatever); echo do_shortcode( '[table id=' . $whatever . ' /]'); } else { echo "Some issue, please refresh whole page."; } die(); // this is required to return a proper result }
and on the front0-end site, I added this in header template.
add_action('wp_head', 'prefix_ajax_add_foobar'); function prefix_ajax_add_foobar() { ?> <script type="text/javascript" > jQuery(document).ready(function($) { $('.content1').bind('click', function(e){ //event.preventDefault(); var data = { action: 'my_action_wp_table_reload', whatever: 2 }; alert('Got this from the server system: ' + MyAjax.ajaxurl); // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php $.post(MyAjax.ajaxurl, data, function(response) { alert('Got this from the server system: ' + response); }); }); }); </script> <?php }
All seems to work nice and I do receive $response variable in alert, but instead of getting full html output of table’s shortcode , I just receive the string “[table id=2 /]” in $response.
Do I need to add “require_once($path.’/wp-config.php’);” in function my_action_callback() to make do_shortcode work ? Anything else am I missing ?
Hi Tobias,
Thanks, It always feel great to get response from the creator.
Well, I manage to make it work like this. Pl. comment if any improvement can be done.
$(document).ready(function(){ $('.content1').bind('click', function(e){ getContent('https://www.oyetweet.com/WP_prod/wp-content/plugins/autocompleter/values.php?tbl=1'); event.preventDefault(); }); function getContent(filename) { $.ajax({ url: filename, type: 'GET', dataType: 'html', beforeSend: function() { $('.wp-table-reloaded, .wp-table-reloaded-id-2').html('<img src="https://www.jquery4u.com/images/loading.gif" />'); }, success: function(data, textStatus, xhr) { $('.wp-table-reloaded, .wp-table-reloaded-id-2').html(data); }, error: function(xhr, textStatus, errorThrown) { $('.wp-table-reloaded, .wp-table-reloaded-id-2').html(textStatus); } }); } });
and in value.php I called these three functions.
if (($status = tony_update_wp_table_reload_cols_with_fb_opengraph(2)) !== FALSE){ $status = tony_wp_table_reloaded_refresh(2); echo do_shortcode( '[table id=2 /]'); } else { echo "Some issue, please refresh whole page."; }
Not sure on how expensive this could be or any other better way to achieve this but now it works.
Forum: Fixing WordPress
In reply to: Plug-In list page has some issue.Thanks, after removal it is okay but not sure if I install autocompleter again, will that issue surface again, is it known issue for autocompleter ?
Forum: Hacks
In reply to: How to change language in each page ?true, I have already started to dig into l10n.php file and all load_textdomain() and other textdomain related functions.
Initially I thought this could be a simple setup somewhere now it turn out to be some good stuff to explore and debug.
My default is English and I not loading any other non-english plugins so I guess that is not an issue.
Let me explore bit more with textdomain stuff and see.
Forum: Hacks
In reply to: How to change language in each page ?Well, I tried but It seems not working this way.
I have created .mo files and placed into WP_LANG_DIR directory and use below two line, to set the language at the beginning of the page header file but it seems not taking any effect.
setlocale(LC_ALL, “de_DE”);
setlocale(LC_NUMERIC, ‘C’);Forum: Hacks
In reply to: How to change language in each page ?Hi bcworks,
Thanks, I will give a try of your suggestions, I guess following article also suggest to use this.
setlocale(LC_ALL, “de_DE”); //at page’s start of header
setlocale(LC_NUMERIC, ‘C’); //to avoid and numeric mismatched as nicely explained in below artible.https://www.code-styling.de/english/php-function-setlocale-and-numbers-can-be-damaged