开源欣赏wordpress之intall.php
引导式安装
$weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : ''; $user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : ''; $admin_password = isset($_POST['admin_password']) ? trim( wp_unslash( $_POST['admin_password'] ) ) : ''; $admin_email = isset( $_POST['admin_email'] ) ? trim( wp_unslash( $_POST['admin_email'] ) ) : '';
点评:这是获取值,并处理的代码,简洁清晰。
<form id="setup" method="post" action="install.php?step=2"> <table class="form-table"> <tr> <th scope="row"><label for="weblog_title"><?php _e( 'Site Title' ); ?></label></th> <td><input name=" value="<?php echo esc_attr( $weblog_title ); ?>" /></td> </tr> <tr> <th scope="row"><label for="user_login"><?php _e('Username'); ?></label></th> <td> <?php if ( $user_table ) { _e('User(s) already exists.'); } else { ?><input name=" value="<?php echo esc_attr( sanitize_user( $user_name, true ) ); ?>" /> <p><?php _e( 'Usernames can have only alphanumeric characters, spaces, underscores, hyphens, periods and the @ symbol.' ); ?></p> <?php } ?> </td> </tr> <?php if ( ! $user_table ) : ?> <tr> <th scope="row"> <label for="admin_password"><?php _e('Password, twice'); ?></label> <p><?php _e('A password will be automatically generated for you if you leave this blank.'); ?></p> </th> <td> <input name=" value="" /> <p><input name=" value="" /></p> <div id="pass-strength-result"><?php _e('Strength indicator'); ?></div> <p><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ & ).'); ?></p> </td> </tr> <?php endif; ?> <tr> <th scope="row"><label for="admin_email"><?php _e( 'Your E-mail' ); ?></label></th> <td><input name=" value="<?php echo esc_attr( $admin_email ); ?>" /> <p><?php _e( 'Double-check your email address before continuing.' ); ?></p></td> </tr> <tr> <th scope="row"><label for="blog_public"><?php _e( 'Privacy' ); ?></label></th> <td colspan=" <?php checked( $blog_public ); ?> /> <?php _e( 'Allow search engines to index this site.' ); ?></label></td> </tr> </table> <p class="step"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Install WordPress' ); ?>" class="button button-large" /></p> </form>
点评:这是form表单的内容。逻辑也非常清晰。思维严谨。
// Let's check to make sure WP isn't already installed. if ( is_blog_installed() ) { display_header(); die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p><p class="step"><a href="../wp-login.php" class="button button-large">' . __( 'Log In' ) . '</a></p></body></html>' ); }
判断是否已安装代码。
各种提示语,人性化。
if ( ! empty( $wpdb->error ) ) wp_die( $wpdb->error->get_error_message() ); display_header(); // Fill in the data we gathered $weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : ''; $user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : ''; $admin_password = isset($_POST['admin_password']) ? wp_unslash( $_POST['admin_password'] ) : ''; $admin_password_check = isset($_POST['admin_password2']) ? wp_unslash( $_POST['admin_password2'] ) : ''; $admin_email = isset( $_POST['admin_email'] ) ?trim( wp_unslash( $_POST['admin_email'] ) ) : ''; $; // check e-mail address $error = false; if ( empty( $user_name ) ) { // TODO: poka-yoke display_setup_form( __( 'Please provide a valid username.' ) ); $error = true; } elseif ( $user_name != sanitize_user( $user_name, true ) ) { display_setup_form( __( 'The username you provided has invalid characters.' ) ); $error = true; } elseif ( $admin_password != $admin_password_check ) { // TODO: poka-yoke display_setup_form( __( 'Your passwords do not match. Please try again.' ) ); $error = true; } else if ( empty( $admin_email ) ) { // TODO: poka-yoke display_setup_form( __( 'You must provide an email address.' ) ); $error = true; } elseif ( ! is_email( $admin_email ) ) { // TODO: poka-yoke display_setup_form( __( 'Sorry, that isn’t a valid email address. Email addresses look like <code>username@example.com</code>.' ) ); $error = true; } if ( $error === false ) { $wpdb->show_errors(); $result = wp_install($weblog_title, $user_name, $admin_email, $public, '', $admin_password); extract( $result, EXTR_SKIP );
点评:注册登录验证,先验证前端的提交是否有错误。碉堡了。
开源欣赏wordpress之intall.php的更多相关文章
- 开源欣赏wordpress之文章新增页面如何实现。
本地网址http://localhost/wordpress/wp-admin/post-new.php 进而找到post-new.php页面. 进入之后, require_once( dirname ...
- 开源欣赏wordpress之用户新增user-new.php
require_once( dirname( __FILE__ ) . '/admin.php' ); 引入根文件. if ( is_multisite() ) { if ( ! current_us ...
- 开源欣赏wordpress之post.php
switch($action) { case 'postajaxpost': case 'post': case 'post-quickpress-publish': case 'post-quick ...
- 开源免费的WordPress个人博客主题推荐
二次元动漫类个人主题 Sakura 功能强大,美观大气,二次元动漫专属 演示地址:https://2heng.xin/theme-sakura/ 开源地址:https://github.com/mas ...
- WordPress版微信小程序开发系列(一):WordPress REST API
自动我发布开源程序WordPress版微信小程序以来,很多WordPress站长在搭建微信小程序的过程中会碰到各种问题来咨询我,有些问题其实很简单,只要仔细看看我写的文章,就可以自己解决.不过这些文章 ...
- wordpress 主题开发
https://yusi123.com/3205.html https://themeshaper.com/2012/10/22/the-themeshaper-wordpress-theme-tut ...
- Wordpress对接小程序配置过程
最近发现一个很棒的开源项目-WordPress版微信小程序 https://github.com/iamxjb/winxin-app-watch-life.net,详细看了下介绍非常棒,不仅支持的功 ...
- 什么是WordPress
首先,假设您没有WordPress的经验: 我将从基础开始. 在本教程中,我将回答问题:"什么是WordPress?" 在这篇文章中,我将说明您可以在哪里获得WordPress以及 ...
- 个人对joomla3.2x和joomla2.5X浅薄看法
很久没有写joomla文章了,发现想写的东西还是挺多的,后面抽时间补回来,其实更多还是php的一些东西.joomla3.0以后系统改变挺大,后台都是用bootstrap作为主题,个人对这个无爱,因为他 ...
随机推荐
- 【转】Linux下tar.xz结尾的文件的解压方法--不错
原文网址:http://blog.csdn.net/silvervi/article/details/6325698 今天尝试编译内核,下载到了一份tar.xz结尾的压缩文件,网上解决方法比较少,不过 ...
- linux下tcpdump命令详解
简介 用简单的话来定义tcpdump,就是:dump the traffic on a network,根据使用者的定义对网络上的数据包进行截获的包分析工具. tcpdump可以将网络中传送的数据包的 ...
- Quartus DSE 初步应用
介绍 Design Space Explorer (DSE) is a program that automates the process of finding the optimal collec ...
- 安全:加固你的ssh 登录
SSH 是我们控制虚拟主机的一种途径,这个途径可以让我们拥有完全的控制权,如果对于这个控制权没有进行很好的安全处理,那么将会造成很大的安全问题. 我们可以在系统的日志文件 (例如:/var/ ...
- mips平台使用jdbc操作sqlite的最终解决方案
1.概述: 本项目需要在多平台上(mips必须支持)操作嵌入式数据库sqlite,而最新的sqlite-jdbc-3.15.1.jar的本地驱动只含有少量的平台,于是解决支持mips平台实在必行.方法 ...
- C/S系统实现两数求和(非阻塞+epoll+心跳包检测用户在线状况+滚动日志+配置文件.)
C/S系统实现两数求和 任务要求: 实现配置文件 实现日志滚动 设置非阻塞套接字,EPOLL实现 检测客户端的连接,设置心跳检测 主线程 + 心跳检测线程 + EPOLL的ET模式处理事务线程 注意事 ...
- Oracle优化技术
1.基本原理 Oracle的日志:Oracle中为了提高硬盘写的效率,採用内存中数据缓冲区来保存数据,等到一定量或一定时间后才写到磁盘(DBWR). 这个时候假如断电之类的故障发生,数据缓冲区的数据将 ...
- Unity 读取CSV与Excel
前几天看到我们在游戏中需要动态加载某些角色的游戏策划值,关于这个问题怎么解决呢?其实办法很多种,归根到底,就是数据的读取.我们可以想到的存储数据的载体有很多.例如:txt,xml,csv,excel. ...
- 在Java中编写带占位符的SQL语句
C#中SQL中带占位符的语句 假设有一张学员信息表Student,通过表中的ID来找学员,查询的SQL语句如下 string sql = string.Format("select * fr ...
- canvas写的一个小时钟demo
<!DOCTYPE html> <html> <head> <title>HTML5 Canvas Demo of clock</title> ...