' . esc_html( $text ) . '

'; } } } function adslastica_save_publisher_settings() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( 'Unauthorized' ); } check_admin_referer( 'adslastica_save_publisher_action', 'adslastica_publisher_nonce' ); $publisher_id = isset( $_POST['adslastica_publisher_id'] ) ? trim( sanitize_text_field( wp_unslash( $_POST['adslastica_publisher_id'] ) ) ) : ''; update_option( 'adslastica_publisher_id', $publisher_id ); wp_safe_redirect( add_query_arg( array( 'page' => 'adslastica', 'adslastica_message' => 'publisher_saved' ), admin_url( 'admin.php' ) ) ); exit; } function adslastica_save_ad_1_settings() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( 'Unauthorized' ); } check_admin_referer( 'adslastica_save_ad_1_action', 'adslastica_ad_1_nonce' ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $ad_code = isset( $_POST['adslastica_manual_ad_1'] ) ? wp_unslash( $_POST['adslastica_manual_ad_1'] ) : ''; update_option( 'adslastica_manual_ad_1', $ad_code ); update_option( 'adslastica_manual_ad_1_enabled', isset( $_POST['adslastica_manual_ad_1_enabled'] ) ? 1 : 0 ); wp_safe_redirect( add_query_arg( array( 'page' => 'adslastica', 'adslastica_message' => 'ad_1_saved' ), admin_url( 'admin.php' ) ) ); exit; } function adslastica_save_ad_2_settings() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( 'Unauthorized' ); } check_admin_referer( 'adslastica_save_ad_2_action', 'adslastica_ad_2_nonce' ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $ad_code = isset( $_POST['adslastica_manual_ad_2'] ) ? wp_unslash( $_POST['adslastica_manual_ad_2'] ) : ''; update_option( 'adslastica_manual_ad_2', $ad_code ); update_option( 'adslastica_manual_ad_2_enabled', isset( $_POST['adslastica_manual_ad_2_enabled'] ) ? 1 : 0 ); wp_safe_redirect( add_query_arg( array( 'page' => 'adslastica', 'adslastica_message' => 'ad_2_saved' ), admin_url( 'admin.php' ) ) ); exit; } function adslastica_enqueue_adsense_header() { $publisher_id = get_option( 'adslastica_publisher_id', '' ); if ( empty( $publisher_id ) || ! preg_match( '/^ca-pub-\d{16}$/', $publisher_id ) ) { return; } wp_enqueue_script( 'adslastica-adsense', 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=' . rawurlencode( $publisher_id ), array(), ADSLASTICA_VERSION, array( 'strategy' => 'async' ) ); } function adslastica_admin_styles( $hook ) { if ( 'toplevel_page_adslastica' !== $hook ) { return; } wp_add_inline_style( 'common', ' .adslastica-wrap { max-width: 900px; } .adslastica-card { background: #ffffff; padding: 20px; border: 1px solid #dcdcde; border-left: 4px solid #2271b1; margin-top: 18px; border-radius: 8px; max-width: 860px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); } .adslastica-card-ad-1 { border-left-color: #2271b1; } .adslastica-card-ad-2 { border-left-color: #00a32a; } .adslastica-shortcode-box { width: 220px; padding: 8px 10px; font-size: 16px; font-family: Consolas, Monaco, monospace; background: #f6f7f7; border: 1px solid #c3c4c7; border-radius: 4px; margin: 8px 0 14px; display: block; box-sizing: border-box; } .adslastica-card h3 { margin-top: 0; color: #1d2327; border-bottom: 1px solid #f0f0f1; padding-bottom: 12px; line-height: 1.4; } .adslastica-card input[type="text"] { width: 100%; max-width: 420px; padding: 8px; margin-bottom: 10px; } .adslastica-card textarea { width: 100%; max-width: 820px; height: 180px; min-height: 180px; font-family: Consolas, Monaco, monospace; font-size: 15px; line-height: 1.6; padding: 12px; background: #f6f7f7; border: 1px solid #c3c4c7; border-radius: 4px; display: block; box-sizing: border-box; } .adslastica-card p.submit { margin-bottom: 0; padding-bottom: 0; } ' ); } function adslastica_render_settings_page() { ?>

Adslastica Settings

Publisher ID

Ad 1

Ad 2

' . get_option( 'adslastica_manual_ad_1', '' ) . ''; } function adslastica_shortcode_manual_ad_2() { if ( ! get_option( 'adslastica_manual_ad_2_enabled' ) ) { return ''; } return '
' . get_option( 'adslastica_manual_ad_2', '' ) . '
'; }