Consider supporting my work by purchasing the course this tutorial is a part of i.e. VSCode Power User →
- Make sure your
Local by FlyWheelWordPress install is a custom install
| <?php | |
| add_action('plugins_loaded','ao_defer_inline_init'); | |
| function ao_defer_inline_init() { | |
| if ( get_option('autoptimize_js_include_inline') != 'on' ) { | |
| add_filter('autoptimize_html_after_minify','ao_defer_inline_jquery',10,1); | |
| } | |
| } | |
| function ao_defer_inline_jquery( $in ) { |
Consider supporting my work by purchasing the course this tutorial is a part of i.e. VSCode Power User →
Local by FlyWheel WordPress install is a custom install| { | |
| // ECHO | |
| "PHP Echo Tag": { | |
| "prefix": "echo", | |
| "body": [ | |
| "<?php echo ${1:\\$var}; ?>" | |
| ], | |
| "description": "Expand \"echo\" into PHP echo block" | |
| }, | |
| function formatBytes(bytes,decimals) { | |
| if(bytes == 0) return '0 Bytes'; | |
| var k = 1024, | |
| dm = decimals || 2, | |
| sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], | |
| i = Math.floor(Math.log(bytes) / Math.log(k)); | |
| return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; | |
| } | |
| // Usage: |
| /** | |
| * Gravity Wiz // Gravity Forms // Map GF Checkbox Field to ACF Checkbox Field | |
| * http://graivtywiz.com/ | |
| */ | |
| add_filter( 'gform_post_data', function( $data ) { | |
| // Update "checkboxes" to your cusotm field name. | |
| $data['post_custom_fields']['checkboxes'] = serialize( explode( ',', $data['post_custom_fields']['checkboxes'] ) ); | |
| return $data; | |
| } ); |
| // Update PHPcs | |
| sudo pear upgrade-all and sudo pear install PHP_CodeSniffer | |
| // Check version of PHPcs | |
| phpcs --version | |
| // Go to Where coding standards available | |
| /usr/local/pear/share/pear/PHP/CodeSniffer/Standards/WordPress-Coding-Standards |
| <?php | |
| // Example 1) Using a function. Returns an array. | |
| function radgh_get_video_data( $url, $width = null, $height = null ) { | |
| if ( function_exists('_wp_oembed_get_object') ) { | |
| require_once( ABSPATH . WPINC . '/class-oembed.php' ); | |
| } | |
| $args = array(); | |
| if ( $width ) $args['width'] = $width; | |
| if ( $height ) $args['height'] = $height; |