function adgear_format_selector_ui($args) { extract($args); ?> <select class="adgear_format_selector" name="<?php echo $name; ?> " id="<?php echo $id; ?> "> <?php if ($include_blank) { ?> <option value="">Choose an Ad format…</option> <?php } foreach (adgear_formats() as $format) { ?> <option <?php if ($selected == $format['id']) { echo "selected"; } ?> value="<?php echo $format["id"]; ?> "><?php echo $format["name"]; if ($format["width"]) { ?> (<?php echo $format["width"]; ?> ×<?php echo $format["height"]; ?> )<?php } ?> </option> <?php } ?> </select> <?php }
function adgear_settings_page() { $plugin_url = WP_PLUGIN_URL . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)); ?> <div class="wrap"> <h2>Settings for AdGear <img height="40" alt="" src="<?php echo $plugin_url . '../adgear-logo.png'; ?> "/></h2> <?php if (function_exists('curl_init')) { ?> <form method="post" action="options.php"> <?php settings_fields('adgear-settings-group'); ?> <table class="form-table"> <tr valign="top"> <th scope="row"><?php echo _e('API Username'); ?> </th> <td><input type="text" name="adgear_api_username" value="<?php echo get_option('adgear_api_username', ''); ?> " /></td> </tr> <tr valign="top"> <th scope="row"><?php echo _e('API Digest Key'); ?> </th> <td><input type="text" name="adgear_api_key" size="68" value="<?php echo get_option('adgear_api_key', ''); ?> " /></td> </tr> <tr valign="top"> <th scope="row"><?php echo _e('API Root URL'); ?> </th> <td><input type="text" name="adgear_api_root_url" size="40" value="<?php echo get_option('adgear_api_root_url', 'http://api.admin.adgear.com/'); ?> " /></td> </tr> <tr valign="top"> <th scope="row"><?php echo _e('AdGear Site'); ?> </th> <td> <?php if (get_option('adgear_api_username') && get_option('adgear_api_key') && get_option('adgear_api_root_url')) { /* API username set, so we presume we can talk to AdGear */ $sites = adgear_get_service_data('list_sites'); if (empty($sites)) { echo '<span style="color:#c33;">'; echo _e('Your AdGear credentials appear to be incorrect: we couldn\'t find any configured sites in your account. Create a site in AdGear or verify your credentials.'); echo "</span>"; } else { ?> <select name="adgear_site_id"> <option value=""><?php echo _e('Choose your site…'); ?> </option> <?php foreach ($sites["sites"] as $site) { ?> <option value="<?php echo $site["id"]; ?> "<?php if ($site["id"] == get_option('adgear_site_id')) { echo ' selected="selected"'; } ?> ><?php echo $site["name"]; ?> </option> <?php } ?> </select> <?php } } else { /* Configuration not set yet */ ?> <p><?php _e('Set your AdGear credentials above, then save the settings to see which sites are already configured.'); ?> </p> <?php } ?> </td> </tr> </table> <p class="submit"> <input type="submit" class="button-primary" value="<?php _e('Save Changes'); ?> " /> <?php if (get_option('adgear_site_id') && get_option('adgear_api_username') && get_option('adgear_api_key') && get_option('adgear_api_root_url')) { $sites = adgear_get_service_data('list_sites'); if (!empty($sites)) { ?> <input type="submit" name="adgear_reload_adgear_data" class="button-secondary" value="<?php _e('Reload AdGear AdSpots and Formats'); ?> " /> <?php } } ?> </p> <?php if (get_option('adgear_site_id') && get_option('adgear_api_username') && get_option('adgear_api_key') && get_option('adgear_api_root_url') && count(adgear_formats()) == 0) { echo "<p>" . _e('Your database does not contain any formats. Use the <em>Reload AdGear AdSpots and Formats</em> button above to prime your database.') . "</p>"; } ?> <p><?php echo _e("To remove this plugin and all it's configuration, visit the <a href='" . get_bloginfo('wpurl') . "/wp-admin/plugins.php'>plugins</a> page."); ?> </p> </form> <?php } else { ?> <p><?php echo _e('Sorry, but cURL support is required for this plugin to work. Follow the instructions on <a href="http://www.php.net/manual/en/curl.installation.php">PHP: Installation</a> for details.'); ?> </p> <?php } /* curl_init function does not exist */ echo "</div>"; }