-
Removing same part of the file in Windows
Once upon the time… All right, it was yesterday. I had to clean up some site, than someone build long time ago. There was an image library, it contains hundreds of images. And it is ok, but all of the images contains “image_” prefix. And all of the images are in /images folder. Unnecessary redundancy I though to myself and I decided to remove “image_” prefix for all image files. And I almost open PHP editor to write short script… And then I thought – damn, we’ve got shell here, it’s Windows! So I opened Windows PowerShell and wrote something like this: PS C:\server\sites\old-site\images> get-childitem | foreach { rename-item $_…
-
How to add your custom css or js on admin screen?
How to add your custom CSS or JS on admin screen? Well, it’s pretty easy. We need to hook into admin_enqueue_scripts action and this is the best and only solution. So, let’s write some code: [crayon-670264556309c430988938/] Please note the $hook variable. Thanks to its value you may enqueue your scripts/styles depending on active admin screen. It is important, because you should not enqueue your scripts or styles where it isn’t necessary. Second thing, first conditional is_admin. It’s pretty obvious, but I have to mention it. Do not even hook into admin_enqueue when you are not on admin screen.
-
Get woocommerce random products
Sometimes people asks me how to get N random products from Woocommerce plugin. Well, I heard it isn’t obvious or easy. And still I don’t know why. It is more than easy! We just need to use get_posts function. Simplest function to get N random products (default value is three as you may see in the source code) would look like that: [crayon-6702645563f1f032055072/]
-
Symbolic links – test your themes and plugins
Symbolic links are great feature in Linux/Unix. Mac has this feature even in its GUI. Many of you knows that Windows can handle symbolic links too. But there are some people that doesn’t know about this feature or doesn’t care because they didn’t think about its power. Of course I’m not gonna to write about symbolic links just for symbolic links. We will use it in real life, for our projects. First of all, I will share one of my computers configuration with you. My first hard drive is 960GB SSD. I use it for my operating system (Windows 7 Pro), programs and local server. Server is stored in C:\server\.…
-
Hey, admin, hide your login!
I bet, that you, as a WordPress developer, knows very well that using “admin” for your administrator account isn’t very clever. Or “administrator”. Or something like that. Once I saw “root”. Even WordPress installer will let you know that. Use something different. Maybe “top-secret-user”. It is good thing, that is true. Why we should avoid that? Because attacker may discover your administrator account login and may use it (in some top secret magical way) to attack your site. It isn’t a joke, it is a possibility. So, everybody should knows that and apply this to their sites. But… There is a small trick about that… Many sites may reveal your…
-
Happy New Year!
Happy new year, all WordPress, PHP, etc. etc. users and developers! It’s my first new year message and I’m not sure what I should write. Excluding happy new year message itself, it’s obvious, of course. Well, I think a bit about WordPress future. Very recently we got WordPress 4.7 version, it’s pretty nice mile stone, I think we all like it. WordPress is superb, powerful CMS, do we need more? What would road-map for WordPress looks like? Of course I use WordPress 4.8 alpha on my local machine (you may do this as well, it is appreciated), but where are we going? First thought was – whenever we will go,…
-
WordPress Toolbar a.k.a. Admin Bar
First things first. Why WordPress Toolbar a.k.a. Admin Bar? Well, a lot of people knows Toolbar as Admin Bar. Still. To be honest, it was Admin Bar. It was Admin Bar in WordPress 3.2 (released July 4, 2011) and previous. Even more, for backward compatibility, WordPress class for Toolbar is named WP_Admin_Bar. However, since WordPress 3.3 (released December 12, 2011) it is Toolbar and please remember it. To be honest, I have to remember it, too. All right, to the point. WordPress Toolbar. Nice feature. Very useful. And great. And even more – it is customizable! And we will learn a few basic tricks, how to deal with it. It…
-
WordPress plugins repository
A few days ago I mentioned about my new plugins. Two of them are in the official WordPress plugins repository. So, my counter is three now. I won’t delete those plugins on github, if you use this source, don’t worry. Posts about those plugins (with github links): Post/Page specific custom CSS Queen Inspirations WordPress repository links: Post/Page specific custom CSS Queen Inspirations I also updated my good-old plugin Google Analytics Head (icon, banner and screenshot). All of my WordPress hosted plugins.
-
WordPress admin buttons once again
I just wrote small nice plugin to add custom CSS code to certain post/page. So I thought I may use it to show you my admin-like button styles (I mentioned it a few days ago – WordPress admin buttons). I’ve added static image to that post but here you are with brand new preview live! Primary Primary Darkgreen Darkgreen Forestgreen Forestgreen Green Green Lime Lime Limegreen Limegreen Seagreen Seagreen Mediumseagreen Mediumseagreen Springgreen Springgreen Mediumspringgreen Mediumspringgreen Darksalmon Darksalmon Mediumaquamarine Mediumaquamarine Coral Coral Orangered Orangered Turquoise Turquoise Lightseagreen Lightseagreen Mediumturquoise Mediumturquoise Cyan Aqua Cyan Aqua Darkcyan Darkcyan Teal Teal Darkturquoise Darkturquoise Deepskyblue Deepskyblue Sienna Sienna Steelblue Steelblue Dodgerblue Dodgerblue Cornflowerblue Cornflowerblue Royalblue…
-
Post/Page specific custom CSS
Hi, we’ve got brand new plugin for you! Post Page specific custom CSS will allow you to add cascade stylesheet to specific posts/pages. It will give you special area in the post/page edit field to attach your CSS. It will also let you decide if this CSS has to be added in multi-page/post view (like archive posts) or only in a single view. Our new plugin is available on github.