Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Class for adding a new field to the options-general.php page
- */
- class ct_drop_add_profile_image_upload {
- /**
- * Class constructor
- */
- public function __construct() {
- add_filter( 'admin_init' , array( &$this , 'register_fields' ) );
- }
- /**
- * Add new fields to wp-admin/options-general.php page
- */
- public function register_fields() {
- register_setting( 'general', 'ct_drop_profile_image_upload', 'esc_attr' );
- add_settings_field(
- 'ct_drop_profile_image_upload',
- '<label for="ct_drop_profile_image_upload">' . __( 'Avatar' , 'drop' ) . '</label>',
- array( &$this, 'fields_html' ),
- 'general'
- );
- }
- /**
- * HTML for extra settings
- */
- public function fields_html() {
- $value = get_option( 'ct_drop_profile_image_upload', '' );
- ?>
- <!-- Outputs the image after save -->
- <img id="image-preview" src="<?php echo esc_url( $value ); ?>" style="width:100px;"><br />
- <!-- Outputs the text field and displays the URL of the image retrieved by the media uploader -->
- <input type="text" name="ct_drop_profile_image_upload" id="ct_drop_profile_image_upload" value="<?php echo esc_url_raw( $value ); ?>" class="regular-text" />
- <!-- Outputs the save button -->
- <input type='button' id="profile-image-upload" class="button-primary" value="<?php _e( 'Upload Image', 'drop' ); ?>"/><br />
- <span class="description"><?php _e( 'This image will be used in the sidebar instead of your Gravatar.', 'drop' ); ?></span>
- <?php
- }
- }
- new ct_drop_add_profile_image_upload();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement