Skip to content

Instantly share code, notes, and snippets.

@bogdan-mainwp
bogdan-mainwp / premium-plugin-updates.php
Last active Mar 14, 2019
Support for the Premium Plugin updates
View premium-plugin-updates.php
<?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_detect_premium_plugins_update', 'myhook_mainwp_detect_premium_plugins_update', 10 );
function myhook_mainwp_detect_premium_plugins_update( $premiums ) {
// add plugin info (slug) here. In this example, we used Elementor Extras, but you should replace it with the correct plugin info
$premiums[] = 'elementor-extras/elementor-extras.php';
@bogdan-mainwp
bogdan-mainwp / code-snippets-customizations.php
Created Mar 8, 2019
Custom code snippet to change code editor height and background color for the Code Snippets extension.
View code-snippets-customizations.php
<?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 / disable-referral-in-google-analytics.php
Created Dec 6, 2018
Custom snippet for disabling referral in Google Analytics
View disable-referral-in-google-analytics.php
<?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 Dec 6, 2018
Custom code snippet for clearing SG Optimizer cache on child sites
View purge-sg-optimizer-cache.php
<?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!";
@bogdan-mainwp
bogdan-mainwp / custom-mainwp-menu-header.php
Last active Dec 6, 2018
Custom snippet for renaming the MainWP Dashboard WP Admin menu header
View custom-mainwp-menu-header.php
<?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 / specific-time-for-emails.php
Last active Dec 6, 2018
Set specific time for email notifications about Trusted Updates
View specific-time-for-emails.php
<?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_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 / file-uploader-allow-filetypes.php
Last active Dec 6, 2018
Custom code snippet that allows you to allow and/or disallow filetyps for the File Uploader extension.
View file-uploader-allow-filetypes.php
<?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_file_uploader_allowed_file_types', 'mycustom_mainwp_file_uploader_allowed_file_types');
function mycustom_mainwp_file_uploader_allowed_file_types( $types ) {
$types[] = 'htaccess';
return $types;
@bogdan-mainwp
bogdan-mainwp / disable-get-site-size.php
Last active Dec 6, 2018
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.
View disable-get-site-size.php
<?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 / sticky-select-sites.php
Last active Dec 6, 2018
Custom snippet for making the Select Sites box sticky
View sticky-select-sites.php
<?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 / branding-support-form.php
Created Sep 19, 2018
Enable MainWP Branding - Support Form for all or specific roles on child sites
View branding-support-form.php
<?php
// Add one of the following code snippet to the functions.php file of the active theme of your child site(s).
// Enable Support form for all roles
add_filter( 'mainwp_branding_role_cap_enable_contact_form', 'mycustom_mainwp_branding_role_cap_enable_contact_form' );
function mycustom_mainwp_branding_role_cap_enable_contact_form( $input = false ) {
return true;
}
You can’t perform that action at this time.