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 / file-uploader-allow-filetypes.php
Last active August 30, 2023 07:00
Custom code snippet that allows you to allow and/or disallow filetyps for the File Uploader extension.
<?php
// Add the following code snippet to the PHP section of the MainWP Custom Dashboard Extension
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 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 / 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 / branding-support-form.php
Created September 19, 2018 11:16
Enable MainWP Branding - Support Form for all or specific roles on child sites
<?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;
}
@bogdan-mainwp
bogdan-mainwp / custom-client-reports-tokens.php
Last active October 1, 2020 06:56
Custom code snippet for creating custom tokens for the Client Reports 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/
// Create Custom Client Report tokens
add_filter( 'mainwp_client_reports_tokens_groups', 'mycustom_reports_tokens_groups' );
function mycustom_reports_tokens_groups( $tokens ) {
// examples
@bogdan-mainwp
bogdan-mainwp / add-sites.php
Created May 30, 2018 12:28
Custom filter for adding new sites to MainWP Dashboard
<?php
// Available parameters: url, name, wpadmin, unique_id, groupids, ssl_verify, ssl_version, http_user, http_pass
$params = array(
'url' => 'demosite.com',
'name' => 'Site Friendly Name',
'wpadmin' => 'adminusername',
'unique_id' => 'unique_id'
);
@bogdan-mainwp
bogdan-mainwp / disable-wordfence-privacy-policy-change-notification.php
Created May 23, 2018 16:54
Custom snippet for the MainWP Code Snippets Extension that can be used for disabling the Privacy Policy change notification introduced in the recent Wordfence plugin update.
<?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
wfConfig::set('touppPromptNeeded', 0);
// To reverse the update, use wfConfig::set('touppPromptNeeded', 1);
@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 / custom-report-pdf-paper-size.php
Last active January 12, 2021 11:14
Custom code snippet for setting the custom paper size for the client report PDF.
<?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_client_report_pdf_page_format', 'mycustom_pdf_page_format', 10 , 1 );
function mycustom_pdf_page_format( $format = '' ) {
return 'A4';
}
@bogdan-mainwp
bogdan-mainwp / mainwp-client-reports-linebreak.php
Last active November 4, 2020 14:44
Custom code snippet for fixing the line break issue in reports.
<?php
// Add the following code snippet to the PHP section of the MainWP Custom Dashboard Extension
add_filter( 'mainwp_client_reports_newline_break', 'mycustom_client_reports_newline_break', 10, 1 );
function mycustom_client_reports_newline_break( $value ){
return false;
}