function form($instance)
    {
        if (adgear_is_dynamic_site()) {
            $options = array('format_id' => '', 'path_type' => 'categories', 'path' => '', 'slugify' => 'yes', 'single' => 'all');
        } else {
            $options = array('adspot_id' => '', 'single' => 'all');
        }
        $instance = wp_parse_args((array) $instance, $options);
        $single = strip_tags($instance['single']);
        echo '<div class="adgear-meta" style="margin:0;padding:0">';
        if (adgear_is_dynamic_site()) {
            $format_id = strip_tags($instance['format_id']);
            $path_type = strip_tags($instance['path_type']);
            $path = strip_tags($instance['path']);
            $slugify = strip_tags($instance['slugify']);
            /* Backwards compatibility: don't show ugly error messages when the keys don't exist */
            if (array_key_exists('path_pre', $instance)) {
                $path_pre = strip_tags($instance['path_pre']);
                $path_middle = strip_tags($instance['path_middle']);
                $path_post = strip_tags($instance['path_post']);
            } else {
                $path_pre = $path_middle = $path_post = "";
            }
            if ($path_pre == "" && $path_middle == "" && $path_post == "") {
                $show_advanced = false;
            } else {
                $show_advanced = true;
            }
            ?>
      <p>
      <label for="<?php 
            echo $this->get_field_id('format_id');
            ?>
"><?php 
            _e('Ad Format:');
            ?>
</label>
        <?php 
            adgear_format_selector_ui(array('id' => $this->get_field_id('format_id'), 'name' => $this->get_field_name('format_id'), 'selected' => $format_id, 'include_blank' => true));
            ?>
      </p>
      <p class="adgear_advanced" style="<?php 
            if (!$show_advanced) {
                echo "display:none";
            }
            ?>
">
        <label for="<?php 
            echo $this->get_field_id('path_pre');
            ?>
"><?php 
            _e('Path before:');
            ?>
</label>
        <?php 
            adgear_path_pre_ui(array('id' => $this->get_field_id('path_pre'), 'name' => $this->get_field_name('path_pre'), 'value' => $path_pre));
            ?>
      </p>
      <p>
        <label for="<?php 
            echo $this->get_field_id('path_type');
            ?>
"><?php 
            _e('Path type:');
            ?>
</label>
        <?php 
            adgear_path_type_selector_ui(array('id' => $this->get_field_id('path_type'), 'name' => $this->get_field_name('path_type'), 'selected' => $path_type, 'path_id' => $this->get_field_id('path'), 'path_name' => $this->get_field_name('path'), 'path_selected' => $path));
            ?>
      </p>
      <p class="adgear_advanced" style="<?php 
            if (!$show_advanced) {
                echo "display:none";
            }
            ?>
">
        <label for="<?php 
            echo $this->get_field_id('path_middle');
            ?>
"><?php 
            _e('Path middle:');
            ?>
</label>
        <?php 
            adgear_path_middle_ui(array('id' => $this->get_field_id('path_middle'), 'name' => $this->get_field_name('path_middle'), 'value' => $path_middle));
            ?>
      </p>
      <p>
        <label for="<?php 
            echo $this->get_field_id('slugify');
            ?>
"><?php 
            _e('Use post\'s slug in path:');
            ?>
</label>
        <?php 
            adgear_slugify_selector_ui(array('id' => $this->get_field_id('slugify'), 'name' => $this->get_field_name('slugify'), 'selected' => $slugify));
            ?>
      </p>
      <p class="adgear_advanced" style="<?php 
            if (!$show_advanced) {
                echo "display:none";
            }
            ?>
">
        <label for="<?php 
            echo $this->get_field_id('path_post');
            ?>
"><?php 
            _e('Path after:');
            ?>
</label>
        <?php 
            adgear_path_post_ui(array('id' => $this->get_field_id('path_post'), 'name' => $this->get_field_name('path_post'), 'value' => $path_post));
            ?>
      </p>
      <p>
        <label><?php 
            _e('Show advanced path options');
            ?>
 <?php 
            adgear_toggle_advanced_ui(array('selected' => $show_advanced));
            ?>
</label>
        <?php 
            adgear_example_ui(array('selected' => $show_advanced));
            ?>
      </p>
<?php 
        } else {
            $adspot_id = strip_tags($instance['adspot_id']);
            ?>
      <p>
        <label for="<?php 
            echo $this->get_field_id('adspot_id');
            ?>
"><?php 
            _e('Ad spot:');
            ?>
</label>
        <?php 
            adgear_adspot_selector_ui(array('id' => $this->get_field_id('adspot_id'), 'name' => $this->get_field_name('adspot_id'), 'selected' => $adspot_id));
            ?>
      </p>
<?php 
        }
        ?>
      <p>
        <label for="<?php 
        $this->get_field_id('single');
        ?>
"><?php 
        _e('When to show this ad:');
        ?>
</label>
        <?php 
        adgear_single_selector_ui(array('id' => $this->get_field_id('single'), 'name' => $this->get_field_name('single'), 'selected' => $single));
        ?>
      </p>
      <div style="display:none;margin:0;padding:0">
        <input type="hidden" value="<?php 
        echo adgear_is_dynamic_site();
        ?>
" id="adgear_site_is_dynamic"/>
      </div>
    </div>
<?php 
    }
