Archive

Posts Tagged ‘Uniform Resource Locator’

Understanding Regular Expression

October 22, 2013 Leave a comment

Regular expression is the most important part in form validations and it is widely used for search, replace and web crawling systems. If you want to write a selector engine (used to find elements in a DOM), it should be possible with Regular Expressions. In this post we explained few tips that how to understand and write the Regular Expression in simple way.

Will discuss about basic regular expression in three stages.

Stage 1

Symbol             Explanation

^                       Start of string
$                       End of string
.                        Any single character
+                       One or more character
\                        Escape Special characters
?                       Zero or more characters

Input exactly match with “abc”

var A = /^abc$/;

Input start with “abc”

var B = /^abc/;

Input end with “abc”

var C = /abc$/;

Input “abc” and one character allowed Eg. abcx

var D = /^abc.$/;

Input  “abc” and more than one character allowed Eg. abcxy

var E = /^abc.+$/;

Input exactly match with “abc.def”, cause (.) escaped

var F = /^abc\.def$/;

Passes any characters followed or not by “abc” Eg. abcxyz12….

var G = /^abc.+?$/

Stage 2

Char                Group Explanation

[abc]                 Should match any single of character
[^abc]               Should not match any single character
[a-zA-Z0-9]      Characters range lowercase a-z, uppercase A-Z and numbers
[a-z-._]              Match against character range lowercase a-z and ._- special chats
(.*?)                  Capture everything enclosed with brackets
(com|info)         Input should be “com” or “info”
{2}                   Exactly two characters
{2,3}                Minimum 2 characters and Maximum 3 characters
{2,}                  More than 2 characters

Put together all in one URL validation.

var URL = /^(http|https|ftp):\/\/(www+\.)?[a-zA-Z0-9]+\.([a-zA-Z]{2,4})\/?/;

URL.test(“http://selvabalaji.com);                      // pass
URL.test(“http://www.selvabalaji.com”);            // pass
URL.test(“https://selvabalaji.com/”);                   // pass
URL.test(“http://selvabalaji.com/index.php”);    // pass

Stage 3

Short Form     Equivalent              Explanation

\d                      [0-9]                         Any numbers
\D                     [^0-9]                       Any non-digits
\w                     [a-zA-Z0-9_]            Characters,numbers and underscore
\W                    [^a-zA-Z0-9_]          Except any characters, numbers and underscore
\s                       –                                White space character
\S                      –                                Non white space character

 

var number = /^(\+\d{2,4})?\s?(\d{10})$/;  // validating phone number

number.test(1111111111);           //pass
number.test(+111111111111);     //pass
number.test(+11 1111111111);    //pass
number.test(11111111);               //Fail

 

7 common mistakes in Magento SEO

October 15, 2013 Leave a comment

1. Homepage title “home”

If I had a dollar for every Magento store out there I’ve seen with a homepage title “home” I’d be a rich man. The homepage is usually a CMS page. Go in there and change the title of the page into something more suitable such as “Blue Widgets Online Store – Example.com”.

2. Using “default description” field

System > Configuration > General > Design > HTML Head > Default description – Leave this blank or you’ll have such a mess of duplicate descriptions on your store that don’t really describe the given URL that it will be unbelievable. Also, please make sure your meta keywords are not “magento, magento commerce” etc.

3. Not turning on rel=canonical

Save yourself from lots of duplicate content issues. Turn canonicals on for both products and categories.

4. Logo title and/or alt “Magento Commerce” 

Logo, usually in the top left of your website. Don’t have it say “Magento Commerce”. I’ve seen that a lot of times.

5. Forgetting to turn meta robots to “index, follow” and remove robots.txt disallow after a move from staging/dev site to the live site

System > Configuration > General > Design > HTML Head > Default robots “INDEX, FOLLOW”.

Sometimes people leave this as noindex, nofollow on dev server and forget to change it when they migrate to the live server.

6. Having a default layered navigation

Layered navigation is a hell for the SEO.

7. Building a sitemap with sample products and sample categories

I’ve seen this one as well. Check what’s in your sitemap.xml before you submit it to Google. No sample products please! :)

Magento Remove index.php from url

October 15, 2013 6 comments

Magento by default added the index,php in url .So,As per the SEO page will not get indexed properly SO here we have try to Remove index.php in url from both End Access Magento URL without index.php
For example:
http://domain.com/index.php/category to
http://domain.com/categoryThen Just follow steps
1) Login to admin section by using the URL http://domain.com/index.php/admin
2) then go to “System >> Configuration >>Web >> Search Engines Optimization” Use Web Server Rewrites : YES
3) Go to “System >> Configuration >>Web >>Secure” Use secure URL Frontend: YES
4)Then create the .htaccess file under your the magento installed folder.

