Created
September 30, 2016 20:32
-
-
Save ginsterbusch/b4d84eb6256cd9373210efcca2764cdf to your computer and use it in GitHub Desktop.
Load configuration file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_config_file( $custom_path = null ) { | |
$return = false; | |
if( empty( $custom_path ) && function_exists( 'wp_upload_dir' ) ) { | |
$upload_dir = wp_upload_dir(); | |
$config_path = trailingslashit( $upload_dir['basedir'] ) . 'control-wp-core-emails.php'; | |
} else { | |
$config_path = $custom_path; | |
} | |
// variation #1: use a php file with an array | |
if( !empty( $config_path ) && file_exists( $config_path ) != false ) { | |
include( $config_path ); | |
if( !empty( $config ) && is_array( $config ) != false ) { | |
$return = wp_parse_args( $config, $this->get_default_config() ); | |
} | |
} | |
return $return; | |
} | |
function get_default_config() { | |
return array( | |
'send_emails' => array( | |
'success' => false, | |
'manual' => false, | |
'failure' => false, | |
'critical' => false, | |
), | |
'enable_admin' => true, | |
); | |
} | |
function load_config_file( $custom_path = null ) { | |
$loaded_config = $this->get_config_file( $custom_path ); | |
if( !empty( $loaded_config ) ) { | |
$this->config = $loaded_config; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment