| @@ -1,58 +1,82 @@ | ||
| 1 | 1 | <?php |
| 2 | - $footnoteOptions = get_option('easy_footnotes_options'); | |
| 2 | +/** | |
| 3 | + * Admin screen functionality for Easy Footnotes. | |
| 4 | + * | |
| 5 | + * @package easy-footnotes | |
| 6 | + */ | |
| 3 | 7 | |
| 4 | - if ( isset($_POST['easy_footnote_hidden']) && $_POST['easy_footnote_hidden'] == 'Y' ) { | |
| 5 | - //Form data sent | |
| 6 | - $easyFootnoteLabel = $_POST['easy_footnotes_label']; | |
| 7 | - if ($_POST['easy_footnote_check']) { | |
| 8 | - $easyFootnoteCheck = true; | |
| 9 | - } else { | |
| 10 | - $easyFootnoteCheck = false; | |
| 11 | - } | |
| 12 | - $updateOptions = array( | |
| 13 | - 'footnoteLabel' => $easyFootnoteLabel, | |
| 14 | - 'useLabel' => $easyFootnoteCheck, | |
| 15 | - ); | |
| 8 | +$footnoteOptions = get_option( 'easy_footnotes_options' ); | |
| 16 | 9 | |
| 17 | - update_option('easy_footnotes_options', $updateOptions); | |
| 10 | +if ( isset( $_POST['easy_footnote_hidden'] ) ) { | |
| 11 | + // Check the nonce for the Reading Time. | |
| 12 | + check_admin_referer( 'easy_footnotes_settings_nonce' ); | |
| 18 | 13 | |
| 19 | - ?> | |
| 20 | - <div class="updated"><p><strong><?php esc_html_e('Options saved.' ); ?></strong></p></div> | |
| 21 | - <?php | |
| 22 | - } else { | |
| 23 | - //Normal page display | |
| 24 | - $easyFootnoteLabel = $footnoteOptions['footnoteLabel']; | |
| 25 | - $easyFootnoteCheck = $footnoteOptions['useLabel']; | |
| 26 | - } | |
| 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 | +} | |
| 27 | 48 | ?> |
| 28 | 49 | |
| 29 | 50 | <div class="wrap"> |
| 30 | - <?php echo "<h2>" . esc_html__( 'Easy Footnotes Settings', 'easy_footnotes_trdom' ) . "</h2>"; ?> | |
| 51 | + <?php echo '<h2>' . esc_html__( 'Easy Footnotes Settings', 'easy-footnotes' ) . '</h2>'; ?> | |
| 31 | 52 | |
| 32 | - <form name="easy_footnotes_form" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>"> | |
| 33 | - <input type="hidden" name="easy_footnote_hidden" value="Y"> | |
| 34 | - <?php echo "<h4>" . esc_html__( 'Easy Footnotes Settings', 'easy_footnotes_trdom' ) . "</h4>"; ?> | |
| 35 | - <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."); ?></p> | |
| 36 | - <p><?php esc_html_e("Easy Footnotes Label: "); ?><input type="text" name="easy_footnotes_label" value="<?php echo esc_attr($easyFootnoteLabel); ?>" size="20"></p> | |
| 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> | |
| 37 | 59 | |
| 38 | - <p><?php esc_html_e("Insert Easy Footnotes Label: "); ?><input type="checkbox" name="easy_footnote_check" <?php checked($easyFootnoteCheck); ?> size="20"><?php esc_html_e(""); ?></p> | |
| 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> | |
| 39 | 61 | |
| 40 | - <p class="submit"> | |
| 41 | - <input type="submit" name="Submit" value="<?php esc_attr_e('Update Options', 'easy_footnotes_trdom' ) ?>" /> | |
| 42 | - </p> | |
| 43 | - </form> | |
| 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> | |
| 44 | 63 | |
| 45 | - <div class="easy-footnotes-shortcode-hint"> | |
| 46 | - <p><?php echo __('Shortcode: [note]Insert your note here.[/note]', 'easy-footnotes'); ?></p> | |
| 47 | - </div> | |
| 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> | |
| 48 | 65 | |
| 49 | - <div class="efn-preview"> | |
| 50 | - <a class="efn-theme-link" href="<?php echo esc_url( 'https://www.themes.pizza/utm_source=easy-footnotes&utm_medium=button&utm_campaign=efnupsell' ); ?>" target="_blank"><img src="<?php echo plugins_url( '/assets/zuul-wordpress-theme.jpg' , __FILE__ ); ?>" alt="Zuul WordPress Theme homepage in various color options" /></a> | |
| 51 | - <div class="efn-preview-copy"> | |
| 52 | - <h2><?php echo __( 'Tasty WordPress Themes', 'easy-footnotes' ); ?></h2> | |
| 53 | - <p><?php printf( __( 'Love easy footnotes? Check out my premium themes now available on Themes.Pizza. Each theme is hand crafted from the finest ingredients with a specific purpose in mind. Need to start a side project / membership site? Try out <a href="%1s" target="_blank">Zuul</a>. Looking to establish yourself as an authoirty on a subject? Try out <a href="%2s" target="_blank">The Authority Pro</a>.', 'easy-footnotes' ), esc_url( 'https://www.themes.pizza/downloads/zuul-pro/utm_source=easy-footnotes&utm_medium=button&utm_campaign=efnupsell' ), esc_url( 'https://www.themes.pizza/downloads/the-authority-pro/utm_source=easy-footnotes&utm_medium=button&utm_campaign=efnupsell' ) ); ?></p> | |
| 54 | - <p><?php echo __( 'All themes are 100% GPL. Use them on as many sites as you want and make something awesome! And for being a faithful Easy Footnotes user get 20% off with the code <strong>TASTYZA</strong>.', 'easy-footnotes' ); ?></p> | |
| 55 | - <a class="efn-theme-button" href="<?php echo esc_url( 'https://www.themes.pizza/utm_source=easy-footnotes&utm_medium=button&utm_campaign=efnupsell' ); ?>" target="_blank"><?php echo __( 'Shop Now', 'easy-footnotes' ); ?></a> | |
| 56 | - </div> | |
| 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> | |
| 57 | 80 | </div> |
| 81 | + | |
| 58 | 82 | </div> |