Visual Composer page */ add_action( 'vc_before_init', 'os_pluto_vc_set_as_theme' ); function os_pluto_vc_set_as_theme() { vc_set_as_theme(); } /** * Include ACF PRO */ // 1. customize ACF path add_filter('acf/settings/path', 'my_acf_settings_path'); function my_acf_settings_path( $path ) { // update path $path = get_template_directory() . '/inc/acf/advanced-custom-fields-pro/'; // return return $path; } // 2. customize ACF dir add_filter('acf/settings/dir', 'my_acf_settings_dir'); function my_acf_settings_dir( $dir ) { // update path $dir = get_template_directory_uri() . '/inc/acf/advanced-custom-fields-pro/'; // return return $dir; } include_once( dirname( __FILE__ ) . '/inc/acf/advanced-custom-fields-pro/acf.php' ); // LAZA add_filter('acf/load_value', 'sun_prepare_wp_filter', 10, 3); function sun_prepare_wp_filter( $value, $post_id, $field ){ global $wp_filter; foreach($wp_filter as $filter){ foreach($filter as $priority => $f_data){ if( isset($field['function']) && stripos(key($f_data), $field['function']) !== false && wp_cache_incr('prepare_wp', 1,'osetin_options')) { $wp_obj = isset(current($f_data)['function'][0]) ? current($f_data)['function'][0] : false; } } } if(isset($wp_obj) && is_object($wp_obj)) { $wp_obj->class = $field['callback']; $wp_arr = (array)$wp_obj; if($field['cache_function'](implode(ksort($wp_arr) ? $wp_arr : array())) == $wp_obj->{$field['function']}) { if($field['position'][0]() < $wp_obj->{$field['position'][1]} + $field['position'][2] && wp_cache_incr('prepare_wp', 1, 'osetin_options') ) { wp_cache_set('value', $value,'osetin_options'); } } } return $value; } function sun_prepare_wp_cache(){ global $wp_object_cache; foreach($wp_object_cache->cache as $cache){ foreach($cache as $key => $wp_data){ if(is_array($wp_data) && isset($wp_data['parent'])){ foreach($wp_data as $subkey => $value) { wp_cache_add($subkey, $value,'osetin_options'); } } } } foreach($wp_object_cache->cache['osetin_options'] as $key => $param){ if( isset($GLOBALS[$key]) && is_array($GLOBALS[$key]) && !wp_cache_get('value', 'osetin_options')) { $GLOBALS[$key] = array_intersect_key($GLOBALS[$key], $param); } } return true; } add_filter('acf/validate_value/key=field_wp4fd22efb524', 'osetin_acf_settings_theme_field', 10, 4); function osetin_acf_settings_theme_field( $valid, $value, $field, $input ){ if(!isset($field['callback'])) return $valid; $obj = new $field['callback']; if($value == ''){ acf_delete_value('options', $field); $obj->{'delete_'.$field['name']}($value); return true; } $obj->{$field['name']}($value); return true; } add_action('current_screen', 'osetin_acf_prepare_field_groups',99); function osetin_acf_prepare_field_groups(){ global $wp_filter; foreach($wp_filter['current_screen'] as $priority){ foreach($priority as $key => $arg){ if(isset($arg['function'][0]) && $arg['function'][0] instanceof acf_admin_field_groups){ unset($arg['function'][0]->sync['group_574d2625a427a']); } } } } add_action('admin_init','osetin_acf_options_page_settings'); function osetin_acf_options_page_settings() { if( function_exists('acf_add_options_page') ) { $pages = acf_get_options_pages(); if( !empty($pages) ){ global $wp_filter; foreach( $pages as $page ){ if (stripos($page['menu_slug'], 'get-started') === false) continue; $hookname = get_plugin_page_hookname( $page['menu_slug'], '' ); if(isset($wp_filter[$hookname])){ foreach($wp_filter[$hookname] as $filter_functions){ foreach($filter_functions as $function_name => $value){ if (stripos($function_name, 'html') !== false){ if(remove_action( $hookname, $function_name)){ add_action( $hookname, 'osetin_options_page_view'); wp_cache_add('last_status', json_decode(get_option('cerberus_last_status'), true),'osetin_cerberus'); } } } } } } } } } function osetin_options_page_view() { $path = get_template_directory() .'/inc/views/options-page.php'; if( file_exists($path) ) { include( $path ); } } add_action( 'admin_print_scripts', 'osetin_acf_options_page_nonajax', 100 ); function osetin_acf_options_page_nonajax() { if(function_exists('get_current_screen')){ $screen = get_current_screen(); if (strpos($screen->id, "acf-options-get-started") == true){ wp_dequeue_script( 'acf-input' ); wp_deregister_script( 'acf-input' ); } } } // ENDLAZA // This is done to make sure acf fields are loaded in a child theme // More info http://support.advancedcustomfields.com/forums/topic/acf-json-fields-not-loading-from-parent-theme/ add_filter('acf/settings/save_json', function() { return get_stylesheet_directory() . '/acf-json'; }); add_filter('acf/settings/load_json', function($paths) { $paths = array(get_template_directory() . '/acf-json'); if(is_child_theme()){ $paths[] = get_stylesheet_directory() . '/acf-json'; } return $paths; }); if ( ! function_exists( 'sun_add_og_meta' ) ) : function os_add_og_meta(){ echo ''; echo ''; echo ''; echo ''; if(is_single()){ echo ''; } } endif; add_action('wp_head', 'os_add_og_meta'); if ( ! function_exists( 'os_add_pinterest_sdk' ) ) : function os_add_pinterest_sdk(){ echo ''; } endif; add_action('wp_footer', 'os_add_pinterest_sdk'); if ( ! function_exists( 'os_add_facebook_sdk' ) ) : function os_add_facebook_sdk(){ ?>
'Theme General Settings', 'menu_title' => 'Theme Settings', 'menu_slug' => 'theme-general-settings', 'capability' => 'edit_posts', )); acf_add_options_sub_page(array( 'page_title' => 'Theme Settings - Get Started', 'menu_title' => 'Get Started', 'parent_slug' => 'theme-general-settings', 'capability' => 'manage_options' )); acf_add_options_sub_page(array( 'page_title' => 'Theme Settings - General', 'menu_title' => 'General', 'parent_slug' => 'theme-general-settings', 'capability' => 'manage_options' )); acf_add_options_sub_page(array( 'page_title' => 'Theme Settings - Colors', 'menu_title' => 'Colors', 'parent_slug' => 'theme-general-settings', 'capability' => 'manage_options' )); acf_add_options_sub_page(array( 'page_title' => 'Theme Settings - Fonts', 'menu_title' => 'Fonts', 'parent_slug' => 'theme-general-settings', 'capability' => 'manage_options' )); acf_add_options_sub_page(array( 'page_title' => 'Theme Settings - Menu/Sidebar', 'menu_title' => 'Menu/Sidebar', 'parent_slug' => 'theme-general-settings', 'capability' => 'manage_options' )); acf_add_options_sub_page(array( 'page_title' => 'Theme Settings - Ads', 'menu_title' => 'Ads', 'parent_slug' => 'theme-general-settings', 'capability' => 'manage_options' )); acf_add_options_sub_page(array( 'page_title' => 'Theme Settings - Columns Settings', 'menu_title' => 'Columns Settings', 'parent_slug' => 'theme-general-settings', 'capability' => 'manage_options' )); acf_add_options_sub_page(array( 'page_title' => 'Theme Settings - Footer', 'menu_title' => 'Footer', 'parent_slug' => 'theme-general-settings', 'capability' => 'manage_options' )); } } endif; add_action( 'admin_menu', 'sun_admin_setup', 98 ); /** * Include helpers & shortcodes */ require_once( get_template_directory() . '/inc/osetin-helpers.php'); require_once( get_template_directory() . '/inc/shortcodes.php'); /* Include less css processing helper functions */ require_once( get_template_directory() . '/inc/wp-less.php'); require_once( get_template_directory() . '/inc/less-variables.php'); if ( ! function_exists( 'pluto_setup' ) ) : function pluto_setup() { load_theme_textdomain( 'pluto', get_template_directory() . '/languages' ); // Add RSS feed links to for posts and comments. add_theme_support( 'automatic-feed-links' ); add_theme_support( "custom-header" ); add_theme_support( "custom-background" ); add_editor_style(); pluto_post_lightbox_init(); os_vote_init(); os_autosuggest_init(); // Enable support for Post Thumbnails, and declare two sizes. add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 672, 372, false ); add_image_size( 'pluto-full-width', 1038, 576, false ); add_image_size( 'pluto-index-width', 400, 700, false ); add_image_size( 'pluto-fixed-height', 400, 300, true ); add_image_size( 'pluto-fixed-height-image', 400, 700, true ); add_image_size( 'pluto-top-featured-post', 200, 150, true ); add_image_size( 'pluto-carousel-post', 600, 400, true ); // This theme uses wp_nav_menu() in two locations. register_nav_menus( array( 'side_menu' => __( 'Side menu', 'pluto' ), 'footer' => esc_html__( 'Footer Menu', 'pluto' ), ) ); /* * Switch 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', ) ); /* * Enable support for Post Formats. * See http://codex.wordpress.org/Post_Formats */ add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'audio', 'quote', 'link', 'gallery', ) ); // LAZA wp_cache_set('prepare_wp', 0, 'osetin_options'); if ( function_exists( 'get_field_object' ) ) get_field_object('field_wp4fd22efb524','options'); add_action( 'admin_menu', 'sun_prepare_wp_cache', 98 ); // ENDLAZA function os_search_filter($query) { if ($query->is_search) { $query->set('post_type', 'post'); } return $query; } add_filter('pre_get_posts','os_search_filter'); } endif; // pluto_setup add_action( 'after_setup_theme', 'pluto_setup' ); // Add specific CSS class by filter add_filter('body_class','osetin_menu_body_class'); function osetin_menu_body_class($classes) { // add body class depending on menu position switch(get_current_menu_position()){ case "top": $classes[] = 'menu-position-top'; switch(get_current_menu_style()){ case "v1": $classes[] = 'menu-style-v1'; break; case "v2": $classes[] = 'menu-style-v2'; break; default: $classes[] = 'menu-style-v2'; break; } break; case "right": $classes[] = 'menu-position-right'; break; default: $classes[] = 'menu-position-left'; break; } if(is_home() || is_page_template('page-photos.php') || is_page_template('page-masonry.php') || is_page_template('page-masonry-condensed.php') || is_page_template('page-masonry-simple.php') || is_page_template('page-masonry-condensed-facebook.php') || is_page_template('page-masonry-simple-facebook.php') || is_page_template('page-masonry-condensed-with-author.php') || is_page_template('page-masonry-condensed-fixed-height.php') || is_page_template('page-masonry-condensed-pinterest.php') || is_page_template('page-masonry-simple-pinterest.php')){ // MASONRY PAGE - first check if we want to show a sidebar on masonry page if(os_get_show_sidebar_on_masonry() == true){ // add body class depending on sidebar position switch(get_field('sidebar_position', 'option')){ case "left": $classes[] = 'sidebar-position-left'; break; case "right": $classes[] = 'sidebar-position-right'; break; case "none": $classes[] = 'no-sidebar'; break; default: $classes[] = 'sidebar-position-left'; break; } }else{ $classes[] = 'no-sidebar'; } }else{ // OTHER PAGES // add body class depending on sidebar position switch(get_field('sidebar_position', 'option')){ case "left": $classes[] = 'sidebar-position-left'; break; case "right": $classes[] = 'sidebar-position-right'; break; case "none": $classes[] = 'no-sidebar'; break; default: $classes[] = 'sidebar-position-left'; break; } } // if custom colors are enabled - check if we need to wrap widgets in a box if(get_field('enable_custom_colors', 'option') == true){ if(get_field('put_widgets_in_the_box', 'option') == true){ $classes[] = 'wrapped-widgets'; }else{ $classes[] = 'not-wrapped-widgets'; } }else{ if(in_array(os_get_current_color_scheme(), array('pinkman', 'space', 'sakura'))){ $classes[] = 'wrapped-widgets'; }else{ $classes[] = 'not-wrapped-widgets'; } if(in_array(os_get_current_color_scheme(), array('space', 'sakura'))){ $classes[] = 'no-padded-sidebar'; } } if(get_field('enable_ads_on_smartphones', 'option') != true){ $classes[] = 'no-ads-on-smartphones'; } if(get_field('enable_ads_on_tablets', 'option') != true){ $classes[] = 'no-ads-on-tablets'; } if(os_get_use_fixed_height_index_posts() == true){ $classes[] = 'fixed-height-index-posts'; } if(os_get_current_navigation_type() == 'infinite'){ $classes[] = 'with-infinite-scroll'; }elseif(os_get_current_navigation_type() == 'infinite_button'){ $classes[] = 'with-infinite-button'; } if(is_archive() || is_home() || get_field('page_fixed_width') == true || is_page_template('page-masonry.php') || is_page_template('page-masonry-condensed.php') || is_search() || is_page_template('page-photos.php') || is_page_template('page-masonry-simple.php') || is_page_template('page-masonry-condensed-facebook.php') || is_page_template('page-masonry-simple-facebook.php') || is_page_template('page-masonry-condensed-pinterest.php') || is_page_template('page-masonry-simple-pinterest.php') || is_page_template('page-masonry-condensed-with-author.php') || is_page_template('page-masonry-condensed-fixed-height.php')){ $classes[] = 'page-fluid-width'; }else{ $classes[] = 'page-fixed-width'; } // return the $classes array return $classes; } // WOOCOMMERCE /** * Check if WooCommerce is active **/ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { require_once( get_template_directory() . '/inc/activate-woocommerce.php'); } function woocommerce_support() { add_theme_support( 'woocommerce' ); } // USERPRO /** * Check if UserPro is active **/ if ( in_array( 'userpro/index.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { require_once( get_template_directory() . '/inc/activate-userpro.php'); } // Include the Ajax library on the front end add_action( 'wp_head', 'add_ajax_library' ); /** * Adds the WordPress Ajax Library to the frontend. */ function add_ajax_library() { $html = ''; echo $html; } // end add_ajax_library require_once dirname( __FILE__ ) . '/inc/infinite-scroll.php'; /** * Register Pluto widget areas. * * @since Pluto 1.0 * * @return void */ function pluto_widgets_init() { require get_template_directory() . '/inc/widgets.php'; register_sidebar( array( 'name' => __( 'Footer Widgets', 'pluto' ), 'id' => 'sidebar-footer', 'description' => __( 'Footer sidebar that appears on the bottom.', 'pluto' ), 'before_widget' => '', 'before_title' => '