Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. /* Global matrix for shortcodes/content for every page */
  2. $locations = array(
  3. array(
  4. 'location' => 'location 1',
  5. 'telephone' => '0121 34838383',
  6. 'email' => 'example@example.com'
  7. ),
  8. array(
  9. 'location' => 'location 2',
  10. 'telephone' => '92939393',
  11. 'email' => 'example2@hello.com'
  12. ),
  13. array(
  14. 'location' => 'location 3',
  15. 'telephone' => '343443433',
  16. 'email' => 'example3@help.com'
  17. ),
  18. array(
  19. 'location' => 'location 4',
  20. 'telephone' => '343433',
  21. 'email' => 'hello@theuk.co.uk'
  22. ),
  23. array(
  24. 'location' => 'Global Matrix Page',
  25. 'telephone' => '222 33 22',
  26. 'email' => 'wow@hey.com'
  27. )
  28. );
  29.  
  30. function telephone_shortcode() {
  31. global $locations;
  32. $title = get_the_title();
  33. $key = array_search($title, array_column($locations, 'location'));
  34. if ($key)
  35. return $locations[$key]['telephone'];
  36. else
  37. return '';
  38. }
  39. add_shortcode('telephone', 'telephone_shortcode');
  40.  
  41. function email_shortcode() {
  42. global $locations;
  43. $title = get_the_title();
  44. $key = array_search($title, array_column($locations, 'location'));
  45. if ($key)
  46. return $locations[$key]['email'];
  47. else
  48. return '';
  49. }
  50. add_shortcode('email', 'email_shortcode');
  51. /* End of Global Matrix */
  52.  
  53. telephone = [telephone]
  54.  
  55. email = [email]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement