IT Blog

  • Blog
  • Technology
    • Technology
    • Architecture
    • CMS
    • CRM
    • Web
    • DotNET
    • Python
    • Database
    • BI
    • Program Language
  • Users
    • Login
    • Register
    • Forgot Password?
  • ENEN
    • 中文中文
    • ENEN
Technology
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
Technology

WordPress database access with $wpdb

What is in $wpdb object WordPress provides a global object, $wpdb , which is an instantiation of the wpdb class. By default, $wpdb is instantiated to access the WordPress database, but it can be used to manipulate any table in the WordPress database, not just those created by WordPress itself. With the following code include "../../wp-config.php"; print_r($wpdb); We will get result as (original data before formatting): wpdb Object ( [show_errors] => [suppress_errors] => [last_error] => [num_queries] => 42 [num_rows] => 0 [rows_affected] => 0 [insert_id] => 0 [last_query] => SELECT option_value FROM wp_options WHERE option_name = 'pods_upload_require_login_cap' LIMIT 1 [last_result] => Array ( ) [result:protected] => mysqli_result Object ( [current_field] => 0 [field_count] => 1 [lengths] => [num_rows] => 0 [type] => 0 ) [col_meta:protected] => Array ( ) [table_charset:protected] => Array ( ) [check_current_query:protected] => 1 [checking_collation:wpdb:private] => [col_info:protected] => [queries] => [reconnect_retries:protected] => 5 [prefix] => wp_ [base_prefix] => wp_ [ready] => 1 [blogid] => 0 [siteid] => 0 [tables] => Array ( [0] => posts [1] => comments [2] => links [3] => options [4] => postmeta [5] => terms [6] => term_taxonomy [7] => term_relationships [8] => termmeta [9] => commentmeta ) [old_tables] => Array ( [0] => categories [1] => post2cat [2] => link2cat ) [global_tables] => Array ( [0] => users [1] => usermeta ) [ms_global_tables] => Array ( [0] => blogs [1] => blogmeta [2] => signups [3] => site [4] => sitemeta [5] => sitecategories [6] => registration_log ) [comments] => wp_comments [commentmeta] => wp_commentmeta [links] => wp_links [options] => wp_options [postmeta] => wp_postmeta [posts] =>…

2021-02-01 0 Comments 187 Views 0 Like IT Team Read more
CSS

CSS Tricks

Instead of JavaScript, CSS also can do some tricks to make magic happen. CSS can maintain counter variables to inrease the value, and also add some content before and after a block, emphasize first letter of a paragraph, mandatory fields validation, etc. Counters Demo 1 Effect Code <head> <style> body { counter-reset:sec-counter; /* Set "sec-counter" to 0 */ } h2::before { counter-increment:sec-counter; /*Increment "sec-counter" by 1*/ content:"Section " counter(sec-counter) ". "; } </style> </head> <body> <h2>HTML Tutorial</h2> <h2>CSS Tutorial</h2> <h2>JavaScript Tutorial</h2> <h2>Bootstrap Tutorial</h2> <h2>SQL Tutorial</h2> <h2>PHP Tutorial</h2> </body> Demo 2 Effect Code <head> <style> body{ counter-reset:section; /* define counter */ counter-reset:heading; } h1:before{ counter-increment: heading; content:counter(heading) " - "; } h1{ counter-reset: subheading; } h2:before{ content: counter(heading) "." counter(subheading) ") "; counter-increment: subheading; } h2{ counter-reset: section; /* define counter */ } h3:before{ content: counter(heading) "." counter(subheading) "." counter(section) ") "; /*content: counter(section) ": ";*/ counter-increment: section; } </style> </head> <body> <h3>Heading 3, no counter</h3> <h3>Heading 3, no counter</h3> <h1>Heading 1</h1> <h2>Subheading</h2> <h2>Subheading</h2> <h3>Heading 3</h3> <h3>Heading 3</h3> <h1>Heading 1</h1> <h2>Subheading</h2> <h2>Subheading</h2> </body> Demo 3 Effect Code <dhead> <style> ol{ counter-reset: counter; list-style-type: none; } li::before{ counter-increment: counter; content: counters(counter, ".") " "; } </style> </head> <body> <ol> <li>item</li> <li>item</li> <ol> <li>item</li> <li>item</li> <li> <ol> <li>item</li> <li>item</li> <li>item</li> </ol> </li> <li>item</li> </ol> <li>item</li> <li>item</li> </ol> <ol> <!-- restart counter --> <li>item</li> <li>item</li> </ol> </body> Mask Effect Code <head>     <style>         body{             background-color: rgb(124, 156, 216);         }         img{             width:900px;             mask-image:linear-gradient(to top,transparent 25%, rgb(50, 13, 184) 75%);             -webkit-mask-image: linear-gradient(to left,transparent 25%, #000 75%);         }     </style> </head> <body>     <img src="toronto city hall.jpg"> </body> First Letter…

2021-01-24 0 Comments 107 Views 1 Like IT Team Read more
SQL Server

Generating Test Data with SQL Scripts

<<< These scripts were tested on MS SQL Server  2019 >>> From time to time we need to generate huge data for testing. Without any data generating tool we can achieve it by using some SQL Scripts. these scripts are different from regular query scripts. Generate list of data CREATE TABLE #accounts ( fname VARCHAR(20), lname VARCHAR(20)) GO INSERT #accounts VALUES ('Fred', 'Flintstone') GO 1000 SELECT TOP 10 * FROM #accounts fname lname Fred Flintstone Fred Flintstone Fred Flintstone Fred Flintstone Fred Flintstone Fred Flintstone Fred Flintstone Fred Flintstone Fred Flintstone Fred Flintstone ALTER TABLE #accounts ADD id INT IDENTITY(1,1) SELECT TOP 10 * FROM #accounts GO fname lname     id Fred Flintstone 1 Fred Flintstone 2 Fred Flintstone 3 Fred Flintstone 4 Fred Flintstone 5 Fred Flintstone 6 Fred Flintstone 7 Fred Flintstone 8 Fred Flintstone 9 Fred Flintstone 10 ALTER TABLE #accounts ADD id INT DECLARE @id INT SET @id = 0 UPDATE #accounts SET @id = id = @id + 1 OPTION ( MAXDOP 1 ) GO SELECT * FROM #accounts GO fname lname     id Fred Flintstone 1 Fred Flintstone 2 Fred Flintstone 3 Fred Flintstone 4 Fred Flintstone 5 Fred Flintstone 6 Fred Flintstone 7 Fred Flintstone 8 Fred Flintstone 9 Fred Flintstone 10 Note: MAXDOP is max degree of parallelism, set it to 1 to avoid duplicate value if running on multiple processors machine. Read article 1 for detail. Generate sequence numbers Using sys.all_columns table SELECT TOP (1000) ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM sys.all_columns Generate huge Rows using CROSS JOIN SELECT ROW_NUMBER()…

2021-01-20 0 Comments 125 Views 0 Like IT Team Read more
Technology

Remote connection to MySQL on SiteGround

1. Install MySQL ODBC Connector. Download it here: https://dev.mysql.com/downloads/connector/odbc/ 2. Run ODBC Search for ODBC Data Source, select 32 or 64 bit based on your OS. My OS is Windows 10 64bit, so I select 64-bit. 3. Add a new DSN Click on Add button to add a new DSN select MySQL ODBC Driver Enter parmeters to the screen. In order to complete the PCI compliance requirements the remote MySQL connection to the server's primary IP is blocked. For establishing a remote MySQL connection to a database you have to use the server's secondary IP. The secondly IP is shown on Remote database access hosts screen. 4. Test connection Click on Test button to verify the connection is working. DONE.  197 total views

2021-01-11 0 Comments 184 Views 0 Like IT Team Read more
12345…16
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 资源大全
Dynamics 365 switch between production and sandbox Generating Test Data with SQL Scripts Disable auto update in wordpress JQuery set selected option for supporting multi-language Develop UNDO feature with Entity Framework 6 and trigger Event Calendar got 500 error
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