Changeset 1838366
- Timestamp:
- 03/12/2018 04:41:12 AM (8 years ago)
- Location:
- ashuwp-invitaion-code/trunk
- Files:
-
- 5 edited
-
admin/admin.php (modified) (4 diffs)
-
ashuwp_invitation_code.php (modified) (1 diff)
-
includes/functions.php (modified) (1 diff)
-
includes/invitation_code_login.php (modified) (4 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ashuwp-invitaion-code/trunk/admin/admin.php
r1775541 r1838366 34 34 35 35 function column_cb( $item ) { 36 return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_args['singular'], $item['id'] );36 return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', 'invitationcode', $item['id'] ); 37 37 } 38 38 … … 200 200 201 201 add_submenu_page('invitation_code', __('Add New', 'ashuwp'), __('Add New', 'ashuwp'), 'manage_options', 'invitation_code_add', array(&$this, 'invitation_code_add')); 202 203 add_submenu_page('invitation_code', __('Options', 'ashuwp'), __('Options', 'ashuwp'), 'manage_options', 'invitation_code_options', array(&$this, 'invitation_code_options')); 202 204 203 205 add_action( "load-$hook", array( $this, 'invitation_code_update' ) ); … … 385 387 return $code_tem; 386 388 } 389 387 390 function invitation_code_add(){ 388 391 $code_added = $this->invitation_code_generate(); … … 460 463 <?php 461 464 } 465 466 function invitation_code_options_update(){ 467 if ( isset( $_POST['ashuwp_invitation_code_options_field'] ) && wp_verify_nonce( $_POST['ashuwp_invitation_code_options_field'], 'ashuwp_invitation_code_options_action' ) ) { 468 469 $new_options = $old_options = get_option('invitation_code'); 470 if( empty($new_options['show_help']) ){ 471 $new_options['show_help'] = ''; 472 } 473 if( empty($new_options['help_content']) ){ 474 $new_options['help_content'] = ''; 475 } 476 477 if( !empty($_POST['show_help']) ){ 478 $show_help = sanitize_text_field($_POST['show_help']); 479 if( $new_options['show_help'] != $show_help ){ 480 $new_options['show_help'] = $show_help; 481 } 482 } 483 484 if( !empty($_POST['help_content']) ){ 485 $v = trim( strip_tags($_POST['help_content'],'<a>') ); 486 $v = htmlspecialchars($v, ENT_COMPAT); 487 488 if( $new_options['help_content'] != $v ){ 489 $new_options['help_content'] = $v; 490 } 491 }else{ 492 $new_options['help_content'] = ''; 493 } 494 495 if( $new_options != $old_options ){ 496 update_option('invitation_code', $new_options); 497 498 $return = array( 499 'status' => true, 500 'msg' => __('Options saved.','ashuwp'), 501 ); 502 } 503 504 } 505 506 if(isset($return)){ 507 return $return; 508 }else{ 509 return NULL; 510 } 511 } 512 function invitation_code_options(){ 513 $return = $this->invitation_code_options_update(); 514 515 $invitation_code_options = get_option('invitation_code'); 516 $show_help = 0; 517 if( !empty($invitation_code_options['show_help']) && $invitation_code_options['show_help']=='yes' ){ 518 $show_help = 1; 519 } 520 521 $help_content = ''; 522 if( !empty($invitation_code_options['help_content']) ){ 523 $help_content = stripslashes($invitation_code_options['help_content']); 524 $help_content = htmlspecialchars_decode($help_content, ENT_QUOTES); 525 } 526 ?> 527 <div class="wrap"> 528 <h1 class="wp-heading-inline"><?php _e('Options', 'ashuwp'); ?></h1> 529 <hr class="wp-header-end"> 530 <?php 531 if(!empty($return)){ 532 if($return['status']){ 533 $c = 'notice-success'; 534 }else{ 535 $c = 'notice-error'; 536 } 537 ?> 538 <div id="message" class="notice <?php echo $c; ?>"> 539 <p><?php echo $return['msg']; ?></p> 540 </div> 541 <?php 542 } 543 ?> 544 <form action="" method="post"> 545 <table class="form-table"> 546 <tbody> 547 <tr> 548 <th><label for="code_prefix"><?php _e('Display help in register form.', 'ashuwp'); ?></label></th> 549 <td> 550 <p> 551 <label><input name="show_help" type="radio" value="yes" <?php if($show_help){ echo 'checked="checked"'; } ?>><?php _e('Display', 'ashuwp'); ?></label> 552 <br> 553 <label><input name="show_help" type="radio" value="no" <?php if(!$show_help){ echo 'checked="checked"'; } ?> ><?php _e('Not Display', 'ashuwp'); ?></label> 554 </p> 555 </td> 556 </tr> 557 <tr> 558 <th><label for="code_length"><?php _e('Help content', 'ashuwp'); ?></label></th> 559 <td> 560 <p class="description"><?php _e('Only <a> allowed.', 'ashuwp'); ?></p> 561 <textarea name="help_content" id="help_content" class="large-text code" rows="3"><?php echo $help_content; ?></textarea> 562 </td> 563 </tr> 564 </tbody> 565 </table> 566 <p class="submit"> 567 <?php wp_nonce_field( 'ashuwp_invitation_code_options_action','ashuwp_invitation_code_options_field' ); ?> 568 <input type="submit" name="submit" id="submit" class="button button-primary" value="Update"> 569 </p> 570 </form> 571 </div> 572 <?php 573 } 574 462 575 public static function get_instance() { 463 576 if ( ! isset( self::$instance ) ) { -
ashuwp-invitaion-code/trunk/ashuwp_invitation_code.php
r1715354 r1838366 3 3 * Plugin Name: Ashuwp invitaion code 4 4 * Description: Ashuwp_Invitation_Code is a wordpress plugin, It helps adding invitation codes for your site. 5 * Version: 1. 15 * Version: 1.2 6 6 * Author: Ashuwp 7 7 * Author URI: http://www.ashuwp.com/package/ashuwp_invitation_code -
ashuwp-invitaion-code/trunk/includes/functions.php
r1715291 r1838366 54 54 return false; 55 55 } 56 } 57 58 /** 59 * update a invite code status. 60 **/ 61 function ashuwp_update_invitation_status( $id ){ 62 global $wpdb; 63 64 if($id==''){ 65 return false; 66 } 67 68 $table_name = $wpdb->prefix . 'ashuwp_invitation_code'; 69 $sql = "select * from $table_name where id='$id'"; 70 71 $code = $wpdb->get_row($sql,'ARRAY_A'); 72 if(!empty($code)){ 73 $users = array(); 74 if(!empty($code['users'])){ 75 $users = code_users_string_to_array($code['users']); 76 } 77 $used = count($users); 78 79 if( ($code['max']<=$used) && ($code['status']=='available') ){ 80 $code['status'] = 'finish'; 81 ashuwp_update_invitation_code( $code['id'], 'status', 'finish' ); 82 } 83 84 $expiration = ''; 85 if( !empty( $code['expiration'] ) && $code['expiration']!='0000-00-00 00:00:00' ){ 86 $expiration = date_i18n( get_option( 'date_format' ).' '.get_option( 'time_format' ), strtotime($code['expiration']) ); 87 88 $now = time() + ( get_option( 'gmt_offset' ) * 3600 ); 89 90 if( ($now >= strtotime($code['expiration'])) && ($code['status'] == 'available') ){ 91 $code['status'] = 'expired'; 92 ashuwp_update_invitation_code( $code['id'], 'status', 'expired' ); 93 } 94 } 95 return true; 96 97 }else{ 98 return false; 99 } 100 56 101 } 57 102 -
ashuwp-invitaion-code/trunk/includes/invitation_code_login.php
r1715291 r1838366 10 10 </p> 11 11 <?php 12 $invitation_code_options = get_option('invitation_code'); 13 if( !empty($invitation_code_options['show_help']) && $invitation_code_options['show_help']=='yes' ){ 14 15 if( !empty($invitation_code_options['help_content']) ){ 16 $help_content = stripslashes($invitation_code_options['help_content']); 17 $help_content = htmlspecialchars_decode($help_content, ENT_QUOTES); 18 $help_content = str_replace(PHP_EOL, '<br>', $help_content); 19 echo '<p style="margin:-16px 6px 16px 0;">'.$help_content.'</p>'; 20 } 21 } 12 22 } 13 23 … … 65 75 66 76 ashuwp_update_invitation_code( $code_id, 'users', $new_users ); 77 ashuwp_update_invitation_status( $code_id ); 67 78 add_user_meta( $user_id, 'invitation_code', $result['code'], true ); 68 79 } … … 79 90 <input type="text" name="invitation_code" id="invitation_code" value="" /> 80 91 <?php 92 $invitation_code_options = get_option('invitation_code'); 93 if( !empty($invitation_code_options['show_help']) && $invitation_code_options['show_help']=='yes' ){ 94 95 if( !empty($invitation_code_options['help_content']) ){ 96 $help_content = stripslashes($invitation_code_options['help_content']); 97 $help_content = htmlspecialchars_decode($help_content, ENT_QUOTES); 98 $help_content = str_replace(PHP_EOL, '<br>', $help_content); 99 echo $help_content; 100 } 101 } 81 102 } 82 103 … … 131 152 <p class="error"><?php echo $errmsg; ?></p> 132 153 <?php endif; ?> 133 <input type="text" name="invitation_code" id="invitation_code" value="" /><br /> 154 <input type="text" name="invitation_code" id="invitation_code" value="" /> 155 <?php 156 $invitation_code_options = get_option('invitation_code'); 157 if( !empty($invitation_code_options['show_help']) && $invitation_code_options['show_help']=='yes' ){ 158 159 if( !empty($invitation_code_options['help_content']) ){ 160 $help_content = stripslashes($invitation_code_options['help_content']); 161 $help_content = htmlspecialchars_decode($help_content, ENT_QUOTES); 162 $help_content = str_replace(PHP_EOL, '<br>', $help_content); 163 echo $help_content; 164 } 165 } 166 ?> 167 <br /> 134 168 <?php 135 169 _e( '(Must be input.)', 'ashuwp' ); -
ashuwp-invitaion-code/trunk/readme.txt
r1775541 r1838366 4 4 Tags: Invitation code, Register 5 5 Requires at least: 4.5 6 Tested up to: 4. 87 Stable tag:4. 86 Tested up to: 4.9 7 Stable tag:4.9 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 43 43 Compatible with version less than php5.5 44 44 45 = 1.3 = 46 Add invitation options. 47 Fix some bugs. 48 45 49 == Upgrade Notice == 46 50 … … 53 57 = 1.2 = 54 58 Compatible with version less than php5.5 59 60 = 1.3 = 61 Add invitation options. 62 Fix some bugs.
Note: See TracChangeset
for help on using the changeset viewer.