| 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_dynamic_banner']) && isset($_POST['enable'])) { |
| 14 |
check_admin_referer('presslearn_toggle_dynamic_banner_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_dynamic_banner_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_dynamic_banner_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 === 'dynamic_banner' && ($enable === 'yes' || $enable === 'no')) { |
| 35 |
update_option('presslearn_dynamic_banner_enabled', $enable); |
| 36 |
$updated = true; |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
$dynamic_banner_enabled = get_option('presslearn_dynamic_banner_enabled', 'no'); |
| 41 |
|
| 42 |
wp_enqueue_media(); |
| 43 |
|
| 44 |
?> |
| 45 |
<div class="presslearn-header"> |
| 46 |
<div class="presslearn-header-logo"> |
| 47 |
<img src="<?php echo esc_url(PRESSLEARN_PLUGIN_URL); ?>assets/images/logo.png" alt="PressLearn Logo"> |
| 48 |
<h1>다이나믹 배너</h1> |
| 49 |
</div> |
| 50 |
<div class="presslearn-header-status"> |
| 51 |
<?php if ($dynamic_banner_enabled === 'yes'): ?> |
| 52 |
<div class="presslearn-header-status-item status-activate"> |
| 53 |
<p>기능이 활성화되었습니다.</p> |
| 54 |
</div> |
| 55 |
<?php else: ?> |
| 56 |
<div class="presslearn-header-status-item status-deactivate"> |
| 57 |
<p>기능이 비활성화 상태� |
| 58 |
니다.</p> |
| 59 |
</div> |
| 60 |
<?php endif; ?> |
| 61 |
</div> |
| 62 |
</div> |
| 63 |
|
| 64 |
<div class="wrap"> |
| 65 |
|
| 66 |
<div class="presslearn-breadcrumbs-wrap"> |
| 67 |
<div class="presslearn-breadcrumbs"> |
| 68 |
<span>대시보드</span> |
| 69 |
<span class="divider">/</span> |
| 70 |
<span class="active">다이나믹 배너</span> |
| 71 |
</div> |
| 72 |
</div> |
| 73 |
|
| 74 |
<?php if (isset($updated) && $updated): ?> |
| 75 |
<div class="notice notice-success inline"> |
| 76 |
<p>설정 정보가 성공적으로 저장되었습니다.</p> |
| 77 |
</div> |
| 78 |
<?php endif; ?> |
| 79 |
|
| 80 |
<div class="presslearn-card"> |
| 81 |
<div class="presslearn-card-header"> |
| 82 |
<h2>다이나믹 배너</h2> |
| 83 |
<p>다이나믹 배너는 다양한 방식으로 자체 광고 및 어필리에이트 광고 세� |
| 84 |
을 도와줍니다.</p> |
| 85 |
</div> |
| 86 |
<div class="presslearn-card-body"> |
| 87 |
<div class="presslearn-card-body-row"> |
| 88 |
<div class="presslearn-card-body-row-item grid-left"> |
| 89 |
<h3>플러그인 기능 활성화</h3> |
| 90 |
</div> |
| 91 |
<div class="presslearn-card-body-row-item grid-right"> |
| 92 |
<form method="post" action="" id="dynamic-banner-toggle-form"> |
| 93 |
<?php wp_nonce_field('presslearn_toggle_dynamic_banner_nonce'); ?> |
| 94 |
<input type="hidden" name="presslearn_toggle_dynamic_banner" value="1"> |
| 95 |
<input type="hidden" name="enable" id="dynamic-banner-enable-value" value="<?php echo esc_attr($dynamic_banner_enabled === 'yes' ? 'no' : 'yes'); ?>"> |
| 96 |
|
| 97 |
<label class="switch"> |
| 98 |
<input type="checkbox" <?php echo esc_attr($dynamic_banner_enabled === 'yes' ? 'checked' : ''); ?> onchange="document.getElementById('dynamic-banner-enable-value').value = this.checked ? 'yes' : 'no'; document.getElementById('dynamic-banner-toggle-form').submit();"> |
| 99 |
<span class="slider round"></span> |
| 100 |
</label> |
| 101 |
</form> |
| 102 |
</div> |
| 103 |
</div> |
| 104 |
<div class="presslearn-card-body-row"> |
| 105 |
<div class="presslearn-card-body-row-item grid-left"> |
| 106 |
<h3>다이나믹 배너 설정</h3> |
| 107 |
</div> |
| 108 |
<div class="presslearn-card-body-row-item grid-right"> |
| 109 |
<button type="button" class="secondary-btn" id="open-shortcode-modal">숏 코드 관리</button> |
| 110 |
</div> |
| 111 |
</div> |
| 112 |
</div> |
| 113 |
<div class="presslearn-card-footer"> |
| 114 |
<div class="presslearn-card-footer-item grid-left"> |
| 115 |
<span class="tip_button">배너 별 숏 코드를 관리할 수 있습니다.</span> |
| 116 |
</div> |
| 117 |
<div class="presslearn-card-footer-item grid-right"> |
| 118 |
<button type="submit" class="point-btn" form="dynamic-banner-settings-form">저장하기</button> |
| 119 |
</div> |
| 120 |
</div> |
| 121 |
</div> |
| 122 |
|
| 123 |
<div id="shortcode-modal" class="presslearn-modal" style="display: none;"> |
| 124 |
<div class="presslearn-modal-content"> |
| 125 |
<div class="presslearn-modal-header"> |
| 126 |
<h3>다이나믹 배너 캠페인 관리</h3> |
| 127 |
<span class="presslearn-modal-close">×</span> |
| 128 |
</div> |
| 129 |
<div class="presslearn-modal-body"> |
| 130 |
<div class="campaign-tabs"> |
| 131 |
<button class="campaign-tab active" data-tab="campaigns">캠페인 목록</button> |
| 132 |
<button class="campaign-tab" data-tab="add-campaign">새 캠페인 추가</button> |
| 133 |
</div> |
| 134 |
|
| 135 |
<div class="campaign-tab-content active" id="campaigns-tab"> |
| 136 |
<table class="widefat campaign-table"> |
| 137 |
<thead> |
| 138 |
<tr> |
| 139 |
<th>캠페인 이름</th> |
| 140 |
<th>숏코드</th> |
| 141 |
<th>관리</th> |
| 142 |
</tr> |
| 143 |
</thead> |
| 144 |
<tbody id="campaign-list"> |
| 145 |
<tr> |
| 146 |
<td colspan="4" class="no-campaigns">등록된 캠페인이 없습니다. 새 캠페인을 추가해주세요.</td> |
| 147 |
</tr> |
| 148 |
</tbody> |
| 149 |
</table> |
| 150 |
</div> |
| 151 |
|
| 152 |
<div class="campaign-tab-content" id="add-campaign-tab"> |
| 153 |
<form id="add-campaign-form"> |
| 154 |
<div class="settings-form-row"> |
| 155 |
<label for="campaign_name">캠페인 이름</label> |
| 156 |
<input type="text" id="campaign_name" name="campaign_name" class="regular-input-form" placeholder="캠페인 이름을 � |
| 157 |
력하세요"> |
| 158 |
</div> |
| 159 |
|
| 160 |
<div class="settings-form-row"> |
| 161 |
<label for="banner_type">배너 유형</label> |
| 162 |
<div class="banner-type-selector"> |
| 163 |
<label class="banner-type-option"> |
| 164 |
<input type="radio" name="banner_type" value="custom" checked> |
| 165 |
<div class="banner-type-btn">자체광고</div> |
| 166 |
</label> |
| 167 |
<label class="banner-type-option"> |
| 168 |
<input type="radio" name="banner_type" value="iframe"> |
| 169 |
<div class="banner-type-btn">iframe 방식</div> |
| 170 |
</label> |
| 171 |
</div> |
| 172 |
</div> |
| 173 |
|
| 174 |
<div id="custom-banner-fields"> |
| 175 |
<div class="settings-form-row"> |
| 176 |
<label for="campaign_banner_url">배너 이미지</label> |
| 177 |
<div class="banner-upload-container"> |
| 178 |
<input type="text" id="campaign_banner_url" name="campaign_banner_url" class="regular-input-form" placeholder="이미지를 � |
| 179 |
로드하세요" readonly> |
| 180 |
<button type="button" id="upload-banner" class="secondary-btn">이미지 선택</button> |
| 181 |
</div> |
| 182 |
<div id="banner-preview" class="banner-preview" style="display: none;"> |
| 183 |
<img src="" alt="배너 미리보기"> |
| 184 |
</div> |
| 185 |
<div class="file-upload-wrapper"> |
| 186 |
<input type="file" id="banner_image_file" accept="image/*" class="file-upload-input" style="display: none;"> |
| 187 |
<div class="file-upload-info" style="display: none;"> |
| 188 |
<span class="file-name"></span> |
| 189 |
<div class="file-upload-progress"> |
| 190 |
<div class="progress-bar"></div> |
| 191 |
</div> |
| 192 |
</div> |
| 193 |
</div> |
| 194 |
<p class="form-hint">이미지 선택 버튼을 클릭하여 배너 이미지를 � |
| 195 |
로드하세요.</p> |
| 196 |
</div> |
| 197 |
|
| 198 |
<div class="settings-form-row"> |
| 199 |
<label for="campaign_cover_banner_url">커버 배너 이미지</label> |
| 200 |
<div class="banner-upload-container"> |
| 201 |
<input type="text" id="campaign_cover_banner_url" name="campaign_cover_banner_url" class="regular-input-form" placeholder="이미지를 � |
| 202 |
로드하세요" readonly> |
| 203 |
<button type="button" id="upload-cover-banner" class="secondary-btn">이미지 선택</button> |
| 204 |
</div> |
| 205 |
<div id="cover-banner-preview" class="banner-preview" style="display: none;"> |
| 206 |
<img src="" alt="커버 배너 미리보기"> |
| 207 |
</div> |
| 208 |
<div class="file-upload-wrapper"> |
| 209 |
<input type="file" id="cover_banner_image_file" accept="image/*" class="file-upload-input" style="display: none;"> |
| 210 |
<div class="file-upload-info" style="display: none;"> |
| 211 |
<span class="file-name"></span> |
| 212 |
<div class="file-upload-progress"> |
| 213 |
<div class="progress-bar"></div> |
| 214 |
</div> |
| 215 |
</div> |
| 216 |
</div> |
| 217 |
<p class="form-hint">이미지 선택 버튼을 클릭하여 커버 배너 이미지를 � |
| 218 |
로드하세요.</p> |
| 219 |
</div> |
| 220 |
|
| 221 |
<div class="settings-form-row banner-dimensions"> |
| 222 |
<div class="dimension-field"> |
| 223 |
<label for="banner_width">가로 너비 <span class="required">*</span></label> |
| 224 |
<div class="input-with-suffix" style="display: flex;"> |
| 225 |
<input type="number" id="banner_width" name="banner_width" class="regular-input-form" placeholder="가로 너비" min="1" max="2000" required> |
| 226 |
<span class="input-suffix">px</span> |
| 227 |
</div> |
| 228 |
</div> |
| 229 |
<div class="dimension-field"> |
| 230 |
<label for="banner_height">세로 높이 <span class="required">*</span></label> |
| 231 |
<div class="input-with-suffix" style="display: flex;"> |
| 232 |
<input type="number" id="banner_height" name="banner_height" class="regular-input-form" placeholder="세로 높이" min="1" max="2000" required> |
| 233 |
<span class="input-suffix">px</span> |
| 234 |
</div> |
| 235 |
</div> |
| 236 |
</div> |
| 237 |
|
| 238 |
<div class="settings-form-row"> |
| 239 |
<label for="campaign_link">링크 URL</label> |
| 240 |
<input type="url" id="campaign_link" name="campaign_link" class="regular-input-form" placeholder="배너 클릭 시 이동할 URL"> |
| 241 |
</div> |
| 242 |
</div> |
| 243 |
|
| 244 |
<div id="iframe-banner-fields" style="display: none;"> |
| 245 |
<div class="settings-form-row"> |
| 246 |
<label for="iframe_code">iframe 코드</label> |
| 247 |
<div class="code-editor-container"> |
| 248 |
<div class="code-editor-header"> |
| 249 |
<span>HTML</span> |
| 250 |
</div> |
| 251 |
<textarea id="iframe_code" name="iframe_code" class="code-editor" rows="8" placeholder="<iframe src="https://example.com/ad" width="300" height="250"></iframe>"></textarea> |
| 252 |
</div> |
| 253 |
<p class="form-hint">알리 익스프레스, 쿠팡 파트너스 등의 광고 코드를 붙여넣으세요.</p> |
| 254 |
</div> |
| 255 |
|
| 256 |
<div class="settings-form-row"> |
| 257 |
<label for="iframe_link_url">이동 URL (선택사항)</label> |
| 258 |
<input type="url" id="iframe_link_url" name="iframe_link_url" class="regular-input-form" placeholder="배너 클릭 시 이동할 URL (예: https://example.com)"> |
| 259 |
<p class="form-hint">iframe 클릭 시 이동할 URL을 � |
| 260 |
력하세요. � |
| 261 |
력하지 않으면 iframe의 src 주소로 이동합니다.</p> |
| 262 |
</div> |
| 263 |
|
| 264 |
<div class="settings-form-row"> |
| 265 |
<label for="iframe_campaign_cover_banner_url">커버 배너 이미지</label> |
| 266 |
<div class="banner-upload-container"> |
| 267 |
<input type="text" id="iframe_campaign_cover_banner_url" name="iframe_campaign_cover_banner_url" class="regular-input-form" placeholder="이미지를 � |
| 268 |
로드하세요" readonly> |
| 269 |
<button type="button" id="iframe-upload-cover-banner" class="secondary-btn">이미지 선택</button> |
| 270 |
</div> |
| 271 |
<div id="iframe-cover-banner-preview" class="banner-preview" style="display: none;"> |
| 272 |
<img src="" alt="커버 배너 미리보기"> |
| 273 |
</div> |
| 274 |
<div class="file-upload-wrapper"> |
| 275 |
<input type="file" id="iframe_cover_banner_image_file" accept="image/*" class="file-upload-input" style="display: none;"> |
| 276 |
<div class="file-upload-info" style="display: none;"> |
| 277 |
<span class="file-name"></span> |
| 278 |
<div class="file-upload-progress"> |
| 279 |
<div class="progress-bar"></div> |
| 280 |
</div> |
| 281 |
</div> |
| 282 |
</div> |
| 283 |
<p class="form-hint">이미지 선택 버튼을 클릭하여 커버 배너 이미지를 � |
| 284 |
로드하세요.</p> |
| 285 |
</div> |
| 286 |
|
| 287 |
<div class="settings-form-row banner-dimensions"> |
| 288 |
<div class="dimension-field"> |
| 289 |
<label for="iframe_width">가로 너비 <span class="required">*</span></label> |
| 290 |
<div class="input-with-suffix" style="display: flex;"> |
| 291 |
<input type="number" id="iframe_width" name="iframe_width" class="regular-input-form" placeholder="가로 너비" min="1" max="2000"> |
| 292 |
<span class="input-suffix">px</span> |
| 293 |
</div> |
| 294 |
</div> |
| 295 |
<div class="dimension-field"> |
| 296 |
<label for="iframe_height">세로 높이 <span class="required">*</span></label> |
| 297 |
<div class="input-with-suffix" style="display: flex;"> |
| 298 |
<input type="number" id="iframe_height" name="iframe_height" class="regular-input-form" placeholder="세로 높이" min="1" max="2000"> |
| 299 |
<span class="input-suffix">px</span> |
| 300 |
</div> |
| 301 |
</div> |
| 302 |
</div> |
| 303 |
</div> |
| 304 |
|
| 305 |
<div class="form-actions"> |
| 306 |
<button type="submit" class="point-btn">캠페인 추가</button> |
| 307 |
</div> |
| 308 |
</form> |
| 309 |
</div> |
| 310 |
</div> |
| 311 |
<div class="presslearn-modal-footer"> |
| 312 |
<button type="button" id="close-modal-button" class="secondary-btn">닫기</button> |
| 313 |
</div> |
| 314 |
</div> |
| 315 |
</div> |
| 316 |
|
| 317 |
</div> |