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