Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ML#123 - Ability To Set Global Custom Name #126

Conversation

kodinkat
Copy link
Collaborator


add_filter( 'dt_magic_link_global_name', 'dt_magic_link_global_name', 10, 1 );
function dt_magic_link_global_name( $global_name ) {
if ( Disciple_Tools_Bulk_Magic_Link_Sender_API::option_exists( Disciple_Tools_Bulk_Magic_Link_Sender_API::$option_dt_magic_links_global_name_enabled ) && boolval( Disciple_Tools_Bulk_Magic_Link_Sender_API::fetch_option( Disciple_Tools_Bulk_Magic_Link_Sender_API::$option_dt_magic_links_global_name_enabled ) ) === true ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kodinkat this section will require 4 database calls. 2 is enough.
just use boolval and get_option( Disciple_Tools_Bulk_Magic_Link_Sender_API::$option_dt_magic_links_global_name_enabled, $default )
and then get_option again with a default set to ''

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace Disciple_Tools_Bulk_Magic_Link_Sender_API::fetch_option() with the wp function. the wrapper seems unnecessary

} else {
$global_name_enabled_checked_html = boolval( Disciple_Tools_Bulk_Magic_Link_Sender_API::fetch_option( Disciple_Tools_Bulk_Magic_Link_Sender_API::$option_dt_magic_links_global_name_enabled ) ) ? 'checked' : '';
}
$global_name_value = Disciple_Tools_Bulk_Magic_Link_Sender_API::option_exists( Disciple_Tools_Bulk_Magic_Link_Sender_API::$option_dt_magic_links_global_name ) ? Disciple_Tools_Bulk_Magic_Link_Sender_API::fetch_option( Disciple_Tools_Bulk_Magic_Link_Sender_API::$option_dt_magic_links_global_name ) : '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be simplified to get_option( $key, '')
with the default being ''

@corsacca corsacca merged commit 537df57 into DiscipleTools:master Nov 9, 2023
2 checks passed
@corsacca
Copy link
Member

corsacca commented Nov 9, 2023

Thanks @kodinkat !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to set custom name instead of "Magic link"
2 participants