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

Conditional update_option()'s #45

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions includes/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,8 @@ function define_customizer_fields( $wp_customize ) {
/**
* Disable comments and trackbacks/pingbacks on this site.
**/
update_option( 'default_ping_status', 'off' );
update_option( 'default_comment_status', 'off' );
force_option_value( 'default_ping_status', 'off' );
force_option_value( 'default_comment_status', 'off' );


/**
Expand Down
4 changes: 2 additions & 2 deletions includes/meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,5 @@ function colleges_post_list_js_deps( $deps ) {

add_filter( 'ucf_post_list_js_deps', 'colleges_post_list_js_deps', 10, 1 );

update_option( 'ucf_post_list_include_js_libs', false );
update_option( 'ucf_degree_search_include_typeahead', false );
force_option_value( 'ucf_post_list_include_js_libs', false );
force_option_value( 'ucf_degree_search_include_typeahead', false );
12 changes: 11 additions & 1 deletion includes/utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ function get_theme_mod_or_default( $theme_mod ) {
}



/**
* Utility function that returns an image url by its thumbnail size.
**/
Expand All @@ -58,3 +57,14 @@ function get_attachment_src_by_size( $id, $size ) {
}
return $attachment;
}


/**
* Checks if a given option is set to the provided value, and updates it
* if it is not
*/
function force_option_value( $option, $value ) {
if ( get_option( $option ) !== $value ) {
update_option( $option, $value );
}
}