Created
May 9, 2016 17:16
-
-
Save stevenwaskey/59437dcbbabbbf266b140d8acd39ac9d to your computer and use it in GitHub Desktop.
functions.php
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 | |
/*-----------------------------------------------------------------------------------*/ | |
/* Directory | |
/*-----------------------------------------------------------------------------------*/ | |
if ( get_stylesheet_directory() == get_template_directory() ) { | |
define('OF_FILEPATH', get_template_directory()); | |
define('OF_DIRECTORY', get_template_directory_uri()); | |
} else { | |
define('OF_FILEPATH', get_stylesheet_directory()); | |
define('OF_DIRECTORY', get_stylesheet_directory_uri()); | |
} | |
define('MADZA_FILEPATH', get_template_directory()); | |
define('MADZA_DIRECTORY', get_template_directory_uri()); | |
/*-----------------------------------------------------------------------------------*/ | |
/* Page Builder | |
/*-----------------------------------------------------------------------------------*/ | |
if($_SERVER['REMOTE_ADDR']=='188.24.59.99') { //163 | |
$dir = dirname(__FILE__) . '/wpbakery/'; | |
$composer_settings = Array( | |
'APP_ROOT' => $dir . '/js_composer_NEW', | |
'WP_ROOT' => dirname( dirname( dirname( dirname($dir ) ) ) ). '/', | |
'APP_DIR' => basename( $dir ) . '/js_composer_NEW/', | |
'CONFIG' => $dir . '/js_composer_NEW/config/', | |
'ASSETS_DIR' => 'assets/', | |
'COMPOSER' => $dir . '/js_composer_NEW/composer/', | |
'COMPOSER_LIB' => $dir . '/js_composer_NEW/composer/lib/', | |
'SHORTCODES_LIB' => $dir . '/js_composer_NEW/composer/lib/shortcodes/', | |
'default_post_types' => Array('page', 'portfolio') /* Default post type where to activate visual composer meta box settings */ | |
); | |
require_once locate_template('/wpbakery/js_composer_NEW/js_composer.php'); | |
$wpVC_setup->init($composer_settings); | |
} else { | |
$dir = dirname(__FILE__) . '/wpbakery/'; | |
$composer_settings = Array( | |
'APP_ROOT' => $dir . '/js_composer', | |
'WP_ROOT' => dirname( dirname( dirname( dirname($dir ) ) ) ). '/', | |
'APP_DIR' => basename( $dir ) . '/js_composer/', | |
'CONFIG' => $dir . '/js_composer/config/', | |
'ASSETS_DIR' => 'assets/', | |
'COMPOSER' => $dir . '/js_composer/composer/', | |
'COMPOSER_LIB' => $dir . '/js_composer/composer/lib/', | |
'SHORTCODES_LIB' => $dir . '/js_composer/composer/lib/shortcodes/', | |
'default_post_types' => Array('page', 'portfolio') /* Default post type where to activate visual composer meta box settings */ | |
); | |
require_once locate_template('/wpbakery/js_composer/js_composer.php'); | |
$wpVC_setup->init($composer_settings); | |
} | |
/** | |
* Optional: set 'ot_show_pages' filter to false. | |
* This will hide the settings & documentation pages. | |
*/ | |
add_filter( 'ot_show_pages', '__return_false' ); | |
/** | |
* Optional: set 'ot_show_new_layout' filter to false. | |
* This will hide the "New Layout" section on the Theme Options page. | |
*/ | |
add_filter( 'ot_show_new_layout', '__return_false' ); | |
/** | |
* Required: set 'ot_theme_mode' filter to true. | |
*/ | |
add_filter( 'ot_theme_mode', '__return_true' ); | |
/** | |
* Required: include OptionTree. | |
*/ | |
include_once( 'option-tree/ot-loader.php' ); | |
include_once( 'option-tree/theme-options.php' ); | |
/*-----------------------------------------------------------------------------------*/ | |
/* Function | |
/*-----------------------------------------------------------------------------------*/ | |
require_once (OF_FILEPATH . '/functions/class-widget.php'); | |
require_once (OF_FILEPATH . '/functions/class-metabox.php'); | |
require_once (OF_FILEPATH . '/functions/functions-widget.php'); | |
require_once (OF_FILEPATH . '/functions/functions-footer.php'); | |
require_once (OF_FILEPATH . '/functions/functions-homepage.php'); | |
require_once (OF_FILEPATH . '/functions/functions-slider.php'); | |
require_once (OF_FILEPATH . '/functions/functions-hooks.php'); | |
require_once (OF_FILEPATH . '/functions/functions-comment.php'); | |
require_once (OF_FILEPATH . '/functions/functions-shortcodes.php'); | |
require_once (OF_FILEPATH . '/functions/functions-general.php'); | |
require_once (OF_FILEPATH . '/functions/plugins/aq_resizer.php'); | |
/*-----------------------------------------------------------------------------------*/ | |
/* Madza Theme Setup | |
/*-----------------------------------------------------------------------------------*/ | |
add_action( 'after_setup_theme', 'madza_theme_setup' ); | |
if ( ! function_exists( 'madza_theme_setup' ) ){ | |
function madza_theme_setup() { | |
add_editor_style(); | |
add_theme_support( 'post-formats', array('image', 'video', 'link', 'quote', 'gallery' ) ); | |
add_theme_support( 'automatic-feed-links' ); | |
load_theme_textdomain( 'madza_translate', get_template_directory() . '/languages' ); | |
$locale = get_locale(); | |
$locale_file = get_template_directory() . "/languages/$locale.php"; | |
if ( is_readable( $locale_file ) ) | |
require_once( $locale_file ); | |
set_post_thumbnail_size( 999, 999, true ); | |
register_nav_menus( array( | |
'header_menu' => __( 'Header Navigation', 'madza_translate' ), | |
) ); | |
register_nav_menus( array( | |
'select_menu' => __( 'Responsive Header Navigation', 'madza_translate' ), | |
) ); | |
register_nav_menus( array( | |
'footer_menu' => __( 'Footer Navigation', 'madza_translate' ), | |
) ); | |
} | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Default Options | |
/*-----------------------------------------------------------------------------------*/ | |
if ( ! isset( $content_width ) ) $content_width = 610; | |
function madzathemes_page_menu_args( $args ) { | |
$args['show_home'] = true; | |
return $args; | |
} | |
add_filter( 'wp_page_menu_args', 'madzathemes_page_menu_args' ); | |
function new_excerpt_length( $length ) { | |
return 1000; | |
} | |
add_filter( 'excerpt_length', 'new_excerpt_length' ); | |
function get_required_page($page = ''){ | |
global $wpdb; | |
$result = wp_cache_get($page . '-guid', __FUNCTION__); | |
if($result === false) | |
{ | |
$result = $wpdb->get_var("SELECT p.guid | |
FROM $wpdb->posts p | |
WHERE p.post_status = 'publish' | |
AND p.post_title = '{$page}' "); | |
if ($result) | |
{ | |
wp_cache_add($page . '-guid', $result, __FUNCTION__); | |
} | |
} | |
return $result; | |
} | |
if (function_exists('add_theme_support')) { | |
add_theme_support( 'post-thumbnails' ); | |
} | |
/*-----------------------------------------------------------------------------------*/ | |
/* Theme Options | |
/*-----------------------------------------------------------------------------------*/ | |
function my_custom_login_logo() { | |
if(ot_get_option("login_logo")!="") { | |
echo '<style type="text/css"> | |
h1 a { '.ot_get_option("login_logo").' !important; } | |
</style>'; | |
} | |
} | |
add_action('login_head', 'my_custom_login_logo'); | |
function madza_sidebar_function() { | |
global $post; | |
$args = array( | |
'post_type'=> 'mt_sidebar', | |
'order' => 'ASC', | |
'posts_per_page' => 999, | |
'orderby' => 'date', | |
'order' => 'DSC', | |
); | |
query_posts($args); while ( have_posts() ) : the_post(); | |
register_sidebar(array( | |
'name' => __(get_the_title()), | |
'id' => 'sidebar-id-'.$post->ID.'', | |
'description' => __( 'Widget area created from Sidebar custom post type.' , 'madza_translate'), | |
'before_widget' => '<div class="menu_categories">', | |
'after_widget' => '<div class="clear"></div></div>', | |
'before_title' => '<h4 class="widget_h"><span>', | |
'after_title' => '</span></h4>', | |
)); | |
endwhile; wp_reset_query(); | |
} | |
add_action('madza_sidebar_function', 'madza_sidebar_function'); | |
madza_sidebar_function(); | |
add_action('admin_init','optionscheck_change_santiziation', 100); | |
function optionscheck_change_santiziation() { | |
remove_filter( 'of_sanitize_textarea', 'of_sanitize_textarea' ); | |
add_filter( 'of_sanitize_textarea', 'custom_sanitize_textarea' ); | |
} | |
function custom_sanitize_textarea($input) { | |
global $allowedposttags; | |
$custom_allowedtags["embed"] = array( | |
"src" => array(), | |
"type" => array(), | |
"allowfullscreen" => array(), | |
"allowscriptaccess" => array(), | |
"height" => array(), | |
"width" => array() | |
); | |
$custom_allowedtags["script"] = array(); | |
$custom_allowedtags = array_merge($custom_allowedtags, $allowedposttags); | |
$output = wp_kses( $input, $custom_allowedtags); | |
return $output; | |
} | |
add_action( 'tgmpa_register', 'madza_register_required_plugins' ); | |
function madza_register_required_plugins() { | |
$plugins = array( | |
array( | |
'name' => 'Contact Form 7', // The plugin name | |
'slug' => 'contact-form-7', // The plugin slug (typically the folder name) | |
'required' => true, // If false, the plugin is only 'recommended' instead of required | |
), | |
); | |
$config = array( | |
'strings' => array( | |
) | |
); | |
tgmpa( $plugins, $config ); | |
} | |
add_filter('widget_text', 'do_shortcode'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment