Something was wrong with the naming, I had to change the field names, and it works ok.
From your code sample, this:
add_settings_field(
'frontend-font', // id attribute of tag
__('بارگذاری فونت برای بخش اصلی سایت', 'persianfont'), // Title as lable for field
function(){
var_dump(get_option( 'persianfont' ));
//$check_frontend_font = is_null(get_option( 'persianfont' )['frontend-font']) ? 'true' : get_option( 'persianfont' )['frontend-font'];
?>
<input type="checkbox" name="frontend-font" id="frontend-font" value="true" <?php //checked( 'true', $check_frontend_font ); ?> />
<?php
}, // Callback function to echo input tag
$this->plugin_slug, // plugin slug, created by add_options_page()
'load-font-setting', // slug-name of the section
[
'label_for' => 'frontend-font', // label for => tag id
'class' => 'frontend-font', // class for <tr>
]
);
should be modified to:
add_settings_field(
'frontend-font', // id attribute of tag
__( 'بارگذاری فونت برای بخش اصلی سایت', 'persianfont' ), // Title as lable for field
function ($args) {
//$check_frontend_font = is_null(get_option( 'persianfont' )['frontend-font']) ? 'true' : get_option( 'persianfont' )['frontend-font'];
$persian_font = get_option('persianfont');
$frontend = !empty( $persian_font ['frontend'] ) ? $persian_font['frontend'] : false;
?>
<input type="checkbox" name="persianfont[frontend]" id="frontend-font"
value="true" <?php checked( 'true', $frontend );
?> />
<?php
}, // Callback function to echo input tag
$this->plugin_slug, // plugin slug, created by add_options_page()
'load-font-setting', // slug-name of the section
[
'label_for' => 'frontend-font', // label for => tag id
'class' => 'frontend-font', // class for <tr>
]
);
And the other one:
add_settings_field(
'backend-font', // id attribute of tag
__( 'بارگذاری فونت برای بخش مدیریت', 'persianfont' ), // Title as lable for field
function ($args) {
$persian_font = get_option('persianfont');
$backend = !empty( $persian_font ['backend'] ) ? $persian_font['backend'] : false;
//$check_backend_font = is_null(get_option( 'persianfont' )['backend-font']) ? 'true' : get_option( 'persianfont' )['backend-font'];
?>
<input type="checkbox" name="persianfont[backend]" id="backend-font"
value="true" <?php checked( 'true', $backend );
?> />
<?php
}, // Callback function to echo input tag
$this->plugin_slug, // plugin slug, created by add_options_page()
'load-font-setting', // slug-name of the section
[
'label_for' => 'backend-font', // label for => tag id
'class' => 'backend-font', // class for <tr>
]
);
I’ve made changes to callback function only.