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

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

232 lines 11.7 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
27 $icon = 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgd2lkdGg9IjIwIiBoZWlnaHQ9IjIwIj48c3R5bGU+LnMwIHsgZmlsbDogIzYzNjZmMSB9IC5zMSB7IGZpbGw6ICNmZmZmZmYgfTwvc3R5bGU+PGcgaWQ9IkxheWVyIDEiPjxwYXRoIGNsYXNzPSJzMCIgZD0ibTE2MyAwaDY5OGM5MC4wMiAwIDE2MyA3Mi45OCAxNjMgMTYzdjY5OGMwIDkwLjAyLTcyLjk4IDE2My0xNjMgMTYzaC02OThjLTkwLjAyIDAtMTYzLTcyLjk4LTE2My0xNjN2LTY5OGMwLTkwLjAyIDcyLjk4LTE2MyAxNjMtMTYzeiIvPjxnPjxwYXRoIGlkPSJtYXJrIiBjbGFzcz0iczEiIGQ9Im02MjAuNyAxNDYuNmgxNDguOWM2LjggMCAxMS44IDUuMiAxMS44IDExLjh2MTU1LjZjMCA1LjUtMi45IDguMi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emypost', '\ShareMyPost\Admin::dispatcher', $icon);
30 }
31
32 static function dispatcher() {
33 echo '<div class="sharemypost-wrap">';
34
35 self::render_header();
36 echo '<div class="sharemypost-main-content">
37 <div id="sharemypost-options" class="sharemypost-tab-content active">';
38 self::render_options_layout();
39 echo '</div>';
40
41 echo '</div>
42 </main></div>
43 </div>';
44 }
45
46 static function render_header() {
47
48 if (defined('SHAREMYPOST_PRO_VERSION')) {
49 $sub_tabs = [
50 'inline_content' => ['label' => 'Inline Content', 'icon' => 'menu'],
51 'floating_bar' => ['label' => 'Floating Bar', 'icon' => 'align-pull-left', 'pro' => true],
52 'custom_networks' => ['label' => 'Custom Networks', 'icon' => 'networking', 'pro' => true],
53 'click_to_tweet' => ['label' => 'Click to X', 'pro' => true],
54 'configuration' => ['label' => 'Configuration', 'icon' => 'admin-settings', 'pro' => true],
55 'support' => ['label' => 'Support', 'icon' => 'sos'],
56 'license' => ['label' => 'License', 'icon' => 'admin-network'],
57 ];
58 } else {
59 $sub_tabs = [
60 'inline_content' => ['label' => 'Inline Content', 'icon' => 'menu'],
61 'support' => ['label' => 'Support', 'icon' => 'sos'],
62 'go_pro' => ['label' => 'Go Pro', 'icon' => 'lock'],
63 ];
64 }
65
66 echo '<div class="sharemypost-admin-wrapper">
67 <header class="sharemypost-admin-header main-header-sticky">
68 <div class="sharemypost-header-left">
69
70 <div class="sharemypost-logo">
71 <img alt="' . esc_attr__('ShareMyPost Logo', 'sharemypost') . '" src="' . esc_url(SHAREMYPOST_ASSETS_URL) . '/img/sharemypost-logo.svg" height="38"/>
72 </div>
73 <nav class="sharemypost-nav-tabs glass-tabs" id="sharemypost-main-nav"></nav>
74 <div class="sharemypost-sub-tabs-wrapper">';
75 $icon = '';
76 foreach($sub_tabs as $slug => $tab){
77
78 if ($slug === 'click_to_tweet') {
79 $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> ';
80 } elseif (!empty($tab['icon'])) {
81 $icon = '<span class="dashicons dashicons-' . esc_attr($tab['icon']) . '"></span> ';
82 }
83
84 $pro_tag = (!defined('SHAREMYPOST_PRO_VERSION') && !empty($tab['pro'])) ? '<span class="sharemypost-pro-tag">PRO</span>' : '';
85 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>';
86 }
87 echo '</div>
88
89 </div> <div class="sharemypost-header-right">
90 <div class="sharemypost-version-badge">
91 v' . esc_html(SHAREMYPOST_VERSION) . '
92 </div>
93 </div>
94 </header>
95 <main class="sharemypost-admin-main-content">';
96 }
97
98 static function render_options_layout() {
99 if (defined('SHAREMYPOST_PRO_VERSION')) {
100 $sub_tabs = [
101 'inline_content' => ['label' => 'Inline Content'],
102 'floating_bar' => ['label' => 'Floating Bar', 'pro' => true],
103 'custom_networks' => ['label' => 'Custom Networks', 'pro' => true],
104 'click_to_tweet' => ['label' => 'Click to X', 'pro' => true],
105 'configuration' => ['label' => 'Configuration', 'pro' => true],
106 'support' => ['label' => 'Support'],
107 'license' => ['label' => 'License', 'pro' => true],
108 ];
109 } else {
110 $sub_tabs = [
111 'inline_content' => ['label' => 'Inline Content'],
112 'support' => ['label' => 'Support'],
113 'go_pro' => ['label' => 'Go Pro'],
114 ];
115 }
116
117 echo '<div class="sharemypost-options-container">';
118 foreach ($sub_tabs as $slug => $tab) {
119 $style = ($slug === 'inline_content') ? '' : 'display:none;';
120 echo '<div id="subtab-' . esc_attr($slug) . '" class="sharemypost-sub-panel" style="' . esc_attr($style) . '">';
121 if($slug === 'custom_networks'){
122 do_action('sharemypost_custom_networks_settings');
123 } elseif($slug === 'floating_bar'){
124 do_action('sharemypost_floating_bar_settings');
125
126 } elseif($slug === 'license'){
127 do_action('sharemypost_render_license_page');
128 } elseif($slug === 'support'){
129 self::support_page();
130 } elseif($slug === 'go_pro'){
131 self::go_pro_page();
132 } else {
133 $method = $slug . '_settings';
134 if(method_exists('\ShareMyPost\Settings\UI', $method)){
135 \ShareMyPost\Settings\UI::$method();
136 }
137 }
138 echo '</div>';
139 }
140 echo '</div>';
141 }
142
143 static function enqueue_admin_assets($hook) {
144 if(false === strpos($hook, 'sharemypost')){
145 return;
146 }
147
148 wp_enqueue_style('sharemypost-admin', SHAREMYPOST_PLUGIN_URL . 'assets/css/admin.css', [], SHAREMYPOST_VERSION);
149 wp_enqueue_media();
150 wp_enqueue_script('sharemypost-admin', SHAREMYPOST_PLUGIN_URL . 'assets/js/admin.js', ['jquery', 'jquery-ui-sortable'], SHAREMYPOST_VERSION, true);
151 wp_localize_script('sharemypost-admin', 'sharemypost_data', [
152 'nonce' => wp_create_nonce('sharemypost_admin_nonce'),
153 'ajax_url' => admin_url('admin-ajax.php'),
154 'is_pro' => defined('SHAREMYPOST_PRO_VERSION')
155 ]);
156 }
157
158 static function support_page(){
159 echo '<div class="sharemypost-support-page" style="margin-top: 24px">
160 <div class="sharemypost-logo-name" style="margin: 0 auto 50px;">
161 <img alt="' . esc_html('sharemypost logo', 'sharemypost') . '" width="300px" src="' . esc_url(SHAREMYPOST_ASSETS_URL) . '/img/sharemypost-logo-name.png' . '"/>
162 </div>
163 <h2>' . esc_html__('Help & Support', 'sharemypost') . '</h2>
164 <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>
165 <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>
166 </div>';
167 }
168
169 static function go_pro_page(){
170 echo '<div class="sharemypost-gopro-container">
171 <div class="sharemypost-gopro-hero">
172 <h2 class="sharemypost-gopro-title">' . esc_html__('Upgrade to ShareMyPost PRO', 'sharemypost') . '</h2>
173 <p class="sharemypost-gopro-description">' . esc_html__('Unlock advanced sharing features, deep tracking analytics, AI tools, and premium support.', 'sharemypost') . '</p>
174 <a href="https://sharemypost.net" target="_blank" class="button button-primary button-large sharemypost-gopro-button">' . esc_html__('Get ShareMyPost Pro Now', 'sharemypost') . '</a>
175 </div>
176
177 <div class="sharemypost-features-grid">
178 <div class="sharemypost-feature-card">
179 <h3 class="sharemypost-feature-title">
180 <span class="dashicons dashicons-chart-bar sharemypost-feature-icon"></span>
181 ' . esc_html__('Advanced Analytics & Tracking', 'sharemypost') . '
182 </h3>
183 <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>
184 </div>
185
186 <div class="sharemypost-feature-card">
187 <h3 class="sharemypost-feature-title">
188 <span class="dashicons dashicons-admin-links sharemypost-feature-icon"></span>
189 ' . esc_html__('Universal Modal Sharing', 'sharemypost') . '
190 </h3>
191 <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>
192 </div>
193
194 <div class="sharemypost-feature-card">
195 <h3 class="sharemypost-feature-title">
196 <span class="dashicons dashicons-edit sharemypost-feature-icon"></span>
197 ' . esc_html__('Click to X (Twitter) Shortcode', 'sharemypost') . '
198 </h3>
199 <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>
200 </div>
201
202 <div class="sharemypost-feature-card">
203 <h3 class="sharemypost-feature-title">
204 <span class="dashicons dashicons-admin-generic sharemypost-feature-icon"></span>
205 ' . esc_html__('AI Sharing Integration', 'sharemypost') . '
206 </h3>
207 <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>
208 </div>
209
210 <div class="sharemypost-feature-card">
211 <h3 class="sharemypost-feature-title">
212 <span class="dashicons dashicons-art sharemypost-feature-icon"></span>
213 ' . esc_html__('Advanced Customization', 'sharemypost') . '
214 </h3>
215 <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>
216 </div>
217
218 <div class="sharemypost-feature-card">
219 <h3 class="sharemypost-feature-title">
220 <span class="dashicons dashicons-align-left sharemypost-feature-icon"></span>
221 ' . esc_html__('Floating Share Bars', 'sharemypost') . '
222 </h3>
223 <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>
224 </div>
225 </div>
226
227 <div class="sharemypost-gopro-footer">
228 ' . esc_html__('Need help? Feel free to contact our support team at support@sharemypost.net', 'sharemypost') . '
229 </div>
230 </div>';
231 }
232 }