PluginProbe
AL Pack / trunk
AL Pack vtrunk
1.3.13 trunk 1.0.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.3.0 1.3.1 1.3.11 1.3.12
alpack / templates / admin-social-share.php

admin-social-share.php in AL Pack trunk, at templates/admin-social-share.php

252 lines 12.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) {
3 exit;
4 }
5
6 $is_activated = presslearn_plugin()->is_plugin_activated();
7
8 if (!$is_activated) {
9 wp_redirect(admin_url('admin.php?page=presslearn-settings'));
10 exit;
11 }
12
13 if (isset($_POST['presslearn_toggle_social_share']) && isset($_POST['enable'])) {
14 check_admin_referer('presslearn_toggle_social_share_nonce');
15
16 if (current_user_can('manage_options')) {
17 $enable = sanitize_text_field(wp_unslash($_POST['enable']));
18 if ($enable === 'yes' || $enable === 'no') {
19 update_option('presslearn_social_share_enabled', $enable);
20 $updated = true;
21 }
22 }
23 }
24
25 if (current_user_can('manage_options') && is_admin() && isset($_GET['action']) && isset($_GET['enable']) && isset($_GET['feature'])) {
26 if (!isset($_GET['_wpnonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['_wpnonce'])), 'presslearn_toggle_social_share_action')) {
27 wp_die('보안 검증에 실패했습니다.');
28 }
29
30 $action = sanitize_text_field(wp_unslash($_GET['action']));
31 $enable = sanitize_text_field(wp_unslash($_GET['enable']));
32 $feature = sanitize_text_field(wp_unslash($_GET['feature']));
33
34 if ($action === 'toggle' && $feature === 'social_share' && ($enable === 'yes' || $enable === 'no')) {
35 update_option('presslearn_social_share_enabled', $enable);
36 $updated = true;
37 }
38 }
39
40 if (isset($_POST['save_social_share_settings'])) {
41 check_admin_referer('presslearn_save_social_share_settings_nonce');
42
43 if (current_user_can('manage_options')) {
44 $social_share_options = array();
45 if (isset($_POST['social_share_options']) && is_array($_POST['social_share_options'])) {
46 $social_share_options = array_map('sanitize_text_field', array_map('wp_unslash', $_POST['social_share_options']));
47 }
48
49 $valid_options = array();
50 $allowed_options = array('facebook', 'naver', 'line', 'kakaotalk', 'band', 'twitter');
51
52 foreach ($social_share_options as $option) {
53 if (in_array($option, $allowed_options)) {
54 $valid_options[] = $option;
55 }
56 }
57
58 update_option('presslearn_social_share_options', $valid_options);
59
60 if (isset($_POST['kakao_api_key'])) {
61 $kakao_api_key = sanitize_text_field(wp_unslash($_POST['kakao_api_key']));
62 update_option('presslearn_kakao_api_key', $kakao_api_key);
63 }
64
65 if (isset($_POST['social_share_style'])) {
66 $style = sanitize_text_field(wp_unslash($_POST['social_share_style']));
67 if (in_array($style, array('default', 'popup'))) {
68 update_option('presslearn_social_share_style', $style);
69 }
70 }
71
72 if (isset($_POST['social_share_alignment'])) {
73 $alignment = sanitize_text_field(wp_unslash($_POST['social_share_alignment']));
74 if (in_array($alignment, array('left', 'right', 'center', 'full', 'inline'))) {
75 update_option('presslearn_social_share_alignment', $alignment);
76 }
77 }
78
79 $settings_updated = true;
80 }
81 }
82
83 $social_share_enabled = get_option('presslearn_social_share_enabled', 'no');
84 $social_share_options = get_option('presslearn_social_share_options', array('facebook', 'naver', 'line', 'kakaotalk', 'band', 'twitter'));
85 $kakao_api_key = get_option('presslearn_kakao_api_key', '');
86 $has_kakao_api_key = !empty($kakao_api_key);
87 $social_share_style = get_option('presslearn_social_share_style', 'default');
88 $social_share_alignment = get_option('presslearn_social_share_alignment', 'left');
89
90 ?>
91
92 <div class="presslearn-header">
93 <div class="presslearn-header-logo">
94 <img src="<?php echo esc_url(PRESSLEARN_PLUGIN_URL); ?>assets/images/logo.png" alt="PressLearn Logo">
95 <h1>소�
96 � 공유</h1>
97 </div>
98 <div class="presslearn-header-status">
99 <?php if ($social_share_enabled === 'yes'): ?>
100 <div class="presslearn-header-status-item status-activate">
101 <p>기능이 활성화되었습니다.</p>
102 </div>
103 <?php else: ?>
104 <div class="presslearn-header-status-item status-deactivate">
105 <p>기능이 비활성화 상태�
106 니다.</p>
107 </div>
108 <?php endif; ?>
109 </div>
110 </div>
111
112 <div class="wrap">
113
114 <div class="presslearn-breadcrumbs-wrap">
115 <div class="presslearn-breadcrumbs">
116 <span>대시보드</span>
117 <span class="divider">/</span>
118 <span class="active">소�
119 � 공유</span>
120 </div>
121 </div>
122
123 <?php if (isset($settings_updated) && $settings_updated): ?>
124 <div class="notice notice-success inline">
125 <p>설정 정보가 성공적으로 저장되었습니다.</p>
126 </div>
127 <?php endif; ?>
128
129 <?php if (!$has_kakao_api_key): ?>
130 <div class="notice notice-warning inline">
131 <p>카카오톡 공유 기능을 사용하려면 카카오톡 API KEY를 �
132 력해주세요.<br/><a href="https://developers.kakao.com/" target="_blank">카카오톡 API KEY 발급 받기</a></p>
133 </div>
134 <?php endif; ?>
135
136 <div class="presslearn-card">
137 <div class="presslearn-card-header">
138 <h2>소�
139 � 공유</h2>
140 <p>다양한 소�
141 � 미디어 매체에 간편하게 나의 게시물을 공유할 수 있도록 도와줍니다.</p>
142 </div>
143 <div class="presslearn-card-body">
144 <div class="presslearn-card-body-row">
145 <div class="presslearn-card-body-row-item grid-left">
146 <h3>플러그인 기능 활성화</h3>
147 </div>
148 <div class="presslearn-card-body-row-item grid-right">
149 <form method="post" action="" id="social-share-toggle-form">
150 <?php wp_nonce_field('presslearn_toggle_social_share_nonce'); ?>
151 <input type="hidden" name="presslearn_toggle_social_share" value="1">
152 <input type="hidden" name="enable" id="social-share-enable-value" value="<?php echo esc_attr($social_share_enabled === 'yes' ? 'no' : 'yes'); ?>">
153
154 <label class="switch">
155 <input type="checkbox" <?php echo esc_attr($social_share_enabled === 'yes' ? 'checked' : ''); ?> onchange="document.getElementById('social-share-enable-value').value = this.checked ? 'yes' : 'no'; document.getElementById('social-share-toggle-form').submit();">
156 <span class="slider round"></span>
157 </label>
158 </form>
159 </div>
160 </div>
161 <form method="post" action="" id="social-share-settings-form">
162 <?php wp_nonce_field('presslearn_save_social_share_settings_nonce'); ?>
163 <input type="hidden" name="save_social_share_settings" value="1">
164 <div class="presslearn-card-body-row">
165 <div class="presslearn-card-body-row-item grid-left">
166 <h3>활성화할 소�
167 � 미디어</h3>
168 </div>
169 <div class="presslearn-card-body-row-item grid-right">
170 <div class="social-share-options">
171 <label class="social-share-button">
172 <input type="checkbox" name="social_share_options[]" value="facebook" <?php echo esc_attr(in_array('facebook', $social_share_options) ? 'checked' : ''); ?>>
173 <span class="social-btn">페이스북</span>
174 </label><label class="social-share-button">
175 <input type="checkbox" name="social_share_options[]" value="band" <?php echo esc_attr(in_array('band', $social_share_options) ? 'checked' : ''); ?>>
176 <span class="social-btn">밴드</span>
177 </label><label class="social-share-button" id="kakaotalk-option-label">
178 <input type="checkbox" name="social_share_options[]" value="kakaotalk" id="kakaotalk-option" <?php echo esc_attr(in_array('kakaotalk', $social_share_options) ? 'checked' : ''); ?> <?php echo esc_attr(!$has_kakao_api_key ? 'disabled' : ''); ?>>
179 <span class="social-btn">카카오톡</span>
180 </label><label class="social-share-button">
181 <input type="checkbox" name="social_share_options[]" value="naver" <?php echo esc_attr(in_array('naver', $social_share_options) ? 'checked' : ''); ?>>
182 <span class="social-btn">네이버</span>
183 </label><label class="social-share-button">
184 <input type="checkbox" name="social_share_options[]" value="line" <?php echo esc_attr(in_array('line', $social_share_options) ? 'checked' : ''); ?>>
185 <span class="social-btn">라인</span>
186 </label><label class="social-share-button">
187 <input type="checkbox" name="social_share_options[]" value="twitter" <?php echo esc_attr(in_array('twitter', $social_share_options) ? 'checked' : ''); ?>>
188 <span class="social-btn">X</span>
189 </label>
190 </div>
191 </div>
192 </div>
193 <div class="presslearn-card-body-row">
194 <div class="presslearn-card-body-row-item grid-left">
195 <h3>카카오톡 API KEY</h3>
196 </div>
197 <div class="presslearn-card-body-row-item grid-right">
198 <input type="text" name="kakao_api_key" class="regular-text" value="<?php echo esc_attr($kakao_api_key); ?>" id="kakao-api-key">
199 </div>
200 </div>
201 <div class="presslearn-card-body-row">
202 <div class="presslearn-card-body-row-item grid-left">
203 <h3>소�
204 � 공유 스타일</h3>
205 </div>
206 <div class="presslearn-card-body-row-item grid-right">
207 <select name="social_share_style" id="social-share-style">
208 <option value="default" <?php selected($social_share_style, 'default'); ?>>나열 형식</option>
209 <option value="popup" <?php selected($social_share_style, 'popup'); ?>>팝�
210 형식</option>
211 </select>
212 </div>
213 </div>
214 <div class="presslearn-card-body-row">
215 <div class="presslearn-card-body-row-item grid-left">
216 <h3>소�
217 � 공유 버튼 정렬 설정</h3>
218 </div>
219 <div class="presslearn-card-body-row-item grid-right">
220 <select name="social_share_alignment" id="social-share-alignment">
221 <option value="left" <?php selected($social_share_alignment, 'left'); ?>>왼쪽</option>
222 <option value="right" <?php selected($social_share_alignment, 'right'); ?>>오른쪽</option>
223 <option value="center" <?php selected($social_share_alignment, 'center'); ?>>가운데</option>
224 <option value="full" <?php selected($social_share_alignment, 'full'); ?> class="popup-only">가로 최대</option>
225 <option value="inline" <?php selected($social_share_alignment, 'inline'); ?>>인라인</option>
226 </select>
227 </div>
228 </div>
229 <div class="presslearn-card-body-row">
230 <div class="presslearn-card-body-row-item grid-left">
231 <h3>소�
232 � 공유 숏코드 복사</h3>
233 </div>
234 <div class="presslearn-card-body-row-item grid-right" style="display: flex; align-items: center; justify-content: end; gap: 10px;">
235 <textarea name="social_share_shortcode" id="social-share-shortcode" class="regular-text" style="height: 38px;" readonly><?php echo esc_textarea(presslearn_get_social_share_shortcode()); ?></textarea>
236 <button type="button" class="point-btn" id="copy-social-share-shortcode">복사하기</button>
237 </div>
238 </div>
239 </form>
240 </div>
241 <div class="presslearn-card-footer">
242 <div class="presslearn-card-footer-item grid-left">
243 <span class="tip_button">카카오톡 디벨로퍼스에서 발급받은 Javascript KEY를 �
244 력해주세요.</span>
245 </div>
246 <div class="presslearn-card-footer-item grid-right">
247 <button type="submit" class="point-btn" form="social-share-settings-form">저장하기</button>
248 </div>
249 </div>
250 </div>
251 </div>
252