Skip to content

Commit

Permalink
Merge ab192a0 into 986af40
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Herman committed Jun 4, 2018
2 parents 986af40 + ab192a0 commit 40eaebd
Show file tree
Hide file tree
Showing 11 changed files with 1,426 additions and 1,334 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Expand Up @@ -25,6 +25,13 @@ env:
- WP_VERSION=latest WP_MULTISITE=0
- WP_VERSION=trunk WP_MULTISITE=0

addons:
chrome: stable
apt:
packages:
# Needed for `xmllint`.
- libxml2-utils

matrix:
fast_finish: true
exclude:
Expand Down
2 changes: 1 addition & 1 deletion Gruntfile.js
Expand Up @@ -185,7 +185,7 @@ module.exports = function( grunt ) {
tasks: [ 'imagemin' ]
},
js: {
files: [ '**/*.js', '!**/*.min.js' ],
files: [ 'js/**/*.js', '!js/**/*.min.js' ],
tasks: [ 'jshint', 'uglify' ]
},
readme: {
Expand Down
26 changes: 14 additions & 12 deletions godaddy-email-marketing.php
Expand Up @@ -76,14 +76,14 @@ public static function instance() {
*/
private function setup_actions() {
add_action( 'plugins_loaded', array( $this, 'i18n' ) );
add_action( 'init', array( $this, 'init' ) );
add_action( 'widgets_init', array( $this, 'register_widget' ) );
add_action( 'init', array( $this, 'register_shortcode' ), 20 );
add_action( 'admin_notices', array( $this, 'action_admin_notices' ) );
add_action( 'init', array( $this, 'init' ) );
add_action( 'widgets_init', array( $this, 'register_widget' ) );
add_action( 'init', array( $this, 'register_shortcode' ), 20 );
add_action( 'admin_notices', array( $this, 'action_admin_notices' ) );

add_filter( 'plugin_action_links_' . self::$basename, array( $this, 'action_links' ), 10 );

register_activation_hook( __FILE__, array( $this, 'activate' ) );
register_activation_hook( __FILE__, array( $this, 'activate' ) );
register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
}

Expand Down Expand Up @@ -111,7 +111,7 @@ private function setup_constants() {
or define( 'GEM_VERSION', '1.2.1' );

// Set up the base name.
isset( self::$basename ) || self::$basename = plugin_basename( __FILE__ );
self::$basename = isset( self::$basename ) ? self::$basename : plugin_basename( __FILE__ );
}

/**
Expand Down Expand Up @@ -198,11 +198,11 @@ public function enqueue() {

// Help strings.
wp_localize_script( 'gem-main', 'GEM', array(
'thankyou' => __( 'Thank you for signing up!', 'godaddy-email-marketing' ),
'thankyou' => __( 'Thank you for signing up!', 'godaddy-email-marketing' ),
'thankyou_suppressed' => __( 'Thank you for signing up! Please check your email to confirm your subscription.', 'godaddy-email-marketing' ),
'oops' => __( 'Oops! There was a problem. Please try again.', 'godaddy-email-marketing' ),
'email' => __( 'Please enter a valid email address.', 'godaddy-email-marketing' ),
'required' => _x( '%s is a required field.', 'Name of required field', 'godaddy-email-marketing' ),
'oops' => __( 'Oops! There was a problem. Please try again.', 'godaddy-email-marketing' ),
'email' => __( 'Please enter a valid email address.', 'godaddy-email-marketing' ),
'required' => /* translators: Name of required field */__( '%s is a required field.', 'godaddy-email-marketing' ),
) );
}

Expand Down Expand Up @@ -246,6 +246,7 @@ public function action_admin_notices() {
<p>
<?php
printf(
/* translators: Link to settings page. */
__( 'Your website has a superpower: Email marketing. %1$s.', 'godaddy-email-marketing' ),
'<a href="' . admin_url( 'options-general.php?page=gem-settings' ) . '">' . __( 'Learn More', 'godaddy-email-marketing' ) . '</a>'
);
Expand All @@ -264,11 +265,12 @@ public function action_admin_notices() {
return;
}

$version = get_option( 'gem-version' );
$version = get_option( 'gem-version' );
$settings = get_option( 'gem-settings' );

if ( ! $version && ( empty( $settings['username'] ) || empty( $settings['api-key'] ) ) ) {
update_option( 'gem-version', GEM_VERSION ); ?>
update_option( 'gem-version', GEM_VERSION );
?>

<div class="updated fade">
<p>
Expand Down
35 changes: 18 additions & 17 deletions includes/class-dispatcher.php
Expand Up @@ -83,14 +83,14 @@ public static function add_default_form() {

// Prepare the URL that includes our credentials.
$response = wp_remote_post( self::get_api_base_url( 'api/v3/signupForms' ), array(
'method' => 'POST',
'method' => 'POST',
'timeout' => 10,
'body' => array(
'username' => $username,
'api_key' => $api_key,
'name' => 'Signup Form',
'integration' => 'WordPress',
'hidden' => false,
'body' => array(
'username' => $username,
'api_key' => $api_key,
'name' => 'Signup Form',
'integration' => 'WordPress',
'hidden' => false,
'subscriberListName' => 'WordPress',
),
) );
Expand All @@ -114,8 +114,8 @@ public static function get_forms() {
if ( ! $username ) {
return false;
}

if ( false === ( $data = get_transient( 'gem-' . $username . '-lists' ) ) ) {
$data = get_transient( 'gem-' . $username . '-lists' );
if ( false === $data ) {
$data = self::fetch_forms();
}

Expand All @@ -129,7 +129,8 @@ public static function get_forms() {
* @return false|object The form fields JSON object or false.
*/
public static function get_fields( $form_id ) {
if ( false === ( $data = get_transient( 'gem-form-' . $form_id ) ) ) {
$data = get_transient( 'gem-form-' . $form_id );
if ( false === $data ) {

// Fields are not cached. fetch and cache.
$response = wp_remote_get( self::get_method_url( 'fields', array(
Expand Down Expand Up @@ -160,9 +161,9 @@ public static function get_user_level() {
if ( ! $username ) {
return false;
}

if ( false === ( $data = get_transient( 'gem-' . $username . '-account' ) ) ) {
$data = false;
$data = get_transient( 'gem-' . $username . '-account' );
if ( false === $data ) {
$data = false;
$request = wp_remote_get( self::get_method_url( 'account' ) );

// If the request has failed for whatever reason.
Expand Down Expand Up @@ -219,20 +220,20 @@ public static function get_api_base_url( $path = '' ) {
public static function get_method_url( $method, $params = array(), $auth = false ) {
$auth = $auth ? $auth : array(
'username' => GEM_Settings_Controls::get_option( 'username' ),
'api_key' => GEM_Settings_Controls::get_option( 'api-key' ),
'api_key' => GEM_Settings_Controls::get_option( 'api-key' ),
);

$path = '';

switch ( $method ) {

case 'forms' :
case 'forms':
$path = add_query_arg( $auth, 'signups.json' );
break;
case 'fields' :
case 'fields':
$path = add_query_arg( $auth, 'signups/' . $params['id'] . '.json' );
break;
case 'account' :
case 'account':
$path = add_query_arg( $auth, 'user/account_status' );
break;
}
Expand Down
14 changes: 7 additions & 7 deletions includes/class-shortcode.php
Expand Up @@ -20,15 +20,15 @@ class GEM_Shortcode {
* @return string|void
*/
public function render( $atts ) {
extract( shortcode_atts( array(
$atts = shortcode_atts( array(
'id' => false,
), $atts ) );
), $atts );

if ( ! $id ) {
if ( ! $atts['id'] ) {
return;
}

return gem_form( $id, false );
return gem_form( $atts['id'], false );
}

/**
Expand All @@ -47,9 +47,9 @@ public function shortcode_ui() {
reset( $options );

$args = array(
'label' => esc_html__( 'GoDaddy Email Marketing', 'godaddy-email-marketing' ),
'label' => esc_html__( 'GoDaddy Email Marketing', 'godaddy-email-marketing' ),
'listItemImage' => 'dashicons-feedback',
'attrs' => array(
'attrs' => array(
array(
'label' => esc_html__( 'Signup Forms', 'godaddy-email-marketing' ),
'description' => esc_html__( 'Choose one of the available forms.', 'godaddy-email-marketing' ),
Expand Down Expand Up @@ -81,7 +81,7 @@ public function shortcode_ui() {
function gem_form( $id, $echo = true ) {
if ( class_exists( 'GEM_Form_Renderer', false ) ) {
$renderer = new GEM_Form_Renderer();
$form = $renderer->process( $id, false );
$form = $renderer->process( $id, false );

if ( ! $echo ) {
return $form;
Expand Down

0 comments on commit 40eaebd

Please sign in to comment.