'bodhi_sanitize_fields'
);
register_setting( 'bodhi_svgs_settings_group', 'bodhi_svgs_settings', $args );
}
add_action( 'admin_init', 'bodhi_svgs_register_settings' );
/**
* Advanced Mode Check
*
* Creates a usable function for conditionals around the plugin
*/
function bodhi_svgs_advanced_mode() {
global $bodhi_svgs_options;
if ( ! empty( $bodhi_svgs_options['advanced_mode'] ) ) {
return true;
} else {
return false;
}
}
add_action( 'admin_init', 'bodhi_svgs_advanced_mode' );
/**
* Screen check function
* Checks if current page is SVG Support settings page
*/
function bodhi_svgs_specific_pages_settings() {
// check current page
$screen = get_current_screen();
// check if we're on SVG Support settings page
if ( is_object( $screen ) && $screen->id == 'settings_page_svg-support' ) {
return true;
} else {
return false;
}
}
/**
* Screen check function
* Checks if the current page is the Media Library page
*/
function bodhi_svgs_specific_pages_media_library() {
// check current page
$screen = get_current_screen();
// check if we're on Media Library page
if ( is_object( $screen ) && $screen->id == 'upload' ) {
return true;
} else {
return false;
}
}
/**
* Screen check function
* Check if the current page is a post edit page
*/
function bodhi_svgs_is_edit_page( $new_edit = null ) {
global $pagenow;
if ( ! is_admin() ) return false;
if ( $new_edit == 'edit' ) {
return in_array( $pagenow, array( 'post.php', ) );
} elseif ( $new_edit == "new" ) { //check for new post page
return in_array( $pagenow, array( 'post-new.php' ) );
} else { //check for either new or edit
return in_array( $pagenow, array( 'post.php', 'post-new.php' ) );
}
}
/**
* Add rating text to footer on settings page
*/
function bodhi_svgs_admin_footer_text( $default ) {
if ( bodhi_svgs_specific_pages_settings() || bodhi_svgs_specific_pages_media_library() ) {
printf( __( 'If you like SVG Support please leave a %s★★★★★%s rating. A huge thanks in advance!', 'svg-support' ), '', '' );
} else {
return $default;
}
}
add_filter( 'admin_footer_text', 'bodhi_svgs_admin_footer_text' );