- Table of contents
- General information
- Terms
- General structure of a test
- WordPress-specific assertions and test functions
- enqueues
- creating posts
- creating terms
- attaching images
- ?
| <?php | |
| /* | |
| This code snippet can be added to your functions.php file (without the <?php) | |
| to add a query string to the login link emailed to the user upon registration | |
| which when clicked will validate the user, log them in, and direct them to | |
| the home page. | |
| */ | |
| /** | |
| * This first function is hooked to the 'user_register' action which fires |
| <?php | |
| // Please see https://github.com/Lewiscowles1986/WordPressSVGPlugin from now on |
| /** | |
| * A distance widget that will display a circle that can be resized and will | |
| * provide the radius in km. | |
| * | |
| * @param {google.maps.Map} map The map on which to attach the distance widget. | |
| * | |
| * @constructor | |
| */ |
| /* | |
| * Sanitize Checkbox | |
| */ | |
| // Source: https://github.com/FlagshipWP/flagship-library/blob/develop/customizer/classes/customizer-base.php | |
| /** | |
| * Sanitize a checkbox to only allow 0 or 1 | |
| * | |
| * @since 1.2.0 | |
| * @access public |
| <?php | |
| add_filter( 'rest_authentication_errors', function( $result ) { | |
| if ( ! empty( $result ) ) { | |
| return $result; | |
| } | |
| if ( ! is_user_logged_in() ) { | |
| return new WP_Error( 'restx_logged_out', 'Sorry, you must be logged in to make a request.', array( 'status' => 401 ) ); | |
| } | |
| return $result; |
| <?php | |
| /** | |
| * Export Data to CSV file | |
| * Could be used in WordPress plugin or theme | |
| */ | |
| // A sample link to Download CSV, could be placed somewhere in plugin settings page | |
| ?> | |
| <a href="<?php echo admin_url( 'admin.php?page=myplugin-settings-page' ) ?>&action=download_csv&_wpnonce=<?php echo wp_create_nonce( 'download_csv' )?>" class="page-title-action"><?php _e('Export to CSV','my-plugin-slug');?></a> |
| #!/bin/bash -e | |
| ## | |
| # WordPress Installation and VirtualHost Creation | |
| # | |
| # Description: Installs a WordPress website in the ~/Sites folder, creates a homepage, | |
| # cleans up the WP install a bit, deletes the akismet and hello dolly plugins, creates the permalinks, | |
| # clones the roots/sage theme framework to the theme folder, deletes all the other WP default themes, | |
| # installs/runs npm and bower and runs gulp to create the initial assets, adds a custom gitignore file | |
| # to /wp-content, installs the roots/soil plugin, creates a git repo in wp-content, saves the WordPress |
| var net = require('net'); | |
| // creates the server | |
| var server = net.createServer(); | |
| //emitted when server closes ...not emitted until all connections closes. | |
| server.on('close',function(){ | |
| console.log('Server closed !'); | |
| }); |