0
X
Add Snippet To Project
New Project
Add To Existing Project
/*
* Plugin Name: WPTurbo Starter Plugin
* Plugin URI: https://wpturbo.dev
* Description: A starter plugin template.
* Version: 1.0.0
* Author: WPTurbo
* Author URI: https://wpturbo.dev
* Text Domain: wpturbo
*/
/**
* Allow SVG File Uploads.
*
* @param array $mimes An associative array of allowed file types.
*
* @return array Modified array of allowed file types.
*/
function wpturbo__enable_svg_uploads( array $mimes ): array {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'wpturbo__enable_svg_uploads' );
/**
* Redirect Attachments To Their Parent Post/Page.
*
* @param string $url The attachment URL.
*
* @return string The modified URL (if applicable).
*/
function wpturbo_redirect_attachments( string $url ): string {
if ( is_attachment() ) {
$parent = get_post( $post->post_parent );
if ( $parent ) {
$parent_link = get_permalink( $parent->ID );
if ( $parent_link ) {
return $parent_link;
}
}
}
return $url;
}
add_filter( 'wp_get_attachment_url', 'wpturbo_redirect_attachments' );
/**
* Remove WordPress Version Generator Tag.
*/
remove_action( 'wp_head', 'wp_generator' );
/**
* Remove WooCommerce Version Generator Tag.
*/
remove_action( 'wp_head', 'wc_generator' );
/**
* Remove X-Powered-By header.
*
* @return void
*/
function wpturbo_remove_x_powered_by() : void {
if (function_exists('header_remove')) {
header_remove('x-powered-by');
}
}
add_action( 'wp', 'wpturbo_remove_x_powered_by' );
/**
* Change Default "From" Name To 'Joe'
*
* @return string
*/
function wpturbo_change_default_from_name(): string {
return 'Joe';
}
add_filter( 'wp_mail_from_name', 'wpturbo_change_default_from_name' );
/**
* Change Default "From" Email To 'joe@joehaddadlaw.com'
*
* @return string
*/
function wpturbo_change_default_from_email(): string {
return 'joe@joehaddadlaw.com';
}
add_filter( 'wp_mail_from', 'wpturbo_change_default_from_email' );
/**
* Remove WordPress Logo from Admin Bar
*
* @param WP_Admin_Bar $wp_admin_bar
*
* @return void
*/
function wpturbo_remove_wordpress_logo( WP_Admin_Bar $wp_admin_bar ) {
$wp_admin_bar->remove_node( 'wp-logo' );
}
add_action( 'admin_bar_menu', 'wpturbo_remove_wordpress_logo', 999 );
/**
* Remove WordPress Logo from Login Page
*
* @return void
*/
function wpturbo_remove_login_logo() : void {
?>
<style type="text/css">
#login h1 a, .login h1 a {
display: none;
}
</style>
<?php
}
add_action( 'login_enqueue_scripts', 'wpturbo_remove_login_logo' );
/**
* Allow Shortcode In Title
*/
add_filter( 'the_title', 'do_shortcode' );
add_filter( 'wpseo_title', 'do_shortcode' );
add_filter( 'wp_title', 'do_shortcode' );
Starter Plugin shell