Example #1
0
function eme_locations_edit_layout($location, $message = "")
{
    if (!isset($location['location_id'])) {
        $action = "add";
    } else {
        $action = "edit";
    }
    ?>
   <div class="wrap">
      <div id="poststuff">
         <div id="icon-edit" class="icon32">
            <br />
         </div>
            
         <h2><?php 
    if ($action == "add") {
        _e('Add location', 'eme');
    } else {
        _e('Edit location', 'eme');
    }
    ?>
</h2>
             <?php 
    admin_show_warnings();
    ?>
         
         <?php 
    if ($message != "") {
        ?>
            <div id="message" class="updated fade below-h2" style="background-color: rgb(255, 251, 204);">
               <p><?php 
        echo $message;
        ?>
</p>
            </div>
         <?php 
    }
    ?>
         <div id="ajax-response"></div>
   
         <form enctype="multipart/form-data" name="editloc" id="editloc" method="post" action="<?php 
    echo admin_url("admin.php?page=eme-locations");
    ?>
" class="validate">
         <?php 
    if ($action == "add") {
        ?>
         <input type="hidden" name="eme_admin_action" value="do_addlocation" />
         <?php 
    } else {
        ?>
         <input type="hidden" name="eme_admin_action" value="do_editlocation" />
         <input type="hidden" name="location_id" value="<?php 
        echo $location['location_id'];
        ?>
" />
         <?php 
    }
    ?>
         
         <!-- we need titlediv and title for qtranslate as ID -->
         <div id="titlediv" class="postbox">
            <h3>
               <?php 
    _e('Location name', 'eme');
    ?>
            </h3>
            <div class="inside">
           <input name="location_name" id="title" type="text" required="required" value="<?php 
    echo eme_sanitize_html($location['location_name']);
    ?>
" size="40" />
           <?php 
    if ($action == "edit") {
        _e('Permalink: ', 'eme');
        echo trailingslashit(home_url()) . eme_permalink_convert(get_option('eme_permalink_locations_prefix')) . $location['location_id'] . "/";
        $slug = $location['location_slug'] ? $location['location_slug'] : $location['location_name'];
        $slug = untrailingslashit(eme_permalink_convert($slug));
        ?>
                    <input type="text" id="slug" name="location_slug" value="<?php 
        echo $slug;
        ?>
" /><?php 
        echo user_trailingslashit("");
        ?>
           <?php 
    }
    ?>
           </div>
         </div>
         <div class="postbox">
            <h3>
               <?php 
    _e('Location address', 'eme');
    ?>
            </h3>
            <div class="inside">
            <input id="location_address" name="location_address" type="text" value="<?php 
    echo eme_trans_sanitize_html($location['location_address']);
    ?>
" size="40" />
            </div>
         </div>
 
         <div class="postbox">
            <h3>
               <?php 
    _e('Location town', 'eme');
    ?>
            </h3>
            <div class="inside">
            <input name="location_town" id="location_town" type="text" value="<?php 
    echo eme_trans_sanitize_html($location['location_town']);
    ?>
" size="40" />
            </div>
         </div>
                        
         <div class="postbox">
            <h3>
               <?php 
    _e('Location latitude/longitude', 'eme');
    ?>
            </h3>
            <div class="inside">
            <table><tr>
            <td><label for="location_latitude"><?php 
    _e('Latitude', 'eme');
    ?>
</label></td>
            <td><input id="location_latitude" name="location_latitude" type="text" value="<?php 
    echo eme_sanitize_html($location['location_latitude']);
    ?>
" size="40" /></td>
            </tr>
            <tr>
            <td><label for="location_longitude"><?php 
    _e('Longitude', 'eme');
    ?>
</label></td>
            <td><input id="location_longitude" name="location_longitude" type="text" value="<?php 
    echo eme_sanitize_html($location['location_longitude']);
    ?>
" size="40" /></td>
            </tr></table>
            </div>
         </div>

         <div class="postbox">
            <h3>
               <?php 
    _e('Location image', 'eme');
    ?>
            </h3>
            <div class="inside">
             <?php 
    if (isset($location['location_image_url']) && !empty($location['location_image_url'])) {
        echo "<img id='eme_location_image_example' src='" . $location['location_image_url'] . "' width='200' />";
        echo "<input type='hidden' name='location_image_url' id='location_image_url' value='" . $location['location_image_url'] . "' />";
    } else {
        echo "<img id='eme_location_image_example' src='' alt='' width='200' />";
        echo "<input type='hidden' name='location_image_url' id='location_image_url' />";
    }
    if (isset($location['location_image_id']) && !empty($location['location_image_id'])) {
        echo "<input type='hidden' name='location_image_id' id='location_image_id' value='" . $location['location_image_id'] . "' />";
    } else {
        echo "<input type='hidden' name='location_image_id' id='location_image_id' />";
    }
    // based on code found at http://codestag.com/how-to-use-wordpress-3-5-media-uploader-in-theme-options/
    ?>

                <input type="button" name="location_image_button" id="location_image_button" value="<?php 
    _e('Set a featured image', 'eme');
    ?>
" />
                <input type="button" id="eme_remove_old_image" name="eme_remove_old_image" value=" <?php 
    _e('Unset featured image', 'eme');
    ?>
" />
            </div>
<script>
jQuery(document).ready(function($){

  $('#eme_remove_old_image').click(function(e) {
        $('#location_image_url').val('');
        $('#location_image_id').val('');
        $('#eme_location_image_example' ).attr("src",'');
  });
  $('#location_image_button').click(function(e) {
    e.preventDefault();

    var custom_uploader = wp.media({
        title: '<?php 
    _e('Select the image to be used as featured image', 'eme');
    ?>
',
        button: {
            text: '<?php 
    _e('Set featured image', 'eme');
    ?>
'
        },
        // Tell the modal to show only images.
        library: {
                type: 'image'
        },  
        multiple: false  // Set this to true to allow multiple files to be selected
    })
    .on('select', function() {
        var attachment = custom_uploader.state().get('selection').first().toJSON();
        $('#location_image_url').val(attachment.url);
        $('#location_image_id').val(attachment.id);
        $('#eme_location_image_example' ).attr("src",attachment.url);
    })
    .open();
  });
});
</script>
        </div>
 
        <?php 
    if (get_option('eme_categories_enabled')) {
        ?>
        <div class="postbox">
            <h3>
               <?php 
        _e('Category', 'eme');
        ?>
            </h3>
            <div class="inside">
           <?php 
        $categories = eme_get_categories();
        foreach ($categories as $category) {
            if ($location['location_category_ids'] && in_array($category['category_id'], explode(",", $location['location_category_ids']))) {
                $selected = "checked='checked'";
            } else {
                $selected = "";
            }
            ?>
              <input type="checkbox" name="location_category_ids[]" value="<?php 
            echo $category['category_id'];
            ?>
" <?php 
            echo $selected;
            ?>
 /><?php 
            echo eme_trans_sanitize_html($category['category_name']);
            ?>
<br />
           <?php 
        }
        ?>
            </div>
        </div>
        <?php 
    }
    ?>

         <?php 
    $gmap_is_active = get_option('eme_gmap_is_active');
    if ($gmap_is_active) {
        ?>
   
         <div class="postbox"><?php 
        if (function_exists('qtrans_getLanguage') || function_exists('ppqtrans_getLanguage') || defined('ICL_LANGUAGE_CODE')) {
            _e("Because qtranslate or a derivate is active, the title of the location might not update automatically in the balloon, so don't panic there.");
        }
        ?>
         </div>
         <div class="postbox" id="eme-admin-map-not-found"><p><?php 
        _e('Map not found', 'eme');
        ?>
</p></div>
         <div class="postbox" id="eme-admin-location-map"></div>
         <br style="clear:both;" />
         <?php 
    }
    ?>
         <div class="postbox" id="loc_description">
            <h3>
               <?php 
    _e('Location description', 'eme');
    ?>
            </h3>
            <div class="inside">
               <div id="<?php 
    echo user_can_richedit() ? 'postdivrich' : 'postdiv';
    ?>
" class="postarea">
                  <!-- we need content for qtranslate as ID -->
                  <?php 
    wp_editor($location['location_description'], "content");
    ?>
               </div>
               <?php 
    _e('A description of the Location. You may include any kind of info here.', 'eme');
    ?>
            </div>
         </div>
     	 <?php 
    if (get_option('eme_attributes_enabled')) {
        ?>
         <div class="postbox">
            <h3>
               <?php 
        _e('Attributes', 'eme');
        ?>
            </h3>
               <?php 
        eme_attributes_form($location);
        ?>
         </div>
       <?php 
    }
    ?>
         <div class="postbox">
            <h3>
               <?php 
    _e('External link', 'eme');
    ?>
            </h3>
            <div class="inside">
            <input name="location_url" id="location_url" type="text" value="<?php 
    echo eme_sanitize_html($location['location_url']);
    ?>
" size="40" />
            <p><?php 
    _e('If this is filled in, the single location URL will point to this url instead of the standard location page.', 'eme');
    ?>
</p>
            </div>
         </div>
         <p class="submit"><input type="submit" class="button-primary" name="submit" value="<?php 
    if ($action == "add") {
        _e('Add location', 'eme');
    } else {
        _e('Update location', 'eme');
    }
    ?>
" /></p>
      </div>
      </form>
   </div>
   <?php 
}
Example #2
0
function eme_meta_box_div_event_attributes($event)
{
    eme_attributes_form($event);
}