Create Custom Widget

Creating the widget

class speedy_widget extends WP_Widget {
 
	function __construct() {
		parent::__construct(
			// Base ID of your widget
			'speedy_widget', 
			 
			// Widget name will appear in UI
			__('Speedy Widget', 'speedy_widget_domain'), 
			 
			// Widget description
			array( 'description' => __( 'Sample widget based on Speedy Tutorial', 'speedy_widget_domain' ), ) 
		);
	}
	 
	// Creating widget front-end
	 
	public function widget( $args, $instance ) {
		$title = apply_filters( 'widget_title', $instance['title'] );

		// before and after widget arguments are defined by themes
		echo $args['before_widget'];
		if ( ! empty( $title ) )
		echo $args['before_title'] . $title . $args['after_title'];
		 
		// This is where you run the code and display the output
		echo __( 'Hello, World!', 'speedy_widget_domain' );
		echo $args['after_widget'];
	}
			 
	// Widget Backend 
	public function form( $instance ) {
		if ( isset( $instance[ 'title' ] ) ) {
			$title = $instance[ 'title' ];
		}
		else {
			$title = __( 'New title', 'speedy_widget_domain' );
		}
		// Widget admin form
		?>
		

			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> 
			<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
		

	<?php 
	}
		 
	// Updating widget replacing old instances with new
	public function update( $new_instance, $old_instance ) {
		$instance = array();
		$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
		return $instance;
	}

}


Register and load the widget

function speedy_load_widget() {
    register_widget( 'speedy_widget' );
}
add_action( 'widgets_init', 'speedy_load_widget' );
Advertisements

Unregister Post Type

Add in function.php

function delete_post_type(){
  	unregister_post_type('POST TYPE NAME');
}
add_action('init','delete_post_type', 100);

Maintenance Mode without Plugin

Add in function.php

// Activate WordPress Maintenance Mode
function wp_maintenance_mode(){
    if(!current_user_can('edit_themes') || !is_user_logged_in()){
        wp_die('<h1>Website under Maintenance</h1><br>We are performing scheduled maintenance. We will be back on-line shortly!');
    }
}
add_action('get_header', 'wp_maintenance_mode');

Wp Config Settings

MySQL settings

define( 'DB_NAME',     'database_name_here' );
define( 'DB_USER',     'username_here' );
define( 'DB_PASSWORD', 'password_here' );
define( 'DB_HOST',     'localhost' );
define( 'DB_CHARSET',  'utf8mb4' );


MySQL database table prefix.

$table_prefix = 'wp_';


SSL

define( 'FORCE_SSL_LOGIN', true );
define( 'FORCE_SSL_ADMIN', true );


Custom WordPress URL.

define( 'WP_SITEURL',     'http://example.com/blog' );
define( 'WP_HOME',        'http://example.com/blog' );
define( 'WP_CONTENT_URL', 'http://example.com/blog' );
define( 'UPLOADS',        'http://example.com/blog/upload' );


Disable Post Revisions.

define( 'WP_POST_REVISIONS', false );


Media Trash.

define( 'MEDIA_TRASH', true );
define( 'EMPTY_TRASH_DAYS', '2' );


Remove Theme Editor

define( 'DISALLOW_FILE_EDIT', true );


Repair and optimize database

In your browser, go to the URL http://yoursite.com/wp-admin/maint/repair.php

define( 'WP_ALLOW_REPAIR', true);


DISALLOW_FILE_MODS

Disables plugin and theme updates and installation through the Dashboard. It also disables all file modifications within the Dashboard, thus removing the Theme Editor and Plugin Editor.

define( 'DISALLOW_FILE_MODS', true );


Updates

define( 'AUTOMATIC_UPDATER_DISABLED', true ); // Disable all automatic updates:

define( 'WP_AUTO_UPDATE_CORE', false ); // Disable all core updates:

define( 'WP_AUTO_UPDATE_CORE', 'minor' ); // Enable core updates for minor releases (default)


Multi Site

define( 'WP_ALLOW_MULTISITE', true );


PHP Memory

define( 'WP_MEMORY_LIMIT', '128' );
define( 'WP_MAX_MEMORY_LIMIT', '400' );


WordPress Cache

define( 'WP_CACHE', true );


Compression

define('SCRIPT_DEBUG', true); //loads the development (non-minified) versions of all scripts and CSS, and disables compression and concatenation
define( 'COMPRESS_CSS',        false ); //disables compression of CSS
define( 'COMPRESS_SCRIPTS',    false ); //disables compression of scripts
define( 'CONCATENATE_SCRIPTS', false ); //disables compression and concatenation of scripts and CSS
define( 'ENFORCE_GZIP',        true ); //forces gzip for compression (default is deflate)


CRON

define( 'DISABLE_WP_CRON',      'true' );
define( 'ALTERNATE_WP_CRON',    'true' );


Cleanup Image Edits Overwrite

define( 'IMAGE_EDIT_OVERWRITE', true );


Absolute path to the WordPress directory.

if ( !defined('ABSPATH') )
	define('ABSPATH', dirname(__FILE__) . '/');

Disable Updates

Disable Updates in wordpress

add this code in function.php file


function remove_core_updates(){
     global $wp_version;return(object) array('last_checked'=> time(),'version_checked'=> $wp_version,);
}

//WP Core Update
add_filter('pre_site_transient_update_core','remove_core_updates');

//WP Plugins
add_filter('pre_site_transient_update_plugins','remove_core_updates');

//WP Themes
add_filter('pre_site_transient_update_themes','remove_core_updates');

Allow Svg in Media Upload

For your functions.php file

function cc_mime_types($mimes) {
  $mimes['svg'] = 'image/svg+xml';
  return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');