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 / 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 / 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;
}
<?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_updatescheck_disable_sendmail', 'mycustom_mainwp_updatescheck_disable_sendmail', 10, 1 );
function mycustom_mainwp_updatescheck_disable_sendmail( $input ) {
return true;
}
@bogdan-mainwp
bogdan-mainwp / premium-plugin-updates.php
Last active May 14, 2020 01:36
Support for the Premium Plugin updates
<?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_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';
return $premiums;
}
@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 / 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;
}
@bogdan-mainwp
bogdan-mainwp / hide-custom-branding.php
Created October 3, 2019 17:00
Hide custom branding for certain user
<?php
// Hide custom branidng for the user with specific ID
// Replace ID with actual ID number
add_filter( 'mainwp_child_branding_init_options', 'mycustom_mainwp_child_branding_init_options' );
function mycustom_mainwp_child_branding_init_options( $option ) {       
$current_user_id = get_current_user_id();       
if ( $current_user_id == 'ID' && is_array( $option ) && isset( $option[ 'cancelled_branding' ] ) ) {        
$option[ 'cancelled_branding' ] = true;    
@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 / 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 / mainwp-custom-edit-site-field.php
Created April 11, 2023 16:48
Snippet exapmle for creating a custom field in the edit site form
add_action( 'mainwp_manage_sites_edit', 'myhook_mainwp_manage_sites_edit', 10, 1 );
function myhook_mainwp_manage_sites_edit( $website ) {
$myvalue = apply_filters( 'mainwp_getwebsiteoptions', false, $website, 'my_site_value' );
?>
<div class="ui grid field">
<label class="six wide column middle aligned"><?php esc_html_e( 'My Value', 'mainwp' ); ?></label>
<div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'My Value', 'mainwp' ); ?>" data-inverted="" data-position="top left">
<div class="ui left labeled input">
<input type="text" id="mainwp_managesites_edit_my_value" name="mainwp_managesites_edit_my_value" value="<?php echo esc_html($myvalue); ?>"/>
</div>