Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.20 KB | None | 0 0
  1. <?php
  2.  
  3. // Set the content width
  4. if ( ! isset( $content_width ) )
  5. $content_width = 598; /* pixels */
  6.  
  7. /*-----------------------------------------------------------------------------------*/
  8. /* Theme setup
  9. /*-----------------------------------------------------------------------------------*/
  10.  
  11. if ( ! function_exists( 'gamepress_setup' ) ):
  12.  
  13. function gamepress_setup() {
  14.  
  15.  
  16.  
  17. // Enable theme translations
  18. load_theme_textdomain( 'gamepress', get_template_directory() . '/languages' );
  19.  
  20. $locale = get_locale();
  21. $locale_file = get_template_directory() . "/languages/$locale.php";
  22. if ( is_readable( $locale_file ) )
  23. require_once( $locale_file );
  24.  
  25. // Add default posts and comments RSS feed links to head
  26. add_theme_support( 'automatic-feed-links' );
  27.  
  28. // Add stylesheet for the WYSIWYG editor
  29. add_editor_style();
  30.  
  31. // Image thumbnails
  32. if (function_exists('add_theme_support')) {
  33. add_theme_support('post-thumbnails');
  34. set_post_thumbnail_size(80, 80, true);
  35. add_image_size('article-thumb', 200, 200, true);
  36. add_image_size('gamecover', 137, 161, true);
  37. add_image_size('gamecover-thumb', 100, 118, true);
  38. add_image_size('video-thumb', 284, 158, true);
  39. add_image_size('nivo-slide', 642, 362, true);
  40. add_image_size('nivo-thumb', 128, 72, true);
  41. }
  42.  
  43. // Register menu
  44. register_nav_menus( array(
  45. 'primary-menu' => __('GamePress Main Menu','gamepress'),
  46. ) );
  47.  
  48. // Clean up the <head>
  49. remove_action('wp_head', 'rsd_link');
  50. remove_action('wp_head', 'wlwmanifest_link');
  51. remove_action('wp_head', 'wp_generator');
  52.  
  53. // Custom backgrounds support
  54. $defaults = array(
  55. 'default-color' => '',
  56. 'default-image' => get_template_directory_uri().'/images/body-bg1.png',
  57. 'wp-head-callback' => 'gamepress_custom_background_callback'
  58. );
  59. add_theme_support( 'custom-background', $defaults );
  60.  
  61.  
  62. }
  63. endif;
  64.  
  65. add_action( 'after_setup_theme', 'gamepress_setup' );
  66.  
  67. function gamepress_custom_background_callback() {
  68.  
  69. /* Get the background image. */
  70. $image = get_background_image();
  71.  
  72. /* If there's an image, just call the normal WordPress callback. We won't do anything here. */
  73. if ( !empty( $image ) ) {
  74. _custom_background_cb();
  75. return;
  76. }
  77.  
  78. /* Get the background color. */
  79. $color = get_background_color();
  80.  
  81. /* If no background color, return. */
  82. if ( empty( $color ) )
  83. return;
  84.  
  85. /* Use 'background' instead of 'background-color'. */
  86. $style = "background: #{$color};";
  87.  
  88. ?>
  89. <style type="text/css">body { <?php echo trim( $style ); ?> }</style>
  90. <?php
  91.  
  92. }
  93.  
  94. /*-----------------------------------------------------------------------------------*/
  95. /* JavaScript & CSS
  96. /*-----------------------------------------------------------------------------------*/
  97. function gamepress_enqueue_scripts()
  98. {
  99. if (!is_admin()) {
  100. wp_enqueue_script('jquery');
  101. wp_register_script('gamepress', get_template_directory_uri() . '/js/gamepress.js',array('jquery'));
  102. wp_enqueue_script('gamepress');
  103. wp_register_script('jquery_tools', get_template_directory_uri() . '/js/jquery.tools.min.js');
  104. wp_enqueue_script('jquery_tools');
  105. wp_register_script('easing', get_template_directory_uri() . '/js/jquery.easing.1.3.js');
  106. wp_enqueue_script('easing');
  107. wp_register_script('modernizr', get_template_directory_uri() . '/js/modernizr-custom.min.js');
  108. wp_enqueue_script('modernizr');
  109. wp_register_script('placeholder', get_template_directory_uri() . '/js/jquery.placeholder.min.js');
  110. wp_enqueue_script('placeholder');
  111. }
  112. if (is_home() && of_get_option('gamepress_slider_radio')){
  113. wp_register_script('nivoslider', get_template_directory_uri() . '/js/nivo-slider/jquery.nivo.slider.pack.js');
  114. wp_enqueue_script('nivoslider');
  115. }
  116. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  117. wp_enqueue_script( 'comment-reply' );
  118. }
  119. }
  120. add_action('wp_enqueue_scripts', 'gamepress_enqueue_scripts');
  121.  
  122. function gamepress_enqueue_css()
  123. {
  124. if (is_home()){
  125. wp_register_style('nivo_css', get_template_directory_uri() . '/js/nivo-slider/nivo-slider.css');
  126. wp_enqueue_style('nivo_css');
  127. if(of_get_option('gamepress_slider_type') == '1') {
  128. wp_register_style('nivo_default_css', get_template_directory_uri() . '/js/nivo-slider/nivo-default.css');
  129. wp_enqueue_style('nivo_default_css');
  130. }else {
  131. wp_register_style('nivo_thumb_css', get_template_directory_uri() . '/js/nivo-slider/nivo-thumbnails.css');
  132. wp_enqueue_style('nivo_thumb_css');
  133. }
  134. }
  135. wp_register_style('default_stylesheet', get_stylesheet_directory_uri() . '/style.css');
  136. wp_enqueue_style('default_stylesheet');
  137. }
  138. add_action('wp_print_styles', 'gamepress_enqueue_css');
  139.  
  140. if ( ! function_exists( 'gamepress_enqueue_skin_css' ) ) {
  141. function gamepress_enqueue_skin_css() {
  142.  
  143. wp_register_style('dark_stylesheet', get_template_directory_uri() . '/css/dark.css');
  144. wp_enqueue_style('dark_stylesheet');
  145.  
  146. if(of_get_option('gamepress_color_scheme') && of_get_option('gamepress_color_scheme') != 'red') {
  147. wp_register_style('color_scheme', get_template_directory_uri() . '/images/' . of_get_option('gamepress_color_scheme','red') . '/style.css');
  148. wp_enqueue_style('color_scheme');
  149. }
  150. }
  151. }
  152. add_action('wp_print_styles', 'gamepress_enqueue_skin_css');
  153.  
  154. /*-----------------------------------------------------------------------------------*/
  155. /* Display <title> tag
  156. /*-----------------------------------------------------------------------------------*/
  157.  
  158. // filter function for wp_title
  159. function gamepress_filter_wp_title( $old_title, $sep, $sep_location ){
  160.  
  161. // add padding to the sep
  162. $ssep = ' ' . $sep . ' ';
  163.  
  164. // find the type of index page this is
  165. if( is_category() ) $insert = $ssep . __('Category','gamepress');
  166. elseif( is_tag() ) $insert = $ssep . __('Tag','gamepress');
  167. elseif( is_author() ) $insert = $ssep . __('Author','gamepress');
  168. elseif( is_year() || is_month() || is_day() ) $insert = $ssep . __('Archives','gamepress');
  169. elseif( is_home() ) $insert = $ssep . get_bloginfo('description');
  170. else $insert = NULL;
  171.  
  172. // get the page number we're on (index)
  173. if( get_query_var( 'paged' ) )
  174. $num = $ssep . __('Page ','gamepress') . get_query_var( 'paged' );
  175.  
  176. // get the page number we're on (multipage post)
  177. elseif( get_query_var( 'page' ) )
  178. $num = $ssep . __('Page ','gamepress') . get_query_var( 'page' );
  179.  
  180. // else
  181. else $num = NULL;
  182.  
  183.  
  184. // concoct and return new title
  185. return get_bloginfo( 'name' ) . $insert . $old_title . $num;
  186. }
  187.  
  188. add_filter( 'wp_title', 'gamepress_filter_wp_title', 10, 3 );
  189.  
  190. function gamepress_rss_title($title) {
  191. /* need to fix our add a | blog name to wp_title */
  192. $ft = str_replace(' | ','',$title);
  193. return str_replace(get_bloginfo('name'),'',$ft);
  194. }
  195. add_filter('get_wp_title_rss', 'gamepress_rss_title',10,1);
  196.  
  197. /*-----------------------------------------------------------------------------------*/
  198. /* Excerpt config
  199. /*-----------------------------------------------------------------------------------*/
  200. function gamepress_excerptlength_teaser($length) {
  201. return 20;
  202. }
  203. function gamepress_excerptlength_default($length) {
  204. return 40;
  205. }
  206. function gamepress_excerptmore($more)
  207. {
  208. global $post;
  209. return '... <br /><a class="more" href="' . get_permalink($post->ID) . '">'.__('Read more', 'gamepress').' &raquo;</a>';
  210. }
  211. function gamepress_morelink($more)
  212. {
  213. global $post;
  214. return '... <a class="more_link" href="' . get_permalink($post->ID) . '">'.__('Read more', 'gamepress').' &raquo;</a>';
  215. }
  216.  
  217. function gamepress_excerpt($length_callback='', $more_callback='') {
  218. global $post;
  219. if(function_exists($length_callback)){
  220. add_filter('excerpt_length', $length_callback);
  221. }
  222. if(function_exists($more_callback)){
  223. add_filter('excerpt_more', $more_callback);
  224. }
  225. $output = get_the_excerpt();
  226. $output = apply_filters('wptexturize', $output);
  227. $output = apply_filters('convert_chars', $output);
  228. $output = '<p>'.$output.'</p>';
  229. echo $output;
  230. }
  231.  
  232. /*-----------------------------------------------------------------------------------*/
  233. /* Homepage main loop mods
  234. /*-----------------------------------------------------------------------------------*/
  235.  
  236. function gamepress_home_pre_get_post ($query) {
  237.  
  238. if (!is_admin() && is_home() && $query->is_main_query()) {
  239. $hp_include = of_get_option('gamepress_hp_include',array());
  240. $include_reviews = '';
  241. $include_videos = '';
  242.  
  243. if(is_array($hp_include) && !empty($hp_include['gamepress_reviews'])) { $include_reviews = "gamepress_reviews"; }
  244. if(is_array($hp_include) && !empty($hp_include['gamepress_video'])) { $include_videos = "gamepress_video"; }
  245.  
  246. $query->set( 'post_type', array(
  247. 'post', $include_reviews, $include_videos
  248. ));
  249.  
  250. return $query;
  251.  
  252. }
  253. }
  254.  
  255. add_action('pre_get_posts', 'gamepress_home_pre_get_post');
  256.  
  257. /*-----------------------------------------------------------------------------------*/
  258. /* Create custom post types
  259. /*-----------------------------------------------------------------------------------*/
  260. add_action( 'init', 'gamepress_register_reviews_post_type' );
  261.  
  262. function gamepress_register_reviews_post_type() {
  263. // Game reviews
  264. register_post_type( 'gamepress_reviews',
  265. array(
  266. 'labels' => array(
  267. 'name' => __( 'Game Reviews', 'gamepress' ),
  268. 'singular_name' => __( 'Game Review', 'gamepress' ),
  269. 'add_new' => __('Add new review', 'gamepress'),
  270. 'edit_item' => __('Edit review', 'gamepress'),
  271. 'new_item' => __('New review', 'gamepress'),
  272. 'view_item' => __('View review', 'gamepress'),
  273. 'search_items' => __('Search reviews', 'gamepress'),
  274. 'not_found' => __('No reviews found', 'gamepress'),
  275. 'not_found_in_trash' => __('No reviews found in Trash', 'gamepress'),
  276. ),
  277. 'public' => true,
  278. 'publicly_queryable' => true,
  279. 'show_ui' => true,
  280. 'show_in_nav_menus' => true,
  281. 'exclude_from_search' => false,
  282. 'hierarchical' => false,
  283. 'menu_position' => 20,
  284. 'has_archive' => true,
  285. 'rewrite' => array('slug' => 'game-review'),
  286. 'supports' => array('title','editor','author','thumbnail','excerpt','trackbacks','comments','revisions'),
  287. 'taxonomies' => array('post_tag'),
  288. 'yarpp_support' => true
  289. )
  290. );
  291.  
  292. }
  293.  
  294. add_action( 'init', 'gamepress_register_videos_post_type' );
  295.  
  296. function gamepress_register_videos_post_type() {
  297. // Video
  298. register_post_type( 'gamepress_video',
  299. array(
  300. 'labels' => array(
  301. 'name' => __( 'Videos','gamepress' ),
  302. 'singular_name' => __( 'Video','gamepress' ),
  303. 'add_new' => __( 'Add New','gamepress' ),
  304. 'add_new_item' => __( 'Add New Video','gamepress' ),
  305. 'edit' => __( 'Edit','gamepress' ),
  306. 'edit_item' => __( 'Edit Video','gamepress' ),
  307. 'new_item' => __( 'New Video','gamepress' ),
  308. 'view' => __( 'View Video','gamepress' ),
  309. 'view_item' => __( 'View Video','gamepress' ),
  310. 'search_items' => __( 'Search Videos','gamepress' ),
  311. 'not_found' => __( 'No videos found','gamepress' ),
  312. 'not_found_in_trash' => __( 'No videos found in Trash','gamepress' ),
  313. 'parent' => __( 'Parent Video','gamepress' ),
  314. ),
  315. 'public' => true,
  316. 'publicly_queryable' => true,
  317. 'show_in_nav_menus' => true,
  318. 'show_ui' => true,
  319. 'exclude_from_search' => false,
  320. 'hierarchical' => false,
  321. 'menu_position' => 22,
  322. 'has_archive' => true,
  323. 'rewrite' => array('slug' => 'video'),
  324. 'supports' => array('title','editor','author','thumbnail','excerpt','comments'),
  325. 'taxonomies' => array('post_tag'),
  326. 'yarpp_support' => true
  327. )
  328. );
  329.  
  330. }
  331. /*-----------------------------------------------------------------------------------*/
  332. /* Register custom taxonomies
  333. /*-----------------------------------------------------------------------------------*/
  334. add_action( 'init', 'gamepress_create_review_category', 0 );
  335.  
  336. function gamepress_create_review_category()
  337. {
  338.  
  339. $labels = array(
  340. 'name' => _x( 'Review Categories', 'taxonomy general name','gamepress' ),
  341. 'singular_name' => _x( 'Review Category', 'taxonomy singular name','gamepress' ),
  342. 'search_items' => __( 'Search Review Categories','gamepress' ),
  343. 'all_items' => __( 'All Review Categories','gamepress' ),
  344. 'parent_item' => __( 'Parent Review Category','gamepress' ),
  345. 'parent_item_colon' => __( 'Parent Review Category:','gamepress' ),
  346. 'edit_item' => __( 'Edit Review Category' ,'gamepress'),
  347. 'update_item' => __( 'Update Review Category','gamepress' ),
  348. 'add_new_item' => __( 'Add New Review Category','gamepress' ),
  349. 'new_item_name' => __( 'New Review Category Name','gamepress' ),
  350. 'menu_name' => __( 'Categories','gamepress' ),
  351. );
  352.  
  353. register_taxonomy('gamepress_review_category',array('gamepress_reviews'), array(
  354. 'public' => true,
  355. 'show_in_nav_menus' => true,
  356. 'hierarchical' => true,
  357. 'labels' => $labels,
  358. 'show_ui' => true,
  359. 'query_var' => true,
  360. 'rewrite' => array( 'slug' => 'reviews', 'with_front' => false ),
  361. ));
  362.  
  363. }
  364.  
  365. add_action( 'init', 'gamepress_create_video_category', 0 );
  366.  
  367. function gamepress_create_video_category()
  368. {
  369.  
  370. $labels = array(
  371. 'name' => _x( 'Video Categories', 'taxonomy general name','gamepress' ),
  372. 'singular_name' => _x( 'Video Category', 'taxonomy singular name','gamepress' ),
  373. 'search_items' => __( 'Search Video Categories','gamepress'),
  374. 'all_items' => __( 'All Video Categories','gamepress' ),
  375. 'parent_item' => __( 'Parent Video Category','gamepress' ),
  376. 'parent_item_colon' => __( 'Parent Video Category:', 'gamepress' ),
  377. 'edit_item' => __( 'Edit Video Category','gamepress' ),
  378. 'update_item' => __( 'Update Video Category','gamepress' ),
  379. 'add_new_item' => __( 'Add New Video Category','gamepress' ),
  380. 'new_item_name' => __( 'New Video Category Name','gamepress' ),
  381. 'menu_name' => __( 'Categories','gamepress' ),
  382. );
  383.  
  384. register_taxonomy('gamepress_video_category',array('gamepress_video'), array(
  385. 'public' => true,
  386. 'show_in_nav_menus' => true,
  387. 'hierarchical' => true,
  388. 'labels' => $labels,
  389. 'show_ui' => true,
  390. 'query_var' => true,
  391. ));
  392.  
  393. }
  394.  
  395. add_filter('pre_get_posts', 'gamepress_query_post_type');
  396. function gamepress_query_post_type($query) {
  397. if(is_tag()) {
  398. $post_type = get_query_var('post_type');
  399. if($post_type)
  400. $post_type = $post_type;
  401. else
  402. $post_type = array('post','nav_menu_item', 'gamepress_reviews', 'gamepress_video');
  403. $query->set('post_type',$post_type);
  404. return $query;
  405. }
  406. }
  407.  
  408. /* Flush rewrite rules for custom post types. */
  409. add_action( 'load-themes.php', 'gamepress_flush' );
  410.  
  411. /* Flush your rewrite rules */
  412. function gamepress_flush() {
  413. global $pagenow, $wp_rewrite;
  414.  
  415. if ( 'themes.php' == $pagenow && isset( $_GET['activated'] ) )
  416. $wp_rewrite->flush_rules();
  417. }
  418.  
  419. /*-----------------------------------------------------------------------------------*/
  420. /* Function to display rating bar & box
  421. /*-----------------------------------------------------------------------------------*/
  422. function gamepress_rating($rating) {
  423.  
  424. $class = explode(".", $rating);
  425. $output = '';
  426.  
  427. if($class[0] >= '10') {
  428. $output .= '<span class="score s10">'.$rating.'</span><span class="desc">'.__('Perfect','gamepress').'</span>';
  429. } elseif($class[0] >= '9') {
  430. $output .= '<span class="score s9">'.$rating.'</span><span class="desc">'.__('Amazing','gamepress').'</span>';
  431. } elseif($class[0] >= '8') {
  432. $output .= '<span class="score s8">'.$rating.'</span><span class="desc">'.__('Great','gamepress').'</span>';
  433. } elseif($class[0] >= '7') {
  434. $output .= '<span class="score s7">'.$rating.'</span><span class="desc">'.__('Good','gamepress').'</span>';
  435. } elseif($class[0] >= '6') {
  436. $output .= '<span class="score s6">'.$rating.'</span><span class="desc">'.__('Fair','gamepress').'</span>';
  437. } elseif($class[0] >= '5') {
  438. $output .= '<span class="score s5">'.$rating.'</span><span class="desc">'.__('Mediocre','gamepress').'</span>';
  439. } elseif($class[0] >= '4') {
  440. $output .= '<span class="score s4">'.$rating.'</span><span class="desc">'.__('Poor','gamepress').'</span>';
  441. } elseif($class[0] >= '3') {
  442. $output .= '<span class="score s3">'.$rating.'</span><span class="desc">'.__('Bad','gamepress').'</span>';
  443. } elseif($class[0] >= '2') {
  444. $output .= '<span class="score s2">'.$rating.'</span><span class="desc">'.__('Terrible','gamepress').'</span>';
  445. } else {
  446. $output .= '<span class="score s1">'.$rating.'</span><span class="desc">'.__('Abysmal','gamepress').'</span>';
  447. }
  448. return $output;
  449. }
  450.  
  451. /*-----------------------------------------------------------------------------------*/
  452. /* Append post content pagination right after post content
  453. /*-----------------------------------------------------------------------------------*/
  454. function gamepress_post_pagination($content) {
  455.  
  456. if ( is_single() ) {
  457. $content .= wp_link_pages( array( 'before' => '<div class="page-link">'. __( 'Pages:', 'gamepress' ), 'after' => '</div>', 'echo' => 0 ) );
  458. }
  459. return $content;
  460. }
  461. add_filter('the_content','gamepress_post_pagination', 10);
  462.  
  463. add_filter('use_default_gallery_style', '__return_false' ); // Remove inline style of WordPress Gallery Shortcode
  464.  
  465. /*-----------------------------------------------------------------------------------*/
  466. /* Append rating to the end of the post
  467. /*-----------------------------------------------------------------------------------*/
  468. function gamepress_display_rating($content) {
  469.  
  470. global $post;
  471.  
  472. if($post->post_type == 'gamepress_reviews' && get_post_meta($post->ID, "gamepress_score", true)) {
  473.  
  474. $content .= '<h2>'. __('The Verdict','gamepress') .'</h2>';
  475. $content .= '<div class="rating">';
  476. $content .= '<div class="rating-box">';
  477. $content .= gamepress_rating(get_post_meta($post->ID, "gamepress_score", true));
  478. $content .= '</div>';
  479.  
  480. if(get_post_meta($post->ID, "gamepress_the_good", true)) {
  481. $content .= '<p><span class="label">'. __( 'The Good: ', 'gamepress' ).'</span>'. get_post_meta($post->ID, "gamepress_the_good", true).'</p>';
  482. }
  483. if(get_post_meta($post->ID, "gamepress_the_bad", true)) {
  484. $content .= '<p><span class="label">'. __( 'The Bad: ', 'gamepress' ).'</span>'. get_post_meta($post->ID, "gamepress_the_bad", true) .'</p>';
  485. }
  486. $content .= '</div>';
  487.  
  488. }
  489.  
  490. return $content;
  491. }
  492. add_filter('the_content','gamepress_display_rating');
  493.  
  494. /*-----------------------------------------------------------------------------------*/
  495. /* Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
  496. /*-----------------------------------------------------------------------------------*/
  497. function gamepress_page_menu_args( $args ) {
  498. $args['show_home'] = true;
  499. return $args;
  500. }
  501. add_filter( 'wp_page_menu_args', 'gamepress_page_menu_args' );
  502.  
  503. /*-----------------------------------------------------------------------------------*/
  504. /* Disable Auto Formating on Posts
  505. /*-----------------------------------------------------------------------------------*/
  506. function gamepress_formating($content) {
  507. $new_content = '';
  508. $pattern_full = '{(\[raw\].*?\[/raw\])}is';
  509. $pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
  510. $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
  511.  
  512. foreach ($pieces as $piece) {
  513. if (preg_match($pattern_contents, $piece, $matches)) {
  514. $new_content .= $matches[1];
  515. } else {
  516. $new_content .= wptexturize(wpautop($piece));
  517. }
  518. }
  519.  
  520. return $new_content;
  521. }
  522. add_filter('the_content', 'gamepress_formating', 99);
  523.  
  524. /*-----------------------------------------------------------------------------------*/
  525. /* Fix wp-caption width
  526. /*-----------------------------------------------------------------------------------*/
  527.  
  528. add_filter( 'img_caption_shortcode', 'gamepress_caption', 10, 3 );
  529.  
  530. function gamepress_caption( $output, $attr, $content ) {
  531.  
  532. /* We're not worried abut captions in feeds, so just return the output here. */
  533. if ( is_feed() )
  534. return $output;
  535.  
  536. /* Set up the default arguments. */
  537. $defaults = array(
  538. 'id' => '',
  539. 'align' => 'alignnone',
  540. 'width' => '',
  541. 'caption' => ''
  542. );
  543.  
  544. /* Merge the defaults with user input. */
  545. $attr = shortcode_atts( $defaults, $attr );
  546.  
  547. /* If the width is less than 1 or there is no caption, return the content wrapped between the [caption]< tags. */
  548. if ( 1 > $attr['width'] || empty( $attr['caption'] ) )
  549. return $content;
  550.  
  551. /* Set up the attributes for the caption <div>. */
  552. $attributes = ( !empty( $attr['id'] ) ? ' id="' . esc_attr( $attr['id'] ) . '"' : '' );
  553. $attributes .= ' class="wp-caption ' . esc_attr( $attr['align'] ) . '"';
  554. $attributes .= ' style="width: ' . esc_attr( $attr['width'] ) . 'px"';
  555.  
  556. /* Open the caption <div>. */
  557. $output = '<div' . $attributes .'>';
  558.  
  559. /* Allow shortcodes for the content the caption was created for. */
  560. $output .= do_shortcode( $content );
  561.  
  562. /* Append the caption text. */
  563. $output .= '<p class="wp-caption-text">' . $attr['caption'] . '</p>';
  564.  
  565. /* Close the caption </div>. */
  566. $output .= '</div>';
  567.  
  568. /* Return the formatted, clean caption. */
  569. return $output;
  570. }
  571.  
  572.  
  573. /*-----------------------------------------------------------------------------------*/
  574. /* Register widgetized area and update sidebar with default widgets
  575. /*-----------------------------------------------------------------------------------*/
  576. if ( function_exists('register_sidebar') ) {
  577. register_sidebar(array(
  578. 'name' => 'Main Sidebar',
  579. 'before_widget' => '<div class="widget">',
  580. 'after_widget' => '</div>',
  581. 'before_title' => '<h3 class="widget-title">',
  582. 'after_title' => '</h3>',
  583. ));
  584. register_sidebar(array(
  585. 'name' => 'Footer 1',
  586. 'before_widget' => '<div class="widget">',
  587. 'after_widget' => '</div>',
  588. 'before_title' => '<h3 class="widget-title">',
  589. 'after_title' => '</h3>',
  590. ));
  591. register_sidebar(array(
  592. 'name' => 'Footer 2',
  593. 'before_widget' => '<div class="widget">',
  594. 'after_widget' => '</div>',
  595. 'before_title' => '<h3 class="widget-title">',
  596. 'after_title' => '</h3>',
  597. ));
  598. register_sidebar(array(
  599. 'name' => 'Footer 3',
  600. 'before_widget' => '<div class="widget">',
  601. 'after_widget' => '</div>',
  602. 'before_title' => '<h3 class="widget-title">',
  603. 'after_title' => '</h3>',
  604. ));
  605. }
  606. // Include functions
  607. include(get_template_directory() . "/admin/widgets/recent-posts-widget.php");
  608. include(get_template_directory() . "/admin/widgets/social-widget.php");
  609.  
  610. /*-----------------------------------------------------------------------------------*/
  611. /* Comments
  612. /*-----------------------------------------------------------------------------------*/
  613.  
  614. if ( ! function_exists( 'gamepress_comment' ) ) :
  615.  
  616. function gamepress_comment( $comment, $args, $depth ) {
  617. $GLOBALS['comment'] = $comment;
  618. ?>
  619. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  620. <article id="comment-<?php comment_ID(); ?>" class="the-comment">
  621.  
  622. <?php echo get_avatar( $comment, 60 ); ?>
  623.  
  624. <?php if ( $comment->comment_approved == '0' ) : ?>
  625. <em><?php _e( 'Your comment is awaiting moderation.', 'gamepress' ); ?></em>
  626. <br />
  627. <?php endif; ?>
  628. <div class="comment-meta">
  629. <?php echo get_comment_author_link() ?>
  630. <span class="comment-time">
  631. <small>
  632. <?php comment_time( 'F j, Y g:i a' ); ?></small>&nbsp;<small>
  633. <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  634. </small>
  635. </span>
  636. <div class="comment-text"><p><?php comment_text(); ?></p></div>
  637. </div>
  638.  
  639. </article>
  640.  
  641. <?php
  642. }
  643. endif;
  644.  
  645. /*-----------------------------------------------------------------------------------*/
  646. /* Shortcodes
  647. /*-----------------------------------------------------------------------------------*/
  648. // Button
  649. add_shortcode('button', 'gamepress_shortcode_button');
  650. function gamepress_shortcode_button($atts, $content = null) {
  651. $atts = shortcode_atts(
  652. array(
  653. 'color' => 'red',
  654. 'url' => '#',
  655. 'size' => '',
  656. ), $atts);
  657.  
  658. if($atts['size'] == 'default'){
  659. $atts['size'] = '';
  660. }
  661.  
  662. return '<a class="button ' . $atts['color'] .' '. $atts['size'] .'" href="' . $atts['url'] . '" >' .do_shortcode($content). '</a>';
  663. }
  664.  
  665. // Unorderd List
  666. add_shortcode('list', 'gamepress_shortcode_list');
  667. function gamepress_shortcode_list( $atts, $content = null ) {
  668. $atts = shortcode_atts(
  669. array(
  670. 'type' => 'arrow',
  671. ), $atts);
  672.  
  673. $content = str_replace('<ul>', '<ul class="list ' . $atts['type'] . '">', do_shortcode($content));
  674. $content = str_replace('<li>', '<li>', do_shortcode($content));
  675.  
  676. return $content;
  677.  
  678. }
  679.  
  680. // Tabs
  681. add_shortcode('tabs', 'gamepress_shortcode_tabs');
  682. function gamepress_shortcode_tabs( $atts, $content = null ) {
  683. extract(shortcode_atts(array(
  684. ), $atts));
  685.  
  686. $out = '';
  687. $out .= '[raw]<div class="tabs-wrapper">[/raw]';
  688.  
  689. $out .= '<ul class="tabs tabs-nav">';
  690. foreach ($atts as $tab) {
  691. $out .= '<li><a href="#">' .$tab. '</a></li>';
  692. }
  693. $out .= '</ul>';
  694.  
  695. $out .= do_shortcode($content) .'[raw]</div>[/raw]';
  696.  
  697. return $out;
  698. }
  699.  
  700. add_shortcode('tab', 'gamepress_shortcode_tab');
  701. function gamepress_shortcode_tab( $atts, $content = null ) {
  702. extract(shortcode_atts(array(
  703. ), $atts));
  704.  
  705. $out = '';
  706. $out .= '[raw]<div class="pane">[/raw]' . do_shortcode($content) .'</div>';
  707.  
  708. return $out;
  709. }
  710.  
  711. // Accordion
  712. add_shortcode('accordion', 'gamepress_shortcode_accordion');
  713. function gamepress_shortcode_accordion( $atts, $content = null ) {
  714. extract(shortcode_atts(array(
  715. ), $atts));
  716.  
  717. $out = '';
  718. $out .= '<div class="accordion">'.do_shortcode($content).'</div>';
  719.  
  720. return $out;
  721. }
  722. add_shortcode('pane', 'gamepress_shortcode_pane');
  723. function gamepress_shortcode_pane( $atts, $content = null ) {
  724. extract(shortcode_atts(array(
  725. 'title' => '',
  726. ), $atts));
  727.  
  728. $out = '';
  729. foreach ($atts as $pane) {
  730. $out .= '<h4 class="accordion-header"><a href="#">' . $pane .'</a></h4>';
  731. $out .= '<div class="pane">'. do_shortcode($content) .'</div>';
  732. }
  733. return $out;
  734. }
  735.  
  736. /*-----------------------------------------------------------------------------------*/
  737. /* Add buttons to tinyMCE
  738. /*-----------------------------------------------------------------------------------*/
  739. add_action('init', 'gamepress_add_button');
  740.  
  741. function gamepress_add_button() {
  742. if ( current_user_can('edit_posts') && current_user_can('edit_pages') )
  743. {
  744. add_filter('mce_external_plugins', 'gamepress_add_plugin');
  745. add_filter('mce_buttons', 'gamepress_register_button');
  746. }
  747. }
  748.  
  749. function gamepress_register_button($buttons) {
  750. array_push($buttons, "button", "list", "tabs", "accordion");
  751. return $buttons;
  752. }
  753.  
  754. function gamepress_add_plugin($plugin_array) {
  755. $plugin_array['button'] = get_template_directory_uri().'/admin/tinymce/customcodes.js';
  756. $plugin_array['list'] = get_template_directory_uri().'/admin/tinymce/customcodes.js';
  757. $plugin_array['tabs'] = get_template_directory_uri().'/admin/tinymce/customcodes.js';
  758. $plugin_array['accordion'] = get_template_directory_uri().'/admin/tinymce/customcodes.js';
  759. return $plugin_array;
  760. }
  761.  
  762.  
  763. /*-----------------------------------------------------------------------------------*/
  764. /* Meta-boxes setup
  765. /*-----------------------------------------------------------------------------------*/
  766. // Re-define meta box path and URL
  767. define( 'RWMB_DIR', trailingslashit( get_template_directory() . '/meta-box' ) );
  768. define( 'RWMB_URL', trailingslashit( get_template_directory_uri() . '/meta-box' ) );
  769.  
  770. // Include the meta box script
  771. require_once RWMB_DIR . 'meta-box.php';
  772.  
  773. // Include the meta box definition (the file where you define meta boxes, see `demo/demo.php`)
  774. include 'meta-box/metabox-def.php';
  775.  
  776. /*-----------------------------------------------------------------------------------*/
  777. /* Options framework
  778. /*-----------------------------------------------------------------------------------*/
  779.  
  780. if ( !function_exists( 'optionsframework_init' ) ) {
  781. define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/admin/options-framework/' );
  782. require_once dirname( __FILE__ ) . '/admin/options-framework/options-framework.php';
  783. }
  784.  
  785. /*
  786. * This is an example of how to add custom scripts to the options panel.
  787. * This one shows/hides the an option when a checkbox is clicked.
  788. */
  789.  
  790. add_action('optionsframework_custom_scripts', 'optionsframework_custom_scripts');
  791.  
  792. function optionsframework_custom_scripts() { ?>
  793.  
  794. <script type="text/javascript">
  795. jQuery(document).ready(function() {
  796.  
  797. jQuery('#example_showhidden').click(function() {
  798. jQuery('#section-example_text_hidden').fadeToggle(400);
  799. });
  800.  
  801. if (jQuery('#example_showhidden:checked').val() !== undefined) {
  802. jQuery('#section-example_text_hidden').show();
  803. }
  804.  
  805. });
  806. </script>
  807.  
  808. <?php
  809. }
  810.  
  811. add_action('admin_init','optionscheck_change_santiziation', 100);
  812.  
  813. function optionscheck_change_santiziation() {
  814. remove_filter( 'of_sanitize_textarea', 'of_sanitize_textarea' );
  815. add_filter( 'of_sanitize_textarea', 'of_sanitize_textarea_custom' );
  816. }
  817.  
  818. function of_sanitize_textarea_custom($input) {
  819. global $allowedtags;
  820. $custom_allowedtags["embed"] = array(
  821. "src" => array(),
  822. "type" => array(),
  823. "allowfullscreen" => array(),
  824. "allowscriptaccess" => array(),
  825. "height" => array(),
  826. "width" => array()
  827. );
  828. $custom_allowedtags["script"] = array(
  829. "type" =>array(),
  830. "src" => array()
  831. );
  832. $custom_allowedtags["img"] = array(
  833. "alt" =>array(),
  834. "src" => array()
  835. );
  836. $custom_allowedtags["a"] = array(
  837. "href" =>array(),
  838. "title" => array()
  839. );
  840. $of_custom_allowedtags = array_merge($custom_allowedtags, $allowedtags);
  841. $output = wp_kses( $input, $custom_allowedtags);
  842. return $output;
  843. }
  844.  
  845.  
  846. // Theme Options sidebar
  847. add_action( 'optionsframework_after','gamepress_options_display_sidebar' );
  848.  
  849. function gamepress_options_display_sidebar() { ?>
  850. <div id="optionsframework-sidebar">
  851. <div class="metabox-holder">
  852. <div class="postbox">
  853. <h3><?php _e('Support','gamepress') ?></h3>
  854. <div class="inside">
  855. <p><?php _e('The best way to contact me with <b>support questions</b> and <b>bug reports</b> is via the','gamepress') ?> <a href="http://wordpress.org/support/"><?php _e('WordPress support forums','gamepress') ?></a>.</p>
  856. <p><?php _e('If you like this theme, I\'d appreciate any of the following:','gamepress') ?></p>
  857. <ul>
  858. <li><a href="http://wordpress.org/extend/themes/gamepress"><?php _e('Rate GamePress at WordPress.org','gamepress') ?></a></li>
  859. <li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8LRJAUNAPKJ9S"><?php _e('Donate a token of your appreciation','gamepress') ?></a></li>
  860. </ul>
  861. </div>
  862. </div>
  863. </div>
  864. </div>
  865. <?php }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement