CORS policy: No ‘Access-Control-Allow-Origin’

Font from origin domain.dev has been blocked… (CORS and browsersync)

If you are getting issue fonts are blocked in web client CORS then below code will help you. Use the code in .htaccess file and problem will be resolved 🙂
# Allow access from all domains for webfonts.
<IfModule mod_headers.c>
<FilesMatch “\.(ttf|ttc|otf|eot|woff|woff2|font.css|css)$”>
Header set Access-Control-Allow-Origin “*”
</FilesMatch>
</IfModule>

Fix 404 error in WordPress category / tag page

Sometimes, especially after switching themes, WordPress will generate 404 errors on the category and tag pages. There might be multiple reasons – and also multiple solutions – to this, here is simple solution and it will fix the issue

Go to your WordPress backend, click Settings, click Permalinks. Make sure the category base is “category” and the tag base is “tag” (unless you have some VERY weird special settings) and simply press the “save changes” button. Even if nothing has changed, clicking the button will probably make your category and tag pages work again now.

Oh, Finally Don’t forget to clear the cache…. 🙂

 

Fix wordpress post 404 error

WordPress is fantastic CMS. Most of the world love it feature and flexibility. I am always try to recommend my clients to use this. Sometimes wordpress users face common problems and one of them in posts 404 error. Today we will learn how we can fix this issue.

This is the simple setting we can do fix this issue easy way.

Go to Settings » Permalinks, and simply click on Save Changes button. This will update your permalinks settings and flush rewrite rules. In most cases this solution fixes theWordPress posts 404 error. However, if it does not work for you, then you probably need to update your .htaccess file manually.

Login to your server using FTP, and modify the .htaccess file which is located in root folder. The easiest thing you can do is to temporarily make the file writeable by changing the permissions to 644.  You can should manually add this code if that is not alreay in in .htaccess file. If .htaccess file not available then you must upload this file.

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

Redirect all url to https

If you have a secure certificate (SSL) on your website, you can automatically redirect visitors to the secured (HTTPS) version of your website to make sure their information is protected.

Using the following code in your .htaccess file automatically redirects visitors to the HTTPS version of your site:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

If you have an existing .htaccess file:

  • Do not duplicate RewriteEngine On.
  • Make sure the lines beginning RewriteCond and RewriteRule immediately follow the already-existing RewriteEngine On.

How To Create WordPress Shortcodes

WordPress introduced the shortcode API in version 2.5. Shortcodes are now used by a large number of WordPress plugins to allow users to add content to their posts and pages. All of us have probably used them at one time or another. They usually come bundled with plugins, or even themes, and what they do is watch for when you insert something inside square brackets then replace that with some other content; it could be a simple sentence or it could be a massive PHP function, it all depends on what you instructed WordPress to do.

The shortcode API allows you to create your own shortcodes by adding functions to your theme functions.php template (this is located at www.yourwebsite.com/wp-content/themes/yourtheme/).

In addition to creating your own shortcodes, WordPress also includes five default shortcodes with the WordPress core:
audio – Allows you to embed audio files.
caption – Allows you to wrap captions around content. It is commonly used with images.
embed – Allows you to embed a wide range of content such as video, audio and tweets.
gallery – Allows you to insert image galleries.
video – Allows you to embed video files.

In this article we will create some simple WordPress shortcodes to help you create any functionality you like.

A Basic Example

In our first example we want to create a shortcode that will create some “custom text” every time we type [spin2win] into the editor. First we need to create the callback function that will return the “custom text”

function spin2win_func() {
return “I am new shortcode text”;
}

Next we need to add this shortcode to WordPress using the add_shortcode function in either our functions.php file

add_shortcode( ‘spin2win’, ‘spin2win_func’ );

So the full code would be like this :

function spin2win_func() {
return “I am new shortcode text”;
}
add_shortcode( ‘spin2win’, ‘spin2win_func’ );

Note : spin2win_func and spin2win can be any name.

Creating a Shortcode With Attributes

Attributes can expand the functionality of shortcodes by allowing you to pass data through your shortcodes.

When WordPress encounters this we want a function that will insert an image. It needs to read the width and height attributes

function get_images($atts) {
extract(shortcode_atts(array(
‘width’ => 250,
‘height’ => 180,
), $atts));
return ‘‘;
}

add_shortcode(‘getpics’, ‘get_images’);

That’s all 🙂

Media query for large screen

Here is media query for large screen. You can apply the breakpoints and enjoy the work.

@media screen and (min-width: 1400px) {

}
@media screen and (min-width: 1600px) {

}
@media screen and (min-width: 1900px) {

}

Settings defined in website scopes are ignored in magento2

Today I will show you how you can fix the Settings defined in website scopes are ignored.

This is a core bug in 2.1.3 – https://github.com/magento/magento2/issues/7943

The change you need to make is to vendor/magento/module-store/Model/Config/Processor/Fallback.php

Change this

/**
* Retrieve Website Config
*
* @param array $websites
* @param int $id
* @return array
*/
private function getWebsiteConfig(array $websites, $id)
{
foreach ($this->websiteData as $website) {
if ($website[‘website_id’] == $id) {
$code = $website[‘website_id’];
return isset($websites[$code]) ? $websites[$code] : [];
}
}
return [];
}
To

/**
* Retrieve Website Config
*
* @param array $websites
* @param int $id
* @return array
*/
private function getWebsiteConfig(array $websites, $id)
{
foreach ($this->websiteData as $website) {
if ($website[‘website_id’] == $id) {
$code = $website[‘code’];
return isset($websites[$code]) ? $websites[$code] : [];
}
}
return [];
}

Note the line

$code = $website[‘code’];

Enable error reporting in joomla

Sometime is not easy to find the site issues. So we must have to enable the error reporting while in development. Joomla uses PHP and when PHP has problems, it reports them to you.

Here is short tutorial for enable error reporting in joomla.

1- Go to Site > Global Configuration > Server > Error Reporting.
2- You have five choices: System Default: this allows error reporting to be determined by the php.ini file on your server. Development will show all error reporting.

System Default this allows error reporting to be determined by the php.ini file on your server.
None will disable all error reporting.
Simple will show Errors and Warnings but won’t show Notices.
Maximum will show Errors, Warnings and Notices.
Development will literally overwhelm you with feedback. If you’re not a developer, please don’t use this option.

 

Disble error reporting in joomla

Sometime is not easy to find the site issues. So we must have to enable the error reporting while in development. Joomla uses PHP and when PHP has problems, it reports them to you. However, often these errors will appear on your site and will be visible to visitors. So we must have to disable theme.

Here is short tutorial for enable or disable error reporting in joomla.

1- Go to Site > Global Configuration > Server > Error Reporting.
2- You have five choices: System Default: this allows error reporting to be determined by the php.ini file on your server. None will disable all error reporting.

System Default this allows error reporting to be determined by the php.ini file on your server.
None will disable all error reporting.
Simple will show Errors and Warnings but won’t show Notices.
Maximum will show Errors, Warnings and Notices.
Development will literally overwhelm you with feedback. If you’re not a developer, please don’t use this option.

How to change continue reading link text in wordpress

How to change continue reading link text in wordpress. In this tutorial I will show you how you can change the “continue reading” text in wordpress. If you want to modify continue reading link with Read more , you can use this function in your functions.php file.

function my_code_excerpt_more( $more ) {
return ‘ ‘ . __(‘Read More’, ‘your-text-domain’) . ‘‘;
}
add_filter( ‘excerpt_more’, ‘my_code_excerpt_more’ );

May be your theme does have another text except “continue reading”, so this trick also will work for those.