Skip to content

Instantly share code, notes, and snippets.

@jimmi-joensson
Last active July 1, 2021 08:05
Show Gist options
  • Save jimmi-joensson/1a6cefb1b7a23a001b51edcaa2cf5c05 to your computer and use it in GitHub Desktop.
Save jimmi-joensson/1a6cefb1b7a23a001b51edcaa2cf5c05 to your computer and use it in GitHub Desktop.
WordPress Essentials

WordPress Essentials

This document has a collection of essential WordPress plugins plus a more advanced WP development setup

Paid Plugins

Advanced Custom Fields Pro - For custom fields

SearchWP - Includes ACF meta data in index + adds search statistic

WPML - The WordPress Multilingual Plugin - Adds localization functionality

Free plugins

Advanced Custom Fields: Image Crop Add-on - Adds image cropper to ACF image field type

Redirection - Provides a great way to add custom redirects from the WP admin panel

BackWPup – WordPress Backup Plugin - Offers a one click backup download of the database

User Role Editor - Create custom user roles and control over single users capabilities

User Switching - See what the user can see in the WP admin panel

All In One WP Security & Firewall - See best security practises and users logged in to the WP admin panel (Great if you have major changes to ACF field groups)

Yoast SEO - Easily customize page titles and meta descriptions on pages and posts

ACF Content Analysis for Yoast SEO

Nested Pages - Intuitive drag and drop + menu sync for pages

Advanced WordPress development setup

Roots.io's Bedrock WordPress - Bedrock provides modern and more secure WordPress development setup. Bedrock uses composer to manage dependencies including WP plugins

Timber - The Timber library adds the Twig Templating Engine + their own powerful object oriented methods (Timber Docs)

ACF fields registered via PHP - Registering ACF fields with php keeps the setup from being stored in the database. The huge gain from this is that the setup can be commited in the git repository. Additionally removes the need for field sync between development and production site

Setup steps

Default setup

  1. composer create-project roots/bedrock target-folder
  2. composer require wpackagist-plugin/timber-library wpackagist-plugin/wordpress-seo wpackagist-plugin/redirection wpackagist-plugin/backwpup wpackagist-plugin/user-role-editor wpackagist-plugin/all-in-one-wp-security-and-firewall wpackagist-plugin/user-switching wpackagist-plugin/better-search-replace

ACF PRO setup

Note that the "version" need to be updated to the desired version of acf

  1. Add your ACF PRO key to the .env file: ACF_PRO_KEY=YOUR_KEY
  2. In composer.json add the object below to the repositories array
  {
    "type": "package",
    "package": {
      "name": "advanced-custom-fields/advanced-custom-fields-pro",
      "version": "5.6.9",
      "type": "wordpress-plugin",
      "dist": {
        "type": "zip",
        "url": "https://connect.advancedcustomfields.com/index.php?p=pro&a=download"
      },
      "require": {
        "philippbaschke/acf-pro-installer": "^1.0",
        "composer/installers": "^1.0"
      }
    }
  }
  1. composer require advanced-custom-fields/advanced-custom-fields-pro:* wpackagist-plugin/acf-image-crop-add-on wpackagist-plugin/acf-content-analysis-for-yoast-seo

WordPress customization

<?php
// Make is_plugin_active in theme:
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );

/**
 * Hide admin bar from development setup
 */
if ( WP_ENV == 'development' ) {
    add_filter( 'show_admin_bar', '__return_false' );
}

/*
    ======================================
     Remove all notifications for all users except Admins
    ======================================
*/

add_action( 'admin_init', function() {
    if ( ! current_user_can('administrator') ) {
        function remove_core_updates(){
            global $wp_version;return(object) array('last_checked'=> time(),'version_checked'=> $wp_version,);
        }
        add_filter('pre_site_transient_update_core','remove_core_updates');
        add_filter('pre_site_transient_update_plugins','remove_core_updates');
        add_filter('pre_site_transient_update_themes','remove_core_updates');
    }
});

/*
    ======================================
     Remove Dashboard Widgets
    ======================================
*/

function remove_dashboard_widgets(){
    remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_primary', 'dashboard', 'side' );
    remove_meta_box( 'dashboard_secondary', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
    remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' );
    remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_activity', 'dashboard', 'normal' );
    remove_meta_box( 'welcome-panel', 'dashboard', 'normal' );
}
add_action( 'admin_menu', 'remove_dashboard_widgets' );

/**
 * Customize WYSIWYG paragraph selector and toolbars
 */
add_filter( 'tiny_mce_before_init', function( $settings ){
	$settings['block_formats'] = 'Paragraph=p;Heading=h2;Subheading=h3';
	return $settings;
} );
/**
 * Check if redirection plugin is active and allow editors to the plugin
 */
if ( is_plugin_active ( 'redirection/redirection.php' ) ) {
    add_filter( 'redirection_role', function () {
        return 'publish_pages';
    });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment