File: /home/dermova/www/me/wp-content/themes/dermoviva-en/functions.php
<?php
@ini_set( 'upload_max_size' , '64M' );
@ini_set( 'post_max_size', '64M');
@ini_set( 'max_execution_time', '300' );
//Add support for WordPress 3.0's custom menus
add_action( 'init', 'register_my_menu' );
//Register area for custom menu
function register_my_menu() {
//register_nav_menu( 'primary-menu', __( 'Primary Menu' ) );
register_nav_menu( 'primary', 'Primary Menu' );
register_nav_menu( 'footer', 'Footer Menu' );
}
// Enable post thumbnails
add_theme_support('post-thumbnails');
set_post_thumbnail_size(520, 250, true);
//Get Slug's Page ID
function getPageBySlugname($slugname) {
$args = array(
'post_type' => 'page',
'hierarchical' => 0,
'post_status' => 'publish'
);
$pages = get_pages($args);
foreach ($pages as $page) {
if ($page->post_name == $slugname) {
return $page->ID;
}
}
}
// Login Styling
function custom_login_css() {
echo '<link rel="stylesheet" type="text/css" href="'.get_stylesheet_directory_uri().'/login/login-styles.css" />';
}
add_action('login_head', 'custom_login_css');
// Login Logo URL
function my_login_logo_url() {
return get_bloginfo( 'url' );
}
add_filter( 'login_headerurl', 'my_login_logo_url' );
function my_login_logo_url_title() {
return 'Osraty Physio and Rehab';
}
add_filter( 'login_headertitle', 'my_login_logo_url_title' );
// Lost Password Link
function remove_lostpassword_text ( $text ) {
if ($text == 'Lost your password?'){$text = '';}
return $text;
}
add_filter( 'gettext', 'remove_lostpassword_text' );
// Login Error Message
add_filter('login_errors',create_function('$a', "return '<b>Error:</b> Invalid Username or Password';"));
// Login Error Shake
function my_login_head() {
remove_action('login_head', 'wp_shake_js', 12);
}
add_action('login_head', 'my_login_head');
//redirect users to front page after login
function redirect_to_investor_page() {
global $redirect_to;
if (!isset($_GET['redirect_to'])) {
$redirect_to = get_option('siteurl');
}
}
add_action('login_form', 'redirect_to_investor_page');
//disable admin bar for subscribers
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
add_action('after_setup_theme', 'remove_admin_bar');
//ShortCode for Image Slider Function
function imagesliderfn( $atts ) {
extract(shortcode_atts(array(
'slidername' => 'none',
'slidercategory' => '',
'header' => '',
'caption' => ''
), $atts));
if($slidername <> 'none'){
$cat = get_category_by_slug($slidercategory);
$catid = $cat->cat_ID;
$args=array(
'name' => $slidername,
'cat' => $catid,
'post_type' => 'post',
'post_status' => 'publish',
'numberposts' => 1
);
$my_posts = get_posts($args);
if( $my_posts ) {
$content = $my_posts[0]->post_content;
$removecon = array('<ul>', '</ul>', '<li>', '</li>');
$replacecon = array('', '', '<div class="slides">', '</div>');
$thecontent = str_replace($removecon, $replacecon, $content);
$fnctnoutput = '<div class="slider-main">'.$thecontent.'<h1><a href="#" class="slider-arrows slider-arrow-left">left</a>
<a href="#" class="slider-arrows slider-arrow-right">right</a></h1></div><!-- slider-main -->';
} else {
$fnctnoutput = '';
}
} else {
$fnctnoutput = '';
}
return $fnctnoutput;
}
add_shortcode( 'displayimageslider', 'imagesliderfn' );
//ShortCode for listing cateogry titles with permalinks
function listcategoryfn( $atts ) {
extract(shortcode_atts(array(
'catname' => 'none'
), $atts));
if($catname <> 'none'){
$cat = get_category_by_slug($catname);
$catid = $cat->cat_ID;
$fnctnoutput = '';
$args=array(
'cat' => $catid,
'post_type' => 'post',
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'ASC'
);
$wp_query = new wp_query($args);
while ($wp_query->have_posts()) : $wp_query->the_post();
$listcontent .= '<li><a href="'.get_the_permalink().'" class="lnk-blck">'.get_the_title().'</a></li>';
endwhile;
$fnctnoutput = '<ul class="into2col">'.$listcontent.'</ul>';
} else {
$fnctnoutput = '';
}
return $fnctnoutput;
}
add_shortcode( 'listcategory', 'listcategoryfn' );
//FUNCTION FOR GETTING PERMALINK BY TITLE
function getLinkByTitle( $title ) {
$permalink = null;
$page = get_page_by_title( strtolower( $title ) );
if( null != $page ) {
$permalink = get_permalink( $page->ID );
}
return $permalink;
}
?>