Пример #1
0
/**
 * Shows the additional application key drop down, given a setting name
 * @param  string $setting_name The corresponding setting name (should match that of the options name for sending notifications
 * to keep things simple)
 * @return void                Echo's out the drop down, no return
 */
function ckpn_display_application_key_dropdown($setting_name = false)
{
    $options = ckpn_get_options();
    if (!$options['multiple_keys']) {
        return false;
    }
    if (empty($setting_name)) {
        return false;
    }
    $all_keys = ckpn_get_application_keys();
    $current_mappings = get_option('_ckpn_additional_key_mapping');
    ?>
<select name="_ckpn_additional_key_mapping[<?php 
    echo $setting_name;
    ?>
]"><?php 
    foreach ($all_keys as $id => $key) {
        $currently_mapped_option = isset($current_mappings[$setting_name]) ? $current_mappings[$setting_name] : false;
        ?>
<option value="<?php 
        echo $id;
        ?>
" <?php 
        selected($id, $currently_mapped_option, true);
        ?>
><?php 
        echo $key['name'];
        ?>
</option><?php 
    }
    ?>
</select><?php 
}
Пример #2
0
/**
 * Given the setting name, return the application key
 * @param  string $setting The setting name associated with the notification being sent
 * @return string          The application key to send the notification with
 */
function ckpn_get_application_key_by_setting($setting = NULL)
{
    if (empty($setting)) {
        return false;
    }
    $current_mappings = get_option('_ckpn_additional_key_mapping');
    $mapped_key = $current_mappings[$setting];
    $all_keys = ckpn_get_application_keys();
    if (!isset($all_keys[$mapped_key])) {
        return false;
    }
    return $all_keys[$mapped_key]['app_key'];
}