예제 #2
0
function adgear_meta_box_form()
{
    ?>
        <table id="adgear-meta" class="form-table adgear-meta">
<?php 
    if (adgear_is_dynamic_site()) {
        ?>
            <tr valign="top">
                <th scope="row"><label for="adgear_format_id"><?php 
        _e('Ad Format:');
        ?>
</label></th>
                <td>
                  <?php 
        adgear_format_selector_ui(array('id' => 'adgear_format_id', 'name' => 'adgear[format_id]', 'selected' => '', 'include_blank' => true));
        ?>
                </td>
            </tr>
            <tr valign="top" class="adgear_advanced" style="display:none">
              <th scope="row"><label for="adgear_path_pre"><?php 
        _e('Path before:');
        ?>
</label></th>
              <td>
                <?php 
        adgear_path_pre_ui(array('id' => 'adgear_path_pre', 'name' => 'adgear[path_pre]', 'value' => ''));
        ?>
              </td>
            </tr>
            <tr valign="top">
              <th scope="row"><label for="adgear_type"><?php 
        _e('Path type:');
        ?>
</label></th>
              <td>
                <?php 
        adgear_path_type_selector_ui(array('id' => 'adgear_type', 'name' => 'adgear[type]', 'selected' => 'categories', 'path_id' => 'adgear_path', 'path_name' => 'adgear[path]', 'path_selected' => ''));
        ?>
              </td>
            </tr>
            <tr valign="top" class="adgear_advanced" style="display:none">
              <th scope="row"><label for="adgear_path_middle"><?php 
        _e('Path middle:');
        ?>
</label></th>
              <td>
                <?php 
        adgear_path_middle_ui(array('id' => 'adgear_path_middle', 'name' => 'adgear[path_middle]', 'value' => ''));
        ?>
              </td>
            </tr>
            <tr valign="top">
              <th scope="row"><label for="adgear_slugify"><?php 
        _e('Use post\'s slug in path:');
        ?>
</label></th>
              <td>
                <?php 
        adgear_slugify_selector_ui(array('id' => 'adgear_slugify', 'name' => 'adgear[slugify]', 'selected' => 'yes'));
        ?>
              </td>
            </tr>
            <tr valign="top" class="adgear_advanced" style="display:none">
              <th scope="row"><label for="adgear_path_post"><?php 
        _e('Path after:');
        ?>
</label></th>
              <td>
                <?php 
        adgear_path_post_ui(array('id' => 'adgear_path_post', 'name' => 'adgear[path_post]', 'value' => ''));
        ?>
              </td>
            </tr>
            <tr valign="top">
              <th scope="row"><label for="adgear_toggle_advanced"><?php 
        _e('Show advanced path options');
        ?>
</label></th>
              <td>
                <?php 
        adgear_toggle_advanced_ui(array('selected' => false));
        ?>
                <?php 
        adgear_example_ui(array('selected' => false));
        ?>
              </td>
            </tr>
<?php 
    } else {
        ?>
            <tr valign="top">
                <th scope="row"><label for="adgear_adspot_id"><?php 
        _e('Ad Spot:');
        ?>
</label></th>
                <td>
                  <?php 
        adgear_adspot_selector_ui(array('id' => 'adgear_adspot_id', 'name' => 'adgear[adspot_id]', 'selected' => ''));
        ?>
                </td>
            </tr>
<?php 
    }
    /* static site */
    ?>
            <tr valign="top">
              <th scope="row"><label for="adgear_single"><?php 
    _e('When to show this ad:');
    ?>
</label></th>
              <td>
                <?php 
    adgear_single_selector_ui(array('id' => 'adgear_single', 'name' => 'adgear[single]', 'selected' => 'all'));
    ?>
              </td>
            </tr>
          <tr valign="top">
            <th scope="row"><label for="adgear_embed_code"><?php 
    _e('Embed Code:');
    ?>
</label></th>
            <td>
              <input type="text" id="adgear_embed_code" name="adgear[embed_code]" size="40" style="width:95%;" autocomplete="off" />
            </td>
          </tr>
        </table>
        <p class="submit">
          <input type="button" id="adgear_send_embed_code_to_editor" value="<?php 
    _e('Send Embed Code to Editor &raquo;');
    ?>
" />
        </p>
        <div style="display:none;margin:0;padding:0">
          <input type="hidden" name="adgear[is_dynamic]" value="<?php 
    echo adgear_is_dynamic_site();
    ?>
" id="adgear_site_is_dynamic"/>
        </div>
        <script type="text/javascript"><?php 
    // Correctly set a value in the embed code field
    if (adgear_is_dynamic_site()) {
        echo "adgearDynamicSiteChange";
    } else {
        echo "adgearStaticSiteChange";
    }
    ?>
(jQuery, "#adgear-meta");</script>
<?php 
}