PluginProbe
ShareMyPost / 1.0.5
ShareMyPost v1.0.5
trunk 1.0.4 1.0.5 1.0.6
sharemypost / main / admin.php

admin.php in ShareMyPost 1.0.5, at main/admin.php

229 lines 10.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ShareMyPost;
4
5 if(!defined('ABSPATH')){
6 exit;
7 }
8
9 class Admin {
10
11 static function init() {
12 add_action('admin_menu', '\ShareMyPost\Admin::add_admin_menu');
13 add_action('admin_enqueue_scripts', '\ShareMyPost\Admin::enqueue_admin_assets');
14 add_action('admin_init', '\ShareMyPost\Admin::register_settings');
15 }
16
17 static function register_settings() {
18 register_setting('sharemypost_settings_group', 'sharemypost_settings', [
19 'type' => 'array',
20 'sanitize_callback' => ['\ShareMyPost\Helpers', 'sanitize_settings'],
21 'default' => [],
22 ]);
23 }
24
25 static function add_admin_menu() {
26 add_menu_page( 'ShareMyPost', 'ShareMyPost', 'manage_options', 'sharemypost', '\ShareMyPost\Admin::dispatcher', SHAREMYPOST_ASSETS_URL.'/img/sidebar-logo.png');
27 }
28
29 static function dispatcher() {
30 echo '<div class="sharemypost-wrap">';
31
32 self::render_header();
33 echo '<div class="sharemypost-main-content">
34 <div id="sharemypost-options" class="sharemypost-tab-content active">';
35 self::render_options_layout();
36 echo '</div>';
37
38 echo '</div>
39 </main></div>
40 </div>';
41 }
42
43 static function render_header() {
44
45 if (defined('SHAREMYPOST_PRO_VERSION')) {
46 $sub_tabs = [
47 'inline_content' => ['label' => 'Inline Content', 'icon' => 'menu'],
48 'floating_bar' => ['label' => 'Floating Bar', 'icon' => 'align-pull-left', 'pro' => true],
49 'custom_networks' => ['label' => 'Custom Networks', 'icon' => 'networking', 'pro' => true],
50 'click_to_tweet' => ['label' => 'Click to X', 'pro' => true],
51 'configuration' => ['label' => 'Configuration', 'icon' => 'admin-settings', 'pro' => true],
52 'support' => ['label' => 'Support', 'icon' => 'sos'],
53 'license' => ['label' => 'License', 'icon' => 'admin-network'],
54 ];
55 } else {
56 $sub_tabs = [
57 'inline_content' => ['label' => 'Inline Content', 'icon' => 'menu'],
58 'support' => ['label' => 'Support', 'icon' => 'sos'],
59 'go_pro' => ['label' => 'Go Pro', 'icon' => 'lock'],
60 ];
61 }
62
63 echo '<div class="sharemypost-admin-wrapper">
64 <header class="sharemypost-admin-header main-header-sticky">
65 <div class="sharemypost-header-left">
66
67 <div class="sharemypost-logo">
68 <img alt="' . esc_attr__('ShareMyPost Logo', 'sharemypost') . '" src="' . esc_url(SHAREMYPOST_ASSETS_URL) . '/img/sharemypost-logo.png" height="38"/>
69 </div>
70 <nav class="sharemypost-nav-tabs glass-tabs" id="sharemypost-main-nav"></nav>
71 <div class="sharemypost-sub-tabs-wrapper">';
72 $icon = '';
73 foreach($sub_tabs as $slug => $tab){
74
75 if ($slug === 'click_to_tweet') {
76 $icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" fill="currentColor" style="width:20px;height:20px;vertical-align:middle"><path d="M453.2 112L523.8 112L369.6 288.2L551 528L409 528L297.7 382.6L170.5 528L99.8 528L264.7 339.5L90.8 112L236.4 112L336.9 244.9L453.2 112zM428.4 485.8L467.5 485.8L215.1 152L173.1 152L428.4 485.8z"/></svg> ';
77 } elseif (!empty($tab['icon'])) {
78 $icon = '<span class="dashicons dashicons-' . esc_attr($tab['icon']) . '"></span> ';
79 }
80
81 $pro_tag = (!defined('SHAREMYPOST_PRO_VERSION') && !empty($tab['pro'])) ? '<span class="sharemypost-pro-tag">PRO</span>' : '';
82 echo '<button type="button" class="sharemypost-sub-tab" data-subtab="' . esc_attr($slug) . '">' . wp_kses_post($icon) . esc_html($tab['label']) . wp_kses_post($pro_tag) . '</button>';
83 }
84 echo '</div>
85
86 </div> <div class="sharemypost-header-right">
87 <div class="sharemypost-version-badge">
88 v' . esc_html(SHAREMYPOST_VERSION) . '
89 </div>
90 </div>
91 </header>
92 <main class="sharemypost-admin-main-content">';
93 }
94
95 static function render_options_layout() {
96 if (defined('SHAREMYPOST_PRO_VERSION')) {
97 $sub_tabs = [
98 'inline_content' => ['label' => 'Inline Content'],
99 'floating_bar' => ['label' => 'Floating Bar', 'pro' => true],
100 'custom_networks' => ['label' => 'Custom Networks', 'pro' => true],
101 'click_to_tweet' => ['label' => 'Click to X', 'pro' => true],
102 'configuration' => ['label' => 'Configuration', 'pro' => true],
103 'support' => ['label' => 'Support'],
104 'license' => ['label' => 'License', 'pro' => true],
105 ];
106 } else {
107 $sub_tabs = [
108 'inline_content' => ['label' => 'Inline Content'],
109 'support' => ['label' => 'Support'],
110 'go_pro' => ['label' => 'Go Pro'],
111 ];
112 }
113
114 echo '<div class="sharemypost-options-container">';
115 foreach ($sub_tabs as $slug => $tab) {
116 $style = ($slug === 'inline_content') ? '' : 'display:none;';
117 echo '<div id="subtab-' . esc_attr($slug) . '" class="sharemypost-sub-panel" style="' . esc_attr($style) . '">';
118 if($slug === 'custom_networks'){
119 do_action('sharemypost_custom_networks_settings');
120 } elseif($slug === 'floating_bar'){
121 do_action('sharemypost_floating_bar_settings');
122
123 } elseif($slug === 'license'){
124 do_action('sharemypost_render_license_page');
125 } elseif($slug === 'support'){
126 self::support_page();
127 } elseif($slug === 'go_pro'){
128 self::go_pro_page();
129 } else {
130 $method = $slug . '_settings';
131 if(method_exists('\ShareMyPost\Settings\UI', $method)){
132 \ShareMyPost\Settings\UI::$method();
133 }
134 }
135 echo '</div>';
136 }
137 echo '</div>';
138 }
139
140 static function enqueue_admin_assets($hook) {
141 if(false === strpos($hook, 'sharemypost')){
142 return;
143 }
144
145 wp_enqueue_style('sharemypost-admin', SHAREMYPOST_PLUGIN_URL . 'assets/css/admin.css', [], SHAREMYPOST_VERSION);
146 wp_enqueue_media();
147 wp_enqueue_script('sharemypost-admin', SHAREMYPOST_PLUGIN_URL . 'assets/js/admin.js', ['jquery', 'jquery-ui-sortable'], SHAREMYPOST_VERSION, true);
148 wp_localize_script('sharemypost-admin', 'sharemypost_data', [
149 'nonce' => wp_create_nonce('sharemypost_admin_nonce'),
150 'ajax_url' => admin_url('admin-ajax.php'),
151 'is_pro' => defined('SHAREMYPOST_PRO_VERSION')
152 ]);
153 }
154
155 static function support_page(){
156 echo '<div class="sharemypost-support-page" style="margin-top: 24px">
157 <div class="sharemypost-logo-name" style="margin: 0 auto 50px; width:60px; height:30px;">
158 <img alt="' . esc_html('sharemypost logo', 'sharemypost') . '" width="300px" height="60px" src="' . esc_url(SHAREMYPOST_ASSETS_URL) . '/img/sharemypost-logo-name.png' . '"/>
159 </div>
160 <h2>' . esc_html__('Help & Support', 'sharemypost') . '</h2>
161 <p>' . esc_html__('You can contact the ShareMyPost team via email at ', 'sharemypost') . '<a href="mailto:support@sharemypost.net">support@sharemypost.net</a> ' . esc_html__('or through our Support Ticket System.', 'sharemypost') . '</p>
162 <p>' . esc_html__('You can also check the documentation here:', 'sharemypost') . ' <a href="https://sharemypost.net/docs" target="_blank" rel="noopener noreferrer">https://sharemypost.net/docs</a></p>
163 </div>';
164 }
165
166 static function go_pro_page(){
167 echo '<div class="sharemypost-gopro-container">
168 <div class="sharemypost-gopro-hero">
169 <h2 class="sharemypost-gopro-title">' . esc_html__('Upgrade to ShareMyPost PRO', 'sharemypost') . '</h2>
170 <p class="sharemypost-gopro-description">' . esc_html__('Unlock advanced sharing features, deep tracking analytics, AI tools, and premium support.', 'sharemypost') . '</p>
171 <a href="https://sharemypost.net" target="_blank" class="button button-primary button-large sharemypost-gopro-button">' . esc_html__('Get ShareMyPost Pro Now', 'sharemypost') . '</a>
172 </div>
173
174 <div class="sharemypost-features-grid">
175 <div class="sharemypost-feature-card">
176 <h3 class="sharemypost-feature-title">
177 <span class="dashicons dashicons-chart-bar sharemypost-feature-icon"></span>
178 ' . esc_html__('Advanced Analytics & Tracking', 'sharemypost') . '
179 </h3>
180 <p class="sharemypost-feature-description">' . esc_html__('Seamless Google Analytics 4 (GA4) integration and customizable dynamic UTM tracking parameters to measure your viral loops.', 'sharemypost') . '</p>
181 </div>
182
183 <div class="sharemypost-feature-card">
184 <h3 class="sharemypost-feature-title">
185 <span class="dashicons dashicons-admin-links sharemypost-feature-icon"></span>
186 ' . esc_html__('Universal Modal Sharing', 'sharemypost') . '
187 </h3>
188 <p class="sharemypost-feature-description">' . esc_html__('Add a single universal share button that triggers a stunning modal listing all 30+ networks, keeping your layout clean.', 'sharemypost') . '</p>
189 </div>
190
191 <div class="sharemypost-feature-card">
192 <h3 class="sharemypost-feature-title">
193 <span class="dashicons dashicons-edit sharemypost-feature-icon"></span>
194 ' . esc_html__('Click to X (Twitter) Shortcode', 'sharemypost') . '
195 </h3>
196 <p class="sharemypost-feature-description">' . esc_html__('Create high-converting callout boxes within your content using customizable themes, accents, and custom pre-written tweets.', 'sharemypost') . '</p>
197 </div>
198
199 <div class="sharemypost-feature-card">
200 <h3 class="sharemypost-feature-title">
201 <span class="dashicons dashicons-admin-generic sharemypost-feature-icon"></span>
202 ' . esc_html__('AI Sharing Integration', 'sharemypost') . '
203 </h3>
204 <p class="sharemypost-feature-description">' . esc_html__('Enable one-click sharing/prompting to popular AI assistants like ChatGPT, Gemini, Claude, Perplexity, and Grok.', 'sharemypost') . '</p>
205 </div>
206
207 <div class="sharemypost-feature-card">
208 <h3 class="sharemypost-feature-title">
209 <span class="dashicons dashicons-art sharemypost-feature-icon"></span>
210 ' . esc_html__('Advanced Customization', 'sharemypost') . '
211 </h3>
212 <p class="sharemypost-feature-description">' . esc_html__('Unlock 6 button shapes, 5 button styles, adjustable custom sizes, margins, custom colors, and custom network icons.', 'sharemypost') . '</p>
213 </div>
214
215 <div class="sharemypost-feature-card">
216 <h3 class="sharemypost-feature-title">
217 <span class="dashicons dashicons-align-left sharemypost-feature-icon"></span>
218 ' . esc_html__('Floating Share Bars', 'sharemypost') . '
219 </h3>
220 <p class="sharemypost-feature-description">' . esc_html__('Add sticky side bars that follow visitors as they scroll, fully customizable in behavior and device visibility.', 'sharemypost') . '</p>
221 </div>
222 </div>
223
224 <div class="sharemypost-gopro-footer">
225 ' . esc_html__('Need help? Feel free to contact our support team at support@sharemypost.net', 'sharemypost') . '
226 </div>
227 </div>';
228 }
229 }