const query = useStaticQuery(graphql`
query WP_Posts {
allWpPost {
edges {
post: node {
id
title
slug
excerpt
uri
}
}
}
}
}
`)
DirectoryIndex site.wsgi index.html
Options +ExecCGI
AddHandler wsgi-script .wsgi
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /site.wsgi/$1 [QSA,PT,L]
post_gallery = Image.objects.filter(article_id=edit_post.pk)
gallery_file_list = post_gallery.values_list('name', flat=True)
...
for f in request.FILES.getlist('files'):
file = f.name
if post_gallery and file in gallery_file_list:
print('file exist')
class ArticleAdmin(SummernoteModelAdmin, contrib.admin.ModelAdmin):
fields = ['category', 'title', 'slug', 'content', 'image', 'image_img',]
list_display = ['title', 'category', 'slug', 'image_img',]
readonly_fields = ['image_img',]
summernote_fields = ('content','additional',)
return $.ajax({
url: '/wp-admin/admin-ajax.php',
data: data,
cache: true,
beforeSend: function(xhr) {
$('.content').css('opacity', 0);
},
complete: function(response) {
$.getScript(add_to_cart_js_url); //переменная с URL скрипта объявлена в functions.php
$.getScript(variation_swatches_js_url); //переменная с URL скрипта объявлена в functions.php
$('.content').css('opacity', 1);
},
success: function(data) {
$('.content').html(data);
},
});
<?php
add_action('wp_footer', function (){
?>
<script type="text/javascript">
var add_to_cart_js_url = '<?=plugins_url("/woocommerce/assets/js/frontend/add-to-cart-variation.min.js");?>';
var variation_swatches_js_url = '<?=plugins_url("/variation-swatches-for-woocommerce/assets/js/frontend.js");?>';
</script>
<?php
}
});
function ajaxUpdate(link, action) {
var requestData = {'premmerce_filter_ajax_action': action};
var spin = action === 'reload';
$.ajax({
'method': 'POST',
'data': requestData,
'url': link,
'dataType': 'json',
success: function (response) {
history.pushState({}, null, link);
initScrolls();
initSliders();
}
});
<?php
add_filter( 'woocommerce_product_tabs', 'woo_config_product_tabs', 98 );
function woo_config_product_tabs( $tabs ) {
if ( $technical_info = get_field('technical_info') ) {
$tabs['additional_information'] = array(
'title' => 'Техническая информация',
'priority' => 30,
'callback' => 'additional_information_tab_content',
'content' => $technical_info,
);
} else unset( $tabs['additional_information'] );
return $tabs;
}
function additional_information_tab_content($tab_name, $tab) {
echo $tab['content'];
}
?>
add_filter( 'woocommerce_product_subcategories_args', 'update_subcategories_args_func',1 );
function update_subcategories_args_func($query) {
if ($_REQUEST['new_product'] == '1') {
$args = array(
'meta_query' => array(
array(
'key' => 'new_product', // name of custom field
'value' => 1,
'type' => 'numeric',
// 'compare' => 'LIKE'
)
)
);
return wp_parse_args( $args, $query );
} else return $query;
}