<?php foreach ($FILTERS_LABELS[$page] as $label) { ?> <li><?php echo $label; ?> </li> <?php } ?> </ul> <?php // Prepare articles and filters $articles = get_posts_from_category($SPECIAL_CATEGORIES[$page], -1); $filters = array(); foreach ($FILTERS[$page] as $filter) { $filters[] = get_filter_values($filter, $articles); } ?> <div id="selects"> <?php // Display the select boxes foreach ($FILTERS_LABELS2[$page] as $index => $select) { ?> <label class="select"> <select class="option-set" data-filter-group="<?php echo $FILTERS[$page][$index]; ?>
function anvelocom_anvelope_page() { ?> <section id="anvelope" class="filter"> <h1>Filtre</h2> <form action="?page=anvelocom-anvelope" method="post"> <input type="hidden" value="<?php echo wp_create_nonce('anvelocom'); ?> " id="nonce" name="nonce"> <input type="hidden" id="action" name="action" value="submit-form"> <input type="hidden" id="index" name="index" value="0"> <input type="submit" value="Anvelope" id="submit" name="submit"> </form> <form action="?page=anvelocom-anvelope" method="post"> <input type="hidden" value="<?php echo wp_create_nonce('anvelocom'); ?> " id="nonce" name="nonce"> <input type="hidden" id="action" name="action" value="submit-form"> <input type="hidden" id="index" name="index" value="1"> <input type="submit" value="Jenti" id="submit" name="submit"> </form> <form action="?page=anvelocom-anvelope" method="post"> <input type="hidden" value="<?php echo wp_create_nonce('anvelocom'); ?> " id="nonce" name="nonce"> <input type="hidden" id="action" name="action" value="submit-form"> <input type="hidden" id="index" name="index" value="2"> <input type="submit" value="Tuning" id="submit" name="submit"> </form> <?php // Generate the relationships // if ($_POST && $_POST['action'] == 'submit-form') { if (wp_verify_nonce($_POST['nonce'], 'anvelocom')) { $index = $_POST['index']; // Get the filters global $SPECIAL_CATEGORIES; global $FILTERS; global $TABLES; $articles = get_posts_from_category($SPECIAL_CATEGORIES[$index], -1); $filters = $FILTERS[$index]; global $wpdb; $table = $wpdb->prefix . 'filter_' . $TABLES[$index]; // First remove all existing data .... $ret = $wpdb->query($wpdb->prepare("TRUNCATE TABLE {$table}", array())); echo $ret != false ? "OK " : "Error "; // Now add relationships $fields = '('; foreach ($filters as $filter) { $fields .= avc_remove_filter_prefix($filter) . ','; } $fields = rtrim($fields, ",") . ')'; foreach ($articles as $article) { $relations = array(); $values = '('; foreach ($filters as $filter) { $filter_value = get_filter_value($filter, $article, true); if ($filter_value) { $values .= '%s,'; } else { $values .= '"NaV",'; } //Not a value: property meta value not set... by iBB! $relations = array_merge($relations, $filter_value); } $values = rtrim($values, ",") . ')'; // convert 10,5 to 10-5 and BF Goodrich to bf-goodrich to match HTML class name conventions in order to be usable with the Isotope plugin which filters through class names $relations = array_map("string_to_classname", $relations); if (!empty($relations)) { $ret = $wpdb->query($wpdb->prepare("INSERT INTO {$table} {$fields} VALUES {$values} ", $relations)); echo $ret != false ? "OK " : "Error "; } } } } ?> </section> <?php }
?> <?php $articles = get_posts_from_category(CATEGORY_PRODUS, 4); $title = 'Produse noi'; $link = get_category_url(CATEGORY_PRODUS); $id = 'anvelope'; $first_article = true; include '_articles.php'; ?> <?php $articles = get_posts_from_category(CATEGORY_REDUCERI, 4); $title = 'Reduceri'; $link = get_category_url(CATEGORY_REDUCERI); $id = 'reduceri'; include '_articles.php'; ?> <?php $articles = get_posts_from_category(CATEGORY_BESTSELLERS, 4); $title = 'Cele mai vandute'; $link = get_category_url(CATEGORY_BESTSELLERS); $id = 'bestsellers'; include '_articles.php'; ?> <?php get_footer();
function get_similar_posts($post, $main_category, $dimension) { $filters = get_post_filters($main_category); $posts = get_posts_from_category($main_category, -1); $ret = array(); foreach ($posts as $p) { $klass = get_article_class($filters, $p); $klass = implode(' / ', $klass); if ($klass == $dimension && $p->ID != $post->ID) { $ret[] = $p; } } return $ret; }