Plugin Directory

Timestamp:
08/21/2019 06:08:02 PM (6 years ago)
Author:
fruitfulcode
Message:

New version 3.7.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • maintenance/trunk/includes/functions.php

    r2140617 r2143309  
    2121);
    2222
    23 
    24 function mt_get_plugin_options( $is_current = false ) {
     23function mtnc_get_plugin_options( $is_current = false ) {
    2524    $saved = (array) get_option( 'maintenance_options' );
    2625
    2726    if ( ! $is_current ) {
    28         $options = wp_parse_args( get_option( 'maintenance_options', array() ), mt_get_default_array() );
     27        $options = wp_parse_args( get_option( 'maintenance_options', array() ), mtnc_get_default_array() );
    2928    } else {
    3029        $options = $saved;
     
    3332}
    3433
    35 function generate_input_filed( $title, $id, $name, $value, $placeholder = '' ) {
     34function mtnc_generate_input_filed( $title, $id, $name, $value, $placeholder = '' ) {
    3635    $out_filed  = '';
    3736    $out_filed .= '<tr valign="top">';
     
    3938    $out_filed .= '<td>';
    4039    $out_filed .= '<fieldset>';
    41     $out_filed .= '<input type="text" id="' . esc_attr( $id ) . '" name="lib_options[' . $name . ']" value="' . esc_attr( stripslashes( $value ) ) . '" placeholder="' . $placeholder . '"/>';
     40    $out_filed .= '<input type="text" id="' . esc_attr( $id ) . '" name="lib_options[' . $name . ']" value="' . esc_attr( stripslashes( $value ) ) . '" placeholder="' . esc_attr( $placeholder ) . '"/>';
    4241    $out_filed .= '</fieldset>';
    4342    $out_filed .= '</td>';
    4443    $out_filed .= '</tr>';
    45     echo $out_filed;
    46 }
    47 
    48 function generate_number_filed( $title, $id, $name, $value, $placeholder = '' ) {
     44    echo $out_filed; // phpcs:ignore WordPress.Security.EscapeOutput
     45}
     46
     47function mtnc_generate_number_filed( $title, $id, $name, $value, $placeholder = '' ) {
    4948    $out_filed  = '';
    5049    $out_filed .= '<tr valign="top">';
     
    5251    $out_filed .= '<td>';
    5352    $out_filed .= '<fieldset>';
    54     $out_filed .= '<input type="number" min="0" step="1" pattern="[0-9]{10}" id="' . esc_attr( $id ) . '" name="lib_options[' . $name . ']" value="' . esc_attr( stripslashes( $value ) ) . '" placeholder="' . $placeholder . '"/>';
     53    $out_filed .= '<input type="number" min="0" step="1" pattern="[0-9]{10}" id="' . esc_attr( $id ) . '" name="lib_options[' . $name . ']" value="' . esc_attr( stripslashes( $value ) ) . '" placeholder="' . esc_attr( $placeholder ) . '"/>';
    5554    $out_filed .= '</fieldset>';
    5655    $out_filed .= '</td>';
    5756    $out_filed .= '</tr>';
    58     echo $out_filed;
    59 }
    60 
    61 function generate_textarea_filed( $title, $id, $name, $value ) {
     57    echo $out_filed; // phpcs:ignore WordPress.Security.EscapeOutput
     58}
     59
     60function mtnc_generate_textarea_filed( $title, $id, $name, $value ) {
    6261    $out_filed  = '';
    6362    $out_filed .= '<tr valign="top">';
     
    6564    $out_filed .= '<td>';
    6665    $out_filed .= '<fieldset>';
    67     $out_filed .= '<textarea name="lib_options[' . $name . ']" id="' . esc_attr( $id ) . '" cols="30" rows="10">' . wp_kses_post( stripslashes( $value ) ) . '</textarea>';
     66    $out_filed .= '<textarea name="lib_options[' . $name . ']" id="' . esc_attr( $id ) . '" cols="30" rows="10">' . esc_textarea( $value ) . '</textarea>';
    6867    $out_filed .= '</fieldset>';
    6968    $out_filed .= '</td>';
    7069    $out_filed .= '</tr>';
    71     echo $out_filed;
    72 }
    73 
    74 
    75 function generate_tinymce_filed( $title, $id, $name, $value ) {
     70    echo $out_filed; // phpcs:ignore WordPress.Security.EscapeOutput
     71}
     72
     73
     74function mtnc_generate_tinymce_filed( $title, $id, $name, $value ) {
    7675    $out_filed  = '';
    7776    $out_filed .= '<tr valign="top">';
     
    9493    $out_filed .= '</td>';
    9594    $out_filed .= '</tr>';
    96     echo $out_filed;
    97 }
    98 
    99 
    100 function generate_check_filed( $title, $label, $id, $name, $value ) {
     95    echo $out_filed; // phpcs:ignore WordPress.Security.EscapeOutput
     96}
     97
     98
     99function mtnc_generate_check_filed( $title, $label, $id, $name, $value ) {
    101100    $out_filed  = '';
    102101    $out_filed .= '<tr valign="top">';
     
    111110    $out_filed .= '</td>';
    112111    $out_filed .= '</tr>';
    113     echo $out_filed;
    114 }
    115 
    116 function generate_image_filed( $title, $id, $name, $value, $class, $name_btn, $class_btn ) {
     112    echo $out_filed; // phpcs:ignore WordPress.Security.EscapeOutput
     113}
     114
     115function mtnc_generate_image_filed( $title, $id, $name, $value, $class, $name_btn, $class_btn ) {
    117116    $out_filed = '';
    118117
     
    140139    $out_filed .= '</td>';
    141140    $out_filed .= '</tr>';
    142     echo $out_filed;
    143 }
    144 
    145 function get_color_field( $title, $id, $name, $value, $default_color ) {
     141    echo $out_filed; // phpcs:ignore WordPress.Security.EscapeOutput
     142}
     143
     144function mtnc_get_color_field( $title, $id, $name, $value, $default_color ) {
    146145    $out_filed  = '';
    147146    $out_filed .= '<tr valign="top">';
     
    153152    $out_filed .= '</td>';
    154153    $out_filed .= '</tr>';
    155     echo $out_filed;
    156 }
    157 
    158 function mt_get_google_font( $font = null ) {
     154    echo $out_filed; // phpcs:ignore WordPress.Security.EscapeOutput
     155}
     156
     157function mtnc_get_google_font( $font = null ) {
    159158    $font_params = $full_link = $gg_fonts = '';
    160159
    161     $gg_fonts = json_decode( mt_get_google_fonts() );
     160    $gg_fonts = json_decode( mtnc_get_google_fonts() );
    162161
    163162    if ( property_exists( $gg_fonts, $font ) ) {
     
    180179}
    181180
     181/*
     182 * Function get_fonts_field is backward compatibility with Maintenance PRO Version 3.6.2 and below */
    182183function get_fonts_field( $title, $id, $name, $value ) {
     184    return mtnc_get_fonts_field( $title, $id, $name, $value );
     185}
     186
     187function mtnc_get_fonts_field( $title, $id, $name, $value ) {
    183188    global $standart_fonts;
    184189    $out_items = $gg_fonts = '';
    185190
    186     $gg_fonts = json_decode( mt_get_google_fonts() );
     191    $gg_fonts = json_decode( mtnc_get_google_fonts() );
    187192
    188193    $out_filed  = '';
     
    213218    $out_filed .= '</td>';
    214219    $out_filed .= '</tr>';
    215     return $out_filed;
    216 }
    217 
    218 function get_fonts_subsets( $title, $id, $name, $value ) {
     220    return $out_filed; // phpcs:ignore WordPress.Security.EscapeOutput
     221}
     222
     223function mtnc_get_fonts_subsets( $title, $id, $name, $value ) {
    219224    global $standart_fonts;
    220225    $out_items = $gg_fonts = $curr_font = $mt_option = '';
    221     $mt_option = mt_get_plugin_options( true );
     226    $mt_option = mtnc_get_plugin_options( true );
    222227    $curr_font = esc_attr( $mt_option['body_font_family'] );
    223228    $vars      = 'subsets';
    224229
    225     $gg_fonts = json_decode( mt_get_google_fonts(), true );
     230    $gg_fonts = json_decode( mtnc_get_google_fonts(), true );
    226231
    227232    if ( ! empty( $gg_fonts ) ) {
     
    234239        $out_filed .= '<select class="select2_customize" name="lib_options[' . $name . ']" id="' . esc_attr( $id ) . '">';
    235240        if ( ! empty( $gg_fonts[ $curr_font ] ) ) {
    236             // if(!empty($gg_fonts[$curr_font][$vars])){
    237241            foreach ( $gg_fonts[ $curr_font ]['variants'] as $key => $v ) {
    238242                $out_filed .= '<option value="' . $v . '" ' . selected( $value, $v, false ) . '>' . $v . '</option>';
    239243            }
    240             // }
    241244        }
    242245        $out_filed .= '</select>';
     
    246249        $out_filed .= '</tr>';
    247250    }
    248     return $out_filed;
    249 }
    250 
    251 function maintenance_page_create_meta_boxes() {
    252     global $maintenance_variable;
    253     add_meta_box( 'maintenance-general', __( 'General Settings', 'maintenance' ), 'add_data_fields', $maintenance_variable->options_page, 'normal', 'default' );
    254     add_meta_box( 'maintenance-css', __( 'Custom CSS', 'maintenance' ), 'add_css_fields', $maintenance_variable->options_page, 'normal', 'default' );
    255     add_meta_box( 'maintenance-excludepages', __( 'Exclude pages from maintenance mode', 'maintenance' ), 'add_exclude_pages_fields', $maintenance_variable->options_page, 'normal', 'default' );
    256 }
    257 add_action( 'add_mt_meta_boxes', 'maintenance_page_create_meta_boxes', 10 );
    258 
    259 function maintenance_page_create_meta_boxes_widget_pro() {
    260     global $maintenance_variable;
    261     add_meta_box( 'promo-extended', __( 'Pro version', 'maintenance' ), 'maintenanace_extended_version', $maintenance_variable->options_page, 'side', 'default' );
    262 }
    263 add_action( 'add_mt_meta_boxes', 'maintenance_page_create_meta_boxes_widget_pro', 11 );
    264 
    265 
    266 function maintenance_page_create_meta_boxes_our_themes() {
    267     global $maintenance_variable;
    268     add_meta_box( 'promo-our-themes', __( 'Fruitful Code projects', 'maintenance' ), 'maintenanace_our_themes', $maintenance_variable->options_page, 'side', 'default' );
    269 }
    270 add_action( 'add_mt_meta_boxes', 'maintenance_page_create_meta_boxes_our_themes', 12 );
    271 
    272 function maintenance_page_create_meta_boxes_widget_support() {
    273     global $maintenance_variable;
    274     add_meta_box( 'promo-content', __( 'Support', 'maintenance' ), 'maintenanace_contact_support', $maintenance_variable->options_page, 'side', 'default' );
    275 }
    276 add_action( 'add_mt_meta_boxes', 'maintenance_page_create_meta_boxes_widget_support', 13 );
    277 
    278 function maintenance_page_create_meta_boxes_improve_translate() {
    279     global $maintenance_variable;
    280     add_meta_box( 'promo-translate', __( 'Translation', 'maintenance' ), 'maintenanace_improve_translate', $maintenance_variable->options_page, 'side', 'default' );
    281 }
    282 add_action( 'add_mt_meta_boxes', 'maintenance_page_create_meta_boxes_improve_translate', 14 );
    283 
    284 function add_data_fields( $object, $box ) {
    285     $mt_option = mt_get_plugin_options( true );
     251    return $out_filed; // phpcs:ignore WordPress.Security.EscapeOutput
     252}
     253
     254function mtnc_page_create_meta_boxes() {
     255    global $mtnc_variable;
     256    add_meta_box( 'mtnc-general', __( 'General Settings', 'maintenance' ), 'mtnc_add_data_fields', $mtnc_variable->options_page, 'normal', 'default' );
     257    add_meta_box( 'mtnc-css', __( 'Custom CSS', 'maintenance' ), 'mtnc_add_css_fields', $mtnc_variable->options_page, 'normal', 'default' );
     258    add_meta_box( 'mtnc-excludepages', __( 'Exclude pages from maintenance mode', 'maintenance' ), 'mtnc_add_exclude_pages_fields', $mtnc_variable->options_page, 'normal', 'default' );
     259}
     260add_action( 'add_mt_meta_boxes', 'mtnc_page_create_meta_boxes', 10 );
     261
     262function mtnc_page_create_meta_boxes_widget_pro() {
     263    global $mtnc_variable;
     264    add_meta_box( 'promo-extended', __( 'Pro version', 'maintenance' ), 'mtnc_extended_version', $mtnc_variable->options_page, 'side', 'default' );
     265}
     266add_action( 'add_mt_meta_boxes', 'mtnc_page_create_meta_boxes_widget_pro', 11 );
     267
     268
     269function mtnc_page_create_meta_boxes_our_themes() {
     270    global $mtnc_variable;
     271    add_meta_box( 'promo-our-themes', __( 'Fruitful Code projects', 'maintenance' ), 'mtnc_our_themes', $mtnc_variable->options_page, 'side', 'default' );
     272}
     273add_action( 'add_mt_meta_boxes', 'mtnc_page_create_meta_boxes_our_themes', 12 );
     274
     275function mtnc_page_create_meta_boxes_widget_support() {
     276    global $mtnc_variable;
     277    add_meta_box( 'promo-content', __( 'Support', 'maintenance' ), 'mtnc_contact_support', $mtnc_variable->options_page, 'side', 'default' );
     278}
     279add_action( 'add_mt_meta_boxes', 'mtnc_page_create_meta_boxes_widget_support', 13 );
     280
     281function mtnc_page_create_meta_boxes_improve_translate() {
     282    global $mtnc_variable;
     283    add_meta_box( 'promo-translate', __( 'Translation', 'maintenance' ), 'mtnc_improve_translate', $mtnc_variable->options_page, 'side', 'default' );
     284}
     285add_action( 'add_mt_meta_boxes', 'mtnc_page_create_meta_boxes_improve_translate', 14 );
     286
     287function mtnc_add_data_fields( $object, $box ) {
     288    $mt_option = mtnc_get_plugin_options( true );
    286289    $is_blur   = false;
    287290
     
    313316        <tbody>
    314317        <?php
    315         generate_input_filed( __( 'Page title', 'maintenance' ), 'page_title', 'page_title', $page_title );
    316         generate_input_filed( __( 'Headline', 'maintenance' ), 'heading', 'heading', $heading );
    317         generate_tinymce_filed( __( 'Description', 'maintenance' ), 'description', 'description', $description );
    318         generate_input_filed( __( 'Footer Text', 'maintenance' ), 'footer_text', 'footer_text', $footer_text );
    319         generate_number_filed( __( 'Set Logo width', 'maintenance' ), 'logo_width', 'logo_width', $logo_width );
    320         generate_number_filed( __( 'Set Logo height', 'maintenance' ), 'logo_height', 'logo_height', $logo_height );
    321         generate_image_filed( __( 'Logo', 'maintenance' ), 'logo', 'logo', (int)$mt_option['logo'], 'boxes box-logo', __( 'Upload Logo', 'maintenance' ), 'upload_logo upload_btn button' );
    322         generate_image_filed( __( 'Retina logo', 'maintenance' ), 'retina_logo', 'retina_logo', (int)$mt_option['retina_logo'], 'boxes box-logo', __( 'Upload Retina Logo', 'maintenance' ), 'upload_logo upload_btn button' );
    323         do_action( 'maintenance_background_field' );
    324         generate_image_filed( __( 'Background image (portrait mode)', 'maintenance' ), 'bg_image_portrait', 'bg_image_portrait', isset( $mt_option['bg_image_portrait'] ) ? (int)$mt_option['bg_image_portrait'] : '', 'boxes box-logo', __( 'Upload image for portrait device orientation', 'maintenance' ), 'upload_logo upload_btn button' );
    325         generate_image_filed( __( 'Page preloader image', 'maintenance' ), 'preloader_img', 'preloader_img', isset( $mt_option['preloader_img'] ) ? (int)$mt_option['preloader_img'] : '', 'boxes box-logo', __( 'Upload preloader', 'maintenance' ), 'upload_logo upload_btn button' );
    326 
    327         do_action( 'maintenance_color_fields' );
    328         do_action( 'maintenance_font_fields' );
    329         generate_check_filed( __( '503', 'maintenance' ), __( 'Service temporarily unavailable, Google analytics will be disable.', 'maintenance' ), '503_enabled', '503_enabled', ! empty( $mt_option['503_enabled'] ) );
     318        mtnc_generate_input_filed( __( 'Page title', 'maintenance' ), 'page_title', 'page_title', $page_title );
     319        mtnc_generate_input_filed( __( 'Headline', 'maintenance' ), 'heading', 'heading', $heading );
     320        mtnc_generate_tinymce_filed( __( 'Description', 'maintenance' ), 'description', 'description', $description );
     321        mtnc_generate_input_filed( __( 'Footer Text', 'maintenance' ), 'footer_text', 'footer_text', $footer_text );
     322        mtnc_generate_number_filed( __( 'Set Logo width', 'maintenance' ), 'logo_width', 'logo_width', $logo_width );
     323        mtnc_generate_number_filed( __( 'Set Logo height', 'maintenance' ), 'logo_height', 'logo_height', $logo_height );
     324        mtnc_generate_image_filed( __( 'Logo', 'maintenance' ), 'logo', 'logo', (int) $mt_option['logo'], 'boxes box-logo', __( 'Upload Logo', 'maintenance' ), 'upload_logo upload_btn button' );
     325        mtnc_generate_image_filed( __( 'Retina logo', 'maintenance' ), 'retina_logo', 'retina_logo', (int) $mt_option['retina_logo'], 'boxes box-logo', __( 'Upload Retina Logo', 'maintenance' ), 'upload_logo upload_btn button' );
     326        do_action( 'mtnc_background_field' );
     327        mtnc_generate_image_filed( __( 'Background image (portrait mode)', 'maintenance' ), 'bg_image_portrait', 'bg_image_portrait', isset( $mt_option['bg_image_portrait'] ) ? (int) $mt_option[ 'bg_image_portrait' ] : '', 'boxes box-logo', __( 'Upload image for portrait device orientation', 'maintenance' ), 'upload_logo upload_btn button' );
     328        mtnc_generate_image_filed( __( 'Page preloader image', 'maintenance' ), 'preloader_img', 'preloader_img', isset( $mt_option['preloader_img'] ) ? (int) $mt_option['preloader_img'] : '', 'boxes box-logo', __( 'Upload preloader', 'maintenance' ), 'upload_logo upload_btn button' );
     329
     330        do_action( 'mtnc_color_fields' );
     331        do_action( 'mtnc_font_fields' );
     332        mtnc_generate_check_filed( __( '503', 'maintenance' ), __( 'Service temporarily unavailable, Google analytics will be disable.', 'maintenance' ), '503_enabled', '503_enabled', ! empty( $mt_option['503_enabled'] ) );
    330333
    331334        $gg_analytics_id = '';
     
    334337        }
    335338
    336         generate_input_filed( __( 'Google Analytics ID', 'maintenance' ), 'gg_analytics_id', 'gg_analytics_id', $gg_analytics_id, __( 'UA-XXXXX-X', 'maintenance' ) );
    337         generate_input_filed( __( 'Set blur intensity', 'maintenance' ), 'blur_intensity', 'blur_intensity', (int) $mt_option['blur_intensity'] );
     339        mtnc_generate_input_filed( __( 'Google Analytics ID', 'maintenance' ), 'gg_analytics_id', 'gg_analytics_id', $gg_analytics_id, __( 'UA-XXXXX-X', 'maintenance' ) );
     340        mtnc_generate_input_filed( __( 'Set blur intensity', 'maintenance' ), 'blur_intensity', 'blur_intensity', (int) $mt_option['blur_intensity'] );
    338341
    339342        if ( isset( $mt_option['is_blur'] ) ) {
     
    343346        }
    344347
    345         generate_check_filed( __( 'Apply background blur', 'maintenance' ), '', 'is_blur', 'is_blur', $is_blur );
    346         generate_check_filed( __( 'Enable frontend login', 'maintenance' ), '', 'is_login', 'is_login', isset( $mt_option['is_login'] ) );
     348        mtnc_generate_check_filed( __( 'Apply background blur', 'maintenance' ), '', 'is_blur', 'is_blur', $is_blur );
     349        mtnc_generate_check_filed( __( 'Enable frontend login', 'maintenance' ), '', 'is_login', 'is_login', isset( $mt_option['is_login'] ) );
    347350
    348351        ?>
     
    353356
    354357
    355 function add_css_fields() {
    356     $mt_option = mt_get_plugin_options( true );
     358function mtnc_add_css_fields() {
     359    $mt_option = mtnc_get_plugin_options( true );
    357360    echo '<table class="form-table">';
    358361    echo '<tbody>';
    359     generate_textarea_filed( __( 'CSS Code', 'maintenance' ), 'custom_css', 'custom_css', wp_kses_stripslashes( $mt_option['custom_css'] ) );
     362    mtnc_generate_textarea_filed( __( 'CSS Code', 'maintenance' ), 'custom_css', 'custom_css', wp_kses_stripslashes( $mt_option['custom_css'] ) );
    360363    echo '</tbody>';
    361364    echo '</table>';
    362365}
    363366
    364 function add_exclude_pages_fields() {
    365     $mt_option = mt_get_plugin_options( true );
     367function mtnc_add_exclude_pages_fields() {
     368    $mt_option = mtnc_get_plugin_options( true );
    366369    $out_filed = '';
    367370
     
    435438    $out_filed .= '</table>';
    436439
    437     echo $out_filed;
    438 }
    439 
    440 function get_background_fileds_action() {
    441     $mt_option = mt_get_plugin_options( true );
    442     generate_image_filed( __( 'Background image', 'maintenance' ), 'body_bg', 'body_bg', esc_attr( $mt_option['body_bg'] ), 'boxes box-bg', __( 'Upload Background', 'maintenance' ), 'upload_background upload_btn button' );
    443 }
    444 add_action( 'maintenance_background_field', 'get_background_fileds_action', 10 );
    445 
    446 function get_color_fileds_action() {
    447     $mt_option = mt_get_plugin_options( true );
    448     get_color_field( __( 'Background color', 'maintenance' ), 'body_bg_color', 'body_bg_color', esc_attr( $mt_option['body_bg_color'] ), '#111111' );
    449     get_color_field( __( 'Font color', 'maintenance' ), 'font_color', 'font_color', esc_attr( $mt_option['font_color'] ), '#ffffff' );
    450     get_color_field( __( 'Login block background color', 'maintenance' ), 'controls_bg_color', 'controls_bg_color', isset( $mt_option['controls_bg_color'] ) ? esc_attr( $mt_option['controls_bg_color'] ) : '', '#000000' );
    451 }
    452 add_action( 'maintenance_color_fields', 'get_color_fileds_action', 10 );
    453 
    454 
    455 function get_font_fileds_action() {
    456     $mt_option = mt_get_plugin_options( true );
    457     echo get_fonts_field( __( 'Font family', 'maintenance' ), 'body_font_family', 'body_font_family', esc_attr( $mt_option['body_font_family'] ) );
     440    echo $out_filed; // phpcs:ignore WordPress.Security.EscapeOutput
     441}
     442
     443function mtnc_get_background_fileds_action() {
     444    $mt_option = mtnc_get_plugin_options( true );
     445    mtnc_generate_image_filed( __( 'Background image', 'maintenance' ), 'body_bg', 'body_bg', esc_attr( $mt_option['body_bg'] ), 'boxes box-bg', __( 'Upload Background', 'maintenance' ), 'upload_background upload_btn button' );
     446}
     447add_action( 'mtnc_background_field', 'mtnc_get_background_fileds_action', 10 );
     448
     449function mtnc_get_color_fileds_action() {
     450    $mt_option = mtnc_get_plugin_options( true );
     451    mtnc_get_color_field( __( 'Background color', 'maintenance' ), 'body_bg_color', 'body_bg_color', esc_attr( $mt_option['body_bg_color'] ), '#111111' );
     452    mtnc_get_color_field( __( 'Font color', 'maintenance' ), 'font_color', 'font_color', esc_attr( $mt_option['font_color'] ), '#ffffff' );
     453    mtnc_get_color_field( __( 'Login block background color', 'maintenance' ), 'controls_bg_color', 'controls_bg_color', isset( $mt_option['controls_bg_color'] ) ? esc_attr( $mt_option['controls_bg_color'] ) : '', '#000000' );
     454}
     455add_action( 'mtnc_color_fields', 'mtnc_get_color_fileds_action', 10 );
     456
     457
     458function mtnc_get_font_fileds_action() {
     459    $mt_option = mtnc_get_plugin_options( true );
     460    echo mtnc_get_fonts_field( __( 'Font family', 'maintenance' ), 'body_font_family', 'body_font_family', esc_attr( $mt_option['body_font_family'] ) ); // phpcs:ignore WordPress.Security.EscapeOutput
    458461    $subset = '';
    459462
     
    461464        $subset = $mt_option['body_font_subset'];
    462465    }
    463     echo get_fonts_subsets( __( 'Subsets', 'maintenance' ), 'body_font_subset', 'body_font_subset', esc_attr( $subset ) );
    464 }
    465 add_action( 'maintenance_font_fields', 'get_font_fileds_action', 10 );
    466 
    467 
    468 function maintenanace_contact_support() {
     466    echo mtnc_get_fonts_subsets( __( 'Subsets', 'maintenance' ), 'body_font_subset', 'body_font_subset', esc_attr( $subset ) ); // phpcs:ignore WordPress.Security.EscapeOutput
     467}
     468add_action( 'mtnc_font_fields', 'mtnc_get_font_fileds_action', 10 );
     469
     470
     471function mtnc_contact_support() {
    469472    $promo_text  = '';
    470473    $promo_text .= '<div class="sidebar-promo" id="sidebar-promo">';
     
    476479    ) . '</p>';
    477480    $promo_text .= '</div>';
    478     echo $promo_text;
    479 }
    480 
    481 function maintenanace_improve_translate() {
     481    echo $promo_text; // phpcs:ignore WordPress.Security.EscapeOutput
     482}
     483
     484function mtnc_improve_translate() {
    482485    $promo_text  = '';
    483486    $promo_text .= '<div class="sidebar-promo" id="sidebar-translate">';
     
    489492    ) . '</p>';
    490493    $promo_text .= '</div>';
    491     echo $promo_text;
    492 }
    493 
    494 function maintenanace_our_themes() {
     494    echo $promo_text; // phpcs:ignore WordPress.Security.EscapeOutput
     495}
     496
     497function mtnc_our_themes() {
    495498    $promo_text  = '';
    496499    $promo_text .= '<div class="sidebar-promo" id="sidebar-themes">';
     
    518521
    519522    $promo_text .= '</div>';
    520     echo $promo_text;
    521 }
    522 
    523 function maintenanace_extended_version() {
     523    echo $promo_text; // phpcs:ignore WordPress.Security.EscapeOutput
     524}
     525
     526function mtnc_extended_version() {
    524527    $promo_text  = '';
    525528    $promo_text .= '<div class="sidebar-promo worker" id="sidebar-promo">';
     
    536539    );
    537540    $promo_text .= '</div>';
    538     echo $promo_text;
    539 }
    540 
    541 function mt_cur_page_url() {
     541    echo $promo_text; // phpcs:ignore WordPress.Security.EscapeOutput
     542}
     543
     544function mtnc_cur_page_url() {
    542545    $page_url = 'http';
    543546    if ( isset( $_SERVER['HTTPS'] ) ) {
     
    552555}
    553556
    554 function mt_check_exclude() {
     557function mtnc_check_exclude() {
    555558    global $mt_options, $post;
    556     $mt_options = mt_get_plugin_options( true );
     559    $mt_options = mtnc_get_plugin_options( true );
    557560    $is_skip    = false;
    558     $cur_url     = mt_cur_page_url();
     561    $cur_url    = mtnc_cur_page_url();
    559562    if ( is_page() || is_single() ) {
    560         $curr_ID = $post->ID;
     563        $curr_id = $post->ID;
    561564    } else {
    562565        if ( is_home() ) {
    563566            $blog_id = get_option( 'page_for_posts' );
    564567            if ( $blog_id ) {
    565                 $curr_ID = $blog_id;
     568                $curr_id = $blog_id;
    566569            }
    567570        }
     
    570573            $front_page_id = get_option( 'show_on_front' );
    571574            if ( $front_page_id ) {
    572                 $curr_ID = $front_page_id;
     575                $curr_id = $front_page_id;
    573576            }
    574577        }
     
    579582        foreach ( $exlude_objs as $objs_id ) {
    580583            foreach ( $objs_id as $obj_id ) {
    581                 if ( $curr_ID === (int) $obj_id ) {
     584                if ( $curr_id === (int) $obj_id ) {
    582585                    $is_skip = true;
    583586                    break;
     
    591594
    592595
    593 function load_maintenance_page( $original_template ) {
     596function mtnc_load_maintenance_page( $original_template ) {
    594597    global $mt_options;
    595     $preview = ( isset( $_GET['preview'] ) && $_GET['preview'] === 1 );
     598    if ( is_preview() && ! wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . (int) $_GET['preview_id'] ) ) {
     599        return;
     600    }
     601    $preview = isset( $_GET['preview'] );
    596602
    597603    $v_curr_date_start = $v_curr_date_end = $v_curr_time = '';
    598     $vdate_start     = $vdate_end = date_i18n( 'Y-m-d', strtotime( current_time( 'mysql', 0 ) ) );
    599     $vtime_start     = date_i18n( 'h:i:s A', strtotime( '01:00:00 am' ) );
    600     $vtime_end       = date_i18n( 'h:i:s A', strtotime( '12:59:59 pm' ) );
     604    $vdate_start       = $vdate_end = date_i18n( 'Y-m-d', strtotime( current_time( 'mysql', 0 ) ) );
     605    $vtime_start       = date_i18n( 'h:i:s A', strtotime( '01:00:00 am' ) );
     606    $vtime_end         = date_i18n( 'h:i:s A', strtotime( '12:59:59 pm' ) );
    601607
    602608    if ( ! is_user_logged_in() ) {
     
    621627            $v_curr_date_end   = strtotime( $vdate_end . ' ' . $vtime_end );
    622628
    623             if ( mt_check_exclude() ) {
     629            if ( mtnc_check_exclude() ) {
    624630                return $original_template;
    625631            }
     
    634640        }
    635641
    636         if ( file_exists( MAINTENANCE_LOAD . 'index.php' ) ) {
    637             add_filter( 'script_loader_tag', 'maintenance_defer_scripts', 10, 2 );
    638             return MAINTENANCE_LOAD . 'index.php';
     642        if ( file_exists( MTNC_LOAD . 'index.php' ) ) {
     643            add_filter( 'script_loader_tag', 'mtnc_defer_scripts', 10, 2 );
     644            return MTNC_LOAD . 'index.php';
    639645        } else {
    640646            return $original_template;
    641647        }
    642     } elseif ( $preview && file_exists( MAINTENANCE_LOAD . 'index.php' ) ) {
    643         add_filter( 'script_loader_tag', 'maintenance_defer_scripts', 10, 2 );
    644         return MAINTENANCE_LOAD . 'index.php';
     648    } elseif ( $preview && file_exists( MTNC_LOAD . 'index.php' ) ) {
     649        add_filter( 'script_loader_tag', 'mtnc_defer_scripts', 10, 2 );
     650        return MTNC_LOAD . 'index.php';
    645651    } else {
    646652        return $original_template;
     
    648654}
    649655
    650 function maintenance_defer_scripts( $tag, $handle ) {
     656function mtnc_defer_scripts( $tag, $handle ) {
    651657    if ( strpos( $handle, '_ie' ) !== 0 ) {
    652658        return $tag;
     
    655661}
    656662
    657 function maintenance_metaboxes_scripts() {
    658     global $maintenance_variable;
     663function mtnc_metaboxes_scripts() {
     664    global $mtnc_variable;
    659665    ?>
    660666    <script type="text/javascript">
     
    662668        jQuery(document).ready( function() {
    663669            jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
    664             postboxes.add_postbox_toggles( '<?php echo esc_js( $maintenance_variable->options_page ); ?>' );
     670            postboxes.add_postbox_toggles( '<?php echo esc_js( $mtnc_variable->options_page ); ?>' );
    665671        });
    666672        //]]>
     
    669675}
    670676
    671 function maintenance_add_toolbar_items() {
     677function mtnc_add_toolbar_items() {
    672678    global $wp_admin_bar, $wpdb;
    673     $mt_options = mt_get_plugin_options( true );
     679    $mt_options = mtnc_get_plugin_options( true );
    674680    $check      = '';
    675681    if ( ! is_super_admin() || ! is_admin_bar_showing() ) {
     
    685691    $wp_admin_bar->add_menu(
    686692        array(
    687             'id'    => 'maintenance_options',
     693            'id'    => 'mtnc_options',
    688694            'title' => __( 'Maintenance', 'maintenance' ) . __( ' is ', 'maintenance' ) . $check,
    689695            'href'  => $url_to,
     
    702708
    703709
    704 function maintenance_hex2rgb( $hex ) {
     710function mtnc_hex2rgb( $hex ) {
    705711    $hex = str_replace( '#', '', $hex );
    706712
     
    719725
    720726
    721 function mt_insert_attach_sample_files() {
     727function mtnc_insert_attach_sample_files() {
    722728    global $wpdb;
    723729
     
    731737        require_once ABSPATH . 'wp-admin/includes/image.php';
    732738        $upload_dir   = wp_upload_dir();
    733         $image_url    = MAINTENANCE_URI . 'images/mt-sample-background.jpg';
     739        $image_url    = MTNC_URI . 'images/mt-sample-background.jpg';
    734740        $file_name    = basename( $image_url );
    735741        $file_content = wp_remote_get( $image_url );
     
    762768}
    763769
    764 function mt_get_default_array() {
     770function mtnc_get_default_array() {
    765771
    766772    $defaults = array(
     
    774780        'logo'              => '',
    775781        'retina_logo'       => '',
    776         'body_bg'           => mt_insert_attach_sample_files(),
     782        'body_bg'           => mtnc_insert_attach_sample_files(),
    777783        'bg_image_portrait' => '',
    778784        'preloader_img'     => '',
     
    790796        'exclude_pages'     => '',
    791797    );
    792     return apply_filters( 'mt_get_default_array', $defaults );
    793 }
    794 
    795 if ( ! function_exists( 'mt_get_google_fonts' ) ) {
    796     function mt_get_google_fonts() {
    797         $gg_fonts = wp_remote_get( MAINTENANCE_URI . 'includes/fonts/googlefonts.json' );
     798    return apply_filters( 'mtnc_get_default_array', $defaults );
     799}
     800
     801if ( ! function_exists( 'mtnc_get_google_fonts' ) ) {
     802    function mtnc_get_google_fonts() {
     803        $gg_fonts = wp_remote_get( MTNC_URI . 'includes/fonts/googlefonts.json' );
    798804        return $gg_fonts['body'];
    799805    }
Note: See TracChangeset for help on using the changeset viewer.