This is a small collection of quick helper functions for debugging and working with PHP.
axyz_d( $var )
| <?php | |
| // Add this code to the themes functions.php | |
| const GOOGLE_MAPS_API_KEY = 'Your Google Maps API Key'; | |
| // Ensure Advanced Custom Fields Pro (ACF Pro) is enabled | |
| // | |
| // Check if plugin is enabled without additionally include the plugin manager for is_plugin_active() | |
| // @see https://developer.wordpress.org/reference/functions/is_plugin_active/#comment-2427 | |
| if ( in_array( 'advanced-custom-fields-pro/acf.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { |
| #!/usr/bin/env python3 | |
| # coding: utf-8 | |
| # Sets the correct content-type and content-encoding for Unity3D files. | |
| # @see https://forum.unity.com/threads/changes-to-the-webgl-loader-and-templates-introduced-in-unity-2020-1.817698/#post-5716621 | |
| import boto3 | |
| bucket_id = 'unity-model' | |
| folder_prefix = 'model' |
| <?php | |
| if ( ( strpos( $url, 'http://' ) === false ) && ( strpos( $url, 'https://' ) === false ) ) { | |
| $url = 'http://' . $url; | |
| } |
| <?php | |
| foreach ( $foobar as $key => $value ) { | |
| if ( preg_match('/^barfoo-/', $key) ) { | |
| // Array entries of $foobar whose keys starts with barfoo- | |
| } | |
| } |
| <?php | |
| $id = $modx->resource->get('id'); | |
| $parents = $modx->getParentIds($id, 2); | |
| $grandparent = $parents[1]; | |
| return $grandparent; |
| <?php | |
| setlocale(LC_ALL, 'en_US'); | |
| return strftime($options, $input); |
| # Temporary files | |
| *~ | |
| *.swp | |
| # Metadata | |
| .DS_Store | |
| Thumbs.db |
| # PHP | |
| php_flag register_globals off | |
| php_flag short_open_tag off | |
| # Set default charset to UTF-8 | |
| AddDefaultCharset UTF-8 | |
| # File types |
| # Temporary files | |
| *~ | |
| *.swp | |
| # Metadata | |
| .DS_Store | |
| Thumbs.db |