Plugin Directory

Changeset 1404847


Ignore:
Timestamp:
04/26/2016 06:50:22 PM (10 years ago)
Author:
AronMS
Message:

fixed potential namespacing issue and bugs

Location:
drafty-in-here/trunk
Files:
2 added
2 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • drafty-in-here/trunk

    • Property svn:global-ignores set to
      .git
      tests
    • Property svn:ignore set to
      *.sublime-project
      *.sublime-workspace
      .gitignore
      .travis.yml
      phpunit.xml.dist
  • drafty-in-here/trunk/Repositories/Admin/Admin.php

    r1392348 r1404847  
    1 <?php namespace Repositories\Admin;
     1<?php namespace Drafty\Repositories\Admin;
    22
    33use \Drafty_In_Here;
    4 use Repositories\Scheduler\Scheduler;
    5 use Repositories\Options\Options;
     4use Drafty\Repositories\Scheduler\Scheduler;
     5use Drafty\Repositories\Options\Options;
    66
    77class Admin extends Drafty_In_Here implements AdminInterface
     
    136136    public function validate_basic_options_section($settings_array = array())
    137137    {
    138         if ( ! is_email( $settings_array['email_address'] ) ) {
     138        if ( empty($settings_array['email_address']) || ! is_email( $settings_array['email_address'] ) ) {
    139139            $settings_array['email_address'] = '';
    140140            add_settings_error( 'email_address', 'invalid_email', __( 'Please enter a valid email address.', 'drafty-in-here' ), 'error' );
    141141        }
    142142
    143         if ( ! in_array( $settings_array['drafty_frequency'], array('never', 'hourly', 'daily', 'weekly') ) ) {
     143        if ( empty($settings_array['drafty_frequency']) || ! in_array( $settings_array['drafty_frequency'], array('never', 'hourly', 'daily', 'weekly') ) ) {
    144144            $settings_array['drafty_frequency'] = '';
    145145            add_settings_error( 'email_address', 'invalid_email', __( 'Please select how often we send emails.', 'drafty-in-here' ), 'error' );
  • drafty-in-here/trunk/Repositories/Admin/AdminInterface.php

    r1364715 r1404847  
    1 <?php namespace Repositories\Admin;
     1<?php namespace Drafty\Repositories\Admin;
    22
    33interface AdminInterface
  • drafty-in-here/trunk/Repositories/Email/Email.php

    r1364715 r1404847  
    1 <?php namespace Repositories\Email;
     1<?php namespace Drafty\Repositories\Email;
    22
    33use Repositories\Email\EmailerInterface;
     4use Drafty\Repositories\Email\EmailInterface;
    45
    56class Email implements EmailInterface
     
    5859    {
    5960        self::buildMessage();
    60         if (self::validate(self::$to, self::$subject, self::$message)) {
     61        if (true === self::validate(self::$to, self::$subject, self::$message)) {
    6162            return wp_mail(self::$to, self::$subject, self::$message, self::$headers);
    6263        }
     
    7172     * @param  string $subject The subject of the email.
    7273     * @param  string $message The content of the email.
    73      * @return bool            Weather validation passes.
     74     * @return bool|\WP_Error
    7475     */
    75     private static function validate($to='', $subject='', $message='')
     76    public static function validate($to='', $subject='', $message='')
    7677    {
    77         $valid = true;
    7878        if (! is_email($to)) {
    7979            return new \WP_Error( 'drafty-email', __( "Can't send email because email is not valid.", 'drafty-in-here' ) );
    80             $valid = false;
    8180        }
    8281        if (empty($subject)) {
    8382            return new \WP_Error( 'drafty-email', __( "Can't send email because there is no subject.", 'drafty-in-here' ) );
    84             $valid = false;
    8583        }
    8684        if (empty($message)) {
    8785            return new \WP_Error( 'drafty-email', __( "Can't send email because there is no message.", 'drafty-in-here' ) );
    88             $valid = false;
    8986        }
    9087
    91         return $valid;
     88        return true;
    9289    }
    9390
  • drafty-in-here/trunk/Repositories/Email/EmailInterface.php

    r1364715 r1404847  
    1 <?php namespace Repositories\Email;
     1<?php namespace Drafty\Repositories\Email;
    22
    33interface EmailInterface
  • drafty-in-here/trunk/Repositories/Options/Options.php

    r1392348 r1404847  
    1 <?php namespace Repositories\Options;
     1<?php namespace Drafty\Repositories\Options;
     2
     3use Drafty\Repositories\Options\OptionsInterface;
    24
    35class Options implements OptionsInterface
  • drafty-in-here/trunk/Repositories/Options/OptionsInterface.php

    r1364715 r1404847  
    1 <?php namespace Repositories\Options;
     1<?php namespace Drafty\Repositories\Options;
    22
    33interface OptionsInterface
  • drafty-in-here/trunk/Repositories/Scheduler/Scheduler.php

    r1394736 r1404847  
    1 <?php namespace Repositories\Scheduler;
     1<?php namespace Drafty\Repositories\Scheduler;
    22
    3 use Repositories\Options\Options;
     3use Drafty\Repositories\Options\Options;
     4use Drafty\Repositories\Scheduler\SchedulerInterface;
    45
    56class Scheduler implements SchedulerInterface
  • drafty-in-here/trunk/Repositories/Scheduler/SchedulerInterface.php

    r1364715 r1404847  
    1 <?php namespace Repositories\Scheduler;
     1<?php namespace Drafty\Repositories\Scheduler;
    22
    33interface SchedulerInterface
  • drafty-in-here/trunk/drafty-in-here.php

    r1394736 r1404847  
    22/**
    33 * Plugin Name: Drafty In Here
    4  * Version:     1.1.2
     4 * Version:     1.1.3
    55 * Plugin URI:  https://wordpress.org/plugins/drafty-in-here/
    66 * Author:      Aron Marriott-Smith <aron@atomace.com>
  • drafty-in-here/trunk/drafty-main.php

    r1392348 r1404847  
    1111 */
    1212require_once 'vendor/autoload.php';
    13 use Repositories\Admin\Admin;
    14 use Repositories\Email\Email;
    15 use Repositories\Options\Options;
    16 use Repositories\Scheduler\Scheduler;
     13use Drafty\Repositories\Admin\Admin;
     14use Drafty\Repositories\Email\Email;
     15use Drafty\Repositories\Options\Options;
     16use Drafty\Repositories\Scheduler\Scheduler;
    1717
    1818
     
    210210     *
    211211     * Here we build up the email contents and pass it to our Email class.
    212      *
     212     * @todo: return a call to an event rather than boolean
     213     *
    213214     * @param  bool $test Weather we are testing the callback or not
    214215     * @return bool|void If no draft posts are found returns false
     
    221222            // we have no posts
    222223            if (false === $test) return false;
    223             $posts=null;
    224         }
    225 
    226         $to = self::$options['email_address'];
    227         $subject = __('You have drafts waiting to be published', 'drafty-in-here');
    228         $text = $this->build_message($posts, $test);
    229         $html = nl2br($text);
    230 
    231         return Email::to($to)->subject($subject)->text($text)->HTML($html)->send();
     224            $posts = null;
     225        }
     226       
     227        if ( $test || $posts) {
     228            $to = self::$options['email_address'];
     229            $subject = __('You have drafts waiting to be published', 'drafty-in-here');
     230            $text = $this->build_message($posts, $test);
     231            $html = nl2br($text);
     232           
     233            Email::to($to)->subject($subject)->text($text)->HTML($html)->send();
     234           
     235            return true;
     236        }
     237       
     238        return false;
    232239    }
    233240
  • drafty-in-here/trunk/readme.txt

    r1394736 r1404847  
    22Contributors: AronMS
    33Tags: productivity, focus, motivation, drafts, draft posts, notify, emails, drafty
    4 Requires at least: 4.0
     4Requires at least: 4.3
    55Tested up to: 4.5
    6 Stable tag: 1.1.2
     6Stable tag: 1.1.3
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7878= 1.1.2 =
    7979* Fixed a bug which was causing a PHP fatal error in the drafty settings page.
     80= 1.1.3 =
     81* Fixed potential namespacing issue
     82* Several bug fixes identified while writing unit tests
    8083
    8184
  • drafty-in-here/trunk/vendor/composer/LICENSE

    r1364715 r1404847  
    11
    2 Copyright (c) 2015 Nils Adermann, Jordi Boggiano
     2Copyright (c) 2016 Nils Adermann, Jordi Boggiano
    33
    44Permission is hereby granted, free of charge, to any person obtaining a copy
  • drafty-in-here/trunk/vendor/composer/autoload_psr4.php

    r1392348 r1404847  
    77
    88return array(
    9     'Repositories\\' => array($baseDir . '/Repositories'),
     9    'Drafty\\Repositories\\' => array($baseDir . '/Repositories'),
    1010);
Note: See TracChangeset for help on using the changeset viewer.