This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Bitwise Check | |
* If $count is an odd number returns true (1st expression). | |
*/ | |
echo $count & 1 ? '' : '' ; | |
/** | |
* Bitwise Check Usage | |
* Add a class 'end' on every even loop (when expression returns false). | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Open terminal stay in home directory. | |
# Running first command results in Permission Denied error so we need to make script executable. | |
# The commmands ls -l are used to check permissions have been changed. | |
# Change back to home directory to show script will run from anywhere. | |
filename.sh | |
cd /usr/local/bin | |
ls -l | |
chmod +x filename.sh | |
ls -l |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Manually add to $PATH. | |
# Open ~/.bash_profile or /Users/USERNAME/.bash_profile | |
# Add the below line and amend PATHTODIRECTORY. Use "" if there are spaces in any directories. | |
# Seperate multiple additions with : | |
# Restart Terminal test with echo $PATH. | |
export PATH=$PATH:PATHTODIRECTORY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 1. Position if underneath a fixed navigation. | |
* 2. Set to image height. | |
*/ | |
.header-image { | |
position: absolute; | |
overflow: hidden; | |
top: px /* 1 */ | |
left: 0; | |
width: 100%; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Allow SVG into media uploader. | |
*/ | |
function malinky_mime_types( $mimes ) | |
{ | |
$mimes['svg'] = 'image/svg+xml'; | |
return $mimes; | |
} | |
add_filter('upload_mimes', 'malinky_mime_types'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Wordpress Custom Post Type Landing Pages | |
* In all examples $rewrite and $args are simplified to the discussed settings. | |
*/ | |
/** | |
* 1. Custom Post Type has archives and the slug is rewritten. | |
* In this case a visit to /post-type-name will use archive-$posttype.php, $archive.php, index.php. | |
* Pagination will work by default assuming $rewrite[ 'pages' ] is also true (default). | |
* It's not possible to create a landing page called /post-type-name as the archive page controls the template hierarchy. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ------------------------------------------------------------------------ * | |
* Custom post type and taxonomy with archives. (Preferable URLS) | |
* ------------------------------------------------------------------------ */ | |
/** | |
* No landing page added to admin. | |
* Use archive template hierarchy to create a landing page if requried. | |
* No custom wp_query is requried for pagination, it just works. | |
* Obviously need to add post_type_link filter for the URLS to include the taxonomy. | |
* As there is no landing page harder to add to a menu. https://wordpress.org/plugins/post-type-archive-links/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine On | |
# Redirect a specific page. Includes optional trailing slash. | |
# Both rules go to the same page on the same domain. | |
# If not using the protocol on the redirect remember the opening slash. | |
# RewriteRule ^djs/meatkatie(/)?$ http://www.domain.co.uk/dj-listings/meatkatie [R=301,L] | |
# RewriteRule ^djs/meatkatie(/)?$ /dj-listings/meatkatie [R=301,L] | |
# Redirect whole directory. Includes optional trailing slash. | |
# RewriteRule ^djs(/)?(.*)$ http://www.domain.co.uk/dj-listings [R=301,L] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* See http://benalman.com/news/2010/11/immediately-invoked-function-expression/ for a better explanation | |
*/ | |
<script> | |
function test() { | |
console.log('function declaration that is called with test()'); | |
} | |
test(); | |
(function test() { | |
console.log('immediately invoked function declaration wrapped in brackets (turned into an expression)'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Delete revisions */ | |
DELETE FROM wp_posts WHERE post_type = "revision"; | |
/** | |
* Also set in wp-config.php | |
* define( 'WP_POST_REVISIONS', 3 ); | |
*/ | |
/* Clean postmeta where the associated post no longer exists */ | |
SELECT * FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL; |
OlderNewer