Tag Archive for '代码分析'

wordpress代码分析 —- wp_safe_redirect

Add a comment

wordpress代码分析 ---- wp_safe_redirect。wordpress提供了一个跳转方法wp_safe_redirect,避免登录url被修改,登录成功后跳转到有害的第三方站点。如下:
PLAIN TEXT
PHP:

/**

* wp_safe_redirect() - Performs a safe (local) redirect, using wp_redirect()

*

* Checks whether the $location is using an allowed host, if it has an absolute

* path. A plugin can therefore set or remove allowed host(s) to or from the list.

*

* If the host is not allowed, then [...]

读取wordpress的代码心得 — 写页面

2 Comments

写页面和写文章的区别不大,但是从$post对象中拿到的值不一样,比如Write Page的时候,$post有下列值:
$post->post_type = 'page';
页面还能设定自定义模板,以及顺序
$post->post_template
而模板的头部必须有如下代码注明:
PLAIN TEXT
CODE:

<?php

/*

Template Name: TemplateName

*/

?>




Open