This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ /** * Redirects user to a new page. * This is done if the custom field 'redirect' is defined as: * + Filed Name: redirect * + Field Value: New target URL. * * @return void */ function ak_theme_redirect() { global $post; if ( is_page() || is_single() ) { if ( $meta = get_post_meta($post->ID, 'redirect', true) ) { wp_redirect($meta, 301); exit; } } } /** * Checks if the sidebar is used. * Do it by checking if there is any widget on a sidebar number. * * @param int|string $index Sidebar number or id * @return boolean True if this sidebar is used and contains any widget, false if not. */ function ak_theme_is_sidebar( $index ) { $sidebar = wp_get_sidebars_widgets(); if ( is_numeric($index) ) { $index = 'sidebar-' . $index; } if (isset($sidebar[$index]) && count($sidebar[$index]) ) { return true; } else { return false; } }