Advertisement
Guest User

fatalerror

a guest
Jan 17th, 2016
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 48.37 KB | None | 0 0
  1. <?php
  2. /**
  3. * Gamexls
  4. *
  5. * @author Megatemas
  6. * @uri http://www.megatemas.com/
  7. *
  8. * @package WordPress
  9. * @subpackage GameXlS
  10. */
  11.  
  12. /** Include buddypress integration file **/
  13. include_once('inc/buddypress.php');
  14. /** Include setup theme **/
  15. require_once (TEMPLATEPATH.'/inc/setup.php');
  16.  
  17. /** Include option panel **/
  18. require_once(TEMPLATEPATH.'/inc/admin/config.php');
  19.  
  20. /** Include theme actions API **/
  21. include_once('inc/actions.php');
  22. /** Include MyArcadePlugin Theme API **/
  23. include_once(TEMPLATEPATH.'/inc/myarcade_api.php');
  24. /** Include custom widgets **/
  25. include_once('inc/myabp_widgets.php');
  26. /** Include TGM Plugin Activation **/
  27. if(is_admin()){include_once (TEMPLATEPATH.'/inc/admin/plugins/plugins.php');}
  28.  
  29. if ( !is_admin() ) {
  30. add_action('wp_print_scripts', 'gamexls_scripts_init');
  31. add_action('wp_print_styles', 'gamexls_stylesheet_init');
  32. }
  33.  
  34. add_filter('avatar_defaults', 'mt_gravatar');
  35. function mt_gravatar ($avatar_defaults) {
  36. $myavatar = get_bloginfo('template_directory').'/img/cnt/imgusr.jpg';
  37. $avatar_defaults[$myavatar] = __('Avatar MT','gamexls');
  38. return $avatar_defaults;
  39. }
  40.  
  41. function gamexls_default_menu() {
  42. wp_list_categories('sort_column=name&title_li=&depth=1&number=5');
  43. }
  44.  
  45. function gamexls_sidebar($type){
  46. if( gamexls_get_option( 'layout', 2 ) ==2 and $type==1){
  47. return 'flol';
  48. }elseif( gamexls_get_option( 'layout', 2 ) ==2 and $type==2){
  49. return 'flor';
  50. }elseif( gamexls_get_option( 'layout', 2 ) ==1 and $type==1){
  51. return 'flor';
  52. }elseif( gamexls_get_option( 'layout', 2 ) ==1 and $type==2){
  53. return 'flol';
  54. }
  55. }
  56.  
  57. function gamexls_social($class=NULL,$up=NULL){
  58. if( gamexls_get_option( 'mtfacebook', '#' ) !='' or gamexls_get_option( 'mttwitter', '#' )!='' or gamexls_get_option( 'mtyoutube', '#' )!='' or gamexls_get_option( 'mtgoogleplus', '#' )!=''){
  59. ?>
  60. <ul class="<?php if($class==''){ ?>lstsoc anmtins flli flor<?php }else{ echo $class; } ?>">
  61. <?php if( gamexls_get_option( 'mtfacebook', '#' )!=''){ ?><li><a target="_blank" href="<?php echo gamexls_get_option( 'mtfacebook', '#' ); ?>" class="bgbl-50 icon-rnd15" title="<?php _e('Facebook','gamexls'); ?>">&#xf09a;</a></li><?php } ?>
  62. <?php if( gamexls_get_option( 'mttwitter', '#' )!=''){ ?><li><a target="_blank" href="<?php echo gamexls_get_option( 'mttwitter', '#' ); ?>" class="bgbl-50 icon-rnd15" title="<?php _e('Twitter','gamexls'); ?>">&#xf099;</a></li><?php } ?>
  63. <?php if( gamexls_get_option( 'mtyoutube', '#' )!=''){ ?><li><a target="_blank" href="<?php echo gamexls_get_option( 'mtyoutube', '#' ); ?>" class="bgbl-50 icon-rnd15" title="<?php _e('Youtube','gamexls'); ?>">&#xf167;</a></li><?php } ?>
  64. <?php if( gamexls_get_option( 'mtgoogleplus', '#' )!=''){ ?><li><a target="_blank" href="<?php echo gamexls_get_option( 'mtgoogleplus', '#' ); ?>" class="bgbl-50 icon-rnd15" title="<?php _e('Google+','gamexls'); ?>">&#xf0d5;</a></li><?php } ?>
  65. <?php if($up==1){ ?><li><a href="#hd" class="bgbl-50 icon-rnd15" title="<?php _e('Up','gamexls'); ?>">&#xf077;</a></li><?php } ?>
  66. </ul>
  67. <?php
  68. }
  69. }
  70.  
  71. function mt_plugin_exists($fun){
  72. if (function_exists($fun)) {
  73. return 'success';
  74. } else {
  75. return 'warning';
  76. }
  77. }
  78.  
  79. if(is_admin()){
  80. function rkv_imagelink_setup() {
  81. $image_set = get_option( 'image_default_link_type' );
  82.  
  83. if ($image_set !== 'none') {
  84. update_option('image_default_link_type', 'none');
  85. }
  86. }
  87. add_action('admin_init', 'rkv_imagelink_setup', 10);
  88. }
  89.  
  90. if ( !function_exists('gamexls_favorite_link') ) {
  91. function myabp_favorite_link($post_id, $opt, $action) {
  92. $link = '<li><span class="wpfp-span"><img src="'.plugins_url('wp-favorite-posts/img/loading.gif').'" alt="'.__('Loading','gamexls').'" title="'.__('Loading','gamexls').'" class="wpfp-hide wpfp-img"><a class="wpfp-link bgbl-50 icon-rnd15 mtfav-'.$action.'" href="?wpfpaction='.$action.'&amp;postid='.$post_id.'" title="'.$opt.'" rel="nofollow">&#xf004;</a></span></li>';
  93. $link = apply_filters( 'wpfp_link_html', $link );
  94. return $link;
  95. }
  96. }
  97.  
  98. function gamexls_contest_alert() {
  99. if ( !function_exists('myarcadecontest_get_contest_id_for_this_game') )
  100. return;
  101.  
  102. $contest_id = myarcadecontest_get_contest_id_for_this_game();
  103. $user_id = get_current_user_id();
  104.  
  105. if (!$contest_id || myarcadecontest_check_user_is_in_contest($contest_id, $user_id) )
  106. return;
  107.  
  108. $permalink_open = '<a href="'.get_permalink($contest_id).'" title="'.get_the_title($contest_id).'">';
  109. $permalink_close = '</a>';
  110.  
  111. ?>
  112. <div class="gam_info">
  113. <p>
  114. <strong><?php _e('Howdy!', 'gamexls'); ?></strong> <?php echo sprintf( __('There is an active contest available for this game. Click %shere%s to join the contest!', 'gamexls'), $permalink_open, $permalink_close); ?>
  115. </p>
  116. </div>
  117. <?php
  118. }
  119.  
  120. function gamexls_get_leaderboard() {
  121. global $wpdb;
  122.  
  123. $output = '';
  124. $results = $wpdb->get_results("SELECT h.user_id, COUNT(*) as highscores, u.plays as plays
  125. FROM ".MYARCADE_HIGHSCORES_TABLE." AS h
  126. INNER JOIN ".MYARCADE_USER_TABLE." AS u ON h.user_id=u.user_id
  127. GROUP BY h.user_id
  128. ORDER BY highscores DESC LIMIT 3");
  129.  
  130. if (!empty($results)) {
  131. $count = 0;
  132.  
  133. foreach ($results as $result) {
  134. $count++;
  135. $plays=0;
  136. echo'
  137. <li class="bgc2">
  138. <figure class="cirl-imgusrcn bgwh-10">'.get_avatar($result->user_id, 116).'</figure>
  139. <p>'.myscore_get_user_link($result->user_id).'</p>
  140. <strong class="iconb-game icon50 bgwh-10">'.$result->plays.' <span>'.__('Plays','gamexls').'</span></strong>
  141. <strong class="iconb-trop bgwh-10 award-'.$count.'">'.$result->highscores.' <span>'.__('Scores','gamexls').'</span></strong>
  142. <span class="posit-rnd10">#'.$count.'</span>
  143. </li>
  144. ';
  145. }
  146. }
  147. }
  148.  
  149. function gamexls_h1($class=NULL) {
  150. if(is_single()){
  151. return '<h1'.$class.'>'.get_the_title(get_the_ID()).'</h1>';
  152. }elseif(is_page()){
  153. return '<h1'.$class.'>'.get_the_title(get_the_ID()).'</h1>';
  154. }elseif(is_search()){
  155. return '<h1'.$class.'>'.get_search_query().'</h1>';
  156. }elseif(is_category()){
  157. return '<h1'.$class.'>'.single_cat_title("", false).'</h1>';
  158. }elseif(is_tag()){
  159. return '<h1'.$class.'>'.single_tag_title("", false).'</h1>';
  160. }elseif(is_home() or is_front_page()){
  161. return '<h1'.$class.'>'.get_option('blogname').'</h1>';
  162. }else{
  163. return '<h1'.$class.'>'.wp_title("",false,"right").'</h1>';
  164. }
  165. }
  166.  
  167. function gamexls_header($class=NULL) {
  168. if(is_single()){
  169. return '<div'.$class.'>'.get_the_title(get_the_ID()).'</div>';
  170. }elseif(is_page()){
  171. return '<h1'.$class.'>'.get_the_title(get_the_ID()).'</h1>';
  172. }elseif(is_search()){
  173. return '<h1'.$class.'>'.get_search_query().'</h1>';
  174. }elseif(is_category()){
  175. return '<h1'.$class.'>'.single_cat_title("", false).'</h1>';
  176. }elseif(is_tag()){
  177. return '<h1'.$class.'>'.single_tag_title("", false).'</h1>';
  178. }elseif(is_home() or is_front_page()){
  179. return '<h1'.$class.'>'.get_option('blogname').'</h1>';
  180. }else{
  181. return '<h1'.$class.'>'.wp_title("",false,"right").'</h1>';
  182. }
  183. }
  184.  
  185. function gamexls_breadcumb() {
  186. if ( is_home() || is_front_page() )
  187. return;
  188.  
  189. if(is_single()){
  190. return '
  191. <div class="brdcrm">
  192. <a title="'.__('Home','gamexls').'" href="'.esc_url( home_url( '/' ) ).'" class="iconb-home"><span class="notx">'.__('Home','gamexls').'</span></a> <strong>'.get_the_category_list(', ','',get_the_ID()).'</strong> <strong>'.get_the_title(get_the_ID()).'</strong>
  193. </div>
  194. ';
  195. }elseif(is_page()){
  196. return '
  197. <div class="brdcrm">
  198. <a title="'.__('Home','gamexls').'" href="'.esc_url( home_url( '/' ) ).'" class="iconb-home"><span class="notx">'.__('Home','gamexls').'</span></a> <strong>'.get_the_title(get_the_ID()).'</strong>
  199. </div>
  200. ';
  201. }elseif(is_search()){
  202. return '
  203. <div class="brdcrm">
  204. <a title="'.__('Home','gamexls').'" href="'.esc_url( home_url( '/' ) ).'" class="iconb-home"><span class="notx">'.__('Home','gamexls').'</span></a> <strong>'.get_search_query().'</strong>
  205. </div>
  206. ';
  207. }elseif(is_category()){
  208. return '
  209. <div class="brdcrm">
  210. <a title="'.__('Home','gamexls').'" href="'.esc_url( home_url( '/' ) ).'" class="iconb-home"><span class="notx">'.__('Home','gamexls').'</span></a> <strong>'.single_cat_title("", false).'</strong>
  211. </div>
  212. ';
  213. }elseif(is_tag()){
  214. return '
  215. <div class="brdcrm">
  216. <a title="'.__('Home','gamexls').'" href="'.esc_url( home_url( '/' ) ).'" class="iconb-home"><span class="notx">'.__('Home','gamexls').'</span></a> <strong>'.single_tag_title("", false).'</strong>
  217. </div>
  218. ';
  219. }else{
  220. return '
  221. <div class="brdcrm">
  222. <a title="'.__('Home','gamexls').'" href="'.esc_url( home_url( '/' ) ).'" class="iconb-home"><span class="notx">'.__('Home','gamexls').'</span></a> <strong>'.wp_title("",false,"right").'</strong>
  223. </div>
  224. ';
  225. }
  226. }
  227.  
  228. function set_mt_cookie() {
  229. if (isset($_POST['idc'])) {
  230. setcookie('idc', '', time()-1209600);
  231. setcookie('idc', intval($_POST['idc']), time()+1209600, COOKIEPATH, COOKIE_DOMAIN, false);
  232. }
  233. }
  234. add_action( 'init', 'set_mt_cookie');
  235.  
  236. function mt_paginacion($tipo=1,$class=NULL,$qc=NULL){
  237. global $wp_query,$paged;
  238. if($qc==''){$total=$wp_query->max_num_pages;}else{$total=$qc;}
  239. if($tipo==1){
  240. $paginacion=paginate_links( array(
  241. 'base' => str_replace(999999999, '%#%', esc_url( get_pagenum_link(999999999) ) ),
  242. 'format' => '?paged=%#%',
  243. 'current' => max( 1, $paged ),
  244. 'total' => $total,
  245. 'mid_size' => 3,
  246. 'prev_next' => false
  247. ) );
  248. }else{
  249. $paginacion=paginate_comments_links( array('prev_next' => true,'echo' => false) );
  250. }
  251. if(!empty($paginacion))echo'<div class="mt-pagnav'.$class.'">'.$paginacion.'</div>';
  252. }
  253.  
  254.  
  255. if ( !function_exists('gamexls_favorite') ) {
  256. function gamexls_favorite() {
  257. global $post, $action;
  258. // Works only when WP Favorite Post is active
  259. if (function_exists('wpfp_link')) {
  260. if ($action == "remove") {
  261. $str = myabp_favorite_link($post->ID, wpfp_get_option('remove_favorite'), "remove");
  262. } elseif ($action == "add") {
  263. $str = myabp_favorite_link($post->ID, wpfp_get_option('add_favorite'), "add");
  264. } elseif (wpfp_check_favorited($post->ID)) {
  265. $str = myabp_favorite_link($post->ID, wpfp_get_option('remove_favorite'), "remove");
  266. } else {
  267. $str = myabp_favorite_link($post->ID, wpfp_get_option('add_favorite'), "add");
  268. }
  269. echo $str;
  270. }
  271. }
  272. }
  273.  
  274. function gamexls_display_buttons() {
  275. if ( ( gamexls_get_option( 'fullscreen-button', 1 ) == '1')
  276. ||( gamexls_get_option( 'lights-button', 1 ) == '1')
  277. ||( gamexls_get_option( 'favorite-button', 1 ) == '1')
  278. ||( gamexls_get_option( 'report-button', 1 ) == '1') ) {
  279. return true;
  280. }
  281. return false;
  282. }
  283.  
  284. function gamexls_report(){
  285. echo'
  286. <input name="RBL_URL" type="hidden" value="'.get_bloginfo('url').$_SERVER['REQUEST_URI'].'">
  287. <span id="RBL_Element" role="button" class="bgbl-50 icon-rnd15" title="Report">&#xf024;</span>';
  288. }
  289.  
  290. /**
  291. * Display related or random games
  292. */
  293. function gamexls_related($tipo=1) {
  294. if($tipo==1){
  295. echo '
  296. <!--<more games>-->
  297. <section class="blkcn mbot10px">
  298. <div class="blkhd"><strong>'.__("MORE GAMES", "gamexls").'</strong></div>
  299. <div class="mt-tbcn bgwh padd10px mbot10px">
  300. <ul class="lstabcn cowh ovhd">
  301. <!--<cntab3>-->
  302. <li class="scrlbr">
  303. <div>
  304. ';
  305. }
  306. if ( function_exists('related_entries') ) {
  307. related_entries();
  308. } else {
  309. get_template_part('games', 'random');
  310. }
  311. if($tipo==1){
  312. echo'
  313. </div>
  314. </li>
  315. <!--</cntab3>-->
  316. </ul>
  317. </div>
  318. <!--</lstabs>-->
  319. </section>
  320. <!--</more games>-->
  321. ';
  322. }
  323. }
  324.  
  325.  
  326. function gamexls_scripts_init() {
  327. global $wp_scripts;
  328.  
  329. $path_to_theme = get_template_directory_uri();
  330.  
  331. if ( !is_admin() ) {
  332. // load the jquery script
  333. wp_enqueue_script('jquery');
  334. /*
  335. if ( gamexls_get_option( 'gamexls_jquery_cdn', 1 ) == '1' ) {
  336. if ( is_a($wp_scripts, 'WP_Scripts') && isset($wp_scripts->registered['jquery']) ) {
  337. if ( isset($wp_scripts->registered['jquery']->ver) && $wp_scripts->registered['jquery']->ver ) {
  338. $google_jquery_url = ($_SERVER['SERVER_PORT'] == 443 ? "https" : "http") . "://ajax.googleapis.com/ajax/libs/jquery/". $wp_scripts->registered['jquery']->ver ."/jquery.min.js";
  339.  
  340. $request = wp_remote_head( $google_jquery_url );
  341.  
  342. if ( 200 === wp_remote_retrieve_response_code( $request ) ) {
  343. wp_deregister_script('jquery');
  344. wp_register_script('jquery', $google_jquery_url , false, null, false);
  345. }
  346. }
  347. }
  348. }
  349. */
  350. wp_enqueue_script('mt-scrlbr', $path_to_theme.'/js/scrlbr.js',array('jquery'),'1.0',true);
  351. wp_enqueue_script('mt-functions', $path_to_theme.'/js/functi.js',array('jquery'),'1.0',true);
  352.  
  353. if(is_front_page() or is_home() or is_game()){
  354. wp_enqueue_script('mt-bxsldr', $path_to_theme.'/js/bxsldr.js',array('jquery'),'4.1.1',false);
  355. wp_enqueue_script('mt-slider', $path_to_theme.'/js/slider.js', '', '',false);
  356. }
  357. if ( is_singular() ) {
  358. if( gamexls_get_option( 'progress-bar', 1 ) =='1'){
  359. wp_enqueue_script('mt-progrs', $path_to_theme.'/js/progrs.js', '', '',false);
  360. }
  361. }
  362. if(is_category()){
  363. wp_enqueue_script('mt-order', $path_to_theme.'/js/order.js', '', '',false);
  364. }
  365. if (is_singular() && comments_open() && get_option('thread_comments') ){
  366. wp_enqueue_script( 'comment-reply' );
  367. }
  368. }
  369. }
  370.  
  371. function gamexls_stylesheet_init() {
  372. $path_to_theme = get_template_directory_uri();
  373. if(defined('BP_VERSION')){
  374. wp_register_style('mt-BuddyPressIntegration', $path_to_theme.'/css/buddypress.css');
  375. wp_enqueue_style( 'mt-BuddyPressIntegration');
  376. }
  377. wp_register_style('mt-rsp', $path_to_theme.'/css/rsp.css');
  378. wp_enqueue_style( 'mt-rsp');
  379. wp_register_style('mt-opensans', '//fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700');
  380. wp_enqueue_style( 'mt-opensans');
  381. if( gamexls_get_option( 'stylesheet', 'style.css' ) !='style.css'){
  382. wp_register_style( gamexls_get_option( 'stylesheet', 'style.css' ), $path_to_theme.'/css/'. gamexls_get_option( 'stylesheet', 'style.css' ) );
  383. wp_enqueue_style( gamexls_get_option( 'stylesheet', 'style.css' ));
  384. }
  385. }
  386.  
  387. function mt_header(){
  388. if( gamexls_get_option( 'custom_header_code', '' ) !=''){echo stripslashes( gamexls_get_option( 'custom_header_code', '' ) )."\r";}
  389.  
  390. $favicon = gamexls_get_option( 'favicon', '' );
  391. if ( is_array( $favicon ) ) {
  392. if( $favicon['url']!=''){echo"<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"".$favicon['url']."\">\r";}
  393. }else{
  394. echo"<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"".get_template_directory_uri()."/img/favico.ico\">\r";
  395. }
  396. }
  397. add_action('wp_head', 'mt_header');
  398.  
  399. function mt_custom_css(){
  400. echo'<style type="text/css">';
  401. if( gamexls_get_option( 'share-button-hover', 1 ) ==1){
  402. echo '.shrbtncn:hover .lstshr-rnd15{width: auto;padding-left: 30px; padding-right:10px; overflow:inherit}';
  403. }
  404. else{
  405. echo '.shrbtncn .lstshr-rnd15{width: auto;padding-left: 30px; padding-right:10px; overflow:inherit}';
  406. }
  407. echo'</style>
  408. '."\n\r";
  409.  
  410. if( gamexls_get_option( 'mtcustom-css', 2 ) == 1 ){
  411. $mtlinkcolor = gamexls_get_option( 'mtlink-color', array( 'regular' => '#333', 'hover' => '#FAC75A' ) );
  412.  
  413.  
  414. echo'
  415. <style type="text/css">
  416. /*
  417. Body Background Color
  418. Pick a background color for the theme (default: #E9E9EA).
  419. */
  420. body,.bx-controls,#bordeswf{background-color:'. gamexls_get_option( 'color-background', '#E9E9EA' ).'}
  421. .hdcn4 .bx-controls:before{border-bottom-color:'. gamexls_get_option( 'color-background', '#E9E9EA' ).'}
  422. .hdcn4 .bx-controls:after{border-bottom-color:'. gamexls_get_option( 'color-background', '#E9E9EA' ).'}
  423.  
  424. /*
  425. Header Background Color 1*
  426. Pick a background color (default: #2E2F31)
  427. */
  428. .hdcn .hdcn1{background-color:'. gamexls_get_option( 'header-backgroundcl1', '#2E2F31' ).'}
  429.  
  430.  
  431. /*
  432. Header Background Color 2*
  433. Pick a background color (default: #3E4649)
  434. */
  435. .hdcn .hdcn2{background-color:'. gamexls_get_option( 'header-backgroundcl2', '#3E4649' ).'}
  436.  
  437.  
  438. /*
  439. Header Background Color 3*
  440. Pick a background color (default: #2E2F31)
  441. */
  442. .hdcn .hdcn3{background-color:'. gamexls_get_option( 'header-backgroundcl3', '#2E2F31' ).'}
  443.  
  444.  
  445. /*
  446. Header Background Color 4*
  447. Pick a background color (default: Transparent)
  448. */
  449. .hdcn .hdcn4{background-color:'. gamexls_get_option( 'header-backgroundcl4', 'transparent' ).'}
  450.  
  451.  
  452. /*
  453. Header 4 Title color*
  454. Pick a background color (default: #666)
  455. */
  456. .hdcn .hdcn4 h1{color:'. gamexls_get_option( 'header4-titlecolor', '#666' ).'}
  457.  
  458.  
  459. /*
  460. Footer Background Color 1*
  461. Pick a background color (default: #2E2F31)
  462. */
  463. .ftcn .ftcn1{background-color:'. gamexls_get_option( 'footer-colorcl1', '#2E2F31' ).'}
  464.  
  465.  
  466. /*
  467. Footer Background Color 2*
  468. Pick a background color (default: #3E4649)
  469. */
  470. .ftcn.bgc2{background-color:'. gamexls_get_option( 'footer-colorcl2', '#3E4649' ).'}
  471.  
  472.  
  473. /*
  474. Dark Background Color 1 (Base)
  475. Pick a background color (default: #2E2F31)
  476. */
  477. .bgc1,.blkcn-2 .blkhd,.widget_myscore_leaderboard .blkhd,a.morgms-rnd10,a.delnkrnd10,a.remove-parent,a.clrfav,.blkhd.bgc1,.widget_search .blkhd,.widget_mabp_user_login .blkhd,.comment-respond,.widget_gamexls_leaderboard .blkhd,.widget_display_search #bbp-search-form,.widget_display_search .blkhd,.bbp_widget_login .blkhd,.bbp_widget_login form,.bbp_widget_login .bbp-logged-in,.widget_myscore_leaderboard ul,.widget_search form,div.ui-dialog,.profile-fields td,#message-threads td,.buddypress .bdcn div.item-list-tabs,.buddypress.widget .blkhd,.buddypress.widget .widget-error,.buddypress.widget .item-list,.buddypress.widget .avatar-block,.buddypress.widget .item-options{background-color:'. gamexls_get_option( 'darkbg-colorcl1b', '#2E2F31' ).';}
  478. .txcmrnd10:before{border-right-color:'. gamexls_get_option( 'darkbg-colorcl1b', '#2E2F31' ).'}
  479.  
  480.  
  481. /*
  482. Dark Background Color 2 (Base)
  483. Pick a background color (default: #3E4649)
  484. */
  485. .bgc2,span.bx-controls-direction a,.ftcn1 a:hover,.blkhd,.tagcnt a,.tagcloud a,.blkcn-2 .mCSB_draggerContainer,.wp-pagenavi a,.wp-pagenavi span,.mt-pagnav a,.mt-pagnav span,.menusr > li > a,.post-blg section .wp-caption,.hdcn3 .botn-rnd15,[class*="botn"],.gam_info,.widget_myscore_leaderboard ul li .playerinfo,.acomment-options a,a.friendship-button, .generic-button a, .item-list .small a.button,.buddypress .bdcn div.activity-meta a,.buddypress .bdcn div#item-header,.buddypress .bdcn div.item-list-tabs ul li.current a,.buddypress .bdcn div.item-list-tabs ul li.selected a,.buddypress.widget .item-list li,#wp-calendar caption{background-color:'. gamexls_get_option( 'darkbg-colorcl2b', '#3E4649' ).'}
  486.  
  487. @media all and (max-width: 960px)
  488. {
  489. .menuhd:before{background-color:'. gamexls_get_option( 'darkbg-colorcl2b', '#3E4649' ).';}
  490. }
  491.  
  492.  
  493. /*
  494. General Background Color
  495. Pick a color for Buttons, and other things (default: #23A96E)
  496. */
  497. .bgc3,[class*="botn"]:hover,button,input[type="submit"],.lstsoc a:hover,.lstsoc span#RBL_Element:hover,.menuhd > li:hover > a,span.bx-controls-direction a:hover,.imgame,.menuhd li ul,.mCSB_horizontal>.mCSB_scrollTools .mCSB_dragger .mCSB_dragger_bar,.blkhd-lnks li:hover,.tagcnt a:hover,.tagcloud a:hover,.pstcnt .bx-controls-direction a,a.morgms-rnd10:hover,.wp-pagenavi span.current,.wp-pagenavi a:hover,.mt-pagnav a:hover,.mt-pagnav span.current,.menusr > li:hover > a,.menusr > li ul,.shrbtncn:hover .iconb-shar,a.mornd15:hover,.hdcn3 .botn-rnd15:hover,.item-meta .activity,#wp-calendar tbody td a,#wp-calendar tfoot #prev a,#wp-calendar tfoot #next a,#wp-calendar tfoot #prev a:hover,#wp-calendar tfoot #next a:hover,.item-list .small a.button:hover,.buddypress .bdcn div.activity-meta a:hover,.generic-button a:hover,.acomment-options a:hover,.buddypress .bdcn div.item-list-tabs ul li a span{background-color:'. gamexls_get_option( 'general-background', '#23A96E' ).'}
  498. .post-blg section blockquote{border-left-color:'. gamexls_get_option( 'general-background', '#23A96E' ).'}
  499.  
  500. @media all and (max-width: 790px)
  501. {
  502. .lstcmnts li li{border-left:2px solid '. gamexls_get_option( 'general-background', '#23A96E' ).'}
  503. }
  504.  
  505. @media all and (max-width: 960px)
  506. {
  507. .menuhd:hover:before,.menuhd,.menuhd li,.menuhd li a,
  508. div.shrbtncn ul.lstshr-rnd15{background-color: '. gamexls_get_option( 'general-background', '#23A96E' ).'!important;}
  509. }
  510.  
  511.  
  512. /*BG Forms: Text Fields*/
  513. /*Regular*/
  514. input[type="text"],
  515. input[type="password"],
  516. textarea,
  517. select{background-color:'. gamexls_get_option( 'bg-forms-text-regular', '#333' ).';}
  518. /*Focus*/
  519. input[type="text"]:focus,
  520. input[type="password"]:focus,
  521. textarea:focus,
  522. select:focus{background-color:'. gamexls_get_option( 'bg-forms-text-focus', '#444' ).'}
  523.  
  524.  
  525. /*Forms: Text Fields*/
  526. /*Color*/
  527. ::-webkit-input-placeholder{color:'. gamexls_get_option( 'forms-text-regular', '#999' ).';}
  528. :-moz-placeholder{color:'. gamexls_get_option( 'forms-text-regular', '#999' ).';}
  529. ::-moz-placeholder{color:'. gamexls_get_option( 'forms-text-regular', '#999' ).';}
  530. :-ms-input-placeholder{color:'. gamexls_get_option( 'forms-text-regular', '#999' ).';}
  531.  
  532. /*Focus*/
  533. input[type="text"],
  534. input[type="password"],
  535. textarea,
  536. select{color:'. gamexls_get_option( 'forms-text-focus', '#fff' ).';}
  537.  
  538.  
  539. /*
  540. Links Color
  541. Pick a color for links
  542. Regular: #333333
  543. Hover: #23A96E
  544. */
  545. /*REGULAR*/
  546. a,.post-blg header p span a:hover,.gam-txt a,.blkhd-lnks a.active,.blkhd-lnks a.active:hover{color:'. $mtlinkcolor['regular'].'}
  547.  
  548. /*HOVER*/
  549. a:hover,.clr1,.logo-txt span span,.hdcn1 h1:before,.hdcn1 div:before,[class*="lsticb"] li a:hover:before,[class*="lsticb"] li a:hover,.hdcn4 .brdcrm a:hover,ul.lstfavgms > li a:hover,.tagsft a:hover,.txcmrnd10 a:hover,.comment-reply-link:hover:before,#cancel-comment-reply-link:hover,.gam-txt a:hover,.shrbtncn strong.iconb-shar:before,.iconb-shar:before,div.ui-dialog .ui-icon-closethick:hover,.widget_categories ul li a:hover:before,.widget_archive ul li a:hover:before,.widget_recent_entries ul li a:hover:before,.widget_pages ul li a:hover:before,.widget_nav_menu li a:hover:before{color:'. $mtlinkcolor['hover'].'}
  550.  
  551.  
  552. /*
  553. Body General Color 1
  554. Pick a color (default: #666)
  555. */
  556. body,.lsticb-tro li,.hdcn4 h1,.gam-txt{color:'. gamexls_get_option( 'bd-general-c1', '#666' ).'}
  557.  
  558.  
  559. /*
  560. Body General Color 2
  561. Pick a color (default: #FFF)
  562. */
  563. .cowh,.cowh a,.cowh a:hover,.bx-controls-direction a i,.blkhd,.blkhd a,.imgame,.imgame a,.imgame a i,a.morgms-rnd10,a.morgms-rnd10:hover,.mt-pagnav,.mt-pagnav a,.mt-pagnav a:hover,.wp-pagenavi,.wp-pagenavi a,.wp-pagenavi a:hover,.lstfavgms li a.delnkrnd10:hover,ul.lstfavgms > li a.remove-parent:hover,.post-blg section .wp-caption,.txcmrnd10 a,div.frmsbcm form .intx,#cancel-comment-reply-link,#progressbar,.shrbtncn:hover strong.iconb-shar:before,.tagcloud a,.tagcloud a:hover,.comment-reply-title,.gam_info,.gam_info a,.gam_info:before,.widget_display_search,.bbp_widget_login form,.bbp-login-links a,.bbp-login-links a:hover,.bbp_widget_login .bbp-logged-in,.bbp_widget_login .bbp-logged-in a,.bbp_widget_login .bbp-logged-in a:hover,#item-header,.buddypress .bdcn table tr td.label,.embgam .blkhd+div p,.comment-respond form,.tagsft,.messages-notices,.txcmrnd10,div.ui-dialog{color:'. gamexls_get_option( 'bd-general-c2', '#FFF' ).'}
  564.  
  565.  
  566. /*
  567. Body General Color 3
  568. Pick a color (default: #ddd)
  569. */
  570. .leabrd li > strong span,.post-blg header p span:before,.post-blg header p time:before,article footer [class*="iconb"]:before,[class*="lsticb"] li a:before,.widget_categories ul li a:before,.widget_archive ul li a:before,.widget_recent_entries ul li a:before,.widget_pages ul li a:before,.widget_myscore_todays_scores ul li:before,.widget_myscore_latest_scores ul li:before,.widget_myscore_game_scores ul li :before,.widget_nav_menu li a:before,.widget_recent_comments ul li:before{color:'. gamexls_get_option( 'bd-general-c3', '#ddd' ).'}
  571.  
  572.  
  573. /*
  574. Body General Color 4
  575. Pick a color (default: #999)
  576. */
  577. article footer [class*="iconb"],.hdcn4 .brdcrm a,.hdcn4 .brdcrm strong,.post-blg header p span,.post-blg header p time,.post-blg header p span a,.post-blg section blockquote,.comment-reply-link:before,.bx-loading:before,.lstmtjq .loading:before,.votcnt .post-ratings+div+div,.videowidget,.widget_views ul,.widget_myscore_todays_scores ul,.widget_text .textwidget,.widget_rss ul,.widget_tag_cloud .tagcloud,.widget_ratings-widget ul,.widget_pages ul,.widget_meta ul,.widget_myarcadecontest_active_contest ul,.widget_myscore_most_active_players ul,.widget_nav_menu ul,.widget_myscore_game_scores ul,.widget_myscore_latest_scores ul,.widget_recent_entries ul,.widget_recent_comments ul,.widget_categories ul,.widget_archive ul,.widget_display_forums ul,.widget_display_topics ul,.widget_display_stats dl,.widget_display_views ul,.widget_display_replies ul,#wp-calendar thead th,#wp-calendar thead td,.buddypress.widget .item-list li,.buddypress.widget .widget-error,.hdcn4 .brdcrm,.post-blg section ul li:before{color:'. gamexls_get_option( 'bd-general-c4', '#999' ).'}
  578. </style>
  579. '."\n\r";
  580. }
  581. if( gamexls_get_option( 'custom-css', '' ) !=''){echo'<style type="text/css">'.gamexls_get_option( 'custom-css', '' ).'</style>'."\n\r";}
  582. }
  583. add_action('wp_head', 'mt_custom_css');
  584.  
  585. function mt_footer() {
  586. if( gamexls_get_option( 'custom_footer_code', '' ) !=''){echo stripslashes( gamexls_get_option( 'custom_footer_code', '' ) )."\r";}
  587. // Get the blog category
  588. $blog_category = gamexls_get_option( 'blogcat', '' );
  589. if(is_game() or is_single() or in_category($blog_category)){
  590. ?>
  591. <div id="fb-root"></div>
  592. <script>(function(d, s, id) {
  593. var js, fjs = d.getElementsByTagName(s)[0];
  594. if (d.getElementById(id)) return;
  595. js = d.createElement(s); js.id = id;
  596. js.src = "//connect.facebook.net/en_EN/all.js#xfbml=1&appId=483876481726854";
  597. fjs.parentNode.insertBefore(js, fjs);
  598. }(document, 'script', 'facebook-jssdk'));</script>
  599. <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
  600. <script type="text/javascript">
  601. window.___gcfg = {lang: 'en'};
  602.  
  603. (function() {
  604. var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
  605. po.src = 'https://apis.google.com/js/plusone.js';
  606. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  607. })();
  608. </script>
  609. <?php
  610. }
  611. }
  612. add_action('wp_footer', 'mt_footer');
  613.  
  614. function mt_get_excerpt($excerpt_length = false, $echo = true) {
  615. global $post;
  616.  
  617. // Get post excerpt
  618. $text = strip_shortcodes( $post->post_content );
  619. $text = apply_filters('the_content', $text);
  620. $text = str_replace(']]>', ']]&gt;', $text);
  621. $text = wp_trim_words( $text, 100, '' );
  622.  
  623. if ( $excerpt_length ) {
  624. if ( strlen($text) > $excerpt_length ) {
  625. $text = mb_substr($text, 0, $excerpt_length).' [...]';
  626. }
  627. }
  628.  
  629. if ($echo)
  630. echo $text;
  631. else
  632. return $text;
  633. }
  634.  
  635. function mt_get_best_players( $count = 5 ) {
  636. global $wpdb;
  637.  
  638. return $wpdb->get_results("SELECT h.user_id, COUNT(*) as highscores, u.plays as plays
  639. FROM ".MYARCADE_HIGHSCORES_TABLE." AS h
  640. INNER JOIN ".MYARCADE_USER_TABLE." AS u ON h.user_id=u.user_id
  641. GROUP BY h.user_id
  642. ORDER BY highscores DESC LIMIT ".$count);
  643. }
  644.  
  645. function mt_get_excluded_categories() {
  646. $result = 'exclude=';
  647. $blog = gamexls_get_option( 'blogcat', '' );
  648. if ( $blog ) {
  649. $result = 'exclude='.$blog.',';
  650. }
  651.  
  652. if ( !empty( gamexls_get_option( 'hidecatbox', '' )) ) {
  653. $categories = implode(',', gamexls_get_option( 'hidecatbox', '' ) );
  654. }
  655. else {
  656. $categories = '';
  657. }
  658.  
  659. $result .= $categories;
  660.  
  661. return $result;
  662. }
  663.  
  664. function gamexls_before_boxes(){
  665. $option= gamexls_get_option( 'presentation', 'Complete' );
  666. if($option=='Miniclip'){
  667. echo'
  668. <!--<pstp-2>-->
  669. <ul class="pstp-2 lstpst flli clfl">
  670. ';
  671. }
  672. if($option=='Vertical'){
  673. echo'<!--<pstp-3>--><ul class="pstp-3 lstpst clfl flli">';
  674. }
  675. }
  676. add_action( 'gamexls_before_boxes', 'gamexls_before_boxes');
  677.  
  678. function gamexls_after_boxes(){
  679. global $post;
  680. $option= gamexls_get_option( 'presentation', 'Complete' );
  681. if($option=='Half' or $option=='Miniclip' or $option=='Complete'){
  682. echo'</ul><!--</pstp-2>-->';
  683. }
  684. if($option=='Vertical'){
  685. echo'</ul><!--</pstp-3>-->';
  686. }
  687. if($option=='Complete'){
  688. ?>
  689. <?php if( gamexls_get_option( 'mtbeforelastestgames-switch', 1 ) =='1'){ ?>
  690. <!--<bnr728>-->
  691. <section class="blkcn bnr728 bgc1 mbot10px">
  692. <?php echo stripslashes( gamexls_get_option( 'mtbeforelastestgames', '<img src="'.get_template_directory_uri().'/img/cnt/bnr728.png" alt="bnr">' ) ); ?>
  693. </section>
  694. <!--</bnr728>-->
  695. <?php } ?>
  696.  
  697. <!--<latest games>-->
  698. <section class="blkcn pstp-4 mbot10px">
  699. <div class="blkhd"><strong><?php _e('LATEST GAMES','gamexls'); ?></strong></div>
  700. <section class="blkbd lstlatgms clfl bgwh padd10px">
  701. <?php if( gamexls_get_option( 'mtlastestgames-switch', 1 ) =='1'){ ?>
  702. <!--<bnr250>-->
  703. <section class="blkcn bnr250 bgc1 mbot10px">
  704. <?php echo stripslashes( gamexls_get_option( 'mtlastestgames', '<img src="'.get_template_directory_uri().'/img/cnt/bnr250.png" alt="bnr">' ) ); ?>
  705. </section>
  706. <!--</bnr250>-->
  707. <?php } ?>
  708. <ul>
  709. <?php
  710. $query = new WP_Query('showposts=6'.gamexls_mobile_tag());
  711. while ($query->have_posts()) :
  712. $query->the_post();
  713. ?>
  714. <!--<game>-->
  715. <li>
  716. <article>
  717. <header>
  718. <h2><a href="<?php the_permalink(); ?>"><?php myabp_get_title(20); ?></a></h2>
  719. <figure class="imgame"><?php echo myabp_print_thumbnail(270,270); ?><a href="<?php the_permalink() ?>" rel="bookmark" title="Play <?php the_title(); ?>"><i class="iconb-game bgbl-20 rnd15"></i></a></figure>
  720. </header>
  721. <footer class="clfl">
  722. <?php if(function_exists('the_ratings')) { ?>
  723. <div class="votcnt">
  724. <?php echo mt_the_ratings_results($post->ID); ?>
  725. </div>
  726. <?php } ?>
  727. <div>
  728. <?php if(function_exists('the_views')) { ?><span class="iconb-game"><?php the_views(); ?></span><?php } ?> <strong class="iconb-comt"><?php echo get_comments_number(); ?></strong>
  729. </div>
  730. </footer>
  731. </article>
  732. </li>
  733. <!--</game>-->
  734. <?php
  735. endwhile;
  736. ?>
  737. </ul>
  738. </section>
  739. </section>
  740. <!--</latest games>-->
  741. <?php
  742. }
  743. }
  744. add_action( 'gamexls_after_boxes', 'gamexls_after_boxes');
  745.  
  746. function gamexls_before_boxes_complete(){
  747. global $i;
  748. $option= gamexls_get_option( 'presentation', 'Complete' );
  749. if($option=='Complete' and $i==2){
  750. echo'<!--<pstp-2>--><ul class="pstp-2 lstpst clfl flli">';
  751. }
  752. }
  753. add_action( 'gamexls_before_boxes_complete', 'gamexls_before_boxes_complete');
  754.  
  755. function gamexls_after_boxes_complete(){
  756. global $i;
  757. $option= gamexls_get_option( 'presentation', 'Complete' );
  758. if($option=='Complete' and $i==7){
  759. echo'</ul><!--</pstp-2>-->';
  760. }
  761. }
  762. add_action( 'gamexls_after_boxes_complete', 'gamexls_after_boxes_complete');
  763.  
  764.  
  765. function gamexls_before_boxes_complete_slider(){
  766. global $i;
  767. $option= gamexls_get_option( 'presentation', 'Complete' );
  768. if($option=='Complete' and $i==8){
  769. echo'<!--<pstp-3>--><ul class="pstp-3 lstpst clfl flli">';
  770. }
  771. }
  772. add_action( 'gamexls_before_boxes_complete_slider', 'gamexls_before_boxes_complete_slider');
  773.  
  774. function mt_calculate_height($gamexls_box_count) {
  775. switch ( gamexls_get_option( 'presentation', 'Complete' ) ) {
  776. case 'Vertical': {
  777. $count = round(intval($gamexls_box_count) / 2);
  778. $height = 60 + 110 * $count;
  779. return 'style="height:'.$height.'px;"';
  780. } break;
  781.  
  782. case 'Half': {
  783. $count = round(intval($gamexls_box_count) );
  784. if($count>=5){$height = 10 + 40 * $count;}elseif($count==1){$height = 10 + 80 * $count;}else{$height = 10 + 60 * $count;}
  785. return 'style="height:'.$height.'px;"';
  786. } break;
  787.  
  788. case 'Miniclip': {
  789. $count = round(intval($gamexls_box_count) );
  790. if($count>=5){$height = 10 + 40 * $count;}elseif($count==1){$height = 10 + 80 * $count;}else{$height = 10 + 60 * $count;}
  791. return 'style="height:'.$height.'px;"';
  792. } break;
  793.  
  794. case 'Complete': {
  795. $count = round(intval($gamexls_box_count) );
  796. if($count>=5){$height = 10 + 37 * $count;}elseif($count==1){$height = 10 + 80 * $count;}else{$height = 10 + 60 * $count;}
  797. return 'style="height:'.$height.'px;"';
  798. } break;
  799.  
  800. default: {
  801. return false;
  802. }
  803. }
  804.  
  805. return '';
  806. }
  807.  
  808. function gamexls_content(){
  809. $content = apply_filters('the_content', get_the_content());
  810. $content = preg_replace("/<img[^>]+\>/i", "", $content);
  811. return $content;
  812. }
  813.  
  814. function gamexls_comment( $comment, $args, $depth ) {
  815. $GLOBALS['comment'] = $comment;
  816. switch ( $comment->comment_type ) :
  817. case '' :
  818. ?>
  819. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  820. <!--<comnt>-->
  821. <div class="comtcn pore" id="comment-<?php comment_ID(); ?>">
  822. <figure class="cirl-imgusrcn bgwh-10"><?php echo get_avatar( $comment, 116); ?></figure>
  823. <div class="txcmrnd10 bgc1 pore">
  824. <p><?php echo get_comment_author_link(); ?> - <?php echo get_comment_date('d'); ?>/<?php echo get_comment_date('m'); ?>/<?php echo get_comment_date('Y'); ?></p>
  825. <?php if ( $comment->comment_approved == '0' ) : ?>
  826. <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'gamexls' ); ?></em>
  827. <br />
  828. <?php endif; ?>
  829. <div class="comment_txt"><?php comment_text(); ?></div>
  830. <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  831. </div>
  832. </div>
  833. <!--</comnt>-->
  834. <?php
  835. break;
  836. case 'pingback' :
  837. case 'trackback' :
  838. ?>
  839. <li class="post pingback">
  840. <p><?php _e( 'Pingback:', 'gamexls' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'gamexls' ), ' ' ); ?></p>
  841. <?php
  842. break;
  843. endswitch;
  844. }
  845.  
  846. if(function_exists('the_ratings')) {
  847. function mt_the_ratings_results($post_id, $new_user = 0, $new_score = 0, $new_average = 0) {
  848. if($new_user == 0 && $new_score == 0 && $new_average == 0) {
  849. $post_ratings_data = null;
  850. } else {
  851. $post_ratings_data = new stdClass();
  852. $post_ratings_data->ratings_users = $new_user;
  853. $post_ratings_data->ratings_score = $new_score;
  854. $post_ratings_data->ratings_average = $new_average;
  855. }
  856. // Return Post Ratings Template
  857. return expand_ratings_template('%RATINGS_IMAGES%', $post_id, $post_ratings_data);
  858. }
  859. }
  860.  
  861. add_action('init', 'gamexls_init', 0);
  862.  
  863. // Add filter for blog template
  864. add_filter('category_template', 'gamexls_blogcat_template');
  865.  
  866. if ( !function_exists('gamexls_blogcat_template') ) {
  867. /**
  868. * Blog template redirection
  869. */
  870. function gamexls_blogcat_template($template) {
  871. global $post;
  872.  
  873. // Get the blog category
  874. $blog_category = gamexls_get_option( 'blogcat', '' );
  875.  
  876. if ($blog_category == '') return $template;
  877.  
  878. if(in_category($blog_category)){
  879. // overwrite the template file if exist
  880. if ( file_exists(get_template_directory() . '/template-blog.php' ) ) {
  881. $template = get_template_directory() . '/template-blog.php';
  882. }
  883. }
  884.  
  885. return $template;
  886. }
  887. }
  888.  
  889. // Add filter for blog template
  890. add_filter('single_template', 'gamexls_blog_template');
  891.  
  892. if ( !function_exists('gamexls_blog_template') ) {
  893. /**
  894. * Blog template redirection
  895. */
  896. function gamexls_blog_template($template) {
  897. global $post;
  898.  
  899. // Get the blog category
  900. $blog_category = gamexls_get_option( 'blogcat', '' );
  901.  
  902. if ($blog_category == '') return $template;
  903.  
  904. $post_cat = get_the_category();
  905.  
  906.  
  907. if ( is_singular() && !empty($post_cat) and (in_category($blog_category) || ($blog_category == $post_cat[0]->category_parent))) {
  908. // overwrite the template file if exist
  909. if ( file_exists(get_template_directory() . '/template-blog-post.php' ) ) {
  910. $template = get_template_directory() . '/template-blog-post.php';
  911. }
  912. }
  913.  
  914. return $template;
  915. }
  916. }
  917.  
  918. /**
  919. * GameXLS activation function
  920. */
  921. function gamexls_activation( $oldname, $oldtheme = false ) {
  922. add_rewrite_endpoint( 'play', EP_PERMALINK );
  923. add_rewrite_endpoint('fullscreen', EP_PERMALINK);
  924. flush_rewrite_rules();
  925. }
  926. add_action('after_switch_theme', 'gamexls_activation', 0);
  927.  
  928. /**
  929. * GameXLS init function - called when WordPress is initialized
  930. */
  931. function gamexls_init() {
  932.  
  933. // Check if pre-game page is enabled
  934. if ( gamexls_get_option( 'pregame-page', 1 ) == '1' ) {
  935. $endpoint = gamexls_get_option( 'game-play-permalink-endpoint', 'play' );
  936. if ( empty($endpoint) ) $endpoint = 'play';
  937. add_rewrite_endpoint( $endpoint, EP_PERMALINK );
  938. add_action( 'template_redirect', 'gamexls_play_template_redirect' );
  939. }
  940.  
  941. // Check if fullscreen option is enabled
  942. if ( gamexls_get_option( 'fullscreen-button', 1 ) == '1' ) {
  943. add_rewrite_endpoint('fullscreen', EP_PERMALINK);
  944. add_action('template_redirect', 'gamexls_fullscreen_teplate_redirect');
  945. }
  946. }
  947.  
  948.  
  949. /**
  950. * Handles game display when user comes from the pre-game page (game landing page)
  951. *
  952. * @global type $wp_query
  953. * @return type
  954. */
  955. function gamexls_play_template_redirect() {
  956. global $wp_query;
  957.  
  958. $endpoint = gamexls_get_option( 'game-play-permalink-endpoint', 'play' );
  959. if ( empty($endpoint) ) return;
  960.  
  961. // if this is not a request for game play then bail
  962. if ( !is_singular() || !isset($wp_query->query_vars[$endpoint]) ) {
  963. return;
  964. }
  965.  
  966. // Include game play template
  967. include dirname( __FILE__ ) . '/single-play.php';
  968. exit;
  969. }
  970.  
  971.  
  972. /**
  973. * Handles full screen redirect
  974. *
  975. * @global type $wp_query
  976. * @return type
  977. */
  978. function gamexls_fullscreen_teplate_redirect() {
  979. global $wp_query;
  980.  
  981. // if this is not a fullscreen request then bail
  982. if ( !is_singular() || !isset($wp_query->query_vars['fullscreen']) ) {
  983. return;
  984. }
  985.  
  986. // Include fullscreen template
  987. include dirname( __FILE__ ) . '/single-fullscreen.php';
  988. exit;
  989. }
  990.  
  991. /**
  992. * Generate play permalink
  993. *
  994. * @return type
  995. */
  996. function gamexls_play_link($op=1) {
  997. $endpoint = gamexls_get_option( 'game-play-permalink-endpoint', 'play' );
  998. if ( empty($endpoint) ) return;
  999. if($op==1){
  1000. ?>
  1001. <a href="<?php echo get_permalink() . $endpoint . '/'; ?>" title="<?php echo __("Play the game", "gamexls"); ?> <?php the_title_attribute(); ?>" rel="bookmark nofollow" class="botn iconb-game"><?php _e("Play The Game", "gamexls"); ?></a>
  1002. <?php
  1003. }else{
  1004. ?>
  1005. <a href="<?php echo get_permalink() . $endpoint . '/'; ?>" title="<?php echo __("Play The Game", "gamexls"); ?> <?php the_title_attribute(); ?>" rel="bookmark nofollow"><i class="iconb-game bgbl-20 rnd15"></i></a>
  1006. <?php
  1007. }
  1008. }
  1009.  
  1010. class gamexls_walker_nav_menu extends Walker_Nav_Menu {
  1011.  
  1012. // add classes to ul sub-menus
  1013. function start_lvl( &$output, $depth = 0, $args = array() ) {
  1014. // depth dependent classes
  1015. $indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' ); // code indent
  1016. $display_depth = ( $depth + 1); // because it counts the first submenu as 0
  1017. $classes = array(
  1018. 'sub-menu',
  1019. ( $display_depth % 2 ? 'menu-odd' : 'menu-even' ),
  1020. ( $display_depth >=2 ? 'sub-sub-menu' : '' ),
  1021. 'menu-depth-' . $display_depth
  1022. );
  1023. $class_names = implode( ' ', $classes );
  1024.  
  1025. // build html
  1026. $output .= "\n" . $indent . '<ul class="' . $class_names . '">' . "\n";
  1027. }
  1028.  
  1029. // add main/sub classes to li's and links
  1030. function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
  1031. global $wp_query;
  1032. $indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' ); // code indent
  1033.  
  1034. // depth dependent classes
  1035. $depth_classes = array(
  1036. ( $depth == 0 ? 'main-menu-item' : 'sub-menu-item' ),
  1037. ( $depth >=2 ? 'sub-sub-menu-item' : '' ),
  1038. ( $depth % 2 ? 'menu-item-odd' : 'menu-item-even' ),
  1039. 'menu-item-depth-' . $depth
  1040. );
  1041. $depth_class_names = esc_attr( implode( ' ', $depth_classes ) );
  1042.  
  1043. // passed classes
  1044. $classes = empty( $item->classes ) ? array() : (array) $item->classes;
  1045. $class_names = esc_attr( implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ) );
  1046.  
  1047. // build html
  1048. $output .= $indent . '<li id="nav-menu-item-'. $item->ID . '" class="' . $depth_class_names . ' ' . $class_names . '">';
  1049.  
  1050. // link attributes
  1051. $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
  1052. $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
  1053. $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
  1054. $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
  1055. $attributes .= ' class="menu-link ' . ( $depth > 0 ? 'sub-menu-link' : 'main-menu-link' ) . '"';
  1056.  
  1057. $item_output = sprintf( '%1$s<a%2$s>%3$s%4$s%5$s</a>%6$s',
  1058. $args->before,
  1059. $attributes,
  1060. $args->link_before,
  1061. apply_filters( 'the_title', $item->title, $item->ID ),
  1062. $args->link_after,
  1063. $args->after
  1064. );
  1065.  
  1066. // build html
  1067. $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
  1068. }
  1069. }
  1070.  
  1071. /**
  1072. * Display Google Rich Snippet
  1073. *
  1074. * @global type $post
  1075. */
  1076. function gamexls_rich_snippet() {
  1077. global $post;
  1078.  
  1079. if ( function_exists('the_ratings') && gamexls_get_option( 'rich-snippet', 1 ) == '1' ) {
  1080. $ratings_user = intval(get_post_meta($post->ID, 'ratings_users', true));
  1081. $rating_average = get_post_meta($post->ID, 'ratings_average', true);
  1082. $ratings_max = intval(get_option('postratings_max'));
  1083.  
  1084. if ( empty($rating_average) ) $rating_average = 0;
  1085. echo "\n";
  1086. ?>
  1087. <!-- Google Rich Snipet -->
  1088. <div itemscope itemtype="http://schema.org/SoftwareApplication">
  1089. <meta itemprop="name" content="<?php the_title(); ?>" />
  1090. <meta itemprop="image" content="<?php myabp_print_thumbnail_url(); ?>" />
  1091. <meta itemprop="description" content="<?php echo get_the_excerpt(); ?>" />
  1092. <meta itemprop="softwareApplicationCategory" content="GameApplication" />
  1093. <div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
  1094. <span itemprop="ratingCount"><?php echo $ratings_user; ?></span> <?php _e('votes','gamexls'); ?>, <?php _e('average:','gamexls'); ?> <span itemprop="ratingValue"><?php echo $rating_average; ?></span>/<span itemprop="bestRating"><?php echo $ratings_max; ?></span>
  1095. </div>
  1096. </div>
  1097. <?php
  1098. echo "\n";
  1099. }
  1100. }
  1101.  
  1102. add_action('widgets_init', 'mt_widgets_init');
  1103. function mt_widgets_init() {
  1104. register_sidebar(
  1105. array('name' =>'Home Sidebar',
  1106. 'id' =>'home-sidebar',
  1107. 'description' => __('This is the sidebar that gets shown on the home page.','gamexls'),
  1108. 'before_widget' => '<section id="%1$s" class="blkcn mbot10px %2$s">',
  1109. 'after_widget' => '</section>',
  1110. 'before_title' => '<div class="blkhd">',
  1111. 'after_title' => '</div>',
  1112. )
  1113. );
  1114.  
  1115. register_sidebar(
  1116. array('name' =>'Single Sidebar',
  1117. 'id' =>'single-sidebar',
  1118. 'description' => __('This is your sidebar that gets shown on the game or blog pages.','gamexls'),
  1119. 'before_widget' => '<section id="%1$s" class="blkcn mbot10px %2$s">',
  1120. 'after_widget' => '</section>',
  1121. 'before_title' => '<div class="blkhd">',
  1122. 'after_title' => '</div>',
  1123. )
  1124. );
  1125.  
  1126. register_sidebar(
  1127. array('name' =>'Page Sidebar',
  1128. 'id' =>'page-sidebar',
  1129. 'description' => __('This is your sidebar that gets shown on most of your pages.','gamexls'),
  1130. 'before_widget' => '<section id="%1$s" class="blkcn mbot10px %2$s">',
  1131. 'after_widget' => '</section>',
  1132. 'before_title' => '<div class="blkhd">',
  1133. 'after_title' => '</div>',
  1134. )
  1135. );
  1136.  
  1137. register_sidebar(
  1138. array('name' =>'Category Sidebar',
  1139. 'id' =>'category-sidebar',
  1140. 'description' => __('This is your sidebar that gets shown on the category pages.','gamexls'),
  1141. 'before_widget' => '<section id="%1$s" class="blkcn mbot10px %2$s">',
  1142. 'after_widget' => '</section>',
  1143. 'before_title' => '<div class="blkhd">',
  1144. 'after_title' => '</div>',
  1145. )
  1146. );
  1147.  
  1148. }
  1149.  
  1150. function bp_core_register_common_scripts_gamexls() {
  1151. if ( gamexls_get_option( 'bp-compatibility', 1 ) == '1' ) {
  1152. $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
  1153. $url = buddypress()->plugin_url . 'bp-core/js/';
  1154.  
  1155. $scripts = apply_filters( 'bp_core_register_common_scripts', array(
  1156.  
  1157. // Legacy
  1158. 'bp-confirm' => array( 'file' => "{$url}confirm{$min}.js", 'dependencies' => array( 'jquery' ) ),
  1159. 'bp-widget-members' => array( 'file' => "{$url}widget-members{$min}.js", 'dependencies' => array( 'jquery' ) ),
  1160. 'bp-jquery-query' => array( 'file' => "{$url}jquery-query{$min}.js", 'dependencies' => array( 'jquery' ) ),
  1161. 'bp-jquery-cookie' => array( 'file' => "{$url}jquery-cookie{$min}.js", 'dependencies' => array( 'jquery' ) ),
  1162.  
  1163. // 2.1
  1164. 'jquery-caret' => array( 'file' => "{$url}jquery.caret{$min}.js", 'dependencies' => array( 'jquery' ) ),
  1165. 'jquery-atwho' => array( 'file' => "{$url}jquery.atwho{$min}.js", 'dependencies' => array( 'jquery', 'jquery-caret' ) ),
  1166. ) );
  1167.  
  1168. $version = bp_get_version();
  1169.  
  1170. foreach ( $scripts as $id => $script ) {
  1171. wp_register_script( $id, $script['file'], $script['dependencies'], $version );
  1172. wp_enqueue_script( $id );
  1173. }
  1174. }
  1175. }
  1176. add_action( 'bp_enqueue_scripts', 'bp_core_register_common_scripts_gamexls', 1 );
  1177.  
  1178. /**
  1179. * Remove query strings from static resources
  1180. *
  1181. * @version 1.0.0
  1182. * @since 1.0.0
  1183. * @return string Cleaned script URL
  1184. */
  1185. function gamexls_script_version( $src ){
  1186. $parts = explode( '?ver', $src );
  1187. return $parts[0];
  1188. }
  1189. if ( ! is_admin() ) {
  1190. add_filter( 'script_loader_src', 'gamexls_script_version', 15, 1 );
  1191. add_filter( 'style_loader_src', 'gamexls_script_version', 15, 1 );
  1192. }
  1193.  
  1194.  
  1195.  
  1196. /**
  1197. * Get mobile query tag is the site is access by a mobile device
  1198. *
  1199. * @version 1.0.0
  1200. * @since 1.0.0
  1201. * @return [type] [description]
  1202. */
  1203. function gamexls_mobile_tag() {
  1204. if ( wp_is_mobile() && gamexls_get_option( 'mobile' ) ) {
  1205. return '&tag=mobile';
  1206. }
  1207.  
  1208. return false;
  1209. }
  1210.  
  1211. /**
  1212. * Get mobile query array tag is the site is access by a mobile device
  1213. *
  1214. * @version 1.0.0
  1215. * @since 1.0.0
  1216. * @return [type] [description]
  1217. */
  1218. function gamexls_mobile_array_tag() {
  1219.  
  1220. if ( wp_is_mobile() && gamexls_get_option( 'mobile' ) ) {
  1221. return 'mobile';
  1222. }
  1223.  
  1224. return false;
  1225. }
  1226.  
  1227. /**
  1228. * Retrieve a theme option
  1229. *
  1230. * @version 2.0.0
  1231. * @since 2.0.0
  1232. * @param string $option_name
  1233. * @return mixed
  1234. */
  1235. function gamexls_get_option( $option_name, $default = false ) {
  1236. global $gamexlsmt;
  1237.  
  1238. if ( empty( $gamexlsmt ) ) {
  1239. $gamexlsmt = get_option( 'gamexlsmt' );
  1240. }
  1241.  
  1242. if ( ! isset( $gamexlsmt[ $option_name ] ) ) {
  1243. return $default;
  1244. }
  1245.  
  1246. return $gamexlsmt[ $option_name ];
  1247. }
  1248. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement