PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.5.4
JetFormBuilder — Dynamic Blocks Form Builder v3.6.5.4
3.6.6.1 3.6.6 3.6.5.4 3.6.5.3 3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 134 releases
jetformbuilder / includes / admin / pages / stable-pages-manager.php

stable-pages-manager.php in JetFormBuilder — Dynamic Blocks Form Builder 3.6.5.4, at includes/admin/pages/stable-pages-manager.php

123 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 namespace Jet_Form_Builder\Admin\Pages;
5
6 use Jet_Form_Builder\Admin\Pages\Settings\Settings_Page;
7 use Jet_Form_Builder\Classes\Http\Utm_Url;
8 use JFB_Components\Repository\Repository_Pattern_Trait;
9 use Jet_Form_Builder\Exceptions\Repository_Exception;
10
11 // If this file is called directly, abort.
12 if ( ! defined( 'WPINC' ) ) {
13 die;
14 }
15
16 class Stable_Pages_Manager {
17
18 use Repository_Pattern_Trait;
19
20 public function __construct() {
21 add_action( 'admin_menu', array( $this, 'add_pages' ) );
22 add_action( 'admin_menu', array( $this, 'add_static_pages' ) );
23 add_action( 'admin_head', array( $this, 'modify_item_styles' ) );
24 }
25
26 /**
27 * Register admin pages
28 */
29 public function rep_instances(): array {
30 return apply_filters(
31 'jet-form-builder/admin/pages',
32 array(
33 new Settings_Page(),
34 new Addons_Page(),
35 )
36 );
37 }
38
39 /**
40 * @param Base_Page $item
41 *
42 * @throws Repository_Exception
43 */
44 public function rep_before_install_item( $item ) {
45 if ( ! $item->is_active() ) {
46 $this->_rep_abort_this();
47 }
48 }
49
50 protected function get_parent_slug(): string {
51 return 'edit.php?post_type=' . jet_form_builder()->post_type->slug();
52 }
53
54 /**
55 * Register appointments
56 */
57 public function add_pages() {
58 $parent = $this->get_parent_slug();
59
60 /** @var Base_Page $page */
61 foreach ( $this->rep_get_items() as $page ) {
62 $submenu_data = apply_filters(
63 'jet-form-builder/admin/form-records-access-capability',
64 array(
65 'parent' => $parent,
66 'title' => $page->title(),
67 'menu_title' => $page->title(),
68 'capability' => 'manage_options',
69 'slug' => $page->slug(),
70 'callback' => array( $page, 'render' ),
71 ),
72 $page
73 );
74
75 add_submenu_page(
76 $submenu_data['parent'],
77 $submenu_data['title'],
78 $submenu_data['menu_title'],
79 $submenu_data['capability'],
80 $submenu_data['slug'],
81 $submenu_data['callback']
82 );
83 }
84 }
85
86 public function add_static_pages() {
87 $parent = $this->get_parent_slug();
88 $pages = array();
89
90 if ( ! jet_form_builder()->addons_manager->is_active() ) {
91 $utm = new Utm_Url( 'plugin' );
92 $utm->set_medium( 'jfb-menu' );
93 $utm->set_campaign( 'go-pro-button' );
94 $utm->set_content( $utm->get_license_and_theme() );
95
96 $pages[] = array(
97 'title' => apply_filters(
98 'jet-form-builder/admin/pages/go-pro-title',
99 __( 'Go PRO', 'jet-form-builder' )
100 ),
101 'capability' => 'manage_options',
102 'slug' => $utm->add_query( JET_FORM_BUILDER_SITE . '/pricing/' ),
103 );
104 }
105
106 foreach ( $pages as $page ) {
107 add_submenu_page(
108 $parent,
109 $page['title'],
110 $page['title'],
111 $page['capability'],
112 $page['slug']
113 );
114 }
115 }
116
117 public function modify_item_styles() {
118 echo '<style type="text/css">
119 #adminmenu #menu-posts-jet-form-builder a[href*="https://jetformbuilder.com"] { color: #F5C546; }
120 </style>';
121 }
122 }
123