make sure ABSPATH is defined before using it - fixes issue #648
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
<?php
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
namespace MailPoet\API;
|
||||
|
||||
use \MailPoet\Util\Security;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
class API {
|
||||
function init() {
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
namespace MailPoet\API;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
namespace MailPoet\API;
|
||||
|
||||
final class Error {
|
||||
const UNKNOWN = 'unknown';
|
||||
const BAD_REQUEST = 'bad_request';
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
namespace MailPoet\Cron;
|
||||
|
||||
use MailPoet\Cron\Workers\Scheduler as SchedulerWorker;
|
||||
@ -6,8 +8,6 @@ use MailPoet\Cron\Workers\SendingQueue\SendingQueue as SendingQueueWorker;
|
||||
|
||||
require_once(ABSPATH . 'wp-includes/pluggable.php');
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
class Daemon {
|
||||
public $daemon;
|
||||
public $request_data;
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
namespace MailPoet\Cron\Workers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
@ -12,7 +14,6 @@ use MailPoet\Newsletter\Scheduler\Scheduler as NewsletterScheduler;
|
||||
|
||||
require_once(ABSPATH . 'wp-includes/pluggable.php');
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
class Scheduler {
|
||||
public $timer;
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
namespace MailPoet\Form\Block;
|
||||
|
||||
class Checkbox extends Base {
|
||||
@ -50,4 +52,3 @@ class Checkbox extends Base {
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
namespace MailPoet\Form\Block;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
namespace MailPoet\Form\Block;
|
||||
|
||||
class Radio extends Base {
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
namespace MailPoet\Form\Block;
|
||||
|
||||
class Segment extends Base {
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
namespace MailPoet\Form\Block;
|
||||
|
||||
class Select extends Base {
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
namespace MailPoet\Form\Block;
|
||||
|
||||
class Submit extends Base {
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
namespace MailPoet\Form\Block;
|
||||
|
||||
class Text extends Base {
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
namespace MailPoet\Form\Block;
|
||||
|
||||
class Textarea extends Base {
|
||||
|
@ -1,11 +1,10 @@
|
||||
<?php
|
||||
namespace MailPoet\Mailer;
|
||||
|
||||
use MailPoet\Models\Setting;
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
require_once(ABSPATH . 'wp-includes/pluggable.php');
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
namespace MailPoet\Mailer;
|
||||
use MailPoet\Models\Setting;
|
||||
|
||||
class Mailer {
|
||||
public $mailer_config;
|
||||
|
@ -1,11 +1,12 @@
|
||||
<?php
|
||||
namespace MailPoet\Newsletter\Shortcodes\Categories;
|
||||
|
||||
use MailPoet\Models\SendingQueue;
|
||||
use MailPoet\Newsletter\Shortcodes\ShortcodesHelper;
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
require_once( ABSPATH . "wp-includes/pluggable.php" );
|
||||
|
||||
namespace MailPoet\Newsletter\Shortcodes\Categories;
|
||||
use MailPoet\Models\SendingQueue;
|
||||
use MailPoet\Newsletter\Shortcodes\ShortcodesHelper;
|
||||
|
||||
class Newsletter {
|
||||
static function process($action,
|
||||
$default_value = false,
|
||||
|
@ -1,11 +1,12 @@
|
||||
<?php
|
||||
namespace MailPoet\Newsletter\Shortcodes\Categories;
|
||||
|
||||
use MailPoet\Models\Subscriber as SubscriberModel;
|
||||
use MailPoet\Models\SubscriberCustomField;
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
require_once(ABSPATH . 'wp-includes/pluggable.php');
|
||||
|
||||
namespace MailPoet\Newsletter\Shortcodes\Categories;
|
||||
use MailPoet\Models\Subscriber as SubscriberModel;
|
||||
use MailPoet\Models\SubscriberCustomField;
|
||||
|
||||
class Subscriber {
|
||||
static function process(
|
||||
$action,
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
namespace MailPoet\Twig;
|
||||
|
||||
class Assets
|
||||
|
@ -1,11 +1,10 @@
|
||||
<?php
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
namespace MailPoet\Twig;
|
||||
|
||||
class Functions extends \Twig_Extension {
|
||||
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
function getName() {
|
||||
return 'functions';
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
<?php
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
namespace MailPoet\Twig;
|
||||
|
||||
class Handlebars extends \Twig_Extension {
|
||||
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return 'handlebars';
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
namespace MailPoet\Twig;
|
||||
|
||||
class I18n extends \Twig_Extension {
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
namespace MailPoet\Util;
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
require_once(ABSPATH . 'wp-includes/pluggable.php');
|
||||
|
||||
namespace MailPoet\Util;
|
||||
|
||||
class Security {
|
||||
static function generateToken() {
|
||||
return wp_create_nonce('mailpoet_token');
|
||||
|
@ -1,8 +1,9 @@
|
||||
<?php
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
namespace Sudzy;
|
||||
|
||||
abstract class ValidModel extends \Model
|
||||
{
|
||||
abstract class ValidModel extends \Model {
|
||||
protected $_validator = null; // Reference to Sudzy validator object
|
||||
protected $_validations = array(); // Array of validations
|
||||
protected $_validationErrors = array(); // Array of error messages
|
||||
@ -13,7 +14,7 @@ abstract class ValidModel extends \Model
|
||||
'throw' => self::ON_SAVE // One of self::ON_SET|ON_SAVE|NEVER.
|
||||
// + ON_SET throws immediately when field is set()
|
||||
// + ON_SAVE throws on save()
|
||||
// + NEVER means an exception is never thrown; check for ->getValidaionErrors()
|
||||
// + NEVER means an exception is never thrown; check for ->getValidationErrors()
|
||||
);
|
||||
|
||||
const ON_SET = 'set';
|
||||
@ -24,8 +25,7 @@ abstract class ValidModel extends \Model
|
||||
$this->_validator = $validatorInstance;
|
||||
}
|
||||
|
||||
public function setValidationOptions($options)
|
||||
{
|
||||
public function setValidationOptions($options) {
|
||||
$this->_validationOptions = array_merge($this->_validationOptions, $options);
|
||||
}
|
||||
|
||||
@ -63,8 +63,7 @@ abstract class ValidModel extends \Model
|
||||
/**
|
||||
* @return bool Will set a message if returning false
|
||||
**/
|
||||
public function validateField($field, $value)
|
||||
{
|
||||
public function validateField($field, $value) {
|
||||
$this->setupValidationEngine();
|
||||
|
||||
if(!isset($this->_validations[$field])) {
|
||||
@ -89,13 +88,11 @@ abstract class ValidModel extends \Model
|
||||
return $success;
|
||||
}
|
||||
|
||||
public function getValidationErrors()
|
||||
{
|
||||
public function getValidationErrors() {
|
||||
return $this->_validationErrors;
|
||||
}
|
||||
|
||||
public function resetValidationErrors()
|
||||
{
|
||||
public function resetValidationErrors() {
|
||||
$this->_validationErrors = array();
|
||||
}
|
||||
|
||||
@ -105,16 +102,14 @@ abstract class ValidModel extends \Model
|
||||
/**
|
||||
* Overload __set to call validateAndSet
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
public function __set($name, $value) {
|
||||
$this->validateAndSet($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overload save; checks if errors exist before saving
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
public function save() {
|
||||
if($this->isNew()) { //Fields populated by create() or hydrate() don't pass through set()
|
||||
foreach(array_keys($this->_validations) as $field) {
|
||||
$this->validateField($field, $this->$field);
|
||||
@ -132,8 +127,7 @@ abstract class ValidModel extends \Model
|
||||
/**
|
||||
* Overload set; to call validateAndSet
|
||||
*/
|
||||
public function set($key, $value = null)
|
||||
{
|
||||
public function set($key, $value = null) {
|
||||
if(is_array($key)) {
|
||||
// multiple values
|
||||
foreach($key as $field => $value) {
|
||||
@ -147,15 +141,13 @@ abstract class ValidModel extends \Model
|
||||
|
||||
////////////////////
|
||||
// Protected methods
|
||||
protected function doValidationError($context)
|
||||
{
|
||||
protected function doValidationError($context) {
|
||||
if($context == $this->_validationOptions['throw']) {
|
||||
throw new \Sudzy\ValidationException($this->_validationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
protected function addValidationError($msg, $field = null)
|
||||
{
|
||||
protected function addValidationError($msg, $field = null) {
|
||||
if($this->_validationOptions['indexedErrors'] && $field !== null) {
|
||||
// Only keep the first error found on a field
|
||||
if(!isset($this->_validationErrors[$field])) {
|
||||
@ -169,14 +161,12 @@ abstract class ValidModel extends \Model
|
||||
/**
|
||||
* Overload set; to call validateAndSet
|
||||
*/
|
||||
protected function validateAndSet($name, $value)
|
||||
{
|
||||
protected function validateAndSet($name, $value) {
|
||||
if(!$this->validateField($name, $value)) $this->doValidationError(self::ON_SET);
|
||||
parent::set($name, $value);
|
||||
}
|
||||
|
||||
protected function setupValidationEngine()
|
||||
{
|
||||
protected function setupValidationEngine() {
|
||||
if(null == $this->_validator) $this->_validator = new \Sudzy\Engine(); // Is lazy setup worth it?
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user