This file contains 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
// This is not planned for hierarchical posts | |
add_action('wp_footer', 'create_wpml_translated_posts'); | |
function create_wpml_translated_posts() { | |
$post_type = 'post'; | |
$new_language = 'en'; | |
$args = array( | |
'post_type' => $post_type, | |
'posts_per_page' => -1 |
This file contains 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
# Catch 404 | |
ErrorDocument 404 https://oldsite.com/404 | |
RewriteEngine on | |
# Single page redirect | |
Redirect 301 /team.php https://newsite.com/our-team/ | |
# Redirect all query variables with url something like https://oldsite.com/blog-list?p=10 to https://newsite.com/en/ (question mark in the end removes query parameter on new page) | |
RewriteCond %{QUERY_STRING} ^p=(.*) |
This file contains 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 | |
RewriteCond %{REQUEST_URI} !^/_skip-this-folder$ | |
RewriteCond %{REQUEST_URI} !^/$ | |
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|css|js)$ | |
RewriteRule .* / [L,R=302] | |
RewriteCond %{HTTP_HOST} ^www.domain.hr [NC] | |
RewriteRule ^(.*) https://domain.hr/$1 [L,R=301] |
This file contains 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
// Accessibility compliant event handler | |
// Taken from http://www.karlgroves.com/2014/11/24/ridiculously-easy-trick-for-keyboard-accessibility/ | |
function a11yClick(event) { | |
if(event.type === 'click'){ | |
return true; | |
} | |
else if(event.type === 'keypress') { | |
var code = event.charCode || event.keyCode; | |
if((code === 32)|| (code === 13)){ |
This file contains 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
<?php | |
if (ICL_LANGUAGE_CODE == 'hr') { | |
setlocale(LC_TIME, 'hr_HR.UTF-8'); | |
echo strtolower(strftime("%e. %B %Y.", get_post_time('U'))); | |
} | |
else if (ICL_LANGUAGE_CODE == 'en') { | |
setlocale(LC_TIME, 'en_US.UTF-8'); | |
echo strftime("%A %e %B %Y", get_post_time('U')); | |
} | |
?> |
This file contains 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
jQuery(document).ready(function ($) { | |
'use strict'; | |
// Add class ('appeared') to each element that should be animated when visible on viewport | |
// Uses scrollmagic.js | |
var controller = new ScrollMagic.Controller(); | |
$('.animate').each(function () { | |
$(this).addClass('disappear'); | |
new ScrollMagic.Scene({ |
This file contains 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
<!-- Be sure to allow commenting in Wordpress settings --> | |
<ol class="commentlist"> | |
<?php | |
$comments = get_comments(array( | |
'post_id' => get_the_ID(), | |
'status' => 'approve' | |
)); | |
wp_list_comments(array( | |
'per_page' => 30, |
This file contains 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
How to run plugin unit tests on Windows 10, currently I can get it to work only with PHP 5 | |
- composer require --dev phpunit/phpunit ^5 | |
- wp scaffold plugin-tests {name-of-plugin-folder} | |
- rm -rf /tmp/wordpress-tests-lib; bash bin/install-wp-tests.sh wordpress_db_test root '' localhost latest | |
- edit file C:/Users/User/AppData/Local/Temp/wordpress-tests-lib/wp-tests-config.php and change path so that instead of relative path there is absolute path to correct folder | |
define('ABSPATH', 'C:/Users/User/AppData/Local/Temp/wordpress/'); | |
- vendor/bin/phpunit |
This file contains 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
#!/bin/bash | |
# Create backup for projects while skipping unimportant folders | |
TIME=`date +%b-%d-%y` | |
FILENAME=html-$TIME.tar.gz | |
SRCDIR=/var/www/html | |
DESDIR=/mnt/ftp/backups | |
tar -cpzf $DESDIR/$FILENAME --exclude=**/node_modules/* $SRCDIR |
This file contains 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
#!/bin/sh | |
# Remove old backup files | |
FILENAME="$(ls /mnt/ftp/backups -rt | head -1)" | |
rm /mnt/ftp/backups/$FILENAME | |
FILENAME2="$(ls /mnt/ftp/dbbackups -rt | head -1)" | |
rm /mnt/ftp/dbbackups/$FILENAME2 |
NewerOlder