= 2 || $page >= 2 ) $title = "$title $sep " . sprintf( __( 'Page %s', "diarjolite" ), max( $paged, $page ) ); return $title; } add_filter( 'wp_title', 'diarjolite_title', 10, 2 ); /*-----------------------------------------------------------------------------------*/ /* LOCALIZE THEME */ /*-----------------------------------------------------------------------------------*/ load_theme_textdomain("diarjolite", get_template_directory() . '/languages'); /*-----------------------------------------------------------------------------------*/ /* REQUIRE FUNCTION */ /*-----------------------------------------------------------------------------------*/ function diarjolite_require($folder) { if (isset($folder)) : if ( ( !diarjolite_setting('diarjolite_loadsystem') ) || ( diarjolite_setting('diarjolite_loadsystem') == "mode_a" ) ) { $folder = dirname(dirname(__FILE__)) . $folder ; $files = scandir($folder); foreach ($files as $key => $name) { if (!is_dir($name)) { require_once $folder . $name; } } } else if ( diarjolite_setting('diarjolite_loadsystem') == "mode_b" ) { $dh = opendir(get_template_directory().$folder); while (false !== ($filename = readdir($dh))) { if ( strlen($filename) > 2 ) { require_once get_template_directory()."/".$folder.$filename; } } } endif; } /*-----------------------------------------------------------------------------------*/ /* SCRIPTS FUNCTION */ /*-----------------------------------------------------------------------------------*/ function diarjolite_enqueue_script($folder) { if (isset($folder)) : if ( ( !diarjolite_setting('diarjolite_loadsystem') ) || ( diarjolite_setting('diarjolite_loadsystem') == "mode_a" ) ) { $dir = dirname(dirname(__FILE__)) . $folder ; $files = scandir($dir); foreach ($files as $key => $name) { if (!is_dir($name)) { wp_enqueue_script( str_replace('.js','',$name), get_template_directory_uri() . $folder . "/" . $name , array('jquery'), FALSE, TRUE ); } } } else if ( diarjolite_setting('diarjolite_loadsystem') == "mode_b" ) { $dh = opendir(get_template_directory().$folder); while (false !== ($filename = readdir($dh))) { if ( strlen($filename) > 2 ) { wp_enqueue_script( str_replace('.js','',$filename), get_template_directory_uri() . $folder . "/" . $filename , array('jquery'), FALSE, TRUE ); } } } endif; } /*-----------------------------------------------------------------------------------*/ /* STYLES FUNCTION */ /*-----------------------------------------------------------------------------------*/ function diarjolite_enqueue_style($folder) { if (isset($folder)) : if ( ( !diarjolite_setting('diarjolite_loadsystem') ) || ( diarjolite_setting('diarjolite_loadsystem') == "mode_a" ) ) { $dir = dirname(dirname(__FILE__)) . $folder ; $files = scandir($dir); foreach ($files as $key => $name) { if (!is_dir($name)) { wp_enqueue_style( str_replace('.css','',$name), get_template_directory_uri() . $folder . "/" . $name ); } } } else if ( diarjolite_setting('diarjolite_loadsystem') == "mode_b" ) { $dh = opendir(get_template_directory().$folder); while (false !== ($filename = readdir($dh))) { if ( strlen($filename) > 2 ) { wp_enqueue_style( str_replace('.css','',$filename), get_template_directory_uri() . $folder . "/" . $filename ); } } } endif; } /*-----------------------------------------------------------------------------------*/ /* REQUEST FUNCTION */ /*-----------------------------------------------------------------------------------*/ function diarjolite_request($id) { if ( isset ( $_REQUEST[$id])) return $_REQUEST[$id]; } /*-----------------------------------------------------------------------------------*/ /* THEME PATH */ /*-----------------------------------------------------------------------------------*/ function diarjolite_theme_data($id) { $themedata = wp_get_theme(); return $themedata->get($id); } /*-----------------------------------------------------------------------------------*/ /* THEME NAME */ /*-----------------------------------------------------------------------------------*/ function diarjolite_themename() { $themename = "diarjolite_theme_settings"; return $themename; } /*-----------------------------------------------------------------------------------*/ /* THEME SETTINGS */ /*-----------------------------------------------------------------------------------*/ function diarjolite_setting($id) { $diarjolite_setting = get_option(diarjolite_themename()); if(isset($diarjolite_setting[$id])) return $diarjolite_setting[$id]; } /*-----------------------------------------------------------------------------------*/ /* POST META */ /*-----------------------------------------------------------------------------------*/ function diarjolite_postmeta($id) { global $post; if (!is_404()) { $val = get_post_meta( $post->ID , $id, TRUE); if(isset($val)) return $val; } else { return null; } } /*-----------------------------------------------------------------------------------*/ /* POST ICON */ /*-----------------------------------------------------------------------------------*/ function diarjolite_posticon() { $icons = array ("video" => "fa fa-film" , "gallery" => "fa fa-camera" , "audio" => "fa fa-music" , "aside" => "fa fa-file-text-o" , "link" => "fa fa-link" , "quote" => "fa fa-quote-left" ); if (get_post_format()) { $icon = ''; } else { $icon = ''; } return $icon; } /*-----------------------------------------------------------------------------------*/ /* Content template */ /*-----------------------------------------------------------------------------------*/ function diarjolite_template($id) { $template = array ("full" => "col-md-12" , "left-sidebar" => "col-md-8" , "right-sidebar" => "col-md-8" ); $span = $template["right-sidebar"]; $sidebar = "right-sidebar"; if ( ( (is_category()) || (is_tag()) || (is_tax()) || (is_month() ) ) && (diarjolite_setting('diarjolite_category_layout')) ) { $span = $template[diarjolite_setting('diarjolite_category_layout')]; $sidebar = diarjolite_setting('diarjolite_category_layout'); } else if ( (is_home()) && (diarjolite_setting('diarjolite_home')) ) { $span = $template[diarjolite_setting('diarjolite_home')]; $sidebar = diarjolite_setting('diarjolite_home'); } else if ( ( (is_single()) || (is_page()) ) && (diarjolite_postmeta('diarjolite_template')) ) { $span = $template[diarjolite_postmeta('diarjolite_template')]; $sidebar = diarjolite_postmeta('diarjolite_template'); } return ${$id}; } /*-----------------------------------------------------------------------------------*/ /* THUMBNAILS */ /*-----------------------------------------------------------------------------------*/ function diarjolite_get_thumbs($type) { if (diarjolite_setting('diarjolite_'.$type.'_thumbinal')): return diarjolite_setting('diarjolite_'.$type.'_thumbinal'); else: return "629"; endif; } /*-----------------------------------------------------------------------------------*/ /* THEME SETUP */ /*-----------------------------------------------------------------------------------*/ function diarjolite_setup() { add_theme_support( 'post-formats', array( 'aside','gallery','quote','video','audio','link' ) ); add_theme_support( 'automatic-feed-links' ); add_theme_support( 'post-thumbnails' ); add_image_size( 'blog', 940,629, TRUE ); add_image_size( 'large', 449,304, TRUE ); add_image_size( 'medium', 290,220, TRUE ); add_image_size( 'small', 211,150, TRUE ); register_nav_menu( 'main-menu', 'Main menu' ); add_theme_support( 'custom-background', array( 'default-color' => 'f3f3f3' ) ); if ( ! isset( $content_width ) ) $content_width = 940; } add_action( 'after_setup_theme', 'diarjolite_setup' ); /*-----------------------------------------------------------------------------------*/ /* DEFAULT STYLE, AFTER THEME ACTIVATION */ /*-----------------------------------------------------------------------------------*/ if ( is_admin() && isset($_GET['activated'] ) && $pagenow == 'themes.php' ) { $diarjolite_setting = get_option(diarjolite_themename()); if (!$diarjolite_setting) { $settings = array( "diarjolite_loadsystem" => "mode_a", "diarjolite_skins" => "turquoise", "diarjolite_logo_font" => "Oswald", "diarjolite_menu_font" => "Roboto Slab", "diarjolite_content_font" => "Roboto Slab", "diarjolite_titles_font" => "Fjalla One", "diarjolite_link_color" => "#48c9b0", "diarjolite_link_color_hover" => "#1abc9c", "diarjolite_bars_background_color" => "#2D3032", "diarjolite_bars_text_color" => "#ffffff", "diarjolite_bars_borders_color" => "#444649", "diarjolite_body_background_color" => "#fafafa", "diarjolite_home" => "right-sidebar", "diarjolite_category_layout" => "right-sidebar", "diarjolite_bottom_layout" => "col-md-4", ); update_option( diarjolite_themename(), $settings ); } } /*-----------------------------------------------------------------------------------*/ /* GET PAGED */ /*-----------------------------------------------------------------------------------*/ function diarjolite_paged() { if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } elseif ( get_query_var('page') ) { $paged = get_query_var('page'); } else { $paged = 1; } return $paged; } /*-----------------------------------------------------------------------------------*/ /* PRETTYPHOTO */ /*-----------------------------------------------------------------------------------*/ function diarjolite_prettyPhoto( $html, $id, $size, $permalink, $icon, $text ) { if ( ! $permalink ) return str_replace( 'post_content, '')): $output = '

'.strip_tags(get_the_content()).' [...]

'; else: $output = '

'.get_the_excerpt().' [...]

'; endif; echo $output; } /*-----------------------------------------------------------------------------------*/ /* REMOVE CATEGORY LIST REL */ /*-----------------------------------------------------------------------------------*/ function diarjolite_remove_category_list_rel($output) { $output = str_replace('rel="category"', '', $output); return $output; } add_filter('wp_list_categories', 'diarjolite_remove_category_list_rel'); add_filter('the_category', 'diarjolite_remove_category_list_rel'); /*-----------------------------------------------------------------------------------*/ /* REMOVE THUMBNAIL DIMENSION */ /*-----------------------------------------------------------------------------------*/ function diarjolite_remove_thumbnail_dimensions( $html, $post_id, $post_image_id ) { $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html ); return $html; } add_filter( 'post_thumbnail_html', 'diarjolite_remove_thumbnail_dimensions', 10, 3 ); /*-----------------------------------------------------------------------------------*/ /* REMOVE CSS GALLERY */ /*-----------------------------------------------------------------------------------*/ function diarjolite_my_gallery_style() { return "