1: <?php
2: 3: 4: 5: 6: 7: 8:
9: if ( ! defined( 'ABSPATH' ) ) {
10: exit;
11: }
12:
13: 14: 15: 16: 17: 18:
19: class Mauticommerce_Admin extends Mauticommerce {
20: 21: 22: 23:
24: private static $instance;
25:
26: 27: 28: 29:
30: private static $text_domain;
31:
32: 33: 34: 35:
36: private $mauticommece_settings = array();
37:
38: 39: 40: 41: 42: 43:
44: private function __construct() {
45: self::$text_domain = Mauticommerce::text_domain();
46: $this->mauticommece_settings = get_option( 'mauticommece_settings' );
47: }
48:
49: 50: 51: 52: 53: 54:
55: public static function get_instance() {
56: if ( ! isset( self::$instance ) ) {
57: $c = __CLASS__;
58: self::$instance = new $c();
59: }
60: return self::$instance;
61: }
62:
63:
64: 65: 66: 67: 68:
69: public function settings_init() {
70: $this->_register_admin_panels();
71: if ( empty( $_POST ) ) {
72: return;
73: }
74: }
75:
76: 77: 78: 79: 80:
81: private function _register_admin_panels() {
82: register_setting( 'MautiCommerce', 'mauticommece_settings' );
83: add_settings_section(
84: 'mauticommece_RelatedScore_settings',
85: __( 'Settings', self::$text_domain ),
86: array( $this, 'mauticommece_settings_url_section_callback' ),
87: 'MautiCommerce'
88: );
89: add_settings_field(
90: 'url',
91: __( 'Mautic URL', self::$text_domain ),
92: array( $this, 'mautic_url_render' ),
93: 'MautiCommerce',
94: 'mauticommece_RelatedScore_settings'
95: );
96: add_settings_field(
97: 'form_id',
98: __( 'Mautic Form ID', self::$text_domain ),
99: array( $this, 'mautic_form_id_render' ),
100: 'MautiCommerce',
101: 'mauticommece_RelatedScore_settings'
102: );
103: }
104:
105: 106: 107: 108: 109:
110: public function mautic_form_id_render() {
111: if ( ! isset( $this->mauticommece_settings['form_id'] ) ) {
112: $this->mauticommece_settings['form_id'] = '';
113: }
114: echo "<input type='text' name='mauticommece_settings[form_id]' value='" . $this->mauticommece_settings['form_id'] . "'>";
115: }
116:
117: 118: 119: 120: 121:
122: public function mautic_url_render() {
123: if ( ! isset( $this->mauticommece_settings['url'] ) ) {
124: $this->mauticommece_settings['url'] = '';
125: }
126: echo "<input type='url' name='mauticommece_settings[url]' value='" . $this->mauticommece_settings['url'] . "' style='width:100%;'>";
127: }
128:
129: 130: 131: 132: 133:
134: public function mauticommece_settings_url_section_callback() {
135: echo __( 'Set Mautic Information.', self::$text_domain );
136: }
137:
138: 139: 140: 141: 142:
143: public function mauticommece_options() {
144: echo '<h2>Mauticommece</h2>';
145: echo "<form action='options.php' method='post'>";
146: settings_fields( 'MautiCommerce' );
147: do_settings_sections( 'MautiCommerce' );
148: submit_button();
149: echo '</form>';
150: }
151:
152: 153: 154: 155: 156:
157: public function add_admin_menu() {
158: add_options_page( 'Mauticommece', 'Mauticommece', 'manage_options', 'mauticommece', array( $this, 'mauticommece_options' ) );
159: }
160:
161: }
162: