IT Blog

  • Blog
  • Technology
    • Technology
    • Architecture
    • CMS
    • CRM
    • Web
    • DotNET
    • Python
    • Database
    • BI
    • Program Language
  • Users
    • Login
    • Register
    • Forgot Password?
  • ENEN
    • 中文中文
    • ENEN
Experience IT
In a World of Technology, People Make the Difference.
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  3,780 total views,  5 views today

2021-02-08 0 Comments 801 Views 1 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 4183 Views 2 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 3117 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 770 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 513 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.  5,731 total views

2021-01-11 0 Comments 1267 Views 0 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 :)  14,714 total views

2021-01-03 1 Comments 3422 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);  18,260 total views

2020-12-29 2 Comments 7581 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;}  13,720 total views

2020-12-24 2 Comments 3135 Views 1 Like IT Team Read more
Technical Tips

Sending email using gmail SMTP

Gmail allows external users to send email from its SMTP server. You could set it up in gmail settings or google admin settings.

2020-12-22 0 Comments 406 Views 2 Like IT Team Read more
12345…18
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
Rich editor not working Making web page scroll down automatically Getting data from Dapper result All Unicode Chars How to keep and display contact form 7 data Common Regular Expressions
CTE benchmark Assign users to a post Hide empty custom fields in Ultimate product catelog plugin Apostrophe menu font too big Wordpress database model Mixed Content warning: request an insecure element was automatically upgraded to HTTPS
Categories
  • Architecture
  • BI
  • C#
  • CSS
  • Database
  • DotNET
  • Hosting
  • HTML
  • JavaScript
  • PHP
  • Program Language
  • Python
  • Security
  • SEO
  • Technology
  • Web
  • Wordpress

COPYRIGHT © 2021 Hostlike IT Blog. All rights reserved.

This site is supported by Hostlike.com