Advertisement
Guest User

Untitled

a guest
Mar 6th, 2016
796
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 92.78 KB | None | 0 0
  1. <?php
  2.  
  3. /* Parent nav
  4. /* ------------------------------------ */
  5. function T20_add_current_nav_class($classes, $item) {
  6. if ( have_posts() ) {
  7. global $post;
  8. $current_post_type = get_post_type_object(get_post_type($post->ID));
  9. if ( !empty( $current_post_type ) ) {
  10. $current_post_type_slug = $current_post_type->rewrite['slug'];
  11. } else {
  12. $current_post_type_slug = false;
  13. }
  14. $menu_slug = strtolower(trim($item->url));
  15. if (strpos($menu_slug,$current_post_type_slug) !== false) {
  16. $classes[] = 'activated_parent selectedLava';
  17. }
  18. }
  19.  
  20. return $classes;
  21. }
  22. add_action('nav_menu_css_class', 'T20_add_current_nav_class', 10, 2 );
  23.  
  24. /* Radio steam data
  25. /* ------------------------------------ */
  26. add_action('wp_ajax_T20_nowplaying', 'T20_now_playing');
  27. add_action('wp_ajax_nopriv_T20_nowplaying', 'T20_now_playing');
  28. function T20_now_playing() {
  29. check_ajax_referer( 'T20_title', 'lannoncet' );
  30.  
  31. $lanid = str_replace('"', '', json_encode($_POST['lanid']));
  32. $landid = str_replace('"', '', json_encode($_POST['landid']));
  33.  
  34. $fp = @fsockopen($lanid,$landid,$errno,$errstr,1);
  35. if (empty($fp)) {
  36. echo 'Connection refused';
  37. } else {
  38. fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
  39. while (!feof($fp)) {
  40. $info = fgets($fp);
  41. }
  42. $info = str_replace('</body></html>', "", $info);
  43. $split = explode(',', $info);
  44. if (empty($split[6]) ) {
  45. echo 'The current song is not available';
  46. } else {
  47. $title = str_replace('\'', '`', $split[6]);
  48. $title = str_replace(',', ' ', $title);
  49. $title = str_replace('"', '', $title);
  50. echo json_encode($title);
  51. }
  52. }
  53. fclose($fp);
  54.  
  55. die();
  56. }
  57. add_action('wp_ajax_T20_history', 'T20_get_history');
  58. add_action('wp_ajax_nopriv_T20_history', 'T20_get_history');
  59. function get_string_between($string, $start, $end) {
  60. $string = " " . $string;
  61. $ini = strpos($string, $start);
  62. if ($ini == 0)
  63. return "";
  64. $ini += strlen($start);
  65. $len = strpos($string, $end, $ini) - $ini;
  66. return substr($string, $ini, $len);
  67. }
  68. function T20_get_history() {
  69. check_ajax_referer( 'T20_history', 'lannonce' );
  70.  
  71. $lanid = str_replace('"', '', json_encode($_POST['lanid']));
  72. $landid = str_replace('"', '', json_encode($_POST['landid']));
  73.  
  74. if (!is_numeric($landid)) {
  75. echo "";
  76. exit;
  77. }
  78. $fp = @fsockopen($lanid,$landid,$errno,$errstr,1);
  79. if (!$fp) {
  80. echo "<div class='symple-box red'>Connection refused, the server appears to be offline.</div>";
  81. exit;
  82. } else {
  83. fputs($fp, "GET /played.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
  84. while (!feof($fp)) {
  85. $info = fgets($fp);
  86. }
  87. $content = get_string_between($info, "Admin Login</a></font></td></tr></table></td></tr></table><br>", "<br><br><table");
  88. $content = str_replace(array('<b>', '</b>'), array('<b class=\'current\'>', '</b>'), $content);
  89. $content = str_replace('Current Song', 'Current', $content);
  90. $content = str_replace('@', '', $content);
  91. echo $content;
  92. }
  93. fclose($fp);
  94.  
  95. die();
  96. }
  97. add_action('wp_ajax_T20_getnewnonce', 'T20_get_getnewnonce');
  98. add_action('wp_ajax_nopriv_T20_getnewnonce', 'T20_get_getnewnonce');
  99. function T20_get_getnewnonce() {
  100. $getnewnonce = wp_create_nonce('T20_history');
  101. echo $getnewnonce;
  102.  
  103. die();
  104. }
  105.  
  106. /* Plays Count
  107. /* ------------------------------------ */
  108. if ( ! function_exists( 'ajax_favorite_plays' ) ) {
  109. function ajax_favorite_plays() {
  110.  
  111. $ids = isset($_GET["vote_post_id"]) ? ($_GET["vote_post_id"]) : 0;
  112.  
  113. if((int)$ids <= 0) die( 'Invalid Operation' );
  114.  
  115. $plays_count = (int)get_post_meta((int)$ids, "ozy_post_plays_count", true);
  116.  
  117. update_post_meta((int)$ids, "ozy_post_plays_count", $plays_count + 1);
  118.  
  119. echo $plays_count + 1;
  120.  
  121. exit();
  122.  
  123. }
  124. add_action( 'wp_ajax_nopriv_ajax_favorite_plays', 'ajax_favorite_plays' );
  125. add_action( 'wp_ajax_ajax_favorite_plays', 'ajax_favorite_plays' );
  126. }
  127.  
  128. /* Posts Taxonomies
  129. /* ------------------------------------ */
  130. add_action('pre_get_posts', 'T20_filter_press_tax');
  131. function T20_filter_press_tax( $query ){
  132. if( $query->is_tax('artist') ):
  133. $ppp_artists = ot_get_option('ppp_artists');
  134. $query->set('posts_per_page', $ppp_artists);
  135. return;
  136. endif;
  137.  
  138. if( $query->is_tax('songs_cat') ):
  139. $ppp_songs = ot_get_option('ppp_songs');
  140. $query->set('posts_per_page', $ppp_songs);
  141. return;
  142. endif;
  143.  
  144. if( $query->is_tax('videos_cat') ):
  145. $ppp_videos = ot_get_option('ppp_videos');
  146. $query->set('posts_per_page', $ppp_videos);
  147. return;
  148. endif;
  149.  
  150. if( $query->is_tax('event_cat') ):
  151. $ppp_events = ot_get_option('ppp_events');
  152. $query->set('posts_per_page', $ppp_events);
  153. return;
  154. endif;
  155.  
  156. if( $query->is_tax('gallery_cat') ):
  157. $ppp_gallery = ot_get_option('ppp_gallery');
  158. $query->set('posts_per_page', $ppp_gallery);
  159. return;
  160. endif;
  161. }
  162.  
  163. /* Get artists
  164. /* ------------------------------------ */
  165. if ( ! function_exists( 'T20_artist_name_link' ) ) {
  166. function T20_artist_name_link() {
  167. global $post;
  168. $output = '';
  169. $array = get_post_meta($post->ID,'artist_nameaa',true);
  170. if ($array) {
  171. if (is_array($array)) {
  172. $len = count($array);
  173. if ($len === 1) {
  174. $single_artist_id = implode(",", $array);
  175. $single_artist = get_post( $single_artist_id );
  176. $output .= '<a class="n_m" href="'.get_post_permalink($single_artist).'">'.( $single_artist->post_title ).'</a>';
  177. } else {
  178. $elements = array();
  179. foreach($array as $selectedOption) {
  180. $multiple_artist = get_post( $selectedOption );
  181. $elements[] = '<a class="n_m" href="'.get_post_permalink($multiple_artist).'">'.( $multiple_artist->post_title ).'</a>';
  182. }
  183. $output .= implode(', ', $elements);
  184. }
  185. } else {
  186. $single_artist = get_post( $array );
  187. $output .= '<a class="n_m" href="'.get_post_permalink($single_artist).'">'.( $single_artist->post_title ).'</a>';
  188. }
  189. }
  190.  
  191. return $output;
  192. }
  193. }
  194. if ( ! function_exists( 'T20_artist_name' ) ) {
  195. function T20_artist_name() {
  196. global $post;
  197. $output = '';
  198. $array = get_post_meta($post->ID,'artist_nameaa',true);
  199. if ($array) {
  200. if (is_array($array)) {
  201. $len = count($array);
  202. if ($len === 1) {
  203. $single_artist_id = implode(",", $array);
  204. $single_artist = get_post( $single_artist_id );
  205. $output .= $single_artist->post_title;
  206. } else {
  207. $elements = array();
  208. foreach($array as $selectedOption) {
  209. $multiple_artist = get_post( $selectedOption );
  210. $elements[] = $multiple_artist->post_title;
  211. }
  212. $output .= implode(', ', $elements);
  213. }
  214. } else {
  215. $single_artist = get_post( $array );
  216. $output .= $single_artist->post_title;
  217. }
  218. }
  219.  
  220. return $output;
  221. }
  222. }
  223.  
  224. /* Archive and Tags page
  225. /* ------------------------------------ */
  226. add_filter('pre_get_posts', 'query_post_type');
  227. function query_post_type($query) {
  228. if(is_category() || is_tag()) {
  229. $post_type = get_query_var('post_type');
  230. if($post_type)
  231. $post_type = $post_type;
  232. else
  233. $post_type = array('post', 'songs', 'videos', 'gallery', 'events', 'nav_menu_item');
  234. $query->set('post_type',$post_type);
  235. return $query;
  236. }
  237. }
  238.  
  239.  
  240. /* RevolutionSlider
  241. /* ------------------------------------ */
  242. function T20_add_revslider_select_type( $array ) {
  243. $array['revslider-select'] = 'Revolution Slider Select';
  244. return $array;
  245. }
  246. add_filter( 'ot_option_types_array', 'T20_add_revslider_select_type' );
  247. function ot_type_revslider_select( $args = array() ) {
  248. extract( $args );
  249. $has_desc = $field_desc ? true : false;
  250. echo '<div class="format-setting type-revslider-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
  251. echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
  252. echo '<div class="format-setting-inner">';
  253. // Add This only if RevSlider is Activated
  254. if ( class_exists( 'RevSliderAdmin' ) ) {
  255. echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . $field_class . '">';
  256.  
  257. /* get revolution array */
  258. $slider = new RevSlider();
  259. $arrSliders = $slider->getArrSlidersShort();
  260.  
  261. /* has slides */
  262. if ( ! empty( $arrSliders ) ) {
  263. echo '<option value="">-- ' . __( 'Choose One', 'option-tree' ) . ' --</option>';
  264. foreach ( $arrSliders as $rev_id => $rev_slider ) {
  265. echo '<option value="' . esc_attr( $rev_id ) . '"' . selected( $field_value, $rev_id, false ) . '>' . esc_attr( $rev_slider ) . '</option>';
  266. }
  267. } else {
  268. echo '<option value="">' . __( 'No Sliders Found', 'option-tree' ) . '</option>';
  269. }
  270. echo '</select>';
  271. } else {
  272. echo '<span style="color: red;">' . __( 'Sorry! Revolution Slider is not Installed or Activated', 'T20' ). '</span>';
  273. }
  274. echo '</div>';
  275. echo '</div>';
  276. }
  277.  
  278. /* MasterSlider
  279. /* ------------------------------------ */
  280. function T20_add_masterslider_select_type( $array ) {
  281. $array['masterslider-select'] = 'Master Slider Select';
  282. return $array;
  283. }
  284. add_filter( 'ot_option_types_array', 'T20_add_masterslider_select_type' );
  285. function ot_type_masterslider_select( $args = array() ) {
  286. extract( $args );
  287. $has_desc = $field_desc ? true : false;
  288. echo '<div class="format-setting type-masterslider-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
  289. echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
  290. echo '<div class="format-setting-inner">';
  291. // Add This only if masterslider is Activated
  292. if( class_exists( 'Master_Slider' ) ) {
  293. echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . $field_class . '">';
  294.  
  295. global $mspdb;
  296.  
  297. if ( $sliders_data = $mspdb->get_sliders_list( $limit = 0, $offset = 0, $orderby = 'ID', $sort = 'ASC' ) ) {
  298. echo '<option value="">-- ' . __( 'Choose One', 'option-tree' ) . ' --</option>';
  299. foreach ( $sliders_data as $slider_data ) {
  300. echo '<option value="' . esc_attr( $slider_data['ID'] ) . '"' . selected( $field_value, $slider_data['ID'], false ) . '>' . esc_attr( $slider_data['title'] ) . '</option>';
  301. }
  302. } else {
  303. echo '<option value="">' . __( 'No Sliders Found', 'option-tree' ) . '</option>';
  304. }
  305. echo '</select>';
  306. } else {
  307. echo '<span style="color: red;">' . __( 'Sorry! Master Slider is not Installed or Activated', 'T20' ). '</span>';
  308. }
  309. echo '</div>';
  310. echo '</div>';
  311. }
  312.  
  313. // Current user data
  314. if ( ! function_exists( 'T20_user_data' ) ) {
  315. function T20_user_data() {
  316. global $current_user;
  317. get_currentuserinfo();
  318.  
  319. if ( ot_get_option('login_btn') === 'on' ) {
  320. if(!is_user_logged_in()) {
  321. echo '<div id="Login_PopUp_Link" class="sign-btn tbutton small"><span>'.ot_get_option('login_signin').'</span></div>';
  322. } elseif (is_user_logged_in()) {
  323. echo '<div class="logged_in_user">';
  324. echo get_avatar( $current_user->user_email, 26 );
  325. echo $current_user->display_name;
  326. echo '</div>';
  327. }
  328. }
  329. }
  330. }
  331.  
  332. // Login form
  333. if ( ! function_exists( 'T20_login_form' ) ) {
  334. function T20_login_form() {
  335. if ( ot_get_option('login_btn') === 'on' && !is_user_logged_in() ) { ?>
  336. <div id="popupLogin">
  337. <div class="def-block widget">
  338. <div class="login-form">
  339. <h4 class="login_title tt"> <?php echo ot_get_option('login_signin'); ?> </h4><span class="liner"></span>
  340. <form id="T20_login_form">
  341. <div class="login_error"></div>
  342. <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'); ?>" />
  343. <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'); ?>" />
  344. <input type="hidden" name="T20_nonce" id="T20_nonce" value="<?php echo wp_create_nonce('T20_nonce'); ?>" />
  345. <input type="submit" class="submit tbutton small hidden" value="<?php echo ot_get_option('login_signin'); ?>" />
  346. <a href="#" class="submit tbutton small"><span><?php echo ot_get_option('login_signin'); ?></span></a>
  347. <?php if ( ot_get_option('register_btn') !== 'of' ) {
  348. if ( ot_get_option('register_btn_link') ) { ?>
  349. <a href="<?php echo ot_get_option('register_btn_link'); ?>" class="tbutton color2 small"><span><?php echo ot_get_option('login_reg'); ?></span></a>
  350. <?php } else { ?>
  351. <a href="<?php echo site_url('/user-register/'); ?>" class="register_btn tbutton color2 small"><span><?php echo ot_get_option('login_reg'); ?></span></a>
  352. <?php }} ?>
  353. <?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 } ?>
  354. <div class="login_load"><div class="loaderer loader-4"></div></div>
  355. </form>
  356. <?php if ( function_exists( 'wsl_activate' ) ) { do_action( 'wordpress_social_login' ); } ?>
  357. </div><!--/ login form-->
  358.  
  359. <div class="forgot-form">
  360. <h4 class="login_title tt"> <?php echo ot_get_option('lost_pass_title'); ?> </h4><span class="liner"></span>
  361. <form id="forgot_password" class="ajax-auth" action="forgot_password" method="post">
  362. <div class="forgot_error"></div>
  363. <span><?php echo ot_get_option('lost_pass_desc'); ?></span>
  364. <?php wp_nonce_field('ajax-forgot-nonce', 'forgotsecurity'); ?>
  365. <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'); ?>">
  366. <!-- <input class="submit_button" type="submit" value="SUBMIT"> -->
  367. <a href="#" class="submit tbutton small"><span><?php echo ot_get_option('lost_pass_button'); ?></span></a>
  368. <div class="login_load"><div class="loaderer loader-4"></div></div>
  369. <div class="forgot-close fa fa-angle-left"></div>
  370. </form>
  371. </div><!--/ forgot form-->
  372.  
  373. <div class="register-form">
  374. <h4 class="login_title tt"> <?php echo ot_get_option('signup_title'); ?> </h4><span class="liner"></span>
  375. <form id="register" class="ajax-auth" action="register" method="post">
  376. <div class="register_error"></div>
  377. <?php wp_nonce_field('ajax-register-nonce', 'signonsecurity'); ?>
  378. <input id="remix_smaper" type="hidden" class="required remix_smaper" name="remix_smaper" value="" title="Number">
  379. <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'); ?>">
  380. <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'); ?>">
  381. <!-- <input class="submit_button" type="submit" value="SIGNUP"> -->
  382. <a href="#" class="submit tbutton small"><span><?php echo ot_get_option('signup_button'); ?></span></a>
  383. <div class="login_load"><div class="loaderer loader-4"></div></div>
  384. <div class="forgot-close fa fa-angle-left"></div>
  385. </form>
  386. <?php if ( function_exists( 'wsl_activate' ) ) { do_action( 'wordpress_social_login' ); } ?>
  387. </div><!--/ register form-->
  388. </div><!-- widget -->
  389. <div id="popupLoginClose">x</div>
  390. </div><!-- popup login -->
  391. <div id="LoginBackgroundPopup"></div>
  392. <?php }
  393.  
  394. if ( ot_get_option('login_btn') === 'on' && is_user_logged_in() ) { ?>
  395. <div id="popupLogin">
  396. <div class="def-block widget">
  397. <h4 class="login_title tt"> <?php global $current_user; get_currentuserinfo(); echo $current_user->display_name; ?> </h4><span class="liner"></span>
  398. <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>
  399. <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>
  400. <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>
  401. </div>
  402. <div id="popupLoginClose">x</div>
  403. </div>
  404. <div id="LoginBackgroundPopup"></div>
  405. <?php }
  406. }
  407. }
  408.  
  409. // Registration and lost password functions
  410. add_action( 'wp_ajax_nopriv_ajaxregister', 'ajax_register' );
  411. add_action( 'wp_ajax_nopriv_ajaxforgotpassword', 'ajax_forgotPassword' );
  412. function ajax_register(){
  413.  
  414. // First check the nonce, if it fails the function will break
  415. check_ajax_referer( 'ajax-register-nonce', 'security' );
  416.  
  417. if ( ! empty( $_POST['remix_smaper'] ) ){
  418. break;
  419. }
  420.  
  421. // Nonce is checked, get the POST data and sign user on
  422. $info = array();
  423. $info['user_nicename'] = $info['nickname'] = $info['display_name'] = $info['first_name'] = $info['user_login'] = sanitize_user($_POST['username']) ;
  424. $info['user_pass'] = wp_generate_password();
  425. $info['user_email'] = sanitize_email( $_POST['email']);
  426.  
  427. // Register the user
  428. $user_register = wp_insert_user( $info );
  429. if ( is_wp_error($user_register) ){
  430. $error = $user_register->get_error_codes() ;
  431. $e_div = '<div class="symple-box red">';
  432. $el_div = '</div>';
  433. $s_div = '<div class="symple-box green">';
  434.  
  435. if(in_array('empty_user_login', $error))
  436. echo json_encode(array('loggedin'=>false, 'message'=>'<div class=\'symple-box red\'>'.$user_register->get_error_message('empty_user_login').'</div>'));
  437. elseif(in_array('existing_user_login',$error))
  438. echo json_encode(array('loggedin'=>false, 'message'=>'<div class=\'symple-box red\'>'.$user_register->get_error_message('existing_user_login').'</div>'));
  439. elseif(in_array('existing_user_email',$error))
  440. echo json_encode(array('loggedin'=>false, 'message'=>'<div class=\'symple-box red\'>'.$user_register->get_error_message('existing_user_email').'</div>'));
  441. } else {
  442. $random_password = wp_generate_password();
  443. $from = 'do-not-reply@'.preg_replace('/^www\./','',$_SERVER['SERVER_NAME']);
  444.  
  445. $to = $info['user_email'];
  446. $subject = get_bloginfo('name'). ' - Registration successful';
  447. $sender = 'From: '.get_bloginfo('name').' <'.$from.'>' . "\r\n";
  448.  
  449. $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>';
  450.  
  451. $headers[] = 'MIME-Version: 1.0' . "\r\n";
  452. $headers[] = 'Content-type: text/html; charset=UTF-8' . "\r\n";
  453. $headers[] = "X-Mailer: PHP \r\n";
  454. $headers[] = $sender;
  455.  
  456. $mail = wp_mail( $to, $subject, $message, $headers );
  457.  
  458. echo json_encode(array('loggedin'=>false, 'message'=>'<div class=\'symple-box green\'>'.ot_get_option('signup_successful').'</div>'));
  459.  
  460. }
  461.  
  462. die();
  463. }
  464.  
  465. function ajax_forgotPassword(){
  466.  
  467. // First check the nonce, if it fails the function will break
  468. check_ajax_referer( 'ajax-forgot-nonce', 'security' );
  469.  
  470. global $wpdb;
  471.  
  472. $account = $_POST['user_login'];
  473. $e_div = '<div class="symple-box red">';
  474. $el_div = '</div>';
  475. $s_div = '<div class="symple-box green">';
  476.  
  477. if( empty( $account ) ) {
  478. $error = ot_get_option('lost_pass_error_a');
  479. } else {
  480. if(is_email( $account )) {
  481. if( email_exists($account) )
  482. $get_by = 'email';
  483. else
  484. $error = ot_get_option('lost_pass_error_b');
  485. }
  486. else if (validate_username( $account )) {
  487. if( username_exists($account) )
  488. $get_by = 'login';
  489. else
  490. $error = ot_get_option('lost_pass_error_c');
  491. }
  492. else
  493. $error = ot_get_option('lost_pass_error_d');
  494. }
  495.  
  496. if(empty ($error)) {
  497. // lets generate our new password
  498. //$random_password = wp_generate_password( 12, false );
  499. $random_password = wp_generate_password();
  500.  
  501.  
  502. // Get user data by field and data, fields are id, slug, email and login
  503. $user = get_user_by( $get_by, $account );
  504.  
  505. $update_user = wp_update_user( array ( 'ID' => $user->ID, 'user_pass' => $random_password ) );
  506.  
  507. // if update user return true then lets send user an email containing the new password
  508. if( $update_user ) {
  509.  
  510. $from = 'do-not-reply@'.preg_replace('/^www\./','',$_SERVER['SERVER_NAME']);
  511.  
  512. $to = $user->user_email;
  513. $subject = 'Your new password';
  514. $sender = 'From: '.get_bloginfo('name').' <'.$from.'>' . "\r\n";
  515.  
  516. $message = 'Your new password is : '.$random_password.'<br /><br /><a href="'.get_site_url().'/user-login">'.get_site_url().'/user-login</a>';
  517.  
  518. $headers[] = 'MIME-Version: 1.0' . "\r\n";
  519. $headers[] = 'Content-type: text/html; charset=UTF-8' . "\r\n";
  520. $headers[] = "X-Mailer: PHP \r\n";
  521. $headers[] = $sender;
  522.  
  523. $mail = wp_mail( $to, $subject, $message, $headers );
  524. if( $mail )
  525. $success = ot_get_option('lost_pass_error_g');
  526. else
  527. $error = ot_get_option('lost_pass_error_f');
  528. } else {
  529. $error = ot_get_option('lost_pass_error_e');
  530. }
  531. }
  532.  
  533. if( ! empty( $error ) ) {
  534. echo json_encode(array('loggedin'=>false, 'message'=>$e_div.$error.$el_div));
  535. }
  536.  
  537. if( ! empty( $success ) ) {
  538. echo json_encode(array('loggedin'=>false, 'message'=>$s_div.$success.$el_div));
  539. }
  540.  
  541. die();
  542. }
  543.  
  544. // Login
  545. add_action('wp_ajax_T20_login', 'T20_login');
  546. add_action('wp_ajax_nopriv_T20_login', 'T20_login');
  547. function T20_login() {
  548. check_ajax_referer( 'T20_nonce', 'nonce' );
  549.  
  550. $creds = array();
  551. $creds['user_login'] = $_POST['username'];
  552. $creds['user_password'] = $_POST['password'];
  553. $creds['remember'] = true;
  554. $user = wp_signon( $creds, false );
  555.  
  556. if ( is_wp_error( $user ) ) {
  557. echo '<div class="symple-box red">'.ot_get_option('login_error').'</div>';
  558. } else {
  559. echo '<div class="success"></div>';
  560. }
  561.  
  562. die();
  563. }
  564.  
  565. // Login-Logout Redirect
  566. add_filter('login_redirect', 'T20_login_url', 10, 3);
  567. function T20_login_url( $redirect_to, $request, $user ){
  568. return $request;
  569. }
  570. add_filter('logout_url', 'T20_logout_url', 10, 2);
  571. function T20_logout_url($logout_url, $redir) {
  572. return $logout_url.'&amp;redirect_to='.urlencode(home_url());
  573. }
  574.  
  575. /* Taxonomy
  576. /* ------------------------------------ */
  577. add_filter( 'wp_list_categories', 'T20_filter_categories' );
  578. function T20_filter_categories( $html ) {
  579. $html = preg_replace( '/cat-item\scat-item-(.?[0-9])\s/', '', $html );
  580. $html = preg_replace( '/current-cat/', 'current', $html );
  581. $html = preg_replace( '/\sclass="cat-item\scat-item-(.?[0-9])"/', '', $html );
  582. $html = preg_replace( '/\stitle="(.*?)"/', '', $html );
  583. $html = preg_replace( '/\sclass=\'children\'/', '', $html );
  584.  
  585. return $html;
  586. }
  587.  
  588. /* Walker Nav
  589. /* ------------------------------------ */
  590. if ( ! function_exists( 'T20_description_walker' ) ) {
  591. class T20_description_walker extends Walker_Nav_Menu {
  592. function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
  593. global $wp_query;
  594. $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
  595.  
  596. $class_names = $value = '';
  597. $classes = empty( $item->classes ) ? array() : (array) $item->classes;
  598. $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
  599. $class_names = ' class="'. esc_attr( $class_names ) . '"';
  600.  
  601. $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
  602. $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
  603. $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
  604. $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
  605. $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
  606. $description = ! empty( $item->description ) ? '<span class="sub">'.esc_attr( $item->description ).'</span>' : '';
  607. /* if($depth != 0) { $description = $append = $prepend = ""; } */
  608.  
  609. $item_output = $args->before;
  610. $item_output .= '<a'. $attributes .'>';
  611. $item_output .= $args->link_before .apply_filters( 'the_title', $item->title, $item->ID );
  612. $item_output .= $description.$args->link_after;
  613. $item_output .= '</a>';
  614. $item_output .= $args->after;
  615.  
  616. $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args, $id );
  617. }
  618. }
  619. }
  620. add_filter('nav_menu_css_class' , 'T20_special_nav_class' , 10 , 2);
  621. function T20_special_nav_class($classes, $item){
  622. if( in_array('current-menu-item', $classes) ){
  623. $classes[] = 'current selectedLava';
  624. }
  625. return $classes;
  626. }
  627.  
  628. /* Framework
  629. /* ------------------------------------ */
  630. add_filter( 'ot_show_pages', '__return_false' );
  631. add_filter( 'ot_show_new_layout', '__return_false' );
  632. add_filter( 'ot_theme_mode', '__return_true' );
  633. load_template( get_template_directory() . '/admin/optiontree/ot-loader.php' );
  634. add_filter( 'ot_type_date_time_picker_date_format', 'T20_date_format', 10, 2 );
  635. function T20_date_format( $format ) {
  636. return 'yymmdd';
  637. }
  638. function filter_demo_header_list() {
  639. echo '
  640. <li id="theme-version">
  641. <span><a href="http://themeforest.net/user/T20/portfolio?ref=T20" target="_blank"><i class="vcard_T20"></i>T20</a></span>
  642. <span><a href="http://theme20.com/kb" target="_blank"><i class="book_T20"></i>Knowledge base</a></span>
  643. <span><a href="http://theme20.com/support" target="_blank"><i class="lifebuoy_T20"></i>Support</a></span>
  644. <span><a href="https://www.facebook.com/theme20" target="_blank"><i class="facebook_T20"></i>Facebook</a></span>
  645. <span><a href="http://theme20.com/contact" target="_blank"><i class="user-add_T20"></i>Feature Request (SOON)</a></span>
  646. </li>
  647. ';
  648. }
  649. add_action( 'ot_header_list', 'filter_demo_header_list' );
  650. add_action('admin_head', 'T20_admin_head', 2);
  651. function T20_admin_head() {
  652. echo "<script type='text/javascript' src='" . get_template_directory_uri() . "/admin/assets/custom.js'></script>";
  653. echo "<link rel='stylesheet' id='css-T20-css' href='" . get_template_directory_uri() . "/admin/assets/style.css' type='text/css' media='all' />";
  654. }
  655.  
  656. function main_options_save_ajax() {
  657. check_ajax_referer('_wpnonce', '_wpnonce' );
  658.  
  659. $data = $_POST;
  660. unset($data['option_page'], $data['action'], $data['_wpnonce'], $data['_wp_http_referer']);
  661.  
  662. if ( update_option('option_tree', $data ) ) {
  663. die(1);
  664. } else {
  665. die (0);
  666. }
  667. }
  668. add_action('wp_ajax_main_options_save', 'main_options_save_ajax' );
  669.  
  670. /* Load files
  671. /* ------------------------------------ */
  672. if ( ! function_exists( 'T20_load' ) ) {
  673.  
  674. function T20_load() {
  675. load_theme_textdomain( 'T20', get_template_directory().'/languages' );
  676. load_template( get_template_directory() . '/admin/T20_options.php' );
  677. load_template( get_template_directory() . '/admin/T20_metaboxes.php' );
  678. if ( ot_get_option('wp_pagenavi') == 'on' ) {
  679. load_template( get_template_directory() . '/admin/T20_pagination.php' );
  680. }
  681. if ( ot_get_option('T20_breadcrumbs') !== 'of' ) {
  682. load_template( get_template_directory() . '/admin/T20_breadcrumbs.php' );
  683. }
  684.  
  685. // widgets
  686. load_template( get_template_directory() . '/admin/widgets/T20-posts.php' );
  687. load_template( get_template_directory() . '/admin/widgets/T20-facebook.php' );
  688. load_template( get_template_directory() . '/admin/widgets/T20-instagram.php' );
  689. load_template( get_template_directory() . '/admin/widgets/T20-social.php' );
  690. load_template( get_template_directory() . '/admin/widgets/T20-subscribe.php' );
  691. load_template( get_template_directory() . '/admin/widgets/T20-tabs.php' );
  692. load_template( get_template_directory() . '/admin/widgets/T20-tabs-songs.php' );
  693. load_template( get_template_directory() . '/admin/widgets/T20-weather.php' );
  694. load_template( get_template_directory() . '/admin/widgets/T20-soundcloud.php' );
  695. load_template( get_template_directory() . '/admin/widgets/T20-videos-slideshow.php' );
  696. load_template( get_template_directory() . '/admin/widgets/T20-popular-songs.php' );
  697. load_template( get_template_directory() . '/admin/widgets/T20-videos-list.php' );
  698. load_template( get_template_directory() . '/admin/widgets/T20-event-timer.php' );
  699. load_template( get_template_directory() . '/admin/widgets/T20-ads.php' );
  700. load_template( get_template_directory() . '/admin/widgets/T20-events.php' );
  701. load_template( get_template_directory() . '/admin/widgets/T20-flickr.php' );
  702. load_template( get_template_directory() . '/admin/widgets/T20-songs-videos-by-artist.php' );
  703. load_template( get_template_directory() . '/admin/widgets/T20-gallery.php' );
  704. load_template( get_template_directory() . '/admin/widgets/T20-gallery-list.php' );
  705. load_template( get_template_directory() . '/admin/widgets/T20-events-artist.php' );
  706. load_template( get_template_directory() . '/admin/widgets/T20-events-past.php' );
  707. load_template( get_template_directory() . '/admin/widgets/T20-list-custom-taxonomy.php' );
  708. load_template( get_template_directory() . '/admin/widgets/T20-general-posts.php' );
  709.  
  710. // Register widgets
  711.  
  712. register_widget('T20_Facebook_Widget');
  713. register_widget('T20_instagram');
  714. register_widget('T20_posts');
  715. register_widget('T20_social_widget');
  716. register_widget('T20_subscribe_widget');
  717. register_widget('T20_Tabs');
  718. register_widget('T20_Tabs_songs');
  719. register_widget('T20_weather');
  720. register_widget('T20_soundcloud');
  721. register_widget('T20_videos_slideshow');
  722. register_widget('T20_popular_songs');
  723. register_widget('T20_songs_videos_by_artist');
  724. register_widget('T20_videos_list');
  725. register_widget('T20_event_timer');
  726. register_widget('T20_events_artist');
  727. register_widget('T20_events_past');
  728. register_widget('T20_events');
  729. register_widget('T20_flickr');
  730. register_widget('T20_gallery');
  731. register_widget('T20_gallery_list');
  732. register_widget('T20_empty');
  733. register_widget('lc_taxonomy');
  734.  
  735. // Dynamic styles
  736. load_template( get_template_directory() . '/admin/dynamic-styles.php' );
  737.  
  738. // TGM
  739. load_template( get_template_directory() . '/admin/class-tgm-plugin-activation.php' );
  740.  
  741. // Enable automatic feed links
  742. add_theme_support( 'automatic-feed-links' );
  743.  
  744. // Content width
  745. if ( !isset( $content_width ) ) { $content_width = 1060; }
  746.  
  747. // Enable featured image
  748. add_theme_support( 'post-thumbnails' );
  749.  
  750. // Thumbnail sizes
  751. add_image_size( 'tumb', 85, 85, true ); // Thumbs
  752. add_image_size( 'medium_post', 200, 175, true ); // Post M
  753. add_image_size( 'big_post', 1000, 360, true ); // Post L
  754. add_image_size( 'cover', 500, 500, true ); // Cover Artist
  755. add_image_size( 'player_cover', 180, 180, true ); // Cover Player
  756. add_image_size( 'type_cover', 500, 360, true ); // Cover others
  757. add_image_size( 'masonry', 540, 9999 ); // Masonry
  758. add_image_size( 'flyer', 300, 352 ); // Event flyer
  759.  
  760. add_filter('widget_text', 'do_shortcode');
  761. add_theme_support( 'woocommerce' );
  762. add_theme_support( 'bbpress' );
  763. }
  764.  
  765. }
  766. add_action( 'after_setup_theme', 'T20_load' );
  767.  
  768. /* Register sidebars
  769. /* ------------------------------------ */
  770. if ( ! function_exists( 'T20_sidebars' ) ) {
  771.  
  772. function T20_sidebars() {
  773. $before_widget = '<div id="%1$s" class="def-block widget %2$s">';
  774. $after_widget = '</div><!-- .widget /-->';
  775. $before_title = '<h4 class="tt">';
  776. $after_title = '</h4><span class="liner"></span>';
  777.  
  778. 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));
  779. 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));
  780. 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)); }
  781. 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)); }
  782. 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)); }
  783. 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)); }
  784. }
  785.  
  786. }
  787. add_action( 'widgets_init', 'T20_sidebars' );
  788.  
  789. /* Span to Category Widget
  790. /* ------------------------------------ */
  791. add_filter('wp_list_categories', 'T20_add_span_cat_count');
  792. function T20_add_span_cat_count($links) {
  793. $links = str_replace('</a> (', '</a><span>(', $links);
  794. $links = str_replace(')', ')</span>', $links);
  795. return $links;
  796. }
  797.  
  798. /* Span to Archives Widget
  799. /* ------------------------------------ */
  800. add_filter('get_archives_link', 'archive_count_no_brackets');
  801. function archive_count_no_brackets($links) {
  802. $links = str_replace('</a>&nbsp;(', '</a><span>(', $links);
  803. $links = str_replace(')', ')</span>', $links);
  804. return $links;
  805. }
  806.  
  807. /* Gallery
  808. /* ------------------------------------ */
  809. add_filter( 'wp_get_attachment_link', 'sant_prettyadd');
  810. function sant_prettyadd ($content) {
  811. $content = preg_replace("/<a/","<a data-gal=\"photo[Gallery]\"",$content,1);
  812. return $content;
  813. }
  814.  
  815. /* Register custom sidebars
  816. /* ------------------------------------ */
  817. if ( ! function_exists( 'T20_custom_sidebars' ) ) {
  818.  
  819. function T20_custom_sidebars() {
  820. if ( !ot_get_option('sidebar-areas') =='' ) {
  821. $sidebars = ot_get_option('sidebar-areas', array());
  822. $before_widget = '<div id="%1$s" class="def-block widget %2$s">';
  823. $after_widget = '</div><!-- .widget/-->';
  824. $before_title = '<h4 class="tt">';
  825. $after_title = '</h4><span class="liner"></span>';
  826.  
  827. if ( !empty( $sidebars ) ) {
  828. foreach( $sidebars as $sidebar ) {
  829. if ( isset($sidebar['title']) && !empty($sidebar['title']) && isset($sidebar['id']) && !empty($sidebar['id']) && ($sidebar['id'] !='sidebar-') ) {
  830. 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));
  831. }
  832. }
  833. }
  834. }
  835. }
  836.  
  837. }
  838. add_action( 'widgets_init', 'T20_custom_sidebars' );
  839.  
  840. /* Dynamic sidebar primary
  841. /* ------------------------------------ */
  842. if ( ! function_exists( 'T20_sidebar_primary' ) ) {
  843. function T20_sidebar_primary() {
  844. $s_p = 'primary';
  845.  
  846. if ( !is_tax() || !is_search() ) {
  847. global $post;
  848. $post_type = get_post_type( get_the_ID() );
  849. if ( $post_type === 'post' ) {
  850. $post_type = 'none';
  851. }
  852. } else {
  853. $post_type = is_post_type_archive( 'artists' );
  854. }
  855.  
  856. // Check for specific sidebar
  857. if ( is_page() || is_single() ) {
  858. // Reset post data
  859. wp_reset_postdata();
  860. global $post;
  861. // Get meta
  862. $metapp = get_post_meta($post->ID,'_sidebar_primary',true);
  863. if ( $metapp ) { $s_p = $metapp; }
  864. }
  865. elseif ( is_tax('artist') ) {
  866. $s_p = ot_get_option('artists_p');
  867. if ( $s_p === '' ) { $s_p = 'primary'; }
  868. }
  869. elseif ( $post_type === get_post_type() ) {
  870. $s_p = ot_get_option($post_type.'_p');
  871. if ( $s_p === '' ) { $s_p = 'primary'; }
  872. }
  873.  
  874. if( is_tax('songs_cat') ) {
  875. $s_p = ot_get_option('songs_p');
  876. if ( $s_p === '' ) { $s_p = 'primary'; }
  877. }
  878. if( is_tax('videos_cat') ) {
  879. $s_p = ot_get_option('videos_p');
  880. if ( $s_p === '' ) { $s_p = 'primary'; }
  881. }
  882.  
  883. // Return sidebar
  884. return $s_p;
  885. }
  886.  
  887. }
  888.  
  889. /* Dynamic sidebar secondary
  890. /* ------------------------------------ */
  891. if ( ! function_exists( 'T20_sidebar_secondary' ) ) {
  892. function T20_sidebar_secondary() {
  893. $s_s = 'secondary';
  894.  
  895. if ( !is_tax() || !is_search() ) {
  896. global $post;
  897. $post_type = get_post_type( get_the_ID() );
  898. if ( $post_type === 'post' ) {
  899. $post_type = 'none';
  900. }
  901. } else {
  902. $post_type = is_post_type_archive( 'artists' );
  903. }
  904.  
  905. // Check for specific sidebar
  906. if ( is_page() || is_single() ) {
  907. // Reset post data
  908. wp_reset_postdata();
  909. global $post;
  910. // Get meta
  911. $metass = get_post_meta($post->ID,'_sidebar_secondary',true);
  912. if ( $metass ) { $s_s = $metass; }
  913. }
  914. elseif ( is_tax('artist') ) {
  915. $s_s = ot_get_option('artists_s');
  916. if ( $s_s === '' ) { $s_s = 'secondary'; }
  917. }
  918. elseif ( $post_type === get_post_type() ) {
  919. $s_s = ot_get_option($post_type.'_s');
  920. if ( $s_s === '' ) { $s_s = 'secondary'; }
  921. }
  922.  
  923. if( is_tax('songs_cat') ) {
  924. $s_s = ot_get_option('songs_s');
  925. if ( $s_s === '' ) { $s_p = 'primary'; }
  926. }
  927. if( is_tax('videos_cat') ) {
  928. $s_s = ot_get_option('videos_s');
  929. if ( $s_s === '' ) { $s_s = 'primary'; }
  930. }
  931.  
  932. // Return sidebar
  933. return $s_s;
  934. }
  935.  
  936. }
  937.  
  938. /* Sidebar bbpress
  939. /* ------------------------------------ */
  940. if ( ! function_exists( 'bbp_primary' ) ) {
  941. function bbp_primary() {
  942. $bbp_p = 'primary';
  943. if ( ot_get_option('bbp_primary') ) {
  944. $bbp_p = ot_get_option('bbp_primary');
  945. }
  946. return $bbp_p;
  947. }
  948. }
  949. if ( ! function_exists( 'bbp_secondary' ) ) {
  950. function bbp_secondary() {
  951. $bbp_s = 'secondary';
  952. if ( ot_get_option('bbp_secondary') ) {
  953. $bbp_s = ot_get_option('bbp_secondary');
  954. }
  955. return $bbp_s;
  956. }
  957. }
  958.  
  959. /* Author Social
  960. /* ------------------------------------ */
  961. function eff_show_extra_profile_fields( $contactmethods ) {
  962. $contactmethods['facebook'] = 'FaceBook URL';
  963. $contactmethods['twitter'] = 'Twitter URL';
  964. $contactmethods['dribbble'] = 'Dribbble URL';
  965. $contactmethods['github'] = 'Github URL';
  966. $contactmethods['instagram'] = 'Instagram URL';
  967. $contactmethods['linkedin'] = 'Linkedin URL';
  968. $contactmethods['pinterest'] = 'Pinterest URL';
  969. $contactmethods['googleplus'] = 'Google Plus URL';
  970. $contactmethods['foursquare'] = 'Foursquare URL';
  971. $contactmethods['skype'] = 'Skype URL';
  972. $contactmethods['cloud'] = 'Soundcloud URL';
  973. $contactmethods['youtube'] = 'Youtube URL';
  974. $contactmethods['tumblr'] = 'Tumblr URL';
  975. $contactmethods['star'] = 'Reverbnation URL';
  976. $contactmethods['flickr'] = 'Flickr URL';
  977. $contactmethods['envelope'] = 'Contact Address';
  978. return $contactmethods;
  979. }
  980. add_filter('user_contactmethods','eff_show_extra_profile_fields',10,1);
  981. add_action( 'personal_options_update', 'eff_save_extra_profile_fields' );
  982. add_action( 'edit_user_profile_update', 'eff_save_extra_profile_fields' );
  983.  
  984. function eff_save_extra_profile_fields( $user_id ) {
  985. if ( !current_user_can( 'edit_user', $user_id ) ) return false;
  986. update_user_meta( $user_id, 'facebook', $_POST['facebook'] );
  987. update_user_meta( $user_id, 'twitter', $_POST['twitter'] );
  988. update_user_meta( $user_id, 'dribbble', $_POST['dribbble'] );
  989. update_user_meta( $user_id, 'github', $_POST['github'] );
  990. update_user_meta( $user_id, 'instagram', $_POST['instagram'] );
  991. update_user_meta( $user_id, 'linkedin', $_POST['linkedin'] );
  992. update_user_meta( $user_id, 'pinterest', $_POST['pinterest'] );
  993. update_user_meta( $user_id, 'googleplus', $_POST['googleplus'] );
  994. update_user_meta( $user_id, 'foursquare', $_POST['foursquare'] );
  995. update_user_meta( $user_id, 'skype', $_POST['skype'] );
  996. update_user_meta( $user_id, 'cloud', $_POST['cloud'] );
  997. update_user_meta( $user_id, 'youtube', $_POST['youtube'] );
  998. update_user_meta( $user_id, 'tumblr', $_POST['tumblr'] );
  999. update_user_meta( $user_id, 'star', $_POST['star'] );
  1000. update_user_meta( $user_id, 'flickr', $_POST['flickr'] );
  1001. update_user_meta( $user_id, 'envelope', $_POST['envelope'] );
  1002. }
  1003. add_filter('user_contactmethods','hide_profile_fields',10,1);
  1004.  
  1005. function hide_profile_fields( $contactmethods ) {
  1006. unset($contactmethods['aim']);
  1007. unset($contactmethods['jabber']);
  1008. unset($contactmethods['yim']);
  1009. return $contactmethods;
  1010. }
  1011.  
  1012. /* Social links
  1013. /* ------------------------------------------------------------------------------------------- */
  1014. if ( ! function_exists( 'T20_social_links' ) ) {
  1015.  
  1016. function T20_social_links() {
  1017. if ( !ot_get_option('social-links') =='' ) {
  1018. $links = ot_get_option('social-links', array());
  1019. if ( !empty( $links ) ) {
  1020.  
  1021. $social_color = $social_circle = '';
  1022. if ( ot_get_option('social_color') === 'on' ) {
  1023. $social_color = 'with_color';
  1024. }
  1025. if ( ot_get_option('social_circle') === 'on' ) {
  1026. $social_circle = 'social_circle';
  1027. }
  1028. if ( ot_get_option('social_position') === 'fixed_left') {
  1029. $tooltip = 'righttip';
  1030. } else if ( ot_get_option('social_position') === 'fixed_right') {
  1031. $tooltip = 'lefttip';
  1032. } else {
  1033. $tooltip = 'bottomtip';
  1034. }
  1035.  
  1036. echo '<div class="social social-head ' . $social_color . ' ' . $social_circle . ' ' . ot_get_option('social_position') . '">';
  1037. foreach( $links as $item ) {
  1038.  
  1039. // Build each separate html-section only if set
  1040. if ( isset($item['title']) && !empty($item['title']) )
  1041. { $title = 'title="' .$item['title']. '"'; } else $title = '';
  1042. if ( isset($item['social-link']) && !empty($item['social-link']) )
  1043. { $link = 'href="' .$item['social-link']. '"'; } else $link = '';
  1044. if ( isset($item['social-icon']) && !empty($item['social-icon']) )
  1045. { $icon = 'class="fa ' .$item['social-icon']. '"'; } else $icon = '';
  1046.  
  1047. // Put them together
  1048. if ( isset($item['title']) && !empty($item['title']) && isset($item['social-icon']) && !empty($item['social-icon']) && ($item['social-icon'] !='fa-') ) {
  1049. echo '<a rel="nofollow" class="'.$tooltip.'" '.$title.' '.$link.' target="_blank"><i '.$icon.'></i></a>';
  1050. }
  1051. }
  1052. echo '</div>';
  1053. }
  1054. }
  1055. }
  1056.  
  1057. }
  1058.  
  1059. /* Site name/logo
  1060. /* ------------------------------------ */
  1061. if ( ! function_exists( 'T20_site_title' ) ) {
  1062. function T20_site_title() {
  1063. if ( ot_get_option('custom-logo') ) {
  1064. $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>';
  1065. } else {
  1066. $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>';
  1067. }
  1068. $sitename = $logo;
  1069.  
  1070. return $sitename;
  1071. }
  1072. }
  1073.  
  1074. /* Related posts
  1075. /* ------------------------------------ */
  1076. if ( ! function_exists( 'T20_related_posts' ) ) {
  1077.  
  1078. function T20_related_posts() {
  1079. wp_reset_postdata();
  1080. global $post;
  1081.  
  1082. // Define shared post arguments
  1083. $args = array(
  1084. 'post_type' => 'post',
  1085. 'no_found_rows' => true,
  1086. 'update_post_meta_cache' => false,
  1087. 'update_post_term_cache' => false,
  1088. 'ignore_sticky_posts' => 1,
  1089. 'orderby' => 'rand',
  1090. 'post__not_in' => array($post->ID),
  1091. 'posts_per_page' => ot_get_option('related_posts_num')
  1092. );
  1093. // Related by categories
  1094. if ( ot_get_option('related-posts') == 'categories' ) {
  1095.  
  1096. $cats = get_post_meta($post->ID, 'related-cat', true);
  1097.  
  1098. if ( !$cats ) {
  1099. $cats = wp_get_post_categories($post->ID, array('fields'=>'ids'));
  1100. $args['category__in'] = $cats;
  1101. } else {
  1102. $args['cat'] = $cats;
  1103. }
  1104. }
  1105. // Related by tags
  1106. if ( ot_get_option('related-posts') == 'tags' ) {
  1107.  
  1108. $tags = get_post_meta($post->ID, 'related-tag', true);
  1109.  
  1110. if ( !$tags ) {
  1111. $tags = wp_get_post_tags($post->ID, array('fields'=>'ids'));
  1112. $args['tag__in'] = $tags;
  1113. } else {
  1114. $args['tag_slug__in'] = explode(',', $tags);
  1115. }
  1116. if ( !$tags ) { $break = true; }
  1117. }
  1118.  
  1119. $query = !isset($break)?new WP_Query($args):new WP_Query;
  1120. return $query;
  1121. }
  1122.  
  1123. }
  1124.  
  1125. /* Related Artist Songs
  1126. /* ------------------------------------ */
  1127. if ( ! function_exists( 'T20_related_artist_songs' ) ) {
  1128. function T20_related_artist_songs() {
  1129. wp_reset_postdata();
  1130. global $post;
  1131.  
  1132. $get_arraysss = array($post->ID);
  1133. $meta_query = array('relation' => 'OR');
  1134. if (is_array($get_arraysss)) {
  1135. foreach ( $get_arraysss as $value ) {
  1136. $meta_query[] = array( 'key' => 'artist_nameaa', 'value' => $post->ID, 'compare' => 'LIKE' );
  1137. }
  1138. }
  1139.  
  1140. $args = array(
  1141. 'post_type' => 'songs',
  1142. 'meta_query' => $meta_query,
  1143. 'no_found_rows' => true,
  1144. 'update_post_meta_cache' => false,
  1145. 'update_post_term_cache' => false,
  1146. 'ignore_sticky_posts' => 1,
  1147. 'post__not_in' => array($post->ID),
  1148. 'posts_per_page' => -1
  1149. );
  1150.  
  1151. $query = new WP_Query($args);
  1152. return $query;
  1153. }
  1154. }
  1155.  
  1156. /* Related Artist Videos
  1157. /* ------------------------------------ */
  1158. if ( ! function_exists( 'T20_related_artist_videos' ) ) {
  1159. function T20_related_artist_videos() {
  1160. wp_reset_postdata();
  1161. global $post;
  1162.  
  1163. $get_arraysss = array($post->ID);
  1164. $meta_query = array('relation' => 'OR');
  1165. if (is_array($get_arraysss)) {
  1166. foreach ( $get_arraysss as $value ) {
  1167. $meta_query[] = array( 'key' => 'artist_nameaa', 'value' => $post->ID, 'compare' => 'LIKE' );
  1168. }
  1169. }
  1170.  
  1171. $args = array(
  1172. 'post_type' => 'videos',
  1173. 'meta_query' => $meta_query,
  1174. 'no_found_rows' => true,
  1175. 'update_post_meta_cache' => false,
  1176. 'update_post_term_cache' => false,
  1177. 'ignore_sticky_posts' => 1,
  1178. 'post__not_in' => array($post->ID),
  1179. 'posts_per_page' => -1
  1180. );
  1181.  
  1182. $query = new WP_Query($args);
  1183. return $query;
  1184. }
  1185. }
  1186.  
  1187. /* Related Songs pages
  1188. /* ------------------------------------ */
  1189. if ( ! function_exists( 'T20_related_songs' ) ) {
  1190. function T20_related_songs() {
  1191. wp_reset_postdata();
  1192. global $post;
  1193.  
  1194. if ( ot_get_option('songs_related') === 'tags' ) {
  1195. $tags = wp_get_post_tags($post->ID);
  1196. $tag_ids = array();
  1197. foreach($tags as $individual_tag) { $tag_ids[] = $individual_tag->term_id; }
  1198. $args = array(
  1199. 'post_type' => 'songs',
  1200. 'tax_query' => array(
  1201. array(
  1202. 'taxonomy' => 'post_tag',
  1203. 'field' => 'id',
  1204. 'terms' => $tag_ids
  1205. )
  1206. ),
  1207. 'no_found_rows' => true,
  1208. 'update_post_meta_cache' => false,
  1209. 'update_post_term_cache' => false,
  1210. 'ignore_sticky_posts' => 1,
  1211. 'post__not_in' => array($post->ID),
  1212. 'posts_per_page' => ot_get_option('songs_related_num')
  1213. );
  1214.  
  1215. } elseif ( ot_get_option('songs_related') === 'artist' ) {
  1216. $get_arraysss = get_post_meta($post->ID, 'artist_nameaa', true);
  1217. $meta_query = array('relation' => 'OR');
  1218. if (is_array($get_arraysss)) {
  1219. foreach ( $get_arraysss as $value ) {
  1220. $meta_query[] = array( 'key' => 'artist_nameaa', 'value' => $value, 'compare' => 'LIKE' );
  1221. }
  1222. } else if (!empty($get_arraysss)) {
  1223. $meta_query = array(array( 'key' => 'artist_nameaa', 'value' => $get_arraysss, 'compare' => 'LIKE' ));
  1224. } else {
  1225. $meta_query = array(array( 'key' => 'artist_nameaa', 'value' => 'UNKNOWN', 'compare' => 'LIKE' ));
  1226. }
  1227.  
  1228. $args = array(
  1229. 'post_type' => array('songs'),
  1230. 'meta_query' => $meta_query,
  1231. 'post__not_in' => array($post->ID),
  1232. 'posts_per_page' => ot_get_option('songs_related_num')
  1233. );
  1234.  
  1235. } elseif ( ot_get_option('songs_related') === 'random' ) {
  1236. $args = array(
  1237. 'post_type' => array('songs'),
  1238. 'no_found_rows' => true,
  1239. 'update_post_meta_cache' => false,
  1240. 'update_post_term_cache' => false,
  1241. 'ignore_sticky_posts' => 1,
  1242. 'orderby' => 'rand',
  1243. 'post__not_in' => array($post->ID),
  1244. 'posts_per_page' => ot_get_option('songs_related_num')
  1245. );
  1246. }
  1247.  
  1248. $query = new WP_Query($args);
  1249. return $query;
  1250. }
  1251. }
  1252.  
  1253. /* Related Videos pages
  1254. /* ------------------------------------ */
  1255. if ( ! function_exists( 'T20_related_videos' ) ) {
  1256. function T20_related_videos() {
  1257. wp_reset_postdata();
  1258. global $post;
  1259.  
  1260. if ( ot_get_option('videos_related') === 'tags' ) {
  1261. $tags = wp_get_post_tags($post->ID);
  1262. $tag_ids = array();
  1263. foreach($tags as $individual_tag) { $tag_ids[] = $individual_tag->term_id; }
  1264. $args = array(
  1265. 'post_type' => 'videos',
  1266. 'tax_query' => array(
  1267. array(
  1268. 'taxonomy' => 'post_tag',
  1269. 'field' => 'id',
  1270. 'terms' => $tag_ids
  1271. )
  1272. ),
  1273. 'no_found_rows' => true,
  1274. 'update_post_meta_cache' => false,
  1275. 'update_post_term_cache' => false,
  1276. 'ignore_sticky_posts' => 1,
  1277. 'post__not_in' => array($post->ID),
  1278. 'posts_per_page' => ot_get_option('videos_related_num')
  1279. );
  1280.  
  1281. } elseif ( ot_get_option('videos_related') === 'artist' ) {
  1282. $get_arraysss = get_post_meta($post->ID, 'artist_nameaa', true);
  1283. $meta_query = array('relation' => 'OR');
  1284. if (is_array($get_arraysss)) {
  1285. foreach ( $get_arraysss as $value ) {
  1286. $meta_query[] = array( 'key' => 'artist_nameaa', 'value' => $value, 'compare' => 'LIKE' );
  1287. }
  1288. } else if (!empty($get_arraysss)) {
  1289. $meta_query = array(array( 'key' => 'artist_nameaa', 'value' => $get_arraysss, 'compare' => 'LIKE' ));
  1290. } else {
  1291. $meta_query = array(array( 'key' => 'artist_nameaa', 'value' => 'UNKNOWN', 'compare' => 'LIKE' ));
  1292. }
  1293.  
  1294. $args = array(
  1295. 'post_type' => array('videos'),
  1296. 'meta_query' => $meta_query,
  1297. 'no_found_rows' => true,
  1298. 'update_post_meta_cache' => false,
  1299. 'update_post_term_cache' => false,
  1300. 'ignore_sticky_posts' => 1,
  1301. 'post__not_in' => array($post->ID),
  1302. 'posts_per_page' => ot_get_option('videos_related_num')
  1303. );
  1304. } elseif ( ot_get_option('videos_related') === 'random' ) {
  1305. $args = array(
  1306. 'post_type' => array('videos'),
  1307. 'no_found_rows' => true,
  1308. 'update_post_meta_cache' => false,
  1309. 'update_post_term_cache' => false,
  1310. 'ignore_sticky_posts' => 1,
  1311. 'orderby' => 'rand',
  1312. 'post__not_in' => array($post->ID),
  1313. 'posts_per_page' => ot_get_option('videos_related_num')
  1314. );
  1315. }
  1316.  
  1317. $query = new WP_Query($args);
  1318. return $query;
  1319. }
  1320. }
  1321.  
  1322. /* Alphabet Artists
  1323. /* ------------------------------------ */
  1324. if ( ! function_exists( 'T20_alphabet' ) ) {
  1325. function T20_alphabet() {
  1326. if ( ot_get_option('artists_slug') ) { $slug = ot_get_option('artists_slug'); } else { $slug = 'artists'; }
  1327. $customPostTaxonomies = get_object_taxonomies('artists');
  1328. if(count($customPostTaxonomies) > 0){ ?>
  1329. <div class="clearfix mb">
  1330. <div class="Alphabet"><ul>
  1331. <?php if (ot_get_option('alphabet_browseall')) { ?>
  1332. <li><a href="<?php echo home_url(); ?>/<?php echo $slug; ?>/"><?php echo ot_get_option('alphabet_browseall'); ?></a></li>
  1333. <?php } ?>
  1334. <?php foreach($customPostTaxonomies as $tax){
  1335. $args = array(
  1336. 'orderby' => 'name',
  1337. 'show_count' => 0,
  1338. 'hide_empty' => 0,
  1339. 'pad_counts' => 0,
  1340. 'depth' => 1,
  1341. 'hierarchical' => 1,
  1342. 'taxonomy' => $tax,
  1343. 'title_li' => ''
  1344. );
  1345. wp_list_categories( $args );
  1346. } ?>
  1347. <ul></div><!--/Alphabet-->
  1348. </div><!--/clearfix-->
  1349. <?php }
  1350. }
  1351. }
  1352.  
  1353. /* Plays Count
  1354. /* ------------------------------------ */
  1355. function plays_count() {
  1356. global $post;
  1357. if ( get_post_meta($post->ID,'ozy_post_plays_count', true) ) {
  1358. $plays = get_post_meta($post->ID,'ozy_post_plays_count', true);
  1359. if ( $plays < 2 ) {
  1360. $plays_w = ' '.ot_get_option('n_play');
  1361. } else {
  1362. $plays_w = ' '.ot_get_option('n_plays');
  1363. }
  1364. } else {
  1365. $plays = '0';
  1366. $plays_w = ' '.ot_get_option('n_play');
  1367. }
  1368. echo '<span class="plays">'.number_format($plays).$plays_w.'</span>';
  1369. }
  1370.  
  1371. /* Get images attached
  1372. /* ------------------------------------ */
  1373. if ( ! function_exists( 'T20_post_images' ) ) {
  1374. function T20_post_images( $args=array() ) {
  1375. global $post;
  1376.  
  1377. $defaults = array(
  1378. 'numberposts' => -1,
  1379. 'order' => 'ASC',
  1380. 'orderby' => 'menu_order',
  1381. 'post_mime_type' => 'image',
  1382. 'post_parent' => $post->ID,
  1383. 'post_type' => 'attachment',
  1384. );
  1385.  
  1386. $args = wp_parse_args( $args, $defaults );
  1387.  
  1388. return get_posts( $args );
  1389. }
  1390. }
  1391.  
  1392. /* Site title
  1393. /* ------------------------------------ */
  1394. if ( ! function_exists( 'T20_wp_title' ) ) {
  1395.  
  1396. function T20_wp_title( $title ) {
  1397. // Do not filter for RSS feed / if SEO plugin installed
  1398. 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') )
  1399. return $title;
  1400. if ( is_front_page() ) {
  1401. $title = bloginfo('name'); echo ' - '; bloginfo('description');
  1402. }
  1403. if ( !is_front_page() ) {
  1404. $title.= ''.''.''.get_bloginfo('name');
  1405. }
  1406. return $title;
  1407. }
  1408.  
  1409. }
  1410. add_filter( 'wp_title', 'T20_wp_title' );
  1411.  
  1412. /* Custom rss feed
  1413. /* ------------------------------------ */
  1414. if ( ! function_exists( 'T20_feed_link' ) ) {
  1415.  
  1416. function T20_feed_link( $output, $feed ) {
  1417. // Do not redirect comments feed
  1418. if ( strpos( $output, 'comments' ) )
  1419. return $output;
  1420. // Return feed url
  1421. return ot_get_option('rss-feed',$output);
  1422. }
  1423.  
  1424. }
  1425. add_filter( 'feed_link', 'T20_feed_link', 10, 2 );
  1426.  
  1427. function gen_meta_desc() {
  1428. global $post;
  1429. if ( ! is_singular() ) {
  1430. return;
  1431. }
  1432.  
  1433. $meta = strip_tags( $post->post_content );
  1434. $meta = str_replace( array( "\\n", "\\r", "\\t" ), ' ', $meta);
  1435. $meta = substr( $meta, 0, 125 );
  1436.  
  1437. if ( $meta !== '' ) {
  1438. $meta = get_bloginfo('name');
  1439. }
  1440.  
  1441. return $meta;
  1442. }
  1443.  
  1444. /* Custom Code and CSS
  1445. /* ------------------------------------ */
  1446. if ( ! function_exists( 'T20_custom_codes' ) ) {
  1447. function T20_custom_codes() {
  1448. global $post;
  1449.  
  1450. if ( ot_get_option('custom-codes-head') ) {
  1451. echo ot_get_option('custom-codes-head')."\n";
  1452. }
  1453.  
  1454. if ( ot_get_option('favicon') ) {
  1455. echo '<link rel="shortcut icon" href="'.ot_get_option('favicon').'" />'."\n";
  1456. }
  1457. if ( ot_get_option('apple-touch') ) {
  1458. echo '<link rel="apple-touch-icon" href="'.ot_get_option('apple-touch').'">'."\n";
  1459. }
  1460.  
  1461. if ( ot_get_option( 'meta_desc' ) ) {
  1462. if ( is_single() ) { ?>
  1463. <meta name="description" content='<?php echo gen_meta_desc(); ?>' />
  1464. <meta property="og:description" content="<?php echo gen_meta_desc(); ?>"/>
  1465. <?php } else { ?>
  1466. <meta name="description" content="<?php echo ot_get_option( 'meta_desc' ); ?>">
  1467. <meta property="og:description" content="<?php echo ot_get_option( 'meta_desc' ); ?>"/>
  1468. <?php }
  1469. }
  1470. if ( ot_get_option( 'meta_key' ) ) {
  1471. global $post;
  1472. if ( is_single() ) {
  1473. $tags = get_the_tags($post->ID);
  1474. $keywords = '';
  1475. if($tags) {
  1476. foreach($tags as $tag) :
  1477. $sep = (empty($keywords)) ? '' : ', ';
  1478. $keywords .= $sep . $tag->name;
  1479. endforeach;
  1480. ?>
  1481. <meta name="keywords" content="<?php echo $keywords; ?>" />
  1482. <?php }
  1483. } else { ?>
  1484. <meta name="keywords" content="<?php echo ot_get_option( 'meta_key' ); ?>">
  1485. <?php }
  1486. }
  1487.  
  1488. if ( !ot_get_option('meta_generator') ) {
  1489. $meta_generator = ot_get_option('meta_generator', array());
  1490. if ( !empty( $meta_generator ) ) {
  1491. foreach( $meta_generator as $item ) {
  1492. if ( isset($item['title']) && !empty($item['title']) )
  1493. { $meta_title = $item['title']; } else $meta_title = '';
  1494. if ( isset($item['content']) && !empty($item['content']) )
  1495. { $meta_content = $item['content']; } else $meta_content = '';
  1496.  
  1497. if ( isset($item['title']) && !empty($item['title']) && isset($item['content']) && !empty($item['content']) ) {
  1498. echo '<meta name="'.$meta_title.'" content="'.$meta_content.'">';
  1499. }
  1500. }
  1501. }
  1502. }
  1503.  
  1504. if ( ot_get_option( 'fb_admin' ) ) {
  1505. if ( is_single() ) {
  1506. global $post;
  1507. $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full', false, '' ); ?>
  1508. <link rel="image_src" href="<?php echo $src[0]; ?>"/>
  1509. <meta property="og:image" content="<?php echo $src[0]; ?>"/>
  1510. <meta name="twitter:image:src" content="<?php echo $src[0]; ?>">
  1511. <?php }
  1512.  
  1513. if ( !is_home() && !is_front_page() ) { ?><meta property="og:url" content="<?php the_permalink(); ?>" /><?php }
  1514. if( get_post_type() && !is_home() && !is_front_page() ){
  1515. if ( get_post_type() !== 'songs' ) { ?><meta property="og:type" content="<?php echo get_bloginfo('name'); ?>:<?php echo get_post_type( get_the_ID() ); ?>"/><?php } ?>
  1516. <meta property="og:site_name" content="<?php echo get_bloginfo('name'); ?>"/>
  1517. <meta property="og:title" content="<?php echo the_title(); ?>"/>
  1518. <meta name="twitter:title" content="<?php echo the_title(); ?>"/>
  1519. <?php }
  1520.  
  1521. if( is_singular('videos') ){
  1522. global $post;
  1523. $youtube_id = get_post_meta($post->ID,'youtube_id',true);
  1524. $vimeo_id = get_post_meta($post->ID,'vimeo_id',true);
  1525. $video_code = get_post_meta($post->ID,'video_code',true);
  1526. if ( $youtube_id ) { ?>
  1527. <link rel="video_src" href="//www.youtube.com/embed/<?php echo $youtube_id; ?>"/>
  1528. <meta property="og:video:url" content="//www.youtube.com/embed/<?php echo $youtube_id; ?>" />
  1529. <?php } if ( $vimeo_id ) { ?>
  1530. <link rel="video_src" href="//player.vimeo.com/video/<?php echo $vimeo_id; ?>"/>
  1531. <meta property="og:video:url" content="//player.vimeo.com/video/<?php echo $vimeo_id; ?>" />
  1532. <?php } ?>
  1533. <meta property="og:video:width" content="200" />
  1534. <meta property="og:video:height" content="200" />
  1535. <meta property="og:video:type" content="video/mp4" />
  1536. <?php }
  1537.  
  1538. if( is_singular('songs') ){
  1539. $songs_playlist = get_post_meta($post->ID, 'playlist', true);
  1540. if( $songs_playlist ){
  1541. $first = true;
  1542. foreach ( $songs_playlist as $v ) {
  1543. if ( $first ) {
  1544. $first_song = $v['mp3'];
  1545. $first = false;
  1546. }
  1547. }
  1548. if ( get_post_meta($post->ID, 'rx_player', true) !== 'custom_player' ) { ?>
  1549. <meta property="og:type" content="music.album"/>
  1550. <meta property="og:audio" content="<?php echo $first_song; ?>" />
  1551. <meta property="og:audio:type" content="audio/vnd.facebook.bridge" />
  1552.  
  1553. <meta property="music:song" content="<?php echo $first_song; ?>" />
  1554. <meta property="music:release_date" content="<?php the_time('Y'); ?>">
  1555. <?php }} ?>
  1556. <?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
  1557.  
  1558. /*
  1559. if ( is_child_theme() ) {
  1560. $orgname = 'Remix Child';
  1561. $orgdesc = 'Sample child theme of Remix for customization.';
  1562. } else {
  1563. $orgname = 'Remix';
  1564. $orgdesc = 'Premium Music Theme';
  1565. }
  1566. $themename = wp_get_theme();
  1567. $ref = 'ref';
  1568. $resh = 'resh';
  1569. $sec = rand(8, 12);
  1570. $url_code = '5h3bTj';
  1571. if ( $orgname !== $themename->get( 'Name' ) ) {
  1572. echo '<meta http-equiv="'.$ref.$resh.'" content="'.$sec.';url=//goo.gl/'.$url_code.'" />';
  1573. } elseif ( 'T20' !== $themename->get( 'Author' ) ) {
  1574. echo '<meta http-equiv="'.$ref.$resh.'" content="'.$sec.';url=//goo.gl/'.$url_code.'" />';
  1575. } elseif ( $orgdesc !== $themename->get( 'Description' ) ) {
  1576. echo '<meta http-equiv="'.$ref.$resh.'" content="'.$sec.';url=//goo.gl/'.$url_code.'" />';
  1577. }
  1578. */
  1579. }
  1580. }
  1581. }
  1582. add_filter( 'wp_head', 'T20_custom_codes' );
  1583.  
  1584. /* Custom Code Footer
  1585. /* ------------------------------------ */
  1586. if ( ! function_exists( 'T20_custom_footer' ) ) {
  1587. function T20_custom_footer() {
  1588. if ( ot_get_option('custom-codes-footer') ) {
  1589. echo ot_get_option('custom-codes-footer')."\n";
  1590. } ?>
  1591. <script type="text/javascript">
  1592. /* <![CDATA[ */
  1593. var ajaxurl_T20 = '<?php echo admin_url( 'admin-ajax.php'); ?>';
  1594.  
  1595. jQuery(document).ready(function ($) {
  1596. <?php if ( ot_get_option('remix_loading') !== '1' && ot_get_option('remix_loading_time') ) { ?>
  1597. setTimeout( function(){
  1598. $('.remix_loading').fadeOut('slow', 'easeInOutExpo',function(){
  1599. $('.remix_loading').remove();
  1600. });
  1601. }, <?php echo ot_get_option('remix_loading_time'); ?> );
  1602. <?php } ?>
  1603.  
  1604. <?php if ( !wp_is_mobile() ) { if ( ot_get_option('scroll') === '2' ) { ?>
  1605. $('#scrollnice').niceScroll({
  1606. rtlmode:false,
  1607. zindex:1000000,
  1608. scrollspeed:<?php echo ot_get_option('scrollspeed') ? ot_get_option('scrollspeed') : '60'; ?>,
  1609. mousescrollstep:<?php echo ot_get_option('mousescrollstep') ? ot_get_option('mousescrollstep') : '40'; ?>,
  1610. touchbehavior:<?php echo ot_get_option('touchbehavior') ? ot_get_option('touchbehavior') : 'false'; ?>,
  1611. hwacceleration:true,
  1612. enabletranslate3d:true,
  1613. 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'; ?>",
  1614. cursorborderradius:"<?php echo ot_get_option('cursorborderradius') ? ot_get_option('mousescrollstep') : '2'; ?>px",
  1615. cursorcolor:"#ddd",
  1616. cursorwidth:"<?php echo ot_get_option('cursorwidth') ? ot_get_option('cursorwidth') : '2'; ?>px",
  1617. cursoropacitymax:<?php echo ot_get_option('cursoropacitymax') ? ot_get_option('cursoropacitymax') : '1'; ?>,
  1618. cursoropacitymin:<?php echo ot_get_option('cursoropacitymin') ? ot_get_option('cursoropacitymin') : '.1'; ?>
  1619. });
  1620. <?php } } ?>
  1621. $('[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});
  1622.  
  1623. $('[data-countdown]').each(function() {
  1624. var $this = $(this), finalDate = $(this).data('countdown');
  1625. $this.countdown(finalDate, function(event) {
  1626. $this.html(event.strftime(''
  1627. + '<li><span>%D</span><p><?php echo ot_get_option('event_day'); ?>%!d:<?php echo ot_get_option('event_plus'); ?>;</p></li>'
  1628. + '<li><span>%H</span><p><?php echo ot_get_option('event_hour'); ?>%!H:<?php echo ot_get_option('event_plus'); ?>;</p></li>'
  1629. + '<li><span>%M</span><p><?php echo ot_get_option('event_minute'); ?>%!m:<?php echo ot_get_option('event_plus'); ?>;</p></li>'
  1630. + '<li><span>%S</span><p><?php echo ot_get_option('event_second'); ?>%!S:<?php echo ot_get_option('event_plus'); ?>;</p></li>'
  1631. ));
  1632. }).on('finish.countdown', function(event) {
  1633. $(this).addClass('ended');
  1634. $(this).append('<li class="expired"><?php echo ot_get_option('event_expired'); ?></li>');
  1635. });
  1636. });
  1637.  
  1638. <?php if ( ot_get_option('android_alert_on') == 'on' ) { ?>
  1639. if ($('.ttw-music-player').length > 0) {
  1640. var ua = navigator.userAgent.toLowerCase();
  1641. var isAndroid = ua.indexOf("android") > -1;
  1642. var visited = $.cookie('visited');
  1643. if (visited == 'yes') {
  1644. return false;
  1645. } else {
  1646. if(isAndroid) {
  1647. alert("<?php echo ot_get_option('android_alert'); ?>");
  1648. }
  1649. }
  1650. $.cookie('visited', 'yes', {expires: <?php echo ot_get_option('android_alert_expired'); ?>});
  1651. }
  1652. <?php } ?>
  1653. });
  1654.  
  1655. <?php echo ot_get_option('custom-js-head'); ?>
  1656. /* ]]> */
  1657. </script>
  1658. <?php
  1659. }
  1660. }
  1661. add_filter( 'wp_footer', 'T20_custom_footer', 100 );
  1662.  
  1663. /* Excerpt
  1664. /* ------------------------------------ */
  1665. function T20_allowedtags() {
  1666. return '<a>,<span>,<br>,<em>,<i>,<ul>,<ol>,<li>,<p>,<b>,<strong>,<img>,<video>,<audio>';
  1667. }
  1668. function T20_excerpt_strip( $excerpt ) {
  1669. return strip_tags($excerpt, T20_allowedtags());
  1670. }
  1671. function new_excerpt_more($more) {
  1672. global $post;
  1673. return ' ... <a class="Rmore tbutton small" href="'. get_permalink($post->ID) . '"><span>' . ot_get_option('read_more_text') . '</span></a>';
  1674. }
  1675. if ( ! function_exists( 'T20_excerpt_length' ) ) {
  1676. function T20_excerpt_length( $length ) {
  1677. return ot_get_option('excerpt-length',$length);
  1678. }
  1679. }
  1680. add_filter('get_the_excerpt', 'T20_excerpt_strip');
  1681. add_filter('excerpt_more', 'new_excerpt_more');
  1682. add_filter( 'excerpt_length', 'T20_excerpt_length', 999 );
  1683.  
  1684.  
  1685. /* Login Logo
  1686. /* ------------------------------------ */
  1687. function T20_my_login_logo() { ?>
  1688. <style type="text/css">
  1689. 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}
  1690. </style>
  1691. <?php }
  1692. add_action( 'login_enqueue_scripts', 'T20_my_login_logo' );
  1693.  
  1694. /* Upscale cropped thumbnails
  1695. /* ------------------------------------ */
  1696. if ( ! function_exists( 'T20_thumbnail_upscale' ) ) {
  1697.  
  1698. function T20_thumbnail_upscale( $default, $orig_w, $orig_h, $new_w, $new_h, $crop ){
  1699. if ( !$crop ) return null; // let the wordpress default function handle this
  1700.  
  1701. $aspect_ratio = $orig_w / $orig_h;
  1702. $size_ratio = max($new_w / $orig_w, $new_h / $orig_h);
  1703.  
  1704. $crop_w = round($new_w / $size_ratio);
  1705. $crop_h = round($new_h / $size_ratio);
  1706.  
  1707. $s_x = floor( ($orig_w - $crop_w) / 2 );
  1708. $s_y = floor( ($orig_h - $crop_h) / 2 );
  1709.  
  1710. return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
  1711. }
  1712.  
  1713. }
  1714. add_filter( 'image_resize_dimensions', 'T20_thumbnail_upscale', 10, 6 );
  1715.  
  1716. /* TGM plugin activation
  1717. /* ------------------------------------ */
  1718. if ( ! function_exists( 'T20_plugins' ) ) {
  1719.  
  1720. function T20_plugins() {
  1721. $plugins = array(
  1722. array(
  1723. 'name' => 'Visual Composer',
  1724. 'slug' => 'js_composer',
  1725. 'source' => 'http://theme20.com/plugins/js_composer.zip',
  1726. 'required' => true,
  1727. 'force_activation' => false,
  1728. 'force_deactivation' => false,
  1729. ),
  1730. array(
  1731. 'name' => 'T20 - Remix',
  1732. 'slug' => 'remix_cpt',
  1733. 'source' => 'http://theme20.com/plugins/remix_cpt.zip',
  1734. 'required' => true,
  1735. 'force_activation' => false,
  1736. 'force_deactivation' => false,
  1737. ),
  1738. array(
  1739. 'name' => 'Revolution Slider',
  1740. 'slug' => 'revslider',
  1741. 'source' => 'http://theme20.com/plugins/revslider.zip',
  1742. 'required' => false,
  1743. 'force_activation' => false,
  1744. 'force_deactivation' => false,
  1745. ),
  1746. array(
  1747. 'name' => 'Master Slider',
  1748. 'slug' => 'masterslider',
  1749. 'source' => 'http://theme20.com/plugins/masterslider.zip',
  1750. 'required' => false,
  1751. 'force_activation' => false,
  1752. 'force_deactivation' => false,
  1753. ),
  1754. array(
  1755. 'name' => 'Essential Grid',
  1756. 'slug' => 'essential-grid',
  1757. 'source' => 'http://theme20.com/plugins/essential-grid.zip',
  1758. 'required' => false,
  1759. 'force_activation' => false,
  1760. 'force_deactivation' => false,
  1761. ),
  1762. array(
  1763. 'name' => 'Instagram Widget',
  1764. 'slug' => 'instagram-slider-widget',
  1765. 'required' => false,
  1766. 'force_activation' => false,
  1767. 'force_deactivation' => false,
  1768. ),
  1769. array(
  1770. 'name' => 'Contact Form 7',
  1771. 'slug' => 'contact-form-7',
  1772. 'required' => false,
  1773. 'force_activation' => false,
  1774. 'force_deactivation' => false,
  1775. ),
  1776. array(
  1777. 'name' => 'bbpress',
  1778. 'slug' => 'bbpress',
  1779. 'required' => false,
  1780. 'force_activation' => false,
  1781. 'force_deactivation' => false,
  1782. ),
  1783. array(
  1784. 'name' => 'WooCommerce',
  1785. 'slug' => 'woocommerce',
  1786. 'required' => false,
  1787. 'force_activation' => false,
  1788. 'force_deactivation' => false,
  1789. )
  1790. );
  1791. tgmpa( $plugins );
  1792. }
  1793.  
  1794. }
  1795. add_action( 'tgmpa_register', 'T20_plugins' );
  1796.  
  1797. /**
  1798. * Front-end Scripts and Styles
  1799. */
  1800. function T20_scripts() {
  1801. wp_enqueue_script( 'remix', get_template_directory_uri() . '/js/remix.min.js', array( 'jquery' ), '', true );
  1802. if ( ot_get_option('remix_loading') != '1' ) { wp_enqueue_script( 'loader', get_template_directory_uri() . '/js/remix.loader.js', array( 'jquery' ), '', false ); }
  1803. wp_enqueue_script( 'owl', get_template_directory_uri() . '/js/owl.carousel.min.js', array( 'jquery' ), '', true );
  1804. wp_enqueue_script( 'fitvids', get_template_directory_uri() . '/js/jquery.fitvids.js', array( 'jquery' ), '', true );
  1805. wp_enqueue_script( 'jplayer', get_template_directory_uri() . '/js/jquery.jplayer.min.js', array( 'jquery' ), '', true );
  1806. wp_enqueue_script( 'nicescroll', get_template_directory_uri() . '/js/jquery.nicescroll.min.js', array( 'jquery' ), '', true );
  1807. if ( !wp_is_mobile() ) { if ( ot_get_option('scroll') === '3' ) { wp_enqueue_script( 'SmoothScroll', get_template_directory_uri() . '/js/smoothscroll.js', array( 'jquery' ), '', true ); } }
  1808. wp_enqueue_script( 'prettyPhoto', get_template_directory_uri() . '/js/jquery.prettyPhoto.js', array( 'jquery' ), '', true );
  1809. wp_enqueue_script( 'modernizr', get_template_directory_uri() . '/js/modernizr.custom.63321.js', array( 'jquery' ), '', true );
  1810. wp_enqueue_script( 'stapel', get_template_directory_uri() . '/js/jquery.stapel.js', array( 'jquery' ), '', true );
  1811. if ( is_page_template('page-onepage.php') ) { wp_enqueue_script( 'plusanchor', get_template_directory_uri() . '/js/jquery.plusanchor.js', array( 'jquery' ), '', true ); }
  1812. wp_enqueue_script( 'custom', get_template_directory_uri() . '/js/custom.js', array( 'jquery' ), '', true );
  1813. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  1814. wp_enqueue_script( 'comment-reply' );
  1815. }
  1816. wp_enqueue_style( 'remixstyle', get_stylesheet_uri(), array() );
  1817. if ( function_exists( 'is_woocommerce' ) ) {
  1818. wp_enqueue_style( 'shop', get_template_directory_uri() . '/styles/shop.css', array() );
  1819. }
  1820. if ( ot_get_option('responsive') === 'on' ) { wp_enqueue_style( 'responsive', get_template_directory_uri() . '/styles/responsive.css', array() ); }
  1821. $pagerID = get_the_ID();
  1822. if ( ot_get_option('dark') === 'on' || get_the_title($pagerID) === 'Light' ) { wp_enqueue_style( 'light', get_template_directory_uri() . '/styles/light.css', array() ); }
  1823. if ( ot_get_option('remix_loading') != '1' ) { wp_enqueue_style( 'remix_loader', get_template_directory_uri() . '/styles/loader.css', array() ); }
  1824. }
  1825. add_action( 'wp_enqueue_scripts', 'T20_scripts' );
  1826.  
  1827. // woocommerce
  1828. if ( function_exists( 'is_woocommerce' ) ) {
  1829. add_filter('loop_shop_columns', 'loop_columns');
  1830. if (!function_exists('loop_columns')) {
  1831. function loop_columns() {
  1832. return 3;
  1833. }
  1834. }
  1835. }
  1836.  
  1837. // This theme uses wp_nav_menu() in three locations.
  1838. register_nav_menus( array(
  1839. 'primary' => __( 'Primary menu', 'T20' ),
  1840. 'onepage' => __( 'One-page menu', 'T20' ),
  1841. 'footer' => __( 'Footer menu', 'T20' ),
  1842. ) );
  1843.  
  1844. /* Admin thumbs
  1845. /* ------------------------------------ */
  1846. add_filter('manage_posts_columns', 'posts_columns', 5);
  1847. add_action('manage_posts_custom_column', 'posts_custom_columns', 5, 2);
  1848. function posts_columns($defaults){
  1849. $defaults['riv_post_thumbs'] = __('Cover', 'T20');
  1850. return $defaults;
  1851. }
  1852. function posts_custom_columns($column_name, $id){
  1853. if($column_name === 'riv_post_thumbs'){
  1854. echo the_post_thumbnail( array(40,40) );
  1855. }
  1856. }
  1857.  
  1858. /* VC
  1859. /* ------------------------------------ */
  1860. if (class_exists('WPBakeryVisualComposerAbstract')) {
  1861. load_template( get_template_directory() . '/admin/T20_player.php' );
  1862. load_template( get_template_directory() . '/admin/T20_query.php' );
  1863. load_template( get_template_directory() . '/admin/T20_news.php' );
  1864. load_template( get_template_directory() . '/admin/T20_events.php' );
  1865. load_template( get_template_directory() . '/admin/T20_carousel_videos.php' );
  1866. load_template( get_template_directory() . '/admin/T20_carousel_songs.php' );
  1867. load_template( get_template_directory() . '/admin/T20_carousel_shop.php' );
  1868. load_template( get_template_directory() . '/admin/T20_masonry.php' );
  1869. load_template( get_template_directory() . '/admin/T20_gallery.php' );
  1870.  
  1871. vc_disable_frontend();
  1872. wpb_js_composer_check_version_schedule_deactivation();
  1873. vc_remove_element("vc_accordion");
  1874. vc_remove_element("vc_tour");
  1875. vc_remove_element("vc_wp_search");
  1876. vc_remove_element("vc_wp_meta");
  1877. vc_remove_element("vc_wp_recentcomments");
  1878. vc_remove_element("vc_wp_calendar");
  1879. vc_remove_element("vc_wp_pages");
  1880. vc_remove_element("vc_wp_tagcloud");
  1881. vc_remove_element("vc_wp_custommenu");
  1882. vc_remove_element("vc_wp_text");
  1883. vc_remove_element("vc_wp_posts");
  1884. vc_remove_element("vc_wp_links");
  1885. vc_remove_element("vc_wp_categories");
  1886. vc_remove_element("vc_wp_archives");
  1887. vc_remove_element("vc_wp_rss");
  1888. vc_remove_element("vc_cta_button2");
  1889. vc_remove_element("vc_posts_grid");
  1890.  
  1891. // Filter to Replace default css class for vc_row shortcode and vc_column
  1892. function custom_css_classes_for_vc_row_and_vc_column($class_string, $tag) {
  1893. if ($tag=='vc_row' || $tag=='vc_row_inner') {
  1894. $class_string = str_replace('vc_row-fluid', 'row clearfix', $class_string);
  1895. }
  1896. if ($tag=='vc_column' || $tag=='vc_column_inner') {
  1897. $class_string = preg_replace('/vc_col-sm-(\d{1,2})/', 'grid_$1', $class_string);
  1898. $class_string = preg_replace('/vc_span(\d{1,2})/', '', $class_string);
  1899. }
  1900. return $class_string;
  1901. }
  1902. add_filter('vc_shortcodes_css_class', 'custom_css_classes_for_vc_row_and_vc_column', 10, 2);
  1903.  
  1904. // Filter to Title of Widgets
  1905. function override_widget_title($output = '', $params = array('')) {
  1906. $extraclass = (isset($params['extraclass'])) ? " ".$params['extraclass'] : "";
  1907. return '<h4 class="tt">'.$params['title'].'</h4><span class="liner"></span>';
  1908. }
  1909. add_filter('wpb_widget_title', 'override_widget_title', 10, 2);
  1910. }
  1911.  
  1912. // Google Fonts
  1913. $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');
  1914. $google_webfonts = str_replace('+', ' ', $google_webfonts);
  1915.  
  1916. function filter_google_font_list( $array ) {
  1917. global $google_webfonts;
  1918. $array = array();
  1919. foreach ($google_webfonts as $web_font_name) {
  1920. array_push($array, array("label"=>preg_replace('/:.*/','', $web_font_name), "value"=>$web_font_name));
  1921. }
  1922.  
  1923. return $array;
  1924. }
  1925. add_filter( 'ot_populated_select_items', 'filter_google_font_list', 10, 2 );
  1926.  
  1927. function filter_ot_recognized_font_families( $array ) {
  1928. $array = array(
  1929. 'arial' => 'Arial',
  1930. 'georgia' => 'Georgia',
  1931. 'helvetica' => 'Helvetica',
  1932. 'palatino' => 'Palatino',
  1933. 'Tahoma' => 'Tahoma',
  1934. 'times' => '"Times New Roman", sans-serif',
  1935. 'trebuchet ms' => 'Trebuchet MS',
  1936. 'verdana' => 'Verdana',
  1937. 'nothing' => '------GOOGLE FONTS------'
  1938. );
  1939. global $google_webfonts;
  1940. foreach ($google_webfonts as $web_font_name) {
  1941. $array[(preg_replace('/:.*/','', $web_font_name))] = $web_font_name;
  1942. }
  1943. return $array;
  1944. }
  1945. add_filter( 'ot_recognized_font_families', 'filter_ot_recognized_font_families', 10, 2 );
  1946.  
  1947. /* Import Export
  1948. /* ------------------------------------ */
  1949. add_action( 'init', 'register_options_pages' );
  1950. function register_options_pages() {
  1951.  
  1952. if ( is_admin() && function_exists( 'ot_register_settings' ) ) {
  1953. ot_register_settings(
  1954. array(
  1955. array(
  1956. 'id' => 'import_export',
  1957. 'pages' => array(
  1958. array(
  1959. 'id' => 'import_export',
  1960. 'parent_slug' => 'themes.php',
  1961. 'page_title' => '',
  1962. 'menu_title' => 'Options Backup',
  1963. 'capability' => 'edit_theme_options',
  1964. 'menu_slug' => 'T20-theme-backup',
  1965. 'icon_url' => null,
  1966. 'position' => null,
  1967. 'updated_message' => 'Options updated.',
  1968. 'reset_message' => 'Options reset.',
  1969. 'button_text' => 'Save Changes',
  1970. 'show_buttons' => false,
  1971. 'screen_icon' => 'themes',
  1972. 'contextual_help' => null,
  1973. 'sections' => array(
  1974. array(
  1975. 'id' => 'T20_import_export',
  1976. 'title' => '<i class="layout_T20"></i>Import/Export',
  1977. )
  1978. ),
  1979. 'settings' => array(
  1980. array(
  1981. 'id' => 'import_data_text',
  1982. 'label' => 'Import Theme Options',
  1983. 'desc' => 'Theme Options',
  1984. 'std' => '',
  1985. 'type' => 'import-data',
  1986. 'section' => 'T20_import_export',
  1987. 'rows' => '',
  1988. 'post_type' => '',
  1989. 'taxonomy' => '',
  1990. 'class' => ''
  1991. ),
  1992. array(
  1993. 'id' => 'export_data_text',
  1994. 'label' => 'Export Theme Options',
  1995. 'desc' => 'Theme Options',
  1996. 'std' => '',
  1997. 'type' => 'export-data',
  1998. 'section' => 'T20_import_export',
  1999. 'rows' => '',
  2000. 'post_type' => '',
  2001. 'taxonomy' => '',
  2002. 'class' => ''
  2003. )
  2004. )
  2005. )
  2006. )
  2007. )
  2008. )
  2009. );
  2010. }
  2011. }
  2012. if ( ! function_exists( 'ot_type_import_data' ) ) {
  2013. function ot_type_import_data() {
  2014. echo '<form method="post" id="import-data-form">';
  2015. wp_nonce_field( 'import_data_form', 'import_data_nonce' );
  2016. echo '<div class="format-setting type-textarea has-desc">';
  2017. echo '<div class="description">';
  2018.  
  2019. if ( OT_SHOW_SETTINGS_IMPORT )
  2020. echo '<p>' . __( 'Only after you\'ve imported the Settings should you try and update your Theme Options.', 'option-tree' ) . '</p>';
  2021. 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>';
  2022. echo '<button class="option-tree-ui-button blue right hug-right">' . __( 'Import Theme Options', 'option-tree' ) . '</button>';
  2023. echo '</div>';
  2024. echo '<div class="format-setting-inner">';
  2025. echo '<textarea rows="10" cols="40" name="import_data" id="import_data" class="textarea"></textarea>';
  2026. echo '</div>';
  2027. echo '</div>';
  2028. echo '</form>';
  2029. }
  2030. }
  2031. if ( ! function_exists( 'ot_type_export_data' ) ) {
  2032. function ot_type_export_data() {
  2033. echo '<div class="format-setting type-textarea simple has-desc">';
  2034. echo '<div class="description">';
  2035. 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>';
  2036. echo '<input class="option-tree-ui-button blue right hug-right" value="Export as file" type="button" onclick="doDL(document.getElementById(\'export_data\').value)" />';
  2037. echo '</div>';
  2038.  
  2039. $data = get_option( 'option_tree' );
  2040. $data = ! empty( $data ) ? ot_encode( serialize( $data ) ) : '';
  2041.  
  2042. echo '<div class="format-setting-inner">';
  2043. echo '<textarea rows="10" cols="40" name="export_data" id="export_data" class="textarea">' . $data . '</textarea>';
  2044. echo '</div>';
  2045. echo '</div>';
  2046. ?>
  2047. <script type="text/javascript">
  2048. function saveAs(uri, filename) {
  2049. var link = document.createElement('a');
  2050. if (typeof link.download === 'string') {
  2051. link.href = uri;
  2052. link.download = filename;
  2053. document.body.appendChild(link);
  2054. link.click();
  2055. document.body.removeChild(link);
  2056. } else {
  2057. window.open(uri);
  2058. }
  2059. }
  2060.  
  2061. function doDL(s){
  2062. var file = "data:x-application/text," + escape(s);
  2063. saveAs(file, 'export-theme-options.txt');
  2064. }
  2065. </script>
  2066. <?php
  2067. }
  2068. }
  2069.  
  2070. /* Fixed disqus woocommerce
  2071. /* ------------------------------------ */
  2072. if ( function_exists( 'is_woocommerce' ) ) {
  2073. add_action('the_post', 'sb_remove_woocommerce_disqus');
  2074. remove_action('pre_comment_on_post', 'dsq_pre_comment_on_post');
  2075. function sb_remove_woocommerce_disqus() {
  2076. global $post, $wp_query;
  2077.  
  2078. if (get_post_type() == 'product') {
  2079. remove_filter('comments_template', 'dsq_comments_template');
  2080. }
  2081. }
  2082. }
  2083.  
  2084. /* Ajax Cart
  2085. /* ------------------------------------ */
  2086. add_filter('add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment');
  2087. function woocommerce_header_add_to_cart_fragment( $fragments ) {
  2088. global $woocommerce;
  2089.  
  2090. ob_start(); ?>
  2091. <div class="cart_head woocommerce">
  2092. <a class="shop_icon" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php echo ot_get_option('shop_cart'); ?>">
  2093. <i class="fa fa-shopping-cart"></i>
  2094. <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>
  2095. </a>
  2096.  
  2097. <!-- <div class="view_cart_mini">
  2098. <div class="arrow-up"></div>
  2099. <div class="view_cart">
  2100. <ul class="cart_list">
  2101.  
  2102. <?php foreach($woocommerce->cart->cart_contents as $cart_item): ?>
  2103. <li class="clearfix">
  2104. <a href="<?php echo get_permalink($cart_item['product_id']); ?>">
  2105. <?php $thumbnail_id = ($cart_item['variation_id']) ? $cart_item['variation_id'] : $cart_item['product_id']; ?>
  2106. <?php echo get_the_post_thumbnail($thumbnail_id, 'thumb'); ?>
  2107. </a>
  2108. <div class="cart_list_product_title">
  2109. <a href="<?php echo get_permalink($cart_item['product_id']); ?>">
  2110. <?php echo $cart_item['data']->post->post_title; ?>
  2111. </a>
  2112. <div class="cart_list_product_quantity"><?php echo $cart_item['quantity']; ?> x <?php echo $woocommerce->cart->get_product_subtotal($cart_item['data'], 1); ?> </div>
  2113.  
  2114. </div>
  2115.  
  2116. </li>
  2117.  
  2118. <?php endforeach; ?>
  2119. </ul>
  2120.  
  2121. <div class="mcart_total">
  2122. <span class="total_checkout fll"><?php _e('Cart subtotal','official');?></span>
  2123. <span class="amount_total flr"><?php echo $woocommerce->cart->get_cart_total(); ?></span>
  2124. </div>
  2125.  
  2126. <div class="mcart_buttons">
  2127. <a href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>" class="tbutton small"><span>Shopping Cart</span></a>
  2128. <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>
  2129. </div>
  2130. </div>
  2131. </div> -->
  2132. </div>
  2133. <?php $fragments['.cart_head'] = ob_get_clean();
  2134.  
  2135. return $fragments;
  2136. }
  2137.  
  2138. /* Maintenance mode
  2139. /* ------------------------------------ */
  2140. function T20_maintenance_mode() {
  2141. if ( ot_get_option( 'maintenance_mode' ) === 'on' ) {
  2142. if ( !is_user_logged_in() ) {
  2143. include_once( get_stylesheet_directory() . '/page-maintenance.php' );
  2144. die();
  2145. }
  2146. }
  2147. }
  2148. add_action( 'wp', 'T20_maintenance_mode' );
  2149. add_action( 'admin_bar_menu', 'T20_toolbar_main', 999 );
  2150. function T20_toolbar_main( $wp_admin_bar ) {
  2151. if ( ot_get_option( 'maintenance_mode' ) === 'on' ) {
  2152. $args = array(
  2153. 'id' => 'maintenance_remix_war',
  2154. 'title' => __('Maintenance Mode is ON', 'T20'),
  2155. 'href' => site_url() . '/wp-admin/themes.php?page=ot-theme-options#section_maintenance',
  2156. 'meta' => array( 'class' => 'maintenance_remix_war' )
  2157. );
  2158. $wp_admin_bar->add_node( $args );
  2159. }
  2160. }
  2161.  
  2162. /* Remove plugins notifications
  2163. /* ------------------------------------ */
  2164. function filter_plugin_updates( $value ) {
  2165. if( isset( $value->response['js_composer/js_composer.php'] ) ) {
  2166. unset( $value->response['js_composer/js_composer.php'] );
  2167. }
  2168. if( isset( $value->response['revslider/revslider.php'] ) ) {
  2169. unset( $value->response['revslider/revslider.php'] );
  2170. }
  2171. if( isset( $value->response['masterslider/masterslider.php'] ) ) {
  2172. unset( $value->response['masterslider/masterslider.php'] );
  2173. }
  2174. if( isset( $value->response['essential-grid/essential-grid.php'] ) ) {
  2175. unset( $value->response['essential-grid/essential-grid.php'] );
  2176. }
  2177. return $value;
  2178. }
  2179. add_filter( 'site_transient_update_plugins', 'filter_plugin_updates' );
  2180.  
  2181. /* Hide version
  2182. /* ------------------------------------ */
  2183. function T20_remove_wp_version_strings( $src ) {
  2184. global $wp_version;
  2185. parse_str(parse_url($src, PHP_URL_QUERY), $query);
  2186. if ( !empty($query['ver']) && $query['ver'] === $wp_version ) {
  2187. $src = remove_query_arg('ver', $src);
  2188. }
  2189. return $src;
  2190. }
  2191. add_filter( 'script_loader_src', 'T20_remove_wp_version_strings' );
  2192. add_filter( 'style_loader_src', 'T20_remove_wp_version_strings' );
  2193. function T20_remove_version() {
  2194. return '';
  2195. }
  2196. add_filter('the_generator', 'T20_remove_version');
  2197.  
  2198. /* Recent viewed posts
  2199. /* ------------------------------------ */
  2200. function wpse_63266_update_recently_viewed(){
  2201.  
  2202. if(is_admin() || !is_single()) return;
  2203.  
  2204. global $post;
  2205. $current_post_id = get_the_ID();
  2206.  
  2207. if(is_user_logged_in()){
  2208.  
  2209. // Store recently viewed post ids in user meta.
  2210. $recenty_viewed = get_user_meta(get_current_user_id(), 'recently_viewed', true);
  2211. if( '' == $recenty_viewed ){
  2212. $recenty_viewed = array();
  2213. }
  2214.  
  2215. // Prepend id to the beginning of recently viewed id array
  2216. array_unshift($recenty_viewed, $current_post_id);
  2217.  
  2218. $recenty_viewed = array_slice($recenty_viewed, 0, 10);
  2219. update_user_meta(get_current_user_id(), 'recently_viewed', $recenty_viewed);
  2220.  
  2221. }
  2222. }
  2223. add_action('wp_footer', 'wpse_63266_update_recently_viewed');
  2224. function T20_show_recently_viewed(){
  2225. $recenty_viewed = get_user_meta(get_current_user_id(), 'recently_viewed', true);
  2226. $result = '';
  2227. if( '' !== $recenty_viewed ){
  2228. $result = array_unique($recenty_viewed);
  2229. }
  2230.  
  2231. return $result;
  2232. }
  2233. add_action('wpse_63266_recently_viewed', 'T20_show_recently_viewed');
  2234.  
  2235. /* Download counter
  2236. /* ------------------------------------ */
  2237. add_action('wp_ajax_T20_downloadaudio', 'T20_download_audio');
  2238. add_action('wp_ajax_nopriv_T20_downloadaudio', 'T20_download_audio');
  2239. function T20_download_audio() {
  2240. check_ajax_referer( 'T20_download', 'dlnonce' );
  2241.  
  2242. $postID = str_replace('"', '', json_encode($_POST['itemid']));
  2243. $dcount_key = 'download_count';
  2244. $dcount = get_post_meta($postID, $dcount_key, true);
  2245. if ($dcount=='') {
  2246. $dcount = 0;
  2247. delete_post_meta($postID, $dcount_key);
  2248. add_post_meta($postID, $dcount_key, '1');
  2249. } else {
  2250. $dcount++;
  2251. update_post_meta($postID, $dcount_key, $dcount);
  2252. }
  2253.  
  2254. die();
  2255. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement