Mailpoet_Helpers::get_all_mailpoet_subscribers( $label = null,  $option_code = 'MAILPOETSUBSCRIBERS',  $args = array() )


Source Source

File: src/integrations/mailpoet/helpers/mailpoet-helpers.php

	public function get_all_mailpoet_subscribers( $label = null, $option_code = 'MAILPOETSUBSCRIBERS', $args = array() ) {
		if ( ! $this->load_options ) {


			return Automator()->helpers->recipe->build_default_options_array( $label, $option_code );
		}

		if ( ! $label ) {
			$label = esc_attr__( 'Subscriber', 'uncanny-automator' );
		}

		$options = array();

		global $wpdb;

		$subscribers = $wpdb->get_results( "SELECT id,email FROM {$wpdb->prefix}mailpoet_subscribers  ORDER BY id DESC", ARRAY_A );

		foreach ( $subscribers as $subscriber ) {
			$options[ $subscriber['id'] ] = $subscriber['email'];
		}

		$option = [
			'option_code'     => $option_code,
			'label'           => $label,
			'input_type'      => 'select',
			'required'        => true,
			'options'         => $options,
			'relevant_tokens' => [
				$option_code         => esc_attr__( 'Subscriber', 'uncanny-automator' ),
				$option_code . '_ID' => esc_attr__( 'Subscriber ID', 'uncanny-automator' ),
			],
		];

		return apply_filters( 'uap_option_get_all_mailpoet_subscribers', $option );
	}