• Resolved wpaga

    (@wpaga)


    Hello
    Is there a way to change the Vendors dataTable language?
    I see that in “public/assets/js/public.js” the dataTable gets its language from the “marketking_display_settings” defined in “public/class-marketking-core-public.php”, but this is hardcoded to “English” and this file isn’t overwritten if I move it to “__my_theme__/marketking” folder.

    If fact there are more changes that I would like to do in “marketking_display_settings”. Is there a way to do it?

    Thank you

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author WebWizards

    (@webwizardsdev)

    Hi there!

    Thanks for using the plugin,

    We should probably add a setting for that language, but right now it can be changed by adding this PHP code snippet to your site:

    add_filter('marketking_tables_language_option_setting', function($lang){
    	$lang = 'Spanish';
    	return $lang;
    }, 10, 1);

    This can be added to the functions.php of your child theme, or to any Snippets plugin.

    If you would like to change various texts, generally we’d recommend using the Loco Translate plugin. Or are you looking to change something that is not a text?

    Thread Starter wpaga

    (@wpaga)

    Hello and thank you for the quick response.
    I’ve solved this issue by overwriting the var in javascript (adding marketking_display_settings[‘tables_language_option’] = … in footer.php)
    but the snippet you wrote would be very useful.

    What I also wanted to do, is to change the “Follow / Following” texts with icons, but right now the html code is rendered as text (public.js 1957, 1959)
    I’ve overwritten the on(‘click’) function but it’s not always working as expected. Sometimes it returns the icon html code…

    Plugin Author WebWizards

    (@webwizardsdev)

    I think indeed a good solution could be to first remove the click function from the button:

    jQuery('.marketking_follow_button').off('click');

    and then add your own custom function:

    jQuery('.marketking_follow_button').on('click', function(){	
    	var datavar = {
            action: 'marketking_change_follow_status',
            security: marketking_display_settings.security,
            vendorid: jQuery(this).val(),
        };
    
        let th = jQuery(this);
    
        jQuery.post(marketking_display_settings.ajaxurl, datavar, function(response){
        	if (response === 'followed'){
        		// set text
        		jQuery(th).text('test1');
        	} else if (response === 'unfollowed'){
        		jQuery(th).text('test2');
        	}
        });
    
    });

    To make that an icon, you would probably want to use the .html() function instead of .text()

    Thread Starter wpaga

    (@wpaga)

    This is exactly what I’ve tried (using ‘off’ and ‘html’) but it is not functioning correctly.
    Sometimes, it gives me the icon, but some other times it outputs the icon’s html code. I can’t see why…

    Maybe the simplest way to solve this, is if you would change the ‘text’ to ‘html’ in a future update ?? . The would give users the freedom to change this part, as they wish.

    Anyway, this is not a major issue. I can live with the ‘follow’ text. ??
    Thank you for your time.

    Plugin Author WebWizards

    (@webwizardsdev)

    I have now changed that to .html() in the code base (will work in the next update).

    Have a nice day!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘dataTables language’ is closed to new replies.