PluginProbe
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce / 1.2.6
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce v1.2.6
1.17.9 1.17.8 1.17.7 1.17.6 1.17.5 1.17.4 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.3.0 1.3.1 1.3.11 1.3.12 1.3.13 1.3.14 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 All 143 releases
erp / includes / class-integration.php

class-integration.php in ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce 1.2.6, at includes/class-integration.php

159 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace WeDevs\ERP;
3
4 use \WeDevs\ERP\Framework\ERP_Settings_Page;
5
6 /**
7 * Integration Class
8 */
9 class Integration extends ERP_Settings_Page {
10 /**
11 * Integration instances.
12 */
13 public $integrations;
14
15 /**
16 * Form option fields.
17 *
18 * @var array
19 */
20 public $form_fields = array();
21
22 /**
23 * Initializes the WeDevs_ERP() class
24 *
25 * Checks for an existing WeDevs_ERP() instance
26 * and if it doesn't find one, creates it.
27 */
28 public static function init() {
29 static $instance = false;
30
31 if ( ! $instance ) {
32 $instance = new self();
33 }
34
35 return $instance;
36 }
37
38 /**
39 * Class constructor.
40 */
41 public function __construct() {
42 // Let 3rd parties unhook the above via this hook
43 do_action( 'erp_integration', $this );
44 }
45
46 /**
47 * Initialize integrations.
48 *
49 * @return array
50 */
51 function init_integrations() {
52 $this->integrations = apply_filters( 'erp_integration_classes', $this->integrations );
53 }
54
55 /**
56 * Return the integration classes - used in admin to load settings.
57 *
58 * @return array
59 */
60 public function get_integrations() {
61 return $this->integrations;
62 }
63
64 /**
65 * Get an registered integration instance
66 *
67 * @param string $class_name
68 *
69 * @return \Integration|false
70 */
71 public function get_integration( $class_name ) {
72 if ( $this->integrations && array_key_exists( $class_name, $this->integrations ) ) {
73 return $this->integrations[ $class_name ];
74 }
75
76 return false;
77 }
78
79 /**
80 * Get saved option id
81 *
82 * @return string
83 */
84 public function get_option_id() {
85 return 'erp_integration_settings_' . $this->id;
86 }
87
88 /**
89 * Get the form fields after they are initialized.
90 * @return array of options
91 */
92 public function get_form_fields() {
93 return apply_filters( 'erp_settings_integration_form_fields_' . $this->id, $this->form_fields );
94 }
95
96 /**
97 * Generate settings html.
98 *
99 * @return void
100 */
101 function generate_settings_html() {
102 $settings = $this->get_form_fields();
103 $this->output_fields( $settings );
104 }
105
106 /**
107 * Get integration setting by key
108 *
109 * @param string $option
110 * @param string $default
111 *
112 * @return string
113 */
114 public function get_setting( $option, $default = '' ) {
115 $settings = get_option( 'erp_settings_erp-integration', [] );
116
117 if ( array_key_exists( $option, $settings ) ) {
118 return $settings[ $option ];
119 }
120
121 return $default;
122 }
123
124 /**
125 * Get the admin options of this integration.
126 *
127 * @return void
128 */
129 public function admin_options() {
130 ?>
131 <h3><?php echo esc_html( $this->get_title() ); ?></h3>
132 <?php echo wpautop( wp_kses_post( $this->get_description() ) ); ?>
133
134 <?php
135 /**
136 * erp_email_settings_before action hook.
137 *
138 * @param string $integration The integration object
139 */
140 do_action( 'erp_integration_settings_before', $this );
141 ?>
142
143 <table class="form-table">
144 <?php $this->generate_settings_html(); ?>
145 </table>
146
147 <?php
148 /**
149 * erp_integration_settings_after action hook.
150 *
151 * @param string $integration The integration object
152 */
153 do_action( 'erp_integration_settings_after', $this );
154 ?>
155 <?php
156 }
157
158 }
159