| 1 | <?php |
| 2 | add_action( 'admin_menu', 'dnxasi_add_admin_menu' ); |
| 3 | add_action( 'admin_init', 'dnxasi_settings_init' ); |
| 4 | |
| 5 | function dnxasi_add_admin_menu() { |
| 6 | $dnxasi_settings_page = add_options_page( 'danixland author signature', 'Author Signature', 'manage_options', 'dnxasi', 'dnxasi_options_page' ); |
| 7 | add_action( 'load-' . $dnxasi_settings_page, 'dnxasi_load_admin_scripts' ); |
| 8 | } |
| 9 | |
| 10 | function dnxasi_load_admin_scripts() { |
| 11 | add_action( 'admin_enqueue_scripts', 'dnxasi_enqueue_styles' ); |
| 12 | } |
| 13 | |
| 14 | // enqueue our scripts |
| 15 | function dnxasi_enqueue_styles() { |
| 16 | wp_enqueue_style( 'dnxasi_admin_style', plugins_url('/css/dnxasi_admin_style.css', dirname(__FILE__)), array(), '0.1' ); |
| 17 | } |
| 18 | |
| 19 | |
| 20 | function dnxasi_settings_init() { |
| 21 | |
| 22 | register_setting( 'dnxasi_options', 'dnxasi_settings' ); |
| 23 | |
| 24 | add_settings_section( |
| 25 | 'dnxasi_pluginPage_section', |
| 26 | __( 'Global Signature positioning and sizing', 'dnxasi' ), |
| 27 | 'dnxasi_settings_section_callback', |
| 28 | 'dnxasi_options' |
| 29 | ); |
| 30 | |
| 31 | add_settings_field( |
| 32 | 'dnxasi_signature_position', |
| 33 | __( 'Signature alignment?', 'dnxasi' ), |
| 34 | 'dnxasi_signature_position_render', |
| 35 | 'dnxasi_options', |
| 36 | 'dnxasi_pluginPage_section' |
| 37 | ); |
| 38 | |
| 39 | add_settings_field( |
| 40 | 'dnxasi_signature_size', |
| 41 | __( 'signature width?', 'dnxasi' ), |
| 42 | 'dnxasi_signature_size_render', |
| 43 | 'dnxasi_options', |
| 44 | 'dnxasi_pluginPage_section' |
| 45 | ); |
| 46 | |
| 47 | } |
| 48 | |
| 49 | |
| 50 | function dnxasi_signature_position_render( ) { |
| 51 | |
| 52 | $options = get_option( 'dnxasi_settings' ); |
| 53 | ?> |
| 54 | <label class="description dnxasi_label"> |
| 55 | <input type='radio' name='dnxasi_settings[dnxasi_signature_position]' <?php checked( $options['dnxasi_signature_position'], 'left' ); ?> value='left'> |
| 56 | <span> |
| 57 | <img src="<?php echo plugins_url('/img/signature-left.png', dirname(__FILE__)); ?>" alt=""> |
| 58 | <?php _e('left', 'dnxasi'); ?> |
| 59 | </span> |
| 60 | </label> |
| 61 | <label class="description dnxasi_label"> |
| 62 | <input type='radio' name='dnxasi_settings[dnxasi_signature_position]' <?php checked( $options['dnxasi_signature_position'], 'center' ); ?> value='center'> |
| 63 | <span> |
| 64 | <img src="<?php echo plugins_url('/img/signature-center.png', dirname(__FILE__)); ?>" alt=""> |
| 65 | <?php _e('center', 'dnxasi'); ?> |
| 66 | </span> |
| 67 | </label> |
| 68 | <label class="description dnxasi_label"> |
| 69 | <input type='radio' name='dnxasi_settings[dnxasi_signature_position]' <?php checked( $options['dnxasi_signature_position'], 'right' ); ?> value='right'> |
| 70 | <span> |
| 71 | <img src="<?php echo plugins_url('/img/signature-right.png', dirname(__FILE__)); ?>" alt=""> |
| 72 | <?php _e('right <small>(default)</small>', 'dnxasi'); ?> |
| 73 | </span> |
| 74 | </label> |
| 75 | <?php |
| 76 | |
| 77 | } |
| 78 | |
| 79 | function dnxasi_signature_size_render ( ) { |
| 80 | $options = get_option( 'dnxasi_settings' ); |
| 81 | ?> |
| 82 | <label class="description"> |
| 83 | <input type="number" name="dnxasi_settings[dnxasi_signature_size]" min="1" max="1600" placeholder="300" value="<?php echo $options['dnxasi_signature_size']; ?>"> <?php _e('pixels', 'dnxasi'); ?><br> |
| 84 | </label> |
| 85 | <p class="description"><?php _e('set the width in pixels for your signature image and it will be scaled accordingly. If you leave this field empty the default width of <strong>300px</strong> will be used.', 'dnxasi'); ?></p> |
| 86 | <?php |
| 87 | } |
| 88 | |
| 89 | function dnxasi_settings_section_callback( ) { |
| 90 | |
| 91 | echo __( 'Choose how you want to position and scale the signature at the bottom of the article.', 'dnxasi' ); |
| 92 | |
| 93 | } |
| 94 | |
| 95 | |
| 96 | function dnxasi_options_page( ) { |
| 97 | |
| 98 | ?> |
| 99 | <h2><?php _e('danixland Author Signature Settings', 'dnxasi'); ?></h2> |
| 100 | |
| 101 | <p class="description"><?php printf( |
| 102 | __('To upload your signature image go to your <a href="%1$s">profile page</a>, here on this page you can set up the general look of the signature trough the website.', 'dnxasi'), |
| 103 | admin_url('profile.php') |
| 104 | ); ?></p> |
| 105 | |
| 106 | <form action='options.php' method='post'> |
| 107 | |
| 108 | <?php |
| 109 | settings_fields( 'dnxasi_options' ); |
| 110 | do_settings_sections( 'dnxasi_options' ); |
| 111 | submit_button(); |
| 112 | ?> |
| 113 | |
| 114 | </form> |
| 115 | <?php |
| 116 | |
| 117 | } |