Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Parent nav
- /* ------------------------------------ */
- function T20_add_current_nav_class($classes, $item) {
- if ( have_posts() ) {
- global $post;
- $current_post_type = get_post_type_object(get_post_type($post->ID));
- if ( !empty( $current_post_type ) ) {
- $current_post_type_slug = $current_post_type->rewrite['slug'];
- } else {
- $current_post_type_slug = false;
- }
- $menu_slug = strtolower(trim($item->url));
- if (strpos($menu_slug,$current_post_type_slug) !== false) {
- $classes[] = 'activated_parent selectedLava';
- }
- }
- return $classes;
- }
- add_action('nav_menu_css_class', 'T20_add_current_nav_class', 10, 2 );
- /* Radio steam data
- /* ------------------------------------ */
- add_action('wp_ajax_T20_nowplaying', 'T20_now_playing');
- add_action('wp_ajax_nopriv_T20_nowplaying', 'T20_now_playing');
- function T20_now_playing() {
- check_ajax_referer( 'T20_title', 'lannoncet' );
- $lanid = str_replace('"', '', json_encode($_POST['lanid']));
- $landid = str_replace('"', '', json_encode($_POST['landid']));
- $fp = @fsockopen($lanid,$landid,$errno,$errstr,1);
- if (empty($fp)) {
- echo 'Connection refused';
- } else {
- fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
- while (!feof($fp)) {
- $info = fgets($fp);
- }
- $info = str_replace('</body></html>', "", $info);
- $split = explode(',', $info);
- if (empty($split[6]) ) {
- echo 'The current song is not available';
- } else {
- $title = str_replace('\'', '`', $split[6]);
- $title = str_replace(',', ' ', $title);
- $title = str_replace('"', '', $title);
- echo json_encode($title);
- }
- }
- fclose($fp);
- die();
- }
- add_action('wp_ajax_T20_history', 'T20_get_history');
- add_action('wp_ajax_nopriv_T20_history', 'T20_get_history');
- function get_string_between($string, $start, $end) {
- $string = " " . $string;
- $ini = strpos($string, $start);
- if ($ini == 0)
- return "";
- $ini += strlen($start);
- $len = strpos($string, $end, $ini) - $ini;
- return substr($string, $ini, $len);
- }
- function T20_get_history() {
- check_ajax_referer( 'T20_history', 'lannonce' );
- $lanid = str_replace('"', '', json_encode($_POST['lanid']));
- $landid = str_replace('"', '', json_encode($_POST['landid']));
- if (!is_numeric($landid)) {
- echo "";
- exit;
- }
- $fp = @fsockopen($lanid,$landid,$errno,$errstr,1);
- if (!$fp) {
- echo "<div class='symple-box red'>Connection refused, the server appears to be offline.</div>";
- exit;
- } else {
- fputs($fp, "GET /played.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
- while (!feof($fp)) {
- $info = fgets($fp);
- }
- $content = get_string_between($info, "Admin Login</a></font></td></tr></table></td></tr></table><br>", "<br><br><table");
- $content = str_replace(array('<b>', '</b>'), array('<b class=\'current\'>', '</b>'), $content);
- $content = str_replace('Current Song', 'Current', $content);
- $content = str_replace('@', '', $content);
- echo $content;
- }
- fclose($fp);
- die();
- }
- add_action('wp_ajax_T20_getnewnonce', 'T20_get_getnewnonce');
- add_action('wp_ajax_nopriv_T20_getnewnonce', 'T20_get_getnewnonce');
- function T20_get_getnewnonce() {
- $getnewnonce = wp_create_nonce('T20_history');
- echo $getnewnonce;
- die();
- }
- /* Plays Count
- /* ------------------------------------ */
- if ( ! function_exists( 'ajax_favorite_plays' ) ) {
- function ajax_favorite_plays() {
- $ids = isset($_GET["vote_post_id"]) ? ($_GET["vote_post_id"]) : 0;
- if((int)$ids <= 0) die( 'Invalid Operation' );
- $plays_count = (int)get_post_meta((int)$ids, "ozy_post_plays_count", true);
- update_post_meta((int)$ids, "ozy_post_plays_count", $plays_count + 1);
- echo $plays_count + 1;
- exit();
- }
- add_action( 'wp_ajax_nopriv_ajax_favorite_plays', 'ajax_favorite_plays' );
- add_action( 'wp_ajax_ajax_favorite_plays', 'ajax_favorite_plays' );
- }
- /* Posts Taxonomies
- /* ------------------------------------ */
- add_action('pre_get_posts', 'T20_filter_press_tax');
- function T20_filter_press_tax( $query ){
- if( $query->is_tax('artist') ):
- $ppp_artists = ot_get_option('ppp_artists');
- $query->set('posts_per_page', $ppp_artists);
- return;
- endif;
- if( $query->is_tax('songs_cat') ):
- $ppp_songs = ot_get_option('ppp_songs');
- $query->set('posts_per_page', $ppp_songs);
- return;
- endif;
- if( $query->is_tax('videos_cat') ):
- $ppp_videos = ot_get_option('ppp_videos');
- $query->set('posts_per_page', $ppp_videos);
- return;
- endif;
- if( $query->is_tax('event_cat') ):
- $ppp_events = ot_get_option('ppp_events');
- $query->set('posts_per_page', $ppp_events);
- return;
- endif;
- if( $query->is_tax('gallery_cat') ):
- $ppp_gallery = ot_get_option('ppp_gallery');
- $query->set('posts_per_page', $ppp_gallery);
- return;
- endif;
- }
- /* Get artists
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_artist_name_link' ) ) {
- function T20_artist_name_link() {
- global $post;
- $output = '';
- $array = get_post_meta($post->ID,'artist_nameaa',true);
- if ($array) {
- if (is_array($array)) {
- $len = count($array);
- if ($len === 1) {
- $single_artist_id = implode(",", $array);
- $single_artist = get_post( $single_artist_id );
- $output .= '<a class="n_m" href="'.get_post_permalink($single_artist).'">'.( $single_artist->post_title ).'</a>';
- } else {
- $elements = array();
- foreach($array as $selectedOption) {
- $multiple_artist = get_post( $selectedOption );
- $elements[] = '<a class="n_m" href="'.get_post_permalink($multiple_artist).'">'.( $multiple_artist->post_title ).'</a>';
- }
- $output .= implode(', ', $elements);
- }
- } else {
- $single_artist = get_post( $array );
- $output .= '<a class="n_m" href="'.get_post_permalink($single_artist).'">'.( $single_artist->post_title ).'</a>';
- }
- }
- return $output;
- }
- }
- if ( ! function_exists( 'T20_artist_name' ) ) {
- function T20_artist_name() {
- global $post;
- $output = '';
- $array = get_post_meta($post->ID,'artist_nameaa',true);
- if ($array) {
- if (is_array($array)) {
- $len = count($array);
- if ($len === 1) {
- $single_artist_id = implode(",", $array);
- $single_artist = get_post( $single_artist_id );
- $output .= $single_artist->post_title;
- } else {
- $elements = array();
- foreach($array as $selectedOption) {
- $multiple_artist = get_post( $selectedOption );
- $elements[] = $multiple_artist->post_title;
- }
- $output .= implode(', ', $elements);
- }
- } else {
- $single_artist = get_post( $array );
- $output .= $single_artist->post_title;
- }
- }
- return $output;
- }
- }
- /* Archive and Tags page
- /* ------------------------------------ */
- add_filter('pre_get_posts', 'query_post_type');
- function query_post_type($query) {
- if(is_category() || is_tag()) {
- $post_type = get_query_var('post_type');
- if($post_type)
- $post_type = $post_type;
- else
- $post_type = array('post', 'songs', 'videos', 'gallery', 'events', 'nav_menu_item');
- $query->set('post_type',$post_type);
- return $query;
- }
- }
- /* RevolutionSlider
- /* ------------------------------------ */
- function T20_add_revslider_select_type( $array ) {
- $array['revslider-select'] = 'Revolution Slider Select';
- return $array;
- }
- add_filter( 'ot_option_types_array', 'T20_add_revslider_select_type' );
- function ot_type_revslider_select( $args = array() ) {
- extract( $args );
- $has_desc = $field_desc ? true : false;
- echo '<div class="format-setting type-revslider-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
- echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
- echo '<div class="format-setting-inner">';
- // Add This only if RevSlider is Activated
- if ( class_exists( 'RevSliderAdmin' ) ) {
- echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . $field_class . '">';
- /* get revolution array */
- $slider = new RevSlider();
- $arrSliders = $slider->getArrSlidersShort();
- /* has slides */
- if ( ! empty( $arrSliders ) ) {
- echo '<option value="">-- ' . __( 'Choose One', 'option-tree' ) . ' --</option>';
- foreach ( $arrSliders as $rev_id => $rev_slider ) {
- echo '<option value="' . esc_attr( $rev_id ) . '"' . selected( $field_value, $rev_id, false ) . '>' . esc_attr( $rev_slider ) . '</option>';
- }
- } else {
- echo '<option value="">' . __( 'No Sliders Found', 'option-tree' ) . '</option>';
- }
- echo '</select>';
- } else {
- echo '<span style="color: red;">' . __( 'Sorry! Revolution Slider is not Installed or Activated', 'T20' ). '</span>';
- }
- echo '</div>';
- echo '</div>';
- }
- /* MasterSlider
- /* ------------------------------------ */
- function T20_add_masterslider_select_type( $array ) {
- $array['masterslider-select'] = 'Master Slider Select';
- return $array;
- }
- add_filter( 'ot_option_types_array', 'T20_add_masterslider_select_type' );
- function ot_type_masterslider_select( $args = array() ) {
- extract( $args );
- $has_desc = $field_desc ? true : false;
- echo '<div class="format-setting type-masterslider-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
- echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
- echo '<div class="format-setting-inner">';
- // Add This only if masterslider is Activated
- if( class_exists( 'Master_Slider' ) ) {
- echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . $field_class . '">';
- global $mspdb;
- if ( $sliders_data = $mspdb->get_sliders_list( $limit = 0, $offset = 0, $orderby = 'ID', $sort = 'ASC' ) ) {
- echo '<option value="">-- ' . __( 'Choose One', 'option-tree' ) . ' --</option>';
- foreach ( $sliders_data as $slider_data ) {
- echo '<option value="' . esc_attr( $slider_data['ID'] ) . '"' . selected( $field_value, $slider_data['ID'], false ) . '>' . esc_attr( $slider_data['title'] ) . '</option>';
- }
- } else {
- echo '<option value="">' . __( 'No Sliders Found', 'option-tree' ) . '</option>';
- }
- echo '</select>';
- } else {
- echo '<span style="color: red;">' . __( 'Sorry! Master Slider is not Installed or Activated', 'T20' ). '</span>';
- }
- echo '</div>';
- echo '</div>';
- }
- // Current user data
- if ( ! function_exists( 'T20_user_data' ) ) {
- function T20_user_data() {
- global $current_user;
- get_currentuserinfo();
- if ( ot_get_option('login_btn') === 'on' ) {
- if(!is_user_logged_in()) {
- echo '<div id="Login_PopUp_Link" class="sign-btn tbutton small"><span>'.ot_get_option('login_signin').'</span></div>';
- } elseif (is_user_logged_in()) {
- echo '<div class="logged_in_user">';
- echo get_avatar( $current_user->user_email, 26 );
- echo $current_user->display_name;
- echo '</div>';
- }
- }
- }
- }
- // Login form
- if ( ! function_exists( 'T20_login_form' ) ) {
- function T20_login_form() {
- if ( ot_get_option('login_btn') === 'on' && !is_user_logged_in() ) { ?>
- <div id="popupLogin">
- <div class="def-block widget">
- <div class="login-form">
- <h4 class="login_title tt"> <?php echo ot_get_option('login_signin'); ?> </h4><span class="liner"></span>
- <form id="T20_login_form">
- <div class="login_error"></div>
- <input type="text" name="T20_username" id="T20_username" title="<?php echo ot_get_option('login_user'); ?>" placeholder="<?php echo ot_get_option('login_user'); ?>" />
- <input type="password" name="T20_password" id="T20_password" title="<?php echo ot_get_option('login_pass'); ?>" placeholder="<?php echo ot_get_option('login_pass'); ?>" />
- <input type="hidden" name="T20_nonce" id="T20_nonce" value="<?php echo wp_create_nonce('T20_nonce'); ?>" />
- <input type="submit" class="submit tbutton small hidden" value="<?php echo ot_get_option('login_signin'); ?>" />
- <a href="#" class="submit tbutton small"><span><?php echo ot_get_option('login_signin'); ?></span></a>
- <?php if ( ot_get_option('register_btn') !== 'of' ) {
- if ( ot_get_option('register_btn_link') ) { ?>
- <a href="<?php echo ot_get_option('register_btn_link'); ?>" class="tbutton color2 small"><span><?php echo ot_get_option('login_reg'); ?></span></a>
- <?php } else { ?>
- <a href="<?php echo site_url('/user-register/'); ?>" class="register_btn tbutton color2 small"><span><?php echo ot_get_option('login_reg'); ?></span></a>
- <?php }} ?>
- <?php if ( ot_get_option('login_lost_show') !== 'of' ) { ?><a href="<?php echo site_url('/user-forgot-password/'); ?>" class="lost_pass"><?php echo ot_get_option('login_lost'); ?> </a><?php } ?>
- <div class="login_load"><div class="loaderer loader-4"></div></div>
- </form>
- <?php if ( function_exists( 'wsl_activate' ) ) { do_action( 'wordpress_social_login' ); } ?>
- </div><!--/ login form-->
- <div class="forgot-form">
- <h4 class="login_title tt"> <?php echo ot_get_option('lost_pass_title'); ?> </h4><span class="liner"></span>
- <form id="forgot_password" class="ajax-auth" action="forgot_password" method="post">
- <div class="forgot_error"></div>
- <span><?php echo ot_get_option('lost_pass_desc'); ?></span>
- <?php wp_nonce_field('ajax-forgot-nonce', 'forgotsecurity'); ?>
- <input id="user_login" type="text" class="required" name="user_login" placeholder="<?php echo ot_get_option('lost_pass_placeholder'); ?>" title="<?php echo ot_get_option('lost_pass_placeholder'); ?>">
- <!-- <input class="submit_button" type="submit" value="SUBMIT"> -->
- <a href="#" class="submit tbutton small"><span><?php echo ot_get_option('lost_pass_button'); ?></span></a>
- <div class="login_load"><div class="loaderer loader-4"></div></div>
- <div class="forgot-close fa fa-angle-left"></div>
- </form>
- </div><!--/ forgot form-->
- <div class="register-form">
- <h4 class="login_title tt"> <?php echo ot_get_option('signup_title'); ?> </h4><span class="liner"></span>
- <form id="register" class="ajax-auth" action="register" method="post">
- <div class="register_error"></div>
- <?php wp_nonce_field('ajax-register-nonce', 'signonsecurity'); ?>
- <input id="remix_smaper" type="hidden" class="required remix_smaper" name="remix_smaper" value="" title="Number">
- <input id="signonname" type="text" name="signonname" class="required" placeholder="<?php echo ot_get_option('signup_name'); ?>" title="<?php echo ot_get_option('signup_name'); ?>">
- <input id="email" type="text" class="required email" name="email" placeholder="<?php echo ot_get_option('signup_email'); ?>" title="<?php echo ot_get_option('signup_email'); ?>">
- <!-- <input class="submit_button" type="submit" value="SIGNUP"> -->
- <a href="#" class="submit tbutton small"><span><?php echo ot_get_option('signup_button'); ?></span></a>
- <div class="login_load"><div class="loaderer loader-4"></div></div>
- <div class="forgot-close fa fa-angle-left"></div>
- </form>
- <?php if ( function_exists( 'wsl_activate' ) ) { do_action( 'wordpress_social_login' ); } ?>
- </div><!--/ register form-->
- </div><!-- widget -->
- <div id="popupLoginClose">x</div>
- </div><!-- popup login -->
- <div id="LoginBackgroundPopup"></div>
- <?php }
- if ( ot_get_option('login_btn') === 'on' && is_user_logged_in() ) { ?>
- <div id="popupLogin">
- <div class="def-block widget">
- <h4 class="login_title tt"> <?php global $current_user; get_currentuserinfo(); echo $current_user->display_name; ?> </h4><span class="liner"></span>
- <div><a href="<?php echo get_author_posts_url( $current_user->id ); ?>"><i class="fa fa-user mi"></i> <?php echo ot_get_option('your_profile'); ?></a></div>
- <div><a href="<?php echo site_url('/user-profile/'); ?>"><i class="fa fa-edit mi"></i> <?php echo ot_get_option('edit_your_profile'); ?></a></div>
- <div><a href="<?php echo wp_logout_url( home_url() ); ?>"><i class="fa fa-sign-out mi"></i> <?php echo ot_get_option('logout'); ?></a></div>
- </div>
- <div id="popupLoginClose">x</div>
- </div>
- <div id="LoginBackgroundPopup"></div>
- <?php }
- }
- }
- // Registration and lost password functions
- add_action( 'wp_ajax_nopriv_ajaxregister', 'ajax_register' );
- add_action( 'wp_ajax_nopriv_ajaxforgotpassword', 'ajax_forgotPassword' );
- function ajax_register(){
- // First check the nonce, if it fails the function will break
- check_ajax_referer( 'ajax-register-nonce', 'security' );
- if ( ! empty( $_POST['remix_smaper'] ) ){
- break;
- }
- // Nonce is checked, get the POST data and sign user on
- $info = array();
- $info['user_nicename'] = $info['nickname'] = $info['display_name'] = $info['first_name'] = $info['user_login'] = sanitize_user($_POST['username']) ;
- $info['user_pass'] = wp_generate_password();
- $info['user_email'] = sanitize_email( $_POST['email']);
- // Register the user
- $user_register = wp_insert_user( $info );
- if ( is_wp_error($user_register) ){
- $error = $user_register->get_error_codes() ;
- $e_div = '<div class="symple-box red">';
- $el_div = '</div>';
- $s_div = '<div class="symple-box green">';
- if(in_array('empty_user_login', $error))
- echo json_encode(array('loggedin'=>false, 'message'=>'<div class=\'symple-box red\'>'.$user_register->get_error_message('empty_user_login').'</div>'));
- elseif(in_array('existing_user_login',$error))
- echo json_encode(array('loggedin'=>false, 'message'=>'<div class=\'symple-box red\'>'.$user_register->get_error_message('existing_user_login').'</div>'));
- elseif(in_array('existing_user_email',$error))
- echo json_encode(array('loggedin'=>false, 'message'=>'<div class=\'symple-box red\'>'.$user_register->get_error_message('existing_user_email').'</div>'));
- } else {
- $random_password = wp_generate_password();
- $from = 'do-not-reply@'.preg_replace('/^www\./','',$_SERVER['SERVER_NAME']);
- $to = $info['user_email'];
- $subject = get_bloginfo('name'). ' - Registration successful';
- $sender = 'From: '.get_bloginfo('name').' <'.$from.'>' . "\r\n";
- $message = 'Your username: '.$info['user_nicename']. '<br />Your password: '.$random_password. '<br />Login page: <a href="'.get_site_url().'/user-login">'.get_site_url().'/user-login</a>';
- $headers[] = 'MIME-Version: 1.0' . "\r\n";
- $headers[] = 'Content-type: text/html; charset=UTF-8' . "\r\n";
- $headers[] = "X-Mailer: PHP \r\n";
- $headers[] = $sender;
- $mail = wp_mail( $to, $subject, $message, $headers );
- echo json_encode(array('loggedin'=>false, 'message'=>'<div class=\'symple-box green\'>'.ot_get_option('signup_successful').'</div>'));
- }
- die();
- }
- function ajax_forgotPassword(){
- // First check the nonce, if it fails the function will break
- check_ajax_referer( 'ajax-forgot-nonce', 'security' );
- global $wpdb;
- $account = $_POST['user_login'];
- $e_div = '<div class="symple-box red">';
- $el_div = '</div>';
- $s_div = '<div class="symple-box green">';
- if( empty( $account ) ) {
- $error = ot_get_option('lost_pass_error_a');
- } else {
- if(is_email( $account )) {
- if( email_exists($account) )
- $get_by = 'email';
- else
- $error = ot_get_option('lost_pass_error_b');
- }
- else if (validate_username( $account )) {
- if( username_exists($account) )
- $get_by = 'login';
- else
- $error = ot_get_option('lost_pass_error_c');
- }
- else
- $error = ot_get_option('lost_pass_error_d');
- }
- if(empty ($error)) {
- // lets generate our new password
- //$random_password = wp_generate_password( 12, false );
- $random_password = wp_generate_password();
- // Get user data by field and data, fields are id, slug, email and login
- $user = get_user_by( $get_by, $account );
- $update_user = wp_update_user( array ( 'ID' => $user->ID, 'user_pass' => $random_password ) );
- // if update user return true then lets send user an email containing the new password
- if( $update_user ) {
- $from = 'do-not-reply@'.preg_replace('/^www\./','',$_SERVER['SERVER_NAME']);
- $to = $user->user_email;
- $subject = 'Your new password';
- $sender = 'From: '.get_bloginfo('name').' <'.$from.'>' . "\r\n";
- $message = 'Your new password is : '.$random_password.'<br /><br /><a href="'.get_site_url().'/user-login">'.get_site_url().'/user-login</a>';
- $headers[] = 'MIME-Version: 1.0' . "\r\n";
- $headers[] = 'Content-type: text/html; charset=UTF-8' . "\r\n";
- $headers[] = "X-Mailer: PHP \r\n";
- $headers[] = $sender;
- $mail = wp_mail( $to, $subject, $message, $headers );
- if( $mail )
- $success = ot_get_option('lost_pass_error_g');
- else
- $error = ot_get_option('lost_pass_error_f');
- } else {
- $error = ot_get_option('lost_pass_error_e');
- }
- }
- if( ! empty( $error ) ) {
- echo json_encode(array('loggedin'=>false, 'message'=>$e_div.$error.$el_div));
- }
- if( ! empty( $success ) ) {
- echo json_encode(array('loggedin'=>false, 'message'=>$s_div.$success.$el_div));
- }
- die();
- }
- // Login
- add_action('wp_ajax_T20_login', 'T20_login');
- add_action('wp_ajax_nopriv_T20_login', 'T20_login');
- function T20_login() {
- check_ajax_referer( 'T20_nonce', 'nonce' );
- $creds = array();
- $creds['user_login'] = $_POST['username'];
- $creds['user_password'] = $_POST['password'];
- $creds['remember'] = true;
- $user = wp_signon( $creds, false );
- if ( is_wp_error( $user ) ) {
- echo '<div class="symple-box red">'.ot_get_option('login_error').'</div>';
- } else {
- echo '<div class="success"></div>';
- }
- die();
- }
- // Login-Logout Redirect
- add_filter('login_redirect', 'T20_login_url', 10, 3);
- function T20_login_url( $redirect_to, $request, $user ){
- return $request;
- }
- add_filter('logout_url', 'T20_logout_url', 10, 2);
- function T20_logout_url($logout_url, $redir) {
- return $logout_url.'&redirect_to='.urlencode(home_url());
- }
- /* Taxonomy
- /* ------------------------------------ */
- add_filter( 'wp_list_categories', 'T20_filter_categories' );
- function T20_filter_categories( $html ) {
- $html = preg_replace( '/cat-item\scat-item-(.?[0-9])\s/', '', $html );
- $html = preg_replace( '/current-cat/', 'current', $html );
- $html = preg_replace( '/\sclass="cat-item\scat-item-(.?[0-9])"/', '', $html );
- $html = preg_replace( '/\stitle="(.*?)"/', '', $html );
- $html = preg_replace( '/\sclass=\'children\'/', '', $html );
- return $html;
- }
- /* Walker Nav
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_description_walker' ) ) {
- class T20_description_walker extends Walker_Nav_Menu {
- function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
- global $wp_query;
- $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
- $class_names = $value = '';
- $classes = empty( $item->classes ) ? array() : (array) $item->classes;
- $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
- $class_names = ' class="'. esc_attr( $class_names ) . '"';
- $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
- $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
- $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
- $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
- $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
- $description = ! empty( $item->description ) ? '<span class="sub">'.esc_attr( $item->description ).'</span>' : '';
- /* if($depth != 0) { $description = $append = $prepend = ""; } */
- $item_output = $args->before;
- $item_output .= '<a'. $attributes .'>';
- $item_output .= $args->link_before .apply_filters( 'the_title', $item->title, $item->ID );
- $item_output .= $description.$args->link_after;
- $item_output .= '</a>';
- $item_output .= $args->after;
- $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args, $id );
- }
- }
- }
- add_filter('nav_menu_css_class' , 'T20_special_nav_class' , 10 , 2);
- function T20_special_nav_class($classes, $item){
- if( in_array('current-menu-item', $classes) ){
- $classes[] = 'current selectedLava';
- }
- return $classes;
- }
- /* Framework
- /* ------------------------------------ */
- add_filter( 'ot_show_pages', '__return_false' );
- add_filter( 'ot_show_new_layout', '__return_false' );
- add_filter( 'ot_theme_mode', '__return_true' );
- load_template( get_template_directory() . '/admin/optiontree/ot-loader.php' );
- add_filter( 'ot_type_date_time_picker_date_format', 'T20_date_format', 10, 2 );
- function T20_date_format( $format ) {
- return 'yymmdd';
- }
- function filter_demo_header_list() {
- echo '
- <li id="theme-version">
- <span><a href="http://themeforest.net/user/T20/portfolio?ref=T20" target="_blank"><i class="vcard_T20"></i>T20</a></span>
- <span><a href="http://theme20.com/kb" target="_blank"><i class="book_T20"></i>Knowledge base</a></span>
- <span><a href="http://theme20.com/support" target="_blank"><i class="lifebuoy_T20"></i>Support</a></span>
- <span><a href="https://www.facebook.com/theme20" target="_blank"><i class="facebook_T20"></i>Facebook</a></span>
- <span><a href="http://theme20.com/contact" target="_blank"><i class="user-add_T20"></i>Feature Request (SOON)</a></span>
- </li>
- ';
- }
- add_action( 'ot_header_list', 'filter_demo_header_list' );
- add_action('admin_head', 'T20_admin_head', 2);
- function T20_admin_head() {
- echo "<script type='text/javascript' src='" . get_template_directory_uri() . "/admin/assets/custom.js'></script>";
- echo "<link rel='stylesheet' id='css-T20-css' href='" . get_template_directory_uri() . "/admin/assets/style.css' type='text/css' media='all' />";
- }
- function main_options_save_ajax() {
- check_ajax_referer('_wpnonce', '_wpnonce' );
- $data = $_POST;
- unset($data['option_page'], $data['action'], $data['_wpnonce'], $data['_wp_http_referer']);
- if ( update_option('option_tree', $data ) ) {
- die(1);
- } else {
- die (0);
- }
- }
- add_action('wp_ajax_main_options_save', 'main_options_save_ajax' );
- /* Load files
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_load' ) ) {
- function T20_load() {
- load_theme_textdomain( 'T20', get_template_directory().'/languages' );
- load_template( get_template_directory() . '/admin/T20_options.php' );
- load_template( get_template_directory() . '/admin/T20_metaboxes.php' );
- if ( ot_get_option('wp_pagenavi') == 'on' ) {
- load_template( get_template_directory() . '/admin/T20_pagination.php' );
- }
- if ( ot_get_option('T20_breadcrumbs') !== 'of' ) {
- load_template( get_template_directory() . '/admin/T20_breadcrumbs.php' );
- }
- // widgets
- load_template( get_template_directory() . '/admin/widgets/T20-posts.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-facebook.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-instagram.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-social.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-subscribe.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-tabs.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-tabs-songs.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-weather.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-soundcloud.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-videos-slideshow.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-popular-songs.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-videos-list.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-event-timer.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-ads.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-events.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-flickr.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-songs-videos-by-artist.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-gallery.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-gallery-list.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-events-artist.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-events-past.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-list-custom-taxonomy.php' );
- load_template( get_template_directory() . '/admin/widgets/T20-general-posts.php' );
- // Register widgets
- register_widget('T20_Facebook_Widget');
- register_widget('T20_instagram');
- register_widget('T20_posts');
- register_widget('T20_social_widget');
- register_widget('T20_subscribe_widget');
- register_widget('T20_Tabs');
- register_widget('T20_Tabs_songs');
- register_widget('T20_weather');
- register_widget('T20_soundcloud');
- register_widget('T20_videos_slideshow');
- register_widget('T20_popular_songs');
- register_widget('T20_songs_videos_by_artist');
- register_widget('T20_videos_list');
- register_widget('T20_event_timer');
- register_widget('T20_events_artist');
- register_widget('T20_events_past');
- register_widget('T20_events');
- register_widget('T20_flickr');
- register_widget('T20_gallery');
- register_widget('T20_gallery_list');
- register_widget('T20_empty');
- register_widget('lc_taxonomy');
- // Dynamic styles
- load_template( get_template_directory() . '/admin/dynamic-styles.php' );
- // TGM
- load_template( get_template_directory() . '/admin/class-tgm-plugin-activation.php' );
- // Enable automatic feed links
- add_theme_support( 'automatic-feed-links' );
- // Content width
- if ( !isset( $content_width ) ) { $content_width = 1060; }
- // Enable featured image
- add_theme_support( 'post-thumbnails' );
- // Thumbnail sizes
- add_image_size( 'tumb', 85, 85, true ); // Thumbs
- add_image_size( 'medium_post', 200, 175, true ); // Post M
- add_image_size( 'big_post', 1000, 360, true ); // Post L
- add_image_size( 'cover', 500, 500, true ); // Cover Artist
- add_image_size( 'player_cover', 180, 180, true ); // Cover Player
- add_image_size( 'type_cover', 500, 360, true ); // Cover others
- add_image_size( 'masonry', 540, 9999 ); // Masonry
- add_image_size( 'flyer', 300, 352 ); // Event flyer
- add_filter('widget_text', 'do_shortcode');
- add_theme_support( 'woocommerce' );
- add_theme_support( 'bbpress' );
- }
- }
- add_action( 'after_setup_theme', 'T20_load' );
- /* Register sidebars
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_sidebars' ) ) {
- function T20_sidebars() {
- $before_widget = '<div id="%1$s" class="def-block widget %2$s">';
- $after_widget = '</div><!-- .widget /-->';
- $before_title = '<h4 class="tt">';
- $after_title = '</h4><span class="liner"></span>';
- register_sidebar(array( 'name' => __( 'Primary', 'T20' ),'id' => 'primary','description' => __( 'Primary Sidebar', 'T20' ), 'before_widget' => $before_widget,'after_widget' => $after_widget,'before_title' => $before_title,'after_title' => $after_title));
- register_sidebar(array( 'name' => __( 'Secondary', 'T20' ),'id' => 'secondary','description' => __( 'Secondary Sidebar', 'T20' ), 'before_widget' => $before_widget,'after_widget' => $after_widget,'before_title' => $before_title,'after_title' => $after_title));
- if ( ot_get_option('footer-widgets') >= '1' ) { register_sidebar(array( 'name' => __( 'Footer 1', 'T20' ),'id' => 'footer-1', 'description' => "Widetized footer column 1", 'before_widget' => $before_widget,'after_widget' => $after_widget,'before_title' => $before_title,'after_title' => $after_title)); }
- if ( ot_get_option('footer-widgets') >= '2' ) { register_sidebar(array( 'name' => __( 'Footer 2', 'T20' ),'id' => 'footer-2', 'description' => "Widetized footer column 2", 'before_widget' => $before_widget,'after_widget' => $after_widget,'before_title' => $before_title,'after_title' => $after_title)); }
- if ( ot_get_option('footer-widgets') >= '3' ) { register_sidebar(array( 'name' => __( 'Footer 3', 'T20' ),'id' => 'footer-3', 'description' => "Widetized footer column 3", 'before_widget' => $before_widget,'after_widget' => $after_widget,'before_title' => $before_title,'after_title' => $after_title)); }
- if ( ot_get_option('footer-widgets') >= '4' ) { register_sidebar(array( 'name' => __( 'Footer 4', 'T20' ),'id' => 'footer-4', 'description' => "Widetized footer column 4", 'before_widget' => $before_widget,'after_widget' => $after_widget,'before_title' => $before_title,'after_title' => $after_title)); }
- }
- }
- add_action( 'widgets_init', 'T20_sidebars' );
- /* Span to Category Widget
- /* ------------------------------------ */
- add_filter('wp_list_categories', 'T20_add_span_cat_count');
- function T20_add_span_cat_count($links) {
- $links = str_replace('</a> (', '</a><span>(', $links);
- $links = str_replace(')', ')</span>', $links);
- return $links;
- }
- /* Span to Archives Widget
- /* ------------------------------------ */
- add_filter('get_archives_link', 'archive_count_no_brackets');
- function archive_count_no_brackets($links) {
- $links = str_replace('</a> (', '</a><span>(', $links);
- $links = str_replace(')', ')</span>', $links);
- return $links;
- }
- /* Gallery
- /* ------------------------------------ */
- add_filter( 'wp_get_attachment_link', 'sant_prettyadd');
- function sant_prettyadd ($content) {
- $content = preg_replace("/<a/","<a data-gal=\"photo[Gallery]\"",$content,1);
- return $content;
- }
- /* Register custom sidebars
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_custom_sidebars' ) ) {
- function T20_custom_sidebars() {
- if ( !ot_get_option('sidebar-areas') =='' ) {
- $sidebars = ot_get_option('sidebar-areas', array());
- $before_widget = '<div id="%1$s" class="def-block widget %2$s">';
- $after_widget = '</div><!-- .widget/-->';
- $before_title = '<h4 class="tt">';
- $after_title = '</h4><span class="liner"></span>';
- if ( !empty( $sidebars ) ) {
- foreach( $sidebars as $sidebar ) {
- if ( isset($sidebar['title']) && !empty($sidebar['title']) && isset($sidebar['id']) && !empty($sidebar['id']) && ($sidebar['id'] !='sidebar-') ) {
- register_sidebar(array('name' => ''.$sidebar['title'].'','id' => ''.strtolower($sidebar['id']).'','before_widget' => $before_widget,'after_widget' => $after_widget,'before_title' => $before_title,'after_title' => $after_title));
- }
- }
- }
- }
- }
- }
- add_action( 'widgets_init', 'T20_custom_sidebars' );
- /* Dynamic sidebar primary
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_sidebar_primary' ) ) {
- function T20_sidebar_primary() {
- $s_p = 'primary';
- if ( !is_tax() || !is_search() ) {
- global $post;
- $post_type = get_post_type( get_the_ID() );
- if ( $post_type === 'post' ) {
- $post_type = 'none';
- }
- } else {
- $post_type = is_post_type_archive( 'artists' );
- }
- // Check for specific sidebar
- if ( is_page() || is_single() ) {
- // Reset post data
- wp_reset_postdata();
- global $post;
- // Get meta
- $metapp = get_post_meta($post->ID,'_sidebar_primary',true);
- if ( $metapp ) { $s_p = $metapp; }
- }
- elseif ( is_tax('artist') ) {
- $s_p = ot_get_option('artists_p');
- if ( $s_p === '' ) { $s_p = 'primary'; }
- }
- elseif ( $post_type === get_post_type() ) {
- $s_p = ot_get_option($post_type.'_p');
- if ( $s_p === '' ) { $s_p = 'primary'; }
- }
- if( is_tax('songs_cat') ) {
- $s_p = ot_get_option('songs_p');
- if ( $s_p === '' ) { $s_p = 'primary'; }
- }
- if( is_tax('videos_cat') ) {
- $s_p = ot_get_option('videos_p');
- if ( $s_p === '' ) { $s_p = 'primary'; }
- }
- // Return sidebar
- return $s_p;
- }
- }
- /* Dynamic sidebar secondary
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_sidebar_secondary' ) ) {
- function T20_sidebar_secondary() {
- $s_s = 'secondary';
- if ( !is_tax() || !is_search() ) {
- global $post;
- $post_type = get_post_type( get_the_ID() );
- if ( $post_type === 'post' ) {
- $post_type = 'none';
- }
- } else {
- $post_type = is_post_type_archive( 'artists' );
- }
- // Check for specific sidebar
- if ( is_page() || is_single() ) {
- // Reset post data
- wp_reset_postdata();
- global $post;
- // Get meta
- $metass = get_post_meta($post->ID,'_sidebar_secondary',true);
- if ( $metass ) { $s_s = $metass; }
- }
- elseif ( is_tax('artist') ) {
- $s_s = ot_get_option('artists_s');
- if ( $s_s === '' ) { $s_s = 'secondary'; }
- }
- elseif ( $post_type === get_post_type() ) {
- $s_s = ot_get_option($post_type.'_s');
- if ( $s_s === '' ) { $s_s = 'secondary'; }
- }
- if( is_tax('songs_cat') ) {
- $s_s = ot_get_option('songs_s');
- if ( $s_s === '' ) { $s_p = 'primary'; }
- }
- if( is_tax('videos_cat') ) {
- $s_s = ot_get_option('videos_s');
- if ( $s_s === '' ) { $s_s = 'primary'; }
- }
- // Return sidebar
- return $s_s;
- }
- }
- /* Sidebar bbpress
- /* ------------------------------------ */
- if ( ! function_exists( 'bbp_primary' ) ) {
- function bbp_primary() {
- $bbp_p = 'primary';
- if ( ot_get_option('bbp_primary') ) {
- $bbp_p = ot_get_option('bbp_primary');
- }
- return $bbp_p;
- }
- }
- if ( ! function_exists( 'bbp_secondary' ) ) {
- function bbp_secondary() {
- $bbp_s = 'secondary';
- if ( ot_get_option('bbp_secondary') ) {
- $bbp_s = ot_get_option('bbp_secondary');
- }
- return $bbp_s;
- }
- }
- /* Author Social
- /* ------------------------------------ */
- function eff_show_extra_profile_fields( $contactmethods ) {
- $contactmethods['facebook'] = 'FaceBook URL';
- $contactmethods['twitter'] = 'Twitter URL';
- $contactmethods['dribbble'] = 'Dribbble URL';
- $contactmethods['github'] = 'Github URL';
- $contactmethods['instagram'] = 'Instagram URL';
- $contactmethods['linkedin'] = 'Linkedin URL';
- $contactmethods['pinterest'] = 'Pinterest URL';
- $contactmethods['googleplus'] = 'Google Plus URL';
- $contactmethods['foursquare'] = 'Foursquare URL';
- $contactmethods['skype'] = 'Skype URL';
- $contactmethods['cloud'] = 'Soundcloud URL';
- $contactmethods['youtube'] = 'Youtube URL';
- $contactmethods['tumblr'] = 'Tumblr URL';
- $contactmethods['star'] = 'Reverbnation URL';
- $contactmethods['flickr'] = 'Flickr URL';
- $contactmethods['envelope'] = 'Contact Address';
- return $contactmethods;
- }
- add_filter('user_contactmethods','eff_show_extra_profile_fields',10,1);
- add_action( 'personal_options_update', 'eff_save_extra_profile_fields' );
- add_action( 'edit_user_profile_update', 'eff_save_extra_profile_fields' );
- function eff_save_extra_profile_fields( $user_id ) {
- if ( !current_user_can( 'edit_user', $user_id ) ) return false;
- update_user_meta( $user_id, 'facebook', $_POST['facebook'] );
- update_user_meta( $user_id, 'twitter', $_POST['twitter'] );
- update_user_meta( $user_id, 'dribbble', $_POST['dribbble'] );
- update_user_meta( $user_id, 'github', $_POST['github'] );
- update_user_meta( $user_id, 'instagram', $_POST['instagram'] );
- update_user_meta( $user_id, 'linkedin', $_POST['linkedin'] );
- update_user_meta( $user_id, 'pinterest', $_POST['pinterest'] );
- update_user_meta( $user_id, 'googleplus', $_POST['googleplus'] );
- update_user_meta( $user_id, 'foursquare', $_POST['foursquare'] );
- update_user_meta( $user_id, 'skype', $_POST['skype'] );
- update_user_meta( $user_id, 'cloud', $_POST['cloud'] );
- update_user_meta( $user_id, 'youtube', $_POST['youtube'] );
- update_user_meta( $user_id, 'tumblr', $_POST['tumblr'] );
- update_user_meta( $user_id, 'star', $_POST['star'] );
- update_user_meta( $user_id, 'flickr', $_POST['flickr'] );
- update_user_meta( $user_id, 'envelope', $_POST['envelope'] );
- }
- add_filter('user_contactmethods','hide_profile_fields',10,1);
- function hide_profile_fields( $contactmethods ) {
- unset($contactmethods['aim']);
- unset($contactmethods['jabber']);
- unset($contactmethods['yim']);
- return $contactmethods;
- }
- /* Social links
- /* ------------------------------------------------------------------------------------------- */
- if ( ! function_exists( 'T20_social_links' ) ) {
- function T20_social_links() {
- if ( !ot_get_option('social-links') =='' ) {
- $links = ot_get_option('social-links', array());
- if ( !empty( $links ) ) {
- $social_color = $social_circle = '';
- if ( ot_get_option('social_color') === 'on' ) {
- $social_color = 'with_color';
- }
- if ( ot_get_option('social_circle') === 'on' ) {
- $social_circle = 'social_circle';
- }
- if ( ot_get_option('social_position') === 'fixed_left') {
- $tooltip = 'righttip';
- } else if ( ot_get_option('social_position') === 'fixed_right') {
- $tooltip = 'lefttip';
- } else {
- $tooltip = 'bottomtip';
- }
- echo '<div class="social social-head ' . $social_color . ' ' . $social_circle . ' ' . ot_get_option('social_position') . '">';
- foreach( $links as $item ) {
- // Build each separate html-section only if set
- if ( isset($item['title']) && !empty($item['title']) )
- { $title = 'title="' .$item['title']. '"'; } else $title = '';
- if ( isset($item['social-link']) && !empty($item['social-link']) )
- { $link = 'href="' .$item['social-link']. '"'; } else $link = '';
- if ( isset($item['social-icon']) && !empty($item['social-icon']) )
- { $icon = 'class="fa ' .$item['social-icon']. '"'; } else $icon = '';
- // Put them together
- if ( isset($item['title']) && !empty($item['title']) && isset($item['social-icon']) && !empty($item['social-icon']) && ($item['social-icon'] !='fa-') ) {
- echo '<a rel="nofollow" class="'.$tooltip.'" '.$title.' '.$link.' target="_blank"><i '.$icon.'></i></a>';
- }
- }
- echo '</div>';
- }
- }
- }
- }
- /* Site name/logo
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_site_title' ) ) {
- function T20_site_title() {
- if ( ot_get_option('custom-logo') ) {
- $logo = '<div class="logo tt_logo bottomtip" title="'.get_bloginfo('description').'"><a href="'.home_url('/').'" rel="home"><img src="'.ot_get_option('custom-logo').'" alt="'.get_bloginfo('name').'" width="'.ot_get_option('logo_width').'" height="'.ot_get_option('logo_height').'"></a></div>';
- } else {
- $logo = '<div class="logo tt_text bottomtip" title="'.get_bloginfo('description').'"><h1><a class="text_logo" href="'.home_url('/').'" rel="home">'.get_bloginfo('name').'</a></h1></div>';
- }
- $sitename = $logo;
- return $sitename;
- }
- }
- /* Related posts
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_related_posts' ) ) {
- function T20_related_posts() {
- wp_reset_postdata();
- global $post;
- // Define shared post arguments
- $args = array(
- 'post_type' => 'post',
- 'no_found_rows' => true,
- 'update_post_meta_cache' => false,
- 'update_post_term_cache' => false,
- 'ignore_sticky_posts' => 1,
- 'orderby' => 'rand',
- 'post__not_in' => array($post->ID),
- 'posts_per_page' => ot_get_option('related_posts_num')
- );
- // Related by categories
- if ( ot_get_option('related-posts') == 'categories' ) {
- $cats = get_post_meta($post->ID, 'related-cat', true);
- if ( !$cats ) {
- $cats = wp_get_post_categories($post->ID, array('fields'=>'ids'));
- $args['category__in'] = $cats;
- } else {
- $args['cat'] = $cats;
- }
- }
- // Related by tags
- if ( ot_get_option('related-posts') == 'tags' ) {
- $tags = get_post_meta($post->ID, 'related-tag', true);
- if ( !$tags ) {
- $tags = wp_get_post_tags($post->ID, array('fields'=>'ids'));
- $args['tag__in'] = $tags;
- } else {
- $args['tag_slug__in'] = explode(',', $tags);
- }
- if ( !$tags ) { $break = true; }
- }
- $query = !isset($break)?new WP_Query($args):new WP_Query;
- return $query;
- }
- }
- /* Related Artist Songs
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_related_artist_songs' ) ) {
- function T20_related_artist_songs() {
- wp_reset_postdata();
- global $post;
- $get_arraysss = array($post->ID);
- $meta_query = array('relation' => 'OR');
- if (is_array($get_arraysss)) {
- foreach ( $get_arraysss as $value ) {
- $meta_query[] = array( 'key' => 'artist_nameaa', 'value' => $post->ID, 'compare' => 'LIKE' );
- }
- }
- $args = array(
- 'post_type' => 'songs',
- 'meta_query' => $meta_query,
- 'no_found_rows' => true,
- 'update_post_meta_cache' => false,
- 'update_post_term_cache' => false,
- 'ignore_sticky_posts' => 1,
- 'post__not_in' => array($post->ID),
- 'posts_per_page' => -1
- );
- $query = new WP_Query($args);
- return $query;
- }
- }
- /* Related Artist Videos
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_related_artist_videos' ) ) {
- function T20_related_artist_videos() {
- wp_reset_postdata();
- global $post;
- $get_arraysss = array($post->ID);
- $meta_query = array('relation' => 'OR');
- if (is_array($get_arraysss)) {
- foreach ( $get_arraysss as $value ) {
- $meta_query[] = array( 'key' => 'artist_nameaa', 'value' => $post->ID, 'compare' => 'LIKE' );
- }
- }
- $args = array(
- 'post_type' => 'videos',
- 'meta_query' => $meta_query,
- 'no_found_rows' => true,
- 'update_post_meta_cache' => false,
- 'update_post_term_cache' => false,
- 'ignore_sticky_posts' => 1,
- 'post__not_in' => array($post->ID),
- 'posts_per_page' => -1
- );
- $query = new WP_Query($args);
- return $query;
- }
- }
- /* Related Songs pages
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_related_songs' ) ) {
- function T20_related_songs() {
- wp_reset_postdata();
- global $post;
- if ( ot_get_option('songs_related') === 'tags' ) {
- $tags = wp_get_post_tags($post->ID);
- $tag_ids = array();
- foreach($tags as $individual_tag) { $tag_ids[] = $individual_tag->term_id; }
- $args = array(
- 'post_type' => 'songs',
- 'tax_query' => array(
- array(
- 'taxonomy' => 'post_tag',
- 'field' => 'id',
- 'terms' => $tag_ids
- )
- ),
- 'no_found_rows' => true,
- 'update_post_meta_cache' => false,
- 'update_post_term_cache' => false,
- 'ignore_sticky_posts' => 1,
- 'post__not_in' => array($post->ID),
- 'posts_per_page' => ot_get_option('songs_related_num')
- );
- } elseif ( ot_get_option('songs_related') === 'artist' ) {
- $get_arraysss = get_post_meta($post->ID, 'artist_nameaa', true);
- $meta_query = array('relation' => 'OR');
- if (is_array($get_arraysss)) {
- foreach ( $get_arraysss as $value ) {
- $meta_query[] = array( 'key' => 'artist_nameaa', 'value' => $value, 'compare' => 'LIKE' );
- }
- } else if (!empty($get_arraysss)) {
- $meta_query = array(array( 'key' => 'artist_nameaa', 'value' => $get_arraysss, 'compare' => 'LIKE' ));
- } else {
- $meta_query = array(array( 'key' => 'artist_nameaa', 'value' => 'UNKNOWN', 'compare' => 'LIKE' ));
- }
- $args = array(
- 'post_type' => array('songs'),
- 'meta_query' => $meta_query,
- 'post__not_in' => array($post->ID),
- 'posts_per_page' => ot_get_option('songs_related_num')
- );
- } elseif ( ot_get_option('songs_related') === 'random' ) {
- $args = array(
- 'post_type' => array('songs'),
- 'no_found_rows' => true,
- 'update_post_meta_cache' => false,
- 'update_post_term_cache' => false,
- 'ignore_sticky_posts' => 1,
- 'orderby' => 'rand',
- 'post__not_in' => array($post->ID),
- 'posts_per_page' => ot_get_option('songs_related_num')
- );
- }
- $query = new WP_Query($args);
- return $query;
- }
- }
- /* Related Videos pages
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_related_videos' ) ) {
- function T20_related_videos() {
- wp_reset_postdata();
- global $post;
- if ( ot_get_option('videos_related') === 'tags' ) {
- $tags = wp_get_post_tags($post->ID);
- $tag_ids = array();
- foreach($tags as $individual_tag) { $tag_ids[] = $individual_tag->term_id; }
- $args = array(
- 'post_type' => 'videos',
- 'tax_query' => array(
- array(
- 'taxonomy' => 'post_tag',
- 'field' => 'id',
- 'terms' => $tag_ids
- )
- ),
- 'no_found_rows' => true,
- 'update_post_meta_cache' => false,
- 'update_post_term_cache' => false,
- 'ignore_sticky_posts' => 1,
- 'post__not_in' => array($post->ID),
- 'posts_per_page' => ot_get_option('videos_related_num')
- );
- } elseif ( ot_get_option('videos_related') === 'artist' ) {
- $get_arraysss = get_post_meta($post->ID, 'artist_nameaa', true);
- $meta_query = array('relation' => 'OR');
- if (is_array($get_arraysss)) {
- foreach ( $get_arraysss as $value ) {
- $meta_query[] = array( 'key' => 'artist_nameaa', 'value' => $value, 'compare' => 'LIKE' );
- }
- } else if (!empty($get_arraysss)) {
- $meta_query = array(array( 'key' => 'artist_nameaa', 'value' => $get_arraysss, 'compare' => 'LIKE' ));
- } else {
- $meta_query = array(array( 'key' => 'artist_nameaa', 'value' => 'UNKNOWN', 'compare' => 'LIKE' ));
- }
- $args = array(
- 'post_type' => array('videos'),
- 'meta_query' => $meta_query,
- 'no_found_rows' => true,
- 'update_post_meta_cache' => false,
- 'update_post_term_cache' => false,
- 'ignore_sticky_posts' => 1,
- 'post__not_in' => array($post->ID),
- 'posts_per_page' => ot_get_option('videos_related_num')
- );
- } elseif ( ot_get_option('videos_related') === 'random' ) {
- $args = array(
- 'post_type' => array('videos'),
- 'no_found_rows' => true,
- 'update_post_meta_cache' => false,
- 'update_post_term_cache' => false,
- 'ignore_sticky_posts' => 1,
- 'orderby' => 'rand',
- 'post__not_in' => array($post->ID),
- 'posts_per_page' => ot_get_option('videos_related_num')
- );
- }
- $query = new WP_Query($args);
- return $query;
- }
- }
- /* Alphabet Artists
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_alphabet' ) ) {
- function T20_alphabet() {
- if ( ot_get_option('artists_slug') ) { $slug = ot_get_option('artists_slug'); } else { $slug = 'artists'; }
- $customPostTaxonomies = get_object_taxonomies('artists');
- if(count($customPostTaxonomies) > 0){ ?>
- <div class="clearfix mb">
- <div class="Alphabet"><ul>
- <?php if (ot_get_option('alphabet_browseall')) { ?>
- <li><a href="<?php echo home_url(); ?>/<?php echo $slug; ?>/"><?php echo ot_get_option('alphabet_browseall'); ?></a></li>
- <?php } ?>
- <?php foreach($customPostTaxonomies as $tax){
- $args = array(
- 'orderby' => 'name',
- 'show_count' => 0,
- 'hide_empty' => 0,
- 'pad_counts' => 0,
- 'depth' => 1,
- 'hierarchical' => 1,
- 'taxonomy' => $tax,
- 'title_li' => ''
- );
- wp_list_categories( $args );
- } ?>
- <ul></div><!--/Alphabet-->
- </div><!--/clearfix-->
- <?php }
- }
- }
- /* Plays Count
- /* ------------------------------------ */
- function plays_count() {
- global $post;
- if ( get_post_meta($post->ID,'ozy_post_plays_count', true) ) {
- $plays = get_post_meta($post->ID,'ozy_post_plays_count', true);
- if ( $plays < 2 ) {
- $plays_w = ' '.ot_get_option('n_play');
- } else {
- $plays_w = ' '.ot_get_option('n_plays');
- }
- } else {
- $plays = '0';
- $plays_w = ' '.ot_get_option('n_play');
- }
- echo '<span class="plays">'.number_format($plays).$plays_w.'</span>';
- }
- /* Get images attached
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_post_images' ) ) {
- function T20_post_images( $args=array() ) {
- global $post;
- $defaults = array(
- 'numberposts' => -1,
- 'order' => 'ASC',
- 'orderby' => 'menu_order',
- 'post_mime_type' => 'image',
- 'post_parent' => $post->ID,
- 'post_type' => 'attachment',
- );
- $args = wp_parse_args( $args, $defaults );
- return get_posts( $args );
- }
- }
- /* Site title
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_wp_title' ) ) {
- function T20_wp_title( $title ) {
- // Do not filter for RSS feed / if SEO plugin installed
- if ( is_feed() || class_exists('All_in_One_SEO_Pack') || class_exists('HeadSpace_Plugin') || class_exists('Platinum_SEO_Pack') || class_exists('wpSEO') || defined('WPSEO_VERSION') )
- return $title;
- if ( is_front_page() ) {
- $title = bloginfo('name'); echo ' - '; bloginfo('description');
- }
- if ( !is_front_page() ) {
- $title.= ''.''.''.get_bloginfo('name');
- }
- return $title;
- }
- }
- add_filter( 'wp_title', 'T20_wp_title' );
- /* Custom rss feed
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_feed_link' ) ) {
- function T20_feed_link( $output, $feed ) {
- // Do not redirect comments feed
- if ( strpos( $output, 'comments' ) )
- return $output;
- // Return feed url
- return ot_get_option('rss-feed',$output);
- }
- }
- add_filter( 'feed_link', 'T20_feed_link', 10, 2 );
- function gen_meta_desc() {
- global $post;
- if ( ! is_singular() ) {
- return;
- }
- $meta = strip_tags( $post->post_content );
- $meta = str_replace( array( "\\n", "\\r", "\\t" ), ' ', $meta);
- $meta = substr( $meta, 0, 125 );
- if ( $meta !== '' ) {
- $meta = get_bloginfo('name');
- }
- return $meta;
- }
- /* Custom Code and CSS
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_custom_codes' ) ) {
- function T20_custom_codes() {
- global $post;
- if ( ot_get_option('custom-codes-head') ) {
- echo ot_get_option('custom-codes-head')."\n";
- }
- if ( ot_get_option('favicon') ) {
- echo '<link rel="shortcut icon" href="'.ot_get_option('favicon').'" />'."\n";
- }
- if ( ot_get_option('apple-touch') ) {
- echo '<link rel="apple-touch-icon" href="'.ot_get_option('apple-touch').'">'."\n";
- }
- if ( ot_get_option( 'meta_desc' ) ) {
- if ( is_single() ) { ?>
- <meta name="description" content='<?php echo gen_meta_desc(); ?>' />
- <meta property="og:description" content="<?php echo gen_meta_desc(); ?>"/>
- <?php } else { ?>
- <meta name="description" content="<?php echo ot_get_option( 'meta_desc' ); ?>">
- <meta property="og:description" content="<?php echo ot_get_option( 'meta_desc' ); ?>"/>
- <?php }
- }
- if ( ot_get_option( 'meta_key' ) ) {
- global $post;
- if ( is_single() ) {
- $tags = get_the_tags($post->ID);
- $keywords = '';
- if($tags) {
- foreach($tags as $tag) :
- $sep = (empty($keywords)) ? '' : ', ';
- $keywords .= $sep . $tag->name;
- endforeach;
- ?>
- <meta name="keywords" content="<?php echo $keywords; ?>" />
- <?php }
- } else { ?>
- <meta name="keywords" content="<?php echo ot_get_option( 'meta_key' ); ?>">
- <?php }
- }
- if ( !ot_get_option('meta_generator') ) {
- $meta_generator = ot_get_option('meta_generator', array());
- if ( !empty( $meta_generator ) ) {
- foreach( $meta_generator as $item ) {
- if ( isset($item['title']) && !empty($item['title']) )
- { $meta_title = $item['title']; } else $meta_title = '';
- if ( isset($item['content']) && !empty($item['content']) )
- { $meta_content = $item['content']; } else $meta_content = '';
- if ( isset($item['title']) && !empty($item['title']) && isset($item['content']) && !empty($item['content']) ) {
- echo '<meta name="'.$meta_title.'" content="'.$meta_content.'">';
- }
- }
- }
- }
- if ( ot_get_option( 'fb_admin' ) ) {
- if ( is_single() ) {
- global $post;
- $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full', false, '' ); ?>
- <link rel="image_src" href="<?php echo $src[0]; ?>"/>
- <meta property="og:image" content="<?php echo $src[0]; ?>"/>
- <meta name="twitter:image:src" content="<?php echo $src[0]; ?>">
- <?php }
- if ( !is_home() && !is_front_page() ) { ?><meta property="og:url" content="<?php the_permalink(); ?>" /><?php }
- if( get_post_type() && !is_home() && !is_front_page() ){
- if ( get_post_type() !== 'songs' ) { ?><meta property="og:type" content="<?php echo get_bloginfo('name'); ?>:<?php echo get_post_type( get_the_ID() ); ?>"/><?php } ?>
- <meta property="og:site_name" content="<?php echo get_bloginfo('name'); ?>"/>
- <meta property="og:title" content="<?php echo the_title(); ?>"/>
- <meta name="twitter:title" content="<?php echo the_title(); ?>"/>
- <?php }
- if( is_singular('videos') ){
- global $post;
- $youtube_id = get_post_meta($post->ID,'youtube_id',true);
- $vimeo_id = get_post_meta($post->ID,'vimeo_id',true);
- $video_code = get_post_meta($post->ID,'video_code',true);
- if ( $youtube_id ) { ?>
- <link rel="video_src" href="//www.youtube.com/embed/<?php echo $youtube_id; ?>"/>
- <meta property="og:video:url" content="//www.youtube.com/embed/<?php echo $youtube_id; ?>" />
- <?php } if ( $vimeo_id ) { ?>
- <link rel="video_src" href="//player.vimeo.com/video/<?php echo $vimeo_id; ?>"/>
- <meta property="og:video:url" content="//player.vimeo.com/video/<?php echo $vimeo_id; ?>" />
- <?php } ?>
- <meta property="og:video:width" content="200" />
- <meta property="og:video:height" content="200" />
- <meta property="og:video:type" content="video/mp4" />
- <?php }
- if( is_singular('songs') ){
- $songs_playlist = get_post_meta($post->ID, 'playlist', true);
- if( $songs_playlist ){
- $first = true;
- foreach ( $songs_playlist as $v ) {
- if ( $first ) {
- $first_song = $v['mp3'];
- $first = false;
- }
- }
- if ( get_post_meta($post->ID, 'rx_player', true) !== 'custom_player' ) { ?>
- <meta property="og:type" content="music.album"/>
- <meta property="og:audio" content="<?php echo $first_song; ?>" />
- <meta property="og:audio:type" content="audio/vnd.facebook.bridge" />
- <meta property="music:song" content="<?php echo $first_song; ?>" />
- <meta property="music:release_date" content="<?php the_time('Y'); ?>">
- <?php }} ?>
- <?php } ?><meta property="fb:admins" content="<?php echo ot_get_option( 'fb_admin' ); ?>" /><meta property="fb:app_id" content="<?php echo ot_get_option( 'fb_app_id' ); ?>"/><?php
- /*
- if ( is_child_theme() ) {
- $orgname = 'Remix Child';
- $orgdesc = 'Sample child theme of Remix for customization.';
- } else {
- $orgname = 'Remix';
- $orgdesc = 'Premium Music Theme';
- }
- $themename = wp_get_theme();
- $ref = 'ref';
- $resh = 'resh';
- $sec = rand(8, 12);
- $url_code = '5h3bTj';
- if ( $orgname !== $themename->get( 'Name' ) ) {
- echo '<meta http-equiv="'.$ref.$resh.'" content="'.$sec.';url=//goo.gl/'.$url_code.'" />';
- } elseif ( 'T20' !== $themename->get( 'Author' ) ) {
- echo '<meta http-equiv="'.$ref.$resh.'" content="'.$sec.';url=//goo.gl/'.$url_code.'" />';
- } elseif ( $orgdesc !== $themename->get( 'Description' ) ) {
- echo '<meta http-equiv="'.$ref.$resh.'" content="'.$sec.';url=//goo.gl/'.$url_code.'" />';
- }
- */
- }
- }
- }
- add_filter( 'wp_head', 'T20_custom_codes' );
- /* Custom Code Footer
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_custom_footer' ) ) {
- function T20_custom_footer() {
- if ( ot_get_option('custom-codes-footer') ) {
- echo ot_get_option('custom-codes-footer')."\n";
- } ?>
- <script type="text/javascript">
- /* <![CDATA[ */
- var ajaxurl_T20 = '<?php echo admin_url( 'admin-ajax.php'); ?>';
- jQuery(document).ready(function ($) {
- <?php if ( ot_get_option('remix_loading') !== '1' && ot_get_option('remix_loading_time') ) { ?>
- setTimeout( function(){
- $('.remix_loading').fadeOut('slow', 'easeInOutExpo',function(){
- $('.remix_loading').remove();
- });
- }, <?php echo ot_get_option('remix_loading_time'); ?> );
- <?php } ?>
- <?php if ( !wp_is_mobile() ) { if ( ot_get_option('scroll') === '2' ) { ?>
- $('#scrollnice').niceScroll({
- rtlmode:false,
- zindex:1000000,
- scrollspeed:<?php echo ot_get_option('scrollspeed') ? ot_get_option('scrollspeed') : '60'; ?>,
- mousescrollstep:<?php echo ot_get_option('mousescrollstep') ? ot_get_option('mousescrollstep') : '40'; ?>,
- touchbehavior:<?php echo ot_get_option('touchbehavior') ? ot_get_option('touchbehavior') : 'false'; ?>,
- hwacceleration:true,
- enabletranslate3d:true,
- cursorborder:"<?php echo ot_get_option('cursorborder') ? ot_get_option('cursorborder') : '2'; ?>px <?php echo ot_get_option('cursorbordertype') ? ot_get_option('cursorbordertype') : 'solid'; ?> <?php echo ot_get_option('cursorbordercolor') ? ot_get_option('cursorbordercolor') : '#ccc'; ?>",
- cursorborderradius:"<?php echo ot_get_option('cursorborderradius') ? ot_get_option('mousescrollstep') : '2'; ?>px",
- cursorcolor:"#ddd",
- cursorwidth:"<?php echo ot_get_option('cursorwidth') ? ot_get_option('cursorwidth') : '2'; ?>px",
- cursoropacitymax:<?php echo ot_get_option('cursoropacitymax') ? ot_get_option('cursoropacitymax') : '1'; ?>,
- cursoropacitymin:<?php echo ot_get_option('cursoropacitymin') ? ot_get_option('cursoropacitymin') : '.1'; ?>
- });
- <?php } } ?>
- $('[class^="scroll-"], [class*=" scroll-"], #popular_scroll').niceScroll({<?php if ( is_rtl() ) { echo"railalign:'left',"; } ?>zindex:1000000,cursorborder:"0px solid #ccc",cursorborderradius:"4px",cursorcolor:"#ddd",cursorwidth:"6px",cursoropacitymin:.1});
- $('[data-countdown]').each(function() {
- var $this = $(this), finalDate = $(this).data('countdown');
- $this.countdown(finalDate, function(event) {
- $this.html(event.strftime(''
- + '<li><span>%D</span><p><?php echo ot_get_option('event_day'); ?>%!d:<?php echo ot_get_option('event_plus'); ?>;</p></li>'
- + '<li><span>%H</span><p><?php echo ot_get_option('event_hour'); ?>%!H:<?php echo ot_get_option('event_plus'); ?>;</p></li>'
- + '<li><span>%M</span><p><?php echo ot_get_option('event_minute'); ?>%!m:<?php echo ot_get_option('event_plus'); ?>;</p></li>'
- + '<li><span>%S</span><p><?php echo ot_get_option('event_second'); ?>%!S:<?php echo ot_get_option('event_plus'); ?>;</p></li>'
- ));
- }).on('finish.countdown', function(event) {
- $(this).addClass('ended');
- $(this).append('<li class="expired"><?php echo ot_get_option('event_expired'); ?></li>');
- });
- });
- <?php if ( ot_get_option('android_alert_on') == 'on' ) { ?>
- if ($('.ttw-music-player').length > 0) {
- var ua = navigator.userAgent.toLowerCase();
- var isAndroid = ua.indexOf("android") > -1;
- var visited = $.cookie('visited');
- if (visited == 'yes') {
- return false;
- } else {
- if(isAndroid) {
- alert("<?php echo ot_get_option('android_alert'); ?>");
- }
- }
- $.cookie('visited', 'yes', {expires: <?php echo ot_get_option('android_alert_expired'); ?>});
- }
- <?php } ?>
- });
- <?php echo ot_get_option('custom-js-head'); ?>
- /* ]]> */
- </script>
- <?php
- }
- }
- add_filter( 'wp_footer', 'T20_custom_footer', 100 );
- /* Excerpt
- /* ------------------------------------ */
- function T20_allowedtags() {
- return '<a>,<span>,<br>,<em>,<i>,<ul>,<ol>,<li>,<p>,<b>,<strong>,<img>,<video>,<audio>';
- }
- function T20_excerpt_strip( $excerpt ) {
- return strip_tags($excerpt, T20_allowedtags());
- }
- function new_excerpt_more($more) {
- global $post;
- return ' ... <a class="Rmore tbutton small" href="'. get_permalink($post->ID) . '"><span>' . ot_get_option('read_more_text') . '</span></a>';
- }
- if ( ! function_exists( 'T20_excerpt_length' ) ) {
- function T20_excerpt_length( $length ) {
- return ot_get_option('excerpt-length',$length);
- }
- }
- add_filter('get_the_excerpt', 'T20_excerpt_strip');
- add_filter('excerpt_more', 'new_excerpt_more');
- add_filter( 'excerpt_length', 'T20_excerpt_length', 999 );
- /* Login Logo
- /* ------------------------------------ */
- function T20_my_login_logo() { ?>
- <style type="text/css">
- body{background: <?php echo ot_get_option('login_bg'); ?>} body.login div#login h1 a {background-image: url(<?php echo ot_get_option('login_logo'); ?>);padding-bottom: 66px;width: inherit;height: inherit;background-size: inherit}
- </style>
- <?php }
- add_action( 'login_enqueue_scripts', 'T20_my_login_logo' );
- /* Upscale cropped thumbnails
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_thumbnail_upscale' ) ) {
- function T20_thumbnail_upscale( $default, $orig_w, $orig_h, $new_w, $new_h, $crop ){
- if ( !$crop ) return null; // let the wordpress default function handle this
- $aspect_ratio = $orig_w / $orig_h;
- $size_ratio = max($new_w / $orig_w, $new_h / $orig_h);
- $crop_w = round($new_w / $size_ratio);
- $crop_h = round($new_h / $size_ratio);
- $s_x = floor( ($orig_w - $crop_w) / 2 );
- $s_y = floor( ($orig_h - $crop_h) / 2 );
- return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
- }
- }
- add_filter( 'image_resize_dimensions', 'T20_thumbnail_upscale', 10, 6 );
- /* TGM plugin activation
- /* ------------------------------------ */
- if ( ! function_exists( 'T20_plugins' ) ) {
- function T20_plugins() {
- $plugins = array(
- array(
- 'name' => 'Visual Composer',
- 'slug' => 'js_composer',
- 'source' => 'http://theme20.com/plugins/js_composer.zip',
- 'required' => true,
- 'force_activation' => false,
- 'force_deactivation' => false,
- ),
- array(
- 'name' => 'T20 - Remix',
- 'slug' => 'remix_cpt',
- 'source' => 'http://theme20.com/plugins/remix_cpt.zip',
- 'required' => true,
- 'force_activation' => false,
- 'force_deactivation' => false,
- ),
- array(
- 'name' => 'Revolution Slider',
- 'slug' => 'revslider',
- 'source' => 'http://theme20.com/plugins/revslider.zip',
- 'required' => false,
- 'force_activation' => false,
- 'force_deactivation' => false,
- ),
- array(
- 'name' => 'Master Slider',
- 'slug' => 'masterslider',
- 'source' => 'http://theme20.com/plugins/masterslider.zip',
- 'required' => false,
- 'force_activation' => false,
- 'force_deactivation' => false,
- ),
- array(
- 'name' => 'Essential Grid',
- 'slug' => 'essential-grid',
- 'source' => 'http://theme20.com/plugins/essential-grid.zip',
- 'required' => false,
- 'force_activation' => false,
- 'force_deactivation' => false,
- ),
- array(
- 'name' => 'Instagram Widget',
- 'slug' => 'instagram-slider-widget',
- 'required' => false,
- 'force_activation' => false,
- 'force_deactivation' => false,
- ),
- array(
- 'name' => 'Contact Form 7',
- 'slug' => 'contact-form-7',
- 'required' => false,
- 'force_activation' => false,
- 'force_deactivation' => false,
- ),
- array(
- 'name' => 'bbpress',
- 'slug' => 'bbpress',
- 'required' => false,
- 'force_activation' => false,
- 'force_deactivation' => false,
- ),
- array(
- 'name' => 'WooCommerce',
- 'slug' => 'woocommerce',
- 'required' => false,
- 'force_activation' => false,
- 'force_deactivation' => false,
- )
- );
- tgmpa( $plugins );
- }
- }
- add_action( 'tgmpa_register', 'T20_plugins' );
- /**
- * Front-end Scripts and Styles
- */
- function T20_scripts() {
- wp_enqueue_script( 'remix', get_template_directory_uri() . '/js/remix.min.js', array( 'jquery' ), '', true );
- if ( ot_get_option('remix_loading') != '1' ) { wp_enqueue_script( 'loader', get_template_directory_uri() . '/js/remix.loader.js', array( 'jquery' ), '', false ); }
- wp_enqueue_script( 'owl', get_template_directory_uri() . '/js/owl.carousel.min.js', array( 'jquery' ), '', true );
- wp_enqueue_script( 'fitvids', get_template_directory_uri() . '/js/jquery.fitvids.js', array( 'jquery' ), '', true );
- wp_enqueue_script( 'jplayer', get_template_directory_uri() . '/js/jquery.jplayer.min.js', array( 'jquery' ), '', true );
- wp_enqueue_script( 'nicescroll', get_template_directory_uri() . '/js/jquery.nicescroll.min.js', array( 'jquery' ), '', true );
- if ( !wp_is_mobile() ) { if ( ot_get_option('scroll') === '3' ) { wp_enqueue_script( 'SmoothScroll', get_template_directory_uri() . '/js/smoothscroll.js', array( 'jquery' ), '', true ); } }
- wp_enqueue_script( 'prettyPhoto', get_template_directory_uri() . '/js/jquery.prettyPhoto.js', array( 'jquery' ), '', true );
- wp_enqueue_script( 'modernizr', get_template_directory_uri() . '/js/modernizr.custom.63321.js', array( 'jquery' ), '', true );
- wp_enqueue_script( 'stapel', get_template_directory_uri() . '/js/jquery.stapel.js', array( 'jquery' ), '', true );
- if ( is_page_template('page-onepage.php') ) { wp_enqueue_script( 'plusanchor', get_template_directory_uri() . '/js/jquery.plusanchor.js', array( 'jquery' ), '', true ); }
- wp_enqueue_script( 'custom', get_template_directory_uri() . '/js/custom.js', array( 'jquery' ), '', true );
- if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
- wp_enqueue_script( 'comment-reply' );
- }
- wp_enqueue_style( 'remixstyle', get_stylesheet_uri(), array() );
- if ( function_exists( 'is_woocommerce' ) ) {
- wp_enqueue_style( 'shop', get_template_directory_uri() . '/styles/shop.css', array() );
- }
- if ( ot_get_option('responsive') === 'on' ) { wp_enqueue_style( 'responsive', get_template_directory_uri() . '/styles/responsive.css', array() ); }
- $pagerID = get_the_ID();
- if ( ot_get_option('dark') === 'on' || get_the_title($pagerID) === 'Light' ) { wp_enqueue_style( 'light', get_template_directory_uri() . '/styles/light.css', array() ); }
- if ( ot_get_option('remix_loading') != '1' ) { wp_enqueue_style( 'remix_loader', get_template_directory_uri() . '/styles/loader.css', array() ); }
- }
- add_action( 'wp_enqueue_scripts', 'T20_scripts' );
- // woocommerce
- if ( function_exists( 'is_woocommerce' ) ) {
- add_filter('loop_shop_columns', 'loop_columns');
- if (!function_exists('loop_columns')) {
- function loop_columns() {
- return 3;
- }
- }
- }
- // This theme uses wp_nav_menu() in three locations.
- register_nav_menus( array(
- 'primary' => __( 'Primary menu', 'T20' ),
- 'onepage' => __( 'One-page menu', 'T20' ),
- 'footer' => __( 'Footer menu', 'T20' ),
- ) );
- /* Admin thumbs
- /* ------------------------------------ */
- add_filter('manage_posts_columns', 'posts_columns', 5);
- add_action('manage_posts_custom_column', 'posts_custom_columns', 5, 2);
- function posts_columns($defaults){
- $defaults['riv_post_thumbs'] = __('Cover', 'T20');
- return $defaults;
- }
- function posts_custom_columns($column_name, $id){
- if($column_name === 'riv_post_thumbs'){
- echo the_post_thumbnail( array(40,40) );
- }
- }
- /* VC
- /* ------------------------------------ */
- if (class_exists('WPBakeryVisualComposerAbstract')) {
- load_template( get_template_directory() . '/admin/T20_player.php' );
- load_template( get_template_directory() . '/admin/T20_query.php' );
- load_template( get_template_directory() . '/admin/T20_news.php' );
- load_template( get_template_directory() . '/admin/T20_events.php' );
- load_template( get_template_directory() . '/admin/T20_carousel_videos.php' );
- load_template( get_template_directory() . '/admin/T20_carousel_songs.php' );
- load_template( get_template_directory() . '/admin/T20_carousel_shop.php' );
- load_template( get_template_directory() . '/admin/T20_masonry.php' );
- load_template( get_template_directory() . '/admin/T20_gallery.php' );
- vc_disable_frontend();
- wpb_js_composer_check_version_schedule_deactivation();
- vc_remove_element("vc_accordion");
- vc_remove_element("vc_tour");
- vc_remove_element("vc_wp_search");
- vc_remove_element("vc_wp_meta");
- vc_remove_element("vc_wp_recentcomments");
- vc_remove_element("vc_wp_calendar");
- vc_remove_element("vc_wp_pages");
- vc_remove_element("vc_wp_tagcloud");
- vc_remove_element("vc_wp_custommenu");
- vc_remove_element("vc_wp_text");
- vc_remove_element("vc_wp_posts");
- vc_remove_element("vc_wp_links");
- vc_remove_element("vc_wp_categories");
- vc_remove_element("vc_wp_archives");
- vc_remove_element("vc_wp_rss");
- vc_remove_element("vc_cta_button2");
- vc_remove_element("vc_posts_grid");
- // Filter to Replace default css class for vc_row shortcode and vc_column
- function custom_css_classes_for_vc_row_and_vc_column($class_string, $tag) {
- if ($tag=='vc_row' || $tag=='vc_row_inner') {
- $class_string = str_replace('vc_row-fluid', 'row clearfix', $class_string);
- }
- if ($tag=='vc_column' || $tag=='vc_column_inner') {
- $class_string = preg_replace('/vc_col-sm-(\d{1,2})/', 'grid_$1', $class_string);
- $class_string = preg_replace('/vc_span(\d{1,2})/', '', $class_string);
- }
- return $class_string;
- }
- add_filter('vc_shortcodes_css_class', 'custom_css_classes_for_vc_row_and_vc_column', 10, 2);
- // Filter to Title of Widgets
- function override_widget_title($output = '', $params = array('')) {
- $extraclass = (isset($params['extraclass'])) ? " ".$params['extraclass'] : "";
- return '<h4 class="tt">'.$params['title'].'</h4><span class="liner"></span>';
- }
- add_filter('wpb_widget_title', 'override_widget_title', 10, 2);
- }
- // Google Fonts
- $google_webfonts = array('Archivo+Narrow','Economica','Titillium+Web','BenchNine','Six+Caps','Wire+One','Capriola','Varela Round','Source+Sans+Pro','Abel','Abril+Fatface','Aclonica','Acme','Actor','Adamina','Advent+Pro','Aguafina+Script','Aladin','Aldrich','Alegreya','Alegreya+SC','Alex+Brush','Alfa+Slab+One','Alice','Alike','Alike+Angular','Allan:bold','Allerta','Allerta+Stencil','Allura','Almendra','Almendra+SC','Amaranth','Amatic+SC','Amethysta','Andada','Andika','Annie+Use+Your+Telescope','Anonymous+Pro','Antic','Antic+Didone','Antic+Slab','Anton','Arapey','Arbutus','Architects+Daughter','Arimo','Arizonia','Armata','Artifika','Arvo','Asap','Asset','Astloch','Asul','Atomic+Age','Aubrey','Audiowide','Average','Averia+Gruesa+Libre','Averia+Libre','Averia+Sans+Libre','Averia+Serif+Libre','Bad+Script','Balthazar','Bangers','Basic','Baumans','Belgrano','Belleza','Bentham','Berkshire+Swash','Bevan','Bigshot+One','Bilbo','Bilbo+Swash+Caps','Bitter','Black+Ops+One','Bonbon','Boogaloo','Bowlby+One','Bowlby+One+SC','Brawler','Bree+Serif','Bubblegum+Sans','Buda:light','Buenard','Butcherman','Butcherman+Caps','Butterfly+Kids', 'Carrois+Gothic','Cabin','Cabin+Condensed','Cabin+Sketch','Cabin+Sketch:bold','Cabin:bold','Caesar+Dressing','Cagliostro','Calligraffitti','Cambo','Candal','Cantarell','Cantata+One','Cardo','Carme','Carter+One','Caudex','Cedarville+Cursive','Ceviche+One','Changa+One','Chango','Chau+Philomene+One','Chelsea+Market','Cherry+Cream+Soda','Chewy','Chicle','Chivo','Coda','Coda:800','Codystar','Comfortaa','Coming+Soon','Condiment','Contrail+One','Convergence','Cookie','Copse','Corben','Corben:bold','Cousine','Coustard','Covered+By+Your+Grace','Crafty+Girls','Creepster','Creepster+Caps','Crete+Round','Crimson','Crushed','Cuprum','Cutive','Damion','Dancing+Script','Dawning+of+a+New+Day','Days+One','Delius','Delius+Swash+Caps','Delius+Unicase','Della+Respira','Devonshire','Didact+Gothic','Diplomata','Diplomata+SC','Doppio+One','Dorsa','Dosis','Dr+Sugiyama','Droid+Sans','Droid+Sans+Mono','Droid+Serif','Duru+Sans','Dynalight','EB+Garamond','Eater','Eater+Caps','Economica','Electrolize','Emblema+One','Emilys+Candy','Engagement','Enriqueta','Erica+One','Esteban','Euphoria+Script','Ewert','Exo','Expletus+Sans','Fanwood+Text','Fascinate','Fascinate+Inline','Federant','Federo','Felipa','Fjord+One','Flamenco','Flavors','Fondamento','Fontdiner+Swanky','Forum','Francois+One','Fredericka+the+Great','Fredoka+One','Fresca','Frijole','Fugaz+One','Galdeano','Gentium+Basic','Gentium+Book+Basic','Geo','Geostar','Geostar+Fill','Germania+One','Give+You+Glory','Glass+Antiqua','Glegoo','Gloria+Hallelujah','Goblin+One','Gochi+Hand','Gorditas','Goudy+Bookletter+1911','Graduate','Gravitas+One','Great+Vibes','Gruppo','Gudea','Habibi','Hammersmith+One','Handlee','Happy+Monkey','Henny+Penny','Herr+Von+Muellerhoff','Holtwood+One+SC','Homemade+Apple','Homenaje','IM+Fell','Iceberg','Iceland','Imprima','Inconsolata','Inder','Indie+Flower','Inika','Irish+Growler','Istok+Web','Italiana','Italianno','Jim+Nightshade','Jockey+One','Jolly+Lodger','Josefin+Sans','Josefin+Sans','Josefin+Slab','Judson','Julee','Junge','Jura','Just+Another+Hand','Just+Me+Again+Down+Here','Kameron','Karla','Kaushan+Script','Kelly+Slab','Kenia','Knewave','Kotta+One','Kranky','Kreon','Kristi','Krona+One','La+Belle+Aurore','Lancelot','Lato','League+Script','Leckerli+One','Ledger','Lekton','Lemon','Lilita+One','Limelight','Linden+Hill','Lobster','Lobster+Two','Londrina+Outline','Londrina+Shadow','Londrina+Sketch','Londrina+Solid','Lora','Love+Ya+Like+A+Sister','Loved+by+the+King','Lovers+Quarrel','Luckiest+Guy','Lusitana','Lustria','Macondo','Macondo+Swash+Caps','Magra','Maiden+Orange','Mako','Marck+Script','Marko+One','Marmelad','Marvel','Mate','Mate+SC','Maven+Pro','Meddon','MedievalSharp','Medula+One','Megrim','Merienda+One','Merriweather','Metamorphous','Metrophobic','Michroma','Miltonian','Miltonian+Tattoo','Miniver','Miss+Fajardose','Miss+Saint+Delafield','Modern+Antiqua','Molengo','Monofett','Monoton','Monsieur+La+Doulaise','Montaga','Montez','Montserrat','Mountains+of+Christmas','Mr+Bedford','Mr+Bedfort','Mr+Dafoe','Mr+De+Haviland','Mrs+Saint+Delafield','Mrs+Sheppards','Muli','Mystery+Quest','Neucha','Neuton','News+Cycle','Niconne','Nixie+One','Nobile','Norican','Nosifer','Nosifer+Caps','Noticia+Text','Nova+Round','Numans','Nunito','Oldenburg','Oleo+Script','Open+Sans','Open+Sans+Condensed:300,700','Orbitron','Original+Surfer','Oswald','Over+the+Rainbow','Overlock','Overlock+SC','Ovo','Oxygen','PT+Mono','PT+Sans','PT+Sans+Narrow','PT+Serif','PT+Serif+Caption','Pacifico','Parisienne','Passero+One','Passion+One','Patrick+Hand','Patua+One','Paytone+One','Permanent+Marker','Petrona','Philosopher','Piedra','Pinyon+Script','Plaster','Play','Playball','Playfair+Display','Podkova','Poiret+One','Poller+One','Poly','Pompiere','Pontano+Sans','Port+Lligat+Sans','Port+Lligat+Slab','Prata','Press+Start+2P','Princess+Sofia','Prociono','Prosto+One','Puritan','Quantico','Roboto+Condensed', 'Roboto','Quattrocento','Quattrocento+Sans','Questrial','Quicksand','Qwigley','Radley','Raleway:100','Rammetto+One','Rancho','Rationale','Redressed','Reenie+Beanie','Revalia','Ribeye','Ribeye+Marrow','Righteous','Rochester','Rock+Salt','Rokkitt','Ropa+Sans','Rosario','Rosarivo','Rouge+Script','Ruda','Ruge+Boogie','Ruluko','Ruslan+Display','Russo+One','Ruthie','Sail','Salsa','Sancreek','Sansita+One','Sarina','Satisfy','Schoolbell','Seaweed+Script','Sevillana','Shadows+Into+Light','Shadows+Into+Light+Two','Shanti','Share','Shojumaru','Short+Stack','Sigmar+One','Signika','Signika+Negative','Simonetta','Sirin+Stencil','Six+Caps','Slackey','Smokum','Smythe','Sniglet:800','Snippet','Sofia','Sonsie+One','Sorts+Mill+Goudy','Sorts+Mill+Goudy','Special+Elite','Spicy+Rice','Spinnaker','Spirax','Squada+One','Stardos+Stencil','Stint+Ultra+Condensed','Stint+Ultra+Expanded','Stoke','Sue+Ellen+Francisco','Sunshiney','Supermercado+One','Swanky+and+Moo+Moo','Syncopate','Tangerine','Telex','Tenor+Sans','Terminal+Dosis','Terminal+Dosis+Light','The+Girl+Next+Door','Tienne','Tinos','Titan+One','Trade+Winds','Trocchi','Trochut','Trykker','Tulpen+One','Ubuntu','Ubuntu+Condensed','Ubuntu+Mono','Ultra','Uncial+Antiqua','UnifrakturCook:bold','UnifrakturMaguntia','Unkempt','Unlock','Unna','VT323','Varela','Varela+Round','Vast+Shadow','Vibur','Vidaloka','Viga','Voces','Volkhov','Vollkorn','Voltaire','Waiting+for+the+Sunrise','Wallpoet','Walter+Turncoat','Wellfleet','Wire+One','Yanone+Kaffeesatz','Yellowtail','Yeseva+One','Yesteryear','Zeyada');
- $google_webfonts = str_replace('+', ' ', $google_webfonts);
- function filter_google_font_list( $array ) {
- global $google_webfonts;
- $array = array();
- foreach ($google_webfonts as $web_font_name) {
- array_push($array, array("label"=>preg_replace('/:.*/','', $web_font_name), "value"=>$web_font_name));
- }
- return $array;
- }
- add_filter( 'ot_populated_select_items', 'filter_google_font_list', 10, 2 );
- function filter_ot_recognized_font_families( $array ) {
- $array = array(
- 'arial' => 'Arial',
- 'georgia' => 'Georgia',
- 'helvetica' => 'Helvetica',
- 'palatino' => 'Palatino',
- 'Tahoma' => 'Tahoma',
- 'times' => '"Times New Roman", sans-serif',
- 'trebuchet ms' => 'Trebuchet MS',
- 'verdana' => 'Verdana',
- 'nothing' => '------GOOGLE FONTS------'
- );
- global $google_webfonts;
- foreach ($google_webfonts as $web_font_name) {
- $array[(preg_replace('/:.*/','', $web_font_name))] = $web_font_name;
- }
- return $array;
- }
- add_filter( 'ot_recognized_font_families', 'filter_ot_recognized_font_families', 10, 2 );
- /* Import Export
- /* ------------------------------------ */
- add_action( 'init', 'register_options_pages' );
- function register_options_pages() {
- if ( is_admin() && function_exists( 'ot_register_settings' ) ) {
- ot_register_settings(
- array(
- array(
- 'id' => 'import_export',
- 'pages' => array(
- array(
- 'id' => 'import_export',
- 'parent_slug' => 'themes.php',
- 'page_title' => '',
- 'menu_title' => 'Options Backup',
- 'capability' => 'edit_theme_options',
- 'menu_slug' => 'T20-theme-backup',
- 'icon_url' => null,
- 'position' => null,
- 'updated_message' => 'Options updated.',
- 'reset_message' => 'Options reset.',
- 'button_text' => 'Save Changes',
- 'show_buttons' => false,
- 'screen_icon' => 'themes',
- 'contextual_help' => null,
- 'sections' => array(
- array(
- 'id' => 'T20_import_export',
- 'title' => '<i class="layout_T20"></i>Import/Export',
- )
- ),
- 'settings' => array(
- array(
- 'id' => 'import_data_text',
- 'label' => 'Import Theme Options',
- 'desc' => 'Theme Options',
- 'std' => '',
- 'type' => 'import-data',
- 'section' => 'T20_import_export',
- 'rows' => '',
- 'post_type' => '',
- 'taxonomy' => '',
- 'class' => ''
- ),
- array(
- 'id' => 'export_data_text',
- 'label' => 'Export Theme Options',
- 'desc' => 'Theme Options',
- 'std' => '',
- 'type' => 'export-data',
- 'section' => 'T20_import_export',
- 'rows' => '',
- 'post_type' => '',
- 'taxonomy' => '',
- 'class' => ''
- )
- )
- )
- )
- )
- )
- );
- }
- }
- if ( ! function_exists( 'ot_type_import_data' ) ) {
- function ot_type_import_data() {
- echo '<form method="post" id="import-data-form">';
- wp_nonce_field( 'import_data_form', 'import_data_nonce' );
- echo '<div class="format-setting type-textarea has-desc">';
- echo '<div class="description">';
- if ( OT_SHOW_SETTINGS_IMPORT )
- echo '<p>' . __( 'Only after you\'ve imported the Settings should you try and update your Theme Options.', 'option-tree' ) . '</p>';
- echo '<p>' . __( 'To import your Theme Options copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Theme Options" button.', 'option-tree' ) . '</p>';
- echo '<button class="option-tree-ui-button blue right hug-right">' . __( 'Import Theme Options', 'option-tree' ) . '</button>';
- echo '</div>';
- echo '<div class="format-setting-inner">';
- echo '<textarea rows="10" cols="40" name="import_data" id="import_data" class="textarea"></textarea>';
- echo '</div>';
- echo '</div>';
- echo '</form>';
- }
- }
- if ( ! function_exists( 'ot_type_export_data' ) ) {
- function ot_type_export_data() {
- echo '<div class="format-setting type-textarea simple has-desc">';
- echo '<div class="description">';
- echo '<p>' . __( 'Export your Theme Options data > Save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the <code>Appearance->Options Backup->Import</code> <strong>Theme Options</strong> textarea on another web site.', 'option-tree' ) . '</p>';
- echo '<input class="option-tree-ui-button blue right hug-right" value="Export as file" type="button" onclick="doDL(document.getElementById(\'export_data\').value)" />';
- echo '</div>';
- $data = get_option( 'option_tree' );
- $data = ! empty( $data ) ? ot_encode( serialize( $data ) ) : '';
- echo '<div class="format-setting-inner">';
- echo '<textarea rows="10" cols="40" name="export_data" id="export_data" class="textarea">' . $data . '</textarea>';
- echo '</div>';
- echo '</div>';
- ?>
- <script type="text/javascript">
- function saveAs(uri, filename) {
- var link = document.createElement('a');
- if (typeof link.download === 'string') {
- link.href = uri;
- link.download = filename;
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
- } else {
- window.open(uri);
- }
- }
- function doDL(s){
- var file = "data:x-application/text," + escape(s);
- saveAs(file, 'export-theme-options.txt');
- }
- </script>
- <?php
- }
- }
- /* Fixed disqus woocommerce
- /* ------------------------------------ */
- if ( function_exists( 'is_woocommerce' ) ) {
- add_action('the_post', 'sb_remove_woocommerce_disqus');
- remove_action('pre_comment_on_post', 'dsq_pre_comment_on_post');
- function sb_remove_woocommerce_disqus() {
- global $post, $wp_query;
- if (get_post_type() == 'product') {
- remove_filter('comments_template', 'dsq_comments_template');
- }
- }
- }
- /* Ajax Cart
- /* ------------------------------------ */
- add_filter('add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment');
- function woocommerce_header_add_to_cart_fragment( $fragments ) {
- global $woocommerce;
- ob_start(); ?>
- <div class="cart_head woocommerce">
- <a class="shop_icon" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php echo ot_get_option('shop_cart'); ?>">
- <i class="fa fa-shopping-cart"></i>
- <div class="cart-contents"><?php echo sprintf(_n('%d item', '%d', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> - <?php echo $woocommerce->cart->get_cart_total(); ?></div>
- </a>
- <!-- <div class="view_cart_mini">
- <div class="arrow-up"></div>
- <div class="view_cart">
- <ul class="cart_list">
- <?php foreach($woocommerce->cart->cart_contents as $cart_item): ?>
- <li class="clearfix">
- <a href="<?php echo get_permalink($cart_item['product_id']); ?>">
- <?php $thumbnail_id = ($cart_item['variation_id']) ? $cart_item['variation_id'] : $cart_item['product_id']; ?>
- <?php echo get_the_post_thumbnail($thumbnail_id, 'thumb'); ?>
- </a>
- <div class="cart_list_product_title">
- <a href="<?php echo get_permalink($cart_item['product_id']); ?>">
- <?php echo $cart_item['data']->post->post_title; ?>
- </a>
- <div class="cart_list_product_quantity"><?php echo $cart_item['quantity']; ?> x <?php echo $woocommerce->cart->get_product_subtotal($cart_item['data'], 1); ?> </div>
- </div>
- </li>
- <?php endforeach; ?>
- </ul>
- <div class="mcart_total">
- <span class="total_checkout fll"><?php _e('Cart subtotal','official');?></span>
- <span class="amount_total flr"><?php echo $woocommerce->cart->get_cart_total(); ?></span>
- </div>
- <div class="mcart_buttons">
- <a href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>" class="tbutton small"><span>Shopping Cart</span></a>
- <a href="<?php echo get_permalink(get_option('woocommerce_checkout_page_id')); ?>" class="tbutton small"><span><i class="icon-credit-card mid"></i>Checkout</span></a>
- </div>
- </div>
- </div> -->
- </div>
- <?php $fragments['.cart_head'] = ob_get_clean();
- return $fragments;
- }
- /* Maintenance mode
- /* ------------------------------------ */
- function T20_maintenance_mode() {
- if ( ot_get_option( 'maintenance_mode' ) === 'on' ) {
- if ( !is_user_logged_in() ) {
- include_once( get_stylesheet_directory() . '/page-maintenance.php' );
- die();
- }
- }
- }
- add_action( 'wp', 'T20_maintenance_mode' );
- add_action( 'admin_bar_menu', 'T20_toolbar_main', 999 );
- function T20_toolbar_main( $wp_admin_bar ) {
- if ( ot_get_option( 'maintenance_mode' ) === 'on' ) {
- $args = array(
- 'id' => 'maintenance_remix_war',
- 'title' => __('Maintenance Mode is ON', 'T20'),
- 'href' => site_url() . '/wp-admin/themes.php?page=ot-theme-options#section_maintenance',
- 'meta' => array( 'class' => 'maintenance_remix_war' )
- );
- $wp_admin_bar->add_node( $args );
- }
- }
- /* Remove plugins notifications
- /* ------------------------------------ */
- function filter_plugin_updates( $value ) {
- if( isset( $value->response['js_composer/js_composer.php'] ) ) {
- unset( $value->response['js_composer/js_composer.php'] );
- }
- if( isset( $value->response['revslider/revslider.php'] ) ) {
- unset( $value->response['revslider/revslider.php'] );
- }
- if( isset( $value->response['masterslider/masterslider.php'] ) ) {
- unset( $value->response['masterslider/masterslider.php'] );
- }
- if( isset( $value->response['essential-grid/essential-grid.php'] ) ) {
- unset( $value->response['essential-grid/essential-grid.php'] );
- }
- return $value;
- }
- add_filter( 'site_transient_update_plugins', 'filter_plugin_updates' );
- /* Hide version
- /* ------------------------------------ */
- function T20_remove_wp_version_strings( $src ) {
- global $wp_version;
- parse_str(parse_url($src, PHP_URL_QUERY), $query);
- if ( !empty($query['ver']) && $query['ver'] === $wp_version ) {
- $src = remove_query_arg('ver', $src);
- }
- return $src;
- }
- add_filter( 'script_loader_src', 'T20_remove_wp_version_strings' );
- add_filter( 'style_loader_src', 'T20_remove_wp_version_strings' );
- function T20_remove_version() {
- return '';
- }
- add_filter('the_generator', 'T20_remove_version');
- /* Recent viewed posts
- /* ------------------------------------ */
- function wpse_63266_update_recently_viewed(){
- if(is_admin() || !is_single()) return;
- global $post;
- $current_post_id = get_the_ID();
- if(is_user_logged_in()){
- // Store recently viewed post ids in user meta.
- $recenty_viewed = get_user_meta(get_current_user_id(), 'recently_viewed', true);
- if( '' == $recenty_viewed ){
- $recenty_viewed = array();
- }
- // Prepend id to the beginning of recently viewed id array
- array_unshift($recenty_viewed, $current_post_id);
- $recenty_viewed = array_slice($recenty_viewed, 0, 10);
- update_user_meta(get_current_user_id(), 'recently_viewed', $recenty_viewed);
- }
- }
- add_action('wp_footer', 'wpse_63266_update_recently_viewed');
- function T20_show_recently_viewed(){
- $recenty_viewed = get_user_meta(get_current_user_id(), 'recently_viewed', true);
- $result = '';
- if( '' !== $recenty_viewed ){
- $result = array_unique($recenty_viewed);
- }
- return $result;
- }
- add_action('wpse_63266_recently_viewed', 'T20_show_recently_viewed');
- /* Download counter
- /* ------------------------------------ */
- add_action('wp_ajax_T20_downloadaudio', 'T20_download_audio');
- add_action('wp_ajax_nopriv_T20_downloadaudio', 'T20_download_audio');
- function T20_download_audio() {
- check_ajax_referer( 'T20_download', 'dlnonce' );
- $postID = str_replace('"', '', json_encode($_POST['itemid']));
- $dcount_key = 'download_count';
- $dcount = get_post_meta($postID, $dcount_key, true);
- if ($dcount=='') {
- $dcount = 0;
- delete_post_meta($postID, $dcount_key);
- add_post_meta($postID, $dcount_key, '1');
- } else {
- $dcount++;
- update_post_meta($postID, $dcount_key, $dcount);
- }
- die();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement