Plugins.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. // Don't load directly
  3. defined( 'WPINC' ) or die;
  4. /**
  5. * Class Pngx__Plugins
  6. *
  7. * Basedd of Modern Tribe's Tribe__Plugin Class
  8. */
  9. class Pngx__Plugins {
  10. /**
  11. * A list of Plugin Engine plugin's details in this format:
  12. *
  13. * array(
  14. * 'short_name' => Common name for the plugin, used in places such as WP Admin messages
  15. * 'class' => Main plugin class
  16. * 'thickbox_url' => Download or purchase URL for plugin from within /wp-admin/ thickbox
  17. * )
  18. */
  19. private $pngx_plugins = array(
  20. array(
  21. 'short_name' => 'Coupon Creator',
  22. 'class' => 'Cctor__Coupon__Main',
  23. 'thickbox_url' => 'plugin-install.php?tab=plugin-information&plugin=coupon-creator&TB_iframe=true',
  24. ),
  25. array(
  26. 'short_name' => 'Coupon Creator Pro',
  27. 'class' => 'Cctor__Coupon__Pro__Main',
  28. 'thickbox_url' => '//couponcreatorplugin.com/products/wordpress-coupon-creator-pro/?TB_iframe=true',
  29. ),
  30. array(
  31. 'short_name' => 'Coupon Creator Add-ons',
  32. 'class' => 'Cctor__Coupon__Addons__Main',
  33. 'thickbox_url' => '//couponcreatorplugin.com/products/wordpress-coupon-creator-pro/?TB_iframe=true',
  34. ),
  35. );
  36. /**
  37. * Searches the plugin list for key/value pair and return the full details for that plugin
  38. *
  39. * @param string $search_key The array key this value will appear in
  40. * @param string $search_val The value itself
  41. *
  42. * @return array|null
  43. */
  44. public function get_plugin_by_key( $search_key, $search_val ) {
  45. foreach ( $this->pngx_plugins as $plugin ) {
  46. if ( isset( $plugin[ $search_key ] ) && $plugin[ $search_key ] === $search_val ) {
  47. return $plugin;
  48. }
  49. }
  50. return null;
  51. }
  52. /**
  53. * Retrieves plugins details by plugin name
  54. *
  55. * @param string $name Common name for the plugin, not necessarily the lengthy name in the WP Admin Plugins list
  56. *
  57. * @return array|null
  58. */
  59. public function get_plugin_by_name( $name ) {
  60. return $this->get_plugin_by_key( 'short_name', $name );
  61. }
  62. /**
  63. * Retrieves plugins details by class name
  64. *
  65. * @param string $main_class Main/base class for this plugin
  66. *
  67. * @return array|null
  68. */
  69. public function get_plugin_by_class( $main_class ) {
  70. return $this->get_plugin_by_key( 'class', $main_class );
  71. }
  72. /**
  73. * Retrieves the entire list
  74. *
  75. * @return array
  76. */
  77. public function get_list() {
  78. /**
  79. * Gives an opportunity to filter the list of pngx plugins
  80. *
  81. * @param array Contains a list of all pngx plugins
  82. *
  83. * @since 3.0
  84. *
  85. */
  86. return apply_filters( 'pngx_plugins_get_list', $this->pngx_plugins );
  87. }
  88. }