/* * This theme styles the visual editor to resemble the theme style, * specifically font, colors, icons, and column width. */ /***************************************/ // / // CORE FUNCTIONALITY FUNCTIONS START / // / /***************************************/ // text_brightness_handler() --> određuje ispravnu boju texta ovisno o odabranom brightnessu function text_brightness_handler(){ if (get_sub_field('text_brightness') == '1') {echo 'color_color_5';} else if (get_sub_field('text_brightness') == '2') {echo 'color_color_1';} } // background_brightness_handler() --> određuje ispravnu boju pozadine ovisno o odabranom brightnessu function background_brightness_handler(){ if (get_sub_field('text_brightness') == '1') {echo 'background_color_5';} else if (get_sub_field('text_brightness') == '2') {echo 'background_color_1';} } // new_tab_handler() --> Provjerava dali se link treba otvoriti u novom tabu i ispisuje: target _blank function new_tab_handler(){ if (get_sub_field('new_tab') == '1') { } else {echo 'target="_blank"';} } // new_tab_head_handler() --> Provjerava dali se link u headeru treba otvoriti u novom tabu i ispisuje: target _blank function new_tab_head_handler(){ if (get_field('new_tab', 'option') == '1') { } else {echo 'target="_blank"';} } // background_color_inverter() --> Provjerava dali je invertana boja i sukladno pušta invertane klase function background_color_inverter(){ if (get_sub_field('color_sheme') == '1') {echo 'background_color_1';} else if (get_sub_field('color_sheme') == '2') {echo 'background_color_4';} } // text_color_inverter() --> Provjerava dali je invertana boja i sukladno pušta invertane klase function text_color_inverter(){ if (get_sub_field('color_sheme') == '1') {echo 'color_color_4';} else if (get_sub_field('color_sheme') == '2') {echo 'color_color_1';} } // footer_background_inverter() --> Provjerava dali je invertana boja i sukladno pušta invertane klase function footer_background_inverter(){ if (get_field("color_sheme", "option") == '1') {echo 'background_color_4';} else if (get_field("color_sheme", "option") == '2') {echo 'background_color_5';} } // footer_text_color_inverter() --> Provjerava dali je invertana boja i sukladno pušta invertane klase function footer_text_color_inverter(){ if (get_field("color_sheme", "option") == '1') {echo 'color_color_3';} else if (get_field("color_sheme", "option") == '2') {echo 'color_color_4';} } // footer_copytext_color_inverter() --> Provjerava dali je invertana boja i sukladno pušta invertane klase function footer_copytext_color_inverter(){ if (get_field("color_sheme", "option") == '1') {echo 'color_color_5';} else if (get_field("color_sheme", "option") == '2') {echo 'color_color_3';} } function footer_copytext_color_inverter_return(){ if (get_field("color_sheme", "option") == '1') {return 'color_color_5_f hover_color_3';} else if (get_field("color_sheme", "option") == '2') {return 'color_color_3_f hover_color_5';} } // cta_text_color_inverter() --> Provjerava dali je invertana boja i sukladno pušta invertane klase function cta_text_color_inverter(){ if (get_field("color_inverter", "option") == '1') { the_field("boja_5", "option");} else if (get_field("color_inverter", "option") == '2') { the_field("boja_1", "option");} } // cta_text_color_inverter_hover() --> Provjerava dali je invertana boja i sukladno pušta invertane klase function cta_text_color_inverter_hover(){ if (get_field("color_inverter", "option") == '1') { the_field("boja_1", "option");} else if (get_field("color_inverter", "option") == '2') { the_field("boja_5", "option");} } // border_radius_cta_handler() --> Provjerava dali je odabran rounded ili squared corner te postavlja na CTA function border_radius_cta_handler(){ if (get_field("corner_style", "option") == '1') {echo 'border-radius:6px!important';} else if (get_field("corner_style", "option") == '2') {echo 'border-radius:0px!important';} } // headline_text_color_inverter() --> Provjerava dali je invertana boja i sukladno pušta invertane klase function headline_text_color_inverter(){ if (get_sub_field("color_sheme") == '1') {echo 'color_color_3';} else if (get_sub_field("color_sheme") == '2') {echo 'color_color_1';} } /***************************************/ // / // CORE FUNCTIONALITY FUNCTIONS END / // / /***************************************/ /** * Set maximum content width */ if (!isset($content_width)) { $content_width = 1280; } /** * See: https://codex.wordpress.org/Function_Reference/add_theme_support */ function wp41boilerplate_setup() { /*$op_name_broj = 'options_broj_jezika'; $op_name_broj = mysql_real_escape_string($op_name_broj); global $wpdb; $results = $wpdb->get_results( "SELECT option_value FROM wp_options WHERE option_name = '$op_name_broj'", OBJECT ); foreach($results['0'] as $result) { $brojka = $result; } $curr_lang = 0; $meni_lokacija = array(); $lokacija = array();*/ /*while($curr_lang < $brojka) { $jezik_no = 'options_jezici_' . $curr_lang . '_jezik'; $jezik_no = mysql_real_escape_string($jezik_no); $results1 = $wpdb->get_results( "SELECT option_value FROM wp_options WHERE option_name = '$jezik_no'", OBJECT ); foreach($results1[0] as $resulti) { $jezik_puni = $resulti; } $nova_lokacija = array(strtolower($jezik_puni . '-header') => $jezik_puni . ' meni header', strtolower($jezik_puni . '-footer') => $jezik_puni . ' meni footer' ); $meni_lokacija = array_merge($meni_lokacija, $nova_lokacija); $curr_lang = $curr_lang + 1; }*/ register_nav_menus(array('meni-header' => 'Header menu', 'meni-footer' => 'Footer Menu')); add_theme_support('title-tag'); add_theme_support('html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption', 'widgets' )); add_theme_support('post-thumbnails'); //set_post_thumbnail_size($width, $height, $crop) add_image_size("gallery", 480, 350, true); add_image_size("blogbaner", 1920, 520, true); add_image_size("blogblok", 960, 400, true); add_image_size("shareimage", 1200, 630, true); //add_theme_support('automatic-feed-links'); //load_theme_textdomain('wp41boilerplate', get_template_directory() . '/languages'); } /** * Enqueue styles, scripts and threaded comments */ function wp41boilerplate_scripts() { wp_register_style('wp41boilerplate', get_template_directory_uri() . '/style.css', false, null); wp_enqueue_style('wp41boilerplate'); wp_register_style('wp41boilerplatefancy', get_template_directory_uri() . '/source/jquery.fancybox.css', false, null); wp_enqueue_style('wp41boilerplatefancy'); wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-accordion', array('jquery')); //wp_register_script('wp41boilerplate-header', get_template_directory_uri() . '/js/header.js', false, null); //wp_enqueue_script('wp41boilerplate-header'); wp_register_script('wp41boilerplate-footer', get_template_directory_uri() . '/js/footer.js', false, null, true); wp_enqueue_script('wp41boilerplate-footer'); wp_register_script('wp41boilerplate-fancy', get_template_directory_uri() . '/source/jquery.fancybox.js', false, null, true); wp_enqueue_script('wp41boilerplate-fancy'); /* * Fetch posts using AJAX * wp_enqueue_script('wp41bp-ajax-fetch-posts', get_template_directory_uri() . '/js/wp41bp-ajax-fetch-posts.js', array('jquery'), null, true); wp_localize_script('wp41bp-ajax-fetch-posts', 'wp41bp_fetch_posts', array( 'ajaxurl' => admin_url('admin-ajax.php') )); /* *Conditional script(s) * if (is_page('pagenamehere')) { wp_register_script('wp41boilerplate-conditional', get_template_directory_uri() . '/js/conditional.js', false, null, true); wp_enqueue_script('wp41boilerplate-conditional'); } */ // Enable threaded comments if (!is_admin()) { if (is_singular() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } } } function cc_mime_types($mimes) { $mimes['eot'] = 'application/vnd.ms-fontobject'; $mimes['woff'] = 'application/font-woff'; $mimes['woff2'] = 'application/font-woff2'; $mimes['ttf'] = 'application/x-font-ttf'; return $mimes; } add_filter('upload_mimes', 'cc_mime_types'); /* ------ INCLUDE PLUGINS IN THEME ------*/ require_once dirname( __FILE__ ) . '/class-tgm-plugin-activation.php'; add_action( 'tgmpa_register', 'my_theme_register_required_plugins' ); function my_theme_register_required_plugins() { $plugins = array( array( 'name' => 'Gravity forms', 'slug' => 'gravityforms', 'source' => 'http://themeupdate.svinaweb.hr/plugins/gravityforms.zip', 'required' => true, 'force_activation' => true, 'external_url' => 'http://www.gravityforms.com/', ), /*array( 'name' => 'Duplicate post', 'slug' => 'duplicate-post', 'required' => true, 'force_activation' => true )*/ ); $config = array( 'id' => 'tgmpa', 'default_path' => '', 'menu' => 'tgmpa-install-plugins', 'parent_slug' => 'themes.php', 'capability' => 'edit_theme_options', 'has_notices' => true, 'dismissable' => true, 'dismiss_msg' => '', 'is_automatic' => false, 'message' => '', ); tgmpa( $plugins, $config ); } /* ------ INCLUDE ACF IN THEME ------ */ // 1. customize ACF path add_filter('acf/settings/path', 'my_acf_settings_path'); function my_acf_settings_path( $path ) { // update path $path = get_stylesheet_directory() . '/acf/'; // 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_stylesheet_directory_uri() . '/acf/'; // return return $dir; } // 4. Include ACF include_once( get_stylesheet_directory() . '/acf/acf.php' ); include_once( get_stylesheet_directory() . '/duplicate-post/duplicate-post.php' ); /*add_filter('acf/settings/show_admin', '__return_false');*/ /* ------ OPTIONS PAGE ------ */ if( function_exists('acf_add_options_page') ) { acf_add_options_page(array( 'page_title' => 'Options', 'menu_title' => 'Options', 'menu_slug' => 'postavke_weba', 'capability' => 'edit_posts', 'icon_url' => 'http://themeupdate.svinaweb.hr/snwtema/favic.png', 'redirect' => false )); acf_add_options_sub_page(array( 'page_title' => 'Languages', 'menu_title' => 'Languages', 'parent_slug' => 'postavke_weba', )); } require 'theme-updates/theme-update-checker.php'; /* ------ GLOBALS ------ */ /* $example_update_checker = new ThemeUpdateChecker( 'snwtema', 'http://themeupdate.svinaweb.hr/snwtema/info.json' );*/ /* ------ MULTILINGUAL ON ------ */ /*function create_jezik() { if (!is_taxonomy('jezik')) { register_taxonomy( 'jezik', array('page', 'post'), array( 'hierarchical' => true, 'label' => __('Jezik'), 'public' => TRUE, 'show_ui' => TRUE, 'query_var' => 'jezik', 'rewrite' => true ) ); } }*/ /* function gbw_langs_init() { if (!is_taxonomy('jezik')) { register_taxonomy( 'jezik', array('page', 'post'), array( 'hierarchical' => true, 'label' => __('Jezik'), 'public' => TRUE, 'show_ui' => TRUE, 'query_var' => 'jezik', 'rewrite' => true ) ); } }*/ /* * Initialize / add more widgets to theme function wp41boilerplate_widgets_init() { register_sidebar(array( 'name' => __('Widget Area 1', 'wp41boilerplate'), 'id' => 'widget-area-1', 'description' => __('Drop widgets here to appear in your sidebar.', 'wp41boilerplate'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'name' => __('Widget Area 2', 'wp41boilerplate'), 'id' => 'widget-area-2', 'description' => __('Drop widgets here to appear in your sidebar.', 'wp41boilerplate'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'name' => __('Widget Area 3', 'wp41boilerplate'), 'id' => 'widget-area-3', 'description' => __('Drop widgets here to appear in your sidebar.', 'wp41boilerplate'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); } */ /** * Remove wp_head() injected Recent Comment styles */ function remove_recent_comments_style() { global $wp_widget_factory; remove_action('wp_head', array($wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style')); } /* * Remove 'id' from enqueued stylesheet */ function clean_style_tag($tag) { $tag = str_replace("id='wp41boilerplate-css' ", '', $tag); return $tag; } /** * Add page slug to body class */ function add_slug_to_body_class($classes) { global $post; if (is_home()) { $blacklist[] = 'blog'; $classes = array_diff($classes, $blacklist); } elseif (is_page()) { $blacklist[] = 'page-id-'.$post->ID; $classes = array_diff($classes, $blacklist); $classes[] = sanitize_html_class($post->post_name); } elseif (is_single()) { $blacklist[] = 'postid-'.$post->ID; $blacklist[] = 'single-format-standard'; $classes = array_diff($classes, $blacklist); $classes[] = sanitize_html_class($post->post_name); } elseif (is_archive()) { $blacklist[] = 'category-'.$post->ID; $blacklist[] = 'tag-'.$post->ID; $classes = array_diff($classes, $blacklist); } elseif (is_attachment()) { $blacklist[] = 'attachmentid-'.$post->ID; $classes = array_diff($classes, $blacklist); $classes[] = sanitize_html_class($post->post_name); } $classes[] .= sanitize_html_class("background_color_1"); return $classes; } /* * Remove width and height attributes from images inserted into TinyMCE */ function remove_width_attribute($html) { $html = preg_replace( '/(width|height)="\d*"\s/', "", $html ); return $html; } /* * Remove thumbnail width and height dimensions that prevent fluid images in the_thumbnail */ function remove_thumbnail_dimensions($html) { $html = preg_replace('/(width|height)=\"\d*\"\s/', "", $html); return $html; } /** * Remove invalid rel attribute values in the categorylist */ function remove_invalid_category_rel($cat_list) { return str_replace('rel="category tag"', 'rel="tag"', $cat_list); } /* * Remove excerpt square brackets ([...] => ...) */ function remove_excerpt_brackets($more) { global $post; return '...'; } function custom_excerpt_length($length) { return 16; } add_action('after_setup_theme', 'wp41boilerplate_setup'); add_action('wp_enqueue_scripts', 'wp41boilerplate_scripts'); // add_action( 'init', 'create_jezik' ); // add_action('init', 'gbw_langs_init'); //add_action('widgets_init', 'wp41boilerplate_widgets_init'); add_action('widgets_init', 'remove_recent_comments_style'); //add_filter('wp_title', 'dynamic_title', 10, 2); add_filter('style_loader_tag', 'clean_style_tag'); add_filter('body_class', 'add_slug_to_body_class'); add_filter('jpeg_quality', create_function('','return 100;')); add_filter('post_thumbnail_html', 'remove_thumbnail_dimensions', 10); add_filter('post_thumbnail_html', 'remove_width_attribute', 10); add_filter('image_send_to_editor', 'remove_width_attribute', 10); //add_filter('show_admin_bar', '__return_false'); add_filter('the_category', 'remove_invalid_category_rel'); add_filter('widget_text', 'do_shortcode'); add_filter('widget_text', 'shortcode_unautop'); add_filter('the_excerpt', 'do_shortcode'); add_filter('the_excerpt', 'shortcode_unautop'); add_filter('excerpt_more', 'remove_excerpt_brackets'); add_filter('excerpt_length', 'custom_excerpt_length', 999); remove_filter('the_excerpt', 'wpautop'); remove_action('wp_head', 'feed_links', 2); remove_action('wp_head', 'feed_links_extra', 3); /* remove_action('wp_head', 'index_rel_link'); remove_action('wp_head', 'parent_post_rel_link', 10, 0); remove_action('wp_head', 'start_post_rel_link', 10, 0); remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); */ remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'wp_generator'); remove_action('wp_head', 'rel_canonical'); remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0); remove_action('wp_head', 'print_emoji_detection_script', 7); remove_action('wp_print_styles', 'print_emoji_styles'); /* * Add & define your AJAX actions here * add_action('wp_ajax_nopriv_wp41bpFetchPosts', 'wp41bpFetchPosts'); add_action('wp_ajax_wp41bpFetchPosts', 'wp41bpFetchPosts'); function wp41bpFetchPosts() { echo get_bloginfo('title'); die(); } /* * Pagination for paged posts, Page 1, Page 2, Page 3, with Next and Previous Links, No plugin */ function wpboilerplate41_pagination() { global $wp_query; $big = 999999999; echo paginate_links(array( 'base' => str_replace($big, '%#%', get_pagenum_link($big)), 'format' => '?paged=%#%', 'current' => max(1, get_query_var('paged')), 'total' => $wp_query->max_num_pages )); } /* * Shortcode example * function wp41boilerplate_shortcode($atts, $content = null) { return '' . $content . ''; } add_shortcode('wp41boilerplate_shortcode', 'wp41boilerplate_shortcode'); /* * Add Categories and Tags to Pages * function add_taxonomies_to_pages() { register_taxonomy_for_object_type('category', 'page'); register_taxonomy_for_object_type('post_tag', 'page'); } add_action('init', 'add_taxonomies_to_pages'); /* * Show them and use them in queries * function category_and_tag_archives($wp_query) { $my_post_array = array('post','page'); if ( $wp_query->get('category_name') || $wp_query->get('cat') ) $wp_query->set('post_type', $my_post_array); if ( $wp_query->get('tag') ) $wp_query->set('post_type', $my_post_array); } if ( !is_admin() ) { add_action('pre_get_posts', 'category_and_tag_archives'); } /* * Create Custom Post Types * function wp41boilerplate_cpt() { register_post_type('wp41boilerplate_cpt', array( 'labels' => array( 'name' => __('WP Boilerplate CPTs', 'wp41boilerplate_cpt'), 'singular_name' => __('WP Boilerplate CPT', 'wp41boilerplate_cpt'), ), 'public' => true, //'menu_position' => 5, 'supports' => array('title', 'editor', 'thumbnail'), 'taxonomies' => array('category', 'post_tag'), 'has_archive' => true, 'can_export' => true )); } add_action('init', 'wp41boilerplate_cpt'); /* * Show Custom Post Types in regular Archives * function show_cpt_in_archives($query) { if( $query->is_main_query() && $query->is_archive() && !is_admin() ) { $query->set('post_type', array('post','wp41boilerplate')); } return $query; } add_filter('pre_get_posts', 'show_cpt_in_archives'); /* * Custom breadcrumb * function the_breadcrumb() { // Settings $separator = '>'; $id = 'breadcrumbs'; $class = 'breadcrumbs'; $home_title = 'Homepage'; // Get the query & post information global $post, $wp_query; $category = get_the_category(); // Build the breadcrums echo ''; } /* * Remove Dashboard meta boxes (not side menu!) * function remove_dashboard_meta() { remove_meta_box('dashboard_incoming_links', 'dashboard', 'normal'); remove_meta_box('dashboard_plugins', 'dashboard', 'normal'); remove_meta_box('dashboard_primary', 'dashboard', 'side'); remove_meta_box('dashboard_secondary', 'dashboard', 'normal'); remove_meta_box('dashboard_quick_press', 'dashboard', 'side'); remove_meta_box('dashboard_recent_drafts', 'dashboard', 'side'); remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal'); remove_meta_box('dashboard_right_now', 'dashboard', 'normal'); remove_meta_box('dashboard_activity', 'dashboard', 'normal'); //since 3.8 } add_action('admin_init', 'remove_dashboard_meta'); */