Wednesday, June 19, 2013

WordPress: remove admin menu items

There are several well-written WordPress plugins that allow removing and re-ordering admin menu items. However, if you want something quick and simple for your site, the code snippet below may be useful. It removes all menus, except for Dashboard and WooCommerce "Products".

Feel free to modify is as necessary.

► Tip: you can print_r($menu) to see what to keep.


add_action('admin_menu', function () {
 if (current_user_can('administrator')) {
  return;
 }

 /**
  * Keep only specific menu items and remove all others
  */
 global $menu;
 $hMenu = $menu;
 foreach ($hMenu as $nMenuIndex => $hMenuItem) {
  if (in_array($hMenuItem[2], array(
       'index.php',
       'edit.php?post_type=product',
      ))
  ) {
   continue;
  }
  unset($menu[$nMenuIndex]);
 }
}

Tuesday, February 12, 2013

Google keeps your “unnatural links” even after full site de-indexing!

Scenario

History: several years ago, before Panda and Penguin, you made a blog and posted some “made-for-Google” content there, with the only purpose of getting links to your main site.

Our days: you've learned that your spammy blog will cause a penalty, sooner or later, and decided to get rid of it.

Proposed (and failed) Action

Google says (here):
If you wish to remove your content using the URL removal request tool in our Google Webmaster Tools ...
To remove a directory and its contents, or your whole site, you must ensure that the pages you want to remove have been blocked using a robots.txt file.

Indeed, in a very short time, you try the site:my-crappy-blog.com query, and there is no results. Voila, it worked!

But then, you click on the “Links To Your Site” in the Webmaster Tools, and still see all the links, from the site that you have removed!

Just takes time?

You wait...

... forever. Links are there.

What happened?

Continue reading:
Content removed with this tool will be excluded from the Google index for a minimum of 90 days.
... and then what? So, the removal was only temporary?

Google clarifies (here):
Content removed using the URL removal tool will not appear in search results for a minimum of 90 days or until the content has been removed from the Google index. However, if you've updated robots.txt, added meta tags, or password-protected content to prevent it being crawled, the content should naturally have dropped out of our index, and you shouldn't need to worry about it reappearing after 90 days.
What about the links?

Nobody said anything about links! I've been watching the links from a removed site for about 6 months, in the Webmaster Tools.

The cure

Do not remove the site using Webmaster Tools; do not place robots.txt or meta tags.

Instead:

Make sure that Googlebot can crawl the entire site. That means, NO robots.txt!
Remove the CONTENT of the site. Let Google see empty pages, maybe with some text like “This site does not exist anymore. Good-bye!”.

Now, relax and watch your links disappear from the Tools.


P.S. The same applies for "glued" sites (when info:site1 and info:site2 show the same information). After cleaning the content, the sites will be "unglued".

Friday, January 25, 2013

Google Reconsideration Request Form is limited to 5,000 symbols

The reconsideration letter to Google must explain in details what did you do wrong, how did you fix it and why should Google believe that you are not going to make it again.

Do not lie and do not hide anything. Google knows anyway. They want you to show that you also know everything. Do not expect that Google will reply with: "Oh, no, you have also this and that, please fix" - they will never tell you. You must discover and solve all the problems yourself.

I highly recommend you reading PERP: A Free Manual for Google Penalty Recovery before writing your reconsideration letter.

Remember: Panda and Penguin are not manual penalties. Submitting a reconsideration request will not work if you have one of those algorithmic penalties.

Then write as much as you can - but fit it into 5,000 symbols, because that's the submission form's limit.

Good luck!

Wednesday, January 2, 2013

ln -s on Windows? Use mklink for symbolic links !

I needed to make Apache server seeing a folder via a symbolic link - on MS Windows. The standard Windows' shortcuts look like links, but Apache does not see them...

Apparently, there is a way to make REAL symbolic links under Windows. (Must run command prompt as administrator).

For example:

mklink C:\etc\hosts C:\Windows\System32\Drivers\etc\hosts

results in

C:\>dir c:\etc

2013-01-02  21:37    <DIR>          .
2013-01-02  21:37    <DIR>          ..
2013-01-02  21:37    <SYMLINK>      hosts [C:\Windows\System32\Drivers\etc\hosts]


The syntax for folders is:

mklink /D linkName target



Note: do not forget the drive letter (C:), or the link may not work in some situations.

Read more:

http://en.wikipedia.org/wiki/NTFS_symbolic_link

Wednesday, November 28, 2012

One Link SERPs Effect

As of today, Nov.26, 2012, searching Google for abstract art (no quotes) puts wwwARTbyLENA.com to the position #117 *).
I am going to test how placing just one link from a Blogger-based site can change the position. There are no other SEO actions performed on Lena's site at the moment.

Here is the "One Link":

Picture of a painting
Original art by Canadian artist Lena Karpinsky:
http://www.artbylena.com/original-art/abstract-art.html
And some "unique content" for this blog post, written in "Fast ESL Mode" :-)
Some people believe that term "abstract art" mean the same as "modern art" or "contemporary art". Therefore we see phrases like "abstract flowers". What they really want to say is "this is not a realism".
Abstraction is something that can exist only in our mind. Abstract paintings are non-objective. They are just splashes of colors, lights and shades, geometric compositions, and so on. When we look at such artwork, those color splashes are transformed into the images and feelings by our brain. And because our brain is a wonderful thing, we can see how amazing non-objective art is.

*) Checked using http://www.allorank.com/check-position, thanks AlloRank!

► Update Nov.28, 2012
AlloRank reports position #81, which looks like a great improvement, but unfortunately it is not, because during my experiment, I found that that nice tool produces highly unreliable results. I will continue watching it for a few more days, but will not make any conclusion and will look for a better rank checking tool.

Tuesday, November 27, 2012

2 Great Articles on Custom Post Types in WordPress

By Justin Tadlock:
http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress
In WordPress 3.0, we’ll have the capability to easily create and manage content via custom post types. Not only that, but you won’t have to rely on a plugin to do this for you. It can be done via your theme’s functions.php file with a few lines of code.
By Richard Shepherd:
http://blog.teamtreehouse.com/create-your-first-wordpress-custom-post-type
...I think the great thing about WordPress is we can use it in the way we feel it should be used. There might be a different or better way, but there is no wrong way to do something (unless it doesn’t work!).
► Both articles provide a great introduction to the custom post types, with detailed PHP code examples. Custom types allow to associate additional information (fields) with a specific group of WordPress posts, and distinguish those posts from others in the admin interface. Having them, it's possible to extend WordPress to a powerful dabatase application.

Sunday, November 18, 2012

Thesis 2.0 multisite CSS (thesis_do=css)

Note: this is a quick patch to Thesis 2.0.1, not optimized, not approved by the Thesis authors and not tested thoroughly.

Problem:

In the WPMU environment, Thesis CSS link looks like:

...?thesis_do=css&ref=...

instead of "normal" link to a .css file

Details:

The code responsible for that resides in the lib/core/skin/box.php, in class class thesis_stylesheets_link :

'url' => !is_multisite() ? THESIS_USER_SKIN_URL . '/css.css' : site_url("?thesis_do=css&ref=". THESIS_MS_CSS_VAL . time()),

Note that the time() call at the end makes this link not cacheable.

The patch:

1. In the box.php:

public function html() {
global $wpdb;
$styles = $links = array();
$styles['layout'] = array(
'url' => THESIS_USER_SKIN_URL . '/css' . (is_multisite() ? $wpdb->blogid : '') . '.css',

2. In lib/core/skin/css.php

public function write($skin, $custom) {
global $wpdb;
$css = $this->reset() . $this->update(apply_filters('thesis_css', $skin), $custom);
$css = strip_tags($css);
if (is_multisite()) {
update_option('thesis_raw_css', $css);
wp_cache_flush();
$lid = @fopen(THESIS_USER_SKIN . '/css' . $wpdb->blogid . '.css', 'w');
@fwrite($lid, trim($css));
@fclose($lid); 
}