-
Using jQuery UI CSS in admin screen
I work on new plugin and I need jQuery UI in admin screen. Well, it’s a common situation. Besides the javascript, I also need jQuery UI stylesheet. How to include proper CSS into your WordPress? It’s not that hard. First, we need to include jQuery and jQuery UI. As an example, we will also use jQuery UI Tabs. Normally we may use Google APIs, but while we are in WordPress environment, we should use jQuery provided. So, let’s write some class: [crayon-67a8119794bc6401958007/] So, what we’ve got here? This code will include jQuery, jQuery UI, jQuery UI Tabs (because those are our dependencies) and plugin.js – our main javascript file located…
-
WordPress 4.7.2
New version of WordPress (4.7.2) is of course security release and all your WordPress instances should update automatically. This version fixes three issues. First issue is about XSS vulnerability in the posts list table. This is most important fix. Second fix is about unsafe queries (it isn’t WordPress core error but it may be exploited with some unsafe plugins). Third fix is about showing user interface for assigning taxonomies in Press This for users who has no permission to view this. Please remember, you should always have WordPress auto-update enabled. If you do, then you do not need to worry about this update, it should be already done.
-
Using gulp to make your WordPress site runs faster
First of all, what is gulp? It’s open software, a task runner build on node.js. Maybe it isn’t very descriptive, so let’s jump into an example. When I build a theme or a plugin for WordPress, I use many CSS, less, scss, javascript files. For WordPress theme it may be: /src/less/basic.less /src/less/main.less /src/css/default-wp.css /src/css/theme-a.css /src/css/theme-b.css /src/css/responsive.css Now, I need those files in my theme, so I use wp_enqueue_scripts hook and then… No, I do not use wp_enqueue_style for each file (including .less compilation somewhere). So, what do I do? I use one single file, let’s call it my-theme.min.css. Just one file, one HTTP call (it may be a bit outdated…
-
Photography source
Sometimes you ask me, where do I get all those photographs I use on this site or in themes examples. Well, there are a lot of public-domain or free to use sources, but I am especially pleased with unsplash.com. Of course it is rather small source (comparing to paid sources) but it’s still enough. And quality of the photos are excellent in most cases. So, feel free to use it! PS: I am not connected with unsplash.com in any way, except for using their photos! Horizontal images gallery Vertical images gallery Note that I decreased a lot of those photographs dimensions and obviously I use only those pictures I used…
-
How to modify footer in admin screen
Sometimes you may want to add your own footer text in admin screen. I use it often to add information about my theme. Of course it is visible only in admin screen, so you do not need to worry about WordPress regulation about asking user to view any copyright notice for common users. How to do that? It’s very easy, we need to use admin_footer_text filter. [crayon-67a81197956df864051341/] So, this is the simplest solution. We’ve got more here. I think we should leave original WordPress copyright, because it is just fair. To do that, just preserve original $msg variable, like this: [crayon-67a81197956e2926791592/] You may notice, that the footer string is in…
-
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-67a8119795885147313248/] 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-67a8119795b95087963195/]
-
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…