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
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
// https://support.advancedcustomfields.com/forums/topic/wpml-acf-5-0-9-and-options-page/ | |
function bi_acf_get_language_default() { | |
return acf_get_setting( 'default_language' ); | |
} | |
function bi_acf_set_language_to_default() { | |
add_filter( 'acf/settings/current_language', 'bi_acf_get_language_default', 100 ); | |
} | |
function bi_acf_unset_language_to_default() { | |
remove_filter( 'acf/settings/current_language', 'bi_acf_get_language_default', 100 ); |
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
<script type="application/ld+json"> | |
{ | |
"@context": "http://schema.org", | |
"@type": "NewsArticle", | |
"mainEntityOfPage": { | |
"@type": "WebPage", | |
"@id": "https://google.com/article" | |
}, | |
"headline": "<?php the_title(); ?>", | |
"image": { |
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
// Doesn't work well when WPML is installed! | |
function ms_update_slug( $data, $postarr ) { | |
if ( !in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) { | |
$data['post_name'] = sanitize_title( $data['post_title'] ); | |
} | |
return $data; | |
} |
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
function seo_yoast_set_default_image() { | |
$img = 'image_path'; | |
$GLOBALS['wpseo_og']->image_output( $img ); | |
} | |
add_action( 'wpseo_opengraph', 'seo_yoast_set_default_image', 29 ); |
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
function wpb_admin_account(){ | |
$user = 'username'; | |
$pass = 'password'; | |
$email = 'email@gmail.com'; | |
if ( !username_exists( $user ) && !email_exists( $email ) ) { | |
$user_id = wp_create_user( $user, $pass, $email ); | |
$user = new WP_User( $user_id ); | |
$user->set_role( 'administrator' ); | |
} } | |
add_action('init','wpb_admin_account'); |
NewerOlder