-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Praesidiarius
committed
Dec 4, 2019
1 parent
b7612de
commit deef011
Showing
7 changed files
with
246 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
/** | ||
* Plugin loader. | ||
* | ||
* @package OnePlace\Swissknife | ||
* @copyright 2019 Verein onePlace | ||
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html GNU General Public License, version 2 | ||
* @link https://1plc.ch/wordpress-plugins/swissknife | ||
*/ | ||
|
||
namespace OnePlace\Swissknife\Modules; | ||
|
||
use OnePlace\Swissknife\Plugin; | ||
|
||
final class Comments { | ||
/** | ||
* Main instance of the module | ||
* | ||
* @since 0.1-stable | ||
* @var Plugin|null | ||
*/ | ||
private static $instance = null; | ||
|
||
/** | ||
* Disable wordpress comments entirely | ||
* | ||
* @since 0.1-stable | ||
*/ | ||
public function register() { | ||
// Close comments on the front-end | ||
add_filter('comments_open', '__return_false', 20, 2); | ||
add_filter('pings_open', '__return_false', 20, 2); | ||
|
||
// Hide existing comments | ||
add_filter('comments_array', '__return_empty_array', 10, 2); | ||
|
||
// Remove comments page in menu | ||
add_action('admin_menu', function () { | ||
remove_menu_page('edit-comments.php'); | ||
}); | ||
|
||
// Remove comments links from admin bar | ||
add_action('init', function () { | ||
if (is_admin_bar_showing()) { | ||
remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60); | ||
} | ||
}); | ||
|
||
add_action('admin_init', function () { | ||
// Redirect any user trying to access comments page | ||
global $pagenow; | ||
|
||
if ($pagenow === 'edit-comments.php') { | ||
wp_redirect(admin_url()); | ||
exit; | ||
} | ||
// Remove comments metabox from dashboard | ||
remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal'); | ||
// Disable support for comments and trackbacks in post types | ||
foreach (get_post_types() as $post_type) { | ||
if (post_type_supports($post_type, 'comments')) { | ||
remove_post_type_support($post_type, 'comments'); | ||
remove_post_type_support($post_type, 'trackbacks'); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Loads the plugin main instance and initializes it. | ||
* | ||
* @since 0.1-stable | ||
* | ||
* @param string $main_file Absolute path to the plugin main file. | ||
* @return bool True if the plugin main instance could be loaded, false otherwise. | ||
*/ | ||
public static function load() { | ||
if ( null !== static::$instance ) { | ||
return false; | ||
} | ||
static::$instance = new self(); | ||
static::$instance->register(); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
/** | ||
* Plugin loader. | ||
* | ||
* @package OnePlace\Swissknife | ||
* @copyright 2019 Verein onePlace | ||
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html GNU General Public License, version 2 | ||
* @link https://1plc.ch/wordpress-plugins/swissknife | ||
*/ | ||
|
||
namespace OnePlace\Swissknife\Modules; | ||
|
||
use OnePlace\Swissknife\Plugin; | ||
|
||
final class Revisions { | ||
/** | ||
* Main instance of the module | ||
* | ||
* @since 0.1-stable | ||
* @var Plugin|null | ||
*/ | ||
private static $instance = null; | ||
|
||
/** | ||
* Enable Google Sitekit IP Anonymization | ||
* | ||
* @since 0.1-stable | ||
*/ | ||
public function register() { | ||
// change autosave interval from 60 to 300 seconds | ||
define('AUTOSAVE_INTERVAL', 300); | ||
|
||
// disable post revision | ||
define('WP_POST_REVISIONS', false); | ||
} | ||
|
||
/** | ||
* Loads the plugin main instance and initializes it. | ||
* | ||
* @since 0.1-stable | ||
* | ||
* @param string $main_file Absolute path to the plugin main file. | ||
* @return bool True if the plugin main instance could be loaded, false otherwise. | ||
*/ | ||
public static function load() { | ||
if ( null !== static::$instance ) { | ||
return false; | ||
} | ||
static::$instance = new self(); | ||
static::$instance->register(); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
/** | ||
* Plugin loader. | ||
* | ||
* @package OnePlace\Swissknife | ||
* @copyright 2019 Verein onePlace | ||
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html GNU General Public License, version 2 | ||
* @link https://1plc.ch/wordpress-plugins/swissknife | ||
*/ | ||
|
||
namespace OnePlace\Swissknife\Modules; | ||
|
||
use OnePlace\Swissknife\Plugin; | ||
|
||
final class Tweaks { | ||
/** | ||
* Main instance of the module | ||
* | ||
* @since 0.1-stable | ||
* @var Plugin|null | ||
*/ | ||
private static $instance = null; | ||
|
||
/** | ||
* Disable wordpress comments entirely | ||
* | ||
* @since 0.1-stable | ||
*/ | ||
public function register() { | ||
// Disable wordpress emojis | ||
add_action( 'init', [ $this, 'disableEmojis' ] ); | ||
|
||
// Disable XML-RPC | ||
add_filter('xmlrpc_enabled', '__return_false'); | ||
} | ||
|
||
public function disableEmojis() { | ||
remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); | ||
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); | ||
remove_action( 'wp_print_styles', 'print_emoji_styles' ); | ||
remove_action( 'admin_print_styles', 'print_emoji_styles' ); | ||
remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); | ||
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); | ||
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); | ||
add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' ); | ||
} | ||
|
||
/** | ||
* Loads the plugin main instance and initializes it. | ||
* | ||
* @since 0.1-stable | ||
* | ||
* @param string $main_file Absolute path to the plugin main file. | ||
* @return bool True if the plugin main instance could be loaded, false otherwise. | ||
*/ | ||
public static function load() { | ||
if ( null !== static::$instance ) { | ||
return false; | ||
} | ||
static::$instance = new self(); | ||
static::$instance->register(); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters