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
#!/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/bash | |
# Create backup for all databases | |
w="$(date +'%d_%m_%Y_%H_%M_%S')" | |
filename="db_$now".gz | |
backupfolder="/mnt/ftp/dbbackups/test" | |
fullpathbackupfile="$backupfolder/$filename" | |
logfile="$backupfolder/"backup_log_"$(date +'%Y_%m')".txt | |
echo "mysqldump started at $(date +'%d-%m-%Y %H:%M:%S')" >> "$logfile" |
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
add_action('pmxi_saved_post', 'update_gallery_ids', 10, 3); | |
function update_gallery_ids($id) { | |
$attached_images = get_attached_media( 'image', $id ); | |
// Prepare images into array | |
$arr = array(); | |
foreach($attached_images as $image) | |
array_push($arr, $image->ID); |
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, |
NewerOlder