<?php
$visible_post = 4;
$query = \RestBuild\RestBuild::get_post_query('news', $visible_post);
if ($query->have_posts()) :?>
<div class="news" id="news">
<h2 class="news__title">Новости</h2>
<div class="news__container">
<?php
while ($query->have_posts()) {
$query->the_post();
get_template_part('loop/loop', 'news');
}
?>
</div>
<?php if (intval($query->found_posts) - $visible_post > 0) : ?>
<div class="news__load">Загрузить еще <?php echo $query->found_posts - $visible_post; ?></div>
<?php endif; ?>
</div>
<?php endif; ?>
<div class='news__item'>
<h4><?php esc_html(the_title()); ?></h4>
<?php if (has_post_thumbnail()) the_post_thumbnail('medium'); ?>
<?php the_excerpt(); ?>
</div>
register_activation_hook( __FILE__, 'dostavka_plugin_activate' );
function dostavka_plugin_activate() {
require_once plugin_dir_path( __FILE__ ) . 'includes/dostavka-activator.php';
DostavkaActivator::run();
}
public static function run()
{
self::loader();
self::add_option();
}
public static function loader()
{
add_action( 'init', self::create_post() );
add_action( 'init', self::create_tax() );
add_filter( 'rwmb_meta_boxes', self::add_metabox());
add_filter( 'template_include', self::template('order') );
add_filter( 'template_include', self::template('cart') );
}
public static function create_post()
{
$labels = array(
'name' => 'Каталог',
'singular_name' => 'Товар',
'add_new' => 'Добавить товар',
'add_new_item' => 'Добавление товара',
'edit_item' => 'Редактирование товара',
'new_item' => 'Новый товар',
'view_item' => 'Смотреть товар',
'search_items' => 'Искать товар',
'not_found' => 'Не найдено',
'not_found_in_trash' => 'Не найдено в корзине',
'parent_item_colon' => '',
'menu_name' => 'Каталог',
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => true,
'menu_position' => 8,
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail'),
'yarpp_support' => true
);
register_post_type( 'catalog', $args );
}
add_action( 'init', 'action_function_name_11' );
function action_function_name_11() {
$id = isset($_GET['id']) ? $_GET['id'] : null;
$result[] = $id;
$result[] = 'foo';
echo json_encode($result);
exit;
}
add_action( 'init', 'action_function_name_11' );
function action_function_name_11() {
$user = 'login';
$password = 'password';
$id = isset($_GET['id']) ? $_GET['id'] : null;
$token = isset($_GET['token']) ? $_GET['token'] : null;
if ($token !== md5($user.$password)) {
exit('Invalid token');
}
return $id;
}
$dateclouse = array();
while ( have_rows('date_cldate_close') ) : the_row();
$date = get_sub_field('date');
array_push($dateclouse, $date);
endwhile;
var dated = <?php echo json_encode($dateclouse); ?>;
function DisabledDate(date){
var string = jQuery.datepicker.formatDate('dd-mm-yy', date);
return [dated.indexOf(string) == -1];
}
$(function() {
$("#datepicker").datepicker({
beforeShowDay: DisabledDate
});
});
function order() {
var msg = $('#order').serialize();
$.ajax({
type: 'POST',
url: "/order.php",
data: msg,
success: function(data) {
alert('Ваш заказ принят!');
$("input[type='text']").val("");
location.reload();
},
error: function(xhr, str){
alert('Возникла ошибка: ' + xhr.responseCode);
}
});
}
require( dirname(__FILE__) . '/wp-load.php' );
$name = $_POST['name'];
$date = $_POST['data'];
$row = array(
'date' => $date
);
add_row('date_cldate_close', $row);