title */ public function get_sections(): array { return [ 'ads_txt_main' => [ 'title' => __( 'Ads.txt settings.', 'adpresso' ), 'description' => '', 'controlled_by' => '', 'initially_open' => true, ], ]; } /** * All ads.txt settings. * * @return array */ protected function define_options(): array { $options = []; $options[ 'enable_module_' . $this->get_id() ] = [ 'section' => 'ads_txt_main', 'label' => __( 'Enable Ads.txt Module', 'adpresso' ), 'type' => 'toggle', 'default' => 0, 'sanitize_type' => 'uint', 'highlighted' => true, 'description' => __( 'Manage the ads.txt file that lists the authorized sellers for your ad inventory.', 'adpresso' ), ]; // Always defined so a save keeps them while the module is off; depends_on hides them then. $options['ads_txt_source'] = [ 'section' => 'ads_txt_main', 'label' => __( 'Ads.txt Source', 'adpresso' ), 'type' => 'button_group', 'html_class' => 'adpresso-color-dark', 'default' => 'virtual', 'options' => [ 'physical' => [ 'key' => 'physical', 'label' => __( 'Physical file in the root directory', 'adpresso' ) ], 'virtual' => [ 'key' => 'virtual', 'label' => __( 'Virtual file generated by AdPresso', 'adpresso' ) ], 'external' => [ 'key' => 'external', 'label' => __( 'File referenced by external URL', 'adpresso' ) ], ], 'depends_on' => [ [ 'field_id' => 'enable_module_' . $this->get_id(), 'operator' => 'is', 'value' => 1, ], ], ]; $enable_adsense_auto_ads = Settings::get_setting( 'adsense_enable_auto_ads', false ); $adsense_publisher_id = Settings::get_setting( 'adsense_publisher_id', '' ); $adsense_auto_ads = false; if ( $enable_adsense_auto_ads && ! empty( $adsense_publisher_id ) ) { $adsense_auto_ads = true; } $ads_txt_custom_lines_placeholder = sprintf( 'google.com, %s, DIRECT, f08c47fec0942fa0', $adsense_auto_ads ? $adsense_publisher_id : 'pub-0000000000000000' ); $options['ads_txt_custom_lines'] = [ 'section' => 'ads_txt_main', 'label' => __( 'Entries', 'adpresso' ), 'type' => 'textarea', 'description' => __( 'AdPresso will deliver the following content as your ads.txt. Add one entry per line.', 'adpresso' ), 'placeholder' => $ads_txt_custom_lines_placeholder, 'depends_on' => [ [ 'field_id' => 'enable_module_' . $this->get_id(), 'operator' => 'is', 'value' => 1, ], [ 'field_id' => 'ads_txt_source', 'operator' => 'is', 'value' => 'virtual', ], ], ]; $options['ads_txt_external_url'] = [ 'type' => 'text', 'section' => 'ads_txt_main', 'label' => __( 'External URL', 'adpresso' ), 'description' => __( 'Enter the complete URL for an external ads.txt file, which will be used as the source (e.g., https://example.com/ads.txt).', 'adpresso' ), 'placeholder' => 'https://example.com/ads.txt', 'default' => '', 'depends_on' => [ [ 'field_id' => 'enable_module_' . $this->get_id(), 'operator' => 'is', 'value' => 1, ], [ 'field_id' => 'ads_txt_source', 'operator' => 'is', 'value' => 'external', ], ], ]; return $options; } }