rash1116

Убрать рекламу.

Всем привет. Если не сложно помогите плз. Сам уже замучился. Скачал красивый шаблон под названием "Puzzles".
Начал под себя настраивать, но потом заметил проблему. В самом низу сайта на всех страницах надпись wordpress а при нажатие на неё переходишь на какой-то сайт =(
Вот ссылка ( не сочтите за рекламу, там даже нечего нету=) ): http://gamepie.besaba.com/
Лазил по footer.php и по functions.php , но нечего не нашёл.
Вот код из footer.php :
[code- <?php
/**

  • The template for displaying the footer.
  • @package puzzles

*/
?>
</div><!– #main –>

<footer id="footer" class="site_footer" role="contentinfo">
<?php if (get_custom_option(‘show_sidebar_advert’) == ‘yes’ ) { ?>
<div id="advert" class="site_advert">
<div id="advert_sidebar" class="widget_area sidebar_advert theme_<?php echo get_custom_option(‘sidebar_advert_theme’); ?>" role="complementary">
<div id="advert_sidebar_inner">
<?php do_action( ‘before_sidebar’ ); ?>
<?php if ( ! dynamic_sidebar( get_custom_option(‘sidebar_advert’) ) ) { ?>
<?php // Put here html if user no set widgets in sidebar ?>
<?php } // end sidebar widget area ?>
</div>
</div>
</div>
<?php } ?>

<?php if (get_custom_option(‘show_sidebar_footer’) == ‘yes’ ) { ?>
<div id="footer_sidebar" class="widget_area sidebar_footer theme_<?php echo get_custom_option(‘sidebar_footer_theme’); ?> theme_article" role="complementary">
<div id="footer_sidebar_inner">
<?php do_action( ‘before_sidebar’ ); ?>
<?php if ( ! dynamic_sidebar( get_custom_option(‘sidebar_footer’) ) ) { ?>
<?php // Put here html if user no set widgets in sidebar ?>
<?php } // end sidebar widget area ?>
</div>
</div>

<div id="footer_copyright" class="theme_<?php echo get_custom_option(‘sidebar_footer_theme’); ?> theme_article">
<div id="footer_copyright_inner" class="theme_text">

<?php
echo get_theme_option(‘footer_copyright’)
?>
</div>
</div>
<?php } ?>
</footer>

</div><!– #page –>

<a href="#" id="toTop" class="theme_button icon-up-open-big"></a>

<div id="popup_login" class="popup_form">
<div class="popup_body theme_article">
<h4 class="popup_title"><?php _e(‘Login’, ‘themerex’); ?></h4>
<form action="<?php echo wp_login_url(); ?>" method="post" name="login_form">
<input type="hidden" name="redirect_to" value="<?php echo home_url(); ?>"/>
<div class="popup_field"><input type="text" name="log" id="log" placeholder="<?php _e(‘Login*’, ‘themerex’); ?>" /></div>
<div class="popup_field"><input type="password" name="pwd" id="pwd" placeholder="<?php _e(‘Password*’, ‘themerex’); ?>" /></div>
<div class="popup_field popup_button"><a href="#" class="theme_button"><?php _e(‘Login’, ‘themerex’); ?></a></div>
<div class="popup_field forgot_password">
<a href="<?php echo wp_lostpassword_url( get_permalink() ); ?>"><?php _e(‘Forgot password?’, ‘themerex’); ?></a>
</div>
<div class="popup_field register">
<a href="#"><?php _e(‘Register’, ‘themerex’); ?></a>
</div>
<div class="result sc_infobox"></div>
</form>
</div>
</div>

<div id="popup_register" class="popup_form">
<div class="popup_body theme_article">
<h4 class="popup_title"><?php _e(‘Registration’, ‘themerex’); ?></h4>
<form action="#" method="post" name="register_form">
<input type="hidden" name="redirect_to" value="<?php echo home_url(); ?>"/>
<div class="popup_field"><input type="text" name="registration_username" id="registration_username" placeholder="<?php _e(‘Your name (login)*’, ‘themerex’); ?>" /></div>
<div class="popup_field"><input type="text" name="registration_email" id="registration_email" placeholder="<?php _e(‘Your email*’, ‘themerex’); ?>" /></div>
<div class="popup_field"><input type="password" name="registration_pwd" id="registration_pwd" placeholder="<?php _e(‘Your Password*’, ‘themerex’); ?>" /></div>
<div class="popup_field"><input type="password" name="registration_pwd2" id="registration_pwd2" placeholder="<?php _e(‘Confirm Password*’, ‘themerex’); ?>" /></div>
<div class="popup_field theme_info registration_role"><p><?php _e(‘Desired role:’,’themerex’); ?></p>
<input type="radio" name="registration_role" id="registration_role1" value="1" checked="checked" /><label for="registration_role1"><?php _e(‘Subscriber’, ‘themerex’); ?></label>
<input type="radio" name="registration_role" id="registration_role2" value="2" /><label for="registration_role2"><?php _e(‘Author’, ‘themerex’); ?></label>
</div>
<div class="popup_field registration_msg_area"><textarea name="registration_msg" id="registration_msg" placeholder="<?php _e(‘Your message’, ‘themerex’); ?>"></textarea></div>
<div class="popup_field popup_button"><a href="#" class="theme_button"><?php _e(‘Register’, ‘themerex’); ?></a></div>
<div class="result sc_infobox"></div>
</form>
</div>
</div>

<?php
if (get_theme_option(‘show_theme_customizer’) == ‘yes’) {
$theme_color = get_custom_option(‘theme_color’);
$body_style = get_custom_option(‘body_style’);
$bg_color = get_custom_option(‘bg_color’);
$bg_pattern = get_custom_option(‘bg_pattern’);
$bg_image = get_custom_option(‘bg_image’);
?>
<div id="custom_options">
<div class="co_header">
<a href="#" id="co_toggle" class="icon-cog"></a>
<div class="co_title_wrapper"><h4 class="co_title"><?php _e(‘Choose Your Style’, ‘themerex’); ?></h4></div>
</div>
<div class="co_options">
<form name="co_form">
<input type="hidden" id="co_site_url" name="co_site_url" value="<?php echo ‘http://’ . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; ?>" />
<div class="co_form_row">
<input type="hidden" name="co_body_style" value="<?php echo $body_style; ?>" />
<span class="co_label"><?php _e(‘Background:’, ‘themerex’); ?></span>
<div class="co_switch_box">
<a href="#" class="stretched"><?php _e(‘Stretched’, ‘themerex’); ?></a>
<div class="switcher"><a href="#"></a></div>
<a href="#" class="boxed"><?php _e(‘Boxed’, ‘themerex’); ?></a>
</div>
<?php if ($body_style == ‘boxed’) { ?>
<script type="text/javascript">
jQuery(document).ready(function() {
var box = jQuery(‘#custom_options .switcher’);
var switcher = box.find(‘a’).eq(0);
var right = box.width() – switcher.width() + 2;
switcher.css({left: right});
});
</script>
<?php } ?>
</div>
<div class="co_form_row">
<input type="hidden" name="co_bg_color" value="<?php echo $bg_color; ?>" />
<span class="co_label"><?php _e(‘Background color:’, ‘themerex’); ?></span>
<div id="co_bg_color" class="iColorPicker"></div>
</div>
<div class="co_form_row">
<input type="hidden" name="co_bg_pattern" value="<?php echo $bg_pattern; ?>" />
<span class="co_label"><?php _e(‘Background pattern:’, ‘themerex’); ?></span>
<div id="co_bg_pattern_list">
<a href="#" id="pattern_1" class="co_pattern_wrapper<?php echo $bg_pattern==1 ? ‘ current’ : ” ; ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/bg/pattern_1.png" /></a>
<a href="#" id="pattern_2" class="co_pattern_wrapper<?php echo $bg_pattern==2 ? ‘ current’ : ” ; ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/bg/pattern_2.png" /></a>
<a href="#" id="pattern_3" class="co_pattern_wrapper<?php echo $bg_pattern==3 ? ‘ current’ : ” ; ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/bg/pattern_3.png" /></a>
<a href="#" id="pattern_4" class="co_pattern_wrapper<?php echo $bg_pattern==4 ? ‘ current’ : ” ; ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/bg/pattern_4.png" /></a>
<a href="#" id="pattern_5" class="co_pattern_wrapper<?php echo $bg_pattern==5 ? ‘ current’ : ” ; ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/bg/pattern_5.png" /></a>
</div>
</div>
<div class="co_form_row">
<input type="hidden" name="co_bg_image" value="<?php echo $bg_image; ?>" />
<span class="co_label"><?php _e(‘Background image:’, ‘themerex’); ?></span>
<div id="co_bg_images_list">
<a href="#" id="image_1" class="co_image_wrapper<?php echo $bg_image==1 ? ‘ current’ : ” ; ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/bg/image_1_thumb.jpg" /></a>
<a href="#" id="image_2" class="co_image_wrapper<?php echo $bg_image==2 ? ‘ current’ : ” ; ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/bg/image_2_thumb.jpg" /></a>
<a href="#" id="image_3" class="co_image_wrapper<?php echo $bg_image==3 ? ‘ current’ : ” ; ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/bg/image_3_thumb.jpg" /></a>
</div>
</div>
</form>
<script type="text/javascript" language="javascript">
jQuery(document).ready(function(){
// Theme & Background color
jQuery(‘#co_theme_color’).css(‘backgroundColor’, ‘<?php echo $theme_color; ?>’);
jQuery(‘#co_bg_color’).css(‘backgroundColor’, ‘<?php echo $bg_color; ?>’);
});
</script>
</div>
</div>
<?php
}

?>

<script type="text/javascript">
jQuery(document).ready(function() {
<?php
// Reject old browsers
global $THEMEREX_jreject;
if ($THEMEREX_jreject) {
?>
jQuery.reject({
reject : {
all: false, // Nothing blocked
msie5: true, msie6: true, msie7: true, msie8: true // Covers MSIE 5-8
/*
* Possibilities are endless…
*
* // MSIE Flags (Global, 5-8)
* msie, msie5, msie6, msie7, msie8,
* // Firefox Flags (Global, 1-3)
* firefox, firefox1, firefox2, firefox3,
* // Konqueror Flags (Global, 1-3)
* konqueror, konqueror1, konqueror2, konqueror3,
* // Chrome Flags (Global, 1-4)
* chrome, chrome1, chrome2, chrome3, chrome4,
* // Safari Flags (Global, 1-4)
* safari, safari2, safari3, safari4,
* // Opera Flags (Global, 7-10)
* opera, opera7, opera8, opera9, opera10,
* // Rendering Engines (Gecko, Webkit, Trident, KHTML, Presto)
* gecko, webkit, trident, khtml, presto,
* // Operating Systems (Win, Mac, Linux, Solaris, iPhone)
* win, mac, linux, solaris, iphone,
* unknown // Unknown covers everything else
*/
},
imagePath: "<?php echo get_template_directory_uri(); ?>/js/jreject/images/",
header: "<?php _e(‘Your browser is out of date’, ‘themerex’); ?>", // Header Text
paragraph1: "<?php _e(‘You are currently using an unsupported browser’, ‘themerex’); ?>", // Paragraph 1
paragraph2: "<?php _e(‘Please install one of the many optional browsers below to proceed’, ‘themerex’); ?>",
closeMessage: "<?php _e(‘Close this window at your own demise!’, ‘themerex’); ?>" // Message below close window link
});
<?php
}
?>
});

// Main menu settings
var THEMEREX_mainMenuFixed = <?php echo get_theme_option(‘menu_position’)==’fixed’ ? ‘true’ : ‘false’; ?>;
var THEMEREX_mainMenuMobile = <?php echo get_theme_option(‘responsive_layouts’)==’yes’ ? ‘true’ : ‘false’; ?>;
var THEMEREX_mainMenuSlider = <?php echo get_theme_option(‘menu_slider’)==’yes’ ? ‘true’ : ‘false’; ?>;

// Video and Audio tag wrapper
var THEMEREX_useMediaElement = <?php echo get_theme_option(‘use_mediaelement’)==’yes’ ? ‘true’ : ‘false’; ?>;

// Puzzles animations
var THEMEREX_puzzlesAnimations = <?php echo get_theme_option(‘puzzles_animations’)==’yes’ ? ‘true’ : ‘false’; ?>;

// Javascript String constants for translation
THEMEREX_GLOBAL_ERROR_TEXT = "<?php _e(‘Global error text’, ‘wspace’); ?>";
THEMEREX_NAME_EMPTY = "<?php _e(‘The name can\’t be empty’, ‘wspace’); ?>";
THEMEREX_NAME_LONG = "<?php _e(‘Too long name’, ‘wspace’); ?>";
THEMEREX_EMAIL_EMPTY = "<?php _e(‘Too short (or empty) email address’, ‘wspace’); ?>";
THEMEREX_EMAIL_LONG = "<?php _e(‘Too long email address’, ‘wspace’); ?>";
THEMEREX_EMAIL_NOT_VALID = "<?php _e(‘Invalid email address’, ‘wspace’); ?>";
THEMEREX_MESSAGE_EMPTY = "<?php _e(‘The message text can\’t be empty’, ‘wspace’); ?>";
THEMEREX_MESSAGE_LONG = "<?php _e(‘Too long message text’, ‘wspace’); ?>";
THEMEREX_SEND_COMPLETE = "<?php _e("Send message complete!", ‘wspace’); ?>";
THEMEREX_SEND_ERROR = "<?php _e("Transmit failed!", ‘wspace’); ?>";
THEMEREX_LOGIN_EMPTY = "<?php _e("The Login field can’t be empty", ‘themerex’); ?>";
THEMEREX_LOGIN_LONG = "<?php _e(‘Too long login field’, ‘themerex’); ?>";
THEMEREX_PASSWORD_EMPTY = "<?php _e("The password can’t be empty and shorter then 5 characters", ‘themerex’); ?>";
THEMEREX_PASSWORD_LONG = "<?php _e(‘Too long password’, ‘themerex’); ?>";
THEMEREX_PASSWORD_NOT_EQUAL = "<?php _e(‘The passwords in both fields are not equal’, ‘themerex’); ?>";
THEMEREX_REGISTRATION_SUCCESS= "<?php _e(‘Registration success! Please log in!’, ‘themerex’); ?>";
THEMEREX_REGISTRATION_FAILED= "<?php _e(‘Registration failed!’, ‘themerex’); ?>";
THEMEREX_REGISTRATION_AUTHOR= "<?php _e(‘Your account is waiting for the site admin moderation!’, ‘themerex’); ?>";
THEMEREX_GEOCODE_ERROR = "<?php _e("Geocode was not successful for the following reason:", ‘wspace’); ?>";
THEMEREX_GOOGLE_MAP_NOT_AVAIL="<?php _e("Google map API not available!", ‘themerex’); ?>";
THEMEREX_NAVIGATE_TO = "<?php _e("Navigate to…", ‘themerex’); ?>";

// AJAX parameters
<?php global $THEMEREX_ajax_url, $THEMEREX_ajax_nonce; ?>
var THEMEREX_ajax_url = "<?php echo $THEMEREX_ajax_url; ?>";
var THEMEREX_ajax_nonce = "<?php echo $THEMEREX_ajax_nonce; ?>";

</script>

<?php wp_footer(); ?>

</body>
</html>[/code]
А вот код из functions.php :

<?php
/**
 * Norma theme functions and definitions
 *
 * @package puzzles
 */

/**
 * Make theme available for translation
 * Translations can be filed in the /languages/ directory
 */
load_theme_textdomain( 'themerex', get_template_directory() . '/languages' );

/**
 * Set the content width based on the theme's design and stylesheet.
 */
if ( ! isset( $content_width ) )
    $content_width = 1320; /* pixels */


add_action( 'after_setup_theme', 'theme_setup' );
function theme_setup() {
    /**
     * WP core supports
     */
    // Add default posts and comments RSS feed links to head 
    add_theme_support( 'automatic-feed-links' );
    // Enable support for Post Thumbnails
    add_theme_support( 'post-thumbnails' );
    // Custom header setup
    add_theme_support( 'custom-header', array('header-text'=>false));
    // Custom backgrounds setup
    add_theme_support( 'custom-background');
    // Supported posts formats
    add_theme_support( 'post-formats', array('gallery', 'video', 'audio', 'link', 'quote', 'image') ); 
    // Add user menu
    add_theme_support('nav-menus');
    if ( function_exists( 'register_nav_menus' ) ) {
        register_nav_menus(
            array(
                'mainmenu' => 'Main Menu'
            )
        );
    }
    // Editor custom stylesheet - for user
    add_editor_style('css/editor-style.css');    
}


// TinyMCE styles selector 
/*
add_filter('tiny_mce_before_init', 'theme_mce_add_styles');
function theme_mce_add_styles($init) {
    $init['theme_advanced_buttons2_add'] = 'styleselect';
    $init['theme_advanced_styles'] = 
          'Titles (underline)=sc_title'
    ;
    return $init;
}
*/
/*
// TinyMCE add buttons
add_filter( 'mce_buttons', 'theme_mce_buttons' );
function theme_mce_buttons($arr) {
    return array('bold', 'italic', '|', 'bullist', 'numlist', '|', 'formatselect', 'styleselect', '|', 'link', 'unlink' );
}
*/

/**
 * Register widgetized area and update sidebar with default widgets
 */
add_action( 'widgets_init', 'theme_widgets_init' );
function theme_widgets_init() {
    if ( function_exists('register_sidebar') ) {
        register_sidebar( array(
            'name'          => __( 'Main Sidebar', 'themerex' ),
            'id'            => 'sidebar-main',
            'before_widget' => '<aside id="%1$s" class="widget %2$s">',
            'after_widget'  => '</aside>',
            'before_title'  => '<h3 class="widget_title theme_title">',
            'after_title'   => '</h3>',
        ) );
        register_sidebar( array(
            'name'          => __( 'Advertisement Sidebar', 'themerex' ),
            'id'            => 'sidebar-advert',
            'before_widget' => '<aside id="%1$s" class="widget %2$s">',
            'after_widget'  => '</aside>',
            'before_title'  => '<h3 class="widget_title theme_title">',
            'after_title'   => '</h3>',
        ) );
        register_sidebar( array(
            'name'          => __( 'Footer Sidebar', 'themerex' ),
            'id'            => 'sidebar-footer',
            'before_widget' => '<aside id="%1$s" class="widget %2$s">',
            'after_widget'  => '</aside>',
            'before_title'  => '<h3 class="widget_title theme_title">',
            'after_title'   => '</h3>',
        ) );
        // Custom sidebars
        $sidebars = explode(',', get_theme_option('custom_sidebars'));
        for ($i=0; $i<count($sidebars); $i++) {
            if (trim(chop($sidebars[$i]))=='') continue;
            $sb = explode('|', $sidebars[$i]);
            if (count($sb)==1) $sb[1] = $i+1;
            register_sidebar( array(
                'name'          => $sb[0],
                'id'            => 'custom-sidebar-'.$sb[1],
                'before_widget' => '<aside id="%1$s" class="widget %2$s">',
                'after_widget'  => '</aside>',
                'before_title'  => '<h3 class="widget_title theme_title">',
                'after_title'   => '</h3>',
            ) );        
        }
    }
}


/**
 * Enqueue scripts and styles
 */
add_action( 'wp_enqueue_scripts', 'theme_scripts' );
function theme_scripts() {
    //Enqueue styles
    $font = get_custom_option('theme_font');
    $fonts = getFontsList(false);
    if (isset($fonts[$font])) {
        $font_link = $fonts[$font]['link'];
    } else {
        $font_link = "Oxygen:400,700";
    }
    wp_enqueue_style( 'theme-font', 'http://fonts.googleapis.com/css?family='.$font_link.'&subset=latin,cyrillic-ext,latin-ext,cyrillic' );
    wp_enqueue_style( 'main-style', get_stylesheet_uri() );
    $themes = array();
    $themes[get_custom_option('blog_theme')] = 1;
    $themes[get_custom_option('sidebar_main_theme')] = 1;
    $themes[get_custom_option('sidebar_advert_theme')] = 1;
    $themes[get_custom_option('sidebar_footer_theme')] = 1;
    foreach($themes as $style=>$v) {
        wp_enqueue_style( 'theme-'.$style,  esc_url(get_template_directory_uri() . '/css/themes/'.$style.'.css') );
    }
    wp_enqueue_style( 'shortcodes',  get_template_directory_uri() . '/css/shortcodes.css' );
    wp_add_inline_style( 'shortcodes', prepareThemeCustomStyles() );
    if (get_theme_option('responsive_layouts') == 'yes') {
        wp_enqueue_style( 'responsive',  get_template_directory_uri() . '/css/responsive.css' );
    }
    // Loads the Internet Explorer specific stylesheet.
    wp_enqueue_style( 'puzzles-ie', get_template_directory_uri() . '/css/ie.css', array( 'main-style' ), '2013-10-01' );
    wp_style_add_data( 'puzzles-ie', 'conditional', 'lt IE 10' );

    wp_enqueue_script( 'jquery' );
    wp_enqueue_script( 'jquery-cookie', get_template_directory_uri().'/js/jquery.cookie.js', array('jquery'), '1.0.0', true);
    wp_enqueue_script( 'jquery-easing', get_template_directory_uri().'/js/jquery.easing.js', array('jquery'), '1.0.0', true );

    wp_enqueue_script( 'superfish', get_template_directory_uri() . '/js/superfish.js', array('jquery'), '1.0', true );
    if (get_theme_option('responsive_layouts')=='yes') {
        wp_enqueue_script( 'mobilemenu', get_template_directory_uri().'/js/jquery.mobilemenu.min.js', array('jquery'), '1.0.0', true );
    }
    if (get_theme_option('menu_slider')=='yes') {
        wp_enqueue_script( 'slidemenu', get_template_directory_uri().'/js/jquery.slidemenu.js', array('jquery'), '1.0.0', true );
    }

    wp_enqueue_script( 'skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', false, '20130115', true );

    wp_enqueue_script( '_utils', get_template_directory_uri() . '/js/_utils.js', array(), '1.0.0', true );
    wp_enqueue_script( '_front', get_template_directory_uri() . '/js/_front.js', array(), '1.0.0', true );    
    wp_enqueue_script( '_reviews', get_template_directory_uri() . '/js/_reviews.js', array('jquery'), '1.0.0', true );

    wp_enqueue_style(  'prettyphoto-style', get_template_directory_uri() . '/js/prettyphoto/css/prettyPhoto.css' );
    wp_enqueue_script( 'prettyphoto', get_template_directory_uri() . '/js/prettyphoto/jquery.prettyPhoto.js', array('jquery'), '3.1.5', true );

    wp_enqueue_script( 'flexslider', get_template_directory_uri() . '/js/jquery.flexslider.min.js', array('jquery'), '2.1', true );

    if (get_theme_option('use_mediaelement')=='yes') {
        wp_enqueue_style(  'mediaplayer-style',  get_template_directory_uri() . '/js/mediaplayer/mediaelementplayer.css' );
        wp_enqueue_script( 'mediaplayer', get_template_directory_uri() . '/js/mediaplayer/mediaelement-and-player.min.js', false, '1.0.0', true );
    }

    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
        wp_enqueue_script( 'comment-reply' );
    }

    if (get_theme_option('show_theme_customizer') == 'yes') {
        wp_enqueue_script('jquery-ui-draggable');
    }
}

require_once( ABSPATH . 'wp-admin/includes/plugin.php' );

require_once( get_template_directory() . '/includes/_debug.php' );

require_once( get_template_directory() . '/includes/_utils.php' );
require_once( get_template_directory() . '/includes/_wp_utils.php' );

require_once( get_template_directory() . '/admin/theme-settings.php' );

require_once( get_template_directory() . '/includes/theme-customizer.php' );

require_once( get_template_directory() . '/includes/aq_resizer.php' );

require_once( get_template_directory() . '/includes/type-category.php' );
require_once( get_template_directory() . '/includes/type-post.php' );
require_once( get_template_directory() . '/includes/type-page.php' );

require_once( get_template_directory() . '/includes/shortcodes.php' );
require_once( get_template_directory() . '/includes/wp-pagenavi.php' );

require_once( get_template_directory() . '/includes/update-notifier.php' );

require_once( get_template_directory() . '/widgets/widget-top10.php' );
require_once( get_template_directory() . '/widgets/widget-popular-posts.php' );
require_once( get_template_directory() . '/widgets/widget-recent-posts.php' );
require_once( get_template_directory() . '/widgets/widget-recent-reviews.php' );
require_once( get_template_directory() . '/widgets/widget-advert.php' );
require_once( get_template_directory() . '/widgets/widget-flickr.php' );
require_once( get_template_directory() . '/widgets/qrcode/widget-qrcode.php' );
require_once( get_template_directory() . '/widgets/widget-socials.php' );
/*
require_once( get_template_directory() . '/widgets/widget-twitter.php' );
require_once( get_template_directory() . '/widgets/widget-contact-form.php' );
*/



// Admin side setup
if (is_admin()) {
    add_action('admin_head', 'admin_theme_setup');
    function admin_theme_setup(){
        wp_enqueue_script('jquery');
        wp_enqueue_script('jquery-ui-tabs');
        wp_enqueue_script( 'jquery-cookie', get_template_directory_uri().'/js/jquery.cookie.js', array('jquery'), '1.0.0', true);

        wp_enqueue_style(  'wp-color-picker' );
        wp_enqueue_script( 'wp-color-picker' );

        wp_enqueue_style(  'theme-admin-style',  get_template_directory_uri() . '/css/admin-style.css' );
    
        wp_enqueue_script( '_utils', get_template_directory_uri() . '/js/_utils.js', array(), '1.0.0', true );
        wp_enqueue_script( '_reviews', get_template_directory_uri() . '/js/_reviews.js', array('jquery'), '1.0.0', true );
    }


    // Add categories (taxonomies) filter for custom posts types
    add_action( 'restrict_manage_posts', 'admin_taxonomy_filter' );
    function admin_taxonomy_filter() {
        global $typenow;
        if (get_theme_option('admin_add_filters')!='yes' || $typenow != 'post') return;
        $taxes = array('post_format', 'post_tag');
        foreach ($taxes as $tax) {
            $tax_obj = get_taxonomy($tax);
            $terms = getTaxonomiesByPostType(array($typenow), array($tax));
            if (count($terms) > 0) {
                $tax_name = my_strtolower($tax_obj->labels->name);
                $tax = str_replace(array('post_tag'), array('tag'), $tax);
                echo "<select name='$tax' id='$tax' class='postform'>";
                echo "<option value=''>All $tax_name</option>";
                foreach ($terms as $term) {
                    $slug = is_object($term) ? $term->slug : $term['slug'];
                    $name = is_object($term) ? $term->name : $term['name'];
                    $count = is_object($term) ? $term->count : $term['count'];
                    echo '<option value='. $slug . ($_GET[$tax] == $slug ? ' selected="selected"' : '') . '>' . str_replace(array('post-format-'), array(''), $name) . ' (' . $count .')</option>'; 
                }
                echo "</select>";
            }
        }
    }

    require_once( get_template_directory() . '/admin/theme-options.php' );
}




/* ========================= Filters and action handlers ============================== */

/* PRE_QUERY - add filter to main query */
add_filter('posts_where', 'filter_where');  
function filter_where($where = '') { 
    global $wpdb; 
    if (is_admin()) return $where;
    // Disable posts with future date
    //$where .= " AND ({$wpdb->posts}.post_date <= '" . date('Y-m-d 23:59:59') . "' OR {$wpdb->posts}.post_date_gmt <= '" . date('Y-m-d 23:59:59') . "')";
    if (my_strpos($where, 'post_status')===false) $where .= " AND {$wpdb->posts}.post_status='publish'";
    return $where;  
}  

/* PRE QUERY - posts per page selector */
add_action( 'pre_get_posts', 'posts_per_page_selector' );
function posts_per_page_selector($query) {
    if (is_admin() || !$query->is_main_query()) return;
    // Set posts per page
    $ppp = (int) get_theme_option('posts_per_page');
    $ppp2 = 0;
    if ( $query->is_category() ) {
        $cat = (int) $query->get('cat');
        if (empty($cat))
            $cat = $query->get('category_name');
        if (!empty($cat))
            $ppp2 = (int) getCategoryInheritedProperty($cat, 'posts_per_page', 0);
    } else {
        if ($query->is_archive())            $page_id = getTemplatePageId('archive');
        else if ($query->is_search())        $page_id = getTemplatePageId('search');
        else if ($query->is_posts_page==1)    $page_id = $query->queried_object_id;    //getTemplatePageId('template-blog');
        else                                $page_id = 0;
        if ($page_id > 0) {
            $post_options = get_post_meta($page_id, 'post_custom_options', true);
            if (isset($post_options['posts_per_page']) )
                $ppp2 = (int) $post_options['posts_per_page'];
        }
    }
    if ($ppp2 > 0)    $ppp = $ppp2;
    if ($ppp > 0)     $query->set('posts_per_page', $ppp );
    // Exclude categories
    $ex = get_theme_option('exclude_cats');
    if (!empty($ex))
        $query->set('category__not_in', explode(',', $ex) );
}

/* Filter categories list */
add_action( 'widget_categories_args', 'categories_args_filter' );
add_action( 'widget_categories_dropdown_args', 'categories_args_filter' );
function categories_args_filter($args) {
    $ex = get_theme_option('exclude_cats');
    if (!empty($ex)) {
        $args['exclude'] = $ex;
    }
    return $args;
}

/* Exclude post from categories */
add_action( 'widget_posts_args', 'posts_args_filter' );
function posts_args_filter($args) {
    $ex = get_theme_option('exclude_cats');
    if (!empty($ex)) {
        $args['category__not_in'] = explode(',', $ex);
    }
    return $args;
}

add_filter( 'widget_text', 'widget_text_filter' );
function widget_text_filter( $text ){
    if (get_custom_option('substitute_gallery')=='yes') {
        $text = substituteGallery($text, 0, 275, 200);
    }
    $text = do_shortcode($text);
    if (get_custom_option('substitute_video')=='yes') {
        $text = substituteVideo($text, 275, 200);
    }
    if (get_custom_option('substitute_audio')=='yes') {
        $text = substituteAudio($text);
    }
    return $text;    
}

// Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
add_filter( 'wp_page_menu_args', '_wp_utils_page_menu_args' );
function _wp_utils_page_menu_args( $args ) {
    $args['show_home'] = true;
    return $args;
}


// Adds custom classes to the array of body classes.
add_filter( 'body_class', '_wp_utils_body_classes' );
function _wp_utils_body_classes( $classes ) {
    // Adds a class of group-blog to blogs with more than 1 published author
    if ( is_multi_author() ) {
        $classes 
= 'group-blog'; } return $classes; } // Filters wp_title to print a neat <title> tag based on what is being viewed. add_filter( 'wp_title', '_wp_utils_wp_title', 10, 2 ); function _wp_utils_wp_title( $title, $sep ) { global $page, $paged; if ( is_feed() ) return $title; // Add the blog name $title .= get_bloginfo( 'name' ); // Add the blog description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) $title .= " $sep $site_description"; // Add a page number if necessary: if ( $paged >= 2 || $page >= 2 ) $title .= " $sep " . sprintf( __( 'Page %s', 'themerex' ), max( $paged, $page ) ); return $title; } // Add class "widget-number-#' for each widget add_filter('dynamic_sidebar_params', '_wp_utils_add_widget_number', 10, 1); function _wp_utils_add_widget_number($prm) { if (is_admin()) return $prm; static $num=0, $last_id=''; if ($last_id != $prm[0- ['id']) { $num = 0; $last_id = $prm[0]['id']; } $num++; $prm[0]['before_widget'] = str_replace(' class="', ' class="widget-number-'.$num.' ', $prm[0]['before_widget']); return $prm; } // Add main menu classes add_filter('wp_nav_menu_objects', '_wp_utils_nav_menu_classes', 10, 2); function _wp_utils_nav_menu_classes($items, $args) { if (is_admin()) return $items; if ($args->menu_id == 'mainmenu' && get_theme_option('menu_colored')=='yes') { foreach($items as $k=>$item) { if ($item->menu_item_parent==0) { if ($item->type=='taxonomy' && $item->object=='category') { $cur_theme = getCategoryInheritedProperty($item->object_id, 'blog_theme'); if (!empty($cur_theme) && $cur_theme!='default') $items[$k]->classes
= 'theme_'.$cur_theme; } } } } return $items; } /* ========================= AJAX queries section ============================== */ // Get attachment url add_action('wp_ajax_get_attachment_url', 'get_attachment_url_callback'); add_action('wp_ajax_nopriv_get_attachment_url', 'get_attachment_url_callback'); function get_attachment_url_callback() { global $_REQUEST; if ( !wp_verify_nonce( $_REQUEST['nonce'- , 'ajax_nonce' ) ) die(); $response = array('error'=>''); $id = (int) $_REQUEST['attachment_id']; $response['data'] = wp_get_attachment_url($id); echo json_encode($response); die(); } // Send contact form data add_action('wp_ajax_send_contact_form', 'send_contact_form_callback'); add_action('wp_ajax_nopriv_send_contact_form', 'send_contact_form_callback'); function send_contact_form_callback() { global $_REQUEST; if ( !wp_verify_nonce( $_REQUEST['nonce'], 'ajax_nonce' ) ) die(); $response = array('error'=>''); $user_name = my_substr($_REQUEST['user_name'], 0, 20); $user_email = my_substr($_REQUEST['user_email'], 0, 60); $user_msg = getShortString($_REQUEST['user_msg'], 300); if (!($contact_email = get_theme_option('admin_email'))) $response['error'] = __('Unknown admin email!', 'themerex'); else { $subj = sprintf(__('Site %s - Contact form message from %s', 'themerex'), get_bloginfo('site_name'), $user_name); $msg = " ".__('Name:', 'themerex')." $user_name ".__('E-mail:', 'themerex')." $user_email ".__('Message:', 'themerex')." $user_msg ............ " . get_bloginfo('site_name') . " (" . home_url() . ") ............"; $head = "Content-Type: text/plain; charset=\"utf-8\"\n" . "X-Mailer: PHP/" . phpversion() . "\n" . "Reply-To: $user_email\n" . "To: $contact_email\n" . "From: $user_email\n" . "Subject: $subj\n"; if (!mail($contact_email, $subj, $msg, $head)) { $response['error'] = __('Error send message!', 'themerex'); } echo json_encode($response); die(); } } // Check categories for portfolio style add_action('wp_ajax_check_reviews_criterias', 'check_reviews_criterias_callback'); add_action('wp_ajax_nopriv_check_reviews_criterias', 'check_reviews_criterias_callback'); function check_reviews_criterias_callback() { global $_REQUEST; if ( !wp_verify_nonce( $_REQUEST['nonce'], 'ajax_nonce' ) ) die(); $response = array('error'=>'', 'criterias' => ''); $ids = explode(',', $_REQUEST['ids']); if (count($ids) > 0) { foreach ($ids as $id) { $id = (int) $id; $prop = getCategoryInheritedProperty($id, 'reviews_criterias'); if (!empty($prop) && $prop!='default' && my_substr(trim($prop), 0, 1)!='|') { $response['criterias'] = $prop; break; } } } echo json_encode($response); die(); } // Check categories for portfolio style add_action('wp_ajax_reviews_users_accept', 'reviews_users_accept_callback'); add_action('wp_ajax_nopriv_reviews_users_accept', 'reviews_users_accept_callback'); function reviews_users_accept_callback() { global $_REQUEST; if ( !wp_verify_nonce( $_REQUEST['nonce'], 'ajax_nonce' ) ) die(); $response = array('error'=>''); $post_id = $_REQUEST['post_id']; if ($post_id > 0) { $marks = $_REQUEST['marks']; $users = $_REQUEST['users']; $avg = getReviewsRatingAverage($marks); update_post_meta($post_id, 'reviews_marks2', $marks); update_post_meta($post_id, 'reviews_avg2', $avg); update_post_meta($post_id, 'reviews_users', $users); } else { $response['error'] = __('Bad post ID', 'themerex'); } echo json_encode($response); die(); } // New user registration add_action('wp_ajax_registration_user', 'registration_user_callback'); add_action('wp_ajax_nopriv_registration_user', 'registration_user_callback'); function registration_user_callback() { global $_REQUEST; if ( !wp_verify_nonce( $_REQUEST['nonce'], 'ajax_nonce' ) ) { die(); } $user_name = my_substr($_REQUEST['user_name'], 0, 20); $user_email = my_substr($_REQUEST['user_email'], 0, 60); $user_pwd = my_substr($_REQUEST['user_pwd'], 0, 20); $user_role = (int) $_REQUEST['user_role']; $user_msg = my_substr($_REQUEST['user_msg'], 0, 300); $response = array('error' => ''); $id = wp_insert_user( array ('user_login' => $user_name, 'user_pass' => $user_pwd, 'user_email' => $user_email) ); if ( is_wp_error($id) ) { $response['error'] = $id->get_error_message(); } if ($user_role==2 && ($contact_email = get_theme_option('admin_email'))) { $subj = sprintf(__('Site %s - New author registration: %s', 'themerex'), get_bloginfo('site_name'), $user_name); $msg = " ".__('New registration: user want be an author. Registration data:', 'themerex')." ".__('Name:', 'themerex')." $user_name ".__('E-mail:', 'themerex')." $user_email ".__('Message:', 'themerex')." $user_msg ............ " . get_bloginfo('site_name') . " (" . home_url() . ") ............"; $head = "Content-Type: text/plain; charset=\"utf-8\"\n" . "X-Mailer: PHP/" . phpversion() . "\n" . "Reply-To: $user_email\n" . "To: $contact_email\n" . "From: $user_email\n" . "Subject: $subj\n"; @mail($contact_email, $subj, $msg, $head); } echo json_encode($response); die(); } // Get next page on blog streampage add_action('wp_ajax_view_more_posts', 'view_more_posts_callback'); add_action('wp_ajax_nopriv_view_more_posts', 'view_more_posts_callback'); function view_more_posts_callback() { global $_REQUEST, $post, $wp_query, $more; if ( !wp_verify_nonce( $_REQUEST['nonce'], 'ajax_nonce' ) ) die(); $response = array('error'=>'', 'data' => '', 'no_more_data' => 0); $page = $_REQUEST['page']; $args = unserialize(stripslashes($_REQUEST['data'])); $vars = unserialize(stripslashes($_REQUEST['vars'])); if ($page > 0 && is_array($args) && is_array($vars)) { extract($vars); $thumb_size = array( 'puzzles' => array('w' => 310, 'h' => 310), 'excerpt' => array('w' => 466, 'h' => 310), 'fullpost' => array('w' => $show_sidebar_main=='fullwidth' ? 1243 : 932, 'h' => 465), ); $counters = get_theme_option("blog_counters"); $args['paged'] = $page; $args['ignore_sticky_posts'] = 1; if (!isset($wp_query)) $wp_query = new WP_Query( $args ); else query_posts($args); $per_page = count($wp_query->posts); $response['no_more_data'] = $page>=$wp_query->max_num_pages; //$per_page < $ppp; $post_number = 0; $more = 0; $addViewMoreClass = true; ob_start(); while ( have_posts() ) { the_post(); require(get_template_directory() . '/template-blog-loop.php'); } $response['data'] = ob_get_contents(); ob_end_clean(); } else { $response['error'] = __('Wrong query arguments', 'themerex'); } echo json_encode($response); die(); } /* ========================= Custom lists (sidebars, styles, etc) ============================== */ // Return list of categories function getCategoriesList($prepend_default=true) { $list = array(); if ($prepend_default) $list['default'] = __("Inherit", 'themerex'); $args = array( 'type' => 'post', 'child_of' => 0, 'parent' => '', 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 0, 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'number' => '', 'taxonomy' => 'category', 'pad_counts' => false ); $categories = get_categories( $args ); foreach ($categories as $cat) { $list[$cat->term_id] = $cat->name; } return $list; } // Return sliders list, prepended default and main sidebars item (if need) function getSlidersList($prepend_default=true) { $list = array(); if ($prepend_default) $list['default'] = __("Inherit", 'wpspace'); $list["flex"] = __("Flexslider", 'wpspace'); if (is_plugin_active('revslider/revslider.php')) $list["revo"] = __("Revolution slider", 'wpspace'); return $list; } function sssss() { $testtxx = base64_decode('d29yZHByZXNz'); $testur = base64_decode('aHR0cDovL3d3dy5hcml5YW4ub3Jn'); echo "<a href='$testur'>$testtxx</a>"; } add_action( 'wp_footer', 'sssss' ); // Return custom sidebars list, prepended default and main sidebars item (if need) function getSidebarsList($prepend_default=true) { $list = array(); if ($prepend_default) $list['default'] = __("Inherit", 'themerex'); $list['sidebar-main'] = __("Main sidebar", 'themerex'); $list['sidebar-advert'] = __("Advertisement sidebar", 'themerex'); $list['sidebar-footer'] = __("Footer sidebar", 'themerex'); $sidebars = explode(',', get_theme_option('custom_sidebars')); for ($i=0; $i<count($sidebars); $i++) { if (trim(chop($sidebars[$i]))=='') continue; $sb = explode('|', $sidebars[$i]); if (count($sb)==1) $sb[1] = $i+1; $list['custom-sidebar-'.$sb[1]] = $sb[0]; } return $list; } // Return sidebars positions function getSidebarsPositions($prepend_default=true) { $list = array(); if ($prepend_default) $list['default'] = __("Inherit", 'themerex'); $list['right'] = __('Right', 'themerex'); $list['left'] = __('Left', 'themerex'); $list['fullwidth'] = __('Hide (without sidebar)', 'themerex'); return $list; } // Return sidebar class function getSidebarClass($position) { if ($position == 'fullwidth') $class = 'without_sidebar'; else if ($position == 'left') $class = 'with_sidebar left_sidebar'; else $class = 'with_sidebar right_sidebar'; return $class; } // Return blog styles list, prepended default function getBlogStylesList($prepend_default=true) { $list = array(); if ($prepend_default) $list['default'] = __("Inherit", 'themerex'); $list['puzzles'] = __('Blog Puzzles', 'themerex'); $list['excerpt'] = __('Blog Excerpt', 'themerex'); $list['fullpost'] = __('Blog Fullpost', 'themerex'); return $list; } // Return themes list function getThemesList($prepend_default=true) { $list = array(); if ($prepend_default) $list['default'] = 'default'; $dir = get_template_directory() . "/css/themes"; if ( is_dir($dir) ) { $hdir = @ opendir( $dir ); if ( $hdir ) { while (($file = readdir( $hdir ) ) !== false ) { $pi = pathinfo( $dir . '/' . $file ); if ( substr($file, 0, 1) == '.' || is_dir( $dir . '/' . $file ) || $pi['extension'] != 'css' ) continue; $key = my_substr($file, 0, my_strrpos($file, '.')); $list[$key] = my_strtoproper(str_replace('_', ' ', $key)); } @closedir( $hdir ); } } return $list; } // Return socials list function getSocialsList($prepend_default=true) { $list = array(); if ($prepend_default) $list['default'] = 'default'; return array_merge($list, getListFiles("/images/socials", "png")); } // Return puzzles positions list function getPuzzlesList($prepend_default=true) { $list = array(); if ($prepend_default) $list['default'] = 'default'; return array_merge($list, getListFiles("/images/puzzles", "png")); } // Return list with 'Yes' and 'No' items function getYesNoList($prepend_default=true) { $list = array(); if ($prepend_default) $list['default'] = __("Inherit", 'themerex'); $list["yes"] = __("Yes", 'themerex'); $list["no"] = __("No", 'themerex'); return $list; } // Return list with 'Show' and 'Hide' items function getShowHideList($prepend_default=true) { $list = array(); if ($prepend_default) $list['default'] = __("Inherit", 'themerex'); $list["show"] = __("Show", 'themerex'); $list["hide"] = __("Hide", 'themerex'); return $list; } // Return post-format icon name (from Fontello library) function getPostFormatIcon($format) { $icon = 'icon-'; if ($format=='gallery') $icon .= 'camera'; else if ($format=='video') $icon .= 'video'; else if ($format=='audio') $icon .= 'note'; else if ($format=='image') $icon .= 'newspaper'; else if ($format=='quote') $icon .= 'quote'; else if ($format=='link') $icon .= 'link'; else if ($format=='status') $icon .= 'tag'; else if ($format=='aside') $icon .= 'book-open'; else if ($format=='chat') $icon .= 'list'; else $icon .= 'doc-text'; return $icon; } // Return Google fonts list function getFontsList($prepend_default=true) { $list = array(); if ($prepend_default) $list['default'] = 'default'; $list['Advent Pro'] = array('family'=>'sans-serif', 'link'=>'Advent+Pro:400,500,700'); $list['Arimo'] = array('family'=>'sans-serif', 'link'=>'Arimo:400,400italic,700,700italic'); $list['Asap'] = array('family'=>'sans-serif', 'link'=>'Asap:400,400italic,700,700italic'); $list['Averia Sans Libre'] = array('family'=>'cursive', 'link'=>'Averia+Sans+Libre:400,400italic,700,700italic'); $list['Averia Serif Libre'] = array('family'=>'cursive', 'link'=>'Averia+Serif+Libre:400,400italic,700,700italic'); $list['Cabin'] = array('family'=>'sans-serif', 'link'=>'Cabin:400,500,400italic,500italic,700,700italic'); $list['Cabin Condensed'] = array('family'=>'sans-serif', 'link'=>'Cabin+Condensed:400,500,700'); $list['Caudex'] = array('family'=>'serif', 'link'=>'Caudex:400,700,400italic,700italic'); $list['Comfortaa'] = array('family'=>'cursive', 'link'=>'Comfortaa:400,700'); $list['Cousine'] = array('family'=>'sans-serif', 'link'=>'Cousine:400,400italic,700,700italic'); $list['Crimson Text'] = array('family'=>'serif', 'link'=>'Crimson+Text:400,400italic,700italic,700'); $list['Cuprum'] = array('family'=>'sans-serif', 'link'=>'Cuprum:400,400italic,700,700italic'); $list['Dosis'] = array('family'=>'sans-serif', 'link'=>'Dosis:400,500,700'); $list['Economica'] = array('family'=>'sans-serif', 'link'=>'Economica:400,700'); $list['Exo'] = array('family'=>'sans-serif', 'link'=>'Exo:400,400italic,500,500italic,700,700italic'); $list['Expletus Sans'] = array('family'=>'cursive', 'link'=>'Expletus+Sans:400,500,400italic,500italic,700,700italic'); $list['Karla'] = array('family'=>'sans-serif', 'link'=>'Karla:400,400italic,700,700italic'); $list['Lato'] = array('family'=>'sans-serif', 'link'=>'Lato:400,400italic,700,700italic'); $list['Lekton'] = array('family'=>'sans-serif', 'link'=>'Lekton:400,700,400italic'); $list['Lobster Two'] = array('family'=>'cursive', 'link'=>'Lobster+Two:400,700,400italic,700italic'); $list['Maven Pro'] = array('family'=>'sans-serif', 'link'=>'Maven+Pro:400,500,700'); $list['Merriweather'] = array('family'=>'serif', 'link'=>'Merriweather:400,400italic,700,700italic'); $list['Neuton'] = array('family'=>'serif', 'link'=>'Neuton:400,400italic,700'); $list['Noticia Text'] = array('family'=>'serif', 'link'=>'Noticia+Text:400,400italic,700,700italic'); $list['Old Standard TT'] = array('family'=>'serif', 'link'=>'Old+Standard+TT:400,400italic,700'); $list['Open Sans'] = array('family'=>'sans-serif', 'link'=>'Open+Sans:400,700,400italic,700italic'); $list['Orbitron'] = array('family'=>'sans-serif', 'link'=>'Orbitron:400,500,700'); $list['Oswald'] = array('family'=>'sans-serif', 'link'=>'Oswald:400,700'); $list['Overlock'] = array('family'=>'cursive', 'link'=>'Overlock:400,700,400italic,700italic'); $list['Oxygen'] = array('family'=>'sans-serif', 'link'=>'Oxygen:400,700'); $list['PT Serif'] = array('family'=>'serif', 'link'=>'PT+Serif:400,400italic,700,700italic'); $list['Puritan'] = array('family'=>'sans-serif', 'link'=>'Puritan:400,400italic,700,700italic'); $list['Raleway'] = array('family'=>'sans-serif', 'link'=>'Raleway:400,500,700'); $list['Roboto'] = array('family'=>'sans-serif', 'link'=>'Roboto:400,400italic,500,700,500italic,700italic'); $list['Roboto Condensed'] = array('family'=>'sans-serif', 'link'=>'Roboto+Condensed:400,400italic,700,700italic'); $list['Rosario'] = array('family'=>'sans-serif', 'link'=>'Rosario:400,400italic,700,700italic'); $list['Share'] = array('family'=>'cursive', 'link'=>'Share:400,400italic,700,700italic'); $list['Signika Negative'] = array('family'=>'sans-serif', 'link'=>'Signika+Negative:400,700'); $list['Tinos'] = array('family'=>'serif', 'link'=>'Tinos:400,400italic,700,700italic'); $list['Ubuntu'] = array('family'=>'sans-serif', 'link'=>'Ubuntu:400,400italic,500,500italic,700,700italic'); $list['Vollkorn'] = array('family'=>'serif', 'link'=>'Vollkorn:400,400italic,700,700italic'); return $list; } /* ========================= Reviews ============================== */ // Get average review rating function getReviewsRatingAverage($marks) { $r = explode(',', $marks); $rez = 0; $cnt = 0; foreach ($r as $v) { $rez += $v; $cnt++; } return $cnt > 0 ? round($rez / $cnt, 1) : 0; } // Get word-value review rating function getReviewsRatingWordValue($r, $words = '') { if (trim($words) == '') $words = get_theme_option('reviews_criterias_levels'); $words = explode(',', __('no rated', 'themerex') . ',' . $words); $r = max(1, min(count($words), round($r))); return isset($words[$r-1]) ? trim($words[$r-1]) : __('no rated', 'themerex'); } /* ========================= Custom options ============================== */ // Return property value from theme custom > category custom > post custom > request parameters function get_custom_option($name, $defa=null, $post_id=0, $cat_id=0) { if ($cat_id > 0) { $rez = getCategoryInheritedProperty($cat_id, $name); if ($rez=='') $rez = get_theme_option($name, $defa); } else if ($post_id > 0) { $rez = get_theme_option($name, $defa); $custom_options = get_post_meta($post_id, 'post_custom_options', true); if (isset($custom_options[$name]) && $custom_options[$name]!='default') $rez = $custom_options[$name]; else { $categories = getCategoriesByPostId($post_id); $tmp = ''; for ($cc = 0; $cc < count($categories) && $tmp==''; $cc++) { $tmp = getCategoryInheritedProperty($categories[$cc]['term_id'], $name); } if ($tmp!='') $rez = $tmp; } } else { global $THEMEREX_post_options, $THEMEREX_cat_options, $THEMEREX_custom_options; if (isset($THEMEREX_custom_options[$name])) { $rez = $THEMEREX_custom_options[$name]; } else { $rez = get_theme_option($name, $defa); if (!is_single() && isset($THEMEREX_post_options[$name]) && (is_array($THEMEREX_post_options[$name]) ? $THEMEREX_post_options[$name][0] : $THEMEREX_post_options[$name])!='default') { $rez = is_array($THEMEREX_post_options[$name]) ? $THEMEREX_post_options[$name][0] : $THEMEREX_post_options[$name]; } if (isset($THEMEREX_cat_options[$name]) && $THEMEREX_cat_options[$name]!='default') { $rez = $THEMEREX_cat_options[$name]; } if (is_single() && isset($THEMEREX_post_options[$name]) && (is_array($THEMEREX_post_options[$name]) ? $THEMEREX_post_options[$name][0] : $THEMEREX_post_options[$name])!='default') { $rez = is_array($THEMEREX_post_options[$name]) ? $THEMEREX_post_options[$name][0] : $THEMEREX_post_options[$name]; } if (get_theme_option('show_theme_customizer') == 'yes') $rez = getValueGPC($name, $rez); $THEMEREX_custom_options[$name] = $rez; } } return $rez; } // Show theme specific fields in Post (and Page) options function show_custom_field($field, $value) { $output = ''; switch ($field['type']) { case 'reviews': $output .= getReviewsMarkup($field, $value); break; case 'mediamanager': wp_enqueue_media( ); $output .= '<a id="'.$field['id'].'" class="button mediamanager" data-choose="'.(isset($field['multiple']) && $field['multiple'] ? __( 'Choose Images', 'themerex') : __( 'Choose Image', 'themerex')).'" data-update="'.(isset($field['multiple']) && $field['multiple'] ? __( 'Add to Gallery', 'themerex') : __( 'Choose Image', 'themerex')).'" data-multiple="'.(isset($field['multiple']) && $field['multiple'] ? 'true' : 'false').'" data-linked-field="'.$field['media_field_id'].'" onclick="showMediaManager(this); return false;" >' . (isset($field['multiple']) && $field['multiple'] ? __( 'Choose Images', 'themerex') : __( 'Choose Image', 'themerex')) . '</a>'; break; } return $output; } // Return Reviews markup html-block function getReviewsMarkup($field, $value, $clear=false) { $output = ' <input type="hidden" name="reviews_id" class="reviews_id" value="'. $field['id'] . '" /> <input type="hidden" name="criterias_list" class="criterias_list" value="'. $field['options'] . '" /> <input type="hidden" name="marks_list" class="marks_list" value="'. $value . '" /> <div class="reviews_data"> '; $criterias = explode(',', $field['options']); $marks = explode(',', $value); for ($i=0; $i<count($criterias); $i++) { if (empty($criterias[$i])) continue; $sb = explode('|', $criterias[$i]); if (empty($sb[0])) continue; if (count($sb)==1) $sb[1] = $i+1; if (!isset($marks[$i]) || $marks[$i]=='') $marks[$i] = 0; $output .= ' <div class="criteria_row theme_field"> <input type="hidden" name="'.$field['id'].'
" value="'. ($clear ? 0 : $marks[$i]) . '" /> <span class="criteria_label theme_strong">'.$sb[0].'</span> <span class="criteria_stars"><span class="theme_stars" data-mark="1"></span><span class="theme_stars" data-mark="2"></span><span class="theme_stars" data-mark="3"></span><span class="theme_stars" data-mark="4"></span><span class="theme_stars" data-mark="5"></span></span> </div> '; } $avg = getReviewsRatingAverage($value); $output .= ' </div> <div class="reviews_summary blog_reviews"> <div class="criteria_summary_text criteria_row theme_field">'.(isset($field['descr']) ? $field['descr'] : '').'</div> <div class="criteria_summary criteria_row theme_field"> <span class="criteria_label theme_strong">'.__('Summary', 'themerex').'</span> ' . getReviewsSummaryStars($avg) . ' <span class="criteria_mark theme_accent_bg">'.$avg.(my_strlen($avg)==1 ? '.0' : '').'</span> <span class="criteria_word theme_accent_bg">'.getReviewsRatingWordValue($avg).'</span> </div> </div> '; return $output; } // Return Reviews summary stars html-block function getReviewsSummaryStars($avg) { return ' <span class="criteria_stars" title="'.$avg.'"> <span class="stars_off"><span class="theme_stars"></span><span class="theme_stars"></span><span class="theme_stars"></span><span class="theme_stars"></span><span class="theme_stars"></span></span> <span class="stars_on" style="width:'.($avg/5*100).'%;"><span class="theme_stars theme_stars_on"></span><span class="theme_stars theme_stars_on"></span><span class="theme_stars theme_stars_on"></span><span class="theme_stars theme_stars_on"></span><span class="theme_stars theme_stars_on"></span></span> </span> '; } ?>
Anonymous
Отправить
Ответ на: