File: /home/retoti4c1e1s/public_html/thecommitment.earth/wp-content/themes/ananke/functions.php
<?php
/**
* Redux Theme functions and definitions.
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package Ananke
*/
if ( ! class_exists( 'ReduxFramewrk' ) ) {
require_once( get_template_directory() . '/framework/sample-config.php' );
function ananke_removeDemoModeLink() { // Be sure to rename this function to something more unique
if ( class_exists('ReduxFrameworkPlugin') ) {
remove_filter( 'plugin_row_meta', array( ReduxFrameworkPlugin::get_instance(), 'plugin_metalinks'), null, 2 );
}
if ( class_exists('ReduxFrameworkPlugin') ) {
remove_action('admin_notices', array( ReduxFrameworkPlugin::get_instance(), 'admin_notices' ) );
}
}
add_action('init', 'ananke_removeDemoModeLink');
}
/*Theme Set up:*/
function ananke_theme_setup() {
if ( ! isset( $content_width ) ) {
$content_width = 900;
}
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on cubic, use a find and replace
* to change 'cubic' to the name of your theme in all the template files
*/
load_theme_textdomain( 'ananke', get_template_directory() . '/languages' );
/*
* This theme uses a custom image size for featured images, displayed on
* "standard" posts and pages.
*/
add_theme_support( 'custom-header' );
add_theme_support( 'custom-background' );
add_theme_support( 'title-tag' );
add_theme_support( 'post-thumbnails' );
// Adds RSS feed links to <head> for posts and comments.
add_theme_support( 'automatic-feed-links' );
// Switches default core markup for search form, comment form, and comments
// to output valid HTML5.
add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list' ) );
//Post formats
add_theme_support( 'post-formats', array(
'audio', 'gallery', 'image', 'quote', 'video'
) );
/*This theme uses wp_nav_menu() in one location.*/
register_nav_menus( array(
'primary' => __('Menu Home <b>Only Use For Home Page</b>', 'ananke'),
'secondary' => __('Menu Pages <b>Only Use For All Other Pages</b>', 'ananke'),
) );
}
add_action( 'after_setup_theme', 'ananke_theme_setup' );
if ( ! function_exists( 'ananke_fonts_url' ) ) :
/**
* Register Google fonts for Ananke.
*
* Create your own ananke_fonts_url() function to override in a child theme.
*
* @since Ananke 3.4.0
*
* @return string Google fonts URL for the theme.
*/
function ananke_fonts_url() {
$fonts_url = '';
$fonts = array();
$subsets = 'latin,cyrillic-ext,greek-ext,greek,vietnamese,latin-ext,cyrillic';
/* translators: If there are characters in your language that are not supported by Lato, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Lato font: on or off', 'ananke' ) ) {
$fonts[] = 'Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic';
}
/* translators: If there are characters in your language that are not supported by Montserrat, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Montserrat font: on or off', 'ananke' ) ) {
$fonts[] = 'Montserrat:400,700';
}
/* translators: If there are characters in your language that are not supported by Open Sans, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Open Sans font: on or off', 'ananke' ) ) {
$fonts[] = 'Open Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800';
}
/* translators: If there are characters in your language that are not supported by Satisfy, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Satisfy font: on or off', 'ananke' ) ) {
$fonts[] = 'Satisfy';
}
if ( $fonts ) {
$fonts_url = add_query_arg( array(
'family' => urlencode( implode( '|', $fonts ) ),
'subset' => urlencode( $subsets ),
), 'https://fonts.googleapis.com/css' );
}
return $fonts_url;
}
endif;
function ananke_theme_scripts_styles() {
global $theme_option;
$protocol = is_ssl() ? 'https' : 'http';
$gmapaipkey = $theme_option['gmap_apikey'];
/*Add custom fonts, used in the main stylesheet.*/
wp_enqueue_style( 'ananke-fonts', ananke_fonts_url(), array(), null );
wp_enqueue_style( 'ananke-base', get_template_directory_uri().'/css/base.css');
if (isset($theme_option['theme_layout']) and $theme_option['theme_layout'] == 'layout1320') {
wp_enqueue_style( 'ananke-skeleton', get_template_directory_uri().'/css/skeleton-1320.css');
}elseif (isset($theme_option['theme_layout']) and $theme_option['theme_layout'] == 'layout1200') {
wp_enqueue_style( 'ananke-skeleton', get_template_directory_uri().'/css/skeleton-1200.css');
}else{
wp_enqueue_style( 'ananke-skeleton', get_template_directory_uri().'/css/skeleton-960.css');
}
wp_enqueue_style( 'ananke-style', get_stylesheet_uri(), array(), '2017-03-08' );
wp_enqueue_style( 'ananke-font-awesome', get_template_directory_uri().'/css/css/font-awesome.min.css');
wp_enqueue_style( 'ananke-flat', get_template_directory_uri().'/css/flat_filled_styles.css');
wp_enqueue_style( 'ananke-fancybox', get_template_directory_uri().'/css/jquery.fancybox.css');
/*Style Dark color for Skill Dark*/
if (isset($theme_option['theme_style']) and $theme_option['theme_style'] != 'light') {
wp_enqueue_style( 'dark-color', get_template_directory_uri().'/css/dark.css');
}
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ){
wp_enqueue_script( 'comment-reply' );
}
wp_enqueue_script("ananke-modernizr", get_template_directory_uri()."/js/modernizr.custom.js",array( 'jquery' ), '20160621', false);
if ( $theme_option['show_pre'] != 'no' ) {
wp_enqueue_script("preloader", get_template_directory_uri()."/js/royal_preloader.min.js",array( 'jquery' ), '20160621', false);
}
if ($gmapaipkey != '') {
wp_enqueue_script("ananke-mapapi", "$protocol://maps.googleapis.com/maps/api/js?key=$gmapaipkey",array( 'jquery' ), '20160621', false);
}
if(is_page_template('page-templates/template-canvas.php') ){
wp_enqueue_script("ananke-tiltSlider", get_template_directory_uri()."/js/tiltSlider.js",array( 'jquery' ), '20160621', false);
}
if($theme_option['animate-switch'] == true){
wp_enqueue_script("ananke-scrollReveal", get_template_directory_uri()."/js/scrollReveal.js",array( 'jquery' ), '20160621', true);
}
wp_enqueue_script("ananke-plugins", get_template_directory_uri()."/js/plugins.js",array( 'jquery' ), '20160621', true);
wp_enqueue_script("ananke-template", get_template_directory_uri()."/js/template.js",array( 'jquery' ), '20160621', true);
}
add_action( 'wp_enqueue_scripts', 'ananke_theme_scripts_styles');
/*Add a class from the body_class array.*/
function ananke_body_classes( $classes ) {
global $theme_option;
if( $theme_option['show_pre'] != 'no' ) {
$classes[] = 'royal_preloader';
}
return $classes;
}
add_filter( 'body_class','ananke_body_classes' );
function ananke_preload_body_open_script() {
global $theme_option;
$method = '';
if ( $theme_option['type_preload'] == 'preload_logo' ) {
$method = 'logo';
} else {
$method = 'text';
}
if ( $theme_option['show_pre'] != 'no' ) {
echo '<div id="royal_preloader" data-method="'.esc_attr($method).'" data-width="'.esc_attr($theme_option['prelogo_width']).'" data-height="'.esc_attr($theme_option['prelogo_height']).'" data-url="'.esc_url($theme_option['logo_preload']['url']).'" data-color="'.esc_attr($theme_option['preload_text_color']).'" data-bgcolor="'.esc_attr($theme_option['bgpreload']).'" data-pretext="'.esc_attr($theme_option['preloadtext']).'"></div>';
}
}
add_action( 'wp_body_open', 'ananke_preload_body_open_script' );
/*Widget Sidebar*/
function ananke_widgets_init() {
register_sidebar( array(
'name' => __( 'Primary Sidebar', 'ananke' ),
'id' => 'sidebar-1',
'description' => __( 'Appears in the sidebar section of the site.', 'ananke' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h6>',
'after_title' => '</h6>'
) );
register_sidebar( array(
'name' => __( 'Footer One Widget Area', 'ananke' ),
'id' => 'footer-area-1',
'description' => __( 'Footer Widget that appears on the Footer.', 'ananke' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h6>',
'after_title' => '</h6>',
) );
register_sidebar( array(
'name' => __( 'Footer Two Widget Area', 'ananke' ),
'id' => 'footer-area-2',
'description' => __( 'Footer Widget that appears on the Footer.', 'ananke' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h6>',
'after_title' => '</h6>',
) );
register_sidebar( array(
'name' => __( 'Footer Three Widget Area', 'ananke' ),
'id' => 'footer-area-3',
'description' => __( 'Footer Widget that appears on the Footer.', 'ananke' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h6>',
'after_title' => '</h6>',
) );
register_sidebar( array(
'name' => __( 'Footer Fourth Widget Area', 'ananke' ),
'id' => 'footer-area-4',
'description' => __( 'Footer Widget that appears on the Footer.', 'ananke' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h6>',
'after_title' => '</h6>',
) );
}
add_action( 'widgets_init', 'ananke_widgets_init' );
/*function tag widgets*/
function ananke_tag_cloud_widget($args) {
$args['number'] = 0; //adding a 0 will display all tags
$args['largest'] = 18; //largest tag
$args['smallest'] = 11; //smallest tag
$args['unit'] = 'px'; //tag font unit
$args['format'] = 'list'; //ul with a class of wp-tag-cloud
$args['exclude'] = ''; //exclude tags by ID
return $args;
}
add_filter( 'widget_tag_cloud_args', 'ananke_tag_cloud_widget' );
/*Excerpt Section Blog Post*/
function ananke_blog_excerpt($limit) {
$excerpt = explode(' ', get_the_excerpt(), $limit);
if (count($excerpt)>=$limit) {
array_pop($excerpt);
$excerpt = implode(" ",$excerpt).'...';
} else {
$excerpt = implode(" ",$excerpt);
}
$excerpt = preg_replace('`[[^]]*]`','',$excerpt);
return $excerpt;
}
/*pagination*/
function ananke_pagination($prev = '<i class="fa fa-chevron-left"></i>', $next = '<i class="fa fa-chevron-right"></i>', $pages='') {
global $wp_query, $wp_rewrite;
$wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
if($pages==''){
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}
$pagination = array(
'base' => str_replace( 999999999, '%#%', get_pagenum_link( 999999999 ) ),
'format' => '',
'current' => max( 1, get_query_var('paged') ),
'total' => $pages,
'prev_text' => $prev,
'next_text' => $next,
'type' => 'list',
'end_size' => 3,
'mid_size' => 3
);
$return = paginate_links( $pagination );
echo str_replace( "<ul class='page-numbers'>", '<ul>', $return );
}
function ananke_search_form( $form ) {
$form = '<form role="search" method="get" id="searchform" class="search_form" action="' . home_url( '/' ) . '" >
<input type="text" value="' . get_search_query() . '" name="s" id="s" placeholder="'. __( 'Search the site...', 'ananke' ) .'" />
<input type="submit" class="search_btn" id="searchsubmit" value="'. __( 'Search', 'ananke' ) .'" />
</form>';
return $form;
}
add_filter( 'get_search_form', 'ananke_search_form' );
/*Custom comment List:*/
function ananke_theme_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<div class="post-down">
<div class="rpl-but"><?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?></div>
<?php echo get_avatar($comment,$size='100',$default='http://0.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=70' ); ?>
<h6><?php printf( '%s', get_comment_author_link()) ?> <span>on <?php $d = "F j, Y \A\T h a"; printf(get_comment_date($d)) ?></span></h6>
<?php if ($comment->comment_approved == '0'){ ?>
<p><em><?php esc_html_e('Your comment is awaiting moderation.','ananke') ?></em></p>
<?php }else{ ?>
<?php comment_text() ?>
<?php } ?>
<div class="clearfix"></div>
</div>
<?php
}
/*Code Visual Compurso.*/
function custom_css_classes_for_vc_row_and_vc_column($class_string, $tag) {
if($tag=='vc_row' || $tag=='vc_row_inner') {
$class_string = str_replace('vc_row-fluid', '', $class_string);
}
if($tag=='vc_column' || $tag=='vc_column_inner') {
$class_string = preg_replace('/vc_col-sm-1/', 'one columns', $class_string);
$class_string = preg_replace('/vc_col-sm-2/', 'two columns', $class_string);
$class_string = preg_replace('/vc_col-sm-3/', 'three columns', $class_string);
$class_string = preg_replace('/vc_col-sm-4/', 'four columns', $class_string);
$class_string = preg_replace('/vc_col-sm-5/', 'five columns ', $class_string);
$class_string = preg_replace('/vc_col-sm-6/', 'six columns', $class_string);
$class_string = preg_replace('/vc_col-sm-7/', 'seven columns', $class_string);
$class_string = preg_replace('/vc_col-sm-8/', 'eight columns', $class_string);
$class_string = preg_replace('/vc_col-sm-9/', 'nine columns', $class_string);
$class_string = preg_replace('/vc_col-sm-10/', 'ten columns', $class_string);
$class_string = preg_replace('/vc_col-sm-11/', 'eleven columns', $class_string);
$class_string = preg_replace('/vc_col-sm-12/', 'twelve columns', $class_string);
}
return $class_string;
}
/*Filter to Replace default css class for vc_row shortcode and vc_column*/
add_filter('vc_shortcodes_css_class', 'custom_css_classes_for_vc_row_and_vc_column', 10, 2);
/*Add new Param in Row*/
if(function_exists('vc_add_param')){
vc_add_param('vc_row',array(
"type" => "textfield",
"heading" => __('Extra id name', 'ananke'),
"param_name" => "extra_id",
"value" => "",
"description" => __("If you wish to style particular content element differently, then use this field to add a id name and then refer to it in your css file.", 'ananke'),
));
vc_add_param('vc_row',array(
"type" => "textfield",
"heading" => __('Section Title', 'ananke'),
"param_name" => "ses_title",
"value" => "",
"description" => __("Title of Section, Leave a blank do not show front-end.", 'ananke'),
));
vc_add_param('vc_row',array(
"type" => "textarea",
"heading" => __('Section Sub Title', 'ananke'),
"param_name" => "ses_sub_title",
"value" => "",
"description" => __("Sub Title of Section, Leave a blank do not show front-end.", 'ananke'),
));
vc_add_param('vc_row',array(
"type" => "dropdown",
"heading" => __('Overlay Pattern', 'ananke'),
"param_name" => "wrap_class",
"value" => array(
__('No', 'ananke') => 'no',
__('Yes', 'ananke') => 'yes',
),
"description" => __("Container Class", 'ananke'),
));
vc_add_param('vc_row',array(
"type" => "dropdown",
"heading" => __('Fullwidth', 'ananke'),
"param_name" => "fullwidth",
"value" => array(
__('No', 'ananke') => 'no',
__('Yes', 'ananke') => 'yes',
),
"description" => __("Select Fullwidth or not, Default: No fullwidth", 'ananke'),
)
);
/*Add new Param in Column*/
vc_add_param('vc_column',array(
"type" => "textfield",
"heading" => __('Column Title', 'ananke'),
"param_name" => "title",
"value" => "",
"description" => __("Title of column", 'ananke'),
)
);
vc_add_param('vc_column',array(
"type" => "textfield",
"heading" => __('Container Class', 'ananke'),
"param_name" => "wap_class",
"value" => "",
"description" => __("Container Class", 'ananke'),
)
);
vc_add_param('vc_column',array(
"type" => "textfield",
"heading" => __('Container id', 'ananke'),
"param_name" => "wap_id",
"value" => "",
"description" => __("Container ID, Only use for content slider.", 'ananke'),
)
);
vc_add_param('vc_column',array(
"type" => "dropdown",
"heading" => __('Column Effect', 'ananke'),
"param_name" => "column_effect",
"value" => array(
__('None', 'ananke') => 'none',
__('Bottom Move', 'ananke') => 'bottommove',
__('Top Move', 'ananke') => 'topmove',
),
"description" => __("Select Effect for column, Default: Move Bottom", 'ananke'),
)
);
/*Remove some param in Row*/
vc_remove_param( "vc_row", "el_id" );
vc_remove_param( "vc_row", "full_width" );
/*Remove some param in Column*/
vc_remove_param( "vc_column", "css_animation" );
vc_remove_param( "vc_column", "el_id" );
}
require_once get_template_directory() . '/framework/class-tgm-plugin-activation.php';
add_action( 'tgmpa_register', 'ananke_register_required_plugins' );
function ananke_register_required_plugins() {
$plugins = array(
/*This is an example of how to include a plugin from the WordPress Plugin Repository.*/
array(
'name' => esc_html__( 'Meta Box', 'ananke' ),
'slug' => 'meta-box',
'required' => true,
),
array(
'name' => esc_html__( 'Redux Framework', 'ananke' ),
'slug' => 'redux-framework',
'required' => true,
'force_activation' => false,
'force_deactivation' => false,
),
array(
'name' => esc_html__( 'Contact Form 7', 'ananke' ),
'slug' => 'contact-form-7',
'required' => true,
),
array(
'name' => esc_html__( 'WPBakery Page Builder', 'ananke' ), // The plugin name.
'slug' => 'js_composer', // The plugin slug (typically the folder name).
'source' => 'https://www.oceanthemes.site/plugins-required/js_composer.zip', // The plugin source.
'required' => true, // If false, the plugin is only 'recommended' instead of required.
'version' => '7.2', // E.g. 1.0.0. If set, the active plugin must be this version or higher. If the plugin version is higher than the plugin version installed, the user will be notified to update the plugin.
'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch.
'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins.
'external_url' => '', // If set, overrides default API URL and points to an external URL.
'is_callable' => '', // If set, this callable will be be checked for availability to determine if a plugin is active.
),
array(
'name' => esc_html__( 'Slider Revolution', 'ananke' ), // The plugin name.
'slug' => 'revslider', // The plugin slug (typically the folder name).
'source' => 'https://www.oceanthemes.site/plugins-required/revslider.zip', // The plugin source.
'required' => false, // If false, the plugin is only 'recommended' instead of required.
'version' => '6.6.18', // E.g. 1.0.0. If set, the active plugin must be this version or higher. If the plugin version is higher than the plugin version installed, the user will be notified to update the plugin.
'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch.
'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins.
'external_url' => '', // If set, overrides default API URL and points to an external URL.
'is_callable' => '', // If set, this callable will be be checked for availability to determine if a plugin is active.
),
array(
'name' => esc_html__( 'One Click Import Demo', 'ananke' ), // The plugin name.
'slug' => 'ot-themes-one-click-import', // The plugin slug (typically the folder name).
'source' => 'https://www.oceanthemes.site/plugins-required/ananke/ot-themes-one-click-import.zip', // The plugin source.
'required' => false, // If false, the plugin is only 'recommended' instead of required.
),
array(
'name' => esc_html__( 'OT Portfolios', 'ananke' ), // The plugin name.
'slug' => 'ot_portfolio', // The plugin slug (typically the folder name).
'source' => 'https://www.oceanthemes.site/plugins-required/ananke/ot_portfolio.zip', // The plugin source.
'required' => false, // If false, the plugin is only 'recommended' instead of required.
),
array(
'name' => esc_html__( 'OT Slide Show', 'ananke' ), // The plugin name.
'slug' => 'ot_slide_show', // The plugin slug (typically the folder name).
'source' => 'https://www.oceanthemes.site/plugins-required/ananke/ot_slide_show.zip', // The plugin source.
'required' => false, // If false, the plugin is only 'recommended' instead of required.
),
);
$config = array(
'id' => 'tgmpa', // Unique ID for hashing notices for multiple instances of TGMPA.
'default_path' => '', // Default absolute path to bundled plugins.
'menu' => 'tgmpa-install-plugins', // Menu slug.
'parent_slug' => 'themes.php', // Parent menu slug.
'capability' => 'edit_theme_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used.
'has_notices' => true, // Show admin notices or not.
'dismissable' => true, // If false, a user cannot dismiss the nag message.
'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
'is_automatic' => false, // Automatically activate plugins after installation or not.
'message' => '', // Message to output right before the plugins table.
);
tgmpa( $plugins, $config );
}
/*Admin Style*/
if ( ! function_exists( 'ananke_custom_wp_admin_style' ) ) :
function ananke_custom_wp_admin_style() {
wp_register_style( 'ananke_custom_wp_admin_css', get_template_directory_uri() . '/framework/admin/css/admin-style.css', false, '1.0.0' );
wp_enqueue_style( 'ananke_custom_wp_admin_css' );
wp_enqueue_script( 'ananke_custom_wp_admin_js', get_template_directory_uri()."/framework/admin/js/admin-script.js", array( 'jquery' ), '1.0.0', true );
wp_enqueue_script( 'ananke_custom_wp_admin_js' );
}
add_action( 'admin_enqueue_scripts', 'ananke_custom_wp_admin_style' );
endif;
if ( ! function_exists( 'wp_body_open' ) ) {
/**
* Shim for wp_body_open, ensuring backward compatibility with versions of WordPress older than 5.2.
*/
function wp_body_open() {
do_action( 'wp_body_open' );
}
}
/*Custom fields:*/
require_once get_template_directory() . '/framework/bfi_thumb-master/BFI_Thumb.php';
require_once get_template_directory() . '/framework/meta-boxes.php';
/*Visual Composer Shortcode*/
require_once get_template_directory() . '/vc_shortcode.php';
require_once get_template_directory() . '/shortcodes.php';
/*Theme Main Colours*/
require_once get_template_directory() . '/framework/color.php';
?>