| 1 |
<?php |
| 2 |
/** |
| 3 |
* Admin screen functionality for Easy Footnotes. |
| 4 |
* |
| 5 |
* @package easy-footnotes |
| 6 |
*/ |
| 7 |
|
| 8 |
$footnoteOptions = get_option( 'easy_footnotes_options' ); |
| 9 |
|
| 10 |
if ( isset( $_POST['easy_footnote_hidden'] ) ) { |
| 11 |
// Check the nonce for the Reading Time. |
| 12 |
check_admin_referer( 'easy_footnotes_settings_nonce' ); |
| 13 |
|
| 14 |
if ( 'Y' === $_POST['easy_footnote_hidden'] ) : |
| 15 |
// Form data sent. |
| 16 |
$easyFootnoteLabel = ( isset( $_POST['easy_footnotes_label'] ) ) ? sanitize_text_field( wp_unslash( $_POST['easy_footnotes_label'] ) ) : ''; |
| 17 |
$easyFootnoteCheck = isset( $_POST['easy_footnote_check'] ) ? true : false; |
| 18 |
$hide_easy_footnote_after_posts = isset( $_POST['hide_easy_footnote_after_posts'] ) ? true : false; |
| 19 |
$show_easy_footnote_on_front = isset( $_POST['show_easy_footnote_on_front'] ) ? true : false; |
| 20 |
$reset_footnotes = isset( $_POST['reset_footnotes'] ) ? true : false; |
| 21 |
$combine_duplicate_footnotes = isset( $_POST['combine_duplicate_footnotes'] ) ? true : false; |
| 22 |
|
| 23 |
$updateOptions = array( |
| 24 |
'footnoteLabel' => sanitize_text_field( $easyFootnoteLabel ), |
| 25 |
'useLabel' => $easyFootnoteCheck, |
| 26 |
'hide_easy_footnote_after_posts' => $hide_easy_footnote_after_posts, |
| 27 |
'show_easy_footnote_on_front' => $show_easy_footnote_on_front, |
| 28 |
'reset_footnotes' => $reset_footnotes, |
| 29 |
'combine_duplicate_footnotes' => $combine_duplicate_footnotes, |
| 30 |
); |
| 31 |
|
| 32 |
update_option( 'easy_footnotes_options', $updateOptions ); |
| 33 |
?> |
| 34 |
<div class="updated"> |
| 35 |
<p><strong><?php esc_html_e( 'Options saved.', 'easy-footnotes' ); ?></strong></p> |
| 36 |
</div> |
| 37 |
<?php |
| 38 |
endif; |
| 39 |
} else { |
| 40 |
// Normal page display. |
| 41 |
$easyFootnoteLabel = isset( $footnoteOptions['footnoteLabel'] ) ? esc_html( $footnoteOptions['footnoteLabel'] ) : __( 'Footnotes', 'easy-footnotes' ); |
| 42 |
$easyFootnoteCheck = isset( $footnoteOptions['useLabel'] ) ? $footnoteOptions['useLabel'] : false; |
| 43 |
$hide_easy_footnote_after_posts = isset( $footnoteOptions['hide_easy_footnote_after_posts'] ) ? $footnoteOptions['hide_easy_footnote_after_posts'] : false; |
| 44 |
$show_easy_footnote_on_front = isset( $footnoteOptions['show_easy_footnote_on_front'] ) ? $footnoteOptions['show_easy_footnote_on_front'] : false; |
| 45 |
$reset_footnotes = isset( $footnoteOptions['reset_footnotes'] ) ? $footnoteOptions['reset_footnotes'] : false; |
| 46 |
$combine_duplicate_footnotes = isset( $footnoteOptions['combine_duplicate_footnotes'] ) ? $footnoteOptions['combine_duplicate_footnotes'] : false; |
| 47 |
} |
| 48 |
?> |
| 49 |
|
| 50 |
<div class="wrap"> |
| 51 |
<?php echo '<h2>' . esc_html__( 'Easy Footnotes Settings', 'easy-footnotes' ) . '</h2>'; ?> |
| 52 |
|
| 53 |
<form name="easy_footnotes_form" method="post"> |
| 54 |
<input type="hidden" name="easy_footnote_hidden" value="Y"> |
| 55 |
<?php wp_nonce_field( 'easy_footnotes_settings_nonce' ); ?> |
| 56 |
<?php echo '<h4>' . esc_html__( 'Easy Footnotes Settings', 'easy-footnotes' ) . '</h4>'; ?> |
| 57 |
<p><?php esc_html_e( 'Want to add a label to your footnotes section at the bottom of your post? Just enter some text here and check the box and you\'re good to go.', 'easy-footnotes' ); ?></p> |
| 58 |
<p><?php esc_html_e( 'Easy Footnotes Label: ', 'easy-footnotes' ); ?><input type="text" name="easy_footnotes_label" value="<?php echo esc_attr( $easyFootnoteLabel ); ?>" size="20"></p> |
| 59 |
|
| 60 |
<p><?php esc_html_e( 'Insert Easy Footnotes Label: ', 'easy-footnotes' ); ?><input type="checkbox" name="easy_footnote_check" <?php checked( $easyFootnoteCheck ); ?> size="20"></p> |
| 61 |
|
| 62 |
<p><?php esc_html_e( 'Hide Footnotes after post content: ', 'easy-footnotes' ); ?><input type="checkbox" name="hide_easy_footnote_after_posts" <?php checked( $hide_easy_footnote_after_posts ); ?> size="20"></p> |
| 63 |
|
| 64 |
<p id="easy_footnote_on_front"><?php esc_html_e( 'Show Footnotes on Front Page: ', 'easy-footnotes' ); ?><input type="checkbox" name="show_easy_footnote_on_front" <?php checked( $show_easy_footnote_on_front ); ?> size="20"></p> |
| 65 |
|
| 66 |
<p><?php esc_html_e( 'Combine duplicate footnotes: ', 'easy-footnotes' ); ?><input type="checkbox" name="combine_duplicate_footnotes" <?php checked( $combine_duplicate_footnotes ); ?> size="20"></p> |
| 67 |
|
| 68 |
<p><?php esc_html_e( 'Reset Footnotes to avoid duplication after the content: ', 'easy-footnotes' ); ?><input type="checkbox" name="reset_footnotes" <?php checked( $reset_footnotes ); ?> size="20"> |
| 69 |
<br> |
| 70 |
<span><?php esc_html_e( 'If you have "Combine duplicate footnotes" turned on, you should leave this setting off. ', 'easy-footnotes' ); ?><span> |
| 71 |
</p> |
| 72 |
|
| 73 |
<p class="submit"> |
| 74 |
<input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options', 'easy-footnotes' ); ?>" /> |
| 75 |
</p> |
| 76 |
</form> |
| 77 |
|
| 78 |
<div class="easy-footnotes-shortcode-hint"> |
| 79 |
<p><?php echo esc_html__( 'Shortcode: [efn_note]Insert your note here.[/efn_note]', 'easy-footnotes' ); ?></p> |
| 80 |
</div> |
| 81 |
|
| 82 |
</div> |
| 83 |
|