| 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_scroll_depth']) && isset($_POST['enable'])) { |
| 14 |
check_admin_referer('presslearn_toggle_scroll_depth_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_scroll_depth_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_scroll_depth_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 === 'scroll_depth' && ($enable === 'yes' || $enable === 'no')) { |
| 35 |
update_option('presslearn_scroll_depth_enabled', $enable); |
| 36 |
$updated = true; |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
if (isset($_POST['save_scroll_settings'])) { |
| 41 |
check_admin_referer('presslearn_save_scroll_settings_nonce'); |
| 42 |
|
| 43 |
if (current_user_can('manage_options')) { |
| 44 |
$scroll_percentage = isset($_POST['scroll_percentage']) ? intval(wp_unslash($_POST['scroll_percentage'])) : 50; |
| 45 |
if ($scroll_percentage < 1) $scroll_percentage = 1; |
| 46 |
if ($scroll_percentage > 100) $scroll_percentage = 100; |
| 47 |
|
| 48 |
$popup_animation = isset($_POST['popup_animation']) ? sanitize_text_field(wp_unslash($_POST['popup_animation'])) : 'fade'; |
| 49 |
$repeat_setting = isset($_POST['repeat_setting']) ? sanitize_text_field(wp_unslash($_POST['repeat_setting'])) : 'once'; |
| 50 |
|
| 51 |
update_option('presslearn_scroll_percentage', $scroll_percentage); |
| 52 |
update_option('presslearn_popup_animation', $popup_animation); |
| 53 |
update_option('presslearn_repeat_setting', $repeat_setting); |
| 54 |
|
| 55 |
if (isset($_POST['popup_content'])) { |
| 56 |
$popup_content = wp_kses_post(wp_unslash($_POST['popup_content'])); |
| 57 |
update_option('presslearn_popup_content', $popup_content); |
| 58 |
} |
| 59 |
|
| 60 |
$settings_updated = true; |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
$scroll_depth_enabled = get_option('presslearn_scroll_depth_enabled', 'no'); |
| 65 |
$scroll_percentage = get_option('presslearn_scroll_percentage', 50); |
| 66 |
$popup_animation = get_option('presslearn_popup_animation', 'fade'); |
| 67 |
$repeat_setting = get_option('presslearn_repeat_setting', 'once'); |
| 68 |
$popup_content = get_option('presslearn_popup_content', ''); |
| 69 |
|
| 70 |
wp_enqueue_editor(); |
| 71 |
wp_enqueue_media(); |
| 72 |
|
| 73 |
?> |
| 74 |
<div class="presslearn-header"> |
| 75 |
<div class="presslearn-header-logo"> |
| 76 |
<img src="<?php echo esc_url(PRESSLEARN_PLUGIN_URL); ?>assets/images/logo.png" alt="PressLearn Logo"> |
| 77 |
<h1>스마트 스크롤</h1> |
| 78 |
</div> |
| 79 |
<div class="presslearn-header-status"> |
| 80 |
<?php if ($scroll_depth_enabled === 'yes'): ?> |
| 81 |
<div class="presslearn-header-status-item status-activate"> |
| 82 |
<p>기능이 활성화되었습니다.</p> |
| 83 |
</div> |
| 84 |
<?php else: ?> |
| 85 |
<div class="presslearn-header-status-item status-deactivate"> |
| 86 |
<p>기능이 비활성화 상태� |
| 87 |
니다.</p> |
| 88 |
</div> |
| 89 |
<?php endif; ?> |
| 90 |
</div> |
| 91 |
</div> |
| 92 |
|
| 93 |
<div class="wrap"> |
| 94 |
|
| 95 |
<div class="presslearn-breadcrumbs-wrap"> |
| 96 |
<div class="presslearn-breadcrumbs"> |
| 97 |
<span>대시보드</span> |
| 98 |
<span class="divider">/</span> |
| 99 |
<span class="active">스마트 스크롤</span> |
| 100 |
</div> |
| 101 |
</div> |
| 102 |
|
| 103 |
<?php if (isset($settings_updated) && $settings_updated): ?> |
| 104 |
<div class="notice notice-success inline"> |
| 105 |
<p>설정 정보가 성공적으로 저장되었습니다.</p> |
| 106 |
</div> |
| 107 |
<?php endif; ?> |
| 108 |
|
| 109 |
<div class="presslearn-card"> |
| 110 |
<div class="presslearn-card-header"> |
| 111 |
<h2>스마트 스크롤</h2> |
| 112 |
<p>스크롤에 따라서 자동으로 팝� |
| 113 |
을 띄워줄 수 있는 기능� |
| 114 |
니다. 단일 캠페인만 운영 가능합니다.</p> |
| 115 |
</div> |
| 116 |
<div class="presslearn-card-body"> |
| 117 |
<div class="presslearn-card-body-row"> |
| 118 |
<div class="presslearn-card-body-row-item grid-left"> |
| 119 |
<h3>플러그인 기능 활성화</h3> |
| 120 |
</div> |
| 121 |
<div class="presslearn-card-body-row-item grid-right"> |
| 122 |
<form method="post" action="" id="scroll-depth-toggle-form"> |
| 123 |
<?php wp_nonce_field('presslearn_toggle_scroll_depth_nonce'); ?> |
| 124 |
<input type="hidden" name="presslearn_toggle_scroll_depth" value="1"> |
| 125 |
<input type="hidden" name="enable" id="scroll-depth-enable-value" value="<?php echo esc_attr($scroll_depth_enabled === 'yes' ? 'no' : 'yes'); ?>"> |
| 126 |
|
| 127 |
<label class="switch"> |
| 128 |
<input type="checkbox" <?php echo esc_attr($scroll_depth_enabled === 'yes' ? 'checked' : ''); ?> onchange="document.getElementById('scroll-depth-enable-value').value = this.checked ? 'yes' : 'no'; document.getElementById('scroll-depth-toggle-form').submit();"> |
| 129 |
<span class="slider round"></span> |
| 130 |
</label> |
| 131 |
</form> |
| 132 |
</div> |
| 133 |
</div> |
| 134 |
<form method="post" action="" id="scroll-settings-form"> |
| 135 |
<?php wp_nonce_field('presslearn_save_scroll_settings_nonce'); ?> |
| 136 |
<input type="hidden" name="save_scroll_settings" value="1"> |
| 137 |
<div class="presslearn-card-body-row"> |
| 138 |
<div class="presslearn-card-body-row-item grid-left"> |
| 139 |
<h3>스크롤 퍼센트</h3> |
| 140 |
</div> |
| 141 |
<div class="presslearn-card-body-row-item grid-right"> |
| 142 |
<input type="number" class="regular-text" name="scroll_percentage" value="<?php echo esc_attr($scroll_percentage); ?>" min="1" max="100"> |
| 143 |
</div> |
| 144 |
</div> |
| 145 |
<div class="presslearn-card-body-row"> |
| 146 |
<div class="presslearn-card-body-row-item grid-left"> |
| 147 |
<h3>팝� |
| 148 |
애니메이� |
| 149 |
�</h3> |
| 150 |
</div> |
| 151 |
<div class="presslearn-card-body-row-item grid-right"> |
| 152 |
<select name="popup_animation" class="regular-text"> |
| 153 |
<option value="fade" <?php selected($popup_animation, 'fade'); ?>>Fade</option> |
| 154 |
<option value="slide" <?php selected($popup_animation, 'slide'); ?>>Slide</option> |
| 155 |
<option value="zoom" <?php selected($popup_animation, 'zoom'); ?>>Zoom</option> |
| 156 |
</select> |
| 157 |
</div> |
| 158 |
</div> |
| 159 |
<div class="presslearn-card-body-row"> |
| 160 |
<div class="presslearn-card-body-row-item grid-left"> |
| 161 |
<h3>반복 설정</h3> |
| 162 |
</div> |
| 163 |
<div class="presslearn-card-body-row-item grid-right"> |
| 164 |
<select name="repeat_setting" class="regular-text"> |
| 165 |
<option value="once" <?php selected($repeat_setting, 'once'); ?>>브라우저 당 한 번만 표시</option> |
| 166 |
<option value="loop" <?php selected($repeat_setting, 'loop'); ?>>반복 표시</option> |
| 167 |
</select> |
| 168 |
</div> |
| 169 |
</div> |
| 170 |
<div class="presslearn-card-body-row"> |
| 171 |
<div class="presslearn-card-body-row-item grid-left"> |
| 172 |
<h3>팝� |
| 173 |
표시 내용</h3> |
| 174 |
</div> |
| 175 |
<div class="presslearn-card-body-row-item grid-right"> |
| 176 |
<input type="hidden" id="popup_content_hidden" name="popup_content" value="<?php echo esc_attr($popup_content); ?>"> |
| 177 |
<button type="button" id="open-popup-editor" class="point-btn">내용 설정하기</button> |
| 178 |
<?php if (!empty($popup_content)): ?> |
| 179 |
<button type="button" id="preview-popup" class="secondary-btn" style="margin-left: 5px;">팝� |
| 180 |
미리보기</button> |
| 181 |
<?php endif; ?> |
| 182 |
</div> |
| 183 |
</div> |
| 184 |
</form> |
| 185 |
</div> |
| 186 |
<div class="presslearn-card-footer"> |
| 187 |
<div class="presslearn-card-footer-item grid-left"> |
| 188 |
<span class="tip_button">팝� |
| 189 |
내용을 저장하고 미리보기를 클릭하여 확인 가능합니다.</span> |
| 190 |
</div> |
| 191 |
<div class="presslearn-card-footer-item grid-right"> |
| 192 |
<button type="submit" class="point-btn" form="scroll-settings-form">저장하기</button> |
| 193 |
</div> |
| 194 |
</div> |
| 195 |
</div> |
| 196 |
|
| 197 |
<div id="popup-editor-modal" class="popup-editor-overlay" style="display:none;"> |
| 198 |
<div class="popup-editor-content"> |
| 199 |
<div class="popup-editor-header"> |
| 200 |
<h2>팝� |
| 201 |
내용 설정</h2> |
| 202 |
<button type="button" class="close-popup-editor">×</button> |
| 203 |
</div> |
| 204 |
<div class="popup-editor-body"> |
| 205 |
<?php |
| 206 |
$editor_settings = array( |
| 207 |
'textarea_name' => 'popup_content_editor', |
| 208 |
'textarea_rows' => 20, |
| 209 |
'editor_height' => 400, |
| 210 |
'media_buttons' => true, |
| 211 |
'tinymce' => array( |
| 212 |
'plugins' => 'lists,paste,tabfocus,wplink,wordpress', |
| 213 |
'paste_as_text' => true, |
| 214 |
'paste_auto_cleanup_on_paste' => true, |
| 215 |
'paste_remove_spans' => true, |
| 216 |
'paste_remove_styles' => true, |
| 217 |
'paste_remove_styles_if_webkit' => true, |
| 218 |
'paste_strip_class_attributes' => true, |
| 219 |
), |
| 220 |
); |
| 221 |
wp_editor($popup_content, 'popup_content_editor', $editor_settings); |
| 222 |
?> |
| 223 |
</div> |
| 224 |
<div class="popup-editor-footer"> |
| 225 |
<button type="button" class="button button-secondary close-popup-editor">취소</button> |
| 226 |
<button type="button" class="button button-primary save-popup-content">적용하기</button> |
| 227 |
</div> |
| 228 |
</div> |
| 229 |
</div> |
| 230 |
|
| 231 |
<div id="popup-preview-modal" class="popup-preview-overlay" style="display:none;"> |
| 232 |
<button type="button" class="close-popup-preview">×</button> |
| 233 |
<div class="popup-preview-container"> |
| 234 |
<div class="popup-preview-window"> |
| 235 |
<div class="popup-preview-body"> |
| 236 |
<?php echo wp_kses_post(wpautop($popup_content)); ?> |
| 237 |
</div> |
| 238 |
</div> |
| 239 |
</div> |
| 240 |
</div> |
| 241 |
</div> |
| 242 |
|