DEST_WWW_PATH="/path/to/www/folder"
CURRENT_PATH=$(pwd)
SITE_FOLDERS=("site.ru" "site2.ru")
for SITE_FOLDER in ${SITE_FOLDERS[@]}; do
CURRENT_FOLDER="${CURRENT_PATH}/${SITE_FOLDER}"
DB_NAME=$(/bin/grep -oP "define\(['\"]DB_NAME['\"],\s*['\"]\K[^'\"]+(?=[\'\"]\s*\)\s*;)" "${CURRENT_FOLDER}/wp-config.php")
DB_USER=$(/bin/grep -oP "define\(['\"]DB_USER['\"],\s*['\"]\K[^'\"]+(?=[\'\"]\s*\)\s*;)" "${CURRENT_FOLDER}/wp-config.php")
DB_PASSWORD=$(/bin/grep -oP "define\(['\"]DB_PASSWORD['\"],\s*['\"]\K[^'\"]+(?=[\'\"]\s*\)\s*;)" "${CURRENT_FOLDER}/wp-config.php")
/usr/bin/mysqldump -u $DB_USER -p$DB_PASSWORD $DB_NAME | /bin/gzip -9 > dump.sql.gz
/usr/bin/rsync -rvp user@XXX.XXX.XXX.XXX:"${DEST_WWW_PATH}/${SITE_FOLDER}/" $CURRENT_FOLDER
/bin/rm -f dump.sql.gz
done
<div class="slider">
<div class="box">
<?php wp_list_categories('orderby=name');
$_cats = get_categories([
'taxonomy' => 'category',
'orderby' => 'name',
]);
if (is_array($_cats) and count($_cats)) {
$_cats_ul = array_chunk($_cats, 3);
if (count($_cats_ul)) {
foreach ($_cats_ul as $_cat_items) {
echo '<ul>';
foreach ($_cat_items as $_item) {
echo "<li>{$_item->name}</li>";
}
echo '</ul>';
}
}
}
?>
</div>
</div>
public function get_attachment_by_hash($hash_file)
{
if ( !$hash_file ) return 0;
$attachments = get_posts(array(
'numberposts' => 1,
'post_type' => 'attachment',
'post_status' => 'inherit',
'meta_query' => array(
array(
'key' => 'hash_file',
'value' => $hash_file
)
)
));
if (!is_array($attachments) or !count($attachments)) return 0;
if ($attachments[0]->ID)
return $attachments[0]->ID;
else
return 0;
//update_post_meta( $attachment_id, 'photo_title', $metadata['image_meta']['title'] );
}
$tmp_file = download_url( $_first_pic, 600 );
if ( is_wp_error( $tmp_file ) ) {
$this->error($tmp_file->get_error_messages());
return '';
} else {
$hash_file = hash_file('md5', $tmp_file);
$this->log("md5 hash file: $hash_file");
$this->log("download image: $_first_pic");
}
$att_id = $this->get_attachment_by_hash($hash_file);
if ($att_id) {
//find attachment duplicate ID: $att_id
} else {
$att_id = media_handle_sideload( array(
'name' => preg_replace('/\?.*/', '', basename($_first_pic)),
'tmp_name' => $tmp_file,
), $this->product_id, $title);
if ( is_wp_error( $att_id ) ) {
$this->error($att_id->get_error_messages());
} else {
update_post_meta($att_id, 'hash_file', $hash_file);
set_post_thumbnail($this->product_id, $att_id);
}
}
$_next_post = new WP_Query( [
'posts_per_page' => 1,
'post_type' => 'projects',
'post_status' => 'publish',
'meta_query' => [
'type' => [
'key' => 'type',
'value' => [ 'archive', 'commin_soon' ],
],
],
'post__not_in' => $next_posts,
'orderby' => 'ID',
'order' => 'ASC',
] );
$next_posts = range(1, 555);
add_filter( 'terms_clauses', function ( $pieces, $taxonomies, $args ) {
global $pagenow, $wpdb;
if ( is_admin() && $pagenow == 'edit-tags.php' && $taxonomies[0] == 'program_session' ) {
$pieces['join'] .= ' INNER JOIN ' . $wpdb->termmeta . ' AS tm ON t.term_id = tm.term_id ';
$pieces['where'] .= ' AND tm.meta_key = "program_session_start"';
$pieces['orderby'] = ' ORDER BY tm.meta_value ';
}
return $pieces;
}, 10, 3 );