Plugin Directory

Changeset 2100496


Ignore:
Timestamp:
06/04/2019 03:19:41 PM (7 years ago)
Author:
inderjeetsingh
Message:
  • Added functionality to show hide text
  • Added functionality to manually enter text
  • Added functionality to color text
Location:
post-thanks/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • post-thanks/trunk/postthankyou.php

    r2087796 r2100496  
    1717 */
    1818 
     19add_action('admin_menu', 'p_my_thank_you_menu');
     20
     21function p_my_thank_you_menu() {
     22    add_menu_page(__('p_my_thank_you_form', 'thank-you'), __('Post Thank You', 'thank-you'), 'manage_options', 'p_my_thank_you_form', 'p_my_thank_you_form');
     23}
     24
     25function p_my_thank_you_form() {
     26   
     27        echo '
     28        <br>
     29        <br>
     30        <br>
     31    <div class="container">
     32  <h2>Post Thank You ---- Menu</h2>
     33    <form action="' . $_SERVER['REQUEST_URI'] . '" method="post">
     34    <p>Display or Hide text:</p>
     35    <div class="radio">
     36      <label><input type="radio" name="displayhide" value="block" checked>Display text</label>
     37    </div>
     38    <div class="radio">
     39      <label><input type="radio" name="displayhide" value="none">Hide text</label>
     40    </div>
     41        <br>
     42        <br>
     43    <div>
     44    <p>Enter your text here:</p>
     45    <textarea name="text">' . ( isset( $_POST['text']) ? $text : null ) . '</textarea>
     46    </div>
     47        <br>
     48        <br>
     49    <div>
     50    <p>Select text color:</p>
     51    <input type ="text" name="textcolor">' . ( isset( $_POST['textcolor']) ? $textcolor : null ) . '
     52    </div>
     53    <br>
     54    <br>
     55    <br>
     56    <input type="submit" name="submit" value="Submit"/>
     57    </form>
     58    </div>
     59    ';
     60
     61    if (!isset($_POST['text'])) {
     62        echo '<br><br>Please enter a custom text to update in all posts.';
     63        exit;
     64    } else {
     65       $text = esc_textarea($_POST['text']);
     66        add_option( 'post_thanks_text', $text );
     67        update_option( 'post_thanks_text', $text );
     68    }
     69   
     70    $textcolor = $_POST["textcolor"];
     71    add_option( 'post_thanks_text_color', $textcolor );
     72    update_option( 'post_thanks_text_color', $textcolor );
     73
     74    $showhide = $_POST["displayhide"];
     75    add_option( 'post_thanks_text_displayhide', $showhide );
     76    update_option( 'post_thanks_text_displayhide', $showhide );
     77}
     78
    1979add_action( 'the_content', 'p_my_thank_you_text' );
    2080
    21 function p_my_thank_you_text ( $content ) {
    22     return $content .= '<p>Thank you for reading!</p>';
     81function p_my_thank_you_text ($content) {
     82    $post_thanks_text = get_option( 'post_thanks_text' );
     83    $post_thanks_text_color = get_option( 'post_thanks_text_color' );
     84    $post_thanks_text_showhide = get_option( 'post_thanks_text_displayhide' );
     85       
     86    if($post_thanks_text == ''){
     87        return $content .= '<div style = "color: '.$post_thanks_text_color.'; display: '.$post_thanks_text_showhide.';" class="post_thanks">Thank you for reading!</div>';
     88    }
     89    else {
     90        return $content .= '<div style = "color: '.$post_thanks_text_color.'; display: '.$post_thanks_text_showhide.';" class="post_thanks">'.$post_thanks_text.'</div>';
     91    }
    2392}
     93//Pending display: block or none not working yet. Color style code working.
  • post-thanks/trunk/readme.txt

    r2094046 r2100496  
    2626== Upgrade Notice ==
    2727
    28 No need to upgrade yet. We will add functionality to automatically add particular text through a text box later.
     28We are upgrading the plugin.
    2929
    3030== Version ==
    31 1.0.0
     31
     32=1.1=
     33* Added functionality to show hide text
     34* Added functionality to manually enter text
     35* Added functionality to color text
     36
     37=1.0=
     38First version
Note: See TracChangeset for help on using the changeset viewer.