Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@benyanke
Last active April 11, 2018 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benyanke/ef1841240419e4227008457f94263274 to your computer and use it in GitHub Desktop.
Save benyanke/ef1841240419e4227008457f94263274 to your computer and use it in GitHub Desktop.
Patched file for corporatesource wp theme to properly use layouts. From corporatesource/inc/customizer/core/
<?php
/**
* Core functions.
*
* @package corporatesource
*/
if ( ! function_exists( 'corporatesource_get_option' ) ) :
/**
* Get theme option.
*
* @since 1.0.0
*
* @param string $key Option key.
* @return mixed Option value.
*/
function corporatesource_get_option( $key ) {
if ( empty( $key ) ) {
return;
}
$value = '';
$default = corporatesource_get_default_theme_options();
$default_value = null;
if ( is_array( $default ) && isset( $default[ $key ] ) ) {
$default_value = $default[ $key ];
}
// handle page_layout key specially, since it doesn't get handled properly with get_theme_mod()
if ($key == 'page_layout') {
$base_template = get_page_template_slug();
// If not set, return default val
if(is_null($base_template) || strlen($base_template) == 0) {
return $default_value;
}
$prefix = "custom-template/";
$postfix = ".php";
// If not a valid template (starting with $prefix and ending with $postfix, return default
if( substr($base_template, strlen($postfix) * -1) != $postfix || substr($base_template, 0, strlen($prefix)) != $prefix) {
return $default_value;
}
// If all tests pass so far, remove prefix and postfix to get the template name, and return it:
// Remove postfix, then prefix
$base_template = substr($base_template, 0, strlen($postfix) * -1);
$base_template = substr($base_template, strlen($prefix));
return $base_template;
}
if ( null !== $default_value ) {
$value = get_theme_mod( $key, $default_value );
}
else {
$value = get_theme_mod( $key );
}
return $value;
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment