| 1 |
<?php |
| 2 |
|
| 3 |
namespace Getwid; |
| 4 |
|
| 5 |
class SettingsPage { |
| 6 |
|
| 7 |
public function __construct() { |
| 8 |
$this->addActions(); |
| 9 |
} |
| 10 |
|
| 11 |
protected function addActions() { |
| 12 |
add_action( 'admin_menu', array( $this, 'registerPage' ) ); |
| 13 |
add_action( 'admin_init', array( $this, 'registerSettingsGroups' ) ); |
| 14 |
add_action( 'admin_init', array( $this, 'registerFields' ) ); |
| 15 |
add_action( 'admin_init', array( $this, 'checkInstagramQueryURL' ) ); |
| 16 |
} |
| 17 |
|
| 18 |
public function getSettingsGroups() { |
| 19 |
return array( |
| 20 |
'general' => array( |
| 21 |
'title' => __( 'General', 'getwid' ), |
| 22 |
'sections' => array( |
| 23 |
'contact_from' => __( 'Contact Form Settings', 'getwid' ), |
| 24 |
), |
| 25 |
), |
| 26 |
'appearance' => array( |
| 27 |
'title' => __( 'Appearance', 'getwid' ), |
| 28 |
'sections' => array(), |
| 29 |
), |
| 30 |
'blocks' => array( |
| 31 |
'title' => __( 'Blocks', 'getwid' ), |
| 32 |
'sections' => array(), |
| 33 |
), |
| 34 |
'post_templates' => array( |
| 35 |
'title' => __( 'Post Templates', 'getwid' ), |
| 36 |
'sections' => array(), |
| 37 |
), |
| 38 |
); |
| 39 |
} |
| 40 |
|
| 41 |
public function registerPage() { |
| 42 |
add_options_page( |
| 43 |
esc_html_x( 'Getwid Settings', 'Settings page title', 'getwid' ), |
| 44 |
esc_html_x( 'Getwid', 'Settings page title(in menu)', 'getwid' ), |
| 45 |
'manage_options', |
| 46 |
'getwid', |
| 47 |
array( $this, 'renderPage' ) |
| 48 |
); |
| 49 |
} |
| 50 |
|
| 51 |
public function registerSettingsGroups() { |
| 52 |
$settings_groups = $this->getSettingsGroups(); |
| 53 |
|
| 54 |
foreach ( $settings_groups as $id => $group ) { |
| 55 |
add_settings_section( |
| 56 |
'getwid_' . $id, |
| 57 |
'', |
| 58 |
'', |
| 59 |
'getwid_' . $id |
| 60 |
); |
| 61 |
|
| 62 |
foreach ( $group['sections'] as $section_id => $section ) { |
| 63 |
add_settings_section( |
| 64 |
'getwid_' . $section_id, |
| 65 |
$section, |
| 66 |
'', |
| 67 |
'getwid_' . $id |
| 68 |
); |
| 69 |
} |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
public function renderPage() { |
| 74 |
if ( ! current_user_can( 'manage_options' ) ) { |
| 75 |
return; |
| 76 |
} |
| 77 |
|
| 78 |
$active_tab_id = $this->getActiveTabID(); |
| 79 |
$settings_groups = $this->getSettingsGroups(); |
| 80 |
|
| 81 |
settings_errors( 'getwid_settings_errors' ); |
| 82 |
?> |
| 83 |
<div class="wrap"> |
| 84 |
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
| 85 |
|
| 86 |
<h2 class="nav-tab-wrapper"> |
| 87 |
<?php |
| 88 |
foreach ( $settings_groups as $tab_id => $tab ) : |
| 89 |
$active_tab_class = $tab_id == $active_tab_id ? 'nav-tab-active' : ''; |
| 90 |
?> |
| 91 |
<a href="<?php echo esc_url( $this->getTabUrl( $tab_id ) ); ?>" class="nav-tab <?php echo esc_attr( $active_tab_class ); ?>"> |
| 92 |
<?php echo esc_html( $tab['title'] ); ?> |
| 93 |
</a> |
| 94 |
<?php |
| 95 |
endforeach; |
| 96 |
?> |
| 97 |
</h2> |
| 98 |
<?php |
| 99 |
if ( 'post_templates' == $active_tab_id ) : |
| 100 |
|
| 101 |
$this->renderPostTemplatesTab(); |
| 102 |
|
| 103 |
else : |
| 104 |
?> |
| 105 |
<form action="options.php" method="post"> |
| 106 |
<?php |
| 107 |
settings_fields( 'getwid_' . $active_tab_id ); |
| 108 |
do_settings_sections( 'getwid_' . $active_tab_id ); |
| 109 |
|
| 110 |
submit_button( esc_html__( 'Save Changes', 'getwid' ) ); |
| 111 |
?> |
| 112 |
</form> |
| 113 |
<?php |
| 114 |
endif; |
| 115 |
?> |
| 116 |
</div> |
| 117 |
<?php |
| 118 |
} |
| 119 |
|
| 120 |
public function getwid_instagram_notice_success() { |
| 121 |
?> |
| 122 |
<div class="notice notice-success"> |
| 123 |
<p><?php esc_html_e( 'Instagram: access token updated.', 'getwid' ); ?></p> |
| 124 |
</div> |
| 125 |
<?php |
| 126 |
} |
| 127 |
|
| 128 |
public function getwid_instagram_notice_error() { |
| 129 |
?> |
| 130 |
<div class="notice notice-error"> |
| 131 |
<p><?php esc_html_e( 'Instagram: access denied.', 'getwid' ); ?></p> |
| 132 |
</div> |
| 133 |
<?php |
| 134 |
} |
| 135 |
|
| 136 |
public function checkInstagramQueryURL() { |
| 137 |
global $pagenow; |
| 138 |
|
| 139 |
if ( $pagenow == 'options-general.php' && isset( $_GET['instagram-token'] ) && isset( $_GET['nonce'] ) ) { |
| 140 |
|
| 141 |
if ( wp_verify_nonce( sanitize_key( $_GET['nonce'] ), 'getwid_nonce_save_instagram_token' ) && current_user_can( 'manage_options' ) ) { |
| 142 |
|
| 143 |
// Update token |
| 144 |
update_option( 'getwid_instagram_token', sanitize_text_field( wp_unslash( $_GET['instagram-token'] ) ) ); |
| 145 |
// Delete cache data |
| 146 |
delete_transient( 'getwid_instagram_response_data' ); |
| 147 |
// Schedule token refresh |
| 148 |
getwid()->instagramTokenManager()->schedule_token_refresh_event(); |
| 149 |
|
| 150 |
$redirect_url = add_query_arg( |
| 151 |
array( |
| 152 |
'getwid-instagram-success' => true, |
| 153 |
), |
| 154 |
$this->getTabUrl( 'general' ) |
| 155 |
); |
| 156 |
} else { |
| 157 |
$redirect_url = add_query_arg( |
| 158 |
array( |
| 159 |
'instagram-error' => true, |
| 160 |
), |
| 161 |
$this->getTabUrl( 'general' ) |
| 162 |
); |
| 163 |
} |
| 164 |
|
| 165 |
wp_redirect( $redirect_url ); |
| 166 |
} |
| 167 |
|
| 168 |
if ( isset( $_GET['getwid-instagram-success'] ) ) { |
| 169 |
add_action( 'admin_notices', array( $this, 'getwid_instagram_notice_success' ) ); |
| 170 |
} |
| 171 |
|
| 172 |
if ( isset( $_GET['instagram-error'] ) ) { |
| 173 |
add_action( 'admin_notices', array( $this, 'getwid_instagram_notice_error' ) ); |
| 174 |
} |
| 175 |
} |
| 176 |
|
| 177 |
public function registerFields() { |
| 178 |
|
| 179 |
/* #region Section Content Width */ |
| 180 |
add_settings_field( |
| 181 |
'getwid_section_content_width', |
| 182 |
__( 'Section Content Width', 'getwid' ), |
| 183 |
array( $this, 'renderSectionContentWidth' ), |
| 184 |
'getwid_appearance', |
| 185 |
'getwid_appearance' |
| 186 |
); |
| 187 |
register_setting( |
| 188 |
'getwid_appearance', |
| 189 |
'getwid_section_content_width', |
| 190 |
array( |
| 191 |
'type' => 'number', |
| 192 |
'default' => '', |
| 193 |
) |
| 194 |
); |
| 195 |
/* #endregion */ |
| 196 |
|
| 197 |
/* #region Animation */ |
| 198 |
add_settings_field( |
| 199 |
'getwid_animation', |
| 200 |
__( 'Animation', 'getwid' ), |
| 201 |
array( $this, 'renderAnimation' ), |
| 202 |
'getwid_appearance', |
| 203 |
'getwid_appearance' |
| 204 |
); |
| 205 |
register_setting( |
| 206 |
'getwid_appearance', |
| 207 |
'getwid_smooth_animation', |
| 208 |
array( |
| 209 |
'type' => 'boolean', |
| 210 |
'default' => false, |
| 211 |
'sanitize_callback' => 'rest_sanitize_boolean', |
| 212 |
) |
| 213 |
); |
| 214 |
/* #endregion */ |
| 215 |
|
| 216 |
/* #region Instagram Access Token */ |
| 217 |
add_settings_field( |
| 218 |
'getwid_instagram_token', |
| 219 |
__( 'Instagram Access Token', 'getwid' ), |
| 220 |
array( $this, 'renderInstagramToken' ), |
| 221 |
'getwid_general', |
| 222 |
'getwid_general' |
| 223 |
); |
| 224 |
register_setting( |
| 225 |
'getwid_general', |
| 226 |
'getwid_instagram_token', |
| 227 |
array( |
| 228 |
'type' => 'text', |
| 229 |
'default' => '', |
| 230 |
) |
| 231 |
); |
| 232 |
/* #endregion */ |
| 233 |
|
| 234 |
/* #region Instagram Cache Timeout */ |
| 235 |
add_settings_field( |
| 236 |
'getwid_instagram_cache_timeout', |
| 237 |
__( 'Instagram Cache Timeout', 'getwid' ), |
| 238 |
array( $this, 'renderInstagramCacheTimeout' ), |
| 239 |
'getwid_general', |
| 240 |
'getwid_general' |
| 241 |
); |
| 242 |
register_setting( |
| 243 |
'getwid_general', |
| 244 |
'getwid_instagram_cache_timeout', |
| 245 |
array( |
| 246 |
'type' => 'number', |
| 247 |
'default' => 30, |
| 248 |
) |
| 249 |
); |
| 250 |
/* #endregion */ |
| 251 |
|
| 252 |
/* #region Google API Key */ |
| 253 |
add_settings_field( |
| 254 |
'getwid_google_api_key', |
| 255 |
__( 'Google Maps API Key', 'getwid' ), |
| 256 |
array( $this, 'renderGoogleApiKey' ), |
| 257 |
'getwid_general', |
| 258 |
'getwid_general' |
| 259 |
); |
| 260 |
register_setting( |
| 261 |
'getwid_general', |
| 262 |
'getwid_google_api_key', |
| 263 |
array( |
| 264 |
'type' => 'text', |
| 265 |
'default' => '', |
| 266 |
) |
| 267 |
); |
| 268 |
/* #endregion */ |
| 269 |
|
| 270 |
/* #region Recaptcha Site Key */ |
| 271 |
add_settings_field( |
| 272 |
'getwid_contact_form_recipient_email', |
| 273 |
__( 'Recipient Email Address', 'getwid' ), |
| 274 |
array( $this, 'renderContactFormRecipientEmail' ), |
| 275 |
'getwid_general', |
| 276 |
'getwid_contact_from' |
| 277 |
); |
| 278 |
register_setting( |
| 279 |
'getwid_general', |
| 280 |
'getwid_contact_form_recipient_email', |
| 281 |
array( |
| 282 |
'type' => 'text', |
| 283 |
'default' => '', |
| 284 |
) |
| 285 |
); |
| 286 |
/* #endregion */ |
| 287 |
|
| 288 |
/* #region Recaptcha Site Key */ |
| 289 |
add_settings_field( |
| 290 |
'getwid_recaptcha_v2_site_key', |
| 291 |
__( 'Recaptcha Site Key', 'getwid' ), |
| 292 |
array( $this, 'renderRecaptchaSiteKey' ), |
| 293 |
'getwid_general', |
| 294 |
'getwid_contact_from' |
| 295 |
); |
| 296 |
register_setting( |
| 297 |
'getwid_general', |
| 298 |
'getwid_recaptcha_v2_site_key', |
| 299 |
array( |
| 300 |
'type' => 'text', |
| 301 |
'default' => '', |
| 302 |
) |
| 303 |
); |
| 304 |
/* #endregion */ |
| 305 |
|
| 306 |
/* #region Recaptcha Secret Key */ |
| 307 |
add_settings_field( |
| 308 |
'getwid_recaptcha_v2_secret_key', |
| 309 |
__( 'Recaptcha Secret Key', 'getwid' ), |
| 310 |
array( $this, 'renderRecaptchaSecretKey' ), |
| 311 |
'getwid_general', |
| 312 |
'getwid_contact_from' |
| 313 |
); |
| 314 |
register_setting( |
| 315 |
'getwid_general', |
| 316 |
'getwid_recaptcha_v2_secret_key', |
| 317 |
array( |
| 318 |
'type' => 'text', |
| 319 |
'default' => '', |
| 320 |
) |
| 321 |
); |
| 322 |
/* #endregion */ |
| 323 |
|
| 324 |
/* #region Mailchimp Api Key */ |
| 325 |
add_settings_field( |
| 326 |
'getwid_mailchimp_api_key', |
| 327 |
__( 'Mailchimp API Key', 'getwid' ), |
| 328 |
array( $this, 'renderMailchimpApiKey' ), |
| 329 |
'getwid_general', |
| 330 |
'getwid_general' |
| 331 |
); |
| 332 |
register_setting( |
| 333 |
'getwid_general', |
| 334 |
'getwid_mailchimp_api_key', |
| 335 |
array( |
| 336 |
'type' => 'text', |
| 337 |
'default' => '', |
| 338 |
) |
| 339 |
); |
| 340 |
/* #endregion */ |
| 341 |
|
| 342 |
/* #region Disabled Blocks */ |
| 343 |
add_settings_field( |
| 344 |
'getwid_disabled_blocks', |
| 345 |
__( 'Disable Getwid Blocks', 'getwid' ), |
| 346 |
array( $this, 'renderDisabledBlocks' ), |
| 347 |
'getwid_blocks', |
| 348 |
'getwid_blocks' |
| 349 |
); |
| 350 |
|
| 351 |
$blocks = getwid()->blocksManager()->getBlocks(); |
| 352 |
|
| 353 |
foreach ( $blocks as $name => $block ) { |
| 354 |
$option_name = $block->get_disabled_option_key(); |
| 355 |
register_setting( |
| 356 |
'getwid_blocks', |
| 357 |
$option_name, |
| 358 |
array( |
| 359 |
'type' => 'boolean', |
| 360 |
'default' => false, |
| 361 |
'sanitize_callback' => 'rest_sanitize_boolean', |
| 362 |
) |
| 363 |
); |
| 364 |
} |
| 365 |
/* #endregion */ |
| 366 |
} |
| 367 |
|
| 368 |
public function renderSectionContentWidth() { |
| 369 |
|
| 370 |
$field_val = get_option( 'getwid_section_content_width', '' ); |
| 371 |
|
| 372 |
?> |
| 373 |
<input type="number" id="getwid_section_content_width" name="getwid_section_content_width" value="<?php echo esc_attr( $field_val ); ?>" /> |
| 374 |
<?php echo esc_html_x( 'px', 'pixels', 'getwid' ); ?> |
| 375 |
<p class="description"><?php echo esc_html__( 'Default width of the content area in the Section block. Leave empty to use $content_width set in your theme. Set 0 to disable this option and control it via CSS.', 'getwid' ); ?></p> |
| 376 |
<?php |
| 377 |
} |
| 378 |
|
| 379 |
public function renderInstagramToken() { |
| 380 |
|
| 381 |
$encryption = new StringEncryption(); |
| 382 |
$field_val = $encryption->decrypt( get_option( 'getwid_instagram_token', '' ) ); |
| 383 |
|
| 384 |
$connectURL = add_query_arg( |
| 385 |
array( 'nonce' => wp_create_nonce( 'getwid_nonce_save_instagram_token' ) ), |
| 386 |
admin_url( 'options-general.php' ) |
| 387 |
); |
| 388 |
|
| 389 |
$refreshURL = add_query_arg( |
| 390 |
array( 'nonce' => wp_create_nonce( 'getwid_nonce_save_instagram_token' ) ), |
| 391 |
admin_url( 'options-general.php' ) |
| 392 |
); |
| 393 |
|
| 394 |
?> |
| 395 |
<input type="text" id="getwid_instagram_token" name="getwid_instagram_token" class="regular-text" value="<?php echo esc_attr( $field_val ); ?>" /> |
| 396 |
<?php |
| 397 |
|
| 398 |
if ( ! empty( $field_val ) ) { |
| 399 |
|
| 400 |
try { |
| 401 |
|
| 402 |
$profile_data_json = wp_remote_get( |
| 403 |
'https://graph.instagram.com/me?fields=username&access_token=' . $field_val |
| 404 |
); |
| 405 |
|
| 406 |
if ( ( ! is_wp_error( $profile_data_json ) ) && ( 200 === wp_remote_retrieve_response_code( $profile_data_json ) ) ) { |
| 407 |
|
| 408 |
$profile_data = json_decode( $profile_data_json['body'] ); |
| 409 |
|
| 410 |
if ( json_last_error() === JSON_ERROR_NONE ) { |
| 411 |
|
| 412 |
if ( isset( $profile_data->username ) ) { |
| 413 |
|
| 414 |
echo '<p class="description">' . sprintf( |
| 415 |
//translators: %s is username or user id |
| 416 |
esc_html__( 'Account: %s', 'getwid' ), |
| 417 |
esc_html( $profile_data->username ) |
| 418 |
) . '<p>'; |
| 419 |
|
| 420 |
} elseif ( isset( $profile_data->id ) ) { |
| 421 |
|
| 422 |
echo '<p class="description">' . sprintf( |
| 423 |
//translators: %s is username or user id |
| 424 |
esc_html__( 'Account: %s', 'getwid' ), |
| 425 |
esc_html( $profile_data->id ) |
| 426 |
) . '</p>'; |
| 427 |
} |
| 428 |
} |
| 429 |
} |
| 430 |
} catch ( \Exception $profile_data_exception ) { |
| 431 |
|
| 432 |
echo esc_html( $profile_data_exception->getMessage() ); |
| 433 |
} |
| 434 |
} |
| 435 |
|
| 436 |
?> |
| 437 |
<p><a href=" |
| 438 |
<?php |
| 439 |
echo esc_url( |
| 440 |
'https://www.instagram.com/oauth/authorize?enable_fb_login=0&force_authentication=0&client_id=1815611002603068&redirect_uri=' . |
| 441 |
'https://api.getmotopress.com/get_instagram_token2.php&scope=instagram_business_basic&response_type=code&state=' . |
| 442 |
$connectURL |
| 443 |
); |
| 444 |
?> |
| 445 |
" class="button button-default"><?php echo esc_html__( 'Connect Instagram Account', 'getwid' ); ?></a> |
| 446 |
<?php |
| 447 |
if ( ! empty( $field_val ) ) { |
| 448 |
?> |
| 449 |
<a href=" |
| 450 |
<?php |
| 451 |
echo esc_url( |
| 452 |
'https://api.getmotopress.com/refresh_instagram_token2.php?access_token=' . $field_val . '&state=' . |
| 453 |
$refreshURL |
| 454 |
); |
| 455 |
?> |
| 456 |
" class="button button-default"><?php echo esc_html__( 'Refresh Access Token', 'getwid' ); ?></a> |
| 457 |
<?php |
| 458 |
} |
| 459 |
?> |
| 460 |
</p> |
| 461 |
<?php |
| 462 |
} |
| 463 |
|
| 464 |
public function renderInstagramCacheTimeout() { |
| 465 |
|
| 466 |
$field_val = get_option( 'getwid_instagram_cache_timeout' ); |
| 467 |
?> |
| 468 |
<input type="number" id="getwid_instagram_cache_timeout" name="getwid_instagram_cache_timeout" value="<?php echo esc_attr( $field_val ); ?>" /> |
| 469 |
<p class="description"><?php echo esc_html__( 'Time until expiration of media data in minutes. Setting to 0 means no expiration.', 'getwid' ); ?></p> |
| 470 |
<?php |
| 471 |
} |
| 472 |
|
| 473 |
public function renderGoogleApiKey() { |
| 474 |
|
| 475 |
$field_val = get_option( 'getwid_google_api_key', '' ); |
| 476 |
?> |
| 477 |
<input type="text" id="getwid_google_api_key" name="getwid_google_api_key" class="regular-text" value="<?php echo esc_attr( $field_val ); ?>" /> |
| 478 |
<?php |
| 479 |
} |
| 480 |
|
| 481 |
public function renderContactFormRecipientEmail() { |
| 482 |
|
| 483 |
$field_val = get_option( 'getwid_contact_form_recipient_email', '' ); |
| 484 |
$default_email = get_option( 'admin_email' ); |
| 485 |
|
| 486 |
?> |
| 487 |
<input type="text" id="getwid_contact_form_recipient_email" name="getwid_contact_form_recipient_email" class="regular-text" value="<?php echo esc_attr( $field_val ); ?>" placeholder="<?php echo esc_attr( $default_email ); ?>"/> |
| 488 |
<?php |
| 489 |
} |
| 490 |
|
| 491 |
public function renderRecaptchaSiteKey() { |
| 492 |
|
| 493 |
$field_val = get_option( 'getwid_recaptcha_v2_site_key', '' ); |
| 494 |
?> |
| 495 |
<input type="text" id="getwid_recaptcha_v2_site_key" name="getwid_recaptcha_v2_site_key" class="regular-text" value="<?php echo esc_attr( $field_val ); ?>" /> |
| 496 |
<?php |
| 497 |
} |
| 498 |
|
| 499 |
public function renderRecaptchaSecretKey() { |
| 500 |
|
| 501 |
$field_val = get_option( 'getwid_recaptcha_v2_secret_key', '' ); |
| 502 |
?> |
| 503 |
<input type="text" id="getwid_recaptcha_v2_secret_key" name="getwid_recaptcha_v2_secret_key" class="regular-text" value="<?php echo esc_attr( $field_val ); ?>" /> |
| 504 |
<?php |
| 505 |
} |
| 506 |
|
| 507 |
public function renderMailchimpApiKey() { |
| 508 |
|
| 509 |
$field_val = get_option( 'getwid_mailchimp_api_key', '' ); |
| 510 |
?> |
| 511 |
<input type="text" id="getwid_mailchimp_api_key" name="getwid_mailchimp_api_key" class="regular-text" value="<?php echo esc_attr( $field_val ); ?>" /> |
| 512 |
<?php |
| 513 |
} |
| 514 |
|
| 515 |
public function renderDisabledBlocks() { |
| 516 |
|
| 517 |
$blocks = getwid()->blocksManager()->getControlledBlocks(); |
| 518 |
$disabledBlocks = getwid()->blocksManager()->getDisabledBlocks(); |
| 519 |
ksort( $blocks ); |
| 520 |
?> |
| 521 |
<p class="description"> |
| 522 |
<?php |
| 523 |
printf( |
| 524 |
//translators: %1$s, %2$s is a number of total and disabled blocks |
| 525 |
esc_html__( 'Total: %1$s, Disabled: %2$s', 'getwid' ), |
| 526 |
esc_html( sizeof( $blocks ) ), |
| 527 |
esc_html( sizeof( $disabledBlocks ) ) |
| 528 |
); |
| 529 |
?> |
| 530 |
<br/> |
| 531 |
<input type="button" id="getwid-disabled-blocks-select-all" class="button button-link" value="<?php esc_html_e( 'Select All', 'getwid' ); ?>" /> |
| 532 |
/ |
| 533 |
<input type="button" id="getwid-disabled-blocks-deselect-all" class="button button-link" value="<?php esc_html_e( 'Deselect All', 'getwid' ); ?>" /> |
| 534 |
</p> |
| 535 |
<fieldset id="getwid-disabled-blocks"> |
| 536 |
<?php |
| 537 |
foreach ( $blocks as $name => $block ) { |
| 538 |
$option_name = $block->get_disabled_option_key(); |
| 539 |
?> |
| 540 |
<label for="<?php echo esc_attr( $option_name ); ?>"> |
| 541 |
<input type="checkbox" id="<?php echo esc_attr( $option_name ); ?>" name="<?php echo esc_attr( $option_name ); ?>" value="1" |
| 542 |
<?php |
| 543 |
checked( '1', $block->is_disabled() ); |
| 544 |
?> |
| 545 |
/> |
| 546 |
<?php echo esc_html( $block->get_label() ); ?> |
| 547 |
</label><br/> |
| 548 |
<?php |
| 549 |
} |
| 550 |
?> |
| 551 |
</fieldset> |
| 552 |
<script> |
| 553 |
jQuery(document).ready(function(){ |
| 554 |
jQuery('#getwid-disabled-blocks-select-all').click(function(){ |
| 555 |
jQuery('#getwid-disabled-blocks input:checkbox').attr('checked','checked'); |
| 556 |
}); |
| 557 |
jQuery('#getwid-disabled-blocks-deselect-all').click(function(){ |
| 558 |
jQuery('#getwid-disabled-blocks input:checkbox').removeAttr('checked'); |
| 559 |
}); |
| 560 |
}) |
| 561 |
</script> |
| 562 |
<?php |
| 563 |
} |
| 564 |
|
| 565 |
public function renderPostTemplatesTab() { |
| 566 |
?> |
| 567 |
<p><?php esc_html_e( 'Post Templates are used for presenting posts in a certain format and style. You can change how a post looks by choosing a post template in the Custom Post Type and related blocks.', 'getwid' ); ?></p> |
| 568 |
<a class="button button-primary" href="<?php echo esc_url( admin_url( 'edit.php?post_type=getwid_template_part' ) ); ?>"><?php esc_html_e( 'Manage Post Templates', 'getwid' ); ?></a> |
| 569 |
<?php |
| 570 |
} |
| 571 |
|
| 572 |
public function renderAnimation() { |
| 573 |
|
| 574 |
$field_val = get_option( 'getwid_smooth_animation', false ); |
| 575 |
?> |
| 576 |
<label for="getwid_smooth_animation"> |
| 577 |
<input type="checkbox" id="getwid_smooth_animation" name="getwid_smooth_animation" value="1" |
| 578 |
<?php |
| 579 |
checked( '1', $field_val ); |
| 580 |
?> |
| 581 |
/> |
| 582 |
<?php echo esc_html__( 'Enable smooth animation of blocks', 'getwid' ); ?> |
| 583 |
</label> |
| 584 |
<p class="description"> |
| 585 |
<?php |
| 586 |
echo esc_html__( 'Hides block until the entrance animation starts. Prevents possible occurrence of horizontal scroll during the animation.', 'getwid' ); |
| 587 |
?> |
| 588 |
</p> |
| 589 |
<?php |
| 590 |
} |
| 591 |
|
| 592 |
public function getTabUrl( $tab = 'general' ) { |
| 593 |
return add_query_arg( |
| 594 |
array( |
| 595 |
'page' => 'getwid', |
| 596 |
'active_tab' => $tab, |
| 597 |
), |
| 598 |
admin_url( 'options-general.php' ) |
| 599 |
); |
| 600 |
} |
| 601 |
|
| 602 |
private function getActiveTabID() { |
| 603 |
$tab_param_isset = isset( $_GET['active_tab'] ) && array_key_exists( $_GET['active_tab'], $this->getSettingsGroups() ); |
| 604 |
return $tab_param_isset ? sanitize_text_field( wp_unslash( $_GET['active_tab'] ) ) : 'general'; |
| 605 |
} |
| 606 |
} |
| 607 |
|