PageRenderTime 44ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/web/app/themes/vegashero-theme/assets/functions/shortcodes.php

https://bitbucket.org/mikestivala/talentcasino
PHP | 438 lines | 392 code | 21 blank | 25 comment | 17 complexity | 5abd40bfe31d631433566ed9beee676d MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. function buffer_include_html($path, $atts, $content){
  3. ob_start();
  4. echo $path;
  5. $result = ob_get_contents();
  6. ob_end_clean();
  7. return $result;
  8. }
  9. if( ! class_exists('acf') ) {
  10. function remove_menus(){
  11. remove_menu_page( 'edit.php?post_type=acf' ); //Remove Post Type ACF from admin menus
  12. }
  13. add_action( 'admin_init', 'remove_menus' );
  14. }
  15. function review($atts,$content = null){
  16. return buffer_include_html('<ul class="rating">' . do_shortcode($content) . '</ul>', $atts, $content);
  17. }
  18. add_shortcode( 'review', 'review');
  19. function rating($atts, $content = null) {
  20. $atts = shortcode_atts(array(
  21. 'display' => ''
  22. ), $atts);
  23. return buffer_include_html('<li class="' . $atts['display'] . '"></li>', $atts, $content);
  24. }
  25. add_shortcode( 'rating', 'rating');
  26. /*--------------- CUSTOM FIELDS --------------------- */
  27. include_once get_template_directory() . '/advanced-custom-fields/acf.php';
  28. // define( 'ACF_LITE', true );
  29. if(function_exists("register_field_group")){
  30. register_field_group(array (
  31. 'id' => 'acf_game-page-options',
  32. 'title' => 'Game page options',
  33. 'fields' => array (
  34. array (
  35. 'key' => 'field_play_for_real_url',
  36. 'label' => 'Visit Casino button',
  37. 'name' => 'play-real-button',
  38. 'type' => 'text',
  39. 'instructions' => 'Add in your affiliate link (optional), this will be your "Visit Casino" button',
  40. 'default_value' => 'Visit Casino',
  41. 'placeholder' => 'Enter your full url here',
  42. 'prepend' => 'Enter URL',
  43. 'append' => '',
  44. 'formatting' => 'html',
  45. 'maxlength' => '',
  46. ),
  47. array (
  48. 'key' => 'field_iframe_url',
  49. 'label' => 'Add iFrame to post',
  50. 'name' => 'iframe-code',
  51. 'type' => 'text',
  52. 'instructions' => 'Add in your iframe code to your game page',
  53. 'default_value' => '',
  54. 'placeholder' => 'Enter the full iframe code here eg: <iframe src="">',
  55. 'prepend' => 'Enter code',
  56. 'append' => '',
  57. 'formatting' => 'html',
  58. 'maxlength' => '',
  59. ),
  60. ),
  61. 'location' => array (
  62. array (
  63. array (
  64. 'param' => 'post_type',
  65. 'operator' => '==',
  66. 'value' => 'game_type',
  67. 'order_no' => 0,
  68. 'group_no' => 0,
  69. ),
  70. ),
  71. ),
  72. 'options' => array (
  73. 'position' => 'normal',
  74. 'layout' => 'no_box',
  75. 'hide_on_screen' => array (
  76. 0 => 'excerpt',
  77. 1 => 'custom_fields',
  78. 2 => 'discussion',
  79. 3 => 'comments',
  80. 4 => 'revisions',
  81. 5 => 'author',
  82. 6 => 'format',
  83. 7 => 'send-trackbacks',
  84. ),
  85. ),
  86. 'menu_order' => 0,
  87. ));
  88. }
  89. if(function_exists("register_field_group"))
  90. {
  91. register_field_group(array (
  92. 'id' => 'acf_turn-off-excerpt',
  93. 'title' => 'Turn off excerpt',
  94. 'fields' => array (
  95. array (
  96. 'key' => 'field_58833a5854965',
  97. 'label' => 'Excerpt Checkbox',
  98. 'name' => 'excerpt_checkbox',
  99. 'type' => 'checkbox',
  100. 'instructions' => 'Turn off sidebar excerpt',
  101. 'choices' => array (
  102. 'off' => 'Off',
  103. ),
  104. 'default_value' => '',
  105. 'layout' => 'horizontal',
  106. ),
  107. ),
  108. 'location' => array (
  109. array (
  110. array (
  111. 'param' => 'post_type',
  112. 'operator' => '==',
  113. 'value' => 'game_type',
  114. 'order_no' => 0,
  115. 'group_no' => 0,
  116. ),
  117. ),
  118. ),
  119. 'options' => array (
  120. 'position' => 'normal',
  121. 'layout' => 'default',
  122. 'hide_on_screen' => array (
  123. ),
  124. ),
  125. 'menu_order' => 0,
  126. ));
  127. }
  128. if(function_exists("register_field_group")){
  129. register_field_group(array (
  130. 'id' => 'acf_casino-page-options',
  131. 'title' => 'Casino page options',
  132. 'fields' => array (
  133. array (
  134. 'key' => 'field_affiliate_url',
  135. 'label' => 'Affiliate URL',
  136. 'name' => 'affiliate-url',
  137. 'type' => 'text',
  138. 'instructions' => 'Add in your affiliate link (optional), this will be your "Visit Casino" button',
  139. 'default_value' => '',
  140. 'placeholder' => 'Enter your full url here',
  141. 'prepend' => 'Enter URL',
  142. 'append' => '',
  143. 'formatting' => 'html',
  144. 'maxlength' => '',
  145. ),
  146. array (
  147. 'key' => 'field_bonus_offer',
  148. 'label' => 'Bonus Offered',
  149. 'name' => 'bonus-offer',
  150. 'type' => 'text',
  151. 'instructions' => 'Add in the bonus offer for the Casino',
  152. 'default_value' => '',
  153. 'placeholder' => 'Enter the bonus here',
  154. 'prepend' => 'Enter bonus',
  155. 'append' => '',
  156. 'formatting' => 'html',
  157. 'maxlength' => '',
  158. ),
  159. array (
  160. 'key' => 'field_title_banner_strip',
  161. 'label' => 'Alternate H2 Title in Banner Strip',
  162. 'name' => 'title-banner-strip',
  163. 'type' => 'text',
  164. 'instructions' => 'Customize the top strip text (by default it will be the same as the post title)',
  165. 'default_value' => '',
  166. 'placeholder' => 'Enter alternate title here',
  167. 'prepend' => 'Enter title',
  168. 'append' => '',
  169. 'formatting' => 'html',
  170. 'maxlength' => '',
  171. ),
  172. ),
  173. 'location' => array (
  174. array (
  175. array (
  176. 'param' => 'post_type',
  177. 'operator' => '==',
  178. 'value' => 'casino_type',
  179. 'order_no' => 0,
  180. 'group_no' => 0,
  181. ),
  182. ),
  183. ),
  184. 'options' => array (
  185. 'position' => 'normal',
  186. 'layout' => 'default',
  187. 'hide_on_screen' => array (
  188. //0 => 'excerpt',
  189. 1 => 'custom_fields',
  190. //2 => 'discussion',
  191. //3 => 'comments',
  192. //4 => 'revisions',
  193. //5 => 'author',
  194. 6 => 'format',
  195. 7 => 'send-trackbacks',
  196. ),
  197. ),
  198. 'menu_order' => 0,
  199. ));
  200. }
  201. if(function_exists("register_field_group")){
  202. register_field_group(array (
  203. 'id' => 'acf_vhgame-page-options',
  204. 'title' => 'Game page options',
  205. 'fields' => array (
  206. array (
  207. 'key' => 'field_title_banner_strip',
  208. 'label' => 'Alternate H2 Title in Banner Strip',
  209. 'name' => 'title-banner-strip',
  210. 'type' => 'text',
  211. 'instructions' => 'Customize the top strip text (by default it will be the same as the post title)',
  212. 'default_value' => '',
  213. 'placeholder' => 'Enter alternate title here',
  214. 'prepend' => 'Enter title',
  215. 'append' => '',
  216. 'formatting' => 'html',
  217. 'maxlength' => '',
  218. ),
  219. ),
  220. 'location' => array (
  221. array (
  222. array (
  223. 'param' => 'post_type',
  224. 'operator' => '==',
  225. 'value' => 'vegashero_games',
  226. 'order_no' => 0,
  227. 'group_no' => 0,
  228. ),
  229. ),
  230. ),
  231. 'options' => array (
  232. 'position' => 'normal',
  233. 'layout' => 'default',
  234. 'hide_on_screen' => array (
  235. //0 => 'excerpt',
  236. //1 => 'custom_fields',
  237. //2 => 'discussion',
  238. //3 => 'comments',
  239. //4 => 'revisions',
  240. //5 => 'author',
  241. 6 => 'format',
  242. 7 => 'send-trackbacks',
  243. ),
  244. ),
  245. 'menu_order' => 0,
  246. ));
  247. }
  248. if(function_exists("register_field_group")){
  249. register_field_group(array (
  250. 'id' => 'acf_default-page-options',
  251. 'title' => 'Page options',
  252. 'fields' => array (
  253. array (
  254. 'key' => 'field_title_banner_strip',
  255. 'label' => 'Alternate H2 Title in Banner Strip',
  256. 'name' => 'title-banner-strip',
  257. 'type' => 'text',
  258. 'instructions' => 'Customize the top strip text (by default it will be the same as the post title)',
  259. 'default_value' => '',
  260. 'placeholder' => 'Enter alternate title here',
  261. 'prepend' => 'Enter title',
  262. 'append' => '',
  263. 'formatting' => 'html',
  264. 'maxlength' => '',
  265. ),
  266. ),
  267. 'location' => array (
  268. array (
  269. array (
  270. 'param' => 'post_type',
  271. 'operator' => '==',
  272. 'value' => 'page',
  273. 'order_no' => 0,
  274. 'group_no' => 0,
  275. ),
  276. ),
  277. ),
  278. 'options' => array (
  279. 'position' => 'normal',
  280. 'layout' => 'default',
  281. 'hide_on_screen' => array (
  282. //0 => 'excerpt',
  283. 1 => 'custom_fields',
  284. 2 => 'discussion',
  285. 3 => 'comments',
  286. //4 => 'revisions',
  287. //5 => 'author',
  288. 6 => 'format',
  289. 7 => 'send-trackbacks',
  290. ),
  291. ),
  292. 'menu_order' => 0,
  293. ));
  294. }
  295. if(function_exists("register_field_group")){
  296. register_field_group(array (
  297. 'id' => 'acf_post-page-options',
  298. 'title' => 'Post options',
  299. 'fields' => array (
  300. array (
  301. 'key' => 'field_title_banner_strip',
  302. 'label' => 'Alternate H2 Title in Banner Strip',
  303. 'name' => 'title-banner-strip',
  304. 'type' => 'text',
  305. 'instructions' => 'Customize the top strip text (by default it will be the same as the post title)',
  306. 'default_value' => '',
  307. 'placeholder' => 'Enter alternate title here',
  308. 'prepend' => 'Enter title',
  309. 'append' => '',
  310. 'formatting' => 'html',
  311. 'maxlength' => '',
  312. ),
  313. ),
  314. 'location' => array (
  315. array (
  316. array (
  317. 'param' => 'post_type',
  318. 'operator' => '==',
  319. 'value' => 'post',
  320. 'order_no' => 0,
  321. 'group_no' => 0,
  322. ),
  323. ),
  324. ),
  325. 'options' => array (
  326. 'position' => 'normal',
  327. 'layout' => 'default',
  328. 'hide_on_screen' => array (
  329. //0 => 'excerpt',
  330. 1 => 'custom_fields',
  331. //2 => 'discussion',
  332. //3 => 'comments',
  333. //4 => 'revisions',
  334. //5 => 'author',
  335. 6 => 'format',
  336. 7 => 'send-trackbacks',
  337. ),
  338. ),
  339. 'menu_order' => 0,
  340. ));
  341. }
  342. // Casino cards grid shortcode
  343. function vh_casino_grid( $atts ) {
  344. $casino_posts_count = of_get_option( 'casino_posts', '6');
  345. //$casino_ratings = get_post_meta( get_the_ID(), 'wp_review_total', true );
  346. $atts = shortcode_atts( array(
  347. 'postcount' => $casino_posts_count,
  348. 'category' => '',
  349. //'pagination' => '',
  350. 'orderby' => 'date',
  351. 'order' => 'DESC'
  352. ), $atts, 'vh-casino-grid' );
  353. ob_start();
  354. $args1 = array(
  355. 'post_type' => 'casino_type',
  356. 'posts_per_page' => $atts['postcount'],
  357. 'orderby' => $atts['orderby'],
  358. 'order' => $atts['order'],
  359. //'meta_key' => 'wp_review_total',
  360. );
  361. $args2 = array(
  362. 'post_type' => 'casino_type',
  363. 'posts_per_page' => $atts['postcount'],
  364. 'orderby' => $atts['orderby'],
  365. 'order' => $atts['order'],
  366. 'tax_query' => array(
  367. array(
  368. 'taxonomy' => 'casino_category',
  369. 'field' => 'slug',
  370. 'terms' => $atts['category'],
  371. ),
  372. ),
  373. );
  374. if ( $atts['category'] == '' ) {
  375. $query_args = $args1;
  376. } else {
  377. $query_args = $args2;
  378. }
  379. $query = new WP_Query( $query_args );
  380. if ( $query->have_posts() ) { ?>
  381. <div class="row casino-reviews-grid small-up-1 medium-up-2 large-up-3">
  382. <?php while ( $query->have_posts() ) : $query->the_post(); ?>
  383. <div class="column">
  384. <a href="<?php the_permalink(); ?>" class="card">
  385. <div class="vh-casino-title"><?php the_title(); ?></div>
  386. <div class="vh-casino-overlay">
  387. <?php
  388. if ( has_post_thumbnail() ) {
  389. the_post_thumbnail('vh-casino-thumb');
  390. } else { ?>
  391. <div class="no-image-radius">
  392. <span><?php $title = get_the_title(); echo $title[0];?></span>
  393. </div>
  394. <?php
  395. }
  396. ?>
  397. </div>
  398. <?php
  399. if (get_field('field_bonus_offer')) { ?>
  400. <div class="vh-bonus-text">
  401. <?php echo get_field('field_bonus_offer'); ?>
  402. </div>
  403. <?php
  404. }
  405. ?>
  406. <div class="grid-casino-rating"><?php if (function_exists('wp_review_show_total')) wp_review_show_total(); ?></div>
  407. <div <?php if (of_get_option('casino_posts_btn_override')) { ?>onclick="window.open('<?php echo get_field('field_affiliate_url');?>')"<?php } ?> class="button"><?php echo of_get_option( 'casino_posts_btn_text', 'Get Bonus'); ?></div>
  408. </a>
  409. </div>
  410. <?php endwhile;
  411. wp_reset_postdata(); ?>
  412. </div>
  413. <?php $myvariable = ob_get_clean();
  414. return $myvariable;
  415. }
  416. }
  417. add_shortcode( 'vh-casino-grid', 'vh_casino_grid' );