If the magento installed under document root ( /home/username/public_html) then add follogig rules into .htaccess file

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

and If the magento installed under /shop or directory then add the following rules into ” /home/username/public_html/shop/.htaccess ” file.

RewriteEngine On

RewriteBase /shop/

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /shop/index.php [L]Thst's it just refresh the cache .Hope this will help!

 

10 More Useful WordPress Code Snippets For Your Blog

July 6, 2012 1 comment

WordPress is the best open source sofware which is completely free to use.The advantage of being open source for a software is that developers can see its codes an write plugins to make it more functional.And also developers add or change small piece of codes especially in functions.php file to unleash the power of your favorite blogging engine.

In today’s post we are again sharing wordpress code snippets.I think you will find a useful wordpress code snippet for your wordpress blog.

You may also take a look at our past wordpress theme collections;

htaccess Gzip Compression

Add the following code in your .htaccess file.Gzip will drastically reduce HTTP response time.

# BEGIN GZIP

AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript

# END GZIP

Instructions:
Just add this to your .htaccess file. Gzip will drastically reduce HTTP response time.

How to Remove the Width and Height Attributes From WP Image Uploader

add_filter( ‘post_thumbnail_html’, ‘remove_width_attribute’, 10 );
add_filter( ‘image_send_to_editor’, ‘remove_width_attribute’, 10 );

function remove_width_attribute( $html ) {
$html = preg_replace( ‘/(width|height)=\”\d*\”\s/’, “”, $html );
return $html;
}

If you upload images via the WordPress image uploader and insert it into your post, it will include the image width and height attribute in the html tag. Here’s what it will look like.

In most cases, this is absolutely alright. However, if you are using a responsive theme or are dealing with responsive web design, the “width” and “height” attribute will be a major roadblock that you need to get rid of.

Here’s how you can do it.

1. Open your theme’s functions.php file.

2. Copy and paste the following code:
add_filter( ‘post_thumbnail_html’, ‘remove_width_attribute’, 10 );
add_filter( ‘image_send_to_editor’, ‘remove_width_attribute’, 10 );

function remove_width_attribute( $html ) {
$html = preg_replace( ‘/(width|height)=\”\d*\”\s/’, “”, $html );
return $html;
}

3. Save the changes.

That’s it. Next time when you insert image into the post via the WP image uploader, the width and height attribute will no longer be there.

How to Change the Font in HTML Editor In WordPress 3.3

add_action( ‘admin_head-post.php’, ‘wpdb_fix_html_editor_font’ );
add_action( ‘admin_head-post-new.php’, ‘wpdb_fix_html_editor_font’ );

function wpdb_fix_html_editor_font() { ?>

<!–?php }

Add/remove Contact Info Fields

To add or remove fields from this section, just add the following to your functions.php.

Login with Username or Email Address

Adding this snippet to the functions.php of your wordpress theme will let users login using an email address or a username. The second snippet will change the text on the login page from “username” to “username / email” but feel free to change the login text to anything you would like.

function login_with_email_address($username) {
$user = get_user_by(’email’,$username);
if(!empty($user->user_login))
$username = $user->user_login;
return $username;
}
add_action(‘wp_authenticate’,’login_with_email_address’);
function change_username_wps_text($text){
if(in_array($GLOBALS[‘pagenow’], array(‘wp-login.php’))){
if ($text == ‘Username’){$text = ‘Username / Email’;}
}
return $text;
}
add_filter( ‘gettext’, ‘change_username_wps_text’ );

Add PayPal Donate Button

Add this snippet to the functions.php to add ‘Donate’ Button on your WordPress Website

// paypal donate button
function cwc_donate_shortcode( $atts ) {
extract(shortcode_atts(array(
‘text’ => ‘Make a donation’,
‘account’ => ‘REPLACE ME’,
‘for’ => ”,
), $atts));
global $post;
if (!$for) $for = str_replace(” “,”+”,$post->post_title);
return ‘‘.$text.’‘;
}
add_shortcode(‘donate’, ‘cwc_donate_shortcode’);

DownloadUrlContent from other site using Curl Method

March 27, 2012 Leave a comment

function DownloadUrlContent($Url,$fields=array(”)){
if (!function_exists(‘curl_init’)){
die(‘CURL is not installed!’);
}
$ch        =    curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_REFERER, “http://www.google.com/&#8221;);
curl_setopt($ch, CURLOPT_USERAGENT,’Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110614 Firefox/3.6.18′);
curl_setopt($ch, CURLOPT_HTTPHEADER,array(‘Expect:’));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
if(count($fields)>0){
foreach($fields as $key=>$value) { @$fields_string .= trim($key).’=’.trim($value).’&’; }

rtrim(trim($fields_string),’&’);
$fields_string    =    substr($fields_string,0,strlen($fields_string)-1);

curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
}
$output = curl_exec($ch);
curl_close($ch);
return $output;
}

Share API

March 27, 2012 Leave a comment

Share API

Reading and Creating Shares

Use the Share API to have a member share content with their network or with all of LinkedIn. This can be a simple short text update, similar to Twitter.  Or a URL with a title and optional photo. Or both.

You can also forward the shared content to Twitter and reshare another member’s share.

This feature replaces the deprecated Status Update API and fields.

Adding New Shares

To add a new share, you markup the content in XML and issue a  HTTP POST to the following URL:

URL

To have LinkedIn pass the status message along to a member’s tethered Twitter account, if they have one, modify the URL to include a query string of twitter-post=true.

Fields for the XML Body

Node Parent Node Required? Value Notes
share Yes Child nodes of share Parent node for all share content
comment share Conditional Text of member’s comment. (Similar to deprecated current-status field.) Post must contain comment and/or (content/title and content/submitted-url). Max length is 700 characters.
content share Conditional Parent node for information on shared document
title share/content Conditional Title of shared document Post must contain comment and/or (content/title and content/submitted-url). Max length is 200 characters.
submitted-url share/content Conditional URL for shared content Post must contain comment and/or (content/title and content/submitted-url).
submitted-image-url share/content Optional URL for image of shared content Invalid without (content/title and content/submitted-url).
description share/content Option Description of shared content Max length of 256 characters.
visibility share Yes Parent node for visibility information
code share/visibility Yes One of anyone: all members or connections-only: connections only.

Sample XML

Here is an example XML document:

<!--?xml version="1.0" encoding="UTF-8"?> 83% of employers will use social media to hire: 78% LinkedIn, 55% Facebook, 45% Twitter [SF Biz Times] -->http://bit.ly/cCpeOD Survey: Social networks top hiring tool - San Francisco Business Times http://sanfrancisco.bizjournals.com/sanfrancisco/stories/2010/06/28/daily34.html</submitted-url> <submitted-image-url>http://images.bizjournals.com/travel/cityscapes/thumbs/sm_sanfrancisco.jpg</submitted-image-url> </content> <visibility> <code>anyone</code> </visibility> </share>

Response

Returns 201 Created on success. It will also provide a Location HTTP header with a URL for the created resource. However, at this time, you cannot retrieve the Share from that location. It’s there for future compatibility.

Resharing An Existing Share

When a member does a reshare, they can pass along a previously shared item to their network. This can either be as-is, or they can annotate the share to provide their own thoughts. The process is similar to creating a new share, but you provide an attribution/id value instead of a content block.

You can only reshare a share with a content block. If this block is empty, you will get a 400 error saying “Specified share {s28311617} has no content”.

Read Retrieving Share Information for instructions to retrieve these value using the API.

URL

Fields for the XML Body

Node Parent Node Required? Value Notes
share Yes Child nodes of share Parent node for all share content
comment share No Text of member’s comment. (Similar to deprecated current-status field.) Max length is 700 characters.
attribution share Yes Parent node for information on reshared document
id share/attribution/share Yes id of reshared document Currently in the format of s12345678, so is not guaranteed to be an integer.Post must contain id if it does not contain content and id must be from a share with a content block.
visibility share Yes Parent node for visibility information
code share/visibility Yes One of anyone: all members or connections-only: connections only.

