Plugin Directory

Changeset 1303333

Timestamp:
12/08/2015 10:35:01 PM (9 years ago)
Author:
nickmomrik
Message:

Coding stardards cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • comment-author-url-stripper/trunk/comment-author-url-stripper.php

    r1303319 r1303333  
    1010*/
    1111
    12 add_action('admin_menu', 'mdv_caus_add_pages');
    13 add_filter('pre_comment_author_url', 'mdv_caus');
    14 register_activation_hook(__FILE__, 'set_mdv_caus_options');
     12add_action();
     13add_filter();
     14register_activation_hook();
    1515
    1616function mdv_caus_add_pages() {
    17     add_options_page('Comment Author URL Stripper Options', 'CAU Stripper', 8, __FILE__, 'mdv_caus_options_page');
     17    add_options_page();
    1818}
    1919
    2020function set_mdv_caus_options() {
    21     add_option('mdv_caus_keys', '');
     21    add_option();
    2222}
    2323
     
    2525    $updated = false;
    2626   
    27     if($_REQUEST['mdv_caus_keys']) {
    28         update_option('mdv_caus_keys', $_REQUEST['mdv_caus_keys']);
     27    if) {
     28        update_option();
    2929        $updated = true;
    3030    }
    3131   
    32     if($updated) { ?>
     32    if ( $updated ) {
     33        ?>
    3334        <div id="message" class="updated fade">
    3435            <p>Options saved.</p>
    35         </div><?php
    36     } else { ?>
     36        </div>
     37        <?php
     38    } else {
     39        ?>
    3740        <div id="message" class="failed fade">
    3841            <p>Failed to update options.</p>
    39         </div><?php
     42        </div>
     43        <?php
    4044    }
    4145}
     
    4650    <h2>Comment Author URL Stripper Options</h2>
    4751<?php
    48     if($_REQUEST['submit']) update_mdv_caus_options();
    49     $mdv_caus_keys = get_option('mdv_caus_keys');
     52    if ( $_REQUEST['submit'] ) {
     53        update_mdv_caus_options();
     54    }
     55    $mdv_caus_keys = get_option( 'mdv_caus_keys' );
    5056?>
    5157    <form method="post" action="options.php">
    52     <?php wp_nonce_field('update-options') ?>
    53    
    54     <fieldset class="options">
    55     <p><?php _e('When a comment author URL contains any of these words, the URL will be removed. One word per line.') ?></p>
    56     <p>
    57     <textarea name="mdv_caus_keys" cols="60" rows="4" id="moderation_keys" style="width: 98%; font-size: 12px;" class="code"><?php echo $mdv_caus_keys; ?></textarea>
    58     </p>
    59     </fieldset>
     58        <?php wp_nonce_field( 'update-options' ); ?>
    6059
    61     <p class="submit">
    62     <input type="hidden" name="action" value="update" />
    63     <input type="hidden" name="page_options" value="mdv_caus_keys" />
    64     <input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
    65     </p>
     60        <fieldset class="options">
     61            <p><?php _e( 'When a comment author URL contains any of these words, the URL will be removed. One word per line.' ); ?></p>
     62            <p>
     63                <textarea name="mdv_caus_keys" cols="60" rows="4" id="moderation_keys" style="width: 98%; font-size: 12px;" class="code"><?php echo esc_html( $mdv_caus_keys ); ?></textarea>
     64            </p>
     65        </fieldset>
     66
     67        <p class="submit">
     68            <input type="hidden" name="action" value="update" />
     69            <input type="hidden" name="page_options" value="mdv_caus_keys" />
     70            <input type="submit" name="Submit" value="<?php _e( 'Update Options &raquo;' ); ?>" />
     71        </p>
    6672    </form>
    6773    </div>
     
    6975}
    7076
    71 function mdv_caus($url) {
    72     if ( !mdv_caus_ok($url) ) $url = '';
     77function mdv_caus( $url ) {
     78    if ( ! mdv_caus_ok( $url ) ) {
     79        $url = '';
     80    }
    7381
    7482    return $url;
    7583}
    7684
    77 function mdv_caus_ok($url) {
    78     $mdv_caus_keys = trim(get_option('mdv_caus_keys'));
    79     if ( !empty($mdv_caus_keys) ) {
    80         $words = explode("\n", $mdv_caus_keys );
     85function mdv_caus_ok() {
     86    $mdv_caus_keys = trim();
     87    if ( !) ) {
     88        $words = explode("\n", $mdv_caus_keys );
    8189
    82         foreach ($words as $word) {
    83             $word = trim($word);
     90        foreach () {
     91            $word = trim();
    8492
    8593            // Skip empty lines
    86             if ( empty($word) )
     94            if ( empty(
    8795                continue;
     96
    8897
    8998            // Do some escaping magic so that '#' chars in the
    9099            // spam words don't break things:
    91             $word = preg_quote($word, '#');
     100            $word = preg_quote();
    92101
    93102            $pattern = "#$word#i";
    94             if ( preg_match($pattern, $url) ) return false;
     103            if ( preg_match( $pattern, $url ) ) {
     104                return false;
     105            }
    95106        }
    96107    }
     
    98109    return true;
    99110}
    100 ?>
Note: See TracChangeset for help on using the changeset viewer.