'array', 'sanitize_callback' => 'agentprose_sanitize', 'default' => agentprose_defaults(), ) ); } add_action( 'admin_init', 'agentprose_register_setting' ); /** * Sanitizes the submitted settings. * * @param mixed $in Raw input. * @return array */ function agentprose_sanitize( $in ) { $in = is_array( $in ) ? $in : array(); $d = agentprose_defaults(); $key = isset( $in['cloud_key'] ) ? trim( sanitize_text_field( $in['cloud_key'] ) ) : ''; if ( '' !== $key && ! preg_match( '/^pk_[A-Za-z0-9_-]{8,64}$/', $key ) ) { add_settings_error( 'agentprose', 'agentprose_cloud_key', __( 'That does not look like an agentprose Cloud site key (it starts with pk_). The previous key was kept.', 'agentprose' ) ); $key = (string) agentprose_options()['cloud_key']; } $types = isset( $in['types'] ) ? strtolower( sanitize_text_field( $in['types'] ) ) : $d['types']; $types = trim( preg_replace( '/[^a-z0-9_,-]/', '', $types ), ',' ); return array( 'enabled' => empty( $in['enabled'] ) ? 0 : 1, 'types' => '' === $types ? $d['types'] : $types, 'content' => isset( $in['content'] ) ? sanitize_text_field( $in['content'] ) : '', 'prefix' => isset( $in['prefix'] ) ? sanitize_key( $in['prefix'] ) : '', 'subscribe' => isset( $in['subscribe'] ) ? esc_url_raw( $in['subscribe'] ) : '', 'navigate' => empty( $in['navigate'] ) ? 0 : 1, 'inspector' => empty( $in['inspector'] ) ? 0 : 1, 'polyfill' => empty( $in['polyfill'] ) ? 0 : 1, 'cloud_key' => $key, 'cloud_search' => empty( $in['cloud_search'] ) ? 0 : 1, 'analytics' => isset( $in['analytics'] ) ? esc_url_raw( $in['analytics'] ) : '', ); } /** * Renders a checkbox row. * * @param string $name Option key. * @param string $label Row heading. * @param string $text Checkbox label. * @param string $help Optional description. */ function agentprose_checkbox_row( $name, $label, $text, $help = '' ) { $o = agentprose_options(); ?>

WebMCP' ); ?>

' . esc_html__( 'your site', 'agentprose' ) . '' ); ?>

agentprose Cloud' ); ?>

' . esc_html__( 'Settings', 'agentprose' ) . '' ); return $links; } add_filter( 'plugin_action_links_' . plugin_basename( AGENTPROSE_FILE ), 'agentprose_action_links' );