This is purely for example and educational purposes.
The resulting contact form you will create with this example is extremely insecure. Do not use it on a live website.
- Create
websitedirectory on Desktop - Open terminal and test PHP
php --version
| <?php | |
| /** | |
| * Get a WP_Post object by its slug ( post_name ) | |
| * | |
| * @param $post_name | |
| * | |
| * @return WP_Post|null | |
| */ | |
| function get_post_by_slug( $post_name ) { |
| <?php | |
| /** | |
| * Simple PHP Templating function | |
| * | |
| * @param $names - string|array Template names | |
| * @param $args - Associative array of variables to pass to the template file. | |
| * @return string - Output of the template file. Likely HTML. | |
| */ | |
| function template( $names, $args ){ | |
| // allow for single file names |
This is purely for example and educational purposes.
The resulting contact form you will create with this example is extremely insecure. Do not use it on a live website.
website directory on Desktopphp --version| <?php | |
| // pick a hook from the wp-login.php file that best our needs. I chose the filter: wp_login_errors | |
| add_filter( 'wp_login_errors', 'my_login_form_lock_down', 90, 2 ); | |
| /** | |
| * Completely lock down the WordPress login form by hijacking the page | |
| * and only executing the the login header, footer, and necessary | |
| * closing tags. | |
| * | |
| * Provide a secret way to show the login form as a url variable in |
| <?php | |
| add_filter( 'wp_kses_allowed_html', array( $this, 'my_kses_allowed_html_hook' ), 20, 2 ); | |
| function my_kses_allowed_html_hook( $tags, $context = null ){ | |
| if ( 'post' == $context && ! isset( $tags['img'] ) ) { | |
| $tags['img'] = array( | |
| 'src' => 1, | |
| 'height' => 1, | |
| 'width' => 1, | |
| 'alt' => 1, |
| <?php | |
| /** | |
| * Class Simple_Json_Api | |
| */ | |
| class Simple_Json_Api { | |
| /** | |
| * The top level argument for the endpoint. | |
| * ex http://example.com/myjson/post/1 |
| <?php | |
| /** | |
| * Example of using wp_kses() to clean up WordPress post data. | |
| */ | |
| function __cleanup_post_data(){ | |
| global $wpdb; | |
| // default wordpress "allowed html" for posts | |
| $allowed_tags = wp_kses_allowed_html( 'post' ); |
| <?php | |
| function __cleanup_post_data(){ | |
| global $wpdb; | |
| // default wordpress "allowed html" for posts | |
| $allowed_tags = wp_kses_allowed_html( 'post' ); | |
| // don't allow spans | |
| unset($allowed_tags['span']); |