' . esc_html__( 'Dotatie: the widget token is missing or not valid. Paste the embed code from your Dotatie dashboard again.', 'dotatie' ) . '

'; } return ''; } wp_enqueue_script( 'dotatie-widgets' ); return '
'; } /** * Block render callback. * * @param array $attributes Block attributes. * @return string */ function dotatie_render_block( $attributes ) { return dotatie_render( isset( $attributes['token'] ) ? $attributes['token'] : '', get_block_wrapper_attributes() ); } /** * Shortcode: [dotatie token="..."]. * * @param array|string $atts Shortcode attributes. * @return string */ function dotatie_shortcode( $atts ) { $atts = shortcode_atts( array( 'token' => '' ), $atts, 'dotatie' ); return dotatie_render( $atts['token'] ); } /** * Register the loader script, the block and the shortcode. */ function dotatie_init() { wp_register_script( 'dotatie-widgets', DOTATIE_SCRIPT, array(), DOTATIE_VERSION, array( 'in_footer' => true, 'strategy' => 'defer', ) ); register_block_type( __DIR__ . '/block', array( 'render_callback' => 'dotatie_render_block' ) ); add_shortcode( 'dotatie', 'dotatie_shortcode' ); } add_action( 'init', 'dotatie_init' ); /** * Add the instructions page under Settings. */ function dotatie_admin_menu() { add_options_page( __( 'Dotatie donation form', 'dotatie' ), 'Dotatie', 'manage_options', 'dotatie', 'dotatie_admin_page' ); } add_action( 'admin_menu', 'dotatie_admin_menu' ); /** * Link to the instructions page from the Plugins screen. * * @param array $links Action links. * @return array */ function dotatie_action_links( $links ) { $url = admin_url( 'options-general.php?page=dotatie' ); array_unshift( $links, '' . esc_html__( 'Get started', 'dotatie' ) . '' ); return $links; } add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'dotatie_action_links' ); /** * Remember the activation, so the next admin page shows where to start. */ function dotatie_activate() { set_transient( 'dotatie_activated', 1, MINUTE_IN_SECONDS ); } register_activation_hook( __FILE__, 'dotatie_activate' ); /** * One-time notice after activation: a Dotatie account is needed, and where to create it. */ function dotatie_activation_notice() { if ( ! get_transient( 'dotatie_activated' ) || ! current_user_can( 'manage_options' ) ) { return; } delete_transient( 'dotatie_activated' ); printf( '

%s %s

', esc_html__( 'To show a donation form on your site you need a Dotatie account. Creating one is free.', 'dotatie' ), esc_url( admin_url( 'options-general.php?page=dotatie' ) ), esc_html__( 'Get started', 'dotatie' ) ); } add_action( 'admin_notices', 'dotatie_activation_notice' ); /** * Instructions page. There are no settings to save. */ function dotatie_admin_page() { ?>

' . esc_html__( 'pricing', 'dotatie' ) . '' ); ?>

  1. ' . esc_html__( 'open widgets', 'dotatie' ) . '' ); ?>
  2. [dotatie token="…"]' ); ?>

' . esc_html__( 'Dotatie privacy policy', 'dotatie' ) . '' ); ?>