mkdir projectname
cd projectname
poetry init
poetry add django
| <?php | |
| /* | |
| Plugin Name: Google Analytics Tracking Code MU-Plugin | |
| Description: A must-use plugin that adds immutable Google Analytics tracking code. | |
| */ | |
| /* This plugin is used to ensure that Google Analytics is always present on the site (thus the use of a mu-plugin) | |
| and to maintain the relationship between WordPress themes (design) and WordPress plugins (functionality) by keeping this | |
| code out of the theme and in a plugin. */ |
| <?php | |
| // Fix for infitite redirect of homepage when using subdomain. Thanks to andrewtaylor-1 | |
| // https://wordpress.org/support/topic/45-causes-infinite-redirect-on-static-front-page/ | |
| function disable_front_page_redirect($redirect_url) { | |
| if( is_front_page() ) { | |
| $redirect_url = false; | |
| } | |
| return $redirect_url; | |
| } |
| # ----------------------------------------------------------------- | |
| # .gitignore for WordPress | |
| # Original file from @salcode (https://gist.github.com/salcode/b515f520d3f8207ecd04/raw/.gitignore) | |
| # | |
| # From the root of your project run | |
| # curl -O https://gist.github.com/dannydover/5c03aade4bdb58b61e8a0b56c2464c2a/raw/.gitignore | |
| # to download this file | |
| # | |
| # By default all files are ignored. You'll need to whitelist | |
| # any mu-plugins, plugins, or themes you want to include in the repo. |
| <?php | |
| /* Add Featured Image to beginning of RSS Feed entries */ | |
| function featuredtoRSS($content) { | |
| global $post; | |
| if ( has_post_thumbnail( $post->ID ) ){ | |
| $content = '<div>' . get_the_post_thumbnail( $post->ID, 'large', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content; | |
| } | |
| return $content; | |
| } |
| <?php | |
| /* Show last updated date rather than first posted date */ | |
| function show_last_modified_date_blog( $the_date, $format ) { | |
| if ( 'guides' === get_post_type() && 'U' !== $format ) { // Make sure the Unix timestamp is not being requested. | |
| $the_time = get_post_time( 'His' ); | |
| $the_modified = get_post_modified_time( 'His' ); | |
| $last_modified = sprintf( __( 'Last Updated %s', 'Divi' ), esc_html( get_post_modified_time( 'M j, Y' ) ) ); |
| // Google Analtics (gtag.js) - Tracking external clicks as events without GTM | |
| function track_outbound_clicks_with_GA() { ?> | |
| <script> | |
| (function trackOutboundClicks() { | |
| var hitCallbackHandler = function(url,win) { | |
| if (win) { | |
| window.open(url, win); | |
| } else { | |
| window.location.href = url; |
| <?php | |
| // Google Analytics Tracking Code Snippet | |
| add_action( 'wp_head', 'google_analytics_tracking', 1 ); | |
| function google_analytics_tracking( $priority ) { | |
| ?> | |
| <!-- Global site tag (gtag.js) - Google Analytics --> | |
| <script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXX-X"></script> | |
| <script> |
| // Add Wordpress Images srcset SSL compatibility with Cloudflare. | |
| add_filter( 'wp_get_attachment_url', 'set_url_scheme' ); | |
| add_filter( 'wp_calculate_image_srcset', function($sources) { | |
| $filtered_sources = array(); | |
| foreach($sources as $source_key=>$source) { | |
| $source['url'] = str_replace('http://','https://', $source['url']); | |
| $filtered_sources[$source_key] = $source; | |
| } | |
| return $filtered_sources; |