function mg_get_cat_items($cat) { if (!$cat) { return false; } // post types $post_types = array('mg_items'); if (mg_woocomm_active()) { $post_types[] = 'product'; } // meta query to allow selective WC products $not_in = array('wc_no'); if (!mg_woocomm_active() || !get_option('mg_integrate_wc')) { $not_in = array_merge($not_in, array(false, 'wc_auto')); } $args = array('post_type' => $post_types, 'post_status' => 'publish', 'posts_per_page' => 3000, 'orderby' => 'title', 'order' => 'ASC', 'meta_query' => array(array('key' => 'mg_main_type', 'value' => $not_in, 'compare' => 'NOT IN'))); // filter by cat if ($cat != 'all') { $term_data = get_term_by('id', $cat, 'mg_item_categories'); $args['tax_query'] = array('relation' => 'AND', array('taxonomy' => 'mg_item_categories', 'field' => 'slug', 'terms' => $term_data->slug, 'operator' => 'IN')); } $query = new WP_Query($args); $items = $query->posts; $items_list = array(); foreach ($items as $item) { $post_id = $item->ID; $img_id = get_post_thumbnail_id($post_id); $type = $item->post_type == 'product' ? 'woocom' : get_post_meta($post_id, 'mg_main_type', true); // show only items with featured image if (!empty($img_id) || ($type == 'spacer' || $type == 'inl_slider' || $type == 'inl_video' || $type == 'inl_text')) { $items_list[] = array('id' => $post_id, 'title' => $item->post_title, 'type' => $type, 'img' => $img_id); } } return $items_list; }
<?php include_once MG_DIR . '/functions.php'; // item types array $types = mg_main_types(); $wooc_active = mg_woocomm_active(); if ($wooc_active) { $wc_attr = wc_get_attribute_taxonomies(); } ?> <div class="wrap lcwp_form"> <div class="icon32"><img src="<?php echo MG_URL . '/img/mg_icon.png'; ?> " alt="mediagrid" /><br/></div> <?php echo '<h2 class="lcwp_page_title" style="border: none;">' . __('Media Grid Settings', 'mg_ml') . "</h2>"; ?> <?php // HANDLE DATA if (isset($_POST['lcwp_admin_submit'])) { if (!isset($_POST['pg_nonce']) || !wp_verify_nonce($_POST['pg_nonce'], __FILE__)) { die('<p>Cheating?</p>'); } include MG_DIR . '/classes/simple_form_validator.php'; $validator = new simple_fv(); $indexes = array(); $indexes[] = array('index' => 'mg_cells_margin', 'label' => __('Cells Margin', 'mg_ml'), 'type' => 'int');
function mg_js_flags() { include_once MG_DIR . '/functions.php'; $delayed_fx = get_option('mg_delayed_fx') ? 'false' : 'true'; $modal_class = get_option('mg_modal_lb') ? 'mg_modal_lb' : 'mg_classic_lb'; $box_border = get_option('mg_cells_border') ? 1 : 0; $lb_vert_center = get_option('mg_lb_not_vert_center') ? 'false' : 'true'; $lb_touchswipe = get_option('mg_lb_touchswipe') ? 'true' : 'false'; $woocom = mg_woocomm_active() ? 'true' : 'false'; ?> <script type="text/javascript"> // Media Grid global dynamic vars mg_boxMargin = <?php echo (int) get_option('mg_cells_margin'); ?> ; mg_boxBorder = <?php echo $box_border; ?> ; mg_imgPadding = <?php echo (int) get_option('mg_cells_img_border'); ?> ; mg_delayed_fx = <?php echo $delayed_fx; ?> ; mg_filters_behav = '<?php echo get_option('mg_filters_behav', 'standard'); ?> '; mg_lightbox_mode = "<?php echo $modal_class; ?> "; mg_lb_touchswipe = <?php echo $lb_touchswipe; ?> ; mg_mobile = <?php echo get_option('mg_mobile_treshold', 800); ?> ; // Galleria global vars mg_galleria_fx = '<?php echo get_option('mg_slider_fx', 'fadeslide'); ?> '; mg_galleria_fx_time = <?php echo get_option('mg_slider_fx_time', 400); ?> ; mg_galleria_interval = <?php echo get_option('mg_slider_interval', 3000); ?> ; </script> <?php // if prevent right click if (get_option('mg_disable_rclick')) { ?> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('body').delegate('.mg_grid_wrap *, #mg_full_overlay *, #mg_wp_video_wrap .wp-video *', "contextmenu", function(e) { e.preventDefault(); }); }); </script> <?php } }