function mg_thumb_center_box()
{
    require_once MG_DIR . '/functions.php';
    global $post;
    $tc = get_post_meta($post->ID, 'mg_thumb_center', true);
    if (!$tc) {
        $tc = 'c';
    }
    // array of sizes
    $vals = mg_sizes();
    ?>
    <div class="lcwp_sidebox_meta">
        <div class="misc-pub-section">
          <input type="hidden" value="<?php 
    echo $tc;
    ?>
" name="mg_thumb_center" id="mg_thumb_center" />
                
          <table class="mg_sel_thumb_center">
            <tr>
                <td id="mg_tl"></td>
                <td id="mg_t"></td>
                <td id="mg_tr"></td>
            </tr>
            <tr>
                <td id="mg_l"></td>
                <td id="mg_c"></td>
                <td id="mg_r"></td>
            </tr>
            <tr>
                <td id="mg_bl"></td>
                <td id="mg_b"></td>
                <td id="mg_br"></td>
            </tr>
          </table>
        </div>
    </div>

    <script type="text/javascript">
	jQuery(document).ready(function() {
		function mg_thumb_center(position) {
			jQuery('.mg_sel_thumb_center td').removeClass('thumb_center');
			jQuery('.mg_sel_thumb_center #mg_'+position).addClass('thumb_center');
			
			jQuery('#mg_thumb_center').val(position);	
		}
		mg_thumb_center( jQuery('#mg_thumb_center').val() );
		
		jQuery('body').delegate('.mg_sel_thumb_center td', 'click', function() {
			var new_position = jQuery(this).attr('id').substr(3);
			mg_thumb_center(new_position);
		});		
	});
    </script>
 
	<?php 
    return true;
}
}
?>
		
		// max width control
		var cols = Math.round( 1 / size );
		if( (wsize * cols) > $container.width() ) {
			wsize = wsize - 1;	
		}
		
		return wsize;
	}
	
	
	function get_height() {
		<?php 
$sizes = mg_sizes();
$sizes[] = 'auto';
foreach ($sizes as $size) {
    ?>
 
		if( $target.hasClass('row<?php 
    echo $size;
    ?>
') ) { 
			var size = get_size('<?php 
    echo $size;
    ?>
');
			var hsize = Math.round($container.width() * size);
		}
		<?php 
Exemple #3
0
function mg_add_item_to_builder()
{
    include_once MG_DIR . '/functions.php';
    $tt_path = MG_TT_URL;
    if (!isset($_POST['item_id'])) {
        die('data is missing');
    }
    $item_id = addslashes($_POST['item_id']);
    $mobile_mode = isset($_POST['mg_mobile']) && $_POST['mg_mobile'] ? true : false;
    $items_data = mg_grid_builder_items_data(array($item_id));
    foreach ($items_data as $item) {
        $w_sizes = mg_sizes();
        $h_sizes = mg_sizes();
        $mw_sizes = mg_mobile_sizes();
        $mh_sizes = mg_mobile_sizes();
        $item_w = '1_4';
        $item_h = '1_4';
        $mobile_w = '1_2';
        $mobile_h = '1_3';
        // add height == auto if type != inline slider or inline video
        if (!in_array($item['type'], array('inl_slider', 'inl_video', 'spacer'))) {
            $h_sizes[] = 'auto';
            $mh_sizes[] = 'auto';
        }
        // featured image
        $img_id = get_post_thumbnail_id($item_id);
        // item thumb
        if (in_array($item['type'], array('inl_slider', 'inl_video', 'inl_text', 'spacer'))) {
            $item_thumb = '<img src="' . MG_URL . '/img/type_icons/' . $item['type'] . '.png" height="19" width="19" class="thumb" alt="" />';
        } else {
            $item_thumb = '<img src="' . mg_thumb_src($img_id, 19, 19) . '" class="thumb" alt="" />';
        }
        // size classes
        $w_class = $mobile_mode ? $mobile_w : $item_w;
        $h_class = $mobile_mode ? $mobile_h : $item_h;
        // item type
        $item_type = get_post_type($item['id']) == 'product' ? 'WooCommerce' : mg_item_types($item['type']);
        echo '
		<li class="mg_box mg_' . $item['type'] . '_type col' . $w_class . ' row' . $h_class . '" id="box_' . mt_rand() . $item['id'] . '" mg-width="' . $item_w . '" mg-height="' . $item_h . '"  mg-m-width="' . $mobile_w . '" mg-m-height="' . $mobile_h . '">
		  <input type="hidden" name="grid_items[]" value="' . $item['id'] . '" />
		  <div class="handler" id="boxlabel" name="' . $item['id'] . '">
		  	  <div class="del_item"></div>
			  <a href="' . get_admin_url() . 'post.php?post=' . $item['id'] . '&action=edit" class="edit_item" target="_blank" title="' . __('edit item', 'mg_ml') . '"></a>
			  <h3>
			    ' . $item_thumb . '
			  	' . strip_tags($item['title']) . '
			  </h3>
			  <p style="padding-top: 6px;">' . $item_type . '</p>
			  <p class="mg_builder_standard_sizes">';
        // choose the width
        echo __('Width', 'mg_ml') . ' <select name="items_w[]" value="" class="select_w mg_items_sizes_dd">';
        foreach ($w_sizes as $size) {
            $size == $item_w ? $sel = 'selected="selected"' : ($sel = '');
            echo '<option value="' . $size . '" ' . $sel . '>' . str_replace('_', '/', $size) . '</option>';
        }
        echo '</select> <br/>  ' . __('Height', 'mg_ml') . ' <select class="select_h mg_items_sizes_dd">';
        foreach ($h_sizes as $size) {
            $size == $item_h ? $sel = 'selected="selected"' : ($sel = '');
            echo '<option value="' . $size . '" ' . $sel . '>' . str_replace('_', '/', $size) . '</option>';
        }
        echo '</select></p>
			  <p class="mg_builder_mobile_sizes">';
        echo __('Width', 'mg_ml') . ' <select name="items_w[]" value="" class="select_m_w mg_items_sizes_dd">';
        foreach ($mw_sizes as $size) {
            $size == $mobile_w ? $sel = 'selected="selected"' : ($sel = '');
            echo '<option value="' . $size . '" ' . $sel . '>' . str_replace('_', '/', $size) . '</option>';
        }
        echo '</select> <br/>  ' . __('Height', 'mg_ml') . ' <select class="select_m_h mg_items_sizes_dd">';
        foreach ($mh_sizes as $size) {
            $size == $mobile_h ? $sel = 'selected="selected"' : ($sel = '');
            echo '<option value="' . $size . '" ' . $sel . '>' . str_replace('_', '/', $size) . '</option>';
        }
        echo '</select></p>
	  
		  </div>
		</li>';
    }
    die;
}