Показват се публикациите с етикет wordpress. Показване на всички публикации
Показват се публикациите с етикет wordpress. Показване на всички публикации

02 април, 2015

Duplicate submenu item in WordPress custom admin menu.

Hi Blogger, long time no see.

Just as a reminder for myself and anyone else searching for the solution of
"how to hide the first submenu of my plugin menu on WordPress":

I read through many articles on stackoverflow and elsewhere about this issue, dated back from 2012 or even 2009, all pointing to the same solution: make the first add_submenu_page $menu_slug the same as the one in add_menu_page (and respectively the same as its own $parent_slug).

Of course this solution does not work anymore (or at least don't work with WordPress 4.1.1).

But I found this post, also dated back from 2012
https://wordpress.org/support/topic/add-menu-page-without-submenu?replies=4
And there is a different suggestion, from apimlott: to use a non-existing capability like this
add_menu_page( "Myplugin", "Myplugin", "nosuchcapability", "Myplugin");
and leave the capability check do it's magic.

And it this works for 4.1.1, yay!

07 януари, 2013

Wordpress MU images got broken.

We recently made a copy of a live site for future development purposes.
Everything went fine, we replaced the references to the new domain in database and the site is operating well except that on the sub-sites (the ones that use /files for uploaded content) all images got broken.

After some investigations we found that the /wp-includes/ms-files.php file (the one that operates as a gateway between the image URL and the actual image location) was serving a BOM characters in the beginning of all images and cutting the last three bytes also.
It turned out that while editing the wp-config.php file for the new database credentials, the editor added the BOM character. We removed it and the images got back.

Credits go to this comment: http://core.trac.wordpress.org/ticket/14730#comment:6 from Sergey Biryukov

04 октомври, 2012

Posts and pages looks weird after domain switch.

Any now and then you are transferring some existing site to a new domain. Or you are just making a demo/test/development copy to another folder. So you follow the best practices and backup all data, alter the database to suit the new domain/folder, create new database, import the tables, altering the wp-config and uploading the files again. Most of the cases this is enough for your new WP installation to work with no problems, but! Sometimes some elements on your site look strange, misplaced or don't show at all. And you start wondering "I've copied everything, why the two installations are different?"

Here is a tip that can guide you. Do you use custom meta fields for the posts? Did you just made a find-and-replace of the old domain/folder with the new ones? Well, then you probably replaced this inside some serialized values of the meta tables also. And now the unserialize returns false because the value is no longer valid. So you have to (manually) recalculate the differences in character lengths and replace the count on every occurrence. Hopefully your database is not so long :)

Oh, and don't forget to freshen the permalinks.

01 март, 2012

WordPress add_rewrite_rule function not working as expected.

Are you using the add_rewrite_rule function to customize your URL/Permalinks? Make sure you use single quotes for the $rewrite parameter, otherwise the $matches[1] is parsed immediately and... will get lost! Took me few hours debugging and searching in the Internet to discover this myself.