Coder Social home page Coder Social logo

review-easy's Introduction

Repo for the Review-Easy project: https://www.cloudfest.com/review-easy-reduce-outgoing-network-traffic-of-your-wordpress-server

Setup

Run composer install to generate the autoloader.

Run npm install to install dependencies.

Run npm run start to run the plugin dashboard settings.

Run composer cs to check the CS of the entire codebase. Prefix this with a file path for a specific file.

Run composer fix-cs to fix the automatically fixed CS of the entire codebase. Prefix this with a file path for a specific file.

Run composer test to run the unit tests.

Run composer phpstan to run PHPStan.

Features

Reschedules of actions that perform external requests

The plugin's goal is to be an opinionated actor that automatically reduces scheduled actions that contain external requests. That way, it can have a positive impact on the carbon footprint of a website out-of-the-box.

Current examples of such automatic reschedules:

  • Reduces runs of the wp_https_detection scheduled action from twice per day to weekly, if the site is already on https. Otherwise, it reduces it to daily.
  • Reduces runs of the wp_version_check scheduled action from twice per day to weekly, if the site is already on an outdated version.
  • Disables completely the wp_version_check scheduled action, if the site has an active DISALLOW_FILE_MODS define.

But in order to maximize potential impact, the plugin also implements a public API for hosts, web owners, etc. to hook into and reschedule such requests even further themselves, according to their site's specific needs and requirements.

Public API

To reschedule a scheduled event, just call the following line, and replace 'daily' with your desired recurrence. This is an open API and can be used at will. This needs to be called prior to the actual register hook.

\ReviewEasy\ReviewEasyWP\Alter_Schedule::reschedule( 'action_name', 'daily' )
add_action(
	'plugins_loaded',
	function () {
		\ReviewEasy\ReviewEasyWP\Alter_Schedule::reschedule( 'wp_https_detection', 'daily' );
	},
	0
);

Manual Throttling

The goal of this feature is to be able to provide hosts, web owners, etc. a public API to throttle specific external requests themselves, according to their site's specific needs and requirements:

add_filter(
    'review_easy_wp_throttled_requests',
    function ( $throttledRequests ) {
        $throttledRequests[] = new \ReviewEasy\ReviewEasyWP\Throttled_Request(
            'https://some.spammy.plugin/ping',
            MONTH_IN_SECONDS,
            'GET'
        );

        return $throttledRequests;
    }
);

Disabling unnecessary core features

We take an opinionated approach to disabling core features that most users aren't actually using. One of these is the News & Events Widget on the dashboard, which sends requests each day to pull in new data.

Public API

To reactivate the News & Events Widget, you can use the following filter:

add_filter( 'review_easy_disable_wordpress_news_events_widget', '__return_false' );

Settings & Chart

In the plugin's admin setting page, the plugin has:

  • a graph that helps provide information to web owners about the amount of scheduled external requests the website is currently saving
  • a list of external requests whose frequency the web owner can tweak

Those frontend features are currently implemented, but hardcodedly so they don't carry any dynamic functionality yet.

review-easy's People

Contributors

diedexx avatar zsolt-r avatar leonidasmi avatar petaryoast avatar vraja-pro avatar thierrya avatar d-claassen avatar pls78 avatar moritzbappert avatar thijsoo avatar hansjovis avatar boblinthorst avatar apermo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.