IT Blog

  • Blog
  • Technology
    • Technology
    • Architecture
    • CMS
    • CRM
    • Web
    • DotNET
    • Python
    • Database
    • BI
    • Program Language
  • Users
    • Login
    • Register
    • Forgot Password?
  • ENEN
    • 中文中文
    • ENEN
CMS
Wordpress

Fixing Kratos theme multi-language issue

This is a note for fixing Kratos theme multi-language issue. Basic information Theme: Kratos Language plugins: Polylang, Loco Language settings: en_CA, zh_CN Symptom On English version, always display Chinese words. While OceanWP theme displays correctly for multi-languages. Reason The theme offers multi-language support for American English, Japanese, and Chinese language files: en_US, ja_JP, zh_TW. For English only contains en_US, not en_CA. For multi-language use, I created a en_CA language file under common location: /wp-content/languages/themes/kratos-en_CA.po. In the theme, the language file location is locked on theme directory.  Therefore all other languages that located on other location cannot be found. function theme_languages() { load_theme_textdomain('kratos', get_template_directory() . '/languages'); } add_action('after_setup_theme', 'theme_languages'); Fixing multi-language issue As a quick fix, just change en_CA to en_US, instead of creating another language file. Then it displays as expected. For better solution, the en_CA language file could be copied over to theme language directory, in order to keep Canadian English style.  312 total views,  8 views today

2021-03-17 0 Comments 273 Views 0 Like IT Team Read more
Wordpress

How to automatically translate a website to any language

GTranslate is a leading website translation services provider since 2008. It uses Google Translate automatic translation service to translate wordpress site and make it multilingual. It provides 103 languages for your site users to choose from. Web masters can simply choose many combination of language options to allow users to select. Install GTraslate plugin Settings After the activation click on setting link under the plugin name. Or select GTraslate from settings menu. Select languages which are expected to be used by users. Select options. Flags with language name displays languages in flat style with flags and language names. Add to widget It is required to add the translation tool to menu, widget, or somewhere you like. The widget title is optional. Styling the language selection panel <style type="text/css" for="gtranslate"> .widget_gtranslate div.title{ margin:0 10px 0 0 !important; } .widget_gtranslate div.title:after{ background-color:#fff !important; } .widget_gtranslate select{ border:solid 1px #ccc; } a.glink img { width:25px !important; } a.glink { width:103px !important; display:inline-block; } </style> Translate language names in order to display in their own language. <script type="text/javascript" id="gtranslate"> $(document).ready(function(){ $('.widget_gtranslate span').each(function(index, obj){ obj.innerText=obj.innerText.replace('Chinese (Simplified)','简体中文'); obj.innerText=obj.innerText.replace('Chinese (Traditional)','繁体中文'); obj.innerText=obj.innerText.replace('French','Français'); obj.innerText=obj.innerText.replace('German','Deutsche'); obj.innerText=obj.innerText.replace('Japanese','日本語'); obj.innerText=obj.innerText.replace('Korean','한국어'); obj.innerText=obj.innerText.replace('Russian','русский'); }); }); </script> Display result on web page On the website, once a user selects a language the browser remembers the selection, whenever the user navigates to any other page it will translate the contents to the selected language automatically.  305 total views

2021-03-06 0 Comments 271 Views 1 Like IT Team Read more
Wordpress

Controling Category List on Sidebar Widget

Category list on sidebar widget will display all categories on post category hierarchy by default. However, we do not want to display all of them for some reason. Here is simple technique to achieve this goal. Find category IDs First thing to do is to find out all category IDs that we don't want them to show on the sidebar. Run the following script against WordPress MySQL database. SELECT t.term_id catID,t.name FROM wp_terms t join wp_term_taxonomy tax on tax.term_id=t.term_id where tax.taxonomy='category' Snippets //Hide categories from WordPress category widget function exclude_widget_categories($args){ $exclude = "4,6,7,8,9,10,13,14,15,16"; $args["exclude"] = $exclude; return $args; } add_filter("widget_categories_args","exclude_widget_categories"); Apply the snippets There are many ways to apply the snippets. You could add it to theme functions.php file or using snippets plugin to apply the snippets code. In my case, I'm using snippets to apply the code. This way is better organized for reusing the snippets. Last words, This is the simplest way to contorl the category list on sidebar, but you may use other ways to control the category list on sidebar, for instance, find a proper plugin or write your own plugin to achieve it.  379 total views,  6 views today

2021-03-04 2 Comments 320 Views 0 Like IT Team Read more
Wordpress

Restoring the Links Manager

WordPress Links Manager is a tool to manage a set of links. You can add, modify, and remove a link easily from admin dashboard. By default, WordPress come with a widget to add a sidebar, where the links will be shown. The Links Manager is provided by default in earlier versions of WordPress than Version 3.5. However, the WordPress Links Manager and blogroll are hidden for new installs. Moreover, if you used an earlier version than 3.5 and upgraded your installation, then the Links Manager was removed if you don’t have any links. Restoring the Links Manager 1. Using filter Add the following line to your theme’s functions.php file to enable WordPress Links Manager if you are using WordPress version 3.5 or higher To enable Links Manager in version 3.5+, just add the following code to one of the following locations: functions.php file of the theme; php snippets plugin; your own plugin; add_filter( 'pre_option_link_manager_enabled', '__return_true' ); Once enabled, you can see a Links tag in the left panel of the dashboard. 2. Change option value from database If you can access the database you could enable it pritty easy by changing the option value in the database directly. There is an option_name = 'link_manager_enabled' in wp_options table. You can set this value to 1 directly. update wp_options set option_value=1 where option_name='link_manager_enabled'; What Link Manager plugin does is just to change this value in wp_option table behind the scene using filter function. Displaying Links in sidebar WordPress provides a widget within its Links Manager. So you can easily locate links in the sidebar…

2021-02-08 0 Comments 149 Views 0 Like IT Team Read more
Plugin

Adding reCaptcha for user forms in WordPress

Google reCAPTCHA uses an advanced risk analysis engine and adaptive challenges to keep malicious software from engaging in abusive activities on your website. UserWP plugin come with anther plugin that support reCaptcha. Here's the steps to setup. Search for UserWP reCaptcha plugin Install and activate UserWP reCaptcha plugin Go to google reCaptcha admin console Find the link to google admin console under Addons tab, and click on the link. Get key from google provider and fill into plugin settings In google admin console, click on plus sign to add a site, then copy the keys. Enter the site key and secret key into plugin settings Check result on the form  131 total views,  1 views today

2021-02-08 0 Comments 113 Views 0 Like IT Team Read more
Wordpress

Scheduling Background Job in WordPress

There are many things have to be done on background, for instance, version check, update theme, delete posts, delayed posting, delete transients, etc. In WordPress this background job is performed by WP-Cron, witch is defined in wp-cron.php file. WordPress cron is the system built-in process that handles the scheduling of time-based tasks. Out-of-the-box, WordPress performs a number of scheduled tasks, they include: WordPress core update checks Plugin update checks Theme update checks Publishing of scheduled posts WP-Cron takes its name from cron, which is a time-based job scheduler in Unix-like systems. However, WP-Cron is designed to work on any hosting provider (including shared hosting) without using any external software or tools for scheduling events. Problem of WP-Cron The wp-cron.php is triggered on every http request. If any scheduled event is due, the event is spawned to wp-cron.php for processing, so the event is triggered to run. This is unreliable, espectially for low traffic sites, or heavily cached sites, cause scheduled events to be missed if no traffic is received for a prolonged period of time. For high-traffic sites, WP-Cron is extremely inefficient. This is because WP-Cron will check for scheduled events on every page load. This could mean that the cron schedules are being checked multiple times per second. This is unnecessary and highly redundant, as scheduled events typically run in minutes or hourly, even monthly interval. Even wp-cron.php creates a lock in WordPress transient, witch stored in wp_options table, but for high traffice sites the high concurrent requests may still spawn multiple requests to wp-cron.php, thus increasing server load.…

2021-02-07 1 Comments 524 Views 1 Like IT Team Read more
Wordpress

Hide author information from WordPress

Author information is an important part of a blog, but for some reason you have to hide it. For example, the blog is a result of multiple authors. 1. Simply hide author information using stylesheet. Add custom css (look like the following): .author,.postauthor-container { display:none; visibility:hidden; } .uwp_widget_author_box { display:none; visibility:hidden; } /* UserWP plugin */ 2. Using "Hide/Remove Metadata" plugin 3. Change code The author information is written by theme, so you have to find out the php code location in order to make change. The possible location is on the following files: single.php, content.php, archive.php, index.php, functions.php, template-tags.php For example, in the theme "Twenty Nineteen" the code is on "twentynineteen_posted_by" function in template-tags.php file. Note that, before making any change on the theme code please make a full backup.   Hope this informaiton will help some people :)  706 total views,  5 views today

2021-01-03 1 Comments 633 Views 1 Like IT Team Read more
Wordpress

How to do some trick to improve WordPress performance

There are many ways to improve WordPress performance. But here I would introduce a trick to dramatically improve the page loading speed. Convert to html page As a web page the ultimate content is html code. If we could response in html directly without bothering the server code and database to run the page would be loaded really quick. make sure the web page working as expected use browser developer tool to view the source copy the html source code go to File Manager of the CPanel, manually create folders and index.html file according to the url pathFor example: for url "https://hostlike.com/zh/web-hosting/"create folder /zh/web-hosting/, then create file index.html under the new folder open index.html with file editor paste the copied content to the index.html file save the content. Dynamic content trick If there is dynamic content, e.g. shopping cart item number. We can use JavaScript to update the value. Add the following JavaScript code to the end of index.html content. function getCookie(name) { const value = `; ${document.cookie}`; const parts = value.split(`; ${name}=`); if (parts.length === 2) return parts.pop().split(';').shift(); } var cart_count = getCookie('woocommerce_items_in_cart'); $('.wcmenucart-details').text(cart_count);  5,017 total views,  11 views today

2020-12-29 2 Comments 4940 Views 1 Like IT Team Read more
Wordpress

Recovering user role in WordPress

The administrator role somehow loss admin privillage, to restore it as an admin, we could update 2 rows information in database easily. The following DML will restore the admin privillage. set @id=1; update wp_usermeta set meta_value='10' where user_id=@id and meta_key='wp_user_level' update wp_usermeta set meta_value='a:1:{s:13:"administrator";b:1;}' where user_id=@id and meta_key='wp_capabilities' The admin role is controlled by user level and capability attributes, and these information are stored in wp_usermeta table. User level: User Level 0 converts to Subscriber User Level 1 converts to Contributor User Level 2 converts to Author User Level 3 converts to Editor User Level 4 converts to Editor User Level 5 converts to Editor User Level 6 converts to Editor User Level 7 converts to Editor User Level 8 converts to Administrator User Level 9 converts to Administrator User Level 10 converts to Administrator Capability: Refer to: Roles and Capabilities for detail information. In wp_usermeta table the meta_value stored as role: Admin:            a:1:{s:13:"administrator";b:1;} Author:           a:1:{s:6:"author";b:1;} Contributor:  a:1:{s:11:"contributor";b:1;} Subscriber:    a:1:{s:10:"subscriber";b:1;}  592 total views,  5 views today

2020-12-24 2 Comments 519 Views 1 Like IT Team Read more
Wordpress

Restrict WordPress user access some contents

Scenario Certain contents are allowed by specific group of users to access. Membership roles concept With Members plugin, user roles can be managed in dashboard. Role permissions are called capability. The capabilities are defined based on themes and plugins. The following figure shows the basic role capabilities. Solution Add a user role that allows users to access those restricted contents. Steps 1. Members plugin Install plugin called "Members – Membership & User Role Editor Plugin". 2. Setup roles Go to Members on the left menu of Dashboard. Here you could add a new role or edit an existing role, and then assign permissions, which called capability within the plugin, to the role. 3. Add user to a role Go to Users menu, click on the user that you want to edit. Scrolldown to the bottom, the last section is User Roles. Select the role to assign. 4. Restrict page access by role On the page/post editor, scrolldown to the last section "Content Permission", assign page with the role that is allowed to access the page/post. Done. Now you have restrict the page to be accessed only the users with the role.  80 total views

2020-12-03 0 Comments 76 Views 0 Like IT Team Read more
12345…7
Chinese (Simplified) Chinese (Simplified) Chinese (Traditional) Chinese (Traditional) English English French French German German Japanese Japanese Korean Korean Russian Russian
Newest Hotspots Random
Newest Hotspots Random
Fixing Kratos theme multi-language issue How to automatically translate a website to any language Controling Category List on Sidebar Widget Restoring the Links Manager Adding reCaptcha for user forms in WordPress Scheduling Background Job in WordPress
2021 最新 DotNet 资源大全
Switch external image for index page and posts Preparing SQL script to check object existance for production deployment fix menu arrow Sending email using gmail SMTP Fixing image issue in posts Add slideshow on homepage for Parallax One theme
Categories
  • Architecture
  • BI
  • C#
  • CSS
  • Database
  • Digital Marketing
  • DotNET
  • Hosting
  • HTML
  • JavaScript
  • PHP
  • Program Language
  • Python
  • Security
  • Technology
  • Web
  • Wordpress

COPYRIGHT © 2021 Hostlike IT Blog. All rights reserved.

THEME KRATOS MADE BY VTROIS