Addons.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php if ( ! defined( 'ABSPATH' ) ) exit;
  2. final class NF_Admin_Menus_Addons extends NF_Abstracts_Submenu
  3. {
  4. public $parent_slug = 'ninja-forms';
  5. public $menu_slug = 'ninja-forms#apps';
  6. public $priority = 13;
  7. public function __construct()
  8. {
  9. $disable_marketing = false;
  10. if ( ! apply_filters( 'ninja_forms_disable_marketing', $disable_marketing ) ) {
  11. parent::__construct();
  12. }
  13. }
  14. public function get_page_title()
  15. {
  16. return __( 'Add-Ons', 'ninja-forms' );
  17. }
  18. public function get_capability()
  19. {
  20. return apply_filters( 'ninja_forms_admin_extend_capabilities', $this->capability );
  21. }
  22. public function display()
  23. {
  24. //wp_enqueue_style( 'nf-admin-addons', Ninja_Forms::$url . 'assets/css/admin-addons.css' );
  25. // $items = wp_remote_get( 'https://ninjaforms.com/?extend_feed=jlhrbgf89734go7387o4g3h' );
  26. // $items = wp_remote_retrieve_body( $items );
  27. $items = file_get_contents( Ninja_Forms::$dir . '/deprecated/addons-feed.json' );
  28. $items = json_decode( $items, true );
  29. //shuffle( $items );
  30. $notices = array();
  31. foreach ($items as $item) {
  32. $plugin_data = array();
  33. if( !empty( $item['plugin'] ) && file_exists( WP_PLUGIN_DIR.'/'.$item['plugin'] ) ){
  34. $plugin_data = get_plugin_data( WP_PLUGIN_DIR.'/'.$item['plugin'], false, true );
  35. }
  36. $version = isset ( $plugin_data['Version'] ) ? $plugin_data['Version'] : '';
  37. if ( ! empty ( $version ) && $version < $item['version'] ) {
  38. $notices[] = array(
  39. 'title' => $item[ 'title' ],
  40. 'old_version' => $version,
  41. 'new_version' => $item[ 'version' ]
  42. );
  43. }
  44. }
  45. Ninja_Forms::template( 'admin-menu-addons.html.php', compact( 'items', 'notices' ) );
  46. }
  47. } // End Class NF_Admin_Addons