Need to use session data in your model?That's it. Just a friendly reminder.
This issue plagued me for way longer than it should. Due to lack of documentation online I figured it would be best to represent it here.
I kept getting Black-holed. The most common answer I found online was to disable security altogether. (Seriously, don't do that). Rather, the correct answer via consensus in the #CakePHP IRC, as well as multiple other hidden forum posts was to disable it on a per hidden field basis.
Easy answer. Make this:Into this: (The last one didn't work for me as was vastly suggested, but the following worked for me and should be an alternate) Happy coding!
For a few months, every time I pushed a commit I would play a sound clip. (Specifically Push It by Salt-n-Pepa) This was just for kicks, but would take a few seconds to open my Spotify account and actually find/play the clip.
Recently I found a way to add it to my post-commit hook in git.
Open .git and navigate to the folder called "hooks". Copy the post-commit.sample and save it as post-commit.
Enter the following command:Save and enjoy!
NOTE: This only works on mac.
This comes from a post here: http://www.joestrong.co.uk/blog/css-tip-how-to-match-column-heights-in-css/
A huge problem (come on CSS devs, we're ready for smarter code! We shouldn't needs jquery or LESS to fix your crap!) is matching a heights to a sibling div.
Simply add the following to the short column's css:And that is it.
Q: What is it doing?
A: The padding-bottom action will push the height to 30,000 (plus the height of the original div) then it will use the margin-bottom to reign in the excess. Can I explain it better? Sure. Will I? NO! Just try it out, it works!
I lost this article once, and I shall never do that again. This originates from here.
This is basically all you need to know:
This goes out to all the theme developers out there. EVERY SINGLE DESIGNER NEEDS TO IMPLEMENT THIS NOW
Featured images are great, unless the user doesn't add them. This solution will allow your template users to have engaging experience with your templates. If you are a template designer, it means more money for you.
Article can be read here: http://www.wpbeginner.com/wp-themes/how-to-set-a-default-fallback-image-for-wordpress-post-thumbnails/
Default WordPress Featured Images
WordPress has this very cool post thumbnail feature which was added in version 2.9. This feature basically allows you to add a custom image as a thumbnail that represents that post. This feature has become a standard for theme designers. But often, new bloggers forget to set a post thumbnail (featured image) which causes the template display to break. Second, it just looks unprofessional to have broken images or empty areas on homepage where the thumbnail was suppose to be. We believe that theme designers and developers should create a new standard of adding a default fallback image for WordPress post thumbnails in their themes. Popular frameworks like Genesis already has this type of option built-in where if the user does not specify a post thumbnail (featured image), then the first image attachment within the post will be displayed as the thumbnail. In this article, we will show you two different ways of adding a default fallback image for WordPress Post Thumbnails.
To utilize the tricks in this post, you have to enable the post thumbnails in your WordPress theme.
Adding a Branded Image as the Default Fallback
Often when creating a custom site for a client, they may have posts that has absolutely no image. So it is always smart for designers to create a branded image that is displayed for posts that has no thumbnail specified. The philosophy of this idea is similar to having a customized gravatar in WordPress. All you really have to do is open the theme file where you are going to display the post thumbnail, this can be (home.php, single.php, loop.php, index.php, archive.php, etc). Then simply paste the following code within the post loop. Explanation: The code checks if the post has a specified thumbnail, and if there is, then it will display the post thumbnail. If there is no post thumbnail specified, then it will display ‘default-image.jpg’ image from your theme’s images folder.
This is the very basic example. You can obviously expand on it with thumbnail sizes, class and much more.
Adding the First Post Image as the Default Fallback
Often new bloggers add images to the post, but either they forget to specify a post thumbnail, or they simply do not know how to. Regardless of what the case is, we as developers should prepare in advance. So the trick that we have seen used specially in theme frameworks like Genesis is adding the first post image as the default fallback for WordPress post thumbnails. To do this, you have to open your theme’sfunctions.php file and add the following codes: Then open the theme file where you are displaying the WordPress post thumbnail, this can be (home.php, single.php, loop.php, index.php, archive.php, etc) and paste the following code:
Explanation: First we create a function that gets the first image attachment for each post. In our theme file code, we check if the post has a thumbnail. If the thumbnail exist, then we display the thumbnail, and if it does not exist, then we display the fallback.
This is just the start. You can get creative with the fallback images for WordPress post thumbnails. You can combine the two techniques mentioned above, create branded images for each category, and much more.
If you are a theme developer, then make sure you have this in your themes.
Are you like me in that anything regex makes your skin crawl? Do you feel like throwing up when you see something like:
I do. So here's a few resources to hopefully help you sort things out:
Regex Generator: http://txt2re.com/
Regex CheatSheat: http://www.cheatography.com/davechild/cheat-sheets/regular-expressions/
Hope this helps!
This problem came up where I needed to remove a folder. Removing a folder is easy, only the PHP command rmdir() only removes the folder if it is empty. The PHP command unlink() is only for files.
So how do I recursively delete a folder that might not be empty? Here is a function for you:Then just call it with the non-empty folder you want to remove.