Sample XML

Here is an example XML document:

<!--?xml version="1.0" encoding="UTF-8"?> Check out this story! I can't believe it. s24681357 -->connections-only

Response

Returns 201 Created on success. It will also provide a Location HTTP header with a URL for the created resource. However, at this time, you cannot retrieve the Share from that location. It’s there for future compatibility.

Retrieving Share Information

A particular member’s current share is detailed in their Profile API, so you can get a member’s current share by requesting:

Use the ~, id, or public profile URL to identify the user.

To retrieve a stream of shares for the member or their member first degree network, use the Get Network Updates API resource requesting the SHAR update type.

For the specified member also use a query parameter of scope=self:

Omit the scope for their first degree network:

You will receive:

<!--?xml version="1.0" encoding="UTF-8"?> s12345678 1279577156654 83% of employers will use social media to hire: 78% LinkedIn, 55% Facebook, 45% Twitter [SF Biz Times] -->http://bit.ly/cCpeOD</comment> <content> <id>123456789</id> <title>Survey: Social networks top hiring tool - San Francisco Business Times</title> <submitted-url>http://sanfrancisco.bizjournals.com/sanfrancisco/stories/2010/06/28/daily34.html</submitted-url> <shortened-url>lnkd.in/abc123</shortened-url> <submitted-image-url>http://images.bizjournals.com/travel/cityscapes/thumbs/sm_sanfrancisco.jpg</submitted-image-url> <thumbnail-url>http://media.linkedin.com/media-proxy/ext...</thumbnail-url> </content> <visibility> <code>anyone</code> </visibility> <source> <service-provider> <name>LINKEDIN</name> </service-provider> <application> <name>Your Cool App</name> </application> </source> <current-share>

Fields for the XML Body

Beyond the fields listed above, you also receive:

Node Parent Node Value Notes
id share Identifier for share.
timestamp share Time of posting in miliseconds since UTC. (Divide this number by 1000 to get the standard Unix timestamp.)
shortened-url share/content Short version of the submitted-url. If the submitted-url is generated via a URL shortener, this is the original URL and the submitted URL is the expanded version. Otherwise, this is a LinkedIn generated short URL using http://lnkd.in/.
resolved-url share/content The submitted-url unwound from any URL shortener services.
author share/attribution/share Information on the author of the original shared item. Only appears when retrieving a reshare, not an original share.
name share/source/service-provider Platform where the share came from, such as LINKEDIN or  TWITTER.
name share/source/application Application where the share came from, such as the name of your application.

Changing Backgrounds with body class()

October 25, 2011 Leave a comment

The body_class() WordPress function attaches a list of classes to the <body> element according to what type of page is being displayed.

These classes can be used — in conjunction with your theme’s stylesheet — to display different backgrounds on different pages.

Let’s assume your header.php template file contains:

<body <?php body_class(); ?>>

And your current CSS for the background looks like:

body {background:#fff url(images/bg.jpg);}

 

In a single post, your body tag would look like:

postid-188 single-format-standard logged-in admin-bar">

A category page could have:

<body class="archive category category-cat-a category-9 logged-in admin-bar">

whilst a tag page might generate:

tag-tag1 tag-92 logged-in admin-bar">

The CSS

You can add some new rules to your theme’s CSS to target specific backgrounds at particular pages.

Default Single Post

body.single {background:#ccc url(images/bg-single.jpg);}

Single Post with an ID of 188

body.postid-188 {background:#999 url(images/bg-special.jpg);}

Default Category Background

body.category {background:#eee url(images/bg-cat.jpg);}

Category A Only

body.category-cat-a {background:#ddd url(images/bg-cat-a.jpg);}

The possibilities are almost endless.

You can find a full list of the classes generated by the body_class() function in the WordPress Codex.

Headers Already Sent

October 25, 2011 1 comment
WordPress 2.5 Czech administration

Image via Wikipedia

Headers Already Sent

The most common reasons for seeing this error message in your WordPress site are spaces, new lines, or invisible characters before an opening <!--?php tag or after a closing ?> tag in one of the site’s scripts. But, in order to fix the problem, you have to know which file is causing the problem.

Step 1: Interpreting the Error Message

All of the relevant information is normally given in the first part of the message — the ... output started at... part.

Example 1

Warning: Cannot modify header information - headers already sent by (output started at /path/wp-content/plugins/foobar/foobar.php:8) in /path/wp-comments-post.php on line 55

In this example, the problem is in the foobar.php file of the Foobar plugin.

Example 2

Warning: Cannot modify header information - headers already sent by (output started at /path/wp-content/themes/wibble/functions.php:11) in /path/wp-includes/pluggable.php on line 850

Here, the problem is in functions.php file within the Wibble theme

Example 3

Warning: Cannot modify header information - headers already sent by (output started at /path/blog/wp-config.php:82) in /path/blog/wp-login.php on line 42

The problem is at line 82 of wp-config.php.

Step 2: Fixing the Problem

Example 1: A Plugin

The easiest option here is to simply delete the plugin and look for an alternative one. If you cannot access your WordPress dashboard, reset the plugins folder. Then re-install your plugins — with the exception of the one that caused the problem.

Example 2: The Theme

If you are not comfortable with editing PHP files, then you may want to look at installing another theme. If you cannot access your WordPress dashboard, switch to the default theme by renaming your current theme’s folder in wp-content/themes and adding “-old” to the end of the folder name using FTP or whatever file management application your host provides. This should allow you back into your dashboard where you can download another theme.

If you are comfortable with editing PHP files, then download the file mentioned in the error message (functions.php in the Example 2) and follow the instructions for removing invisible characters in a file.

Example 3: wp-config.php

  1. Download wp-config.php from your site’s main WordPress folder.
  2. Open the file in a plain text editor.
  3. Check that the very first characters are <?php
  4. If the very last characters are ?>, remove them.
  5. Check that there are no invisible characters in the file.
  6. Re-upload the amended file.

Removing Invisible Characters in a File

  1. Open the file in a plain text editor.
  2. Place the cursor before the first character in the file.
  3. Press the BACKSPACE key & keep it pressed for a count of 10.
  4. Place the cursor after the last character in the file.
  5. Now press the DELETE key on your computer & keep it pressed for a count of 10.
  6. Save the file without pressing any other key.
  7. Check the encoding of the file. Do not encode files as UTF-8 with BOM. The BOM will be seen as a character.

October 20, 2011 Leave a comment
Php

Image via Wikipedia

I’ve run into an error using an image resizing script by Victor Teixeira, which has worked wonderfully until I noticed an issue related to using the Featured Image uploader. If I a Featured Image, then attempt to re-insert a different image in its place I get this error:

function vt_resize( $attach_id = null, $img_url = null, $width, $height, $crop = false ) {

// this is an attachment, so we have the ID
if ( $attach_id ) {

    $image_src = wp_get_attachment_image_src( $attach_id, 'full' );
    $file_path = get_attached_file( $attach_id );

// this is not an attachment, let's use the image url
} else if ( $img_url ) {

    $file_path = parse_url( $img_url );
    $file_path = $_SERVER['DOCUMENT_ROOT'] . $file_path['path'];

    //$file_path = ltrim( $file_path['path'], '/' );
    //$file_path = rtrim( ABSPATH, '/' ).$file_path['path'];

    $orig_size = getimagesize( $file_path );

    $image_src[0] = $img_url;
    $image_src[1] = $orig_size[0];
    $image_src[2] = $orig_size[1];
}

$file_info = pathinfo( $file_path );
$extension = '.'. $file_info['extension'];

// the image path without the extension
$no_ext_path = $file_info['dirname'].'/'.$file_info['filename'];

$cropped_img_path = $no_ext_path.'-'.$width.'x'.$height.$extension;

// checking if the file size is larger than the target size
// if it is smaller or the same size, stop right here and return
if ( $image_src[1] > $width || $image_src[2] > $height ) {

    // the file is larger, check if the resized version already exists (for $crop = true but will also work for $crop = false if the sizes match)
    if ( file_exists( $cropped_img_path ) ) {

        $cropped_img_url = str_replace( basename( $image_src[0] ), basename( $cropped_img_path ), $image_src[0] );

        $vt_image = array (
            'url' => $cropped_img_url,
            'width' => $width,
            'height' => $height
        );

        return $vt_image;
    }

    // $crop = false
    if ( $crop == false ) {

        // calculate the size proportionaly
        $proportional_size = wp_constrain_dimensions( $image_src[1], $image_src[2], $width, $height );
        $resized_img_path = $no_ext_path.'-'.$proportional_size[0].'x'.$proportional_size[1].$extension;            

        // checking if the file already exists
        if ( file_exists( $resized_img_path ) ) {

            $resized_img_url = str_replace( basename( $image_src[0] ), basename( $resized_img_path ), $image_src[0] );

            $vt_image = array (
                'url' => $resized_img_url,
                'width' => $proportional_size[0],
                'height' => $proportional_size[1]
            );

            return $vt_image;
        }
    }

    // no cache files - let's finally resize it
    $new_img_path = image_resize( $file_path, $width, $height, $crop );
    $new_img_size = getimagesize( $new_img_path );
    $new_img = str_replace( basename( $image_src[0] ), basename( $new_img_path ), $image_src[0] );

    // resized output
    $vt_image = array (
        'url' => $new_img,
        'width' => $new_img_size[0],
        'height' => $new_img_size[1]
    );

    return $vt_image;
}

// default output - without resizing
$vt_image = array (
    'url' => $image_src[0],
    'width' => $image_src[1],
    'height' => $image_src[2]
);

return $vt_image;
}

Quick tip: paths and URLs in WordPress

September 8, 2010 Leave a comment
Image representing WordPress as depicted in Cr...

Image via CrunchBase

The direct reason for this was one of their code examples and the authors apparent incomplete knowledge of the WordPress API‘s most basic functions and constants. In that example, he does the following:
define(
‘MY_WORDPRESS_FOLDER’,
$_SERVER[‘DOCUMENT_ROOT’]
);
define(
‘MY_THEME_FOLDER’,
str_replace(“”,’/’,dirname(__FILE__))
);
define(
‘MY_THEME_PATH’,
‘/’ . substr(
MY_THEME_FOLDER,
stripos(MY_THEME_FOLDER,’wp-content’)
That annoyed me, quite a bit. Why? Well because if people write articles about stuff like custom write panels, I expect them to know a bit about the basics of the WordPress API. And well, the WordPress API has constants and functions for these things. So let me introduce you to them in the same order as the author of the articles did his defines above:

ABSPATH constant

Not only is their method inconvenient, it’s wrong for a lot of installs. You see, some people install WordPress in a subdirectory, and depending on what you need, there are two different paths you might need. ABSPATH is a constant that always returns the home of WordPress. So if WordPress is in the wp/ subdirectory, it would give you something like: /home/username/public_html/wp/. If WordPress were installed in the root, it would just return /home/username/public_html/. Now I don’t know how they’re using it, as it’s not used in this particular article, but they’d have to be very cautious with that.

TEMPLATEPATH constant

The second two things they’re doing are possibly even weirder. First they define a constant MY_THEME_FOLDER, which is basically the path to the current theme. WordPress has a very convenient constant for that: TEMPLATEPATH. Since they’re using it in an include, that’s probably what they need. Would save about 4 lines of code. Note that what they call a “folder” is actually a path.

get_template_directory_uri()

This is were they really go wrong. You see, they define a constant MY_THEME_PATH, and then use it as a URL in a call to wp_enqueue_style(), in other words: to enqueue a style sheet. Now paths and URLs are different animals altogether, and they don’t mix well. Take this example:
1 My blog is installed in a subdirectory /wp/
2 Because of that MY_THEME_FOLDER has been defined as follows:
/home/user/public_html/wp/wp-content/themes/example-theme
3 The code that sets MY_THEME_PATH turns that into:
/wp-content/themes/example-theme
4 The stylesheet is now included with the following path:
/wp-content/themes/example-theme/custom/book_panel.css
5 This causes a 404 (file not found error) because that directory simply doesn’t exist! It should have been:
/wp/wp-content/themes/example-theme/custom/book_panel.css
The proper way of doing the enqueue would thus have been the following:
wp_enqueue_style(
‘my_meta_css’,
get_template_directory_uri(). ‘/custom/book_panel.css’
);

Conclusion

I hope you understand why this annoys me. This is exactly the kind of coding that gives WordPress coders out there a bad name, as 5 – 10% of people out there trying this will not get it to work. If you want to prevent from making such mistakes, there’s plenty of resources to learn about these things, or look them up. Two starting points would be the codex and my own cross reference of the WordPress source along with its very convenient WordPress source search function.