How to Fix Operation Timed Error While Importing a Starter Template?

How to Fix Operation Timed Error While Importing a Starter Template?

When you import a template, the data are being transferred to your server. If you see the error description like the one shown below, the error is caused by a server not being able to respond to a connection request in a timely manner:

Error: 500 Maximum execution time of XXX seconds exceeded

The connection request flow looks like this:

That means that the whole flow you see in the image above needs to be completed within the set time frame (30 seconds in this case). If the above connection request flow does not complete in the allowed time frame, it will cause the connection request to timeout and the import process to fail.

How To Fix This?

Please follow these steps and try importing again with each step. Let』s start:

Simply try importing the template again. Something temporary could have caused the delay. Chances are, it works in the next attempt.No luck with the previous step? Try again but using a different browser. There might be something in your browser (maybe an extension) blocking the request and causing a time-out.Next, if you』re using VPN, please try turning it off.If that didn』t help, please temporarily deactivate a security plugin on your website if you』re using it (Ex – Wordfence, iThemes Security, etc.)If all previous steps didn』t solve it, deactivate all of your plugins except Starter Templates and give it another try (some other plugin on your website may be causing conflict)

Still Having Issues?

Contact your hosting provider and ask them to help, as your host might be causing the conflict. You could use the following template to contact your hosting provider:

Host Email Template:

Hello,I』m building a WordPress website using the Astra theme. I』m trying to import a template using the 「Starter Templates」 plugin (https://wordpress.org/plugins/astra-sites/), but the process keeps failing. Here is the error notice I am receiving – 『WP_Error – cURL error 28: Operation timed out after 30001 milliseconds with 0 bytes receivedWould you please take a look? I』m looking forward to hearing from you.Thank you!Regards,Your name

Still Not Fixed – Let Us Know? 

Open a support ticket with us here, and we will be happy to take a look. If you』re our Premium user, you can expect a reply from our Support team in a maximum of 24 hours. If you』re a free user, don』t worry our Support team will help you out, but it might take a few days as we prioritize tickets.

We will need the FTP details of your server, so please include these in your support request.

How to Fix 5XX Error While Importing a Starter Template?

How to Fix 5XX Error While Importing a Starter Template?

Did you try to import templates for your website using the Starter Templates plugin, and your import failed?

Do you see a 5XX error like for example:

Error: 500 Allowed memory size of XXXXXXXX bytes exhausted (tried to allocate XXXXX bytes)

This error can be seen on the Starter Template 「import process interrupted」 notification popup or in the debug.log file.

This can happen if any of the following is true:

There is an issue with plugins on the site (Plugin conflicts / PHP error)There is an issue with the hosting (Resources such as old PHP version / exhausted resources)

Let』s take a look at how this can be fixed:

Step One: Avoid Conflicts

Deactivate all plugins except Starter Templates to get rid of any possible issues with other plugins. And try importing the template again.

Did it work? Awesome!

If not, let』s continue to the next step:

Step Two: Check WP Debug Log

Enable WordPress debugging mode by installing the WP Debugging plugin and try importing a starter template. This plugin will provide log files to get an idea of what might be causing the issue.

Still no luck? Let』s move on.

Step Three: Update PHP Version

WordPress works with PHP versions as old as PHP 5.6. However, all PHP versions before PHP 7.3 are end-of-life (EOL), meaning they no longer receive updates. Because of this, your site may be exposed to security vulnerabilities.

Moreover, old PHP versions slow down the website and cause other issues.

This article will help you understand how to check the PHP version of your website. We recommend getting on the latest possible PHP version, or at least 7.3.

Step Four: Increase Resources Set by Host

In many cases, Starter Templates import can fail because of the limits set by server PHP configuration.

Your website needs a certain amount of resources to function properly. Depending on the activities on your website and all the plugins running, there may be just not enough resources left for the successful template import. In this case, we would suggest modifying your PHP configuration to the following recommended values (values are approximate):

memory_limit = 512M
max_execution_time = 900
max_input_time = 900
post_max_size = 256M
upload_max_filesize = 720M

These settings will ensure that there are enough resources on your website, even if you』re, for example, running some highly demanding plugins. These are not, in any case, the minimum required values, as the Starter Templates plugin needs minimal resources. Thus, you can also try increasing your values gradually and checking if you can import your template successfully with those settings.

For many non-techie users, this might feel daunting, and checking the log files process will differ from host to host. So it is always better to get it done by someone who knows it well.

So feel free to get in touch with your hosting company, and they will be happy to do it for you.

Here is an email that you can send:

Host Email Template:

Hello,I』m trying to import a starter template from the plugin: https://wordpress.org/plugins/astra-sites/. And it appears that my website is getting a 500 – Internal Server Error. Is it possible for you to:1) Enable WordPress debugging mode2) Check the log files3) Share the file with me?Also the plugin documentation mentioned recommended PHP configuration to be used. Could you please apply the following values for my website:PHP Version: 7.3 or latest possiblememory_limit = 512Mmax_execution_time = 900max_input_time = 900post_max_size = 256Mupload_max_filesize = 720MCan you help me with this?

Still no luck? Please feel free to get in touch with our support, and we will be happy to take a look. But before that.. one question for you:

Is Your Website With Good Host?

We have mostly seen this happen on low-end hosting. Such hosting servers are shared by many different websites, and hence individual users don』t get enough resources that their website needs to perform properly.

The above PHP configuration helps in many cases, but it does not guarantee your website will get those resources. If a server does not have any resources left, your website won』t have them available for the Starter Template import, no matter how we configure it.

We always recommend opting for decent hosting as it is a crucial part of running a healthy website. If you are looking for recommendations, we have a few. They all come with a trial period / money-back guarantee.

How To Hide Astra Settings for Specific User Roles?

How To Hide Astra Settings for Specific User Roles?

Astra Settings that you can find on each page or post of your website contain meta settings that give the user more control and the possibility of even overriding some customizer settings on each page or post. This document will show you how to hide Astra Settings for specific user roles on your website, thus limiting their access to these settings.

Why Would I Have a Need To Hide These Settings?

Meta settings are handy for additional customization of a specific page or post that needs to be different from the rest of your website. But, on the other hand, this can impact the design and even disturb the functioning of your website (for example, Disabling Primary Header on Homepage). 

If your website has a more significant number of users with different user roles, or you』re giving access to outside service providers, these users would probably require access to your content on all or some pages or posts. At the same time, they would typically have access to the meta settings too. Thus, your website might require limiting access to Astra』s Meta Settings for specific user roles while still allowing them access to pages or posts content. This might be a security measure or just the prevention of accidental issues with a website design and functions.

How To Do This?

Achieving this would require adding in a little bit of custom code to your website. Please follow these steps:Step 1 – Check your User Roles and the exact names of the User Roles you would like to limit. WordPress comes with some default user roles:

Super AdministratorAdministratorEditorAuthorContributorSubscriber

Also, some plugins could add additional User Roles to this list. You can check your Users and User Roles at Dashboard > Users.

Step 2 – Add the following filter to the functions.php file of your Child Theme:

add_action( 'do_meta_boxes', 'ast_remove_plugin_metaboxes' );

/**
* Remove Astra settings meta box for users that are not administrators
*/
function ast_remove_plugin_metaboxes(){
if ( ! current_user_can( 'administrator' ) ) {
remove_meta_box( 'astra_settings_meta_box', 'page', 'side' ); // Remove Astra Settings in Pages
remove_meta_box( 'astra_settings_meta_box', 'post', 'side' ); // Remove Astra Settings in Posts
}
}

The code mentioned above will be applied to the user roles lower than the Administrator user role – to apply this to different user roles, you can change the bolded role name 「administrator」 to any user role you wish. This will limit access to Astra』s Meta Settings for all lower roles that the one set in the code. For example, if we would want to set this limit to lower roles than Editor, this line of the code would look like this:

if ( ! current_user_can( 'editor' ) ) {

This change will now allow access to Astra』s Meta Settings to Administrators and Editors but limit it for all other (lower) roles.

Also, the code above will hide Astra Settings on both pages and posts. If you wish to, for example, leave access to these settings in Posts but hide it on Pages for a specific user role, you can do this by removing the line of code related to Posts:

remove_meta_box( 'astra_settings_meta_box', 'post', 'side' ); // Remove Astra Settings in Posts

If you don』t have your Child Theme installed, please check this article on how to do it.If you are not sure how to add this code, please check this article.

How to Change the Default Astra Strings

How to Change the Default Astra Strings

Description

The astra_default_strings filter allows you to change the default strings printed by Astra.

Usage

// Filter callback function
function example_callback( $strings ) {
# ...
return $strings;
}
add_filter( 'astra_default_strings', 'example_callback', 10 );

Parameters

// 404 Page Strings
$strings['string-404-sub-title'] = __( 'This page doesn't seem to exist.', 'astra' );
$strings['string-404-search-title'] = __( 'It looks like the link pointing here was faulty. May be try searching?', 'astra' );

// Search Page Strings
$strings['string-search-nothing-found'] = __( 'Nothing Found', 'astra' );
$strings['string-search-nothing-found-message'] = __( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'astra' );
$strings['string-full-width-search-message'] = __( 'Start typing and press enter to search', 'astra' );
$strings['string-full-width-search-placeholder'] = __( 'Start Typing...', 'astra' );
$strings['string-header-cover-search-placeholder'] = __( 'Start Typing...', 'astra' );
$strings['string-search-input-placeholder'] = __( 'Search ...', 'astra' );

// Comment Template Strings
$strings['string-comment-reply-link'] = __( 'REPLY', 'astra' );
$strings['string-comment-edit-link'] = __( 'EDIT', 'astra' );
$strings['string-comment-awaiting-moderation'] = __( 'Your comment is awaiting moderation.', 'astra' );
$strings['string-comment-title-reply'] = __( 'Leave Comment', 'astra' );
$strings['string-comment-cancel-reply-link'] = __( 'Cancel Reply', 'astra' );
$strings['string-comment-label-submit'] = __( 'Post Comment →', 'astra' );
$strings['string-comment-label-message'] = __( 'Message', 'astra' );
$strings['string-comment-label-name'] = __( 'Name*', 'astra' );
$strings['string-comment-label-email'] = __( 'Email*', 'astra' );
$strings['string-comment-label-website'] = __( 'Website', 'astra' );
$strings['string-comment-closed'] = __( 'Comments are closed.', 'astra' );
$strings['string-comment-navigation-title'] = __( 'Comment navigation', 'astra' );
$strings['string-comment-navigation-next'] = __( 'Newer Comments', 'astra' );
$strings['string-comment-navigation-previous'] = __( 'Older Comments', 'astra' );
$strings['string-comment-one-comment'] = __( 'ONE COMMENT', 'astra' );
$strings['string-comment-multiple-comment'] = __( '%1$s COMMENTS', 'astra' );

// Blog Default Strings
$strings['string-blog-page-links-before'] = __( 'Pages:', 'astra' );
$strings['string-blog-meta-author-by'] = __( 'By ', 'astra' );
$strings['string-blog-meta-leave-a-comment'] = __( 'Leave a comment', 'astra' );
$strings['string-blog-meta-one-comment'] = __( '1 Comment', 'astra' );
$strings['string-blog-meta-multiple-comment'] = __( '% Comments', 'astra' );
$strings['string-blog-navigation-next'] = __('Next Page', 'astra') . ' →';
$strings['string-blog-navigation-previous'] = '← ' . __('Previous Page', 'astra');

// Single Post Default Strings
$strings['string-single-page-links-before'] = __( 'Pages:', 'astra' );
$strings['string-single-navigation-next'] = __('Next Post', 'astra') . ' →';
$strings['string-single-navigation-previous'] = '← ' . __('Previous Post', 'astra');

// Content None
$strings['string-content-nothing-found-message'] = __( 'It seems we can't find what you're looking for. Perhaps searching can help.', 'astra' );

Example

/**
* Update Search Nothing Found String and Search Input Box Placeholder Strings
*
* @param array $strings List of default strings used in theme
* @return array $strings
*/
function default_strings_callback( $strings ) {
// Search nothing found string
$strings['string-search-nothing-found-message'] = __( 'Sorry, There is no Search Result found.', 'astra' );
// Search input box placeholder
$strings['string-search-input-placeholder'] = __( 'Search ...', 'astra' );
return $strings;
}
add_filter( 'astra_default_strings', 'default_strings_callback', 10 );

Check out the doc that explains how to add custom PHP code using the child theme』s functions.php file.

Using Hooks in Astra

Using Hooks in Astra

Description

Hooks allow you to add extra functionality at various areas inside the theme. For example, you might want to display some promotional message below all of your blog posts. Hooks make such dynamic things possible.

Astra uses WordPress Hooks API to insert various hooks throughout the theme.

Usage

add_action( 'hook_name','callback_function_name' );
function callback_function_name () { ?>
// Insert your hook contents in here.
<?php }

In the example above, replace hook_name with the name of the hook you』re wanting to use, like astra_header_before or astra_header_after. Then replace callback_function_name with a unique meaningful function name, something specific to you.

To see the list of hooks available in Astra Visually, check out this site we』ve set.

Example

The astra_header_before hook is executed right before the Site Header.

Note: Site Header –

.

Add PHP to your header

// Add scripts to astra_header_before()
add_action( 'astra_header_before', 'add_script_before_header' );
function add_script_before_header() {
// Your PHP goes here
}

or…

Add HTML to your header

// Add content to astra_header_before()
add_action( 'astra_header_before', 'add_content_before_header' );
function add_content_before_header() { ?>

<?php }

If you are adding PHP to astra_header_before(), use the first method. Use the second method for anything else you may be adding.

Check out the doc that explains how to add custom PHP code using the child theme』s functions.php file.

How to Change the 「Scroll To Top」 Icon in Astra?

How to Change the 「Scroll To Top」 Icon in Astra?

The astra_scroll_top_icon filter allows you to update the Scroll To Top icon class.

Usage

// Filter callback function
function example_callback( ) {
// Process you code here
return variable;
}
add_filter( 'astra_scroll_top_icon', 'example_callback', 10 );

Example

/**
* Add custom class to Scroll To Top
*
* @return string $classes
*/
function astra_scroll_top_icon_callback() {
$classes = 'fa fa-angle-double-up'; // 'fa fa-angle-double-up' replace with your class
return $classes;
}
add_filter( 'astra_scroll_top_icon', 'astra_scroll_top_icon_callback', 10 );

Note: To use 『fa fa-angle-double-up』 class you need to enqueue Font Awesome to your theme.

Check out the doc that explains how to add custom PHP code using the child theme』s functions.php file. 

Refer – How to Add Font Awesome Icons in Astra?

Astra Pro WP CLI Commands

Astra Pro WP CLI Commands

This is a premium feature available with Astra Pro Addon plugin. To use these Pro features, you need to have the Astra theme along with the Astra Pro Addon installed on your website.

Astra Pro Addon plugin adds support for some WP-CLI commands.

Activate your license of Astra Pro Addon using WP-CLI:

wp brainstormforce license activate astra-addon your-license-key-here

This article will be updated as we add support for more WP CLI Commands. Keep coming back!

Change Woocommerce Out of Stock Text

Change Woocommerce Out of Stock Text

Astra adds a text 「Out Of Stock」 for the WooCommerece products that have 『Stock status』 as out of stock. Below is the screenshot of how the text displays in the front end on the product –

You can change the 「Out Of Stock」 text with any custom text you want, on both the Product Catalog (Shop page) and Single Product pages using filters.

You need to add the following filters to the functions.php file of your Child Theme:

Add the folowing code to change the 「Out Of Stock」 text on the Product Catalog (Shop page):

add_filter( 'astra_woo_shop_out_of_stock_string', 'out_of_stock_callback' );
function out_of_stock_callback( $title ) {
return 'SOLD';
}

Add the folowing code to change the 「Out Of Stock」 text on the Single Product pages:

add_filter( 'woocommerce_get_availability', 'change_out_of_stock_text_woocommerce', 1, 2 );
function change_out_of_stock_text_woocommerce( $availability, $product_to_check ) {
// Change Out of Stock Text
if ( ! $product_to_check->is_in_stock() ) {
$availability['availability'] = __('SOLD', 'woocommerce');
}
return $availability;
}

Both of these codes will replace the 「Out Of Stock」 text with 「SOLD」. You can modify this by replacing the bolded word 「SOLD」 in both codes with your custom text.

If you don』t have your Child Theme installed, please check this article on how to do it. If you are not sure how to add this code, please check this article.

Disable Astra』s Native AMP Functionality

Disable Astra』s Native AMP Functionality

If you want to disable Astra』s integration for AMP, use custom code snippet mentioned below.

Add mentioned filter into child theme』s functions.php file.

// Disable Astra Theme's Native AMP support.
add_filter( 'astra_amp_support', '__return_false' );

Read more about Astra』s AMP integration and other related docs –

Native AMP Support in AstraConfigure AMP Plugin

How to Remove Inline CSS from Astra?

How to Remove Inline CSS from Astra?

The following filter will remove inline CSS generated by the Astra theme and Astra Pro plugin. Paste the following code into child theme』s functions.php file

IMPORTANT NOTE: This filter will remove all the inline CSS added by Astra which will affect the styling of your website.

function astra_force_remove_style() {
add_filter( 'print_styles_array', function($styles) {

// Set styles to remove.
$styles_to_remove = array('astra-theme-css', 'astra-addon-css');
if(is_array($styles) AND count($styles) > 0){
foreach($styles AS $key => $code){
if(in_array($code, $styles_to_remove)){
unset($styles[$key]);
}
}
}
return $styles;
});
}
add_action('wp_enqueue_scripts', 'astra_force_remove_style', 99);