Skip to content

Instantly share code, notes, and snippets.

View bogdan-mainwp's full-sized avatar

Bogdan Rapaić bogdan-mainwp

View GitHub Profile
@bogdan-mainwp
bogdan-mainwp / show-full-comment-content.php
Created April 20, 2020 11:12
Filter to display custom comment lenght in the MainWP Comments extension
<?php
// Add the following code snippet to the PHP section of the MainWP Custom Dashboard Extension,
// or the functions.php file of the active theme on your Dashboard site.
add_filter( 'mainwp_comments_widget_limit_string', 'mycustom_mainwp_comments_widget_limit_string', 10, 1 );
function mycustom_mainwp_comments_widget_limit_string( $length = false ) {
return 99999;
}
@bogdan-mainwp
bogdan-mainwp / specific-time-for-emails.php
Last active April 16, 2020 11:56
Set specific time for email notifications about Trusted Updates
<?php
// Add the following code snippet to the PHP section in the MainWP Custom Dashbaord plugin
add_filter( 'mainwp_updatescheck_sendmail_at_time', 'mycustom_mainwp_updatescheck_sendmail_at_time', 10, 1 );
function myhook_mainwp_updatescheck_sendmail_at_time( $hour ) {
$hour = '12:00'; // send email notifactions after 12:00
return $hour;
}
@bogdan-mainwp
bogdan-mainwp / code-snippets-customizations.php
Created March 8, 2019 09:52
Custom code snippet to change code editor height and background color for the Code Snippets extension.
<?php
// Add the following code snippet to the functions.php file of the MainWP Customisations plugin
// Download MainWP Customisations here: https://github.com/mainwp/mainwp-customisations
// More about the plugin: https://mainwp.com/mainwp-customisations/
add_filter( 'mainwp_codesnippets_editor_attr', 'myhook_mainwp_codesnippets_editor_attr', 10);
function myhook_mainwp_codesnippets_editor_attr( $data ) {
$data['height'] = 500;
// supported themes: 'erlang-dark', 'night', 'xq-dark', 'xq-light', 'the-matrix', 'eclipse'
@bogdan-mainwp
bogdan-mainwp / mainwp-wp-version.php
Last active December 6, 2018 14:02
Custom code snippet for creating a custom WP Version column in the Manage Sites table and displaying Child Site WP version for each child site.
<?php
// Add the following code snippet to the functions.php file of the MainWP Customisations plugin
// Download MainWP Customisations here: https://github.com/mainwp/mainwp-customisations
// More about the plugin: https://mainwp.com/mainwp-customisations/
// WP Version example
add_filter( 'mainwp-sitestable-getcolumns', 'mycustom_sites_table_column', 10 );
add_filter( 'mainwp-sitestable-item', 'mycustom_sitestable_item', 10 );
@bogdan-mainwp
bogdan-mainwp / disable-openssl-usage.php
Last active December 6, 2018 14:01
Custom snippet for disabling OpenSSL.cnf usage.
<?php
// Add the following code snippet to the functions.php file of the MainWP Customisations plugin
// Download MainWP Customisations here: https://github.com/mainwp/mainwp-customisations
// More about the plugin: https://mainwp.com/mainwp-customisations/
// Disable OpenSSL.cnf usage
if ( ! defined( 'MAINWP_CRYPT_RSA_OPENSSL_CONFIG' ) ) {
define( 'MAINWP_CRYPT_RSA_OPENSSL_CONFIG', false );
}
@bogdan-mainwp
bogdan-mainwp / sticky-select-sites.php
Last active December 6, 2018 14:01
Custom snippet for making the Select Sites box sticky
<?php
// Add the following code snippet to the functions.php file of the MainWP Customisations plugin
// Download MainWP Customisations here: https://github.com/mainwp/mainwp-customisations
// More about the plugin: https://mainwp.com/mainwp-customisations/
add_action('admin_head', 'sticky_sidebar');
function sticky_sidebar() {
echo '<style>.mainwp_select_sites_box { position: -webkit-sticky; position: sticky; top: 0; }</style>';
}
@bogdan-mainwp
bogdan-mainwp / custom-mainwp-menu-header.php
Last active December 6, 2018 14:00
Custom snippet for renaming the MainWP Dashboard WP Admin menu header
<?php
// Add the following code snippet to the functions.php file of the MainWP Customisations plugin
// Download MainWP Customisations here: https://github.com/mainwp/mainwp-customisations
// More about the plugin: https://mainwp.com/mainwp-customisations/
add_action( 'admin_head', 'mycustom_menu_admin_head' );
function mycustom_menu_admin_head() {
global $menu;
foreach( $menu as &$item ) {
@bogdan-mainwp
bogdan-mainwp / disable-get-site-size.php
Last active December 6, 2018 13:59
Custom snippet that will disable site size calculation. In case of inability to connect a child site, it is good to try to use this on the child site.
<?php
// Add the following code snippet to the functions.php file of the active theme of your Child Site site.
add_filter( 'mainwp-child-get-total-size', 'mycustom_mainwp_child_get_total_size', 10 , 1 );
function mycustom_mainwp_child_get_total_size( $value ) {
return false;
}
?>
@bogdan-mainwp
bogdan-mainwp / disable-referral-in-google-analytics.php
Created December 6, 2018 13:55
Custom snippet for disabling referral in Google Analytics
<?php
// Add the following code snippet to the functions.php file of the MainWP Customisations plugin
// Download MainWP Customisations here: https://github.com/mainwp/mainwp-customisations
// More about the plugin: https://mainwp.com/mainwp-customisations/
add_filter( 'mainwp_open_hide_referrer', 'myhook_mainwp_open_hide_referrer');
function myhook_mainwp_open_hide_referrer() {
return true;
}
@bogdan-mainwp
bogdan-mainwp / purge-sg-optimizer-cache.php
Created December 6, 2018 13:09
Custom code snippet for clearing SG Optimizer cache on child sites
<?php
// Use this snippet in the MainWP Code Snippets Extension (https://mainwp.com/extension/code-snippets/)
// Snippet Type: This Code Snippet only returns information from Child Site
if ( function_exists( 'sg_cachepress_purge_cache' ) ) {
sg_cachepress_purge_cache();
echo "Cache cleared successfully!";
} else {
echo "Clearing cache failed!";