Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. <?php
  2. // in function.php of your wp theme
  3. function test_shortcode_func( $atts ){
  4. $a = shortcode_atts( array(
  5. 'value' => 0,
  6. ), $atts );
  7.  
  8. $num = (int) $a['value'];
  9.  
  10. switch ($num) {
  11. case $num % 7 === 0:
  12. if ($num % 11 === 0) {
  13. return "[LongRead]";
  14. }else{
  15. return "[Long]";
  16. }
  17. break;
  18. case $num % 11 === 0:
  19. if ($num % 7 === 0) {
  20. return "[Long]";
  21. }else{
  22. return "[Read]";
  23. }
  24. break;
  25. default:
  26. return "[{$num}]";
  27. }
  28.  
  29. }
  30. add_shortcode( 'test_shortcode', 'test_shortcode_func' );
  31.  
  32. /*
  33. [test_shortcode value="5"]
  34. [test_shortcode value="7"]
  35. [test_shortcode value="11"]
  36. [test_shortcode value="77"]
  37. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement